summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorosnola <alonso@loria.fr>2016-08-10 12:43:56 +0200
committerDavid Tardon <dtardon@redhat.com>2016-08-11 08:13:27 +0200
commit1faae1f37521df7734462443936e1469820fd489 (patch)
tree8c3ab056cdd2e6a3fbc2642588563e4eeb65b022 /writerperfect
parent6a2cc612decea57b9c3ab31f2f32aa2126c06cf7 (diff)
integrate libstaroffice
Change-Id: I85913f1bd1af5d102573040588cca9d8ddeebb5d
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/Library_wpftcalc.mk2
-rw-r--r--writerperfect/Library_wpftdraw.mk2
-rw-r--r--writerperfect/Library_wpftwriter.mk2
-rw-r--r--writerperfect/source/calc/StarOfficeCalcImportFilter.cxx96
-rw-r--r--writerperfect/source/calc/StarOfficeCalcImportFilter.hxx45
-rw-r--r--writerperfect/source/calc/wpftcalc.component5
-rw-r--r--writerperfect/source/common/WPXSvInputStream.cxx4
-rw-r--r--writerperfect/source/draw/StarOfficeDrawImportFilter.cxx98
-rw-r--r--writerperfect/source/draw/StarOfficeDrawImportFilter.hxx45
-rw-r--r--writerperfect/source/draw/wpftdraw.component5
-rw-r--r--writerperfect/source/writer/StarOfficeWriterImportFilter.cxx116
-rw-r--r--writerperfect/source/writer/StarOfficeWriterImportFilter.hxx45
-rw-r--r--writerperfect/source/writer/wpftwriter.component5
13 files changed, 468 insertions, 2 deletions
diff --git a/writerperfect/Library_wpftcalc.mk b/writerperfect/Library_wpftcalc.mk
index 1672e63f2c33..3d378cb82dd0 100644
--- a/writerperfect/Library_wpftcalc.mk
+++ b/writerperfect/Library_wpftcalc.mk
@@ -49,6 +49,7 @@ $(eval $(call gb_Library_use_externals,wpftcalc,\
odfgen \
revenge \
mwaw \
+ staroffice \
wps \
zlib \
lcms2 \
@@ -61,6 +62,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftcalc,\
writerperfect/source/calc/MSWorksCalcImportFilter \
writerperfect/source/calc/MWAWCalcImportFilter \
writerperfect/source/calc/NumbersImportFilter \
+ writerperfect/source/calc/StarOfficeCalcImportFilter \
))
# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index cdec02962383..23d294518466 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_Library_use_externals,wpftdraw,\
odfgen \
pagemaker \
revenge \
+ staroffice \
visio \
wpg \
wpd \
@@ -70,6 +71,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftdraw,\
writerperfect/source/draw/MSPUBImportFilter \
writerperfect/source/draw/MWAWDrawImportFilter \
writerperfect/source/draw/PageMakerImportFilter \
+ writerperfect/source/draw/StarOfficeDrawImportFilter \
writerperfect/source/draw/VisioImportFilter \
writerperfect/source/draw/WPGImportFilter \
writerperfect/source/draw/ZMFImportFilter \
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 9ec43c4491c9..b260dc4fe419 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -57,6 +57,7 @@ $(eval $(call gb_Library_use_externals,wpftwriter,\
mwaw \
odfgen \
revenge \
+ staroffice \
wpd \
wpg \
wps \
@@ -69,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftwriter,\
writerperfect/source/writer/MSWorksImportFilter \
writerperfect/source/writer/MWAWImportFilter \
writerperfect/source/writer/PagesImportFilter \
+ writerperfect/source/writer/StarOfficeWriterImportFilter \
writerperfect/source/writer/WordPerfectImportFilter \
))
diff --git a/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx
new file mode 100644
index 000000000000..5accde1e1cd9
--- /dev/null
+++ b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx
@@ -0,0 +1,96 @@
+/* -*- 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 <cppuhelper/supportsservice.hxx>
+
+#include <libstaroffice/libstaroffice.hxx>
+#include <libodfgen/libodfgen.hxx>
+
+#include "StarOfficeCalcImportFilter.hxx"
+
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::XComponentContext;
+
+static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdgGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeGraphic(data, &exporter);
+}
+
+static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdsGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeSpreadsheet(data, &exporter);
+}
+
+bool StarOfficeCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &)
+{
+ return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator);
+}
+
+bool StarOfficeCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
+{
+ rTypeName.clear();
+ STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
+ const STOFFDocument::Confidence confidence = STOFFDocument::isFileFormatSupported(&rInput, docKind);
+ if (confidence == STOFFDocument::STOFF_C_EXCELLENT || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
+ {
+ switch (docKind)
+ {
+ case STOFFDocument::STOFF_K_DATABASE:
+ case STOFFDocument::STOFF_K_SPREADSHEET:
+ rTypeName = "StarOffice_Spreadsheet";
+ break;
+ default:
+ break;
+ }
+ }
+
+ return !rTypeName.isEmpty();
+}
+
+void StarOfficeCalcImportFilter::doRegisterHandlers(OdsGenerator &rGenerator)
+{
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject);
+}
+
+// XServiceInfo
+OUString SAL_CALL StarOfficeCalcImportFilter::getImplementationName()
+throw (RuntimeException, std::exception)
+{
+ return OUString("org.libreoffice.comp.Calc.StarOfficeCalcImportFilter");
+}
+
+sal_Bool SAL_CALL StarOfficeCalcImportFilter::supportsService(const OUString &rServiceName)
+throw (RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SAL_CALL StarOfficeCalcImportFilter::getSupportedServiceNames()
+throw (RuntimeException, std::exception)
+{
+ return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+}
+
+extern "C"
+SAL_DLLPUBLIC_EXPORT css::uno::XInterface *SAL_CALL
+org_libreoffice_comp_Calc_StarOfficeCalcImportFilter_get_implementation(
+ css::uno::XComponentContext *const context,
+ const css::uno::Sequence<css::uno::Any> &)
+{
+ return cppu::acquire(new StarOfficeCalcImportFilter(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx b/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx
new file mode 100644
index 000000000000..bcf457fd5bae
--- /dev/null
+++ b/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_CALC_STAROFFICECALCIMPORTFILTER_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_CALC_STAROFFICECALCIMPORTFILTER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "ImportFilter.hxx"
+
+#include "DocumentHandlerForOds.hxx"
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class StarOfficeCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator>
+{
+public:
+ explicit StarOfficeCalcImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
+ : writerperfect::ImportFilter<OdsGenerator>(rxContext) {}
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName)
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+private:
+ virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override;
+ virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) override;
+ virtual void doRegisterHandlers(OdsGenerator &rGenerator) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/wpftcalc.component b/writerperfect/source/calc/wpftcalc.component
index 117ec1f80288..404d09b6ca6a 100644
--- a/writerperfect/source/calc/wpftcalc.component
+++ b/writerperfect/source/calc/wpftcalc.component
@@ -24,4 +24,9 @@
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
+ <implementation name="org.libreoffice.comp.Calc.StarOfficeCalcImportFilter"
+ constructor="org_libreoffice_comp_Calc_StarOfficeCalcImportFilter_get_implementation">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
</component>
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
index d52c696e0f23..c5e344850475 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -44,8 +44,8 @@ class PositionHolder
public:
explicit PositionHolder(const Reference<XSeekable> &rxSeekable);
~PositionHolder();
- PositionHolder(const PositionHolder&) = delete;
- PositionHolder& operator=(const PositionHolder&) = delete;
+ PositionHolder(const PositionHolder &) = delete;
+ PositionHolder &operator=(const PositionHolder &) = delete;
private:
const Reference<XSeekable> mxSeekable;
diff --git a/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx
new file mode 100644
index 000000000000..57dfb7f070b2
--- /dev/null
+++ b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx
@@ -0,0 +1,98 @@
+/* -*- 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 <cppuhelper/supportsservice.hxx>
+
+#include <libstaroffice/libstaroffice.hxx>
+#include <libodfgen/libodfgen.hxx>
+
+#include "StarOfficeDrawImportFilter.hxx"
+
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::XComponentContext;
+
+static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdgGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeGraphic(data, &exporter);
+}
+
+static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdsGenerator exporter;
+ exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeSpreadsheet(data, &exporter);
+}
+
+bool StarOfficeDrawImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &)
+{
+ return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator);
+}
+
+bool StarOfficeDrawImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
+{
+ rTypeName.clear();
+
+ STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
+ const STOFFDocument::Confidence confidence = STOFFDocument::isFileFormatSupported(&rInput, docKind);
+
+ if (confidence == STOFFDocument::STOFF_C_EXCELLENT || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
+ {
+ switch (docKind)
+ {
+ case STOFFDocument::STOFF_K_DRAW:
+ rTypeName = "StarOffice_Drawing";
+ break;
+ default:
+ break;
+ }
+ }
+
+ return !rTypeName.isEmpty();
+}
+
+void StarOfficeDrawImportFilter::doRegisterHandlers(OdgGenerator &rGenerator)
+{
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject);
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject);
+}
+
+// XServiceInfo
+OUString SAL_CALL StarOfficeDrawImportFilter::getImplementationName()
+throw (RuntimeException, std::exception)
+{
+ return OUString("org.libreoffice.comp.Draw.StarOfficeDrawImportFilter");
+}
+
+sal_Bool SAL_CALL StarOfficeDrawImportFilter::supportsService(const OUString &rServiceName)
+throw (RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SAL_CALL StarOfficeDrawImportFilter::getSupportedServiceNames()
+throw (RuntimeException, std::exception)
+{
+ return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+}
+
+extern "C"
+SAL_DLLPUBLIC_EXPORT css::uno::XInterface *SAL_CALL
+org_libreoffice_comp_Draw_StarOfficeDrawImportFilter_get_implementation(
+ css::uno::XComponentContext *const context,
+ const css::uno::Sequence<css::uno::Any> &)
+{
+ return cppu::acquire(new StarOfficeDrawImportFilter(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx b/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx
new file mode 100644
index 000000000000..2fd9b7bb24e8
--- /dev/null
+++ b/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_DRAW_STAROFFICEDRAWIMPORTFILTER_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_DRAW_STAROFFICEDRAWIMPORTFILTER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "ImportFilter.hxx"
+
+#include "DocumentHandlerForOdg.hxx"
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class StarOfficeDrawImportFilter : public writerperfect::ImportFilter<OdgGenerator>
+{
+public:
+ explicit StarOfficeDrawImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
+ : writerperfect::ImportFilter<OdgGenerator>(rxContext) {}
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName)
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+private:
+ virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override;
+ virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) override;
+ virtual void doRegisterHandlers(OdgGenerator &rGenerator) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/wpftdraw.component b/writerperfect/source/draw/wpftdraw.component
index c315fa9f4dd3..72330b24de70 100644
--- a/writerperfect/source/draw/wpftdraw.component
+++ b/writerperfect/source/draw/wpftdraw.component
@@ -34,6 +34,11 @@
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
+ <implementation name="org.libreoffice.comp.Draw.StarOfficeDrawImportFilter"
+ constructor="org_libreoffice_comp_Draw_StarOfficeDrawImportFilter_get_implementation">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
<implementation name="com.sun.star.comp.Draw.VisioImportFilter"
constructor="com_sun_star_comp_Draw_VisioImportFilter_get_implementation">
<service name="com.sun.star.document.ImportFilter"/>
diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx
new file mode 100644
index 000000000000..e0580dc4d05c
--- /dev/null
+++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx
@@ -0,0 +1,116 @@
+/* -*- 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 <cppuhelper/supportsservice.hxx>
+
+#include <libstaroffice/libstaroffice.hxx>
+
+#include <sfx2/passwd.hxx>
+
+#include "StarOfficeWriterImportFilter.hxx"
+
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::XComponentContext;
+
+static bool handleEmbeddedSTOFFWriterGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdgGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeGraphic(data, &exporter);
+}
+
+static bool handleEmbeddedSTOFFWriterSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdsGenerator exporter;
+ exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFWriterGraphicObject);
+ exporter.addDocumentHandler(pHandler, streamType);
+ return STOFFDocument::decodeSpreadsheet(data, &exporter);
+}
+
+bool StarOfficeWriterImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &)
+{
+ STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
+ const STOFFDocument::Confidence confidence = STOFFDocument::isFileFormatSupported(&rInput, docKind);
+ OString aUtf8Passwd;
+ if (confidence==STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) {
+ // try to ask for a password
+ try {
+ ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr);
+ aPasswdDlg->SetMinLen(0);
+ if (!aPasswdDlg->Execute())
+ return false;
+ OUString aPasswd = aPasswdDlg->GetPassword();
+ aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8);
+ }
+ catch (...) {
+ // ok, we will probably guess it
+ }
+ }
+ return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator, !aUtf8Passwd.isEmpty() ? aUtf8Passwd.getStr() : nullptr);
+}
+
+bool StarOfficeWriterImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName)
+{
+ rTypeName.clear();
+
+ STOFFDocument::Kind docKind = STOFFDocument::STOFF_K_UNKNOWN;
+ const STOFFDocument::Confidence confidence = STOFFDocument::isFileFormatSupported(&rInput, docKind);
+
+ if (confidence == STOFFDocument::STOFF_C_EXCELLENT|| confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION)
+ {
+ switch (docKind)
+ {
+ case STOFFDocument::STOFF_K_TEXT:
+ rTypeName = "StarOffice_Writer";
+ break;
+ default:
+ break;
+ }
+ }
+
+ return !rTypeName.isEmpty();
+}
+
+void StarOfficeWriterImportFilter::doRegisterHandlers(OdtGenerator &rGenerator)
+{
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFWriterGraphicObject);
+ rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFWriterSpreadsheetObject);
+}
+
+// XServiceInfo
+OUString SAL_CALL StarOfficeWriterImportFilter::getImplementationName()
+throw (RuntimeException, std::exception)
+{
+ return OUString("org.libreoffice.comp.Writer.StarOfficeWriterImportFilter");
+}
+
+sal_Bool SAL_CALL StarOfficeWriterImportFilter::supportsService(const OUString &rServiceName)
+throw (RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SAL_CALL StarOfficeWriterImportFilter::getSupportedServiceNames()
+throw (RuntimeException, std::exception)
+{
+ return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"};
+}
+
+extern "C"
+SAL_DLLPUBLIC_EXPORT css::uno::XInterface *SAL_CALL
+org_libreoffice_comp_Writer_StarOfficeWriterImportFilter_get_implementation(
+ css::uno::XComponentContext *const context,
+ const css::uno::Sequence<css::uno::Any> &)
+{
+ return cppu::acquire(new StarOfficeWriterImportFilter(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx
new file mode 100644
index 000000000000..65805e049aee
--- /dev/null
+++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_STAROFFICEWRITERIMPORTFILTER_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_STAROFFICEWRITERIMPORTFILTER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "ImportFilter.hxx"
+
+#include "DocumentHandlerForOdt.hxx"
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class StarOfficeWriterImportFilter : public writerperfect::ImportFilter<OdtGenerator>
+{
+public:
+ explicit StarOfficeWriterImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
+ : writerperfect::ImportFilter<OdtGenerator>(rxContext) {}
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName)
+ throw (css::uno::RuntimeException, std::exception) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException, std::exception) override;
+
+private:
+ virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override;
+ virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &) override;
+ virtual void doRegisterHandlers(OdtGenerator &rGenerator) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/wpftwriter.component b/writerperfect/source/writer/wpftwriter.component
index 4c5f37fa4ceb..ace6b687363c 100644
--- a/writerperfect/source/writer/wpftwriter.component
+++ b/writerperfect/source/writer/wpftwriter.component
@@ -48,4 +48,9 @@
<service name="com.sun.star.document.ExtendedTypeDetection"/>
<service name="com.sun.star.document.ImportFilter"/>
</implementation>
+ <implementation name="org.libreoffice.comp.Writer.StarOfficeWriterImportFilter"
+ constructor="org_libreoffice_comp_Writer_StarOfficeWriterImportFilter_get_implementation">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
</component>