svx/source/svdraw/svdedtv2.cxx |   17 ++++++++++++++++-
 svx/source/svdraw/svdpdf.cxx   |   13 ++++++++-----
 svx/source/svdraw/svdpdf.hxx   |    8 +++++---
 3 files changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 90922a7b4485d7dac7666ee7e44eda2eee916dc0
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Mar 27 20:14:39 2020 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Jun 6 19:27:01 2020 +0200

    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.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91234
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit f265b14d6f8e3e63260b3c8ecce48d4251288fea)
    
    Change-Id: I1d817f1556e37fcbcc3d2850b690eb0810676fa5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95635
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 4531aa511579..7eab69f7bb5b 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -52,6 +52,7 @@
 #include <tools/debug.hxx>
 #include <memory>
 #include <vector>
+#include <vcl/graph.hxx>
 
 using ::std::vector;
 using namespace com::sun::star;
@@ -2095,7 +2096,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 b392e9523f79..415c6e3dc7df 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -29,6 +29,7 @@
 
 #include <vcl/bitmapaccess.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/vectorgraphicdata.hxx>
 
 #include <editeng/editdata.hxx>
 #include <math.h>
@@ -118,11 +119,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)
@@ -166,8 +167,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 70b5a44e4ddf..1005b081142a 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -32,6 +32,7 @@
 #include <tools/fract.hxx>
 #include <vcl/metaact.hxx>
 #include <vcl/virdev.hxx>
+#include <vcl/graph.hxx>
 #include <svx/svdobj.hxx>
 #include <svx/xdash.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
@@ -158,10 +159,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 const 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;
@@ -233,7 +234,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; }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to