[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 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
Thu Dec 31 12:02:50 UTC 2020
Rebased ref, commits from common ancestor:
commit 6767de862a64b75e4c40a9a4874aaa3bb9f5d9d5
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: Thu Dec 31 21:02:01 2020 +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..5e7fa60ebc34 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -446,6 +446,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui/test,\
UITest \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/util,\
+ BinaryDataContainer \
JobManager \
NumberFormatter \
NumberFormatsSupplier \
@@ -4143,6 +4144,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/BinaryDataContainer.idl b/offapi/com/sun/star/util/BinaryDataContainer.idl
new file mode 100644
index 000000000000..be4102a20b1c
--- /dev/null
+++ b/offapi/com/sun/star/util/BinaryDataContainer.idl
@@ -0,0 +1,30 @@
+/* -*- 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_BinaryDataContainer_idl
+#define com_sun_star_util_BinaryDataContainer_idl
+
+
+module com { module sun { module star { module util
+{
+
+/** Implementation of a container for binary data.
+
+ @since LibreOffice 7.2
+ */
+
+service BinaryDataContainer : XBinaryDataContainer
+{
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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