summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-02 20:34:11 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commit5be75c91086683233e41a5c6562125946b061cf3 (patch)
tree6691732a5753dbd2b89c38484d0993c162618917
parent83e2c70b62226cc50b773beb375241fc0f672365 (diff)
vcl: svx: preserve the imported PDF page number in Graphic
(cherry picked from commit dbbf8641e9e66c106cf74637ea9e94b56fd588c0) Change-Id: I1bb3fa7d44d5f92df2bb8c4ed4b85ccd984c2617
-rw-r--r--include/svx/svdograf.hxx6
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx1
-rw-r--r--svx/source/svdraw/svdograf.cxx15
-rw-r--r--svx/source/xml/xmlgrhlp.cxx2
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx1
-rw-r--r--vcl/source/gdi/impgraph.cxx27
6 files changed, 44 insertions, 8 deletions
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 24f56557df1a..8171f353936d 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -22,6 +22,7 @@
#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 <vcl/GraphicObject.hxx>
@@ -203,6 +204,11 @@ public:
bool isEmbeddedVectorGraphicData() const;
GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() 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 tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 50318a12b46f..4022a0fcb4bc 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -122,6 +122,7 @@ bool SdPdfFilter::Import()
// Create the Graphic and link the original PDF stream.
Graphic aGraphic(aBitmap);
aGraphic.setPdfData(pPdfData);
+ aGraphic.setPageNumber(nPageNumber);
aGraphic.SetGfxLink(aGfxLink);
aGraphic.setOriginURL(aFileName);
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 3dd1356c547e..bb233e476732 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1067,6 +1067,21 @@ GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const
return GDIMetaFile();
}
+bool SdrGrafObj::isEmbeddedPdfData() const
+{
+ return GetGraphic().hasPdfData();
+}
+
+std::shared_ptr<uno::Sequence<sal_Int8>> SdrGrafObj::getEmbeddedPdfData() const
+{
+ return GetGraphic().getPdfData();
+}
+
+sal_Int32 SdrGrafObj::getEmbeddedPageNumber() const
+{
+ return GetGraphic().getPageNumber();
+}
+
SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
{
SdrObject* pRetval = nullptr;
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index e69bfcbe7e0d..312572ccd24f 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -771,7 +771,7 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
// See if we have this PDF already, and avoid duplicate storage.
auto aIt = maExportPdf.find(rPdfData.get());
if (aIt != maExportPdf.end())
- return true;
+ return aIt->second.first;
// The graphic has PDF data attached to it, use that.
// vcl::ImportPDF() possibly downgraded the PDF data from a
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index f94e6b320dd2..7083c4a9cc99 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -246,6 +246,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
const 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 fe8eb1166250..505289c2eea3 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -180,7 +180,8 @@ ImpGraphic::ImpGraphic() :
mbSwapOut ( false ),
mbDummyContext ( false ),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared ( false )
+ mbPrepared ( false ),
+ mnPageNumber(-1)
{
}
@@ -194,6 +195,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
+ , mnPageNumber(-1)
, maVectorGraphicData(rImpGraphic.maVectorGraphicData)
, mpPdfData(rImpGraphic.mpPdfData)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
@@ -222,6 +224,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
+ , mnPageNumber(-1)
, maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
, mpPdfData(std::move(rImpGraphic.mpPdfData))
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
@@ -239,7 +242,8 @@ ImpGraphic::ImpGraphic(GraphicExternalLink const & rGraphicExternalLink) :
mbDummyContext ( false ),
maGraphicExternalLink(rGraphicExternalLink),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -250,7 +254,8 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
mbSwapOut ( false ),
mbDummyContext ( false ),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -261,7 +266,8 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
mbSwapOut ( false ),
mbDummyContext ( false ),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -272,7 +278,8 @@ ImpGraphic::ImpGraphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr)
mbDummyContext ( false ),
maVectorGraphicData(rVectorGraphicDataPtr),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -284,7 +291,8 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
mbSwapOut ( false ),
mbDummyContext ( false ),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -295,7 +303,8 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
mbSwapOut ( false ),
mbDummyContext ( false ),
maLastUsed (std::chrono::high_resolution_clock::now()),
- mbPrepared (false)
+ mbPrepared (false),
+ mnPageNumber(-1)
{
}
@@ -317,6 +326,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
maSwapInfo = rImpGraphic.maSwapInfo;
mpContext = rImpGraphic.mpContext;
mbDummyContext = rImpGraphic.mbDummyContext;
+ mnPageNumber = rImpGraphic.mnPageNumber;
maGraphicExternalLink = rImpGraphic.maGraphicExternalLink;
mpAnimation.reset();
@@ -360,6 +370,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;
@@ -376,6 +387,8 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
vcl::graphic::Manager::get().changeExisting(this, aOldSizeBytes);
+ rImpGraphic.mnPageNumber = -1;
+
return *this;
}