filter/Configuration_filter.mk | 2 filter/source/config/fragments/filters/PowerPoint3.xcu | 2 filter/source/config/fragments/filters/StarOffice_Presentation.xcu | 29 +++ filter/source/config/fragments/types/StarOffice_Presentation.xcu | 27 ++ filter/source/config/fragments/types/calc_WPS_Lotus_Document.xcu | 2 filter/source/config/fragments/types/impress_PowerPoint3.xcu | 2 writerperfect/Library_wpftcalc.mk | 1 writerperfect/Library_wpftimpress.mk | 2 writerperfect/qa/unit/DrawingImportTest.cxx | 2 writerperfect/qa/unit/PresentationImportTest.cxx | 2 writerperfect/qa/unit/SpreadsheetImportTest.cxx | 2 writerperfect/qa/unit/TextImportTest.cxx | 2 writerperfect/source/calc/MSWorksCalcImportFilter.cxx | 41 +++- writerperfect/source/common/DocumentHandler.cxx | 6 writerperfect/source/common/WPXSvInputStream.cxx | 24 +- writerperfect/source/impress/MWAWPresentationImportFilter.cxx | 2 writerperfect/source/impress/StarOfficePresentationImportFilter.cxx | 95 ++++++++++ writerperfect/source/impress/StarOfficePresentationImportFilter.hxx | 42 ++++ writerperfect/source/impress/wpftimpress.component | 5 19 files changed, 263 insertions(+), 27 deletions(-)
New commits: commit 0e261a6908c2521a9967069095239eeb02810b8c Author: osnola <alo...@loria.fr> Date: Sun Apr 2 09:56:42 2017 +0200 libmwaw import filter improvements + correct a small mistake + add pot the file extension (the file extension for PowerPoint 95 template) Change-Id: I4ad18088ccb9777e1b34f393effbe2d24468804e diff --git a/filter/source/config/fragments/filters/PowerPoint3.xcu b/filter/source/config/fragments/filters/PowerPoint3.xcu index d61a360d4eb0..d1d19e6d2845 100644 --- a/filter/source/config/fragments/filters/PowerPoint3.xcu +++ b/filter/source/config/fragments/filters/PowerPoint3.xcu @@ -14,7 +14,7 @@ <value>com.sun.star.comp.Impress.MWAWPresentationImportFilter</value> </prop> <prop oor:name="UIName"> - <value xml:lang="en-US">Microsoft PowerPoint 1-4</value> + <value xml:lang="en-US">Microsoft PowerPoint 1-4 and 95's</value> </prop> <prop oor:name="FileFormatVersion"> <value>0</value> diff --git a/filter/source/config/fragments/types/impress_PowerPoint3.xcu b/filter/source/config/fragments/types/impress_PowerPoint3.xcu index 45cbb2855c2f..4c6885943b76 100644 --- a/filter/source/config/fragments/types/impress_PowerPoint3.xcu +++ b/filter/source/config/fragments/types/impress_PowerPoint3.xcu @@ -11,7 +11,7 @@ <value>com.sun.star.comp.Impress.MWAWPresentationImportFilter</value> </prop> <prop oor:name="Extensions"> - <value>ppt</value> + <value>ppt pot</value> </prop> <prop oor:name="PreferredFilter"> <value>PowerPoint 3</value> diff --git a/writerperfect/source/impress/MWAWPresentationImportFilter.cxx b/writerperfect/source/impress/MWAWPresentationImportFilter.cxx index 3b77605a2c6e..a1b2d7f06145 100644 --- a/writerperfect/source/impress/MWAWPresentationImportFilter.cxx +++ b/writerperfect/source/impress/MWAWPresentationImportFilter.cxx @@ -58,7 +58,7 @@ bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream &r case MWAWDocument::MWAW_T_CLARISWORKS: rTypeName = "impress_ClarisWorks"; break; - case MWAWDocument::MWAW_T_RESERVED9: + case MWAWDocument::MWAW_T_RESERVED8: rTypeName = "impress_PowerPoint3"; break; default: commit 8988c925ce07395478fbbb10d25fd6c0a10fead5 Author: osnola <alo...@loria.fr> Date: Sun Apr 2 09:53:44 2017 +0200 libstaroffice import filter improvements + add support for presentation file (i.e. the file created will StarImpress are now open as presentation). + modify the OLE parser to be similar to the librevenge OLE parser, ie. the librevenge parser ignores the first character of a filename if this is a control character... Change-Id: I913a70cba29839d43dac58d5e00dbebfc4d28abc diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index cbb951f3fe28..52483dc58ccf 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -600,6 +600,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impress_types.xc impress_OOXML_Presentation_Template \ impress_OOXML_Presentation_AutoPlay \ impress_ClarisWorks \ + StarOffice_Presentation \ MWAW_Presentation \ impress_PowerPoint3 \ )) @@ -625,6 +626,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impress_filter impress_OOXML_Template \ impress_OOXML_AutoPlay \ ClarisWorks_Impress \ + StarOffice_Presentation \ MWAW_Presentation \ PowerPoint3 \ )) diff --git a/filter/source/config/fragments/filters/StarOffice_Presentation.xcu b/filter/source/config/fragments/filters/StarOffice_Presentation.xcu new file mode 100644 index 000000000000..7179379d74d6 --- /dev/null +++ b/filter/source/config/fragments/filters/StarOffice_Presentation.xcu @@ -0,0 +1,29 @@ +<!-- + * 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/. + * +--> + +<node oor:name="StarOffice_Presentation" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Impress.StarOfficePresentationImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">Legacy StarOffice Presentation</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>StarOffice_Presentation</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.presentation.PresentationDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/StarOffice_Presentation.xcu b/filter/source/config/fragments/types/StarOffice_Presentation.xcu new file mode 100644 index 000000000000..02c0f3af67a8 --- /dev/null +++ b/filter/source/config/fragments/types/StarOffice_Presentation.xcu @@ -0,0 +1,27 @@ +<!-- + * 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/. + * +--> + +<node oor:name="StarOffice_Presentation" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Impress.StarOfficePresentationImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>sdd</value> + </prop> + <prop oor:name="MediaType"/> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>StarOffice_Presentation</value> + </prop> + <prop oor:name="UIName"> + <value>Legacy StarOffice Presentation</value> + </prop> +</node> diff --git a/writerperfect/Library_wpftimpress.mk b/writerperfect/Library_wpftimpress.mk index 116b72a1235a..18c8afa110bc 100644 --- a/writerperfect/Library_wpftimpress.mk +++ b/writerperfect/Library_wpftimpress.mk @@ -49,6 +49,7 @@ $(eval $(call gb_Library_use_externals,wpftimpress,\ etonyek \ mwaw \ odfgen \ + staroffice \ revenge \ zlib \ libxml2 \ @@ -57,6 +58,7 @@ $(eval $(call gb_Library_use_externals,wpftimpress,\ $(eval $(call gb_Library_add_exception_objects,wpftimpress,\ writerperfect/source/impress/KeynoteImportFilter \ writerperfect/source/impress/MWAWPresentationImportFilter \ + writerperfect/source/impress/StarOfficePresentationImportFilter \ )) # vim: set noet sw=4 ts=4: diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx index 4c4998cbaca7..4137cd6f5425 100644 --- a/writerperfect/source/common/WPXSvInputStream.cxx +++ b/writerperfect/source/common/WPXSvInputStream.cxx @@ -105,7 +105,7 @@ const rtl::OUString concatPath(const rtl::OUString &lhs, const rtl::OUString &rh struct OLEStreamData { - explicit OLEStreamData(const rtl::OString &rName); + OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName); SotStorageStreamRefWrapper stream; @@ -115,6 +115,12 @@ struct OLEStreamData * produce const char* from it. */ rtl::OString name; + /** librevenge name of the stream. + * + * This is not @c rtl::OUString, because we need to be able to + * produce const char* from it. + */ + rtl::OString RVNGname; }; typedef std::unordered_map<rtl::OUString, std::size_t, rtl::OUStringHash> NameMap_t; @@ -158,9 +164,10 @@ public: bool mbInitialized; }; -OLEStreamData::OLEStreamData(const rtl::OString &rName) +OLEStreamData::OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName) : stream() , name(rName) + , RVNGname(rvngName) { } @@ -197,7 +204,7 @@ tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString &rP return tools::SvRef<SotStorageStream>(); if (!maStreams[aIt->second].stream.ref.is()) - maStreams[aIt->second].stream.ref = createStream(aPath); + maStreams[aIt->second].stream.ref = createStream(rtl::OStringToOUString(maStreams[aIt->second].name, RTL_TEXTENCODING_UTF8)); return maStreams[aIt->second].stream.ref; } @@ -220,8 +227,13 @@ void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rt { if (aIt->IsStream()) { - maStreams.push_back(OLEStreamData(rtl::OUStringToOString(concatPath(rPath, aIt->GetName()), RTL_TEXTENCODING_UTF8))); - maNameMap[concatPath(rPath, aIt->GetName())] = maStreams.size() - 1; + rtl::OUString baseName=aIt->GetName(), rvngName=baseName; + // librevenge::RVNGOLEStream ignores the first character when is a control code, so ... + if (!rvngName.isEmpty() && rvngName.toChar()<32) + rvngName=rvngName.copy(1); + maStreams.push_back(OLEStreamData(rtl::OUStringToOString(concatPath(rPath, baseName), RTL_TEXTENCODING_UTF8), + rtl::OUStringToOString(concatPath(rPath, rvngName), RTL_TEXTENCODING_UTF8))); + maNameMap[concatPath(rPath, rvngName)] = maStreams.size() - 1; } else if (aIt->IsStorage()) { @@ -590,7 +602,7 @@ const char *WPXSvInputStreamImpl::subStreamName(const unsigned id) if (mpOLEStorage->maStreams.size() <= id) return nullptr; - return mpOLEStorage->maStreams[id].name.getStr(); + return mpOLEStorage->maStreams[id].RVNGname.getStr(); } mxSeekable->seek(0); diff --git a/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx b/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx new file mode 100644 index 000000000000..00fdd5b22933 --- /dev/null +++ b/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx @@ -0,0 +1,95 @@ +/* -*- 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 "StarOfficePresentationImportFilter.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 StarOfficePresentationImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) +{ + return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator); +} + +bool StarOfficePresentationImportFilter::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_PRESENTATION: + rTypeName = "StarOffice_Presentation"; + break; + default: + break; + } + } + + return !rTypeName.isEmpty(); +} + +void StarOfficePresentationImportFilter::doRegisterHandlers(OdpGenerator &rGenerator) +{ + rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject); +} + +// XServiceInfo +OUString SAL_CALL StarOfficePresentationImportFilter::getImplementationName() +{ + return OUString("org.libreoffice.comp.Impress.StarOfficePresentationImportFilter"); +} + +sal_Bool SAL_CALL StarOfficePresentationImportFilter::supportsService(const OUString &rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +Sequence< OUString > SAL_CALL StarOfficePresentationImportFilter::getSupportedServiceNames() +{ + 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_Presentation_StarOfficePresentationImportFilter_get_implementation( + css::uno::XComponentContext *const context, + const css::uno::Sequence<css::uno::Any> &) +{ + return cppu::acquire(new StarOfficePresentationImportFilter(context)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx b/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx new file mode 100644 index 000000000000..3651315b0e3a --- /dev/null +++ b/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx @@ -0,0 +1,42 @@ +/* -*- 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_PRESENTATION_STAROFFICEPRESENTATIONIMPORTFILTER_HXX +#define INCLUDED_WRITERPERFECT_SOURCE_PRESENTATION_STAROFFICEPRESENTATIONIMPORTFILTER_HXX + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include "ImportFilter.hxx" + +#include "DocumentHandlerForOdp.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 StarOfficePresentationImportFilter : public writerperfect::ImportFilter<OdpGenerator> +{ +public: + explicit StarOfficePresentationImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + : writerperfect::ImportFilter<OdpGenerator>(rxContext) {} + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +private: + virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual void doRegisterHandlers(OdpGenerator &rGenerator) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/impress/wpftimpress.component b/writerperfect/source/impress/wpftimpress.component index 5413c9a7b4bd..0f7df39fa94e 100644 --- a/writerperfect/source/impress/wpftimpress.component +++ b/writerperfect/source/impress/wpftimpress.component @@ -19,4 +19,9 @@ <service name="com.sun.star.document.ImportFilter"/> <service name="com.sun.star.document.ExtendedTypeDetection"/> </implementation> + <implementation name="org.libreoffice.comp.Impress.StarOfficePresentationImportFilter" + constructor="org_libreoffice_comp_Presentation_StarOfficePresentationImportFilter_get_implementation"> + <service name="com.sun.star.document.ImportFilter"/> + <service name="com.sun.star.document.ExtendedTypeDetection"/> + </implementation> </component> commit b0067c89e6b2a4e29465d9da9a731ae30a66dce6 Author: osnola <alo...@loria.fr> Date: Sun Apr 2 09:42:59 2017 +0200 libwps import filter improvements + some astyle modifications, + add .wk4 and .123 to the list of file extensions, + add support to open Lotus files protected by a password. Change-Id: I94d4afffd73f0999ff2b1958704cb3985fcd0cc9 diff --git a/filter/source/config/fragments/types/calc_WPS_Lotus_Document.xcu b/filter/source/config/fragments/types/calc_WPS_Lotus_Document.xcu index 0ecc7114c3ed..abea24321e6b 100644 --- a/filter/source/config/fragments/types/calc_WPS_Lotus_Document.xcu +++ b/filter/source/config/fragments/types/calc_WPS_Lotus_Document.xcu @@ -18,7 +18,7 @@ <node oor:name="calc_WPS_Lotus_Document" oor:op="replace" > <prop oor:name="DetectService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop> <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>wk1 wk3</value></prop> + <prop oor:name="Extensions"><value>wk1 wk3 wk4 123</value></prop> <prop oor:name="MediaType"></prop> <prop oor:name="Preferred"><value>true</value></prop> <prop oor:name="PreferredFilter"><value>WPS_Lotus_Calc</value></prop> diff --git a/writerperfect/Library_wpftcalc.mk b/writerperfect/Library_wpftcalc.mk index 311741d26f5d..c4aecf391d44 100644 --- a/writerperfect/Library_wpftcalc.mk +++ b/writerperfect/Library_wpftcalc.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,wpftcalc,\ cppu \ cppuhelper \ sal \ + sfx \ sot \ svx \ tl \ diff --git a/writerperfect/qa/unit/DrawingImportTest.cxx b/writerperfect/qa/unit/DrawingImportTest.cxx index 433c9a4458c4..661f851d3a0f 100644 --- a/writerperfect/qa/unit/DrawingImportTest.cxx +++ b/writerperfect/qa/unit/DrawingImportTest.cxx @@ -120,7 +120,7 @@ void DrawingImportTest::test() { using namespace css; - rtl::Reference<DrawingImportFilter> xFilter{new DrawingImportFilter(m_xContext)}; + rtl::Reference<DrawingImportFilter> xFilter {new DrawingImportFilter(m_xContext)}; writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/sdraw", m_xDesktop, m_xContext); uno::Reference<drawing::XDrawPagesSupplier> xDoc(aLoader.getDocument(), uno::UNO_QUERY); diff --git a/writerperfect/qa/unit/PresentationImportTest.cxx b/writerperfect/qa/unit/PresentationImportTest.cxx index 7c1154ba6cfa..4181d55be85b 100644 --- a/writerperfect/qa/unit/PresentationImportTest.cxx +++ b/writerperfect/qa/unit/PresentationImportTest.cxx @@ -120,7 +120,7 @@ void PresentationImportTest::test() { using namespace css; - rtl::Reference<PresentationImportFilter> xFilter{new PresentationImportFilter(m_xContext)}; + rtl::Reference<PresentationImportFilter> xFilter {new PresentationImportFilter(m_xContext)}; writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/simpress", m_xDesktop, m_xContext); uno::Reference<drawing::XDrawPagesSupplier> xDoc(aLoader.getDocument(), uno::UNO_QUERY); diff --git a/writerperfect/qa/unit/SpreadsheetImportTest.cxx b/writerperfect/qa/unit/SpreadsheetImportTest.cxx index 379f57ae1fd5..55d03151924b 100644 --- a/writerperfect/qa/unit/SpreadsheetImportTest.cxx +++ b/writerperfect/qa/unit/SpreadsheetImportTest.cxx @@ -115,7 +115,7 @@ void SpreadsheetImportTest::test() { using namespace css; - rtl::Reference<SpreadsheetImportFilter> xFilter{new SpreadsheetImportFilter(m_xContext)}; + rtl::Reference<SpreadsheetImportFilter> xFilter {new SpreadsheetImportFilter(m_xContext)}; writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/scalc", m_xDesktop, m_xContext); uno::Reference<sheet::XSpreadsheetDocument> xDoc(aLoader.getDocument(), uno::UNO_QUERY); diff --git a/writerperfect/qa/unit/TextImportTest.cxx b/writerperfect/qa/unit/TextImportTest.cxx index ba464c6c0ac4..4789d003abec 100644 --- a/writerperfect/qa/unit/TextImportTest.cxx +++ b/writerperfect/qa/unit/TextImportTest.cxx @@ -108,7 +108,7 @@ void TextImportTest::test() { using namespace css; - rtl::Reference<TextImportFilter> xFilter{new TextImportFilter(m_xContext)}; + rtl::Reference<TextImportFilter> xFilter {new TextImportFilter(m_xContext)}; writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/swriter", m_xDesktop, m_xContext); uno::Reference<text::XTextDocument> xDoc(aLoader.getDocument(), uno::UNO_QUERY); diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index 94a111ec7127..11881202ad28 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/ucb/XContentAccess.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/supportsservice.hxx> +#include <sfx2/passwd.hxx> #include <tools/urlobj.hxx> #include <ucbhelper/content.hxx> @@ -90,7 +91,7 @@ public: /*! \brief seeks to a offset position, from actual, beginning or ending position * \return 0 if ok */ - int seek(long , librevenge::RVNG_SEEK_TYPE) override + int seek(long, librevenge::RVNG_SEEK_TYPE) override { return 1; } @@ -191,8 +192,10 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp bool needEncoding; const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); + if ((kind != libwps::WPS_SPREADSHEET && kind != libwps::WPS_DATABASE) || (confidence == libwps::WPS_CONFIDENCE_NONE)) + return false; std::string fileEncoding(""); - if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding) + if (needEncoding) { OUString title, encoding; if (creator == libwps::WPS_MSWORKS) @@ -232,7 +235,25 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp SAL_WARN("writerperfect", "ignoring Exception in MSWorksCalcImportFilter::doImportDocument"); } } - return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator, "", fileEncoding.c_str()); + OString aUtf8Passwd; + if (confidence==libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION) + { + // try to ask for a password + try + { + ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr); + aPasswdDlg->SetMinLen(1); + if (!aPasswdDlg->Execute()) + return false; + OUString aPasswd = aPasswdDlg->GetPassword(); + aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); + } + catch (...) + { + return false; + } + } + return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator, confidence==libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION ? aUtf8Passwd.getStr() : nullptr, fileEncoding.c_str()); } //XExtendedFilterDetection @@ -326,12 +347,12 @@ sal_Bool MSWorksCalcImportFilter::filter(const css::uno::Sequence< css::beans::P structuredInput.addFile(sWM3Name,"WK3"); structuredInput.addFile(sFM3Name,"FM3"); - // If the file is valid and libwps is at least 0.4.4, doImportDocument will convert it. - // If libwps is at most 0.4.3, doImportDocument will fail when checking if the file is supported - // and it is ok to call again doImportDocument with the main input. - // If the file is corrupted beyond all retrieval, doImportDocument will fail two times :-~ - if (this->doImportDocument(structuredInput, exporter, aDescriptor)) - return true; + libwps::WPSKind kind = libwps::WPS_TEXT; + libwps::WPSCreator creator; + bool needEncoding; + const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&structuredInput, kind, creator, needEncoding); + if (confidence!=libwps::WPS_CONFIDENCE_NONE) + return this->doImportDocument(structuredInput, exporter, aDescriptor); } } } @@ -350,7 +371,7 @@ bool MSWorksCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput bool needEncoding; const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); - if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && confidence == libwps::WPS_CONFIDENCE_EXCELLENT) + if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && confidence != libwps::WPS_CONFIDENCE_NONE) { if (creator == libwps::WPS_MSWORKS) { diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx index 29788200b6de..a38f8fc0fcf8 100644 --- a/writerperfect/source/common/DocumentHandler.cxx +++ b/writerperfect/source/common/DocumentHandler.cxx @@ -111,10 +111,10 @@ using com::sun::star::xml::sax::XAttributeList; using com::sun::star::xml::sax::XDocumentHandler; DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) : - mxHandler( xHandler ) + mxHandler(xHandler) { - if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get())) - mxHandler.set( new SvXMLLegacyToFastDocHandler( pFastHandler ) ); + if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport *>(mxHandler.get())) + mxHandler.set(new SvXMLLegacyToFastDocHandler(pFastHandler)); } void DocumentHandler::startDocument() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits