[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source vcl/vcl.common.component
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 31 11:57:19 UTC 2020
Rebased ref, commits from common ancestor:
commit 1a5731ca35bec6663842eaf517d72174c81d009f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Dec 31 19:38:25 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Dec 31 19:41:03 2020 +0900
BinaryDataContainer UNO improvement
Change-Id: I44afd52d39bcb3d11bbd6676f54118b4161786cb
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/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index b7b47ac463ec..478638da2220 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -322,6 +322,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 \
diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
new file mode 100644
index 000000000000..f722d8966b62
--- /dev/null
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -0,0 +1,53 @@
+/* -*- 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/XServiceInfo.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
index cd6ce99d4a39..8ee3660be416 100644
--- a/vcl/source/graphic/UnoBinaryDataContainer.cxx
+++ b/vcl/source/graphic/UnoBinaryDataContainer.cxx
@@ -8,77 +8,27 @@
*
*/
-#include <cppuhelper/implbase.hxx>
-#include <cppuhelper/supportsservice.hxx>
+#include <graphic/UnoBinaryDataContainer.hxx>
-#include <com/sun/star/util/XBinaryDataContainer.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-#include <vcl/BinaryDataContainer.hxx>
+#include <cppuhelper/queryinterface.hxx>
using namespace css;
-namespace
-{
-typedef ::cppu::WeakImplHelper<util::XBinaryDataContainer, css::lang::XServiceInfo>
- BinaryDataContainer_BASE;
+// css::lang::XUnoTunnel
+UNO3_GETIMPLEMENTATION_IMPL(UnoBinaryDataContainer);
-class UnoBinaryDataContainer : public BinaryDataContainer_BASE
+css::uno::Sequence<sal_Int8> SAL_CALL UnoBinaryDataContainer::getCopyAsByteSequence()
{
-private:
- BinaryDataContainer maBinaryDataContainer;
-
-public:
- explicit UnoBinaryDataContainer() {}
-
- BinaryDataContainer const& getBinaryDataContainer() { return maBinaryDataContainer; }
-
- void setBinaryDataContainer(BinaryDataContainer const& rBinaryDataContainer)
- {
- maBinaryDataContainer = rBinaryDataContainer;
- }
-
- // XBinaryDataContainer
- css::uno::Sequence<sal_Int8> SAL_CALL getCopyAsByteSequence() override
- {
- if (maBinaryDataContainer.isEmpty())
- return css::uno::Sequence<sal_Int8>();
+ if (maBinaryDataContainer.isEmpty())
+ return css::uno::Sequence<sal_Int8>();
- size_t nSize = maBinaryDataContainer.getSize();
+ size_t nSize = maBinaryDataContainer.getSize();
- css::uno::Sequence<sal_Int8> aData(nSize);
+ css::uno::Sequence<sal_Int8> aData(nSize);
- std::copy(maBinaryDataContainer.cbegin(), maBinaryDataContainer.cend(), aData.getArray());
+ std::copy(maBinaryDataContainer.cbegin(), maBinaryDataContainer.cend(), aData.getArray());
- return aData;
- }
-
- // XServiceInfo
- virtual OUString SAL_CALL getImplementationName() override
- {
- return "com.sun.star.util.BinaryDataContainer";
- }
-
- virtual sal_Bool SAL_CALL supportsService(OUString const& rServiceName) override
- {
- return cppu::supportsService(this, rServiceName);
- }
-
- virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
- {
- return uno::Sequence<OUString>{ "com.sun.star.util.BinaryDataContainer" };
- }
-};
-
-} // end anonymous namespace
-
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
-com_sun_star_comp_util_BinaryDataContainer_get_implementation(
- SAL_UNUSED_PARAMETER uno::XComponentContext*,
- SAL_UNUSED_PARAMETER uno::Sequence<uno::Any> const&)
-{
- return cppu::acquire(new UnoBinaryDataContainer());
+ return aData;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/vcl.common.component b/vcl/vcl.common.component
index abf5da9c10dd..2665a136afcc 100644
--- a/vcl/vcl.common.component
+++ b/vcl/vcl.common.component
@@ -35,8 +35,4 @@
constructor="dtrans_CMimeContentTypeFactory_get_implementation">
<service name="com.sun.star.datatransfer.MimeContentTypeFactory"/>
</implementation>
- <implementation name="com.sun.star.util.BinaryDataContainer"
- constructor="com_sun_star_comp_util_BinaryDataContainer_get_implementation">
- <service name="com.sun.star.util.BinaryDataContainer"/>
- </implementation>
</component>
More information about the Libreoffice-commits
mailing list