[Libreoffice-commits] core.git: filter/source writerperfect/Library_wpftwriter.mk writerperfect/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Sep 12 15:17:05 UTC 2017


 filter/source/config/fragments/filters/EPUB.xcu       |    2 
 writerperfect/Library_wpftwriter.mk                   |    1 
 writerperfect/source/writer/EPUBExportUIComponent.cxx |   83 ++++++++++++++++++
 writerperfect/source/writer/EPUBExportUIComponent.hxx |   61 +++++++++++++
 writerperfect/source/writer/wpftwriter.component      |    4 
 5 files changed, 150 insertions(+), 1 deletion(-)

New commits:
commit e6746a005419235d20074d696a1f8fadbda0a003
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 12 14:07:07 2017 +0200

    EPUB export: initial UI component
    
    EPUBExportUIComponent::execute() still needs to launch an actual dialog,
    but otherwise it has enough functionality that only tweaking
    maFilterData is necessary in the UNO component to pass custom filter
    options to the exporter.
    
    Change-Id: I95af024f5babd66a5aa0b446550f4f0fec45ef43
    Reviewed-on: https://gerrit.libreoffice.org/42204
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/filter/source/config/fragments/filters/EPUB.xcu b/filter/source/config/fragments/filters/EPUB.xcu
index 49d8020b0d39..8ec0da9cdd37 100644
--- a/filter/source/config/fragments/filters/EPUB.xcu
+++ b/filter/source/config/fragments/filters/EPUB.xcu
@@ -17,7 +17,7 @@
 -->
     <node oor:name="EPUB" oor:op="replace">
         <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER</value></prop>
-        <prop oor:name="UIComponent"/>
+        <prop oor:name="UIComponent"><value>com.sun.star.comp.Writer.EPUBExportUIComponent</value></prop>
         <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.EPUBExportFilter</value></prop>
         <prop oor:name="UserData"><value>EPUB</value></prop>
         <prop oor:name="UIName">
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 826ffe600e12..94ad9a868796 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -69,6 +69,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftwriter,\
 	writerperfect/source/writer/AbiWordImportFilter \
 	writerperfect/source/writer/EBookImportFilter \
 	writerperfect/source/writer/EPUBExportFilter \
+	writerperfect/source/writer/EPUBExportUIComponent \
 	writerperfect/source/writer/EPUBPackage \
 	writerperfect/source/writer/MSWorksImportFilter \
 	writerperfect/source/writer/MWAWImportFilter \
diff --git a/writerperfect/source/writer/EPUBExportUIComponent.cxx b/writerperfect/source/writer/EPUBExportUIComponent.cxx
new file mode 100644
index 000000000000..40ecea56262d
--- /dev/null
+++ b/writerperfect/source/writer/EPUBExportUIComponent.cxx
@@ -0,0 +1,83 @@
+/* -*- 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 "EPUBExportUIComponent.hxx"
+
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace com::sun::star;
+
+namespace writerperfect
+{
+
+EPUBExportUIComponent::EPUBExportUIComponent(const uno::Reference<uno::XComponentContext> &/*xContext*/)
+{
+}
+
+uno::Sequence<beans::PropertyValue> EPUBExportUIComponent::getPropertyValues()
+{
+    maMediaDescriptor["FilterData"] <<= maFilterData.getAsConstPropertyValueList();
+    return maMediaDescriptor.getAsConstPropertyValueList();
+}
+
+void EPUBExportUIComponent::setPropertyValues(const uno::Sequence<beans::PropertyValue> &rProperties)
+{
+    maMediaDescriptor.clear();
+    maMediaDescriptor << rProperties;
+    auto it = maMediaDescriptor.find("FilterData");
+    if (it != maMediaDescriptor.end())
+    {
+        uno::Sequence<beans::PropertyValue> aFilterData;
+        if (it->second >>= aFilterData)
+        {
+            maFilterData.clear();
+            maFilterData << aFilterData;
+        }
+    }
+}
+
+OUString EPUBExportUIComponent::getImplementationName()
+{
+    return OUString("com.sun.star.comp.Writer.EPUBExportUIComponent");
+}
+
+sal_Bool EPUBExportUIComponent::supportsService(const OUString &rServiceName)
+{
+    return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence<OUString> EPUBExportUIComponent::getSupportedServiceNames()
+{
+    uno::Sequence<OUString> aRet =
+    {
+        OUString("com.sun.star.ui.dialogs.FilterOptionsDialog")
+    };
+    return aRet;
+}
+
+void EPUBExportUIComponent::setTitle(const OUString &/*rTitle*/)
+{
+}
+
+sal_Int16 EPUBExportUIComponent::execute()
+{
+    return ui::dialogs::ExecutableDialogResults::OK;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *SAL_CALL com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation(uno::XComponentContext *pCtx, uno::Sequence<uno::Any> const &)
+{
+    return cppu::acquire(new EPUBExportUIComponent(pCtx));
+}
+
+} // namespace writerperfect
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/EPUBExportUIComponent.hxx b/writerperfect/source/writer/EPUBExportUIComponent.hxx
new file mode 100644
index 000000000000..f20adfd2d997
--- /dev/null
+++ b/writerperfect/source/writer/EPUBExportUIComponent.hxx
@@ -0,0 +1,61 @@
+/* -*- 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 INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTUICOMPONENT_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTUICOMPONENT_HXX
+
+#include <vector>
+
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <comphelper/sequenceashashmap.hxx>
+#include <cppuhelper/implbase.hxx>
+
+namespace writerperfect
+{
+
+/// EPUB export UI component implementation.
+class EPUBExportUIComponent : public cppu::WeakImplHelper
+    <
+    css::beans::XPropertyAccess,
+    css::lang::XServiceInfo,
+    css::ui::dialogs::XExecutableDialog
+    >
+{
+public:
+    EPUBExportUIComponent(const css::uno::Reference<css::uno::XComponentContext> &xContext);
+
+    // XPropertyAccess
+    css::uno::Sequence<css::beans::PropertyValue> SAL_CALL getPropertyValues() override;
+    void SAL_CALL setPropertyValues(const css::uno::Sequence<css::beans::PropertyValue> &rProperties) override;
+
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override;
+    css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+    // XExecutableDialog
+    void SAL_CALL setTitle(const OUString &rTitle) override;
+    sal_Int16 SAL_CALL execute() override;
+
+private:
+    /// The full set of property values.
+    comphelper::SequenceAsHashMap maMediaDescriptor;
+    /// The filter data key.
+    comphelper::SequenceAsHashMap maFilterData;
+};
+
+} // namespace writerperfect
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/wpftwriter.component b/writerperfect/source/writer/wpftwriter.component
index 5e68de56cfd2..8ab436634052 100644
--- a/writerperfect/source/writer/wpftwriter.component
+++ b/writerperfect/source/writer/wpftwriter.component
@@ -57,4 +57,8 @@
       constructor="com_sun_star_comp_Writer_EPUBExportFilter_get_implementation">
     <service name="com.sun.star.document.ExportFilter"/>
   </implementation>
+  <implementation name="com.sun.star.comp.Writer.EPUBExportUIComponent"
+      constructor="com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation">
+    <service name="com.sun.star.ui.dialogs.FilterOptionsDialog"/>
+  </implementation>
 </component>


More information about the Libreoffice-commits mailing list