[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - filter/source offapi/com vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 31 12:36:14 UTC 2020


 filter/source/pdf/pdfdecomposer.cxx            |   14 ++++++++++----
 offapi/com/sun/star/graphic/XPdfDecomposer.idl |    7 ++++---
 vcl/source/gdi/vectorgraphicdata.cxx           |   10 +++++++---
 3 files changed, 21 insertions(+), 10 deletions(-)

New commits:
commit 8763e2e161787004cd98a879595e6a45acff9e79
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Dec 31 21:10:27 2020 +0900
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Dec 31 21:21:57 2020 +0900

    [API CHANGE] change XPdfDecomposer to use XBinaryDataContainer
    
    Using BinaryDataContainer doesn't require to copy the data as it
    is compatible with what is used in Graphic, VectorGraphicData and
    GfxLink.
    
    Change-Id: I01589158ae6bf6ac407bde60f07952e3968e3970

diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx
index ce1321a3ceb5..f4572f93742a 100644
--- a/filter/source/pdf/pdfdecomposer.cxx
+++ b/filter/source/pdf/pdfdecomposer.cxx
@@ -17,11 +17,14 @@
 #include <vcl/pdfread.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/outdev.hxx>
+#include <vcl/BinaryDataContainer.hxx>
+#include <vcl/BinaryDataContainerTools.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 
 #include <com/sun/star/graphic/XPdfDecomposer.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XBinaryDataContainer.hpp>
 
 using namespace css;
 
@@ -38,7 +41,7 @@ public:
 
     // XPdfDecomposer
     uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL
-    getDecomposition(const uno::Sequence<sal_Int8>& xPdfData,
+    getDecomposition(const uno::Reference<util::XBinaryDataContainer>& xDataContainer,
                      const uno::Sequence<beans::PropertyValue>& xDecompositionParameters) override;
 
     // XServiceInfo
@@ -49,8 +52,9 @@ public:
 
 XPdfDecomposer::XPdfDecomposer(uno::Reference<uno::XComponentContext> const&) {}
 
-uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL XPdfDecomposer::getDecomposition(
-    const uno::Sequence<sal_Int8>& xPdfData, const uno::Sequence<beans::PropertyValue>& xParameters)
+uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL
+XPdfDecomposer::getDecomposition(const uno::Reference<util::XBinaryDataContainer>& xDataContainer,
+                                 const uno::Sequence<beans::PropertyValue>& xParameters)
 {
     sal_Int32 nPageIndex = -1;
 
@@ -66,8 +70,10 @@ uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL XPdfDecomposer::ge
     if (nPageIndex < 0)
         nPageIndex = 0;
 
+    BinaryDataContainer aDataContainer = vcl::convertUnoBinaryDataContainer(xDataContainer);
+
     std::vector<BitmapEx> aBitmaps;
-    int rv = vcl::RenderPDFBitmaps(xPdfData.getConstArray(), xPdfData.getLength(), aBitmaps,
+    int rv = vcl::RenderPDFBitmaps(aDataContainer.getData(), aDataContainer.getSize(), aBitmaps,
                                    nPageIndex, 1);
     if (rv == 0)
         return {}; // happens if we do not have PDFium
diff --git a/offapi/com/sun/star/graphic/XPdfDecomposer.idl b/offapi/com/sun/star/graphic/XPdfDecomposer.idl
index 25bf8870c1ee..9976475d74cd 100644
--- a/offapi/com/sun/star/graphic/XPdfDecomposer.idl
+++ b/offapi/com/sun/star/graphic/XPdfDecomposer.idl
@@ -11,6 +11,7 @@
 #define __com_sun_star_graphic_XPdfDecomposer_idl__
 
 #include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/util/XBinaryDataContainer.idl>
 
 module com {  module sun {  module star {  module graphic {
 
@@ -26,15 +27,15 @@ interface XPdfDecomposer : ::com::sun::star::uno::XInterface
 {
     /** Retrieve decomposed list - in this case a bitmap with the rendered PDF.
 
-        @param xPdfData
-        The PDF data.
+        @param xDataContainer
+        The PDF data in a data container
 
         @param xDecompositionParameters
         Parameters for decomposition. Parameters include:
 
         sal_Int32 PageIndex - which page to use
      */
-    sequence<XPrimitive2D> getDecomposition([in] sequence<byte> xPdfData,
+    sequence<XPrimitive2D> getDecomposition([in] com::sun::star::util::XBinaryDataContainer xDataContainer,
                                             [in] sequence<com::sun::star::beans::PropertyValue> xDecompositionParameters);
 };
 
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index 24be63da30dc..13a89f48617a 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/graphic/Primitive2DTools.hpp>
 #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
 #include <com/sun/star/util/XAccounting.hpp>
+#include <com/sun/star/util/XBinaryDataContainer.hpp>
+#include <com/sun/star/util/BinaryDataContainer.hpp>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <vcl/canvastools.hxx>
 #include <comphelper/seqstream.hxx>
@@ -40,6 +42,7 @@
 #include <vcl/wmfexternal.hxx>
 #include <vcl/pdfread.hxx>
 #include <unotools/streamwrap.hxx>
+#include <graphic/UnoBinaryDataContainer.hxx>
 
 using namespace ::com::sun::star;
 
@@ -252,9 +255,10 @@ void VectorGraphicData::ensureSequenceAndRange()
                 {"PageIndex", uno::makeAny<sal_Int32>(mnPageIndex)},
             });
             // TODO: change xPdfDecomposer to use BinaryDataContainer directly
-            css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize());
-            std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin());
-            auto xPrimitive2D = xPdfDecomposer->getDecomposition(aDataSequence, aDecompositionParameters);
+            auto* pUnoBinaryDataContainer = new UnoBinaryDataContainer(getBinaryDataContainer());
+            uno::Reference<util::XBinaryDataContainer> xDataContainer = pUnoBinaryDataContainer;
+
+            auto xPrimitive2D = xPdfDecomposer->getDecomposition(xDataContainer, aDecompositionParameters);
             maSequence = comphelper::sequenceToContainer<std::deque<uno::Reference<graphic::XPrimitive2D>>>(xPrimitive2D);
 
             break;


More information about the Libreoffice-commits mailing list