summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/BinaryDataContainerTools.hxx23
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/util/XBinaryDataContainer.idl34
-rw-r--r--vcl/Library_vcl.mk2
-rw-r--r--vcl/inc/graphic/UnoBinaryDataContainer.hxx52
-rw-r--r--vcl/source/graphic/BinaryDataContainerTools.cxx28
-rw-r--r--vcl/source/graphic/UnoBinaryDataContainer.cxx34
7 files changed, 174 insertions, 0 deletions
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: */