[Libreoffice-commits] core.git: 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
Wed Jan 20 08:07:22 UTC 2021


 include/vcl/BinaryDataContainerTools.hxx          |   23 +++++++++
 offapi/UnoApi_offapi.mk                           |    1 
 offapi/com/sun/star/util/XBinaryDataContainer.idl |   34 ++++++++++++++
 vcl/Library_vcl.mk                                |    2 
 vcl/inc/graphic/UnoBinaryDataContainer.hxx        |   52 ++++++++++++++++++++++
 vcl/source/graphic/BinaryDataContainerTools.cxx   |   28 +++++++++++
 vcl/source/graphic/UnoBinaryDataContainer.cxx     |   34 ++++++++++++++
 7 files changed, 174 insertions(+)

New commits:
commit eda153002f619697394066de127bed42ff3eeb50
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Dec 25 20:10:44 2020 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jan 20 09:06:41 2021 +0100

    vcl: add an UNO interface and impl. for BinaryDataContainer
    
    Change-Id: Icbc384892bee8c31eb7f3a39ff9a64f1199b23b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109596
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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..b58bca00d0e0
--- /dev/null
+++ b/offapi/com/sun/star/util/XBinaryDataContainer.idl
@@ -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/.
+ */
+
+#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.
+
+    The binary data in the container is regarded as read-only so no
+    access that would allow changing the data is allowed in this
+    interface.
+
+    @since LibreOffice 7.2
+ */
+interface XBinaryDataContainer
+{
+    /** Get a copy of the contained data */
+    sequence<byte> getCopyAsByteSequence();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 9bb7906eb39f..e58e6b8b3d17 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -321,6 +321,7 @@ $(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 \
@@ -328,6 +329,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/graphic/GraphicReader \
     vcl/source/graphic/grfattr \
     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