summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-27 20:14:39 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-03-27 23:32:36 +0100
commitf265b14d6f8e3e63260b3c8ecce48d4251288fea (patch)
tree4adeaf9681a015bb09a4fa6f014286f97c0dd619
parent8b006e541e3fb2c84e091d9f7f51fab5477effa9 (diff)
pdfium: make breaking of PDF graphic work again
Changing PDF to use VectorGraphicData deleted the calls which triggered the breaking of the PDF. This change makes breaking work again. Change-Id: I1d817f1556e37fcbcc3d2850b690eb0810676fa5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91234 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--svx/source/svdraw/svdedtv2.cxx17
-rw-r--r--svx/source/svdraw/svdpdf.cxx13
-rw-r--r--svx/source/svdraw/svdpdf.hxx8
3 files changed, 29 insertions, 9 deletions
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 9879d6adcee6..c7f5dfebeec0 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -49,6 +49,7 @@
#include <tools/debug.hxx>
#include <memory>
#include <vector>
+#include <vcl/graph.hxx>
using ::std::vector;
using namespace com::sun::star;
@@ -2096,7 +2097,21 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
SdrGrafObj* pGraf = dynamic_cast<SdrGrafObj*>( pObj );
if (pGraf != nullptr)
{
- if (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedVectorGraphicData())
+ Graphic aGraphic = pGraf->GetGraphic();
+ auto const & pVectorGraphicData = aGraphic.getVectorGraphicData();
+
+ if (pVectorGraphicData && pVectorGraphicData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ {
+#if HAVE_FEATURE_PDFIUM
+ aLogicRect = pGraf->GetLogicRect();
+ ImpSdrPdfImport aFilter(*mpModel, pObj->GetLayer(), aLogicRect, aGraphic);
+ if (pGraf->getEmbeddedPageNumber() < aFilter.GetPageCount())
+ {
+ nInsCnt = aFilter.DoImport(*pOL, nInsPos, aGraphic.getPageNumber(), pProgrInfo);
+ }
+#endif // HAVE_FEATURE_PDFIUM
+ }
+ else if (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedVectorGraphicData() )
{
GDIMetaFile aMetaFile(GetMetaFile(pGraf));
if (aMetaFile.GetActionSize())
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 333b832190d6..a86be9aa5bc0 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -27,6 +27,7 @@
#include <fpdf_text.h>
#include <vcl/graph.hxx>
+#include <vcl/vectorgraphicdata.hxx>
#include <math.h>
#include <editeng/eeitem.hxx>
@@ -107,11 +108,11 @@ struct FPDFBitmapDeleter
using namespace com::sun::star;
ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
- const std::shared_ptr<std::vector<sal_Int8>>& pPdfData)
- : maTmpList()
+ Graphic const& rGraphic)
+ : mrGraphic(rGraphic)
+ , maTmpList()
, mpVD(VclPtr<VirtualDevice>::Create())
, maScaleRect(rRect)
- , mpPdfData(pPdfData)
, mnMapScalingOfs(0)
, mpModel(&rModel)
, mnLayer(nLay)
@@ -155,8 +156,10 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
FPDF_InitLibraryWithConfig(&aConfig);
// Load the buffer using pdfium.
- mpPdfDocument = FPDF_LoadMemDocument(mpPdfData->data(), mpPdfData->size(),
- /*password=*/nullptr);
+ auto const& rVectorGraphicData = mrGraphic.getVectorGraphicData();
+ mpPdfDocument = FPDF_LoadMemDocument(
+ rVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
+ rVectorGraphicData->getVectorGraphicDataArrayLength(), /*password=*/nullptr);
if (!mpPdfDocument)
{
//TODO: Handle failure to load.
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 74c17c1690b5..1648eeb3cdd1 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -30,6 +30,7 @@
#include <tools/fract.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/graph.hxx>
#include <svx/svdobj.hxx>
#include <svx/xdash.hxx>
@@ -155,10 +156,10 @@ class ImpSdrPdfImport final
double ma, mb, mc, md, me, mf;
};
- ::std::vector<SdrObject*> maTmpList;
+ Graphic const& mrGraphic;
+ std::vector<SdrObject*> maTmpList;
ScopedVclPtr<VirtualDevice> mpVD;
tools::Rectangle maScaleRect;
- const std::shared_ptr<std::vector<sal_Int8>> mpPdfData;
size_t mnMapScalingOfs; // from here on, not edited with MapScaling
std::unique_ptr<SfxItemSet> mpLineAttr;
std::unique_ptr<SfxItemSet> mpFillAttr;
@@ -230,7 +231,8 @@ class ImpSdrPdfImport final
public:
ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
- const std::shared_ptr<std::vector<sal_Int8>>& pPdfData);
+ Graphic const& rGraphic);
+
~ImpSdrPdfImport();
int GetPageCount() const { return mnPageCount; }