summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-02 20:34:11 -0400
committerJan Holesovsky <kendy@collabora.com>2018-05-22 12:17:10 +0200
commitdbbf8641e9e66c106cf74637ea9e94b56fd588c0 (patch)
tree1db4c3551faebd8697d4c5727d06b3b9a7058b27
parent9510d017af8f36953bd17ac4ae4ab7768684665c (diff)
vcl: svx: preserve the imported PDF page number in Graphic
Change-Id: I1bb3fa7d44d5f92df2bb8c4ed4b85ccd984c2617
-rw-r--r--include/svx/svdograf.hxx7
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx1
-rw-r--r--svx/source/svdraw/svdograf.cxx15
-rw-r--r--vcl/inc/impgraph.hxx3
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx1
-rw-r--r--vcl/source/gdi/impgraph.cxx24
6 files changed, 42 insertions, 9 deletions
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 54e067e00405..6eb65c60fc47 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -21,6 +21,8 @@
#define INCLUDED_SVX_SVDOGRAF_HXX
#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
#include <vcl/graph.hxx>
#include <svx/svdorect.hxx>
#include <svtools/grfmgr.hxx>
@@ -191,6 +193,11 @@ public:
bool isEmbeddedSvg() const;
GDIMetaFile getMetafileFromEmbeddedSvg() const;
+ bool isEmbeddedPdfData() const;
+ std::shared_ptr<css::uno::Sequence<sal_Int8>> getEmbeddedPdfData() const;
+ /// Returns the page number of the embedded data (typically to re-render or import it).
+ sal_Int32 getEmbeddedPageNumber() const;
+
virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 541316372b56..72e8cd503250 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -123,6 +123,7 @@ bool SdPdfFilter::Import()
// Create the Graphic and link the original PDF stream.
Graphic aGraphic(aBitmap);
aGraphic.setPdfData(pPdfData);
+ aGraphic.setPageNumber(nPageNumber);
aGraphic.SetLink(aGfxLink);
aGraphic.setOriginURL(aFileName);
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index c9115151abab..f0fccbfef964 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1085,6 +1085,21 @@ GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const
return GDIMetaFile();
}
+bool SdrGrafObj::isEmbeddedPdfData() const
+{
+ return pGraphic->GetGraphic().hasPdfData();
+}
+
+std::shared_ptr<uno::Sequence<sal_Int8>> SdrGrafObj::getEmbeddedPdfData() const
+{
+ return pGraphic->GetGraphic().getPdfData();
+}
+
+sal_Int32 SdrGrafObj::getEmbeddedPageNumber() const
+{
+ return pGraphic->GetGraphic().getPageNumber();
+}
+
SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
{
SdrObject* pRetval = nullptr;
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index e82b6a8e935c..33b591a81a6c 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -63,9 +63,6 @@ private:
/// this Graphic (a page) from the source in GfxLink or PdfData.
sal_Int32 mnPageNumber;
- std::chrono::high_resolution_clock::time_point maLastUsed;
- bool mbPrepared;
-
ImpGraphic();
ImpGraphic( const ImpGraphic& rImpGraphic );
ImpGraphic( ImpGraphic&& rImpGraphic );
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 36d070c67289..ec45de2af5e7 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -258,6 +258,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
bool bRet = ImportPDF(rStream, aBitmap, aPdfData);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
+ rGraphic.setPageNumber(0); // We currently import only the first page.
return bRet;
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 6fc4d0220410..20c1f7c0834c 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -104,7 +104,8 @@ ImpGraphic::ImpGraphic() :
meType ( GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
- mbDummyContext ( false )
+ mbDummyContext ( false ),
+ mnPageNumber(-1)
{
}
@@ -118,6 +119,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
+ , mnPageNumber(-1)
, maSvgData(rImpGraphic.maSvgData)
, mpPdfData(rImpGraphic.mpPdfData)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
@@ -144,6 +146,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
+ , mnPageNumber(-1)
, maSvgData(std::move(rImpGraphic.maSvgData))
, mpPdfData(std::move(rImpGraphic.mpPdfData))
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
@@ -157,7 +160,8 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
- mbDummyContext ( false )
+ mbDummyContext ( false ),
+ mnPageNumber(-1)
{
}
@@ -166,7 +170,8 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
- mbDummyContext ( false )
+ mbDummyContext ( false ),
+ mnPageNumber(-1)
{
}
@@ -175,7 +180,8 @@ ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
mnSizeBytes( 0UL ),
mbSwapOut( false ),
mbDummyContext ( false ),
- maSvgData(rSvgDataPtr)
+ maSvgData(rSvgDataPtr),
+ mnPageNumber(-1)
{
}
@@ -185,7 +191,8 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
meType ( GraphicType::Bitmap ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
- mbDummyContext ( false )
+ mbDummyContext ( false ),
+ mnPageNumber(-1)
{
}
@@ -194,7 +201,8 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
meType ( GraphicType::GdiMetafile ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
- mbDummyContext ( false )
+ mbDummyContext ( false ),
+ mnPageNumber(-1)
{
}
@@ -213,6 +221,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
maSwapInfo = rImpGraphic.maSwapInfo;
mpContext = rImpGraphic.mpContext;
mbDummyContext = rImpGraphic.mbDummyContext;
+ mnPageNumber = rImpGraphic.mnPageNumber;
maGraphicExternalLink = rImpGraphic.maGraphicExternalLink;
mpAnimation.reset();
@@ -250,6 +259,7 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
maSwapInfo = std::move(rImpGraphic.maSwapInfo);
mpContext = std::move(rImpGraphic.mpContext);
mbDummyContext = rImpGraphic.mbDummyContext;
+ mnPageNumber = rImpGraphic.mnPageNumber;
mpAnimation = std::move(rImpGraphic.mpAnimation);
maEx = std::move(rImpGraphic.maEx);
mbSwapOut = rImpGraphic.mbSwapOut;
@@ -262,6 +272,8 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
rImpGraphic.ImplClear();
rImpGraphic.mbDummyContext = false;
+ rImpGraphic.mnPageNumber = -1;
+
return *this;
}