[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 2 commits - filter/source include/vcl offapi/com offapi/UnoApi_offapi.mk vcl/inc vcl/Library_vcl.mk vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 1 07:14:06 UTC 2021


Rebased ref, commits from common ancestor:
commit c486fab465eeff78a329564b5df660b828760243
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: Fri Jan 1 12:53:01 2021 +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 7c5462d75ce7..193fa5c7022a 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;
 
@@ -250,9 +253,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;
commit ab2d5cb94e12db507bd41124ba1db1613bcf32f9
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Dec 25 20:10:44 2020 +0900
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Fri Jan 1 12:52:36 2021 +0900

    vcl: add an UNO interface and impl. for BinaryDataContainer
    
    Change-Id: Icbc384892bee8c31eb7f3a39ff9a64f1199b23b1

diff --git a/include/vcl/BinaryDataContainerTools.hxx b/include/vcl/BinaryDataContainerTools.hxx
new file mode 100644
index 000000000000..3d50379a82d3
--- /dev/null
+++ b/include/vcl/BinaryDataContainerTools.hxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/dllapi.h>
+#include <vcl/BinaryDataContainer.hxx>
+#include <com/sun/star/util/XBinaryDataContainer.hpp>
+
+namespace vcl
+{
+VCL_DLLPUBLIC BinaryDataContainer convertUnoBinaryDataContainer(
+    css::uno::Reference<css::util::XBinaryDataContainer> const& rxBinaryDataContainer);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index eabb1272588a..5e2384552b5b 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4143,6 +4143,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\
 	VetoException \
 	XAccounting \
 	XAtomServer \
+	XBinaryDataContainer \
 	XBroadcaster \
 	XCancellable \
 	XChainable \
diff --git a/offapi/com/sun/star/util/XBinaryDataContainer.idl b/offapi/com/sun/star/util/XBinaryDataContainer.idl
new file mode 100644
index 000000000000..563ac4db7e00
--- /dev/null
+++ b/offapi/com/sun/star/util/XBinaryDataContainer.idl
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef com_sun_star_util_XBinaryDataContainer_idl
+#define com_sun_star_util_XBinaryDataContainer_idl
+
+module com { module sun { module star { module util
+{
+
+/** Container for binary data, typically an in-memory content of files.
+
+    @since LibreOffice 7.2
+ */
+interface XBinaryDataContainer
+{
+    sequence<byte> getCopyAsByteSequence();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 1a93ab808208..478638da2220 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -322,12 +322,14 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/pdf/PDFiumLibrary \
     vcl/source/pdf/ExternalPDFStreams \
     vcl/source/graphic/BinaryDataContainer \
+    vcl/source/graphic/BinaryDataContainerTools \
     vcl/source/graphic/GraphicID \
     vcl/source/graphic/GraphicLoader \
     vcl/source/graphic/GraphicObject \
     vcl/source/graphic/GraphicObject2 \
     vcl/source/graphic/GraphicReader \
     vcl/source/graphic/Manager \
+    vcl/source/graphic/UnoBinaryDataContainer \
     vcl/source/graphic/UnoGraphic \
     vcl/source/graphic/UnoGraphicMapper \
     vcl/source/graphic/UnoGraphicDescriptor \
diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
new file mode 100644
index 000000000000..115cbc46d46c
--- /dev/null
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ */
+
+#pragma once
+
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include <com/sun/star/util/XBinaryDataContainer.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vcl/BinaryDataContainer.hxx>
+
+class UnoBinaryDataContainer final
+    : public cppu::WeakImplHelper<css::util::XBinaryDataContainer, css::lang::XUnoTunnel>
+{
+private:
+    BinaryDataContainer maBinaryDataContainer;
+
+public:
+    UnoBinaryDataContainer() {}
+
+    UnoBinaryDataContainer(BinaryDataContainer const& rBinaryDataContainer)
+        : maBinaryDataContainer(rBinaryDataContainer)
+    {
+    }
+
+    BinaryDataContainer const& getBinaryDataContainer() const { return maBinaryDataContainer; }
+
+    void setBinaryDataContainer(BinaryDataContainer const& rBinaryDataContainer)
+    {
+        maBinaryDataContainer = rBinaryDataContainer;
+    }
+
+    // XBinaryDataContainer
+    css::uno::Sequence<sal_Int8> SAL_CALL getCopyAsByteSequence() override;
+
+    UNO3_GETIMPLEMENTATION_DECL(UnoBinaryDataContainer)
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/BinaryDataContainerTools.cxx b/vcl/source/graphic/BinaryDataContainerTools.cxx
new file mode 100644
index 000000000000..3921e075cea2
--- /dev/null
+++ b/vcl/source/graphic/BinaryDataContainerTools.cxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <vcl/BinaryDataContainerTools.hxx>
+#include <graphic/UnoBinaryDataContainer.hxx>
+
+namespace vcl
+{
+BinaryDataContainer convertUnoBinaryDataContainer(
+    const css::uno::Reference<css::util::XBinaryDataContainer>& rxBinaryDataContainer)
+{
+    BinaryDataContainer aBinaryDataContainer;
+    UnoBinaryDataContainer* pUnoBinaryDataContainer
+        = comphelper::getUnoTunnelImplementation<UnoBinaryDataContainer>(rxBinaryDataContainer);
+    if (pUnoBinaryDataContainer)
+        aBinaryDataContainer = pUnoBinaryDataContainer->getBinaryDataContainer();
+    return aBinaryDataContainer;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/UnoBinaryDataContainer.cxx b/vcl/source/graphic/UnoBinaryDataContainer.cxx
new file mode 100644
index 000000000000..8ee3660be416
--- /dev/null
+++ b/vcl/source/graphic/UnoBinaryDataContainer.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <graphic/UnoBinaryDataContainer.hxx>
+
+#include <cppuhelper/queryinterface.hxx>
+
+using namespace css;
+
+// css::lang::XUnoTunnel
+UNO3_GETIMPLEMENTATION_IMPL(UnoBinaryDataContainer);
+
+css::uno::Sequence<sal_Int8> SAL_CALL UnoBinaryDataContainer::getCopyAsByteSequence()
+{
+    if (maBinaryDataContainer.isEmpty())
+        return css::uno::Sequence<sal_Int8>();
+
+    size_t nSize = maBinaryDataContainer.getSize();
+
+    css::uno::Sequence<sal_Int8> aData(nSize);
+
+    std::copy(maBinaryDataContainer.cbegin(), maBinaryDataContainer.cend(), aData.getArray());
+
+    return aData;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list