diff options
123 files changed, 2743 insertions, 2612 deletions
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index c9a12c4d57d7..27fd14f8d24f 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -18803,130 +18803,6 @@ writerfilter/source/ooxml/OOXMLPropertySet.hxx writerfilter/source/ooxml/OOXMLStreamImpl.cxx writerfilter/source/ooxml/OOXMLStreamImpl.hxx writerfilter/source/ooxml/qnametostrcore.cxx -writerperfect/inc/DirectoryStream.hxx -writerperfect/inc/DocumentHandler.hxx -writerperfect/inc/DocumentHandlerFor.hxx -writerperfect/inc/DocumentHandlerForOdg.hxx -writerperfect/inc/DocumentHandlerForOdp.hxx -writerperfect/inc/DocumentHandlerForOds.hxx -writerperfect/inc/DocumentHandlerForOdt.hxx -writerperfect/inc/ImportFilter.hxx -writerperfect/inc/WPFTEncodingDialog.hxx -writerperfect/inc/WPFTResMgr.hxx -writerperfect/inc/WPXSvInputStream.hxx -writerperfect/inc/writerperfectdllapi.h -writerperfect/qa/unit/DirectoryStreamTest.cxx -writerperfect/qa/unit/DrawingImportTest.cxx -writerperfect/qa/unit/EPUBExportTest.cxx -writerperfect/qa/unit/ImportTest.cxx -writerperfect/qa/unit/PresentationImportTest.cxx -writerperfect/qa/unit/SpreadsheetImportTest.cxx -writerperfect/qa/unit/TextImportTest.cxx -writerperfect/qa/unit/WPXSvStreamTest.cxx -writerperfect/qa/unit/WpftCalcFilterTest.cxx -writerperfect/qa/unit/WpftDrawFilterTest.cxx -writerperfect/qa/unit/WpftFilterFixture.cxx -writerperfect/qa/unit/WpftFilterFixture.hxx -writerperfect/qa/unit/WpftFilterTestBase.cxx -writerperfect/qa/unit/WpftFilterTestBase.hxx -writerperfect/qa/unit/WpftImpressFilterTest.cxx -writerperfect/qa/unit/WpftLoader.cxx -writerperfect/qa/unit/WpftLoader.hxx -writerperfect/qa/unit/WpftWriterFilterTest.cxx -writerperfect/qa/unit/stream.cxx -writerperfect/qa/unit/wpftimport.cxx -writerperfect/qa/unit/wpftimport.hxx -writerperfect/qa/unit/wpftqahelperdllapi.h -writerperfect/source/calc/MSWorksCalcImportFilter.cxx -writerperfect/source/calc/MSWorksCalcImportFilter.hxx -writerperfect/source/calc/MWAWCalcImportFilter.cxx -writerperfect/source/calc/MWAWCalcImportFilter.hxx -writerperfect/source/calc/NumbersImportFilter.cxx -writerperfect/source/calc/NumbersImportFilter.hxx -writerperfect/source/calc/StarOfficeCalcImportFilter.cxx -writerperfect/source/calc/StarOfficeCalcImportFilter.hxx -writerperfect/source/common/DirectoryStream.cxx -writerperfect/source/common/DocumentHandler.cxx -writerperfect/source/common/WPFTEncodingDialog.cxx -writerperfect/source/common/WPXSvInputStream.cxx -writerperfect/source/draw/CDRImportFilter.cxx -writerperfect/source/draw/CDRImportFilter.hxx -writerperfect/source/draw/CMXImportFilter.cxx -writerperfect/source/draw/CMXImportFilter.hxx -writerperfect/source/draw/FreehandImportFilter.cxx -writerperfect/source/draw/FreehandImportFilter.hxx -writerperfect/source/draw/MSPUBImportFilter.cxx -writerperfect/source/draw/MSPUBImportFilter.hxx -writerperfect/source/draw/MWAWDrawImportFilter.cxx -writerperfect/source/draw/MWAWDrawImportFilter.hxx -writerperfect/source/draw/PageMakerImportFilter.cxx -writerperfect/source/draw/PageMakerImportFilter.hxx -writerperfect/source/draw/QXPImportFilter.cxx -writerperfect/source/draw/QXPImportFilter.hxx -writerperfect/source/draw/StarOfficeDrawImportFilter.cxx -writerperfect/source/draw/StarOfficeDrawImportFilter.hxx -writerperfect/source/draw/VisioImportFilter.cxx -writerperfect/source/draw/VisioImportFilter.hxx -writerperfect/source/draw/WPGImportFilter.cxx -writerperfect/source/draw/WPGImportFilter.hxx -writerperfect/source/draw/ZMFImportFilter.cxx -writerperfect/source/draw/ZMFImportFilter.hxx -writerperfect/source/impress/KeynoteImportFilter.cxx -writerperfect/source/impress/KeynoteImportFilter.hxx -writerperfect/source/impress/MWAWPresentationImportFilter.cxx -writerperfect/source/impress/MWAWPresentationImportFilter.hxx -writerperfect/source/impress/StarOfficePresentationImportFilter.cxx -writerperfect/source/impress/StarOfficePresentationImportFilter.hxx -writerperfect/source/writer/AbiWordImportFilter.cxx -writerperfect/source/writer/AbiWordImportFilter.hxx -writerperfect/source/writer/EBookImportFilter.cxx -writerperfect/source/writer/EBookImportFilter.hxx -writerperfect/source/writer/EPUBExportDialog.cxx -writerperfect/source/writer/EPUBExportDialog.hxx -writerperfect/source/writer/EPUBExportFilter.cxx -writerperfect/source/writer/EPUBExportFilter.hxx -writerperfect/source/writer/EPUBExportUIComponent.cxx -writerperfect/source/writer/EPUBExportUIComponent.hxx -writerperfect/source/writer/EPUBPackage.cxx -writerperfect/source/writer/EPUBPackage.hxx -writerperfect/source/writer/MSWorksImportFilter.cxx -writerperfect/source/writer/MSWorksImportFilter.hxx -writerperfect/source/writer/MWAWImportFilter.cxx -writerperfect/source/writer/MWAWImportFilter.hxx -writerperfect/source/writer/PagesImportFilter.cxx -writerperfect/source/writer/PagesImportFilter.hxx -writerperfect/source/writer/StarOfficeWriterImportFilter.cxx -writerperfect/source/writer/StarOfficeWriterImportFilter.hxx -writerperfect/source/writer/WordPerfectImportFilter.cxx -writerperfect/source/writer/WordPerfectImportFilter.hxx -writerperfect/source/writer/exp/XMLBase64ImportContext.cxx -writerperfect/source/writer/exp/XMLBase64ImportContext.hxx -writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx -writerperfect/source/writer/exp/XMLFootnoteImportContext.hxx -writerperfect/source/writer/exp/XMLSectionContext.cxx -writerperfect/source/writer/exp/XMLSectionContext.hxx -writerperfect/source/writer/exp/XMLTextFrameContext.cxx -writerperfect/source/writer/exp/XMLTextFrameContext.hxx -writerperfect/source/writer/exp/XMLTextListContext.cxx -writerperfect/source/writer/exp/XMLTextListContext.hxx -writerperfect/source/writer/exp/XMLTextListItemContext.cxx -writerperfect/source/writer/exp/XMLTextListItemContext.hxx -writerperfect/source/writer/exp/txtparai.cxx -writerperfect/source/writer/exp/txtparai.hxx -writerperfect/source/writer/exp/txtstyli.cxx -writerperfect/source/writer/exp/txtstyli.hxx -writerperfect/source/writer/exp/xmlfmt.cxx -writerperfect/source/writer/exp/xmlfmt.hxx -writerperfect/source/writer/exp/xmlictxt.cxx -writerperfect/source/writer/exp/xmlictxt.hxx -writerperfect/source/writer/exp/xmlimp.cxx -writerperfect/source/writer/exp/xmlimp.hxx -writerperfect/source/writer/exp/xmlmetai.cxx -writerperfect/source/writer/exp/xmlmetai.hxx -writerperfect/source/writer/exp/xmltbli.cxx -writerperfect/source/writer/exp/xmltbli.hxx -writerperfect/source/writer/exp/xmltext.cxx -writerperfect/source/writer/exp/xmltext.hxx xmlhelp/source/cxxhelp/inc/qe/DocGenerator.hxx xmlhelp/source/cxxhelp/inc/tvfactory.hxx xmlhelp/source/cxxhelp/inc/tvread.hxx diff --git a/writerperfect/README b/writerperfect/README index 2207b6fb19df..9edcb4011ec0 100644 --- a/writerperfect/README +++ b/writerperfect/README @@ -4,9 +4,3 @@ This collection of filters is here in this folder in addition to the WordPerfect filter that gave the module its (humorous) name "writerperfect" because the libraries they use all have the same "style" of API and are developed, at least partially, by the same person or group of persons. - -This module uses astyle to keep consistent coding style. Please run - -astyle --options=astyle.options \*.?xx - -before committing. diff --git a/writerperfect/astyle.options b/writerperfect/astyle.options deleted file mode 100644 index b7cc7d063aa8..000000000000 --- a/writerperfect/astyle.options +++ /dev/null @@ -1,12 +0,0 @@ -# formatting options -style=allman -indent=spaces=4 -align-pointer=name -break-closing-brackets -pad-header -unpad-paren -max-instatement-indent=120 - -# processing options -recursive -suffix=none diff --git a/writerperfect/inc/DirectoryStream.hxx b/writerperfect/inc/DirectoryStream.hxx index 0421f9ced8cd..5fb9d2b8d3db 100644 --- a/writerperfect/inc/DirectoryStream.hxx +++ b/writerperfect/inc/DirectoryStream.hxx @@ -32,28 +32,28 @@ class XContent; namespace writerperfect { - class WRITERPERFECT_DLLPUBLIC DirectoryStream : public librevenge::RVNGInputStream { struct Impl; public: - explicit DirectoryStream(const css::uno::Reference<css::ucb::XContent> &xContent); + explicit DirectoryStream(const css::uno::Reference<css::ucb::XContent>& xContent); virtual ~DirectoryStream() override; - static bool isDirectory(const css::uno::Reference<css::ucb::XContent> &xContent); - static std::unique_ptr<DirectoryStream> createForParent(const css::uno::Reference<css::ucb::XContent> &xContent); + static bool isDirectory(const css::uno::Reference<css::ucb::XContent>& xContent); + static std::unique_ptr<DirectoryStream> + createForParent(const css::uno::Reference<css::ucb::XContent>& xContent); const css::uno::Reference<css::ucb::XContent> getContent() const; virtual bool isStructured() override; virtual unsigned subStreamCount() override; - virtual const char *subStreamName(unsigned id) override; - virtual bool existsSubStream(const char *name) override; - virtual librevenge::RVNGInputStream *getSubStreamByName(const char *name) override; - virtual librevenge::RVNGInputStream *getSubStreamById(unsigned id) override; + virtual const char* subStreamName(unsigned id) override; + virtual bool existsSubStream(const char* name) override; + virtual librevenge::RVNGInputStream* getSubStreamByName(const char* name) override; + virtual librevenge::RVNGInputStream* getSubStreamById(unsigned id) override; - virtual const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) override; + virtual const unsigned char* read(unsigned long numBytes, unsigned long& numBytesRead) override; virtual int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override; virtual long tell() override; virtual bool isEnd() override; @@ -61,7 +61,6 @@ public: private: std::unique_ptr<Impl> m_pImpl; }; - } #endif // INCLUDED_WRITERPERFECT_DIRECTORYSTREAM_HXX diff --git a/writerperfect/inc/DocumentHandler.hxx b/writerperfect/inc/DocumentHandler.hxx index 03188c995f68..ab7b15dd6aab 100644 --- a/writerperfect/inc/DocumentHandler.hxx +++ b/writerperfect/inc/DocumentHandler.hxx @@ -47,21 +47,19 @@ class XDocumentHandler; namespace writerperfect { - -class WRITERPERFECT_DLLPUBLIC DocumentHandler: public OdfDocumentHandler +class WRITERPERFECT_DLLPUBLIC DocumentHandler : public OdfDocumentHandler { public: - DocumentHandler(css::uno::Reference < css::xml::sax::XDocumentHandler > const &xHandler); + DocumentHandler(css::uno::Reference<css::xml::sax::XDocumentHandler> const& xHandler); void startDocument() override; void endDocument() override; - void startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList) override; - void endElement(const char *psName) override; - void characters(const librevenge::RVNGString &sCharacters) override; + void startElement(const char* psName, const librevenge::RVNGPropertyList& xPropList) override; + void endElement(const char* psName) override; + void characters(const librevenge::RVNGString& sCharacters) override; private: - css::uno::Reference < css::xml::sax::XDocumentHandler > mxHandler; + css::uno::Reference<css::xml::sax::XDocumentHandler> mxHandler; }; - } #endif // INCLUDED_WRITERPERFECT_DOCUMENTHANDLER_HXX diff --git a/writerperfect/inc/DocumentHandlerFor.hxx b/writerperfect/inc/DocumentHandlerFor.hxx index fbe10a795e8d..dabd4ffcc5ef 100644 --- a/writerperfect/inc/DocumentHandlerFor.hxx +++ b/writerperfect/inc/DocumentHandlerFor.hxx @@ -10,17 +10,14 @@ namespace writerperfect { - /** Definition of XML import service used with a Generator. This template must be specialized for every libodfgen generator. */ -template<class Generator> -struct DocumentHandlerFor +template <class Generator> struct DocumentHandlerFor { // static const rtl::OUString name(); }; - } #endif // INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_DOCUMENTHANDLERFOR_HXX diff --git a/writerperfect/inc/DocumentHandlerForOdg.hxx b/writerperfect/inc/DocumentHandlerForOdg.hxx index 4f64066a42ed..96cb288f6ba7 100644 --- a/writerperfect/inc/DocumentHandlerForOdg.hxx +++ b/writerperfect/inc/DocumentHandlerForOdg.hxx @@ -14,16 +14,13 @@ namespace writerperfect { - -template<> -struct DocumentHandlerFor<OdgGenerator> +template <> struct DocumentHandlerFor<OdgGenerator> { static const rtl::OUString name() { return rtl::OUString("com.sun.star.comp.Draw.XMLOasisImporter"); } }; - } #endif diff --git a/writerperfect/inc/DocumentHandlerForOdp.hxx b/writerperfect/inc/DocumentHandlerForOdp.hxx index 83190470d2fe..0ca91c65bd06 100644 --- a/writerperfect/inc/DocumentHandlerForOdp.hxx +++ b/writerperfect/inc/DocumentHandlerForOdp.hxx @@ -14,16 +14,13 @@ namespace writerperfect { - -template<> -struct DocumentHandlerFor<OdpGenerator> +template <> struct DocumentHandlerFor<OdpGenerator> { static const rtl::OUString name() { return rtl::OUString("com.sun.star.comp.Impress.XMLOasisImporter"); } }; - } #endif diff --git a/writerperfect/inc/DocumentHandlerForOds.hxx b/writerperfect/inc/DocumentHandlerForOds.hxx index e7762c40eb4d..60f96d2332cd 100644 --- a/writerperfect/inc/DocumentHandlerForOds.hxx +++ b/writerperfect/inc/DocumentHandlerForOds.hxx @@ -14,16 +14,13 @@ namespace writerperfect { - -template<> -struct DocumentHandlerFor<OdsGenerator> +template <> struct DocumentHandlerFor<OdsGenerator> { static const rtl::OUString name() { return rtl::OUString("com.sun.star.comp.Calc.XMLOasisImporter"); } }; - } #endif diff --git a/writerperfect/inc/DocumentHandlerForOdt.hxx b/writerperfect/inc/DocumentHandlerForOdt.hxx index 8607119a8c2b..e933644b534d 100644 --- a/writerperfect/inc/DocumentHandlerForOdt.hxx +++ b/writerperfect/inc/DocumentHandlerForOdt.hxx @@ -14,16 +14,13 @@ namespace writerperfect { - -template<> -struct DocumentHandlerFor<OdtGenerator> +template <> struct DocumentHandlerFor<OdtGenerator> { static const rtl::OUString name() { return rtl::OUString("com.sun.star.comp.Writer.XMLOasisImporter"); } }; - } #endif diff --git a/writerperfect/inc/ImportFilter.hxx b/writerperfect/inc/ImportFilter.hxx index c59fb9431a47..53029ef32176 100644 --- a/writerperfect/inc/ImportFilter.hxx +++ b/writerperfect/inc/ImportFilter.hxx @@ -41,35 +41,31 @@ namespace writerperfect { - namespace detail { - -template<class Generator> -class ImportFilterImpl : public cppu::WeakImplHelper - < - css::document::XFilter, - css::document::XImporter, - css::document::XExtendedFilterDetection, - css::lang::XInitialization - > +template <class Generator> +class ImportFilterImpl + : public cppu::WeakImplHelper<css::document::XFilter, css::document::XImporter, + css::document::XExtendedFilterDetection, + css::lang::XInitialization> { public: - ImportFilterImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + ImportFilterImpl(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : mxContext(rxContext) { } - const css::uno::Reference< css::uno::XComponentContext > &getXContext() const + const css::uno::Reference<css::uno::XComponentContext>& getXContext() const { return mxContext; } // XFilter - virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor) override + virtual sal_Bool SAL_CALL + filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) override { utl::MediaDescriptor aDescriptor(rDescriptor); - css::uno::Reference < css::io::XInputStream > xInputStream; + css::uno::Reference<css::io::XInputStream> xInputStream; aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; if (!xInputStream.is()) { @@ -78,13 +74,14 @@ public: } // An XML import service: what we push sax messages to.. - css::uno::Reference < css::xml::sax::XDocumentHandler > xInternalHandler( + css::uno::Reference<css::xml::sax::XDocumentHandler> xInternalHandler( mxContext->getServiceManager()->createInstanceWithContext( DocumentHandlerFor<Generator>::name(), mxContext), css::uno::UNO_QUERY_THROW); // The XImporter sets up an empty target document for XDocumentHandler to write to.. - css::uno::Reference < css::document::XImporter > xImporter(xInternalHandler, css::uno::UNO_QUERY); + css::uno::Reference<css::document::XImporter> xImporter(xInternalHandler, + css::uno::UNO_QUERY); xImporter->setTargetDocument(mxDoc); // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here @@ -101,32 +98,29 @@ public: return doImportDocument(input, exporter, aDescriptor); } - virtual void SAL_CALL cancel() override - { - } + virtual void SAL_CALL cancel() override {} // XImporter - const css::uno::Reference< css::lang::XComponent > &getTargetDocument() const - { - return mxDoc; - } - virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override + const css::uno::Reference<css::lang::XComponent>& getTargetDocument() const { return mxDoc; } + virtual void SAL_CALL + setTargetDocument(const css::uno::Reference<css::lang::XComponent>& xDoc) override { mxDoc = xDoc; } //XExtendedFilterDetection - virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) override + virtual OUString SAL_CALL + detect(css::uno::Sequence<css::beans::PropertyValue>& Descriptor) override { OUString sTypeName; sal_Int32 nLength = Descriptor.getLength(); sal_Int32 location = nLength; - const css::beans::PropertyValue *pValue = Descriptor.getConstArray(); - css::uno::Reference < css::io::XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) + const css::beans::PropertyValue* pValue = Descriptor.getConstArray(); + css::uno::Reference<css::io::XInputStream> xInputStream; + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "TypeName") - location=i; + location = i; else if (pValue[i].Name == "InputStream") pValue[i].Value >>= xInputStream; } @@ -142,26 +136,26 @@ public: if (location == nLength) { - Descriptor.realloc(nLength+1); + Descriptor.realloc(nLength + 1); Descriptor[location].Name = "TypeName"; } - Descriptor[location].Value <<=sTypeName; + Descriptor[location].Value <<= sTypeName; } return sTypeName; } // XInitialization - virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override { - css::uno::Sequence < css::beans::PropertyValue > aAnySeq; + css::uno::Sequence<css::beans::PropertyValue> aAnySeq; sal_Int32 nLength = aArguments.getLength(); if (nLength && (aArguments[0] >>= aAnySeq)) { - const css::beans::PropertyValue *pValue = aAnySeq.getConstArray(); + const css::beans::PropertyValue* pValue = aAnySeq.getConstArray(); nLength = aAnySeq.getLength(); - for (sal_Int32 i = 0 ; i < nLength; i++) + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "Type") { @@ -173,28 +167,30 @@ public: } private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, Generator &rGenerator, utl::MediaDescriptor &rDescriptor) = 0; - virtual void doRegisterHandlers(Generator &) {}; - - css::uno::Reference< css::uno::XComponentContext > mxContext; - css::uno::Reference< css::lang::XComponent > mxDoc; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) = 0; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, Generator& rGenerator, + utl::MediaDescriptor& rDescriptor) + = 0; + virtual void doRegisterHandlers(Generator&){}; + + css::uno::Reference<css::uno::XComponentContext> mxContext; + css::uno::Reference<css::lang::XComponent> mxDoc; OUString msFilterName; }; - } /** A base class for import filters. */ -template<class Generator> -struct ImportFilter : public cppu::ImplInheritanceHelper<detail::ImportFilterImpl<Generator>, css::lang::XServiceInfo> +template <class Generator> +struct ImportFilter : public cppu::ImplInheritanceHelper<detail::ImportFilterImpl<Generator>, + css::lang::XServiceInfo> { - ImportFilter(const css::uno::Reference<css::uno::XComponentContext> &rxContext) - : cppu::ImplInheritanceHelper<detail::ImportFilterImpl<Generator>, css::lang::XServiceInfo>(rxContext) + ImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : cppu::ImplInheritanceHelper<detail::ImportFilterImpl<Generator>, css::lang::XServiceInfo>( + rxContext) { } }; - } #endif // INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_IMPORTFILTER_HXX diff --git a/writerperfect/inc/WPFTEncodingDialog.hxx b/writerperfect/inc/WPFTEncodingDialog.hxx index 1730f760a1ca..c6c501ff1af7 100644 --- a/writerperfect/inc/WPFTEncodingDialog.hxx +++ b/writerperfect/inc/WPFTEncodingDialog.hxx @@ -22,35 +22,32 @@ namespace writerperfect { - class WRITERPERFECT_DLLPUBLIC WPFTEncodingDialog : public ModalDialog { public: - WPFTEncodingDialog(const OUString &title, const OUString &defEncoding); + WPFTEncodingDialog(const OUString& title, const OUString& defEncoding); virtual ~WPFTEncodingDialog() override; OUString GetEncoding() const; - bool hasUserCalledCancel() const - { - return m_userHasCancelled; - } + bool hasUserCalledCancel() const { return m_userHasCancelled; } + private: VclPtr<ListBox> m_pLbCharset; - VclPtr<OKButton> m_pBtnOk; - VclPtr<CancelButton> m_pBtnCancel; + VclPtr<OKButton> m_pBtnOk; + VclPtr<CancelButton> m_pBtnCancel; bool m_userHasCancelled; + private: - DECL_LINK(DoubleClickHdl, ListBox &, void); - DECL_LINK(CancelHdl, Button *, void); + DECL_LINK(DoubleClickHdl, ListBox&, void); + DECL_LINK(CancelHdl, Button*, void); void dispose() override; - WPFTEncodingDialog(WPFTEncodingDialog const &) = delete; - WPFTEncodingDialog &operator=(WPFTEncodingDialog const &) = delete; + WPFTEncodingDialog(WPFTEncodingDialog const&) = delete; + WPFTEncodingDialog& operator=(WPFTEncodingDialog const&) = delete; }; - } #endif diff --git a/writerperfect/inc/WPFTResMgr.hxx b/writerperfect/inc/WPFTResMgr.hxx index 1ac6796bb91e..a6cd38951716 100644 --- a/writerperfect/inc/WPFTResMgr.hxx +++ b/writerperfect/inc/WPFTResMgr.hxx @@ -7,10 +7,7 @@ #include <unotools/resmgr.hxx> -inline OUString WpResId(const char *pId) -{ - return Translate::get(pId, Translate::Create("wpt")); -} +inline OUString WpResId(const char* pId) { return Translate::get(pId, Translate::Create("wpt")); } #endif diff --git a/writerperfect/inc/WPXSvInputStream.hxx b/writerperfect/inc/WPXSvInputStream.hxx index e04158604714..f67e4159e28d 100644 --- a/writerperfect/inc/WPXSvInputStream.hxx +++ b/writerperfect/inc/WPXSvInputStream.hxx @@ -32,23 +32,22 @@ class XSeekable; namespace writerperfect { - class WPXSvInputStreamImpl; class WRITERPERFECT_DLLPUBLIC WPXSvInputStream : public librevenge::RVNGInputStream { public: - WPXSvInputStream(css::uno::Reference< css::io::XInputStream > const &xStream); + WPXSvInputStream(css::uno::Reference<css::io::XInputStream> const& xStream); virtual ~WPXSvInputStream() override; virtual bool isStructured() override; virtual unsigned subStreamCount() override; - virtual const char *subStreamName(unsigned id) override; - virtual bool existsSubStream(const char *name) override; - virtual librevenge::RVNGInputStream *getSubStreamByName(const char *name) override; - virtual librevenge::RVNGInputStream *getSubStreamById(unsigned id) override; + virtual const char* subStreamName(unsigned id) override; + virtual bool existsSubStream(const char* name) override; + virtual librevenge::RVNGInputStream* getSubStreamByName(const char* name) override; + virtual librevenge::RVNGInputStream* getSubStreamById(unsigned id) override; - virtual const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) override; + virtual const unsigned char* read(unsigned long numBytes, unsigned long& numBytesRead) override; virtual int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override; virtual long tell() override; virtual bool isEnd() override; @@ -56,7 +55,6 @@ public: private: std::unique_ptr<WPXSvInputStreamImpl> mpImpl; }; - } #endif // INCLUDED_WRITERPERFECT_WPXSVINPUTSTREAM_HXX diff --git a/writerperfect/qa/unit/DirectoryStreamTest.cxx b/writerperfect/qa/unit/DirectoryStreamTest.cxx index 730ce41aa718..8584184cfaad 100644 --- a/writerperfect/qa/unit/DirectoryStreamTest.cxx +++ b/writerperfect/qa/unit/DirectoryStreamTest.cxx @@ -33,7 +33,6 @@ using writerperfect::DirectoryStream; namespace { - class DirectoryStreamTest : public test::BootstrapFixture { public: @@ -72,7 +71,8 @@ DirectoryStreamTest::DirectoryStreamTest() m_xDir = Content(m_directories.getURLFromSrc(g_aDirPath), xCmdEnv, xContext).get(); m_xFile = Content(m_directories.getURLFromSrc(g_aNondirPath), xCmdEnv, xContext).get(); - m_xNonexistent = Content(m_directories.getURLFromSrc(g_aNonexistentPath), xCmdEnv, xContext).get(); + m_xNonexistent + = Content(m_directories.getURLFromSrc(g_aNonexistentPath), xCmdEnv, xContext).get(); } void DirectoryStreamTest::testConstruction() @@ -102,7 +102,7 @@ void DirectoryStreamTest::testDetection() CPPUNIT_ASSERT(!DirectoryStream::isDirectory(m_xNonexistent)); } -void lcl_testDataOperations(RVNGInputStream &rStream) +void lcl_testDataOperations(RVNGInputStream& rStream) { CPPUNIT_ASSERT(rStream.isEnd()); CPPUNIT_ASSERT_EQUAL(0L, rStream.tell()); @@ -125,7 +125,7 @@ void DirectoryStreamTest::testDataOperations() lcl_testDataOperations(aFile); } -void lcl_testStructuredOperations(RVNGInputStream &rStream) +void lcl_testStructuredOperations(RVNGInputStream& rStream) { CPPUNIT_ASSERT(rStream.isStructured()); unique_ptr<RVNGInputStream> pSubstream(rStream.getSubStreamByName("mimetype")); @@ -145,7 +145,6 @@ void DirectoryStreamTest::testStructuredOperations() } CPPUNIT_TEST_SUITE_REGISTRATION(DirectoryStreamTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/DrawingImportTest.cxx b/writerperfect/qa/unit/DrawingImportTest.cxx index 06bb33aeec7f..f2e0a707a32b 100644 --- a/writerperfect/qa/unit/DrawingImportTest.cxx +++ b/writerperfect/qa/unit/DrawingImportTest.cxx @@ -27,34 +27,38 @@ namespace { - namespace uno = css::uno; class DrawingImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit DrawingImportFilter(const uno::Reference< uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdgGenerator>(rxContext) {} + explicit DrawingImportFilter(const uno::Reference<uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdgGenerator>(rxContext) + { + } // XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString &ServiceName) override; - virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() override; + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) override; + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() override; private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, rtl::OUString &rTypeName) override; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, + rtl::OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; - static void generate(librevenge::RVNGDrawingInterface &rDocument); + static void generate(librevenge::RVNGDrawingInterface& rDocument); }; -bool DrawingImportFilter::doImportDocument(librevenge::RVNGInputStream &, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool DrawingImportFilter::doImportDocument(librevenge::RVNGInputStream&, OdgGenerator& rGenerator, + utl::MediaDescriptor&) { DrawingImportFilter::generate(rGenerator); return true; } -bool DrawingImportFilter::doDetectFormat(librevenge::RVNGInputStream &, rtl::OUString &rTypeName) +bool DrawingImportFilter::doDetectFormat(librevenge::RVNGInputStream&, rtl::OUString& rTypeName) { rTypeName = "WpftDummyDrawing"; return true; @@ -66,17 +70,17 @@ rtl::OUString SAL_CALL DrawingImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Wpft.QA.DrawingImportFilter"); } -sal_Bool SAL_CALL DrawingImportFilter::supportsService(const rtl::OUString &rServiceName) +sal_Bool SAL_CALL DrawingImportFilter::supportsService(const rtl::OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -uno::Sequence< rtl::OUString > SAL_CALL DrawingImportFilter::getSupportedServiceNames() +uno::Sequence<rtl::OUString> SAL_CALL DrawingImportFilter::getSupportedServiceNames() { - return {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" }; } -void DrawingImportFilter::generate(librevenge::RVNGDrawingInterface &rDocument) +void DrawingImportFilter::generate(librevenge::RVNGDrawingInterface& rDocument) { using namespace librevenge; @@ -100,12 +104,10 @@ void DrawingImportFilter::generate(librevenge::RVNGDrawingInterface &rDocument) rDocument.endPage(); rDocument.endDocument(); } - } namespace { - class DrawingImportTest : public writerperfect::test::WpftFilterFixture { public: @@ -120,8 +122,9 @@ void DrawingImportTest::test() { using namespace css; - rtl::Reference<DrawingImportFilter> xFilter {new DrawingImportFilter(m_xContext)}; - writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/sdraw", m_xDesktop, 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); CPPUNIT_ASSERT(xDoc.is()); @@ -142,13 +145,13 @@ void DrawingImportTest::test() uno::Reference<drawing::XShapeDescriptor> xShapeDesc; CPPUNIT_ASSERT(aShape >>= xShapeDesc); CPPUNIT_ASSERT(xShapeDesc.is()); - CPPUNIT_ASSERT_EQUAL(rtl::OUString("com.sun.star.drawing.TextShape"), xShapeDesc->getShapeType()); + CPPUNIT_ASSERT_EQUAL(rtl::OUString("com.sun.star.drawing.TextShape"), + xShapeDesc->getShapeType()); uno::Reference<text::XText> xText(xShapeDesc, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(rtl::OUString("My hovercraft is full of eels."), xText->getString()); } CPPUNIT_TEST_SUITE_REGISTRATION(DrawingImportTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 231c63252efd..ce8f2964b0b7 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -30,11 +30,12 @@ using namespace ::com::sun::star; namespace { - char const DATA_DIRECTORY[] = "/writerperfect/qa/unit/data/writer/epubexport/"; /// Tests the EPUB export filter. -class EPUBExportTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class EPUBExportTest : public test::BootstrapFixture, + public unotest::MacrosTest, + public XmlTestTools { uno::Reference<uno::XComponentContext> mxComponentContext; uno::Reference<lang::XComponent> mxComponent; @@ -46,14 +47,15 @@ class EPUBExportTest : public test::BootstrapFixture, public unotest::MacrosTest public: void setUp() override; void tearDown() override; - void registerNamespaces(xmlXPathContextPtr &pXmlXpathCtx) override; - void createDoc(const OUString &rFile, const uno::Sequence<beans::PropertyValue> &rFilterData); + void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; + void createDoc(const OUString& rFile, const uno::Sequence<beans::PropertyValue>& rFilterData); /// Returns an XML representation of the stream named rName in the exported package. - xmlDocPtr parseExport(const OUString &rName); + xmlDocPtr parseExport(const OUString& rName); /// Parses a CSS representation of the stream named rName and returns it. - std::map< OUString, std::vector<OUString> > parseCss(const OUString &rName); + std::map<OUString, std::vector<OUString>> parseCss(const OUString& rName); /// Looks up a key of a class in rCss. - static OUString getCss(std::map< OUString, std::vector<OUString> > &rCss, const OUString &rClass, const OUString &rKey); + static OUString getCss(std::map<OUString, std::vector<OUString>>& rCss, const OUString& rClass, + const OUString& rKey); void testOutlineLevel(); void testMimetype(); void testEPUB2(); @@ -175,7 +177,7 @@ void EPUBExportTest::tearDown() test::BootstrapFixture::tearDown(); } -void EPUBExportTest::registerNamespaces(xmlXPathContextPtr &pXmlXpathCtx) +void EPUBExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) { xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dc"), BAD_CAST("http://purl.org/dc/elements/1.1/")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("opf"), BAD_CAST("http://www.idpf.org/2007/opf")); @@ -183,7 +185,8 @@ void EPUBExportTest::registerNamespaces(xmlXPathContextPtr &pXmlXpathCtx) xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("http://www.w3.org/2000/svg")); } -void EPUBExportTest::createDoc(const OUString &rFile, const uno::Sequence<beans::PropertyValue> &rFilterData) +void EPUBExportTest::createDoc(const OUString& rFile, + const uno::Sequence<beans::PropertyValue>& rFilterData) { // Import the bugdoc and export as EPUB. OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + rFile; @@ -199,19 +202,20 @@ void EPUBExportTest::createDoc(const OUString &rFile, const uno::Sequence<beans: else aMediaDescriptor["FilterOptions"] <<= maFilterOptions; xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - mxZipFile = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL()); + mxZipFile + = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL()); } -xmlDocPtr EPUBExportTest::parseExport(const OUString &rName) +xmlDocPtr EPUBExportTest::parseExport(const OUString& rName) { uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName(rName), uno::UNO_QUERY); std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); return parseXmlStream(pStream.get()); } -std::map< OUString, std::vector<OUString> > EPUBExportTest::parseCss(const OUString &rName) +std::map<OUString, std::vector<OUString>> EPUBExportTest::parseCss(const OUString& rName) { - std::map< OUString, std::vector<OUString> > aRet; + std::map<OUString, std::vector<OUString>> aRet; uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName(rName), uno::UNO_QUERY); std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); @@ -232,14 +236,15 @@ std::map< OUString, std::vector<OUString> > EPUBExportTest::parseCss(const OUStr return aRet; } -OUString EPUBExportTest::getCss(std::map< OUString, std::vector<OUString> > &rCss, const OUString &rClass, const OUString &rKey) +OUString EPUBExportTest::getCss(std::map<OUString, std::vector<OUString>>& rCss, + const OUString& rClass, const OUString& rKey) { OUString aRet; auto it = rCss.find(rClass); CPPUNIT_ASSERT(it != rCss.end()); - for (const auto &rKeyValue : it->second) + for (const auto& rKeyValue : it->second) { OUString aKeyValue = rKeyValue.trim(); std::vector<OUString> aTokens = comphelper::string::split(aKeyValue, ':'); @@ -279,7 +284,8 @@ void EPUBExportTest::testMimetype() OString aExpected("application/epub+zip"); CPPUNIT_ASSERT(aMemoryStream.GetSize() > static_cast<sal_uInt64>(38 + aExpected.getLength())); - OString aActual(static_cast<const char *>(aMemoryStream.GetBuffer()) + 38, aExpected.getLength()); + OString aActual(static_cast<const char*>(aMemoryStream.GetBuffer()) + 38, + aExpected.getLength()); // This failed: actual data was some garbage, not the uncompressed mime type. CPPUNIT_ASSERT_EQUAL(aExpected, aActual); @@ -288,10 +294,12 @@ void EPUBExportTest::testMimetype() assertXPath(mpXmlDoc, "/opf:package", "version", "3.0"); // This was just "libepubgen/x.y.z", i.e. the LO version was missing. - OUString aGenerator = getXPath(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@name='generator']", "content"); + OUString aGenerator + = getXPath(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@name='generator']", "content"); CPPUNIT_ASSERT(aGenerator.startsWith(utl::DocInfoHelper::GetGeneratorString())); - uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponentContext->getServiceManager(), uno::UNO_QUERY); + uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponentContext->getServiceManager(), + uno::UNO_QUERY); const OUString aServiceName("com.sun.star.comp.Writer.EPUBExportFilter"); uno::Reference<document::XFilter> xFilter(xMSF->createInstance(aServiceName), uno::UNO_QUERY); // Should result in no errors. @@ -305,10 +313,8 @@ void EPUBExportTest::testMimetype() void EPUBExportTest::testEPUB2() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - // Explicitly request EPUB2. - {"EPUBVersion", uno::makeAny(static_cast<sal_Int32>(20))} - })); + { // Explicitly request EPUB2. + { "EPUBVersion", uno::makeAny(static_cast<sal_Int32>(20)) } })); createDoc("hello.fodt", aFilterData); mpXmlDoc = parseExport("OEBPS/content.opf"); @@ -319,15 +325,15 @@ void EPUBExportTest::testEPUB2() void EPUBExportTest::testEPUBFixedLayout() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - // Explicitly request fixed layout. - {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} - })); + { // Explicitly request fixed layout. + { "EPUBLayoutMethod", + uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED)) } })); createDoc("hello.fodt", aFilterData); mpXmlDoc = parseExport("OEBPS/content.opf"); // This was missing, EPUBLayoutMethod filter option was ignored and we always emitted reflowable layout. - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", "pre-paginated"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", + "pre-paginated"); } void EPUBExportTest::testEPUBFixedLayoutOption() @@ -338,16 +344,16 @@ void EPUBExportTest::testEPUBFixedLayoutOption() // This failed, fixed layout was only working via the FilterData map. mpXmlDoc = parseExport("OEBPS/content.opf"); - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", "pre-paginated"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", + "pre-paginated"); } void EPUBExportTest::testEPUBFixedLayoutImplicitBreak() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - // Explicitly request fixed layout. - {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} - })); + { // Explicitly request fixed layout. + { "EPUBLayoutMethod", + uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED)) } })); createDoc("fxl-2page.fodt", aFilterData); CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/sections/section0001.xhtml")); @@ -366,10 +372,9 @@ void EPUBExportTest::testEPUBFixedLayoutImplicitBreak() void EPUBExportTest::testPageBreakSplit() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - // Explicitly request split on page break (instead of on heading). - {"EPUBSplitMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_SPLIT_METHOD_PAGE_BREAK))} - })); + { // Explicitly request split on page break (instead of on heading). + { "EPUBSplitMethod", + uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_SPLIT_METHOD_PAGE_BREAK)) } })); createDoc("2pages.fodt", aFilterData); // Make sure that the output is split into two. @@ -410,11 +415,14 @@ void EPUBExportTest::testMeta() assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "A U Thor"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "Title"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "hu"); - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", "2017-09-27T09:51:19Z"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", + "2017-09-27T09:51:19Z"); // Make sure that cover image next to the source document is picked up. - assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", "properties", "cover-image"); - assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", "media-type", "image/png"); + assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", + "properties", "cover-image"); + assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", + "media-type", "image/png"); CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.png")); } @@ -424,48 +432,50 @@ void EPUBExportTest::testMetaXMP() mpXmlDoc = parseExport("OEBPS/content.opf"); // These were the libepubgen default values, metadata from a matching .xmp file was not picked up. - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier", "deadbeef-e394-4cd6-9b83-7172794612e5"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier", + "deadbeef-e394-4cd6-9b83-7172794612e5"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "unknown title from xmp"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "unknown author from xmp"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "nl"); - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", "2016-11-20T17:16:07Z"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", + "2016-11-20T17:16:07Z"); } void EPUBExportTest::testMetaAPI() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - {"RVNGIdentifier", uno::makeAny(OUString("deadc0de-e394-4cd6-9b83-7172794612e5"))}, - {"RVNGTitle", uno::makeAny(OUString("unknown title from api"))}, - {"RVNGInitialCreator", uno::makeAny(OUString("unknown author from api"))}, - {"RVNGLanguage", uno::makeAny(OUString("hu"))}, - {"RVNGDate", uno::makeAny(OUString("2015-11-20T17:16:07Z"))} - })); + { { "RVNGIdentifier", uno::makeAny(OUString("deadc0de-e394-4cd6-9b83-7172794612e5")) }, + { "RVNGTitle", uno::makeAny(OUString("unknown title from api")) }, + { "RVNGInitialCreator", uno::makeAny(OUString("unknown author from api")) }, + { "RVNGLanguage", uno::makeAny(OUString("hu")) }, + { "RVNGDate", uno::makeAny(OUString("2015-11-20T17:16:07Z")) } })); createDoc("meta-xmp.fodt", aFilterData); mpXmlDoc = parseExport("OEBPS/content.opf"); // These were values from XMP (deadbeef, etc.), not from API. - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier", "deadc0de-e394-4cd6-9b83-7172794612e5"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier", + "deadc0de-e394-4cd6-9b83-7172794612e5"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", "unknown title from api"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "unknown author from api"); assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", "hu"); - assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", "2015-11-20T17:16:07Z"); + assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", + "2015-11-20T17:16:07Z"); } void EPUBExportTest::testCoverImage() { OUString aCoverURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "meta.cover-image.png"; - uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - {"RVNGCoverImage", uno::makeAny(aCoverURL)} - })); + uno::Sequence<beans::PropertyValue> aFilterData( + comphelper::InitPropertySequence({ { "RVNGCoverImage", uno::makeAny(aCoverURL) } })); createDoc("hello.fodt", aFilterData); mpXmlDoc = parseExport("OEBPS/content.opf"); // Make sure that the explicitly set cover image is used. // This failed, as the image was not part of the package. - assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", "properties", "cover-image"); - assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", "media-type", "image/png"); + assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", + "properties", "cover-image"); + assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='images/image0001.png']", + "media-type", "image/png"); CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.png")); } @@ -502,13 +512,14 @@ void EPUBExportTest::testNamedStyleInheritance() // Find the CSS rule for the blue text. mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); OUString aBlue = getXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span[2]", "class"); CPPUNIT_ASSERT_EQUAL(OUString("#0000ff"), EPUBExportTest::getCss(aCssDoc, aBlue, "color")); // This failed, the span only had the properties from its style, but not // from the style's parent(s). - CPPUNIT_ASSERT_EQUAL(OUString("'Liberation Mono'"), EPUBExportTest::getCss(aCssDoc, aBlue, "font-family")); + CPPUNIT_ASSERT_EQUAL(OUString("'Liberation Mono'"), + EPUBExportTest::getCss(aCssDoc, aBlue, "font-family")); } void EPUBExportTest::testNestedSpan() @@ -517,7 +528,7 @@ void EPUBExportTest::testNestedSpan() // Check textural content of nested span. mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // This crashed, span had no content. assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "red"); @@ -525,7 +536,8 @@ void EPUBExportTest::testNestedSpan() OUString aRed = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class"); // This failed, direct formatting on top of named style was lost. CPPUNIT_ASSERT_EQUAL(OUString("#ff0000"), EPUBExportTest::getCss(aCssDoc, aRed, "color")); - CPPUNIT_ASSERT_EQUAL(OUString("'Liberation Mono'"), EPUBExportTest::getCss(aCssDoc, aRed, "font-family")); + CPPUNIT_ASSERT_EQUAL(OUString("'Liberation Mono'"), + EPUBExportTest::getCss(aCssDoc, aRed, "font-family")); } void EPUBExportTest::testLineBreak() @@ -549,7 +561,10 @@ void EPUBExportTest::testEscape() // Make sure escaping happens only once. assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a&b"); // This was also lost. - assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", OUString::fromUtf8("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0 ")); + assertXPathContent( + mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", + OUString::fromUtf8("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2" + "\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0 ")); } void EPUBExportTest::testParaCharProps() @@ -557,10 +572,11 @@ void EPUBExportTest::testParaCharProps() createDoc("para-char-props.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // Check formatting of the middle span. OUString aMiddle = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("italic"), EPUBExportTest::getCss(aCssDoc, aMiddle, "font-style")); + CPPUNIT_ASSERT_EQUAL(OUString("italic"), + EPUBExportTest::getCss(aCssDoc, aMiddle, "font-style")); // Direct para formatting was lost, only direct char formatting was // written, so this failed. CPPUNIT_ASSERT_EQUAL(OUString("bold"), EPUBExportTest::getCss(aCssDoc, aMiddle, "font-weight")); @@ -599,11 +615,12 @@ void EPUBExportTest::testImageBorder() createDoc("image-border.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:img", "class"); // This failed, image had no border. - CPPUNIT_ASSERT_EQUAL(OUString("0.99pt dashed #ed1c24"), EPUBExportTest::getCss(aCssDoc, aClass, "border")); + CPPUNIT_ASSERT_EQUAL(OUString("0.99pt dashed #ed1c24"), + EPUBExportTest::getCss(aCssDoc, aClass, "border")); } void EPUBExportTest::testImageNospan() @@ -637,11 +654,13 @@ void EPUBExportTest::testTableCellBorder() createDoc("table-cell-border.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); - OUString aClass = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class"); + OUString aClass + = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class"); // This failed, cell border wasn't exported. - CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"), EPUBExportTest::getCss(aCssDoc, aClass, "border-left")); + CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"), + EPUBExportTest::getCss(aCssDoc, aClass, "border-left")); } void EPUBExportTest::testTableCellWidth() @@ -649,13 +668,18 @@ void EPUBExportTest::testTableCellWidth() createDoc("table-cell-width.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); - OUString aClass1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class"); - OUString aClass2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[2]", "class"); - OUString aClass3 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[3]", "class"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + OUString aClass1 + = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "class"); + OUString aClass2 + = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[2]", "class"); + OUString aClass3 + = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[3]", "class"); // These failed, all widths were 0. - CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, "width").toDouble(), EPUBExportTest::getCss(aCssDoc, aClass1, "width").toDouble()); - CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass3, "width").toDouble(), EPUBExportTest::getCss(aCssDoc, aClass1, "width").toDouble()); + CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, "width").toDouble(), + EPUBExportTest::getCss(aCssDoc, aClass1, "width").toDouble()); + CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass3, "width").toDouble(), + EPUBExportTest::getCss(aCssDoc, aClass1, "width").toDouble()); } void EPUBExportTest::testTableRowHeight() @@ -663,11 +687,12 @@ void EPUBExportTest::testTableRowHeight() createDoc("table-row-height.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); OUString aClass1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]", "class"); OUString aClass2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[2]", "class"); // These failed, both heights were 0. - CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, "height").toDouble(), EPUBExportTest::getCss(aCssDoc, aClass1, "height").toDouble()); + CPPUNIT_ASSERT_GREATER(EPUBExportTest::getCss(aCssDoc, aClass2, "height").toDouble(), + EPUBExportTest::getCss(aCssDoc, aClass1, "height").toDouble()); } void EPUBExportTest::testLink() @@ -704,7 +729,7 @@ void EPUBExportTest::testLinkNamedCharFormat() createDoc("link-namedcharformat.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // This failed, there was no span inside the hyperlink. assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "http://libreoffice.org"); assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "http://libreoffice.org/"); @@ -718,7 +743,7 @@ void EPUBExportTest::testTableWidth() createDoc("table-width.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:table", "class"); // This failed, relative total width of table was lost. @@ -730,7 +755,7 @@ void EPUBExportTest::testTextBox() createDoc("text-box.fodt", {}); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // This failed, image with caption was lost. assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1"); @@ -752,18 +777,22 @@ void EPUBExportTest::testFontEmbedding() // Make sure that the params of defineEmbeddedFont() are all handled. // librevenge:name - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // 'SketchFlow Print' or ''SketchFlow Print1' - CPPUNIT_ASSERT(EPUBExportTest::getCss(aCssDoc, "font-face", "font-family").startsWith("'SketchFlow Print")); + CPPUNIT_ASSERT(EPUBExportTest::getCss(aCssDoc, "font-face", "font-family") + .startsWith("'SketchFlow Print")); // librevenge:mime-type mpXmlDoc = parseExport("OEBPS/content.opf"); - assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='fonts/font0001.otf']", "media-type", "application/vnd.ms-opentype"); + assertXPath(mpXmlDoc, "/opf:package/opf:manifest/opf:item[@href='fonts/font0001.otf']", + "media-type", "application/vnd.ms-opentype"); // office:binary-data CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/fonts/font0001.otf")); // librevenge:font-style - CPPUNIT_ASSERT_EQUAL(OUString("normal"), EPUBExportTest::getCss(aCssDoc, "font-face", "font-style")); + CPPUNIT_ASSERT_EQUAL(OUString("normal"), + EPUBExportTest::getCss(aCssDoc, "font-face", "font-style")); // librevenge:font-weight - CPPUNIT_ASSERT_EQUAL(OUString("normal"), EPUBExportTest::getCss(aCssDoc, "font-face", "font-weight")); + CPPUNIT_ASSERT_EQUAL(OUString("normal"), + EPUBExportTest::getCss(aCssDoc, "font-face", "font-weight")); #endif } @@ -822,10 +851,8 @@ void EPUBExportTest::testPopupAPI() { // Make sure that the popup works with data from a media directory. OUString aMediaDir = m_directories.getURLFromSrc(DATA_DIRECTORY) + "popup"; - uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - {"RVNGMediaDir", uno::makeAny(aMediaDir)} - })); + uno::Sequence<beans::PropertyValue> aFilterData( + comphelper::InitPropertySequence({ { "RVNGMediaDir", uno::makeAny(aMediaDir) } })); createDoc("popup-api.odt", aFilterData); // We have a non-empty anchor image. @@ -842,15 +869,15 @@ void EPUBExportTest::testPopupAPI() void EPUBExportTest::testPageSize() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} - })); + { { "EPUBLayoutMethod", + uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED)) } })); createDoc("hello.fodt", aFilterData); // This failed, viewport was empty, so page size was lost. mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); // 21,59cm x 27.94cm (letter). - assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content", "width=816, height=1056"); + assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content", + "width=816, height=1056"); xmlFreeDoc(mpXmlDoc); mpXmlDoc = parseExport("OEBPS/images/image0001.svg"); @@ -862,13 +889,13 @@ void EPUBExportTest::testPageSize() void EPUBExportTest::testSVG() { uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( - { - {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} - })); + { { "EPUBLayoutMethod", + uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED)) } })); createDoc("hello.fodt", aFilterData); CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.svg")); - uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName("OEBPS/images/image0001.svg"), uno::UNO_QUERY); + uno::Reference<io::XInputStream> xInputStream( + mxZipFile->getByName("OEBPS/images/image0001.svg"), uno::UNO_QUERY); std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); SvMemoryStream aMemoryStream; @@ -878,7 +905,7 @@ void EPUBExportTest::testSVG() // This failed, there was a '<!DOCTYPE' line between the xml and the svg // one, causing a validation error. - OString aActual(static_cast<const char *>(aMemoryStream.GetBuffer()), aExpected.getLength()); + OString aActual(static_cast<const char*>(aMemoryStream.GetBuffer()), aExpected.getLength()); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); // This failed, we used the xlink attribute namespace, but we did not @@ -887,25 +914,26 @@ void EPUBExportTest::testSVG() assertXPathNSDef(mpXmlDoc, "/svg:svg", "xlink", "http://www.w3.org/1999/xlink"); } - void EPUBExportTest::testTdf115623SingleWritingMode() { // Simple page that has single writing mode should work. createDoc("tdf115623-single-writing-mode.odt", {}); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); + CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), + EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); } void EPUBExportTest::testTdf115623SplitByChapter() { createDoc("tdf115623-split-by-chapter.odt", {}); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); { mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); + CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), + EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); xmlFreeDoc(mpXmlDoc); mpXmlDoc = nullptr; } @@ -913,31 +941,33 @@ void EPUBExportTest::testTdf115623SplitByChapter() { mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); + CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), + EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); } } void EPUBExportTest::testTdf115623ManyPageSpans() { createDoc("tdf115623-many-pagespans.odt", {}); - std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); + std::map<OUString, std::vector<OUString>> aCssDoc = parseCss("OEBPS/styles/stylesheet.css"); // Two pages should have different writing modes. { mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); + CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), + EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); xmlFreeDoc(mpXmlDoc); mpXmlDoc = nullptr; } { mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml"); OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); - CPPUNIT_ASSERT_EQUAL(OUString("horizontal-tb"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); + CPPUNIT_ASSERT_EQUAL(OUString("horizontal-tb"), + EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); } } CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/ImportTest.cxx b/writerperfect/qa/unit/ImportTest.cxx index 9275c6c11b7f..dca0808bd432 100644 --- a/writerperfect/qa/unit/ImportTest.cxx +++ b/writerperfect/qa/unit/ImportTest.cxx @@ -23,7 +23,6 @@ namespace { - namespace beans = css::beans; namespace container = css::container; namespace document = css::document; @@ -48,11 +47,11 @@ public: CPPUNIT_TEST_SUITE_END(); private: - WpftLoader createCalcLoader(const rtl::OUString &rFile) const; + WpftLoader createCalcLoader(const rtl::OUString& rFile) const; - WpftLoader createLoader(const rtl::OUString &rUrl, const rtl::OUString &rFactoryUrl) const; + WpftLoader createLoader(const rtl::OUString& rUrl, const rtl::OUString& rFactoryUrl) const; - rtl::OUString makeUrl(const rtl::OUString &rFile) const; + rtl::OUString makeUrl(const rtl::OUString& rFile) const; private: uno::Reference<lang::XMultiServiceFactory> m_xFilterFactory; @@ -86,12 +85,13 @@ void ImportTest::testWK3WithFM3() #endif } -WpftLoader ImportTest::createCalcLoader(const rtl::OUString &rFile) const +WpftLoader ImportTest::createCalcLoader(const rtl::OUString& rFile) const { return createLoader(makeUrl(rFile), "private:factory/scalc"); } -WpftLoader ImportTest::createLoader(const rtl::OUString &rUrl, const rtl::OUString &rFactoryUrl) const +WpftLoader ImportTest::createLoader(const rtl::OUString& rUrl, + const rtl::OUString& rFactoryUrl) const { utl::MediaDescriptor aDesc; aDesc[utl::MediaDescriptor::PROP_URL()] <<= rUrl; @@ -99,18 +99,18 @@ WpftLoader ImportTest::createLoader(const rtl::OUString &rUrl, const rtl::OUStri uno::Sequence<beans::PropertyValue> lDesc(aDesc.getAsConstPropertyValueList()); const rtl::OUString sType = m_xTypeDetection->queryTypeByDescriptor(lDesc, true); CPPUNIT_ASSERT(!sType.isEmpty()); - const uno::Reference<document::XFilter> xFilter(m_xFilterFactory->createInstance(sType), UNO_QUERY); + const uno::Reference<document::XFilter> xFilter(m_xFilterFactory->createInstance(sType), + UNO_QUERY); CPPUNIT_ASSERT(xFilter.is()); return WpftLoader(rUrl, xFilter, rFactoryUrl, m_xDesktop, m_xTypeMap, m_xContext); } -rtl::OUString ImportTest::makeUrl(const rtl::OUString &rFile) const +rtl::OUString ImportTest::makeUrl(const rtl::OUString& rFile) const { - return const_cast<ImportTest *>(this)->m_directories.getURLFromSrc("/" TEST_DIR "/" + rFile); + return const_cast<ImportTest*>(this)->m_directories.getURLFromSrc("/" TEST_DIR "/" + rFile); } CPPUNIT_TEST_SUITE_REGISTRATION(ImportTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/PresentationImportTest.cxx b/writerperfect/qa/unit/PresentationImportTest.cxx index 9ad9fed92ac6..de0b951f1c03 100644 --- a/writerperfect/qa/unit/PresentationImportTest.cxx +++ b/writerperfect/qa/unit/PresentationImportTest.cxx @@ -27,34 +27,39 @@ namespace { - namespace uno = css::uno; class PresentationImportFilter : public writerperfect::ImportFilter<OdpGenerator> { public: - explicit PresentationImportFilter(const uno::Reference< uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdpGenerator>(rxContext) {} + explicit PresentationImportFilter(const uno::Reference<uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdpGenerator>(rxContext) + { + } // XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString &ServiceName) override; - virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() override; + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) override; + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() override; private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, rtl::OUString &rTypeName) override; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, + rtl::OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdpGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; - static void generate(librevenge::RVNGPresentationInterface &rDocument); + static void generate(librevenge::RVNGPresentationInterface& rDocument); }; -bool PresentationImportFilter::doImportDocument(librevenge::RVNGInputStream &, OdpGenerator &rGenerator, utl::MediaDescriptor &) +bool PresentationImportFilter::doImportDocument(librevenge::RVNGInputStream&, + OdpGenerator& rGenerator, utl::MediaDescriptor&) { PresentationImportFilter::generate(rGenerator); return true; } -bool PresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream &, rtl::OUString &rTypeName) +bool PresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream&, + rtl::OUString& rTypeName) { rTypeName = "WpftDummyPresentation"; return true; @@ -66,17 +71,17 @@ rtl::OUString SAL_CALL PresentationImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Wpft.QA.PresentationImportFilter"); } -sal_Bool SAL_CALL PresentationImportFilter::supportsService(const rtl::OUString &rServiceName) +sal_Bool SAL_CALL PresentationImportFilter::supportsService(const rtl::OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -uno::Sequence< rtl::OUString > SAL_CALL PresentationImportFilter::getSupportedServiceNames() +uno::Sequence<rtl::OUString> SAL_CALL PresentationImportFilter::getSupportedServiceNames() { - return {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" }; } -void PresentationImportFilter::generate(librevenge::RVNGPresentationInterface &rDocument) +void PresentationImportFilter::generate(librevenge::RVNGPresentationInterface& rDocument) { using namespace librevenge; @@ -100,12 +105,10 @@ void PresentationImportFilter::generate(librevenge::RVNGPresentationInterface &r rDocument.endSlide(); rDocument.endDocument(); } - } namespace { - class PresentationImportTest : public writerperfect::test::WpftFilterFixture { public: @@ -120,8 +123,9 @@ void PresentationImportTest::test() { using namespace css; - rtl::Reference<PresentationImportFilter> xFilter {new PresentationImportFilter(m_xContext)}; - writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/simpress", m_xDesktop, 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); CPPUNIT_ASSERT(xDoc.is()); @@ -142,13 +146,13 @@ void PresentationImportTest::test() uno::Reference<drawing::XShapeDescriptor> xShapeDesc; CPPUNIT_ASSERT(aShape >>= xShapeDesc); CPPUNIT_ASSERT(xShapeDesc.is()); - CPPUNIT_ASSERT_EQUAL(rtl::OUString("com.sun.star.drawing.TextShape"), xShapeDesc->getShapeType()); + CPPUNIT_ASSERT_EQUAL(rtl::OUString("com.sun.star.drawing.TextShape"), + xShapeDesc->getShapeType()); uno::Reference<text::XText> xText(xShapeDesc, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(rtl::OUString("My hovercraft is full of eels."), xText->getString()); } CPPUNIT_TEST_SUITE_REGISTRATION(PresentationImportTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/SpreadsheetImportTest.cxx b/writerperfect/qa/unit/SpreadsheetImportTest.cxx index a3aa1a968bc3..ef4e18c16ff0 100644 --- a/writerperfect/qa/unit/SpreadsheetImportTest.cxx +++ b/writerperfect/qa/unit/SpreadsheetImportTest.cxx @@ -26,34 +26,38 @@ namespace { - namespace uno = css::uno; class SpreadsheetImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: - explicit SpreadsheetImportFilter(const uno::Reference< uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} + explicit SpreadsheetImportFilter(const uno::Reference<uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdsGenerator>(rxContext) + { + } // XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString &ServiceName) override; - virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() override; + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) override; + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() override; private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, rtl::OUString &rTypeName) override; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, + rtl::OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdsGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; - static void generate(librevenge::RVNGSpreadsheetInterface &rDocument); + static void generate(librevenge::RVNGSpreadsheetInterface& rDocument); }; -bool SpreadsheetImportFilter::doImportDocument(librevenge::RVNGInputStream &, OdsGenerator &rGenerator, utl::MediaDescriptor &) +bool SpreadsheetImportFilter::doImportDocument(librevenge::RVNGInputStream&, + OdsGenerator& rGenerator, utl::MediaDescriptor&) { SpreadsheetImportFilter::generate(rGenerator); return true; } -bool SpreadsheetImportFilter::doDetectFormat(librevenge::RVNGInputStream &, rtl::OUString &rTypeName) +bool SpreadsheetImportFilter::doDetectFormat(librevenge::RVNGInputStream&, rtl::OUString& rTypeName) { rTypeName = "WpftDummySpreadsheet"; return true; @@ -65,17 +69,17 @@ rtl::OUString SAL_CALL SpreadsheetImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Wpft.QA.SpreadsheetImportFilter"); } -sal_Bool SAL_CALL SpreadsheetImportFilter::supportsService(const rtl::OUString &rServiceName) +sal_Bool SAL_CALL SpreadsheetImportFilter::supportsService(const rtl::OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -uno::Sequence< rtl::OUString > SAL_CALL SpreadsheetImportFilter::getSupportedServiceNames() +uno::Sequence<rtl::OUString> SAL_CALL SpreadsheetImportFilter::getSupportedServiceNames() { - return {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" }; } -void SpreadsheetImportFilter::generate(librevenge::RVNGSpreadsheetInterface &rDocument) +void SpreadsheetImportFilter::generate(librevenge::RVNGSpreadsheetInterface& rDocument) { using namespace librevenge; @@ -95,12 +99,10 @@ void SpreadsheetImportFilter::generate(librevenge::RVNGSpreadsheetInterface &rDo rDocument.closePageSpan(); rDocument.endDocument(); } - } namespace { - class SpreadsheetImportTest : public writerperfect::test::WpftFilterFixture { public: @@ -115,8 +117,9 @@ void SpreadsheetImportTest::test() { using namespace css; - rtl::Reference<SpreadsheetImportFilter> xFilter {new SpreadsheetImportFilter(m_xContext)}; - writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/scalc", m_xDesktop, 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); CPPUNIT_ASSERT(xDoc.is()); @@ -131,7 +134,6 @@ void SpreadsheetImportTest::test() } CPPUNIT_TEST_SUITE_REGISTRATION(SpreadsheetImportTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/TextImportTest.cxx b/writerperfect/qa/unit/TextImportTest.cxx index dcf599577ee6..cbad0f154c27 100644 --- a/writerperfect/qa/unit/TextImportTest.cxx +++ b/writerperfect/qa/unit/TextImportTest.cxx @@ -25,34 +25,38 @@ namespace { - namespace uno = css::uno; class TextImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit TextImportFilter(const uno::Reference< uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit TextImportFilter(const uno::Reference<uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(rxContext) + { + } // XServiceInfo virtual rtl::OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService(const rtl::OUString &ServiceName) override; - virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() override; + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) override; + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() override; private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, rtl::OUString &rTypeName) override; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, + rtl::OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdtGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; - static void generate(librevenge::RVNGTextInterface &rDocument); + static void generate(librevenge::RVNGTextInterface& rDocument); }; -bool TextImportFilter::doImportDocument(librevenge::RVNGInputStream &, OdtGenerator &rGenerator, utl::MediaDescriptor &) +bool TextImportFilter::doImportDocument(librevenge::RVNGInputStream&, OdtGenerator& rGenerator, + utl::MediaDescriptor&) { TextImportFilter::generate(rGenerator); return true; } -bool TextImportFilter::doDetectFormat(librevenge::RVNGInputStream &, rtl::OUString &rTypeName) +bool TextImportFilter::doDetectFormat(librevenge::RVNGInputStream&, rtl::OUString& rTypeName) { rTypeName = "WpftDummyText"; return true; @@ -64,17 +68,17 @@ rtl::OUString SAL_CALL TextImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Wpft.QA.TextImportFilter"); } -sal_Bool SAL_CALL TextImportFilter::supportsService(const rtl::OUString &rServiceName) +sal_Bool SAL_CALL TextImportFilter::supportsService(const rtl::OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -uno::Sequence< rtl::OUString > SAL_CALL TextImportFilter::getSupportedServiceNames() +uno::Sequence<rtl::OUString> SAL_CALL TextImportFilter::getSupportedServiceNames() { - return {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" }; } -void TextImportFilter::generate(librevenge::RVNGTextInterface &rDocument) +void TextImportFilter::generate(librevenge::RVNGTextInterface& rDocument) { using namespace librevenge; @@ -88,12 +92,10 @@ void TextImportFilter::generate(librevenge::RVNGTextInterface &rDocument) rDocument.closePageSpan(); rDocument.endDocument(); } - } namespace { - class TextImportTest : public writerperfect::test::WpftFilterFixture { public: @@ -108,8 +110,9 @@ void TextImportTest::test() { using namespace css; - rtl::Reference<TextImportFilter> xFilter {new TextImportFilter(m_xContext)}; - writerperfect::test::WpftLoader aLoader(createDummyInput(), xFilter.get(), "private:factory/swriter", m_xDesktop, 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); CPPUNIT_ASSERT(xDoc.is()); @@ -118,7 +121,8 @@ void TextImportTest::test() uno::Reference<container::XEnumeration> xParas = xParaAccess->createEnumeration(); CPPUNIT_ASSERT(xParas.is()); CPPUNIT_ASSERT(xParas->hasMoreElements()); - uno::Reference<container::XEnumerationAccess> xPortionsAccess(xParas->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xPortionsAccess(xParas->nextElement(), + uno::UNO_QUERY); CPPUNIT_ASSERT(xPortionsAccess.is()); uno::Reference<container::XEnumeration> xPortions = xPortionsAccess->createEnumeration(); CPPUNIT_ASSERT(xPortions.is()); @@ -136,7 +140,6 @@ void TextImportTest::test() } CPPUNIT_TEST_SUITE_REGISTRATION(TextImportTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/WPXSvStreamTest.cxx b/writerperfect/qa/unit/WPXSvStreamTest.cxx index 456af32f01a0..0899b4a64ad1 100644 --- a/writerperfect/qa/unit/WPXSvStreamTest.cxx +++ b/writerperfect/qa/unit/WPXSvStreamTest.cxx @@ -45,7 +45,6 @@ using writerperfect::WPXSvInputStream; namespace { - class WPXSvStreamTest : public test::BootstrapFixture { public: @@ -73,7 +72,8 @@ shared_ptr<RVNGInputStream> lcl_createStream() { using comphelper::SequenceInputStream; - const css::uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8 *>(aText), sizeof aText); + const css::uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8*>(aText), + sizeof aText); const uno::Reference<io::XInputStream> xInputStream(new SequenceInputStream(aData)); shared_ptr<RVNGInputStream> pInputStream; @@ -83,22 +83,25 @@ shared_ptr<RVNGInputStream> lcl_createStream() return pInputStream; } -const shared_ptr<RVNGInputStream> lcl_createStreamForURL(const rtl::OUString &rURL) +const shared_ptr<RVNGInputStream> lcl_createStreamForURL(const rtl::OUString& rURL) { using uno::Reference; using uno::UNO_QUERY_THROW; - const Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext(), UNO_QUERY_THROW); + const Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext(), + UNO_QUERY_THROW); const Reference<ucb::XSimpleFileAccess> xFileAccess( - xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", xContext), + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.ucb.SimpleFileAccess", xContext), UNO_QUERY_THROW); - const Reference<io::XInputStream> xInputStream(xFileAccess->openFileRead(rURL), UNO_QUERY_THROW); + const Reference<io::XInputStream> xInputStream(xFileAccess->openFileRead(rURL), + UNO_QUERY_THROW); const shared_ptr<RVNGInputStream> pInput(new WPXSvInputStream(xInputStream)); return pInput; } -void lcl_testSubStreams(const shared_ptr<RVNGInputStream> &pInput) +void lcl_testSubStreams(const shared_ptr<RVNGInputStream>& pInput) { shared_ptr<RVNGInputStream> pSubStream; @@ -122,9 +125,9 @@ void WPXSvStreamTest::testRead() const unsigned long nLen = sizeof aText; unsigned long nReadBytes = 0; - const unsigned char *pData = nullptr; - const unsigned char *const pTextOrig = reinterpret_cast<const unsigned char *>(aText); - const unsigned char *pText = pTextOrig; + const unsigned char* pData = nullptr; + const unsigned char* const pTextOrig = reinterpret_cast<const unsigned char*>(aText); + const unsigned char* pText = pTextOrig; // reading by small pieces pData = pInput->read(1UL, nReadBytes); @@ -174,7 +177,7 @@ void WPXSvStreamTest::testRead() pData = pInput->read(0UL, nReadBytes); CPPUNIT_ASSERT_EQUAL(0UL, nReadBytes); CPPUNIT_ASSERT_EQUAL(0L, pInput->tell()); - CPPUNIT_ASSERT_EQUAL(pData, static_cast<const unsigned char *>(nullptr)); + CPPUNIT_ASSERT_EQUAL(pData, static_cast<const unsigned char*>(nullptr)); CPPUNIT_ASSERT(!pInput->isEnd()); } @@ -293,7 +296,8 @@ void WPXSvStreamTest::testStructured() { // OLE2 { - const shared_ptr<RVNGInputStream> pInput(lcl_createStreamForURL(m_directories.getURLFromSrc(aOLEFile))); + const shared_ptr<RVNGInputStream> pInput( + lcl_createStreamForURL(m_directories.getURLFromSrc(aOLEFile))); assert(bool(pInput)); CPPUNIT_ASSERT(pInput->isStructured()); @@ -314,7 +318,8 @@ void WPXSvStreamTest::testStructured() // Zip { - const shared_ptr<RVNGInputStream> pInput(lcl_createStreamForURL(m_directories.getURLFromSrc(aZipFile))); + const shared_ptr<RVNGInputStream> pInput( + lcl_createStreamForURL(m_directories.getURLFromSrc(aZipFile))); assert(bool(pInput)); CPPUNIT_ASSERT(pInput->isStructured()); @@ -347,7 +352,6 @@ void WPXSvStreamTest::testStructured() } CPPUNIT_TEST_SUITE_REGISTRATION(WPXSvStreamTest); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/qa/unit/WpftCalcFilterTest.cxx b/writerperfect/qa/unit/WpftCalcFilterTest.cxx index 0e5584e1ff85..894c0bcf7f9a 100644 --- a/writerperfect/qa/unit/WpftCalcFilterTest.cxx +++ b/writerperfect/qa/unit/WpftCalcFilterTest.cxx @@ -11,7 +11,6 @@ namespace { - class WpftCalcFilterTest : public writerperfect::test::WpftFilterTestBase { public: @@ -31,25 +30,26 @@ WpftCalcFilterTest::WpftCalcFilterTest() void WpftCalcFilterTest::test() { - const writerperfect::test::WpftOptionalMap_t aEtonyekOptional - { - {"Numbers_2.numbers", REQUIRE_ETONYEK_VERSION(0, 1, 2)}, + const writerperfect::test::WpftOptionalMap_t aEtonyekOptional{ + { "Numbers_2.numbers", REQUIRE_ETONYEK_VERSION(0, 1, 2) }, }; - const writerperfect::test::WpftOptionalMap_t aWpsOptional - { - {"Lotus123_3.123", REQUIRE_WPS_VERSION(0, 4, 5)}, - {"Lotus123_98.123", REQUIRE_WPS_VERSION(0, 4, 6)}, - {"QuattroPro.wb1", REQUIRE_WPS_VERSION(0, 4, 8)}, + const writerperfect::test::WpftOptionalMap_t aWpsOptional{ + { "Lotus123_3.123", REQUIRE_WPS_VERSION(0, 4, 5) }, + { "Lotus123_98.123", REQUIRE_WPS_VERSION(0, 4, 6) }, + { "QuattroPro.wb1", REQUIRE_WPS_VERSION(0, 4, 8) }, }; - doTest("com.sun.star.comp.Calc.MWAWCalcImportFilter", "/writerperfect/qa/unit/data/calc/libmwaw/"); - doTest("com.sun.star.comp.Calc.MSWorksCalcImportFilter", "/writerperfect/qa/unit/data/calc/libwps/", aWpsOptional); - doTest("org.libreoffice.comp.Calc.NumbersImportFilter", "/writerperfect/qa/unit/data/calc/libetonyek/", aEtonyekOptional); - doTest("org.libreoffice.comp.Calc.StarOfficeCalcImportFilter", "/writerperfect/qa/unit/data/calc/libstaroffice/"); + doTest("com.sun.star.comp.Calc.MWAWCalcImportFilter", + "/writerperfect/qa/unit/data/calc/libmwaw/"); + doTest("com.sun.star.comp.Calc.MSWorksCalcImportFilter", + "/writerperfect/qa/unit/data/calc/libwps/", aWpsOptional); + doTest("org.libreoffice.comp.Calc.NumbersImportFilter", + "/writerperfect/qa/unit/data/calc/libetonyek/", aEtonyekOptional); + doTest("org.libreoffice.comp.Calc.StarOfficeCalcImportFilter", + "/writerperfect/qa/unit/data/calc/libstaroffice/"); } CPPUNIT_TEST_SUITE_REGISTRATION(WpftCalcFilterTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/WpftDrawFilterTest.cxx b/writerperfect/qa/unit/WpftDrawFilterTest.cxx index 95a85c4ef52b..bdf2e33fb058 100644 --- a/writerperfect/qa/unit/WpftDrawFilterTest.cxx +++ b/writerperfect/qa/unit/WpftDrawFilterTest.cxx @@ -11,7 +11,6 @@ namespace { - class WpftDrawFilterTest : public writerperfect::test::WpftFilterTestBase { public: @@ -31,39 +30,43 @@ WpftDrawFilterTest::WpftDrawFilterTest() void WpftDrawFilterTest::test() { - const writerperfect::test::WpftOptionalMap_t aMWAWOptional - { - {"ClarisDraw.hqx", REQUIRE_MWAW_VERSION(0, 3, 5)}, - {"CricketDraw_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"CricketDraw_1.1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"FreeHand_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"FreeHand_2.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"MacDraft_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 5)}, - {"MacDraft_5.5.drw", REQUIRE_MWAW_VERSION(0, 3, 6)}, - {"MacDraw_0.hqx", REQUIRE_MWAW_VERSION(0, 3, 2)}, - {"MacDraw_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 2)}, - {"MacDraw_II.hqx", REQUIRE_MWAW_VERSION(0, 3, 3)}, - {"MacDraw_Pro_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 4)}, + const writerperfect::test::WpftOptionalMap_t aMWAWOptional{ + { "ClarisDraw.hqx", REQUIRE_MWAW_VERSION(0, 3, 5) }, + { "CricketDraw_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "CricketDraw_1.1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "FreeHand_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "FreeHand_2.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "MacDraft_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 5) }, + { "MacDraft_5.5.drw", REQUIRE_MWAW_VERSION(0, 3, 6) }, + { "MacDraw_0.hqx", REQUIRE_MWAW_VERSION(0, 3, 2) }, + { "MacDraw_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 2) }, + { "MacDraw_II.hqx", REQUIRE_MWAW_VERSION(0, 3, 3) }, + { "MacDraw_Pro_1.0.hqx", REQUIRE_MWAW_VERSION(0, 3, 4) }, }; - const writerperfect::test::WpftOptionalMap_t aStarOfficeOptional - { - {"Draw_3.1.sda", REQUIRE_STAROFFICE_VERSION(0, 0, 1)}, + const writerperfect::test::WpftOptionalMap_t aStarOfficeOptional{ + { "Draw_3.1.sda", REQUIRE_STAROFFICE_VERSION(0, 0, 1) }, }; doTest("com.sun.star.comp.Draw.CDRImportFilter", "/writerperfect/qa/unit/data/draw/libcdr/"); - doTest("com.sun.star.comp.Draw.CMXImportFilter", "/writerperfect/qa/unit/data/draw/libcdr-cmx/"); - doTest("com.sun.star.comp.Draw.FreehandImportFilter", "/writerperfect/qa/unit/data/draw/libfreehand/"); - doTest("com.sun.star.comp.Draw.MSPUBImportFilter", "/writerperfect/qa/unit/data/draw/libmspub/"); - doTest("com.sun.star.comp.Draw.MWAWDrawImportFilter", "/writerperfect/qa/unit/data/draw/libmwaw/", aMWAWOptional); - doTest("com.sun.star.comp.Draw.VisioImportFilter", "/writerperfect/qa/unit/data/draw/libvisio/"); + doTest("com.sun.star.comp.Draw.CMXImportFilter", + "/writerperfect/qa/unit/data/draw/libcdr-cmx/"); + doTest("com.sun.star.comp.Draw.FreehandImportFilter", + "/writerperfect/qa/unit/data/draw/libfreehand/"); + doTest("com.sun.star.comp.Draw.MSPUBImportFilter", + "/writerperfect/qa/unit/data/draw/libmspub/"); + doTest("com.sun.star.comp.Draw.MWAWDrawImportFilter", + "/writerperfect/qa/unit/data/draw/libmwaw/", aMWAWOptional); + doTest("com.sun.star.comp.Draw.VisioImportFilter", + "/writerperfect/qa/unit/data/draw/libvisio/"); doTest("com.sun.star.comp.Draw.WPGImportFilter", "/writerperfect/qa/unit/data/draw/libwpg/"); - doTest("org.libreoffice.comp.Draw.PageMakerImportFilter", "/writerperfect/qa/unit/data/draw/libpagemaker/"); - doTest("org.libreoffice.comp.Draw.StarOfficeDrawImportFilter", "/writerperfect/qa/unit/data/draw/libstaroffice/", aStarOfficeOptional); + doTest("org.libreoffice.comp.Draw.PageMakerImportFilter", + "/writerperfect/qa/unit/data/draw/libpagemaker/"); + doTest("org.libreoffice.comp.Draw.StarOfficeDrawImportFilter", + "/writerperfect/qa/unit/data/draw/libstaroffice/", aStarOfficeOptional); doTest("org.libreoffice.comp.Draw.ZMFImportFilter", "/writerperfect/qa/unit/data/draw/libzmf/"); } CPPUNIT_TEST_SUITE_REGISTRATION(WpftDrawFilterTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/WpftFilterFixture.cxx b/writerperfect/qa/unit/WpftFilterFixture.cxx index 60708ce30287..f7c3dfcc5999 100644 --- a/writerperfect/qa/unit/WpftFilterFixture.cxx +++ b/writerperfect/qa/unit/WpftFilterFixture.cxx @@ -21,7 +21,6 @@ namespace writerperfect { namespace test { - void WpftFilterFixture::setUp() { ::test::BootstrapFixture::setUp(); @@ -33,7 +32,6 @@ void WpftFilterFixture::setUp() uno::UNO_QUERY_THROW); m_xTypeMap.set(m_xTypeDetection, uno::UNO_QUERY_THROW); } - } } diff --git a/writerperfect/qa/unit/WpftFilterFixture.hxx b/writerperfect/qa/unit/WpftFilterFixture.hxx index 058c042df3d1..f32478165617 100644 --- a/writerperfect/qa/unit/WpftFilterFixture.hxx +++ b/writerperfect/qa/unit/WpftFilterFixture.hxx @@ -21,25 +21,27 @@ #include <test/bootstrapfixture.hxx> -#define REQUIRE_VERSION(major, minor, micro, req_major, req_minor, req_micro) \ - (major) > (req_major) || \ - ((major) == (req_major) && \ - ((minor) > (req_minor) \ - || ((minor) == (req_minor) && ((micro) >= (req_micro))))) +#define REQUIRE_VERSION(major, minor, micro, req_major, req_minor, req_micro) \ + (major) > (req_major) \ + || ((major) == (req_major) \ + && ((minor) > (req_minor) || ((minor) == (req_minor) && ((micro) >= (req_micro))))) -#define REQUIRE_EBOOK_VERSION(major, minor, micro) \ - REQUIRE_VERSION(EBOOK_VERSION_MAJOR, EBOOK_VERSION_MINOR, EBOOK_VERSION_MICRO, major, minor, micro) +#define REQUIRE_EBOOK_VERSION(major, minor, micro) \ + REQUIRE_VERSION(EBOOK_VERSION_MAJOR, EBOOK_VERSION_MINOR, EBOOK_VERSION_MICRO, major, minor, \ + micro) -#define REQUIRE_ETONYEK_VERSION(major, minor, micro) \ - REQUIRE_VERSION(ETONYEK_VERSION_MAJOR, ETONYEK_VERSION_MINOR, ETONYEK_VERSION_MICRO, major, minor, micro) +#define REQUIRE_ETONYEK_VERSION(major, minor, micro) \ + REQUIRE_VERSION(ETONYEK_VERSION_MAJOR, ETONYEK_VERSION_MINOR, ETONYEK_VERSION_MICRO, major, \ + minor, micro) -#define REQUIRE_MWAW_VERSION(major, minor, micro) \ +#define REQUIRE_MWAW_VERSION(major, minor, micro) \ REQUIRE_VERSION(MWAW_VERSION_MAJOR, MWAW_VERSION_MINOR, MWAW_VERSION_MICRO, major, minor, micro) -#define REQUIRE_STAROFFICE_VERSION(major, minor, micro) \ - REQUIRE_VERSION(STAROFFICE_VERSION_MAJOR, STAROFFICE_VERSION_MINOR, STAROFFICE_VERSION_MICRO, major, minor, micro) +#define REQUIRE_STAROFFICE_VERSION(major, minor, micro) \ + REQUIRE_VERSION(STAROFFICE_VERSION_MAJOR, STAROFFICE_VERSION_MINOR, STAROFFICE_VERSION_MICRO, \ + major, minor, micro) -#define REQUIRE_WPS_VERSION(major, minor, micro) \ +#define REQUIRE_WPS_VERSION(major, minor, micro) \ REQUIRE_VERSION(WPS_VERSION_MAJOR, WPS_VERSION_MINOR, WPS_VERSION_MICRO, major, minor, micro) namespace com @@ -68,7 +70,6 @@ namespace writerperfect { namespace test { - class WPFTQAHELPER_DLLPUBLIC WpftFilterFixture : public ::test::BootstrapFixture { public: @@ -79,7 +80,6 @@ protected: css::uno::Reference<css::document::XTypeDetection> m_xTypeDetection; css::uno::Reference<css::container::XNameAccess> m_xTypeMap; }; - } } diff --git a/writerperfect/qa/unit/WpftFilterTestBase.cxx b/writerperfect/qa/unit/WpftFilterTestBase.cxx index dbb1ba27f7a0..301d9a1348ab 100644 --- a/writerperfect/qa/unit/WpftFilterTestBase.cxx +++ b/writerperfect/qa/unit/WpftFilterTestBase.cxx @@ -21,8 +21,7 @@ namespace writerperfect { namespace test { - -WpftFilterTestBase::WpftFilterTestBase(const rtl::OUString &rFactoryURL) +WpftFilterTestBase::WpftFilterTestBase(const rtl::OUString& rFactoryURL) : ::test::FiltersTest() , WpftFilterFixture() , m_aFactoryURL(rFactoryURL) @@ -30,10 +29,9 @@ WpftFilterTestBase::WpftFilterTestBase(const rtl::OUString &rFactoryURL) { } -bool WpftFilterTestBase::load(const OUString &, const OUString &rURL, const OUString &, +bool WpftFilterTestBase::load(const OUString&, const OUString& rURL, const OUString&, SfxFilterFlags, SotClipboardFormatId, unsigned int) { - if (m_pOptionalMap) { // first check if this test file is supported by the used version of the library @@ -47,20 +45,20 @@ bool WpftFilterTestBase::load(const OUString &, const OUString &rURL, const OUSt return aLoader.getDocument().is(); } -void WpftFilterTestBase::doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath) +void WpftFilterTestBase::doTest(const rtl::OUString& rFilter, const rtl::OUString& rPath) { m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW); testDir(OUString(), m_directories.getURLFromSrc(rPath)); } -void WpftFilterTestBase::doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath, const WpftOptionalMap_t &rOptionalMap) +void WpftFilterTestBase::doTest(const rtl::OUString& rFilter, const rtl::OUString& rPath, + const WpftOptionalMap_t& rOptionalMap) { m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW); m_pOptionalMap = &rOptionalMap; testDir(OUString(), m_directories.getURLFromSrc(rPath)); m_pOptionalMap = nullptr; } - } } diff --git a/writerperfect/qa/unit/WpftFilterTestBase.hxx b/writerperfect/qa/unit/WpftFilterTestBase.hxx index 31267f8609bf..481d169d1663 100644 --- a/writerperfect/qa/unit/WpftFilterTestBase.hxx +++ b/writerperfect/qa/unit/WpftFilterTestBase.hxx @@ -40,30 +40,28 @@ namespace writerperfect { namespace test { - typedef std::unordered_map<rtl::OUString, bool> WpftOptionalMap_t; -class WPFTQAHELPER_DLLPUBLIC WpftFilterTestBase - : public ::test::FiltersTest - , public WpftFilterFixture +class WPFTQAHELPER_DLLPUBLIC WpftFilterTestBase : public ::test::FiltersTest, + public WpftFilterFixture { public: - explicit WpftFilterTestBase(const rtl::OUString &rFactoryURL); + explicit WpftFilterTestBase(const rtl::OUString& rFactoryURL); protected: - void doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath); - void doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath, const WpftOptionalMap_t &rOptionalMap); + void doTest(const rtl::OUString& rFilter, const rtl::OUString& rPath); + void doTest(const rtl::OUString& rFilter, const rtl::OUString& rPath, + const WpftOptionalMap_t& rOptionalMap); private: - virtual bool load(const OUString &, const OUString &rURL, const OUString &, - SfxFilterFlags, SotClipboardFormatId, unsigned int) override; + virtual bool load(const OUString&, const OUString& rURL, const OUString&, SfxFilterFlags, + SotClipboardFormatId, unsigned int) override; private: const rtl::OUString m_aFactoryURL; css::uno::Reference<css::document::XFilter> m_xFilter; - const WpftOptionalMap_t *m_pOptionalMap; + const WpftOptionalMap_t* m_pOptionalMap; }; - } } diff --git a/writerperfect/qa/unit/WpftImpressFilterTest.cxx b/writerperfect/qa/unit/WpftImpressFilterTest.cxx index 2da1195d30c5..261085f97cdf 100644 --- a/writerperfect/qa/unit/WpftImpressFilterTest.cxx +++ b/writerperfect/qa/unit/WpftImpressFilterTest.cxx @@ -11,7 +11,6 @@ namespace { - class WpftImpressFilterTest : public writerperfect::test::WpftFilterTestBase { public: @@ -31,31 +30,30 @@ WpftImpressFilterTest::WpftImpressFilterTest() void WpftImpressFilterTest::test() { - const writerperfect::test::WpftOptionalMap_t aEtonyekOptional - { - {"v2.zip", REQUIRE_ETONYEK_VERSION(0, 1, 1)}, - {"v3.zip", REQUIRE_ETONYEK_VERSION(0, 1, 1)}, - {"v6.zip", REQUIRE_ETONYEK_VERSION(0, 1, 4)}, + const writerperfect::test::WpftOptionalMap_t aEtonyekOptional{ + { "v2.zip", REQUIRE_ETONYEK_VERSION(0, 1, 1) }, + { "v3.zip", REQUIRE_ETONYEK_VERSION(0, 1, 1) }, + { "v6.zip", REQUIRE_ETONYEK_VERSION(0, 1, 4) }, }; - const writerperfect::test::WpftOptionalMap_t aMWAWOptional - { - {"ClarisWorks_6.0.cwk", REQUIRE_MWAW_VERSION(0, 3, 3)}, - {"PowerPoint_Mac_1", REQUIRE_MWAW_VERSION(0, 3, 9)}, - {"PowerPoint_Mac_2", REQUIRE_MWAW_VERSION(0, 3, 9)}, - {"PowerPoint_Mac_3", REQUIRE_MWAW_VERSION(0, 3, 9)}, - {"PowerPoint_Mac_4.ppt", REQUIRE_MWAW_VERSION(0, 3, 10)}, - {"PowerPoint_2.ppt", REQUIRE_MWAW_VERSION(0, 3, 10)}, - {"PowerPoint_3.ppt", REQUIRE_MWAW_VERSION(0, 3, 9)}, - {"PowerPoint_4.ppt", REQUIRE_MWAW_VERSION(0, 3, 10)}, - {"PowerPoint_7.ppt", REQUIRE_MWAW_VERSION(0, 3, 11)}, + const writerperfect::test::WpftOptionalMap_t aMWAWOptional{ + { "ClarisWorks_6.0.cwk", REQUIRE_MWAW_VERSION(0, 3, 3) }, + { "PowerPoint_Mac_1", REQUIRE_MWAW_VERSION(0, 3, 9) }, + { "PowerPoint_Mac_2", REQUIRE_MWAW_VERSION(0, 3, 9) }, + { "PowerPoint_Mac_3", REQUIRE_MWAW_VERSION(0, 3, 9) }, + { "PowerPoint_Mac_4.ppt", REQUIRE_MWAW_VERSION(0, 3, 10) }, + { "PowerPoint_2.ppt", REQUIRE_MWAW_VERSION(0, 3, 10) }, + { "PowerPoint_3.ppt", REQUIRE_MWAW_VERSION(0, 3, 9) }, + { "PowerPoint_4.ppt", REQUIRE_MWAW_VERSION(0, 3, 10) }, + { "PowerPoint_7.ppt", REQUIRE_MWAW_VERSION(0, 3, 11) }, }; - doTest("org.libreoffice.comp.Impress.KeynoteImportFilter", "/writerperfect/qa/unit/data/impress/libetonyek/", aEtonyekOptional); - doTest("com.sun.star.comp.Impress.MWAWPresentationImportFilter", "/writerperfect/qa/unit/data/impress/libmwaw/", aMWAWOptional); + doTest("org.libreoffice.comp.Impress.KeynoteImportFilter", + "/writerperfect/qa/unit/data/impress/libetonyek/", aEtonyekOptional); + doTest("com.sun.star.comp.Impress.MWAWPresentationImportFilter", + "/writerperfect/qa/unit/data/impress/libmwaw/", aMWAWOptional); } CPPUNIT_TEST_SUITE_REGISTRATION(WpftImpressFilterTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/WpftLoader.cxx b/writerperfect/qa/unit/WpftLoader.cxx index dbf94287ef8a..b89353d5c568 100644 --- a/writerperfect/qa/unit/WpftLoader.cxx +++ b/writerperfect/qa/unit/WpftLoader.cxx @@ -42,15 +42,12 @@ namespace writerperfect { namespace test { - -WpftLoader::WpftLoader( - const rtl::OUString &rURL, - const css::uno::Reference<css::document::XFilter> &rxFilter, - const rtl::OUString &rFactoryURL, - const css::uno::Reference<css::frame::XDesktop2> &rxDesktop, - const css::uno::Reference<css::container::XNameAccess> &rxTypeMap, - const css::uno::Reference<css::uno::XComponentContext> &rxContext -) +WpftLoader::WpftLoader(const rtl::OUString& rURL, + const css::uno::Reference<css::document::XFilter>& rxFilter, + const rtl::OUString& rFactoryURL, + const css::uno::Reference<css::frame::XDesktop2>& rxDesktop, + const css::uno::Reference<css::container::XNameAccess>& rxTypeMap, + const css::uno::Reference<css::uno::XComponentContext>& rxContext) : m_aURL(rURL) , m_aFactoryURL(rFactoryURL) , m_xFilter(rxFilter) @@ -62,13 +59,11 @@ WpftLoader::WpftLoader( impl_dispose(); } -WpftLoader::WpftLoader( - const css::uno::Reference<css::io::XInputStream> &rxInputStream, - const css::uno::Reference<css::document::XFilter> &rxFilter, - const rtl::OUString &rFactoryURL, - const css::uno::Reference<css::frame::XDesktop2> &rxDesktop, - const css::uno::Reference<css::uno::XComponentContext> &rxContext -) +WpftLoader::WpftLoader(const css::uno::Reference<css::io::XInputStream>& rxInputStream, + const css::uno::Reference<css::document::XFilter>& rxFilter, + const rtl::OUString& rFactoryURL, + const css::uno::Reference<css::frame::XDesktop2>& rxDesktop, + const css::uno::Reference<css::uno::XComponentContext>& rxContext) : m_xInputStream(rxInputStream) , m_aFactoryURL(rFactoryURL) , m_xFilter(rxFilter) @@ -90,17 +85,14 @@ WpftLoader::~WpftLoader() } } -const css::uno::Reference<css::lang::XComponent> &WpftLoader::getDocument() const -{ - return m_xDoc; -} +const css::uno::Reference<css::lang::XComponent>& WpftLoader::getDocument() const { return m_xDoc; } bool WpftLoader::impl_load() { // create an empty frame - m_xDoc.set( - m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, uno::Sequence<beans::PropertyValue>()), - uno::UNO_QUERY_THROW); + m_xDoc.set(m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, + uno::Sequence<beans::PropertyValue>()), + uno::UNO_QUERY_THROW); // Find the model and frame. We need them later. m_xFrame.set(m_xDoc, uno::UNO_QUERY); @@ -143,14 +135,16 @@ bool WpftLoader::impl_load() } else { - ucbhelper::Content aContent(m_aURL, uno::Reference<ucb::XCommandEnvironment>(), m_xContext); + ucbhelper::Content aContent(m_aURL, uno::Reference<ucb::XCommandEnvironment>(), + m_xContext); aDescriptor[1].Name = "InputStream"; aDescriptor[1].Value <<= aContent.openStream(); aDescriptor[2].Name = "UCBContent"; aDescriptor[2].Value <<= aContent.get(); } - const uno::Reference<document::XExtendedFilterDetection> xDetector(m_xFilter, uno::UNO_QUERY_THROW); + const uno::Reference<document::XExtendedFilterDetection> xDetector(m_xFilter, + uno::UNO_QUERY_THROW); const rtl::OUString aTypeName(xDetector->detect(aDescriptor)); if (aTypeName.isEmpty()) @@ -164,7 +158,7 @@ bool WpftLoader::impl_load() xModel->unlockControllers(); return bLoaded; } - catch (const uno::Exception &) + catch (const uno::Exception&) { // ignore } @@ -184,7 +178,8 @@ void WpftLoader::impl_dispose() m_xFrame.clear(); } -void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue> &rDescriptor, const rtl::OUString &rTypeName) +void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue>& rDescriptor, + const rtl::OUString& rTypeName) { const sal_Int32 nDescriptorLen = rDescriptor.getLength(); @@ -212,7 +207,6 @@ void WpftLoader::impl_detectFilterName(uno::Sequence<beans::PropertyValue> &rDes throw container::NoSuchElementException(); } - } } diff --git a/writerperfect/qa/unit/WpftLoader.hxx b/writerperfect/qa/unit/WpftLoader.hxx index 0283b6a6fcda..d76fb76ea52f 100644 --- a/writerperfect/qa/unit/WpftLoader.hxx +++ b/writerperfect/qa/unit/WpftLoader.hxx @@ -60,34 +60,30 @@ namespace writerperfect { namespace test { - class WPFTQAHELPER_DLLPUBLIC WpftLoader { public: - WpftLoader( - const rtl::OUString &rURL, - const css::uno::Reference<css::document::XFilter> &rxFilter, - const rtl::OUString &rFactoryURL, - const css::uno::Reference<css::frame::XDesktop2> &rxDesktop, - const css::uno::Reference<css::container::XNameAccess> &rxTypeMap, - const css::uno::Reference<css::uno::XComponentContext> &rxContext - ); - WpftLoader( - const css::uno::Reference<css::io::XInputStream> &rxInputStream, - const css::uno::Reference<css::document::XFilter> &rxFilter, - const rtl::OUString &rFactoryURL, - const css::uno::Reference<css::frame::XDesktop2> &rxDesktop, - const css::uno::Reference<css::uno::XComponentContext> &rxContext - ); + WpftLoader(const rtl::OUString& rURL, + const css::uno::Reference<css::document::XFilter>& rxFilter, + const rtl::OUString& rFactoryURL, + const css::uno::Reference<css::frame::XDesktop2>& rxDesktop, + const css::uno::Reference<css::container::XNameAccess>& rxTypeMap, + const css::uno::Reference<css::uno::XComponentContext>& rxContext); + WpftLoader(const css::uno::Reference<css::io::XInputStream>& rxInputStream, + const css::uno::Reference<css::document::XFilter>& rxFilter, + const rtl::OUString& rFactoryURL, + const css::uno::Reference<css::frame::XDesktop2>& rxDesktop, + const css::uno::Reference<css::uno::XComponentContext>& rxContext); ~WpftLoader(); - const css::uno::Reference<css::lang::XComponent> &getDocument() const; + const css::uno::Reference<css::lang::XComponent>& getDocument() const; private: bool impl_load(); void impl_dispose(); - void impl_detectFilterName(css::uno::Sequence<css::beans::PropertyValue> &rDescriptor, const rtl::OUString &rTypeName); + void impl_detectFilterName(css::uno::Sequence<css::beans::PropertyValue>& rDescriptor, + const rtl::OUString& rTypeName); private: const rtl::OUString m_aURL; @@ -100,7 +96,6 @@ private: css::uno::Reference<css::lang::XComponent> m_xDoc; css::uno::Reference<css::frame::XFrame> m_xFrame; }; - } } diff --git a/writerperfect/qa/unit/WpftWriterFilterTest.cxx b/writerperfect/qa/unit/WpftWriterFilterTest.cxx index 515a2b8a7e92..0ec335da6c00 100644 --- a/writerperfect/qa/unit/WpftWriterFilterTest.cxx +++ b/writerperfect/qa/unit/WpftWriterFilterTest.cxx @@ -11,7 +11,6 @@ namespace { - class WpftWriterFilterTest : public writerperfect::test::WpftFilterTestBase { public: @@ -31,43 +30,44 @@ WpftWriterFilterTest::WpftWriterFilterTest() void WpftWriterFilterTest::test() { - const writerperfect::test::WpftOptionalMap_t aEBookOptional - { - {"FictionBook2.fb2.zip", REQUIRE_EBOOK_VERSION(0, 1, 1)}, + const writerperfect::test::WpftOptionalMap_t aEBookOptional{ + { "FictionBook2.fb2.zip", REQUIRE_EBOOK_VERSION(0, 1, 1) }, }; - const writerperfect::test::WpftOptionalMap_t aEtonyekOptional - { - {"Pages_4.pages", REQUIRE_ETONYEK_VERSION(0, 1, 2)}, + const writerperfect::test::WpftOptionalMap_t aEtonyekOptional{ + { "Pages_4.pages", REQUIRE_ETONYEK_VERSION(0, 1, 2) }, }; - const writerperfect::test::WpftOptionalMap_t aMWAWOptional - { - {"MaxWrite_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"MouseWrite_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8)}, - {"RagTime_2.1.hqx", REQUIRE_MWAW_VERSION(0, 3, 2)}, - {"RagTime_3.2.hqx", REQUIRE_MWAW_VERSION(0, 3, 2)}, - {"RagTime_5.5.rag", REQUIRE_MWAW_VERSION(0, 3, 6)}, + const writerperfect::test::WpftOptionalMap_t aMWAWOptional{ + { "MaxWrite_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "MouseWrite_1.hqx", REQUIRE_MWAW_VERSION(0, 3, 8) }, + { "RagTime_2.1.hqx", REQUIRE_MWAW_VERSION(0, 3, 2) }, + { "RagTime_3.2.hqx", REQUIRE_MWAW_VERSION(0, 3, 2) }, + { "RagTime_5.5.rag", REQUIRE_MWAW_VERSION(0, 3, 6) }, }; - const writerperfect::test::WpftOptionalMap_t aStarOfficeOptional - { - {"Writer_3.1.sdw", REQUIRE_STAROFFICE_VERSION(0, 0, 2)}, + const writerperfect::test::WpftOptionalMap_t aStarOfficeOptional{ + { "Writer_3.1.sdw", REQUIRE_STAROFFICE_VERSION(0, 0, 2) }, }; - const writerperfect::test::WpftOptionalMap_t aWpsOptional - { - {"Word_5.0_DOS.doc", REQUIRE_WPS_VERSION(0, 4, 3)}, - {"Write_3.1.wri", REQUIRE_WPS_VERSION(0, 4, 2)}, + const writerperfect::test::WpftOptionalMap_t aWpsOptional{ + { "Word_5.0_DOS.doc", REQUIRE_WPS_VERSION(0, 4, 3) }, + { "Write_3.1.wri", REQUIRE_WPS_VERSION(0, 4, 2) }, }; - doTest("com.sun.star.comp.Writer.AbiWordImportFilter", "/writerperfect/qa/unit/data/writer/libabw/"); - doTest("org.libreoffice.comp.Writer.EBookImportFilter", "/writerperfect/qa/unit/data/writer/libe-book/", aEBookOptional); - doTest("com.sun.star.comp.Writer.MSWorksImportFilter", "/writerperfect/qa/unit/data/writer/libwps/", aWpsOptional); - doTest("com.sun.star.comp.Writer.MWAWImportFilter", "/writerperfect/qa/unit/data/writer/libmwaw/", aMWAWOptional); - doTest("org.libreoffice.comp.Writer.PagesImportFilter", "/writerperfect/qa/unit/data/writer/libetonyek/", aEtonyekOptional); - doTest("org.libreoffice.comp.Writer.StarOfficeWriterImportFilter", "/writerperfect/qa/unit/data/writer/libstaroffice/", aStarOfficeOptional); - doTest("com.sun.star.comp.Writer.WordPerfectImportFilter", "/writerperfect/qa/unit/data/writer/libwpd/"); + doTest("com.sun.star.comp.Writer.AbiWordImportFilter", + "/writerperfect/qa/unit/data/writer/libabw/"); + doTest("org.libreoffice.comp.Writer.EBookImportFilter", + "/writerperfect/qa/unit/data/writer/libe-book/", aEBookOptional); + doTest("com.sun.star.comp.Writer.MSWorksImportFilter", + "/writerperfect/qa/unit/data/writer/libwps/", aWpsOptional); + doTest("com.sun.star.comp.Writer.MWAWImportFilter", + "/writerperfect/qa/unit/data/writer/libmwaw/", aMWAWOptional); + doTest("org.libreoffice.comp.Writer.PagesImportFilter", + "/writerperfect/qa/unit/data/writer/libetonyek/", aEtonyekOptional); + doTest("org.libreoffice.comp.Writer.StarOfficeWriterImportFilter", + "/writerperfect/qa/unit/data/writer/libstaroffice/", aStarOfficeOptional); + doTest("com.sun.star.comp.Writer.WordPerfectImportFilter", + "/writerperfect/qa/unit/data/writer/libwpd/"); } CPPUNIT_TEST_SUITE_REGISTRATION(WpftWriterFilterTest); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerperfect/qa/unit/wpftimport.cxx b/writerperfect/qa/unit/wpftimport.cxx index 427cb2c294d6..fe3bfa02f9a6 100644 --- a/writerperfect/qa/unit/wpftimport.cxx +++ b/writerperfect/qa/unit/wpftimport.cxx @@ -19,7 +19,8 @@ css::uno::Reference<css::io::XInputStream> createDummyInput() { - rtl::Reference<comphelper::SequenceInputStream> xDummyInput(new comphelper::SequenceInputStream(css::uno::Sequence<sal_Int8>())); + rtl::Reference<comphelper::SequenceInputStream> xDummyInput( + new comphelper::SequenceInputStream(css::uno::Sequence<sal_Int8>())); return xDummyInput.get(); } diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index e10cdc45d638..c254f70b5198 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -31,24 +31,26 @@ using namespace ::com::sun::star; -using uno::Sequence; -using uno::XInterface; using uno::Exception; using uno::RuntimeException; +using uno::Sequence; using uno::XComponentContext; +using uno::XInterface; namespace MSWorksCalcImportFilterInternal { - /// returns the list of stream name present in a folder -uno::Reference<sdbc::XResultSet> getResultSet(const css::uno::Reference<css::ucb::XContent> &xPackageContent) -try +uno::Reference<sdbc::XResultSet> +getResultSet(const css::uno::Reference<css::ucb::XContent>& xPackageContent) try { if (xPackageContent.is()) { - ucbhelper::Content packageContent(xPackageContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); - uno::Sequence<OUString> lPropNames { "Title" }; - uno::Reference<sdbc::XResultSet> xResultSet(packageContent.createCursor(lPropNames, ucbhelper::INCLUDE_DOCUMENTS_ONLY)); + ucbhelper::Content packageContent(xPackageContent, + uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext()); + uno::Sequence<OUString> lPropNames{ "Title" }; + uno::Reference<sdbc::XResultSet> xResultSet( + packageContent.createCursor(lPropNames, ucbhelper::INCLUDE_DOCUMENTS_ONLY)); return xResultSet; } return uno::Reference<sdbc::XResultSet>(); @@ -61,138 +63,133 @@ catch (...) /** internal class used to create a structured RVNGInputStream from a list of path and their short names */ -class FolderStream: public librevenge::RVNGInputStream +class FolderStream : public librevenge::RVNGInputStream { public: //! constructor - explicit FolderStream(const css::uno::Reference<css::ucb::XContent> &xContent) : - librevenge::RVNGInputStream(), m_xContent(xContent), m_nameToPathMap() + explicit FolderStream(const css::uno::Reference<css::ucb::XContent>& xContent) + : librevenge::RVNGInputStream() + , m_xContent(xContent) + , m_nameToPathMap() { } //! add a file - void addFile(rtl::OUString const &path, std::string const &shortName) + void addFile(rtl::OUString const& path, std::string const& shortName) { - m_nameToPathMap[shortName]=path; + m_nameToPathMap[shortName] = path; } /**! reads numbytes data. * \return a pointer to the read elements */ - const unsigned char *read(unsigned long, unsigned long &) override - { - return nullptr; - } + const unsigned char* read(unsigned long, unsigned long&) override { return nullptr; } //! returns actual offset position - long tell() override - { - return 0; - } + long tell() override { return 0; } /*! \brief seeks to a offset position, from actual, beginning or ending position * \return 0 if ok */ - int seek(long, librevenge::RVNG_SEEK_TYPE) override - { - return 1; - } + int seek(long, librevenge::RVNG_SEEK_TYPE) override { return 1; } //! returns true if we are at the end of the section/file - bool isEnd() override - { - return true; - } + bool isEnd() override { return true; } /** returns true if the stream is ole \sa returns always false*/ - bool isStructured() override - { - return true; - } + bool isStructured() override { return true; } /** returns the number of sub streams. \sa returns always 2*/ - unsigned subStreamCount() override - { - return unsigned(m_nameToPathMap.size()); - } + unsigned subStreamCount() override { return unsigned(m_nameToPathMap.size()); } /** returns the ith sub streams name */ - const char *subStreamName(unsigned id) override + const char* subStreamName(unsigned id) override { - std::map<std::string, rtl::OUString>::const_iterator it=m_nameToPathMap.begin(); - for (unsigned i=0; i<id; ++i) + std::map<std::string, rtl::OUString>::const_iterator it = m_nameToPathMap.begin(); + for (unsigned i = 0; i < id; ++i) { - if (it==m_nameToPathMap.end()) return nullptr; + if (it == m_nameToPathMap.end()) + return nullptr; ++it; } - if (it==m_nameToPathMap.end()) return nullptr; + if (it == m_nameToPathMap.end()) + return nullptr; return it->first.c_str(); } /** returns true if a substream with name exists */ - bool existsSubStream(const char *name) override + bool existsSubStream(const char* name) override { - return name && m_nameToPathMap.find(name)!= m_nameToPathMap.end(); + return name && m_nameToPathMap.find(name) != m_nameToPathMap.end(); } /** return a new stream for a ole zone */ - librevenge::RVNGInputStream *getSubStreamByName(const char *name) override + librevenge::RVNGInputStream* getSubStreamByName(const char* name) override { - if (m_nameToPathMap.find(name)== m_nameToPathMap.end() || !m_xContent.is()) return nullptr; + if (m_nameToPathMap.find(name) == m_nameToPathMap.end() || !m_xContent.is()) + return nullptr; try { - const uno::Reference<sdbc::XResultSet> xResultSet=getResultSet(m_xContent); + const uno::Reference<sdbc::XResultSet> xResultSet = getResultSet(m_xContent); if (xResultSet.is() && xResultSet->first()) { - const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY_THROW); + const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, + uno::UNO_QUERY_THROW); const uno::Reference<sdbc::XRow> xRow(xResultSet, uno::UNO_QUERY_THROW); - OUString lPath=m_nameToPathMap.find(name)->second; + OUString lPath = m_nameToPathMap.find(name)->second; do { const rtl::OUString aTitle(xRow->getString(1)); - if (aTitle != lPath) continue; + if (aTitle != lPath) + continue; const uno::Reference<ucb::XContent> xSubContent(xContentAccess->queryContent()); - ucbhelper::Content aSubContent(xSubContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); + ucbhelper::Content aSubContent(xSubContent, + uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext()); uno::Reference<io::XInputStream> xInputStream = aSubContent.openStream(); if (xInputStream.is()) return new writerperfect::WPXSvInputStream(xInputStream); break; - } - while (xResultSet->next()); + } while (xResultSet->next()); } } catch (...) { - SAL_WARN("writerperfect", "ignoring Exception in MSWorksCalcImportFilterInternal::FolderStream::getSubStreamByName"); + SAL_WARN("writerperfect", "ignoring Exception in " + "MSWorksCalcImportFilterInternal::FolderStream::" + "getSubStreamByName"); } return nullptr; } /** return a new stream for a ole zone */ - librevenge::RVNGInputStream *getSubStreamById(unsigned id) override + librevenge::RVNGInputStream* getSubStreamById(unsigned id) override { - char const *name=subStreamName(id); + char const* name = subStreamName(id); return name ? getSubStreamByName(name) : nullptr; } + private: /// the main container uno::Reference<ucb::XContent> m_xContent; /// the map short name to path std::map<std::string, rtl::OUString> m_nameToPathMap; - FolderStream(const FolderStream &) = delete; - FolderStream &operator=(const FolderStream &) = delete; + FolderStream(const FolderStream&) = delete; + FolderStream& operator=(const FolderStream&) = delete; }; - } //////////////////////////////////////////////////////////// -bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) +bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdsGenerator& rGenerator, utl::MediaDescriptor&) { libwps::WPSKind kind = libwps::WPS_TEXT; libwps::WPSCreator creator; bool needEncoding; - const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, 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)) + if ((kind != libwps::WPS_SPREADSHEET && kind != libwps::WPS_DATABASE) + || (confidence == libwps::WPS_CONFIDENCE_NONE)) return false; std::string fileEncoding; if (needEncoding) @@ -200,23 +197,23 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp OUString title, encoding; if (creator == libwps::WPS_MSWORKS) { - title=WpResId(STR_ENCODING_DIALOG_TITLE_MSWORKS); - encoding="CP850"; + title = WpResId(STR_ENCODING_DIALOG_TITLE_MSWORKS); + encoding = "CP850"; } else if (creator == libwps::WPS_LOTUS) { - title=WpResId(STR_ENCODING_DIALOG_TITLE_LOTUS); - encoding="CP437"; + title = WpResId(STR_ENCODING_DIALOG_TITLE_LOTUS); + encoding = "CP437"; } else if (creator == libwps::WPS_SYMPHONY) { - title=WpResId(STR_ENCODING_DIALOG_TITLE_SYMPHONY); - encoding="CP437"; + title = WpResId(STR_ENCODING_DIALOG_TITLE_SYMPHONY); + encoding = "CP437"; } else { - title=WpResId(STR_ENCODING_DIALOG_TITLE_QUATTROPRO); - encoding="CP437"; + title = WpResId(STR_ENCODING_DIALOG_TITLE_QUATTROPRO); + encoding = "CP437"; } try { @@ -224,7 +221,7 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp if (pDlg->Execute() == RET_OK) { if (!pDlg->GetEncoding().isEmpty()) - fileEncoding=pDlg->GetEncoding().toUtf8().getStr(); + fileEncoding = pDlg->GetEncoding().toUtf8().getStr(); } // we can fail because we are in headless mode, the user has cancelled conversion, ... else if (pDlg->hasUserCalledCancel()) @@ -232,11 +229,12 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp } catch (...) { - SAL_WARN("writerperfect", "ignoring Exception in MSWorksCalcImportFilter::doImportDocument"); + SAL_WARN("writerperfect", + "ignoring Exception in MSWorksCalcImportFilter::doImportDocument"); } } OString aUtf8Passwd; - if (confidence==libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION) + if (confidence == libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION) { // try to ask for a password try @@ -253,19 +251,25 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp return false; } } - return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator, confidence==libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION ? aUtf8Passwd.getStr() : nullptr, fileEncoding.c_str()); + return libwps::WPS_OK + == libwps::WPSDocument::parse(&rInput, &rGenerator, + confidence == libwps::WPS_CONFIDENCE_SUPPORTED_ENCRYPTION + ? aUtf8Passwd.getStr() + : nullptr, + fileEncoding.c_str()); } //XExtendedFilterDetection -sal_Bool MSWorksCalcImportFilter::filter(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor) +sal_Bool +MSWorksCalcImportFilter::filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) { OUString sUrl; - css::uno::Reference < css::io::XInputStream > xInputStream; - css::uno::Reference < ucb::XContent > xContent; + css::uno::Reference<css::io::XInputStream> xInputStream; + css::uno::Reference<ucb::XContent> xContent; sal_Int32 nLength = rDescriptor.getLength(); - const css::beans::PropertyValue *pValue = rDescriptor.getConstArray(); - for (sal_Int32 i = 0 ; i < nLength; i++) + const css::beans::PropertyValue* pValue = rDescriptor.getConstArray(); + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "InputStream") pValue[i].Value >>= xInputStream; @@ -282,13 +286,13 @@ sal_Bool MSWorksCalcImportFilter::filter(const css::uno::Sequence< css::beans::P } // An XML import service: what we push sax messages to.. - css::uno::Reference < css::xml::sax::XDocumentHandler > xInternalHandler - (getXContext()->getServiceManager()->createInstanceWithContext - (writerperfect::DocumentHandlerFor<OdsGenerator>::name(), getXContext()), - css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::xml::sax::XDocumentHandler> xInternalHandler( + getXContext()->getServiceManager()->createInstanceWithContext( + writerperfect::DocumentHandlerFor<OdsGenerator>::name(), getXContext()), + css::uno::UNO_QUERY_THROW); // The XImporter sets up an empty target document for XDocumentHandler to write to.. - css::uno::Reference < css::document::XImporter > xImporter(xInternalHandler, css::uno::UNO_QUERY); + css::uno::Reference<css::document::XImporter> xImporter(xInternalHandler, css::uno::UNO_QUERY); xImporter->setTargetDocument(getTargetDocument()); // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here @@ -305,53 +309,61 @@ sal_Bool MSWorksCalcImportFilter::filter(const css::uno::Sequence< css::beans::P { // time to check if the file is a WK3 file and a FM3 file is // present - bool checkForFM3=false; - if (input.seek(0, librevenge::RVNG_SEEK_SET)==0 && xContent.is() && INetURLObject(sUrl).getExtension().equalsIgnoreAsciiCase("WK3")) + bool checkForFM3 = false; + if (input.seek(0, librevenge::RVNG_SEEK_SET) == 0 && xContent.is() + && INetURLObject(sUrl).getExtension().equalsIgnoreAsciiCase("WK3")) { // check if the file header corresponds to a .wk3 file unsigned long numBytesRead; - const unsigned char *data=input.read(6, numBytesRead); - if (data && numBytesRead==6 && data[0]==0 && data[1]==0 && data[2]==0x1a && - data[3]==0 && data[4]<2 && data[5]==0x10) - checkForFM3=true; + const unsigned char* data = input.read(6, numBytesRead); + if (data && numBytesRead == 6 && data[0] == 0 && data[1] == 0 && data[2] == 0x1a + && data[3] == 0 && data[4] < 2 && data[5] == 0x10) + checkForFM3 = true; } if (checkForFM3) { // check if the format file exists - const css::uno::Reference < container::XChild > xChild(xContent, uno::UNO_QUERY); + const css::uno::Reference<container::XChild> xChild(xContent, uno::UNO_QUERY); if (xChild.is()) { rtl::OUString sWM3Name; rtl::OUString sFM3Name; - const css::uno::Reference < ucb::XContent > xPackageContent(xChild->getParent(), uno::UNO_QUERY); - uno::Reference<sdbc::XResultSet> xResultSet=MSWorksCalcImportFilterInternal::getResultSet(xPackageContent); + const css::uno::Reference<ucb::XContent> xPackageContent(xChild->getParent(), + uno::UNO_QUERY); + uno::Reference<sdbc::XResultSet> xResultSet + = MSWorksCalcImportFilterInternal::getResultSet(xPackageContent); if (xResultSet.is() && xResultSet->first()) { - const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY_THROW); + const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, + uno::UNO_QUERY_THROW); const uno::Reference<sdbc::XRow> xRow(xResultSet, uno::UNO_QUERY_THROW); INetURLObject aTmpUrl(sUrl); - sWM3Name = aTmpUrl.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); + sWM3Name = aTmpUrl.getName(INetURLObject::LAST_SEGMENT, true, + INetURLObject::DecodeMechanism::WithCharset); aTmpUrl.setExtension("FM3"); - const rtl::OUString &sTestFM3Name = aTmpUrl.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); + const rtl::OUString& sTestFM3Name + = aTmpUrl.getName(INetURLObject::LAST_SEGMENT, true, + INetURLObject::DecodeMechanism::WithCharset); do { - const rtl::OUString &aTitle(xRow->getString(1)); + const rtl::OUString& aTitle(xRow->getString(1)); if (aTitle.equalsIgnoreAsciiCase(sTestFM3Name)) sFM3Name = aTitle; - } - while (xResultSet->next() && sFM3Name.isEmpty()); + } while (xResultSet->next() && sFM3Name.isEmpty()); } if (!sFM3Name.isEmpty()) { MSWorksCalcImportFilterInternal::FolderStream structuredInput(xPackageContent); - structuredInput.addFile(sWM3Name,"WK3"); - structuredInput.addFile(sFM3Name,"FM3"); + structuredInput.addFile(sWM3Name, "WK3"); + structuredInput.addFile(sFM3Name, "FM3"); 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) + const libwps::WPSConfidence confidence + = libwps::WPSDocument::isFileFormatSupported(&structuredInput, kind, + creator, needEncoding); + if (confidence != libwps::WPS_CONFIDENCE_NONE) return doImportDocument(structuredInput, exporter, aDescriptor); } } @@ -364,14 +376,17 @@ sal_Bool MSWorksCalcImportFilter::filter(const css::uno::Sequence< css::beans::P return doImportDocument(input, exporter, aDescriptor); } -bool MSWorksCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MSWorksCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, + OUString& rTypeName) { libwps::WPSKind kind = libwps::WPS_TEXT; libwps::WPSCreator creator; bool needEncoding; - const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, 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) + if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) + && confidence != libwps::WPS_CONFIDENCE_NONE) { if (creator == libwps::WPS_MSWORKS) { @@ -393,9 +408,7 @@ bool MSWorksCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput return false; } -void MSWorksCalcImportFilter::doRegisterHandlers(OdsGenerator &) -{ -} +void MSWorksCalcImportFilter::doRegisterHandlers(OdsGenerator&) {} // XServiceInfo OUString SAL_CALL MSWorksCalcImportFilter::getImplementationName() @@ -403,25 +416,23 @@ OUString SAL_CALL MSWorksCalcImportFilter::getImplementationName() return OUString("com.sun.star.comp.Calc.MSWorksCalcImportFilter"); } -sal_Bool SAL_CALL MSWorksCalcImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MSWorksCalcImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MSWorksCalcImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MSWorksCalcImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Calc_MSWorksCalcImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MSWorksCalcImportFilter(context)); } diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx index 045013f55350..4af9bee1f800 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx @@ -23,20 +23,26 @@ class MSWorksCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: - explicit MSWorksCalcImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} + explicit MSWorksCalcImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdsGenerator>(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; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; //XFilter - virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor) override; + virtual sal_Bool SAL_CALL + filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) 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; + 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 diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.cxx b/writerperfect/source/calc/MWAWCalcImportFilter.cxx index 64b61e9dad3c..6981f70ffd45 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.cxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.cxx @@ -16,85 +16,92 @@ #include "MWAWCalcImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdgGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeGraphic(data, &exporter); } -static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) +bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdsGenerator& rGenerator, utl::MediaDescriptor&) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } -bool MWAWCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MWAWCalcImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { rTypeName.clear(); MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN; MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN; - const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); + const MWAWDocument::Confidence confidence + = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); if (confidence == MWAWDocument::MWAW_C_EXCELLENT) { switch (docKind) { - case MWAWDocument::MWAW_K_DATABASE: - switch (docType) - { - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "calc_ClarisWorks"; - break; - case MWAWDocument::MWAW_T_MICROSOFTWORKS: - rTypeName = "calc_Mac_Works"; - break; - default: - rTypeName = "MWAW_Database"; - break; - } - break; - case MWAWDocument::MWAW_K_SPREADSHEET: - switch (docType) - { - case MWAWDocument::MWAW_T_CLARISRESOLVE: - rTypeName = "calc_Claris_Resolve"; - break; - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "calc_ClarisWorks"; + case MWAWDocument::MWAW_K_DATABASE: + switch (docType) + { + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "calc_ClarisWorks"; + break; + case MWAWDocument::MWAW_T_MICROSOFTWORKS: + rTypeName = "calc_Mac_Works"; + break; + default: + rTypeName = "MWAW_Database"; + break; + } break; - case MWAWDocument::MWAW_T_MICROSOFTWORKS: - rTypeName = "calc_Mac_Works"; + case MWAWDocument::MWAW_K_SPREADSHEET: + switch (docType) + { + case MWAWDocument::MWAW_T_CLARISRESOLVE: + rTypeName = "calc_Claris_Resolve"; + break; + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "calc_ClarisWorks"; + break; + case MWAWDocument::MWAW_T_MICROSOFTWORKS: + rTypeName = "calc_Mac_Works"; + break; + default: + rTypeName = "MWAW_Spreadsheet"; + break; + } break; default: - rTypeName = "MWAW_Spreadsheet"; break; - } - break; - default: - break; } } return !rTypeName.isEmpty(); } -void MWAWCalcImportFilter::doRegisterHandlers(OdsGenerator &rGenerator) +void MWAWCalcImportFilter::doRegisterHandlers(OdsGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", + &handleEmbeddedMWAWSpreadsheetObject); } // XServiceInfo @@ -103,25 +110,23 @@ OUString SAL_CALL MWAWCalcImportFilter::getImplementationName() return OUString("com.sun.star.comp.Calc.MWAWCalcImportFilter"); } -sal_Bool SAL_CALL MWAWCalcImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MWAWCalcImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MWAWCalcImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MWAWCalcImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Calc_MWAWCalcImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MWAWCalcImportFilter(context)); } diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.hxx b/writerperfect/source/calc/MWAWCalcImportFilter.hxx index 96c079186594..4b0b3727a9d3 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.hxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.hxx @@ -23,18 +23,21 @@ class MWAWCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: - explicit MWAWCalcImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} + explicit MWAWCalcImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdsGenerator>(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; + 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, OdsGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdsGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/calc/NumbersImportFilter.cxx b/writerperfect/source/calc/NumbersImportFilter.cxx index 9d0774f8a5c8..68f091768c0f 100644 --- a/writerperfect/source/calc/NumbersImportFilter.cxx +++ b/writerperfect/source/calc/NumbersImportFilter.cxx @@ -15,23 +15,25 @@ #include "NumbersImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; using libetonyek::EtonyekDocument; -bool NumbersImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) +bool NumbersImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdsGenerator& rGenerator, utl::MediaDescriptor&) { return EtonyekDocument::parse(&rInput, &rGenerator); } -bool NumbersImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool NumbersImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { EtonyekDocument::Type type = EtonyekDocument::TYPE_UNKNOWN; const EtonyekDocument::Confidence confidence = EtonyekDocument::isSupported(&rInput, &type); - if ((confidence == EtonyekDocument::CONFIDENCE_EXCELLENT) && (type == EtonyekDocument::TYPE_NUMBERS)) + if ((confidence == EtonyekDocument::CONFIDENCE_EXCELLENT) + && (type == EtonyekDocument::TYPE_NUMBERS)) { rTypeName = "calc_AppleNumbers"; return true; @@ -40,9 +42,7 @@ bool NumbersImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OU return false; } -void NumbersImportFilter::doRegisterHandlers(OdsGenerator &) -{ -} +void NumbersImportFilter::doRegisterHandlers(OdsGenerator&) {} // XServiceInfo OUString SAL_CALL NumbersImportFilter::getImplementationName() @@ -50,25 +50,23 @@ OUString SAL_CALL NumbersImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Calc.NumbersImportFilter"); } -sal_Bool SAL_CALL NumbersImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL NumbersImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL NumbersImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL NumbersImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Calc_NumbersImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new NumbersImportFilter(context)); } diff --git a/writerperfect/source/calc/NumbersImportFilter.hxx b/writerperfect/source/calc/NumbersImportFilter.hxx index 367f6f8076c8..ccb28f7e0492 100644 --- a/writerperfect/source/calc/NumbersImportFilter.hxx +++ b/writerperfect/source/calc/NumbersImportFilter.hxx @@ -22,18 +22,21 @@ class NumbersImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: - explicit NumbersImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} + explicit NumbersImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdsGenerator>(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; + 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, OdsGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdsGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx index 38a7dd062163..913636e31b02 100644 --- a/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx +++ b/writerperfect/source/calc/StarOfficeCalcImportFilter.cxx @@ -14,55 +14,64 @@ #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::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +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) +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 &) +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) +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) + 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; + case STOFFDocument::STOFF_K_DATABASE: + case STOFFDocument::STOFF_K_SPREADSHEET: + rTypeName = "StarOffice_Spreadsheet"; + break; + default: + break; } } return !rTypeName.isEmpty(); } -void StarOfficeCalcImportFilter::doRegisterHandlers(OdsGenerator &rGenerator) +void StarOfficeCalcImportFilter::doRegisterHandlers(OdsGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", + &handleEmbeddedSTOFFSpreadsheetObject); } // XServiceInfo @@ -71,21 +80,20 @@ OUString SAL_CALL StarOfficeCalcImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Calc.StarOfficeCalcImportFilter"); } -sal_Bool SAL_CALL StarOfficeCalcImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL StarOfficeCalcImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL StarOfficeCalcImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL StarOfficeCalcImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Calc_StarOfficeCalcImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new StarOfficeCalcImportFilter(context)); } diff --git a/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx b/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx index b395618581de..d288f91f6b44 100644 --- a/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx +++ b/writerperfect/source/calc/StarOfficeCalcImportFilter.hxx @@ -23,18 +23,22 @@ class StarOfficeCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: - explicit StarOfficeCalcImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} + explicit StarOfficeCalcImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdsGenerator>(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; + 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, OdsGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdsGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/common/DirectoryStream.cxx b/writerperfect/source/common/DirectoryStream.cxx index cc186cfaab0b..eeb449db0e9a 100644 --- a/writerperfect/source/common/DirectoryStream.cxx +++ b/writerperfect/source/common/DirectoryStream.cxx @@ -49,22 +49,22 @@ namespace uno = com::sun::star::uno; namespace writerperfect { - namespace { - -uno::Reference<io::XInputStream> findStream(ucbhelper::Content &rContent, const rtl::OUString &rName) +uno::Reference<io::XInputStream> findStream(ucbhelper::Content& rContent, + const rtl::OUString& rName) { uno::Reference<io::XInputStream> xInputStream; - uno::Sequence<OUString> lPropNames { "Title" }; + uno::Sequence<OUString> lPropNames{ "Title" }; try { const uno::Reference<sdbc::XResultSet> xResultSet( rContent.createCursor(lPropNames, ucbhelper::INCLUDE_DOCUMENTS_ONLY)); if (xResultSet->first()) { - const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY_THROW); + const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, + uno::UNO_QUERY_THROW); const uno::Reference<sdbc::XRow> xRow(xResultSet, uno::UNO_QUERY_THROW); do { @@ -72,57 +72,56 @@ uno::Reference<io::XInputStream> findStream(ucbhelper::Content &rContent, const if (aTitle == rName) { const uno::Reference<ucb::XContent> xSubContent(xContentAccess->queryContent()); - ucbhelper::Content aSubContent(xSubContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); + ucbhelper::Content aSubContent(xSubContent, + uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext()); xInputStream = aSubContent.openStream(); break; } - } - while (xResultSet->next()); + } while (xResultSet->next()); } } - catch (const uno::RuntimeException &) + catch (const uno::RuntimeException&) { // ignore } - catch (const uno::Exception &) + catch (const uno::Exception&) { // ignore } return xInputStream; } - } struct DirectoryStream::Impl { - explicit Impl(const uno::Reference<ucb::XContent> &rxContent); + explicit Impl(const uno::Reference<ucb::XContent>& rxContent); uno::Reference<ucb::XContent> xContent; }; -DirectoryStream::Impl::Impl(const uno::Reference<ucb::XContent> &rxContent) +DirectoryStream::Impl::Impl(const uno::Reference<ucb::XContent>& rxContent) : xContent(rxContent) { } -DirectoryStream::DirectoryStream(const css::uno::Reference<css::ucb::XContent> &xContent) +DirectoryStream::DirectoryStream(const css::uno::Reference<css::ucb::XContent>& xContent) : m_pImpl(isDirectory(xContent) ? new Impl(xContent) : nullptr) { } -DirectoryStream::~DirectoryStream() -{ -} +DirectoryStream::~DirectoryStream() {} -bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent> &xContent) +bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent>& xContent) { try { if (!xContent.is()) return false; - ucbhelper::Content aContent(xContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); + ucbhelper::Content aContent(xContent, uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext()); return aContent.isFolder(); } catch (...) @@ -131,7 +130,8 @@ bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent> } } -std::unique_ptr<DirectoryStream> DirectoryStream::createForParent(const css::uno::Reference<css::ucb::XContent> &xContent) +std::unique_ptr<DirectoryStream> +DirectoryStream::createForParent(const css::uno::Reference<css::ucb::XContent>& xContent) { try { @@ -167,10 +167,7 @@ const css::uno::Reference<css::ucb::XContent> DirectoryStream::getContent() cons return m_pImpl->xContent; } -bool DirectoryStream::isStructured() -{ - return m_pImpl != nullptr; -} +bool DirectoryStream::isStructured() { return m_pImpl != nullptr; } unsigned DirectoryStream::subStreamCount() { @@ -178,58 +175,50 @@ unsigned DirectoryStream::subStreamCount() return 0; } -const char *DirectoryStream::subStreamName(unsigned /* id */) +const char* DirectoryStream::subStreamName(unsigned /* id */) { // TODO: implement me return nullptr; } -bool DirectoryStream::existsSubStream(const char * /* name */) +bool DirectoryStream::existsSubStream(const char* /* name */) { // TODO: implement me return false; } -librevenge::RVNGInputStream *DirectoryStream::getSubStreamByName(const char *const pName) +librevenge::RVNGInputStream* DirectoryStream::getSubStreamByName(const char* const pName) { if (!m_pImpl) return nullptr; - ucbhelper::Content aContent(m_pImpl->xContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); - const uno::Reference<io::XInputStream> xInputStream(findStream(aContent, rtl::OUString::createFromAscii(pName))); + ucbhelper::Content aContent(m_pImpl->xContent, uno::Reference<ucb::XCommandEnvironment>(), + comphelper::getProcessComponentContext()); + const uno::Reference<io::XInputStream> xInputStream( + findStream(aContent, rtl::OUString::createFromAscii(pName))); if (xInputStream.is()) return new WPXSvInputStream(xInputStream); return nullptr; } -librevenge::RVNGInputStream *DirectoryStream::getSubStreamById(unsigned /* id */) +librevenge::RVNGInputStream* DirectoryStream::getSubStreamById(unsigned /* id */) { // TODO: implement me return nullptr; } -const unsigned char *DirectoryStream::read(unsigned long, unsigned long &nNumBytesRead) +const unsigned char* DirectoryStream::read(unsigned long, unsigned long& nNumBytesRead) { nNumBytesRead = 0; return nullptr; } -int DirectoryStream::seek(long, librevenge::RVNG_SEEK_TYPE) -{ - return -1; -} - -long DirectoryStream::tell() -{ - return 0; -} +int DirectoryStream::seek(long, librevenge::RVNG_SEEK_TYPE) { return -1; } -bool DirectoryStream::isEnd() -{ - return true; -} +long DirectoryStream::tell() { return 0; } +bool DirectoryStream::isEnd() { return true; } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx index 43de86bfc879..aa171ba8a199 100644 --- a/writerperfect/source/common/DocumentHandler.cxx +++ b/writerperfect/source/common/DocumentHandler.cxx @@ -20,81 +20,81 @@ namespace writerperfect { - -static const unsigned char librvng_utf8_skip_data[256] = -{ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1 -}; - -#define librvng_utf8_next_char(p) ((p) + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const *>(p)]) - -static void unescapeXML(const char *s, const unsigned long sz, librevenge::RVNGString &res) +static const unsigned char librvng_utf8_skip_data[256] + = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 }; + +#define librvng_utf8_next_char(p) \ + ((p) + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const*>(p)]) + +static void unescapeXML(const char* s, const unsigned long sz, librevenge::RVNGString& res) { - const char *p = s; - const char *const end = p + sz; + const char* p = s; + const char* const end = p + sz; while (p != end) { - const char *const next = librvng_utf8_next_char(p); + const char* const next = librvng_utf8_next_char(p); if (next > end) { // oops, the string is invalid break; } - if (p+4 <= end && p+1==next && *p=='&') + if (p + 4 <= end && p + 1 == next && *p == '&') { // look for & , < , > , ' , " - bool escapedChar=false; - switch (*(p+1)) + bool escapedChar = false; + switch (*(p + 1)) { - case 'a': - if (p+5 <= end && strncmp(p,"&",5)==0) - { - res.append('&'); - p+=5; - escapedChar=true; - } - else if (p+6 <= end && strncmp(p,"'",6)==0) - { - res.append('\''); - p+=6; - escapedChar=true; - } - break; - case 'g': - if (strncmp(p,">",4)==0) - { - res.append('>'); - p+=4; - escapedChar=true; - } - break; - case 'l': - if (strncmp(p,"<",4)==0) - { - res.append('<'); - p+=4; - escapedChar=true; - } - break; - case 'q': - if (p+6 <= end && strncmp(p,""",6)==0) - { - res.append('"'); - p+=6; - escapedChar=true; - } - break; - default: - break; + case 'a': + if (p + 5 <= end && strncmp(p, "&", 5) == 0) + { + res.append('&'); + p += 5; + escapedChar = true; + } + else if (p + 6 <= end && strncmp(p, "'", 6) == 0) + { + res.append('\''); + p += 6; + escapedChar = true; + } + break; + case 'g': + if (strncmp(p, ">", 4) == 0) + { + res.append('>'); + p += 4; + escapedChar = true; + } + break; + case 'l': + if (strncmp(p, "<", 4) == 0) + { + res.append('<'); + p += 4; + escapedChar = true; + } + break; + case 'q': + if (p + 6 <= end && strncmp(p, """, 6) == 0) + { + res.append('"'); + p += 6; + escapedChar = true; + } + break; + default: + break; } - if (escapedChar) continue; + if (escapedChar) + continue; } while (p != next) @@ -110,52 +110,51 @@ using com::sun::star::uno::Reference; using com::sun::star::xml::sax::XAttributeList; using com::sun::star::xml::sax::XDocumentHandler; -DocumentHandler::DocumentHandler(Reference < XDocumentHandler > const &xHandler) : - mxHandler(xHandler) +DocumentHandler::DocumentHandler(Reference<XDocumentHandler> const& xHandler) + : mxHandler(xHandler) { - if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport *>(mxHandler.get())) + if (SvXMLImport* pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get())) mxHandler.set(new SvXMLLegacyToFastDocHandler(pFastHandler)); } -void DocumentHandler::startDocument() -{ - mxHandler->startDocument(); -} +void DocumentHandler::startDocument() { mxHandler->startDocument(); } -void DocumentHandler::endDocument() -{ - mxHandler->endDocument(); -} +void DocumentHandler::endDocument() { mxHandler->endDocument(); } -void DocumentHandler::startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList) +void DocumentHandler::startElement(const char* psName, + const librevenge::RVNGPropertyList& xPropList) { - SvXMLAttributeList *pAttrList = new SvXMLAttributeList(); - Reference < XAttributeList > xAttrList(pAttrList); + SvXMLAttributeList* pAttrList = new SvXMLAttributeList(); + Reference<XAttributeList> xAttrList(pAttrList); librevenge::RVNGPropertyList::Iter i(xPropList); for (i.rewind(); i.next();) { // filter out librevenge elements if (strncmp(i.key(), "librevenge", 10) != 0) { - size_t keyLength=strlen(i.key()); - OUString sName(i.key(), keyLength, RTL_TEXTENCODING_UTF8); - OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), RTL_TEXTENCODING_UTF8); + size_t keyLength = strlen(i.key()); + OUString sName(i.key(), keyLength, RTL_TEXTENCODING_UTF8); + OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), + RTL_TEXTENCODING_UTF8); // libodfgen xml-encodes some attribute's value, so check if the value is encoded or not - for (int j=0; j<9; ++j) + for (int j = 0; j < 9; ++j) { // list of the encoded attributes followed by their lengths - static char const *listEncoded[9]= - { - "draw:name", "svg:font-family", "style:condition", "style:num-prefix", "style:num-suffix", - "table:formula", "text:bullet-char", "text:label", "xlink:href" - }; - static size_t const listEncodedLength[9]= {9,15,15,16,16,13,16,10,10}; - if (keyLength==listEncodedLength[j] && strncmp(i.key(), listEncoded[j], keyLength)==0) + static char const* listEncoded[9] + = { "draw:name", "svg:font-family", "style:condition", + "style:num-prefix", "style:num-suffix", "table:formula", + "text:bullet-char", "text:label", "xlink:href" }; + static size_t const listEncodedLength[9] = { 9, 15, 15, 16, 16, 13, 16, 10, 10 }; + if (keyLength == listEncodedLength[j] + && strncmp(i.key(), listEncoded[j], keyLength) == 0) { librevenge::RVNGString decodedValue(""); - unescapeXML(i()->getStr().cstr(), static_cast<unsigned long>(strlen(i()->getStr().cstr())), decodedValue); - sValue=OUString(decodedValue.cstr(), strlen(decodedValue.cstr()), RTL_TEXTENCODING_UTF8); + unescapeXML(i()->getStr().cstr(), + static_cast<unsigned long>(strlen(i()->getStr().cstr())), + decodedValue); + sValue = OUString(decodedValue.cstr(), strlen(decodedValue.cstr()), + RTL_TEXTENCODING_UTF8); break; } } @@ -167,18 +166,17 @@ void DocumentHandler::startElement(const char *psName, const librevenge::RVNGPro mxHandler->startElement(sElementName, xAttrList); } -void DocumentHandler::endElement(const char *psName) +void DocumentHandler::endElement(const char* psName) { OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8); mxHandler->endElement(sElementName); } -void DocumentHandler::characters(const librevenge::RVNGString &sCharacters) +void DocumentHandler::characters(const librevenge::RVNGString& sCharacters) { OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8); mxHandler->characters(sCharU16); } - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/common/WPFTEncodingDialog.cxx b/writerperfect/source/common/WPFTEncodingDialog.cxx index d025774d2e0d..dbd5356e5030 100644 --- a/writerperfect/source/common/WPFTEncodingDialog.cxx +++ b/writerperfect/source/common/WPFTEncodingDialog.cxx @@ -26,96 +26,93 @@ namespace writerperfect { - namespace { - -std::pair<OUStringLiteral, OUStringLiteral> const s_encodings[] = -{ - {"MacArabic", "Arabic (Apple Macintosh)"}, - {"CP864", "Arabic (DOS/OS2-864)"}, - {"CP1006", "Arabic (IBM-1006)"}, - {"CP1256", "Arabic (Windows-1256)"}, - {"CP775", "Baltic (DOS/OS2-775)"}, - {"CP1257", "Baltic (Windows-1257)"}, - {"MacCeltic", "Celtic (Apple Macintosh)"}, - {"MacCyrillic", "Cyrillic (Apple Macintosh)"}, - {"CP855", "Cyrillic (DOS/OS2-855)"}, - {"CP866", "Cyrillic (DOS/OS2-866/Russian)"}, - {"CP1251", "Cyrillic (Windows-1251)"}, - {"MacCEurope", "Eastern Europe (Apple Macintosh)"}, - {"MacCroatian", "Eastern Europe (Apple Macintosh/Croatian)"}, - {"MacRomanian", "Eastern Europe (Apple Macintosh/Romanian)"}, - {"CP852", "Eastern Europe (DOS/OS2-852)"}, - {"CP1250", "Eastern Europe (Windows-1250/WinLatin 2)"}, - {"MacGreek", "Greek (Apple Macintosh)"}, - {"CP737", "Greek (DOS/OS2-737)"}, - {"CP869", "Greek (DOS/OS2-869/Greek-2)"}, - {"CP875", "Greek (DOS/OS2-875)"}, - {"CP1253", "Greek (Windows-1253)"}, - {"MacHebrew", "Hebrew (Apple Macintosh)"}, - {"CP424", "Hebrew (DOS/OS2-424)"}, - {"CP856", "Hebrew (DOS/OS2-856)"}, - {"CP862", "Hebrew (DOS/OS2-862)"}, - {"CP1255", "Hebrew (Windows-1255)"}, - {"CP500", "International (DOS/OS2-500)"}, - {"CP932", "Japanese (Windows-932)"}, - {"MacThai", "Thai (Apple Macintosh)"}, - {"CP874", "Thai (DOS/OS2-874)"}, - {"CP950", "Traditional Chinese (Windows-950)"}, - {"MacTurkish", "Turkish (Apple Macintosh)"}, - {"CP857", "Turkish (DOS/OS2-857)"}, - {"CP1026", "Turkish (DOS/OS2-1026)"}, - {"CP1254", "Turkish (Windows-1254)"}, - {"CP1258", "Vietnamese (Windows-1258)"}, - {"MacRoman", "Western Europe (Apple Macintosh)"}, - {"MacIceland", "Western Europe (Apple Macintosh/Icelandic)"}, - {"CP037", "Western Europe (DOS/OS2-037/US-Canada)"}, - {"CP437", "Western Europe (DOS/OS2-437/US)"}, - {"CP850", "Western Europe (DOS/OS2-850)"}, - {"CP860", "Western Europe (DOS/OS2-860/Portuguese)"}, - {"CP861", "Western Europe (DOS/OS2-861/Icelandic)"}, - {"CP863", "Western Europe (DOS/OS2-863/French)"}, - {"CP865", "Western Europe (DOS/OS2-865/Nordic)"}, - {"CP1252", "Western Europe (Windows-1252/WinLatin 1)"} -}; +std::pair<OUStringLiteral, OUStringLiteral> const s_encodings[] + = { { "MacArabic", "Arabic (Apple Macintosh)" }, + { "CP864", "Arabic (DOS/OS2-864)" }, + { "CP1006", "Arabic (IBM-1006)" }, + { "CP1256", "Arabic (Windows-1256)" }, + { "CP775", "Baltic (DOS/OS2-775)" }, + { "CP1257", "Baltic (Windows-1257)" }, + { "MacCeltic", "Celtic (Apple Macintosh)" }, + { "MacCyrillic", "Cyrillic (Apple Macintosh)" }, + { "CP855", "Cyrillic (DOS/OS2-855)" }, + { "CP866", "Cyrillic (DOS/OS2-866/Russian)" }, + { "CP1251", "Cyrillic (Windows-1251)" }, + { "MacCEurope", "Eastern Europe (Apple Macintosh)" }, + { "MacCroatian", "Eastern Europe (Apple Macintosh/Croatian)" }, + { "MacRomanian", "Eastern Europe (Apple Macintosh/Romanian)" }, + { "CP852", "Eastern Europe (DOS/OS2-852)" }, + { "CP1250", "Eastern Europe (Windows-1250/WinLatin 2)" }, + { "MacGreek", "Greek (Apple Macintosh)" }, + { "CP737", "Greek (DOS/OS2-737)" }, + { "CP869", "Greek (DOS/OS2-869/Greek-2)" }, + { "CP875", "Greek (DOS/OS2-875)" }, + { "CP1253", "Greek (Windows-1253)" }, + { "MacHebrew", "Hebrew (Apple Macintosh)" }, + { "CP424", "Hebrew (DOS/OS2-424)" }, + { "CP856", "Hebrew (DOS/OS2-856)" }, + { "CP862", "Hebrew (DOS/OS2-862)" }, + { "CP1255", "Hebrew (Windows-1255)" }, + { "CP500", "International (DOS/OS2-500)" }, + { "CP932", "Japanese (Windows-932)" }, + { "MacThai", "Thai (Apple Macintosh)" }, + { "CP874", "Thai (DOS/OS2-874)" }, + { "CP950", "Traditional Chinese (Windows-950)" }, + { "MacTurkish", "Turkish (Apple Macintosh)" }, + { "CP857", "Turkish (DOS/OS2-857)" }, + { "CP1026", "Turkish (DOS/OS2-1026)" }, + { "CP1254", "Turkish (Windows-1254)" }, + { "CP1258", "Vietnamese (Windows-1258)" }, + { "MacRoman", "Western Europe (Apple Macintosh)" }, + { "MacIceland", "Western Europe (Apple Macintosh/Icelandic)" }, + { "CP037", "Western Europe (DOS/OS2-037/US-Canada)" }, + { "CP437", "Western Europe (DOS/OS2-437/US)" }, + { "CP850", "Western Europe (DOS/OS2-850)" }, + { "CP860", "Western Europe (DOS/OS2-860/Portuguese)" }, + { "CP861", "Western Europe (DOS/OS2-861/Icelandic)" }, + { "CP863", "Western Europe (DOS/OS2-863/French)" }, + { "CP865", "Western Europe (DOS/OS2-865/Nordic)" }, + { "CP1252", "Western Europe (Windows-1252/WinLatin 1)" } }; std::size_t const numEncodings = SAL_N_ELEMENTS(s_encodings); -void insertEncodings(ListBox *box) +void insertEncodings(ListBox* box) { - for (std::size_t i=0; i<numEncodings; ++i) + for (std::size_t i = 0; i < numEncodings; ++i) { - sal_IntPtr nAt=box->InsertEntry(s_encodings[i].second); - box->SetEntryData( - nAt, reinterpret_cast<void *>(static_cast<sal_uIntPtr>(i))); + sal_IntPtr nAt = box->InsertEntry(s_encodings[i].second); + box->SetEntryData(nAt, reinterpret_cast<void*>(static_cast<sal_uIntPtr>(i))); } } -void selectEncoding(ListBox *box, const OUString &encoding) +void selectEncoding(ListBox* box, const OUString& encoding) { - for (std::size_t i=0; i<numEncodings; ++i) + for (std::size_t i = 0; i < numEncodings; ++i) { - if (encoding!=s_encodings[i].first) continue; + if (encoding != s_encodings[i].first) + continue; box->SelectEntryPos(i); return; } } -OUString getEncoding(ListBox const *box) +OUString getEncoding(ListBox const* box) { sal_uIntPtr pos = reinterpret_cast<sal_uIntPtr>(box->GetSelectedEntryData()); - if (pos>=numEncodings) + if (pos >= numEncodings) return OUString(); return s_encodings[pos].first; } - } -WPFTEncodingDialog::WPFTEncodingDialog( - const OUString &title, const OUString &encoding) - : ModalDialog(nullptr, "WPFTEncodingDialog", "writerperfect/ui/wpftencodingdialog.ui"), - m_pLbCharset(), m_pBtnOk(), m_pBtnCancel(), m_userHasCancelled(false) +WPFTEncodingDialog::WPFTEncodingDialog(const OUString& title, const OUString& encoding) + : ModalDialog(nullptr, "WPFTEncodingDialog", "writerperfect/ui/wpftencodingdialog.ui") + , m_pLbCharset() + , m_pBtnOk() + , m_pBtnCancel() + , m_userHasCancelled(false) { get(m_pLbCharset, "comboboxtext"); get(m_pBtnOk, "ok"); @@ -133,23 +130,17 @@ WPFTEncodingDialog::WPFTEncodingDialog( SetText(title); } -WPFTEncodingDialog::~WPFTEncodingDialog() -{ - disposeOnce(); -} +WPFTEncodingDialog::~WPFTEncodingDialog() { disposeOnce(); } -OUString WPFTEncodingDialog::GetEncoding() const -{ - return getEncoding(m_pLbCharset); -} +OUString WPFTEncodingDialog::GetEncoding() const { return getEncoding(m_pLbCharset); } -IMPL_LINK_NOARG(WPFTEncodingDialog, CancelHdl, Button *, void) +IMPL_LINK_NOARG(WPFTEncodingDialog, CancelHdl, Button*, void) { - m_userHasCancelled=true; + m_userHasCancelled = true; Close(); } -IMPL_LINK(WPFTEncodingDialog, DoubleClickHdl, ListBox &, rLb, void) +IMPL_LINK(WPFTEncodingDialog, DoubleClickHdl, ListBox&, rLb, void) { if (&rLb == m_pLbCharset) { @@ -164,7 +155,6 @@ void WPFTEncodingDialog::dispose() m_pBtnCancel.disposeAndClear(); ModalDialog::dispose(); } - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx index 971280b8e25b..2dfee8a44799 100644 --- a/writerperfect/source/common/WPXSvInputStream.cxx +++ b/writerperfect/source/common/WPXSvInputStream.cxx @@ -30,7 +30,6 @@ namespace writerperfect { - using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; @@ -39,21 +38,20 @@ namespace packages = com::sun::star::packages; namespace { - class PositionHolder { public: - explicit PositionHolder(const Reference<XSeekable> &rxSeekable); + 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; const sal_uInt64 mnPosition; }; -PositionHolder::PositionHolder(const Reference<XSeekable> &rxSeekable) +PositionHolder::PositionHolder(const Reference<XSeekable>& rxSeekable) : mxSeekable(rxSeekable) , mnPosition(rxSeekable->getPosition()) { @@ -65,7 +63,9 @@ PositionHolder::~PositionHolder() { mxSeekable->seek(mnPosition); } - catch (...) {} + catch (...) + { + } } } // anonymous namespace @@ -82,8 +82,7 @@ typedef struct namespace { - -rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString &rPath) +rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString& rPath) { // accept paths which begin by '/' // TODO: maybe this should to a full normalization @@ -91,13 +90,11 @@ rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString &rPath) return rPath.copy(1); return rPath; } - } namespace { - -const rtl::OUString concatPath(const rtl::OUString &lhs, const rtl::OUString &rhs) +const rtl::OUString concatPath(const rtl::OUString& lhs, const rtl::OUString& rhs) { if (lhs.isEmpty()) return rhs; @@ -106,7 +103,7 @@ const rtl::OUString concatPath(const rtl::OUString &lhs, const rtl::OUString &rh struct OLEStreamData { - OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName); + OLEStreamData(const rtl::OString& rName, const rtl::OString& rvngName); SotStorageStreamRefWrapper stream; @@ -147,25 +144,25 @@ struct OLEStorageImpl { OLEStorageImpl(); - void initialize(SvStream *pStream); + void initialize(SvStream* pStream); - tools::SvRef<SotStorageStream> getStream(const rtl::OUString &rPath); - tools::SvRef<SotStorageStream> const &getStream(std::size_t nId); + tools::SvRef<SotStorageStream> getStream(const rtl::OUString& rPath); + tools::SvRef<SotStorageStream> const& getStream(std::size_t nId); private: - void traverse(const tools::SvRef<SotStorage> &rStorage, const rtl::OUString &rPath); + void traverse(const tools::SvRef<SotStorage>& rStorage, const rtl::OUString& rPath); - tools::SvRef<SotStorageStream> createStream(const rtl::OUString &rPath); + tools::SvRef<SotStorageStream> createStream(const rtl::OUString& rPath); public: SotStorageRefWrapper mxRootStorage; //< root storage of the OLE2 OLEStorageMap_t maStorageMap; //< map of all sub storages by name - ::std::vector< OLEStreamData > maStreams; //< list of streams and their names + ::std::vector<OLEStreamData> maStreams; //< list of streams and their names NameMap_t maNameMap; //< map of stream names to indexes (into @c maStreams) bool mbInitialized; }; -OLEStreamData::OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName) +OLEStreamData::OLEStreamData(const rtl::OString& rName, const rtl::OString& rvngName) : stream() , name(rName) , RVNGname(rvngName) @@ -181,7 +178,7 @@ OLEStorageImpl::OLEStorageImpl() { } -void OLEStorageImpl::initialize(SvStream *const pStream) +void OLEStorageImpl::initialize(SvStream* const pStream) { if (!pStream) return; @@ -193,7 +190,7 @@ void OLEStorageImpl::initialize(SvStream *const pStream) mbInitialized = true; } -tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString &rPath) +tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString& rPath) { const rtl::OUString aPath(lcl_normalizeSubStreamPath(rPath)); NameMap_t::iterator aIt = maNameMap.find(aPath); @@ -205,20 +202,22 @@ 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(rtl::OStringToOUString(maStreams[aIt->second].name, RTL_TEXTENCODING_UTF8)); + maStreams[aIt->second].stream.ref = createStream( + rtl::OStringToOUString(maStreams[aIt->second].name, RTL_TEXTENCODING_UTF8)); return maStreams[aIt->second].stream.ref; } -tools::SvRef<SotStorageStream> const &OLEStorageImpl::getStream(const std::size_t nId) +tools::SvRef<SotStorageStream> const& OLEStorageImpl::getStream(const std::size_t nId) { if (!maStreams[nId].stream.ref.is()) - maStreams[nId].stream.ref = createStream(rtl::OStringToOUString(maStreams[nId].name, RTL_TEXTENCODING_UTF8)); + maStreams[nId].stream.ref + = createStream(rtl::OStringToOUString(maStreams[nId].name, RTL_TEXTENCODING_UTF8)); return maStreams[nId].stream.ref; } -void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rtl::OUString &rPath) +void OLEStorageImpl::traverse(const tools::SvRef<SotStorage>& rStorage, const rtl::OUString& rPath) { SvStorageInfoList infos; @@ -228,12 +227,13 @@ void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rt { if (aIt->IsStream()) { - rtl::OUString baseName=aIt->GetName(), rvngName=baseName; + 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.emplace_back(rtl::OUStringToOString(concatPath(rPath, baseName), RTL_TEXTENCODING_UTF8), - rtl::OUStringToOString(concatPath(rPath, rvngName), RTL_TEXTENCODING_UTF8)); + if (!rvngName.isEmpty() && rvngName.toChar() < 32) + rvngName = rvngName.copy(1); + maStreams.emplace_back( + 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()) @@ -248,12 +248,13 @@ void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rt } else { - SAL_WARN("writerperfect", "OLEStorageImpl::traverse: invalid storage entry, neither stream nor file"); + SAL_WARN("writerperfect", + "OLEStorageImpl::traverse: invalid storage entry, neither stream nor file"); } } } -tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString &rPath) +tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString& rPath) { const sal_Int32 nDelim = rPath.lastIndexOf(u'/'); @@ -270,15 +271,13 @@ tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString return aIt->second.ref->OpenSotStream(aName, StreamMode::STD_READ); } - } namespace { - struct ZipStreamData { - explicit ZipStreamData(const rtl::OString &rName); + explicit ZipStreamData(const rtl::OString& rName); Reference<XInputStream> xStream; @@ -297,7 +296,7 @@ struct ZipStreamData */ struct ZipStorageImpl { - explicit ZipStorageImpl(const Reference<container::XNameAccess> &rxContainer); + explicit ZipStorageImpl(const Reference<container::XNameAccess>& rxContainer); /** Initialize for access. * @@ -307,28 +306,28 @@ struct ZipStorageImpl */ void initialize(); - Reference<XInputStream> getStream(const rtl::OUString &rPath); - Reference<XInputStream> const &getStream(std::size_t nId); + Reference<XInputStream> getStream(const rtl::OUString& rPath); + Reference<XInputStream> const& getStream(std::size_t nId); private: - void traverse(const Reference<container::XNameAccess> &rxEnum); + void traverse(const Reference<container::XNameAccess>& rxEnum); - Reference<XInputStream> createStream(const rtl::OUString &rPath); + Reference<XInputStream> createStream(const rtl::OUString& rPath); public: Reference<container::XNameAccess> mxContainer; //< root of the Zip - ::std::vector< ZipStreamData > maStreams; //< list of streams and their names + ::std::vector<ZipStreamData> maStreams; //< list of streams and their names NameMap_t maNameMap; //< map of stream names to indexes (into @c maStreams) bool mbInitialized; }; -ZipStreamData::ZipStreamData(const rtl::OString &rName) +ZipStreamData::ZipStreamData(const rtl::OString& rName) : xStream() , aName(rName) { } -ZipStorageImpl::ZipStorageImpl(const Reference<container::XNameAccess> &rxContainer) +ZipStorageImpl::ZipStorageImpl(const Reference<container::XNameAccess>& rxContainer) : mxContainer(rxContainer) , maStreams() , maNameMap() @@ -344,7 +343,7 @@ void ZipStorageImpl::initialize() mbInitialized = true; } -Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString &rPath) +Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString& rPath) { const rtl::OUString aPath(lcl_normalizeSubStreamPath(rPath)); NameMap_t::iterator aIt = maNameMap.find(aPath); @@ -361,15 +360,16 @@ Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString &rPath) return maStreams[aIt->second].xStream; } -Reference<XInputStream> const &ZipStorageImpl::getStream(const std::size_t nId) +Reference<XInputStream> const& ZipStorageImpl::getStream(const std::size_t nId) { if (!maStreams[nId].xStream.is()) - maStreams[nId].xStream = createStream(rtl::OStringToOUString(maStreams[nId].aName, RTL_TEXTENCODING_UTF8)); + maStreams[nId].xStream + = createStream(rtl::OStringToOUString(maStreams[nId].aName, RTL_TEXTENCODING_UTF8)); return maStreams[nId].xStream; } -void ZipStorageImpl::traverse(const Reference<container::XNameAccess> &rxContainer) +void ZipStorageImpl::traverse(const Reference<container::XNameAccess>& rxContainer) { const Sequence<rtl::OUString> lNames = rxContainer->getElementNames(); @@ -385,7 +385,7 @@ void ZipStorageImpl::traverse(const Reference<container::XNameAccess> &rxContain } } -Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString &rPath) +Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString& rPath) { Reference<XInputStream> xStream; @@ -397,32 +397,31 @@ Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString &rPath) if (xSeekable.is()) xStream = xInputStream; else - xStream.set(new comphelper::OSeekableInputWrapper(xInputStream, comphelper::getProcessComponentContext())); + xStream.set(new comphelper::OSeekableInputWrapper( + xInputStream, comphelper::getProcessComponentContext())); } - catch (const Exception &) + catch (const Exception&) { // nothing needed } return xStream; } - } class WPXSvInputStreamImpl { public: - explicit WPXSvInputStreamImpl(css::uno::Reference< - css::io::XInputStream > const &xStream); + explicit WPXSvInputStreamImpl(css::uno::Reference<css::io::XInputStream> const& xStream); bool isStructured(); unsigned subStreamCount(); - const char *subStreamName(unsigned id); - bool existsSubStream(const char *name); - librevenge::RVNGInputStream *getSubStreamByName(const char *name); - librevenge::RVNGInputStream *getSubStreamById(unsigned id); + const char* subStreamName(unsigned id); + bool existsSubStream(const char* name); + librevenge::RVNGInputStream* getSubStreamByName(const char* name); + librevenge::RVNGInputStream* getSubStreamById(unsigned id); - const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); + const unsigned char* read(unsigned long numBytes, unsigned long& numBytesRead); int seek(long offset); long tell(); bool isEnd(); @@ -436,36 +435,38 @@ private: bool isZip(); void ensureZipIsInitialized(); - static librevenge::RVNGInputStream *createWPXStream(const tools::SvRef<SotStorageStream> &rxStorage); - static librevenge::RVNGInputStream *createWPXStream(const Reference<XInputStream> &rxStream); + static librevenge::RVNGInputStream* + createWPXStream(const tools::SvRef<SotStorageStream>& rxStorage); + static librevenge::RVNGInputStream* createWPXStream(const Reference<XInputStream>& rxStream); private: - css::uno::Reference< css::io::XInputStream > mxStream; - css::uno::Reference< css::io::XSeekable > mxSeekable; - css::uno::Sequence< sal_Int8 > maData; - std::unique_ptr< OLEStorageImpl > mpOLEStorage; - std::unique_ptr< ZipStorageImpl > mpZipStorage; + css::uno::Reference<css::io::XInputStream> mxStream; + css::uno::Reference<css::io::XSeekable> mxSeekable; + css::uno::Sequence<sal_Int8> maData; + std::unique_ptr<OLEStorageImpl> mpOLEStorage; + std::unique_ptr<ZipStorageImpl> mpZipStorage; bool mbCheckedOLE; bool mbCheckedZip; + public: sal_Int64 mnLength; - const unsigned char *mpReadBuffer; + const unsigned char* mpReadBuffer; unsigned long mnReadBufferLength; unsigned long mnReadBufferPos; }; -WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const &xStream) : - mxStream(xStream), - mxSeekable(xStream, UNO_QUERY), - maData(0), - mpOLEStorage(nullptr), - mpZipStorage(nullptr), - mbCheckedOLE(false), - mbCheckedZip(false), - mnLength(0), - mpReadBuffer(nullptr), - mnReadBufferLength(0), - mnReadBufferPos(0) +WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference<XInputStream> const& xStream) + : mxStream(xStream) + , mxSeekable(xStream, UNO_QUERY) + , maData(0) + , mpOLEStorage(nullptr) + , mpZipStorage(nullptr) + , mbCheckedOLE(false) + , mbCheckedZip(false) + , mnLength(0) + , mpReadBuffer(nullptr) + , mnReadBufferLength(0) + , mnReadBufferPos(0) { if (!xStream.is() || !mxStream.is()) mnLength = 0; @@ -490,7 +491,7 @@ WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const &xStr } } -const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long &numBytesRead) +const unsigned char* WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long& numBytesRead) { numBytesRead = 0; @@ -501,7 +502,7 @@ const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned if (numBytesRead == 0) return nullptr; - return reinterpret_cast<const unsigned char *>(maData.getConstArray()); + return reinterpret_cast<const unsigned char*>(maData.getConstArray()); } long WPXSvInputStreamImpl::tell() @@ -588,7 +589,7 @@ unsigned WPXSvInputStreamImpl::subStreamCount() return 0; } -const char *WPXSvInputStreamImpl::subStreamName(const unsigned id) +const char* WPXSvInputStreamImpl::subStreamName(const unsigned id) { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return nullptr; @@ -621,7 +622,7 @@ const char *WPXSvInputStreamImpl::subStreamName(const unsigned id) return nullptr; } -bool WPXSvInputStreamImpl::existsSubStream(const char *const name) +bool WPXSvInputStreamImpl::existsSubStream(const char* const name) { if (!name) return false; @@ -651,7 +652,7 @@ bool WPXSvInputStreamImpl::existsSubStream(const char *const name) return false; } -librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char *const name) +librevenge::RVNGInputStream* WPXSvInputStreamImpl::getSubStreamByName(const char* const name) { if (!name) return nullptr; @@ -680,7 +681,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char { return createWPXStream(mpZipStorage->getStream(aName)); } - catch (const Exception &) + catch (const Exception&) { // nothing needed } @@ -689,7 +690,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char return nullptr; } -librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamById(const unsigned id) +librevenge::RVNGInputStream* WPXSvInputStreamImpl::getSubStreamById(const unsigned id) { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return nullptr; @@ -720,7 +721,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamById(const unsign { return createWPXStream(mpZipStorage->getStream(id)); } - catch (const Exception &) + catch (const Exception&) { // nothing needed } @@ -739,17 +740,19 @@ void WPXSvInputStreamImpl::invalidateReadBuffer() } } -librevenge::RVNGInputStream *WPXSvInputStreamImpl::createWPXStream(const tools::SvRef<SotStorageStream> &rxStorage) +librevenge::RVNGInputStream* +WPXSvInputStreamImpl::createWPXStream(const tools::SvRef<SotStorageStream>& rxStorage) { if (rxStorage.is()) { - Reference < XInputStream > xContents(new utl::OSeekableInputStreamWrapper(rxStorage.get())); + Reference<XInputStream> xContents(new utl::OSeekableInputStreamWrapper(rxStorage.get())); return new WPXSvInputStream(xContents); } return nullptr; } -librevenge::RVNGInputStream *WPXSvInputStreamImpl::createWPXStream(const Reference<XInputStream> &rxStream) +librevenge::RVNGInputStream* +WPXSvInputStreamImpl::createWPXStream(const Reference<XInputStream>& rxStream) { if (rxStream.is()) return new WPXSvInputStream(rxStream); @@ -784,13 +787,15 @@ bool WPXSvInputStreamImpl::isZip() Sequence<Any> aArgs(1); aArgs[0] <<= mxStream; - const Reference<XComponentContext> xContext(comphelper::getProcessComponentContext(), UNO_QUERY_THROW); + const Reference<XComponentContext> xContext(comphelper::getProcessComponentContext(), + UNO_QUERY_THROW); const Reference<packages::zip::XZipFileAccess2> xZip( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.packages.zip.ZipFileAccess", aArgs, xContext), + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.packages.zip.ZipFileAccess", aArgs, xContext), UNO_QUERY_THROW); mpZipStorage.reset(new ZipStorageImpl(xZip)); } - catch (const Exception &) + catch (const Exception&) { // ignore } @@ -817,29 +822,28 @@ void WPXSvInputStreamImpl::ensureZipIsInitialized() mpZipStorage->initialize(); } -WPXSvInputStream::WPXSvInputStream(Reference< XInputStream > const &xStream) : - mpImpl(new WPXSvInputStreamImpl(xStream)) +WPXSvInputStream::WPXSvInputStream(Reference<XInputStream> const& xStream) + : mpImpl(new WPXSvInputStreamImpl(xStream)) { } -WPXSvInputStream::~WPXSvInputStream() -{ -} +WPXSvInputStream::~WPXSvInputStream() {} #define BUFFER_MAX 65536 -const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned long &numBytesRead) +const unsigned char* WPXSvInputStream::read(unsigned long numBytes, unsigned long& numBytesRead) { numBytesRead = 0; - if (numBytes == 0 || numBytes > std::numeric_limits<unsigned long>::max()/2) + if (numBytes == 0 || numBytes > std::numeric_limits<unsigned long>::max() / 2) return nullptr; if (mpImpl->mpReadBuffer) { - if ((mpImpl->mnReadBufferPos + numBytes > mpImpl->mnReadBufferPos) && (mpImpl->mnReadBufferPos + numBytes <= mpImpl->mnReadBufferLength)) + if ((mpImpl->mnReadBufferPos + numBytes > mpImpl->mnReadBufferPos) + && (mpImpl->mnReadBufferPos + numBytes <= mpImpl->mnReadBufferLength)) { - const unsigned char *pTmp = mpImpl->mpReadBuffer + mpImpl->mnReadBufferPos; + const unsigned char* pTmp = mpImpl->mpReadBuffer + mpImpl->mnReadBufferPos; mpImpl->mnReadBufferPos += numBytes; numBytesRead = numBytes; return pTmp; @@ -849,11 +853,12 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon } unsigned long curpos = static_cast<unsigned long>(mpImpl->tell()); - if (curpos == static_cast<unsigned long>(-1)) // returned ERROR + if (curpos == static_cast<unsigned long>(-1)) // returned ERROR return nullptr; - if ((curpos + numBytes < curpos) /*overflow*/ || - (curpos + numBytes >= static_cast<sal_uInt64>(mpImpl->mnLength))) /*reading more than available*/ + if ((curpos + numBytes < curpos) /*overflow*/ + || (curpos + numBytes + >= static_cast<sal_uInt64>(mpImpl->mnLength))) /*reading more than available*/ { numBytes = mpImpl->mnLength - curpos; } @@ -889,7 +894,8 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon long WPXSvInputStream::tell() { long retVal = mpImpl->tell(); - return retVal - static_cast<long>(mpImpl->mnReadBufferLength) + static_cast<long>(mpImpl->mnReadBufferPos); + return retVal - static_cast<long>(mpImpl->mnReadBufferLength) + + static_cast<long>(mpImpl->mnReadBufferPos); } int WPXSvInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) @@ -912,9 +918,12 @@ int WPXSvInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) retVal = -1; } - if (tmpOffset < mpImpl->tell() && static_cast<unsigned long>(tmpOffset) >= static_cast<unsigned long>(mpImpl->tell()) - mpImpl->mnReadBufferLength) + if (tmpOffset < mpImpl->tell() + && static_cast<unsigned long>(tmpOffset) + >= static_cast<unsigned long>(mpImpl->tell()) - mpImpl->mnReadBufferLength) { - mpImpl->mnReadBufferPos = static_cast<unsigned long>(tmpOffset + static_cast<long>(mpImpl->mnReadBufferLength) - mpImpl->tell()); + mpImpl->mnReadBufferPos = static_cast<unsigned long>( + tmpOffset + static_cast<long>(mpImpl->mnReadBufferLength) - mpImpl->tell()); return retVal; } @@ -942,30 +951,29 @@ unsigned WPXSvInputStream::subStreamCount() return mpImpl->subStreamCount(); } -const char *WPXSvInputStream::subStreamName(const unsigned id) +const char* WPXSvInputStream::subStreamName(const unsigned id) { mpImpl->invalidateReadBuffer(); return mpImpl->subStreamName(id); } -bool WPXSvInputStream::existsSubStream(const char *const name) +bool WPXSvInputStream::existsSubStream(const char* const name) { mpImpl->invalidateReadBuffer(); return mpImpl->existsSubStream(name); } -librevenge::RVNGInputStream *WPXSvInputStream::getSubStreamByName(const char *name) +librevenge::RVNGInputStream* WPXSvInputStream::getSubStreamByName(const char* name) { mpImpl->invalidateReadBuffer(); return mpImpl->getSubStreamByName(name); } -librevenge::RVNGInputStream *WPXSvInputStream::getSubStreamById(const unsigned id) +librevenge::RVNGInputStream* WPXSvInputStream::getSubStreamById(const unsigned id) { mpImpl->invalidateReadBuffer(); return mpImpl->getSubStreamById(id); } - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx index 362c56fa522b..e706ee089e41 100644 --- a/writerperfect/source/draw/CDRImportFilter.cxx +++ b/writerperfect/source/draw/CDRImportFilter.cxx @@ -24,12 +24,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool CDRImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool CDRImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libcdr::CDRDocument::parse(&rInput, &rGenerator); } -bool CDRImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool CDRImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libcdr::CDRDocument::isSupported(&rInput)) { @@ -46,25 +47,23 @@ OUString SAL_CALL CDRImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.CDRImportFilter"); } -sal_Bool SAL_CALL CDRImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL CDRImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL CDRImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL CDRImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_CDRImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new CDRImportFilter(context)); } diff --git a/writerperfect/source/draw/CDRImportFilter.hxx b/writerperfect/source/draw/CDRImportFilter.hxx index 2d31cc603e39..e2d35fc24bad 100644 --- a/writerperfect/source/draw/CDRImportFilter.hxx +++ b/writerperfect/source/draw/CDRImportFilter.hxx @@ -21,19 +21,20 @@ class CDRImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit CDRImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit CDRImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx index 3e7541863259..5b8ff653585d 100644 --- a/writerperfect/source/draw/CMXImportFilter.cxx +++ b/writerperfect/source/draw/CMXImportFilter.cxx @@ -24,12 +24,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool CMXImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool CMXImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libcdr::CMXDocument::parse(&rInput, &rGenerator); } -bool CMXImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool CMXImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libcdr::CMXDocument::isSupported(&rInput)) { @@ -46,25 +47,23 @@ OUString SAL_CALL CMXImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.CMXImportFilter"); } -sal_Bool SAL_CALL CMXImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL CMXImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL CMXImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL CMXImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); pArray[0] = "com.sun.star.document.ImportFilter"; pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_CMXImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new CMXImportFilter(context)); } diff --git a/writerperfect/source/draw/CMXImportFilter.hxx b/writerperfect/source/draw/CMXImportFilter.hxx index 17ac270d1e7e..cd35f1b2d45a 100644 --- a/writerperfect/source/draw/CMXImportFilter.hxx +++ b/writerperfect/source/draw/CMXImportFilter.hxx @@ -21,19 +21,20 @@ class CMXImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit CMXImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit CMXImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/FreehandImportFilter.cxx b/writerperfect/source/draw/FreehandImportFilter.cxx index e22844b5cbd4..44aa3b39a424 100644 --- a/writerperfect/source/draw/FreehandImportFilter.cxx +++ b/writerperfect/source/draw/FreehandImportFilter.cxx @@ -20,12 +20,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool FreehandImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool FreehandImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libfreehand::FreeHandDocument::parse(&rInput, &rGenerator); } -bool FreehandImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool FreehandImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libfreehand::FreeHandDocument::isSupported(&rInput)) { @@ -42,25 +43,23 @@ OUString SAL_CALL FreehandImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.FreehandImportFilter"); } -sal_Bool SAL_CALL FreehandImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL FreehandImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL FreehandImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL FreehandImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_FreehandImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new FreehandImportFilter(context)); } diff --git a/writerperfect/source/draw/FreehandImportFilter.hxx b/writerperfect/source/draw/FreehandImportFilter.hxx index 8493c9d3619a..0897e4a815d5 100644 --- a/writerperfect/source/draw/FreehandImportFilter.hxx +++ b/writerperfect/source/draw/FreehandImportFilter.hxx @@ -18,19 +18,20 @@ class FreehandImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit FreehandImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit FreehandImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx index 36c20f267c63..ce3967da5736 100644 --- a/writerperfect/source/draw/MSPUBImportFilter.cxx +++ b/writerperfect/source/draw/MSPUBImportFilter.cxx @@ -20,12 +20,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool MSPUBImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool MSPUBImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libmspub::MSPUBDocument::parse(&rInput, &rGenerator); } -bool MSPUBImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MSPUBImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libmspub::MSPUBDocument::isSupported(&rInput)) { @@ -42,25 +43,23 @@ OUString SAL_CALL MSPUBImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.MSPUBImportFilter"); } -sal_Bool SAL_CALL MSPUBImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MSPUBImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MSPUBImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MSPUBImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_MSPUBImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MSPUBImportFilter(context)); } diff --git a/writerperfect/source/draw/MSPUBImportFilter.hxx b/writerperfect/source/draw/MSPUBImportFilter.hxx index c4fd4917f2d0..5a41d2166234 100644 --- a/writerperfect/source/draw/MSPUBImportFilter.hxx +++ b/writerperfect/source/draw/MSPUBImportFilter.hxx @@ -18,19 +18,20 @@ class MSPUBImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit MSPUBImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit MSPUBImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/MWAWDrawImportFilter.cxx b/writerperfect/source/draw/MWAWDrawImportFilter.cxx index 483eb5a89225..b0432e3bbab2 100644 --- a/writerperfect/source/draw/MWAWDrawImportFilter.cxx +++ b/writerperfect/source/draw/MWAWDrawImportFilter.cxx @@ -16,19 +16,23 @@ #include "MWAWDrawImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdgGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeGraphic(data, &exporter); } -static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); @@ -36,57 +40,60 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWDrawImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool MWAWDrawImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } -bool MWAWDrawImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MWAWDrawImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { rTypeName.clear(); MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN; MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN; - const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); + const MWAWDocument::Confidence confidence + = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); if (confidence == MWAWDocument::MWAW_C_EXCELLENT) { switch (docKind) { - case MWAWDocument::MWAW_K_DRAW: - switch (docType) - { - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "draw_ClarisWorks"; - break; - default: - rTypeName = "MWAW_Drawing"; + case MWAWDocument::MWAW_K_DRAW: + switch (docType) + { + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "draw_ClarisWorks"; + break; + default: + rTypeName = "MWAW_Drawing"; + break; + } break; - } - break; - case MWAWDocument::MWAW_K_PAINT: - switch (docType) - { - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "draw_ClarisWorks"; + case MWAWDocument::MWAW_K_PAINT: + switch (docType) + { + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "draw_ClarisWorks"; + break; + default: + rTypeName = "MWAW_Bitmap"; + break; + } break; default: - rTypeName = "MWAW_Bitmap"; break; - } - break; - default: - break; } } return !rTypeName.isEmpty(); } -void MWAWDrawImportFilter::doRegisterHandlers(OdgGenerator &rGenerator) +void MWAWDrawImportFilter::doRegisterHandlers(OdgGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", + &handleEmbeddedMWAWSpreadsheetObject); } // XServiceInfo @@ -95,25 +102,23 @@ OUString SAL_CALL MWAWDrawImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.MWAWDrawImportFilter"); } -sal_Bool SAL_CALL MWAWDrawImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MWAWDrawImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MWAWDrawImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MWAWDrawImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_MWAWDrawImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MWAWDrawImportFilter(context)); } diff --git a/writerperfect/source/draw/MWAWDrawImportFilter.hxx b/writerperfect/source/draw/MWAWDrawImportFilter.hxx index 8bbfbb5f3898..15cdeb9356ec 100644 --- a/writerperfect/source/draw/MWAWDrawImportFilter.hxx +++ b/writerperfect/source/draw/MWAWDrawImportFilter.hxx @@ -23,18 +23,21 @@ class MWAWDrawImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit MWAWDrawImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdgGenerator>(rxContext) {} + explicit MWAWDrawImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdgGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/draw/PageMakerImportFilter.cxx b/writerperfect/source/draw/PageMakerImportFilter.cxx index 450c59c19df5..64866c57f6ee 100644 --- a/writerperfect/source/draw/PageMakerImportFilter.cxx +++ b/writerperfect/source/draw/PageMakerImportFilter.cxx @@ -22,12 +22,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool PageMakerImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool PageMakerImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libpagemaker::PMDocument::parse(&rInput, &rGenerator); } -bool PageMakerImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool PageMakerImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libpagemaker::PMDocument::isSupported(&rInput)) { @@ -44,25 +45,23 @@ OUString SAL_CALL PageMakerImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Draw.PageMakerImportFilter"); } -sal_Bool SAL_CALL PageMakerImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL PageMakerImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL PageMakerImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL PageMakerImportFilter::getSupportedServiceNames() { - Sequence< OUString > aRet(2); - OUString *pArray = aRet.getArray(); + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); pArray[0] = "com.sun.star.document.ImportFilter"; pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Draw_PageMakerImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new PageMakerImportFilter(context)); } diff --git a/writerperfect/source/draw/PageMakerImportFilter.hxx b/writerperfect/source/draw/PageMakerImportFilter.hxx index d5a7c3745f38..50e38fc9ec78 100644 --- a/writerperfect/source/draw/PageMakerImportFilter.hxx +++ b/writerperfect/source/draw/PageMakerImportFilter.hxx @@ -18,19 +18,21 @@ class PageMakerImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit PageMakerImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit PageMakerImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/QXPImportFilter.cxx b/writerperfect/source/draw/QXPImportFilter.cxx index 3779bc5c38bc..0a719ac58296 100644 --- a/writerperfect/source/draw/QXPImportFilter.cxx +++ b/writerperfect/source/draw/QXPImportFilter.cxx @@ -22,12 +22,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool QXPImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool QXPImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libqxp::QXPDocument::parse(&rInput, &rGenerator) == libqxp::QXPDocument::RESULT_OK; } -bool QXPImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool QXPImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libqxp::QXPDocument::isSupported(&rInput)) { @@ -44,21 +45,20 @@ OUString SAL_CALL QXPImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Draw.QXPImportFilter"); } -sal_Bool SAL_CALL QXPImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL QXPImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL QXPImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL QXPImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Draw_QXPImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new QXPImportFilter(context)); } diff --git a/writerperfect/source/draw/QXPImportFilter.hxx b/writerperfect/source/draw/QXPImportFilter.hxx index 5672165a2d43..6b73e8ae1357 100644 --- a/writerperfect/source/draw/QXPImportFilter.hxx +++ b/writerperfect/source/draw/QXPImportFilter.hxx @@ -18,19 +18,20 @@ class QXPImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit QXPImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit QXPImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx index b5cfb1537619..a0fcb392d811 100644 --- a/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx +++ b/writerperfect/source/draw/StarOfficeDrawImportFilter.cxx @@ -14,19 +14,23 @@ #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::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +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) +static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); @@ -34,37 +38,42 @@ static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryDat return STOFFDocument::decodeSpreadsheet(data, &exporter); } -bool StarOfficeDrawImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +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) +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); + const STOFFDocument::Confidence confidence + = STOFFDocument::isFileFormatSupported(&rInput, docKind); - if (confidence == STOFFDocument::STOFF_C_EXCELLENT || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) + 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; + case STOFFDocument::STOFF_K_DRAW: + rTypeName = "StarOffice_Drawing"; + break; + default: + break; } } return !rTypeName.isEmpty(); } -void StarOfficeDrawImportFilter::doRegisterHandlers(OdgGenerator &rGenerator) +void StarOfficeDrawImportFilter::doRegisterHandlers(OdgGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", + &handleEmbeddedSTOFFSpreadsheetObject); } // XServiceInfo @@ -73,21 +82,20 @@ OUString SAL_CALL StarOfficeDrawImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Draw.StarOfficeDrawImportFilter"); } -sal_Bool SAL_CALL StarOfficeDrawImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL StarOfficeDrawImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL StarOfficeDrawImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL StarOfficeDrawImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Draw_StarOfficeDrawImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new StarOfficeDrawImportFilter(context)); } diff --git a/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx b/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx index 519a77107055..fb0ebabcd38c 100644 --- a/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx +++ b/writerperfect/source/draw/StarOfficeDrawImportFilter.hxx @@ -23,18 +23,22 @@ class StarOfficeDrawImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit StarOfficeDrawImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdgGenerator>(rxContext) {} + explicit StarOfficeDrawImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdgGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx index 4745d0add6c0..1b377495ebb6 100644 --- a/writerperfect/source/draw/VisioImportFilter.cxx +++ b/writerperfect/source/draw/VisioImportFilter.cxx @@ -20,12 +20,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool VisioImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool VisioImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libvisio::VisioDocument::parse(&rInput, &rGenerator); } -bool VisioImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool VisioImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libvisio::VisioDocument::isSupported(&rInput)) { @@ -42,25 +43,23 @@ OUString SAL_CALL VisioImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.VisioImportFilter"); } -sal_Bool SAL_CALL VisioImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL VisioImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL VisioImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL VisioImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_VisioImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new VisioImportFilter(context)); } diff --git a/writerperfect/source/draw/VisioImportFilter.hxx b/writerperfect/source/draw/VisioImportFilter.hxx index 7fd4e8c7eca1..8468c602e8af 100644 --- a/writerperfect/source/draw/VisioImportFilter.hxx +++ b/writerperfect/source/draw/VisioImportFilter.hxx @@ -18,19 +18,20 @@ class VisioImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit VisioImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit VisioImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx index 31dce33774e7..bd4d238245d3 100644 --- a/writerperfect/source/draw/WPGImportFilter.cxx +++ b/writerperfect/source/draw/WPGImportFilter.cxx @@ -27,12 +27,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool WPGImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool WPGImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libwpg::WPGraphics::parse(&rInput, &rGenerator); } -bool WPGImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool WPGImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libwpg::WPGraphics::isSupported(&rInput)) { @@ -49,25 +50,23 @@ OUString SAL_CALL WPGImportFilter::getImplementationName() return OUString("com.sun.star.comp.Draw.WPGImportFilter"); } -sal_Bool SAL_CALL WPGImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL WPGImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL WPGImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL WPGImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Draw_WPGImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new WPGImportFilter(context)); } diff --git a/writerperfect/source/draw/WPGImportFilter.hxx b/writerperfect/source/draw/WPGImportFilter.hxx index 9945c6745dd2..b31ac6bf8627 100644 --- a/writerperfect/source/draw/WPGImportFilter.hxx +++ b/writerperfect/source/draw/WPGImportFilter.hxx @@ -23,19 +23,20 @@ class WPGImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit WPGImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit WPGImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/draw/ZMFImportFilter.cxx b/writerperfect/source/draw/ZMFImportFilter.cxx index ce63773ef4c2..3a71eee63f6a 100644 --- a/writerperfect/source/draw/ZMFImportFilter.cxx +++ b/writerperfect/source/draw/ZMFImportFilter.cxx @@ -22,12 +22,13 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool ZMFImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +bool ZMFImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdgGenerator& rGenerator, utl::MediaDescriptor&) { return libzmf::ZMFDocument::parse(&rInput, &rGenerator); } -bool ZMFImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool ZMFImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libzmf::ZMFDocument::isSupported(&rInput)) { @@ -44,21 +45,20 @@ OUString SAL_CALL ZMFImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Draw.ZMFImportFilter"); } -sal_Bool SAL_CALL ZMFImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL ZMFImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL ZMFImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL ZMFImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Draw_ZMFImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new ZMFImportFilter(context)); } diff --git a/writerperfect/source/draw/ZMFImportFilter.hxx b/writerperfect/source/draw/ZMFImportFilter.hxx index 76407033aa82..85dbf59c0cda 100644 --- a/writerperfect/source/draw/ZMFImportFilter.hxx +++ b/writerperfect/source/draw/ZMFImportFilter.hxx @@ -18,19 +18,20 @@ class ZMFImportFilter : public writerperfect::ImportFilter<OdgGenerator> { public: - explicit ZMFImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + explicit ZMFImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) : writerperfect::ImportFilter<OdgGenerator>(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; + 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, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdgGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/impress/KeynoteImportFilter.cxx b/writerperfect/source/impress/KeynoteImportFilter.cxx index 2f7760cae86c..c535786ff91f 100644 --- a/writerperfect/source/impress/KeynoteImportFilter.cxx +++ b/writerperfect/source/impress/KeynoteImportFilter.cxx @@ -48,12 +48,13 @@ using writerperfect::WPXSvInputStream; namespace beans = com::sun::star::beans; namespace ucb = com::sun::star::ucb; -bool KeynoteImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) +bool KeynoteImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdpGenerator& rGenerator, utl::MediaDescriptor&) { return libetonyek::EtonyekDocument::parse(&rInput, &rGenerator); } -bool KeynoteImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool KeynoteImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libetonyek::EtonyekDocument::isSupported(&rInput)) { @@ -65,7 +66,8 @@ bool KeynoteImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OU } // XExtendedFilterDetection -OUString SAL_CALL KeynoteImportFilter::detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) +OUString SAL_CALL +KeynoteImportFilter::detect(css::uno::Sequence<css::beans::PropertyValue>& Descriptor) { sal_Int32 nLength = Descriptor.getLength(); sal_Int32 nNewLength = nLength + 2; @@ -74,14 +76,14 @@ OUString SAL_CALL KeynoteImportFilter::detect(css::uno::Sequence< css::beans::Pr sal_Int32 nUCBContentLocation = -1; bool bIsPackage = false; bool bUCBContentChanged = false; - const beans::PropertyValue *pValue = Descriptor.getConstArray(); - Reference < XInputStream > xInputStream; - Reference < ucb::XContent > xContent; - Sequence < beans::NamedValue > lComponentDataNV; - Sequence < beans::PropertyValue > lComponentDataPV; + const beans::PropertyValue* pValue = Descriptor.getConstArray(); + Reference<XInputStream> xInputStream; + Reference<ucb::XContent> xContent; + Sequence<beans::NamedValue> lComponentDataNV; + Sequence<beans::PropertyValue> lComponentDataPV; bool bComponentDataNV = true; - for (sal_Int32 i = 0 ; i < nLength; i++) + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "TypeName") { @@ -112,7 +114,7 @@ OUString SAL_CALL KeynoteImportFilter::detect(css::uno::Sequence< css::beans::Pr if (!xInputStream.is()) return OUString(); - shared_ptr< librevenge::RVNGInputStream > input(new WPXSvInputStream(xInputStream)); + shared_ptr<librevenge::RVNGInputStream> input(new WPXSvInputStream(xInputStream)); /* Apple Keynote documents come in two variants: * * actual files (zip), only produced by Keynote 5 (at least with @@ -129,8 +131,7 @@ OUString SAL_CALL KeynoteImportFilter::detect(css::uno::Sequence< css::beans::Pr */ if (xContent.is()) { - ucbhelper::Content aContent(xContent, - utl::UCBContentHelper::getDefaultCommandEnvironment(), + ucbhelper::Content aContent(xContent, utl::UCBContentHelper::getDefaultCommandEnvironment(), comphelper::getProcessComponentContext()); try { @@ -147,20 +148,24 @@ OUString SAL_CALL KeynoteImportFilter::detect(css::uno::Sequence< css::beans::Pr } libetonyek::EtonyekDocument::Type type = libetonyek::EtonyekDocument::TYPE_UNKNOWN; - const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(input.get(), &type); - if ((libetonyek::EtonyekDocument::CONFIDENCE_NONE == confidence) || (libetonyek::EtonyekDocument::TYPE_KEYNOTE != type)) + const libetonyek::EtonyekDocument::Confidence confidence + = libetonyek::EtonyekDocument::isSupported(input.get(), &type); + if ((libetonyek::EtonyekDocument::CONFIDENCE_NONE == confidence) + || (libetonyek::EtonyekDocument::TYPE_KEYNOTE != type)) return OUString(); if (confidence == libetonyek::EtonyekDocument::CONFIDENCE_SUPPORTED_PART) { - if (bIsPackage) // we passed a directory stream, but the filter claims it's APXL file? + if (bIsPackage) // we passed a directory stream, but the filter claims it's APXL file? return OUString(); - const std::shared_ptr<writerperfect::DirectoryStream> pDir = writerperfect::DirectoryStream::createForParent(xContent); + const std::shared_ptr<writerperfect::DirectoryStream> pDir + = writerperfect::DirectoryStream::createForParent(xContent); input = pDir; if (bool(input)) { - if (libetonyek::EtonyekDocument::CONFIDENCE_EXCELLENT == libetonyek::EtonyekDocument::isSupported(input.get())) + if (libetonyek::EtonyekDocument::CONFIDENCE_EXCELLENT + == libetonyek::EtonyekDocument::isSupported(input.get())) { xContent = pDir->getContent(); bUCBContentChanged = true; @@ -237,25 +242,23 @@ OUString SAL_CALL KeynoteImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Impress.KeynoteImportFilter"); } -sal_Bool SAL_CALL KeynoteImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL KeynoteImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL KeynoteImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL KeynoteImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); pArray[0] = "com.sun.star.document.ImportFilter"; pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Impress_KeynoteImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new KeynoteImportFilter(context)); } diff --git a/writerperfect/source/impress/KeynoteImportFilter.hxx b/writerperfect/source/impress/KeynoteImportFilter.hxx index c7dc52a4ad82..dc62b44f1d61 100644 --- a/writerperfect/source/impress/KeynoteImportFilter.hxx +++ b/writerperfect/source/impress/KeynoteImportFilter.hxx @@ -20,20 +20,24 @@ class KeynoteImportFilter : public writerperfect::ImportFilter<OdpGenerator> { public: - explicit KeynoteImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdpGenerator>(rxContext) {} + explicit KeynoteImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdpGenerator>(rxContext) + { + } //XExtendedFilterDetection - virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) override; + virtual OUString SAL_CALL + detect(css::uno::Sequence<css::beans::PropertyValue>& Descriptor) override; // 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; + 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 bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdpGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/impress/MWAWPresentationImportFilter.cxx b/writerperfect/source/impress/MWAWPresentationImportFilter.cxx index 5fe085548364..cd35fb6f275c 100644 --- a/writerperfect/source/impress/MWAWPresentationImportFilter.cxx +++ b/writerperfect/source/impress/MWAWPresentationImportFilter.cxx @@ -16,19 +16,23 @@ #include "MWAWPresentationImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdgGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeGraphic(data, &exporter); } -static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); @@ -36,18 +40,21 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWPresentationImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) +bool MWAWPresentationImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdpGenerator& rGenerator, utl::MediaDescriptor&) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } -bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, + OUString& rTypeName) { rTypeName.clear(); MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN; MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN; - const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); + const MWAWDocument::Confidence confidence + = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); if (confidence == MWAWDocument::MWAW_C_EXCELLENT) { @@ -55,15 +62,15 @@ bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream &r { switch (docType) { - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "impress_ClarisWorks"; - break; - case MWAWDocument::MWAW_T_RESERVED8: - rTypeName = "impress_PowerPoint3"; - break; - default: - rTypeName = "MWAW_Presentation"; - break; + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "impress_ClarisWorks"; + break; + case MWAWDocument::MWAW_T_RESERVED8: + rTypeName = "impress_PowerPoint3"; + break; + default: + rTypeName = "MWAW_Presentation"; + break; } } } @@ -71,10 +78,11 @@ bool MWAWPresentationImportFilter::doDetectFormat(librevenge::RVNGInputStream &r return !rTypeName.isEmpty(); } -void MWAWPresentationImportFilter::doRegisterHandlers(OdpGenerator &rGenerator) +void MWAWPresentationImportFilter::doRegisterHandlers(OdpGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", + &handleEmbeddedMWAWSpreadsheetObject); } // XServiceInfo @@ -82,24 +90,22 @@ OUString SAL_CALL MWAWPresentationImportFilter::getImplementationName() { return OUString("com.sun.star.comp.Impress.MWAWPresentationImportFilter"); } -sal_Bool SAL_CALL MWAWPresentationImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MWAWPresentationImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MWAWPresentationImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MWAWPresentationImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Impress_MWAWPresentationImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MWAWPresentationImportFilter(context)); } diff --git a/writerperfect/source/impress/MWAWPresentationImportFilter.hxx b/writerperfect/source/impress/MWAWPresentationImportFilter.hxx index fce0250fe6ff..2d004282f7f1 100644 --- a/writerperfect/source/impress/MWAWPresentationImportFilter.hxx +++ b/writerperfect/source/impress/MWAWPresentationImportFilter.hxx @@ -23,18 +23,22 @@ class MWAWPresentationImportFilter : public writerperfect::ImportFilter<OdpGenerator> { public: - explicit MWAWPresentationImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdpGenerator>(rxContext) {} + explicit MWAWPresentationImportFilter( + 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; + 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; + 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 diff --git a/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx b/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx index 02ab78b899fa..34ed2a72ffd3 100644 --- a/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx +++ b/writerperfect/source/impress/StarOfficePresentationImportFilter.cxx @@ -14,19 +14,23 @@ #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::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedSTOFFGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +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) +static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); @@ -34,37 +38,43 @@ static bool handleEmbeddedSTOFFSpreadsheetObject(const librevenge::RVNGBinaryDat return STOFFDocument::decodeSpreadsheet(data, &exporter); } -bool StarOfficePresentationImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) +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) +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); + const STOFFDocument::Confidence confidence + = STOFFDocument::isFileFormatSupported(&rInput, docKind); - if (confidence == STOFFDocument::STOFF_C_EXCELLENT || confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) + 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; + case STOFFDocument::STOFF_K_PRESENTATION: + rTypeName = "StarOffice_Presentation"; + break; + default: + break; } } return !rTypeName.isEmpty(); } -void StarOfficePresentationImportFilter::doRegisterHandlers(OdpGenerator &rGenerator) +void StarOfficePresentationImportFilter::doRegisterHandlers(OdpGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", + &handleEmbeddedSTOFFSpreadsheetObject); } // XServiceInfo @@ -73,21 +83,20 @@ OUString SAL_CALL StarOfficePresentationImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Impress.StarOfficePresentationImportFilter"); } -sal_Bool SAL_CALL StarOfficePresentationImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL StarOfficePresentationImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL StarOfficePresentationImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL StarOfficePresentationImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Presentation_StarOfficePresentationImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new StarOfficePresentationImportFilter(context)); } diff --git a/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx b/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx index 7611135ef71b..4df403bae184 100644 --- a/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx +++ b/writerperfect/source/impress/StarOfficePresentationImportFilter.hxx @@ -23,18 +23,22 @@ class StarOfficePresentationImportFilter : public writerperfect::ImportFilter<OdpGenerator> { public: - explicit StarOfficePresentationImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdpGenerator>(rxContext) {} + 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; + 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; + 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 diff --git a/writerperfect/source/writer/AbiWordImportFilter.cxx b/writerperfect/source/writer/AbiWordImportFilter.cxx index 4bc4414793f1..c6d6823276f8 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.cxx +++ b/writerperfect/source/writer/AbiWordImportFilter.cxx @@ -15,17 +15,18 @@ #include "AbiWordImportFilter.hxx" -using com::sun::star::uno::Sequence; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool AbiWordImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &) +bool AbiWordImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdtGenerator& rGenerator, utl::MediaDescriptor&) { return libabw::AbiDocument::parse(&rInput, &rGenerator); } -bool AbiWordImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool AbiWordImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { if (libabw::AbiDocument::isFileFormatSupported(&rInput)) { @@ -42,25 +43,23 @@ OUString SAL_CALL AbiWordImportFilter::getImplementationName() return OUString("com.sun.star.comp.Writer.AbiWordImportFilter"); } -sal_Bool SAL_CALL AbiWordImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL AbiWordImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL AbiWordImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL AbiWordImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Writer_AbiWordImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new AbiWordImportFilter(context)); } diff --git a/writerperfect/source/writer/AbiWordImportFilter.hxx b/writerperfect/source/writer/AbiWordImportFilter.hxx index a939d414743b..30d0ef77b922 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.hxx +++ b/writerperfect/source/writer/AbiWordImportFilter.hxx @@ -23,17 +23,20 @@ class AbiWordImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit AbiWordImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit AbiWordImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdtGenerator& rGenerator, + utl::MediaDescriptor&) override; }; #endif diff --git a/writerperfect/source/writer/EBookImportFilter.cxx b/writerperfect/source/writer/EBookImportFilter.cxx index a911ea2cc8d7..8bd96a7e12f7 100644 --- a/writerperfect/source/writer/EBookImportFilter.cxx +++ b/writerperfect/source/writer/EBookImportFilter.cxx @@ -15,14 +15,16 @@ #include "EBookImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; using libebook::EBOOKDocument; -bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) +bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdtGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) { rtl::OUString aFilterName; @@ -53,7 +55,7 @@ bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, Od return false; } -bool EBookImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool EBookImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { rTypeName.clear(); @@ -63,25 +65,27 @@ bool EBookImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUSt { switch (type) { - case EBOOKDocument::TYPE_BBEB : - rTypeName = "writer_BroadBand_eBook"; - break; - case EBOOKDocument::TYPE_FICTIONBOOK2 : - rTypeName = "writer_FictionBook_2"; - break; - case EBOOKDocument::TYPE_PALMDOC : - rTypeName = "writer_PalmDoc"; - break; - case EBOOKDocument::TYPE_PLUCKER : - rTypeName = "writer_Plucker_eBook"; - break; - case EBOOKDocument::TYPE_PEANUTPRESS : - case EBOOKDocument::TYPE_TEALDOC : - case EBOOKDocument::TYPE_ZTXT : - rTypeName = "Palm_Text_Document"; - break; - default : - SAL_WARN_IF(type != EBOOKDocument::TYPE_UNKNOWN, "writerperfect", "EBookImportFilter::doDetectFormat: document type " << type << " detected, but ignored"); + case EBOOKDocument::TYPE_BBEB: + rTypeName = "writer_BroadBand_eBook"; + break; + case EBOOKDocument::TYPE_FICTIONBOOK2: + rTypeName = "writer_FictionBook_2"; + break; + case EBOOKDocument::TYPE_PALMDOC: + rTypeName = "writer_PalmDoc"; + break; + case EBOOKDocument::TYPE_PLUCKER: + rTypeName = "writer_Plucker_eBook"; + break; + case EBOOKDocument::TYPE_PEANUTPRESS: + case EBOOKDocument::TYPE_TEALDOC: + case EBOOKDocument::TYPE_ZTXT: + rTypeName = "Palm_Text_Document"; + break; + default: + SAL_WARN_IF(type != EBOOKDocument::TYPE_UNKNOWN, "writerperfect", + "EBookImportFilter::doDetectFormat: document type " + << type << " detected, but ignored"); } } @@ -94,25 +98,23 @@ OUString SAL_CALL EBookImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Writer.EBookImportFilter"); } -sal_Bool SAL_CALL EBookImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL EBookImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL EBookImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL EBookImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Writer_EBookImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new EBookImportFilter(context)); } diff --git a/writerperfect/source/writer/EBookImportFilter.hxx b/writerperfect/source/writer/EBookImportFilter.hxx index 96e07d98d382..209f080c2cdf 100644 --- a/writerperfect/source/writer/EBookImportFilter.hxx +++ b/writerperfect/source/writer/EBookImportFilter.hxx @@ -23,17 +23,20 @@ class EBookImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit EBookImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit EBookImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdtGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; }; #endif diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx index bf1f4a0e4cfd..fa9bc9193992 100644 --- a/writerperfect/source/writer/EPUBExportDialog.cxx +++ b/writerperfect/source/writer/EPUBExportDialog.cxx @@ -31,15 +31,15 @@ sal_Int32 VersionToPosition(sal_Int32 nVersion) switch (nVersion) { - case 30: - nPosition = 0; - break; - case 20: - nPosition = 1; - break; - default: - assert(false); - break; + case 30: + nPosition = 0; + break; + case 20: + nPosition = 1; + break; + default: + assert(false); + break; } return nPosition; @@ -52,15 +52,15 @@ sal_Int32 PositionToVersion(sal_Int32 nPosition) switch (nPosition) { - case 0: - nVersion = 30; - break; - case 1: - nVersion = 20; - break; - default: - assert(false); - break; + case 0: + nVersion = 30; + break; + case 1: + nVersion = 20; + break; + default: + assert(false); + break; } return nVersion; @@ -69,8 +69,10 @@ sal_Int32 PositionToVersion(sal_Int32 nPosition) namespace writerperfect { - -EPUBExportDialog::EPUBExportDialog(weld::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, uno::Reference<uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument) +EPUBExportDialog::EPUBExportDialog(weld::Window* pParent, + comphelper::SequenceAsHashMap& rFilterData, + uno::Reference<uno::XComponentContext> xContext, + css::uno::Reference<css::lang::XComponent> xDocument) : GenericDialogController(pParent, "writerperfect/ui/exportepub.ui", "EpubDialog") , m_xContext(std::move(xContext)) , m_rFilterData(rFilterData) @@ -158,19 +160,19 @@ EPUBExportDialog::EPUBExportDialog(weld::Window *pParent, comphelper::SequenceAs m_xOKButton->connect_clicked(LINK(this, EPUBExportDialog, OKClickHdl)); } -IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, weld::ComboBoxText &, void) +IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, weld::ComboBoxText&, void) { m_rFilterData["EPUBVersion"] <<= PositionToVersion(m_xVersion->get_active()); } -IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, weld::ComboBoxText &, void) +IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, weld::ComboBoxText&, void) { // No conversion, 1:1 mapping between entry positions and // libepubgen::EPUBSplitMethod. m_rFilterData["EPUBSplitMethod"] <<= static_cast<sal_Int32>(m_xSplit->get_active()); } -IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, weld::ComboBoxText &, void) +IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, weld::ComboBoxText&, void) { // No conversion, 1:1 mapping between entry positions and // libepubgen::EPUBLayoutMethod. @@ -178,7 +180,7 @@ IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, weld::ComboBoxText &, void) m_xSplit->set_sensitive(m_xLayout->get_active() != libepubgen::EPUB_LAYOUT_METHOD_FIXED); } -IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, weld::Button &, void) +IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, weld::Button&, void) { SvxOpenGraphicDialog aDlg("Import", m_xDialog.get()); aDlg.EnableLink(false); @@ -186,16 +188,17 @@ IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, weld::Button &, void) m_xCoverPath->set_text(aDlg.GetPath()); } -IMPL_LINK_NOARG(EPUBExportDialog, MediaClickHdl, weld::Button &, void) +IMPL_LINK_NOARG(EPUBExportDialog, MediaClickHdl, weld::Button&, void) { - uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(m_xContext); + uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker + = ui::dialogs::FolderPicker::create(m_xContext); if (xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK) return; m_xMediaDir->set_text(xFolderPicker->getDirectory()); } -IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, weld::Button &, void) +IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, weld::Button&, void) { // General if (!m_xCoverPath->get_text().isEmpty()) @@ -218,9 +221,7 @@ IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, weld::Button &, void) m_xDialog->response(RET_OK); } -EPUBExportDialog::~EPUBExportDialog() -{ -} +EPUBExportDialog::~EPUBExportDialog() {} } // namespace writerperfect diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx index 51326c1ae1f6..6852b11a6bbb 100644 --- a/writerperfect/source/writer/EPUBExportDialog.hxx +++ b/writerperfect/source/writer/EPUBExportDialog.hxx @@ -19,24 +19,25 @@ class SequenceAsHashMap; namespace writerperfect { - /// EPUB export options dialog. class EPUBExportDialog : public weld::GenericDialogController { public: - EPUBExportDialog(weld::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, css::uno::Reference<css::uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument); + EPUBExportDialog(weld::Window* pParent, comphelper::SequenceAsHashMap& rFilterData, + css::uno::Reference<css::uno::XComponentContext> xContext, + css::uno::Reference<css::lang::XComponent> xDocument); ~EPUBExportDialog() override; private: - DECL_LINK(VersionSelectHdl, weld::ComboBoxText &, void); - DECL_LINK(SplitSelectHdl, weld::ComboBoxText &, void); - DECL_LINK(LayoutSelectHdl, weld::ComboBoxText &, void); - DECL_LINK(CoverClickHdl, weld::Button &, void); - DECL_LINK(MediaClickHdl, weld::Button &, void); - DECL_LINK(OKClickHdl, weld::Button &, void); + DECL_LINK(VersionSelectHdl, weld::ComboBoxText&, void); + DECL_LINK(SplitSelectHdl, weld::ComboBoxText&, void); + DECL_LINK(LayoutSelectHdl, weld::ComboBoxText&, void); + DECL_LINK(CoverClickHdl, weld::Button&, void); + DECL_LINK(MediaClickHdl, weld::Button&, void); + DECL_LINK(OKClickHdl, weld::Button&, void); css::uno::Reference<css::uno::XComponentContext> m_xContext; - comphelper::SequenceAsHashMap &m_rFilterData; + comphelper::SequenceAsHashMap& m_rFilterData; css::uno::Reference<css::lang::XComponent> m_xSourceDocument; std::unique_ptr<weld::ComboBoxText> m_xVersion; diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx index 2e4286e1f80b..e24bb1e54859 100644 --- a/writerperfect/source/writer/EPUBExportFilter.cxx +++ b/writerperfect/source/writer/EPUBExportFilter.cxx @@ -33,16 +33,12 @@ using namespace com::sun::star; namespace writerperfect { - EPUBExportFilter::EPUBExportFilter(uno::Reference<uno::XComponentContext> xContext) : mxContext(std::move(xContext)) { } -sal_Int32 EPUBExportFilter::GetDefaultVersion() -{ - return 30; -} +sal_Int32 EPUBExportFilter::GetDefaultVersion() { return 30; } sal_Int32 EPUBExportFilter::GetDefaultSplitMethod() { @@ -54,7 +50,7 @@ sal_Int32 EPUBExportFilter::GetDefaultLayoutMethod() return libepubgen::EPUB_LAYOUT_METHOD_REFLOWABLE; } -sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDescriptor) +sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescriptor) { sal_Int32 nVersion = EPUBExportFilter::GetDefaultVersion(); sal_Int32 nSplitMethod = EPUBExportFilter::GetDefaultSplitMethod(); @@ -98,20 +94,24 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe if (nLayoutMethod == libepubgen::EPUB_LAYOUT_METHOD_FIXED) CreateMetafiles(aPageMetafiles); - uno::Reference<xml::sax::XDocumentHandler> xExportHandler(new exp::XMLImport(mxContext, aGenerator, aSourceURL, rDescriptor, aPageMetafiles)); + uno::Reference<xml::sax::XDocumentHandler> xExportHandler( + new exp::XMLImport(mxContext, aGenerator, aSourceURL, rDescriptor, aPageMetafiles)); - uno::Reference<lang::XInitialization> xInitialization(mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.Writer.XMLOasisExporter", mxContext), uno::UNO_QUERY); + uno::Reference<lang::XInitialization> xInitialization( + mxContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.comp.Writer.XMLOasisExporter", mxContext), + uno::UNO_QUERY); // A subset of parameters are passed in as a property set. - comphelper::PropertyMapEntry const aInfoMap[] = - { - {OUString("BaseURI"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString(), 0, uno::Type(), 0, 0} - }; - uno::Reference<beans::XPropertySet> xInfoSet(comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aInfoMap))); + comphelper::PropertyMapEntry const aInfoMap[] + = { { OUString("BaseURI"), 0, cppu::UnoType<OUString>::get(), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { OUString(), 0, uno::Type(), 0, 0 } }; + uno::Reference<beans::XPropertySet> xInfoSet( + comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aInfoMap))); xInfoSet->setPropertyValue("BaseURI", uno::makeAny(aSourceURL)); - xInitialization->initialize({uno::makeAny(xExportHandler), uno::makeAny(xInfoSet)}); + xInitialization->initialize({ uno::makeAny(xExportHandler), uno::makeAny(xInfoSet) }); uno::Reference<document::XExporter> xExporter(xInitialization, uno::UNO_QUERY); xExporter->setSourceDocument(mxSourceDocument); uno::Reference<document::XFilter> xFilter(xInitialization, uno::UNO_QUERY); @@ -119,18 +119,20 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe return xFilter->filter(rDescriptor); } -void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage> &rPageMetafiles) +void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage>& rPageMetafiles) { DocumentToGraphicRenderer aRenderer(mxSourceDocument, /*bSelectionOnly=*/false); uno::Reference<frame::XModel> xModel(mxSourceDocument, uno::UNO_QUERY); if (!xModel.is()) return; - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); if (!xTextViewCursorSupplier.is()) return; - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), + uno::UNO_QUERY); if (!xCursor.is()) return; @@ -141,9 +143,11 @@ void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage> &rPageM Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(nPage); Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage); // Get the CSS pixel size of the page (mm100 -> pixel using 96 DPI, independent from system DPI). - Size aCss(static_cast<double>(aLogic.getWidth()) / 26.4583, static_cast<double>(aLogic.getHeight()) / 26.4583); - Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aCss, COL_WHITE, /*bExtOutDevData=*/true); - auto &rGDIMetaFile = const_cast<GDIMetaFile &>(aGraphic.GetGDIMetaFile()); + Size aCss(static_cast<double>(aLogic.getWidth()) / 26.4583, + static_cast<double>(aLogic.getHeight()) / 26.4583); + Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aCss, COL_WHITE, + /*bExtOutDevData=*/true); + auto& rGDIMetaFile = const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()); // Set preferred map unit and size on the metafile, so the SVG size // will be correct in MM. @@ -154,7 +158,8 @@ void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage> &rPageM SvMemoryStream aMemoryStream; rGDIMetaFile.Write(aMemoryStream); - uno::Sequence<sal_Int8> aSequence(static_cast<const sal_Int8 *>(aMemoryStream.GetData()), aMemoryStream.Tell()); + uno::Sequence<sal_Int8> aSequence(static_cast<const sal_Int8*>(aMemoryStream.GetData()), + aMemoryStream.Tell()); exp::FixedLayoutPage aPage; aPage.aMetafile = aSequence; @@ -164,11 +169,9 @@ void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage> &rPageM } } -void EPUBExportFilter::cancel() -{ -} +void EPUBExportFilter::cancel() {} -void EPUBExportFilter::setSourceDocument(const uno::Reference<lang::XComponent> &xDocument) +void EPUBExportFilter::setSourceDocument(const uno::Reference<lang::XComponent>& xDocument) { mxSourceDocument = xDocument; } @@ -178,21 +181,20 @@ OUString EPUBExportFilter::getImplementationName() return OUString("com.sun.star.comp.Writer.EPUBExportFilter"); } -sal_Bool EPUBExportFilter::supportsService(const OUString &rServiceName) +sal_Bool EPUBExportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } uno::Sequence<OUString> EPUBExportFilter::getSupportedServiceNames() { - uno::Sequence<OUString> aRet = - { - OUString("com.sun.star.document.ExportFilter") - }; + uno::Sequence<OUString> aRet = { OUString("com.sun.star.document.ExportFilter") }; return aRet; } -extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *com_sun_star_comp_Writer_EPUBExportFilter_get_implementation(uno::XComponentContext *pContext, uno::Sequence<uno::Any> const &/*rSeq*/) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_Writer_EPUBExportFilter_get_implementation( + uno::XComponentContext* pContext, uno::Sequence<uno::Any> const& /*rSeq*/) { return cppu::acquire(new EPUBExportFilter(pContext)); } diff --git a/writerperfect/source/writer/EPUBExportFilter.hxx b/writerperfect/source/writer/EPUBExportFilter.hxx index fb5d7d6616a9..c8c37f25e652 100644 --- a/writerperfect/source/writer/EPUBExportFilter.hxx +++ b/writerperfect/source/writer/EPUBExportFilter.hxx @@ -27,12 +27,9 @@ struct FixedLayoutPage; } /// EPUB export XFilter implementation. -class EPUBExportFilter : public cppu::WeakImplHelper - < - css::document::XFilter, - css::document::XExporter, - css::lang::XServiceInfo - > +class EPUBExportFilter + : public cppu::WeakImplHelper<css::document::XFilter, css::document::XExporter, + css::lang::XServiceInfo> { css::uno::Reference<css::uno::XComponentContext> mxContext; css::uno::Reference<css::lang::XComponent> mxSourceDocument; @@ -41,15 +38,17 @@ public: EPUBExportFilter(css::uno::Reference<css::uno::XComponentContext> xContext); // XFilter - sal_Bool SAL_CALL filter(const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor) override; + sal_Bool SAL_CALL + filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) override; void SAL_CALL cancel() override; // XExporter - void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) override; + void SAL_CALL + setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDocument) override; // XServiceInfo OUString SAL_CALL getImplementationName() override; - sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override; + sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; /// Gives the default EPUB version. @@ -61,7 +60,7 @@ public: private: /// Create page metafiles in case of fixed layout. - void CreateMetafiles(std::vector<exp::FixedLayoutPage> &rPageMetafiles); + void CreateMetafiles(std::vector<exp::FixedLayoutPage>& rPageMetafiles); }; } // namespace writerperfect diff --git a/writerperfect/source/writer/EPUBExportUIComponent.cxx b/writerperfect/source/writer/EPUBExportUIComponent.cxx index abf533f7f19a..13e7be6b59d8 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.cxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.cxx @@ -21,7 +21,6 @@ using namespace com::sun::star; namespace writerperfect { - EPUBExportUIComponent::EPUBExportUIComponent(uno::Reference<uno::XComponentContext> xContext) : mxContext(std::move(xContext)) { @@ -33,7 +32,8 @@ uno::Sequence<beans::PropertyValue> EPUBExportUIComponent::getPropertyValues() return maMediaDescriptor.getAsConstPropertyValueList(); } -void EPUBExportUIComponent::setPropertyValues(const uno::Sequence<beans::PropertyValue> &rProperties) +void EPUBExportUIComponent::setPropertyValues( + const uno::Sequence<beans::PropertyValue>& rProperties) { maMediaDescriptor.clear(); maMediaDescriptor << rProperties; @@ -54,23 +54,18 @@ OUString EPUBExportUIComponent::getImplementationName() return OUString("com.sun.star.comp.Writer.EPUBExportUIComponent"); } -sal_Bool EPUBExportUIComponent::supportsService(const OUString &rServiceName) +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") - }; + uno::Sequence<OUString> aRet = { OUString("com.sun.star.ui.dialogs.FilterOptionsDialog") }; return aRet; } -void EPUBExportUIComponent::setTitle(const OUString &/*rTitle*/) -{ -} +void EPUBExportUIComponent::setTitle(const OUString& /*rTitle*/) {} void SAL_CALL EPUBExportUIComponent::initialize(const uno::Sequence<uno::Any>& rArguments) { @@ -83,18 +78,22 @@ sal_Int16 EPUBExportUIComponent::execute() { SolarMutexGuard aGuard; - EPUBExportDialog aDialog(Application::GetFrameWeld(mxDialogParent), maFilterData, mxContext, mxSourceDocument); + EPUBExportDialog aDialog(Application::GetFrameWeld(mxDialogParent), maFilterData, mxContext, + mxSourceDocument); if (aDialog.run() == RET_OK) return ui::dialogs::ExecutableDialogResults::OK; return ui::dialogs::ExecutableDialogResults::CANCEL; } -void SAL_CALL EPUBExportUIComponent::setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) +void SAL_CALL EPUBExportUIComponent::setSourceDocument( + const css::uno::Reference<css::lang::XComponent>& xDocument) { mxSourceDocument = xDocument; } -extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation(uno::XComponentContext *pCtx, uno::Sequence<uno::Any> const &/*rSeq*/) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation( + uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/) { return cppu::acquire(new EPUBExportUIComponent(pCtx)); } diff --git a/writerperfect/source/writer/EPUBExportUIComponent.hxx b/writerperfect/source/writer/EPUBExportUIComponent.hxx index f2288a91ad76..84f3ed8be893 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.hxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.hxx @@ -23,38 +23,35 @@ namespace writerperfect { - /// EPUB export UI component implementation. -class EPUBExportUIComponent : public cppu::WeakImplHelper - < - css::beans::XPropertyAccess, - css::lang::XInitialization, - css::lang::XServiceInfo, - css::ui::dialogs::XExecutableDialog, - css::document::XExporter - > +class EPUBExportUIComponent + : public cppu::WeakImplHelper<css::beans::XPropertyAccess, css::lang::XInitialization, + css::lang::XServiceInfo, css::ui::dialogs::XExecutableDialog, + css::document::XExporter> { public: EPUBExportUIComponent(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; + 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 &rServiceName) override; + sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; // XExecutableDialog - void SAL_CALL setTitle(const OUString &rTitle) override; + void SAL_CALL setTitle(const OUString& rTitle) override; sal_Int16 SAL_CALL execute() override; // XExporter - void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) override; + void SAL_CALL + setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDocument) override; // XInitialization - void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; + void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; private: /// The full set of property values. diff --git a/writerperfect/source/writer/EPUBPackage.cxx b/writerperfect/source/writer/EPUBPackage.cxx index 147a44b09454..6decc3b8f9b7 100644 --- a/writerperfect/source/writer/EPUBPackage.cxx +++ b/writerperfect/source/writer/EPUBPackage.cxx @@ -23,20 +23,26 @@ using namespace com::sun::star; namespace writerperfect { - -EPUBPackage::EPUBPackage(uno::Reference<uno::XComponentContext> xContext, const uno::Sequence<beans::PropertyValue> &rDescriptor) +EPUBPackage::EPUBPackage(uno::Reference<uno::XComponentContext> xContext, + const uno::Sequence<beans::PropertyValue>& rDescriptor) : mxContext(std::move(xContext)) { // Extract the output stream from the descriptor. utl::MediaDescriptor aMediaDesc(rDescriptor); - auto xStream = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STREAMFOROUTPUT(), uno::Reference<io::XStream>()); + auto xStream = aMediaDesc.getUnpackedValueOrDefault( + utl::MediaDescriptor::PROP_STREAMFOROUTPUT(), uno::Reference<io::XStream>()); const sal_Int32 nOpenMode = embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE; - mxStorage.set(comphelper::OStorageHelper::GetStorageOfFormatFromStream(ZIP_STORAGE_FORMAT_STRING, xStream, nOpenMode, mxContext), uno::UNO_QUERY); + mxStorage.set(comphelper::OStorageHelper::GetStorageOfFormatFromStream( + ZIP_STORAGE_FORMAT_STRING, xStream, nOpenMode, mxContext), + uno::UNO_QUERY); // The zipped content represents an EPUB Publication. - mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName("mimetype", embed::ElementModes::READWRITE), uno::UNO_QUERY); + mxOutputStream.set( + mxStorage->openStreamElementByHierarchicalName("mimetype", embed::ElementModes::READWRITE), + uno::UNO_QUERY); const OString aMimeType("application/epub+zip"); - uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8 *>(aMimeType.getStr()), aMimeType.getLength()); + uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8*>(aMimeType.getStr()), + aMimeType.getLength()); mxOutputStream->writeBytes(aData); uno::Reference<embed::XTransactedObject> xTransactedObject(mxOutputStream, uno::UNO_QUERY); xTransactedObject->commit(); @@ -53,19 +59,21 @@ EPUBPackage::~EPUBPackage() xTransactedObject->commit(); } -void EPUBPackage::openXMLFile(const char *pName) +void EPUBPackage::openXMLFile(const char* pName) { assert(pName); assert(!mxOutputStream.is()); assert(!mxOutputWriter.is()); - mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY); + mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName( + OUString::fromUtf8(pName), embed::ElementModes::READWRITE), + uno::UNO_QUERY); mxOutputWriter = xml::sax::Writer::create(mxContext); mxOutputWriter->setOutputStream(mxOutputStream); mxOutputWriter->startDocument(); } -void EPUBPackage::openElement(const char *pName, const librevenge::RVNGPropertyList &rAttributes) +void EPUBPackage::openElement(const char* pName, const librevenge::RVNGPropertyList& rAttributes) { assert(mxOutputWriter.is()); @@ -73,19 +81,21 @@ void EPUBPackage::openElement(const char *pName, const librevenge::RVNGPropertyL librevenge::RVNGPropertyList::Iter it(rAttributes); for (it.rewind(); it.next();) - pAttributeList->AddAttribute(OUString::fromUtf8(it.key()), OUString::fromUtf8(it()->getStr().cstr())); + pAttributeList->AddAttribute(OUString::fromUtf8(it.key()), + OUString::fromUtf8(it()->getStr().cstr())); - mxOutputWriter->startElement(OUString::fromUtf8(pName), uno::Reference<xml::sax::XAttributeList>(pAttributeList.get())); + mxOutputWriter->startElement(OUString::fromUtf8(pName), + uno::Reference<xml::sax::XAttributeList>(pAttributeList.get())); } -void EPUBPackage::closeElement(const char *pName) +void EPUBPackage::closeElement(const char* pName) { assert(mxOutputWriter.is()); mxOutputWriter->endElement(OUString::fromUtf8(pName)); } -void EPUBPackage::insertCharacters(const librevenge::RVNGString &rCharacters) +void EPUBPackage::insertCharacters(const librevenge::RVNGString& rCharacters) { mxOutputWriter->characters(OUString::fromUtf8(rCharacters.cstr())); } @@ -103,15 +113,18 @@ void EPUBPackage::closeXMLFile() mxOutputStream.clear(); } -void EPUBPackage::openCSSFile(const char *pName) +void EPUBPackage::openCSSFile(const char* pName) { assert(pName); assert(!mxOutputStream.is()); - mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY); + mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName( + OUString::fromUtf8(pName), embed::ElementModes::READWRITE), + uno::UNO_QUERY); } -void EPUBPackage::insertRule(const librevenge::RVNGString &rSelector, const librevenge::RVNGPropertyList &rProperties) +void EPUBPackage::insertRule(const librevenge::RVNGString& rSelector, + const librevenge::RVNGPropertyList& rProperties) { assert(mxOutputStream.is()); @@ -130,7 +143,8 @@ void EPUBPackage::insertRule(const librevenge::RVNGString &rSelector, const libr aStream << "}\n"; std::string aString = aStream.str(); - uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8 *>(aString.c_str()), aString.size()); + uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8*>(aString.c_str()), + aString.size()); mxOutputStream->writeBytes(aData); } @@ -143,22 +157,25 @@ void EPUBPackage::closeCSSFile() mxOutputStream.clear(); } -void EPUBPackage::openBinaryFile(const char *pName) +void EPUBPackage::openBinaryFile(const char* pName) { assert(pName); assert(!mxOutputStream.is()); - mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY); + mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName( + OUString::fromUtf8(pName), embed::ElementModes::READWRITE), + uno::UNO_QUERY); } -void EPUBPackage::insertBinaryData(const librevenge::RVNGBinaryData &rData) +void EPUBPackage::insertBinaryData(const librevenge::RVNGBinaryData& rData) { assert(mxOutputStream.is()); if (rData.empty()) return; - uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8 *>(rData.getDataBuffer()), rData.size()); + uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8*>(rData.getDataBuffer()), + rData.size()); mxOutputStream->writeBytes(aData); } @@ -171,12 +188,12 @@ void EPUBPackage::closeBinaryFile() mxOutputStream.clear(); } -void EPUBPackage::openTextFile(const char *pName) +void EPUBPackage::openTextFile(const char* pName) { SAL_WARN("writerperfect", "EPUBPackage::openTextFile, " << pName << ": implement me"); } -void EPUBPackage::insertText(const librevenge::RVNGString &/*rCharacters*/) +void EPUBPackage::insertText(const librevenge::RVNGString& /*rCharacters*/) { SAL_WARN("writerperfect", "EPUBPackage::insertText: implement me"); } diff --git a/writerperfect/source/writer/EPUBPackage.hxx b/writerperfect/source/writer/EPUBPackage.hxx index 5cb5f6dbefce..e7d135648326 100644 --- a/writerperfect/source/writer/EPUBPackage.hxx +++ b/writerperfect/source/writer/EPUBPackage.hxx @@ -20,7 +20,6 @@ namespace writerperfect { - /// The epub package has direct access to the resulting ZIP file. class EPUBPackage : public libepubgen::EPUBPackage { @@ -30,34 +29,36 @@ class EPUBPackage : public libepubgen::EPUBPackage css::uno::Reference<css::xml::sax::XWriter> mxOutputWriter; public: - explicit EPUBPackage(css::uno::Reference<css::uno::XComponentContext> xContext, const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor); + explicit EPUBPackage(css::uno::Reference<css::uno::XComponentContext> xContext, + const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor); ~EPUBPackage() override; - void openXMLFile(const char *pName) override; + void openXMLFile(const char* pName) override; - void openElement(const char *pName, const librevenge::RVNGPropertyList &rAttributes) override; - void closeElement(const char *pName) override; + void openElement(const char* pName, const librevenge::RVNGPropertyList& rAttributes) override; + void closeElement(const char* pName) override; - void insertCharacters(const librevenge::RVNGString &rCharacters) override; + void insertCharacters(const librevenge::RVNGString& rCharacters) override; void closeXMLFile() override; - void openCSSFile(const char *pName) override; + void openCSSFile(const char* pName) override; - void insertRule(const librevenge::RVNGString &rSelector, const librevenge::RVNGPropertyList &rProperties) override; + void insertRule(const librevenge::RVNGString& rSelector, + const librevenge::RVNGPropertyList& rProperties) override; void closeCSSFile() override; - void openBinaryFile(const char *pName) override; + void openBinaryFile(const char* pName) override; - void insertBinaryData(const librevenge::RVNGBinaryData &rData) override; + void insertBinaryData(const librevenge::RVNGBinaryData& rData) override; void closeBinaryFile() override; - void openTextFile(const char *pName) override; + void openTextFile(const char* pName) override; - void insertText(const librevenge::RVNGString &rCharacters) override; + void insertText(const librevenge::RVNGString& rCharacters) override; void insertLineBreak() override; diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx index 9af6027b3e75..c22474d190bc 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.cxx +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -18,77 +18,83 @@ #include "MSWorksImportFilter.hxx" #include <strings.hrc> -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedWKSObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedWKSObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, const OdfStreamType streamType) { OdsGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); - return libwps::WPSDocument::parse(data.getDataStream(), &exporter)==libwps::WPS_OK; + return libwps::WPSDocument::parse(data.getDataStream(), &exporter) == libwps::WPS_OK; } -bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &) +bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdtGenerator& rGenerator, utl::MediaDescriptor&) { libwps::WPSKind kind = libwps::WPS_TEXT; libwps::WPSCreator creator; bool needEncoding = false; - const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); + const libwps::WPSConfidence confidence + = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); std::string fileEncoding; try { - if ((kind == libwps::WPS_TEXT) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) && needEncoding) + if ((kind == libwps::WPS_TEXT) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT) + && needEncoding) { OUString title, encoding; switch (creator) { - case libwps::WPS_MSWORKS: - title = WpResId(STR_ENCODING_DIALOG_TITLE_MSWORKS); - encoding = "CP850"; - break; - case libwps::WPS_RESERVED_0: // MS Write - title = WpResId(STR_ENCODING_DIALOG_TITLE_MSWRITE); - encoding = "CP1252"; - break; - case libwps::WPS_RESERVED_1: // DosWord - title = WpResId(STR_ENCODING_DIALOG_TITLE_DOSWORD); - encoding = "CP850"; - break; - default: - title = WpResId(STR_ENCODING_DIALOG_TITLE); - encoding = "CP850"; - break; + case libwps::WPS_MSWORKS: + title = WpResId(STR_ENCODING_DIALOG_TITLE_MSWORKS); + encoding = "CP850"; + break; + case libwps::WPS_RESERVED_0: // MS Write + title = WpResId(STR_ENCODING_DIALOG_TITLE_MSWRITE); + encoding = "CP1252"; + break; + case libwps::WPS_RESERVED_1: // DosWord + title = WpResId(STR_ENCODING_DIALOG_TITLE_DOSWORD); + encoding = "CP850"; + break; + default: + title = WpResId(STR_ENCODING_DIALOG_TITLE); + encoding = "CP850"; + break; } const ScopedVclPtrInstance<writerperfect::WPFTEncodingDialog> pDlg(title, encoding); if (pDlg->Execute() == RET_OK) { if (!pDlg->GetEncoding().isEmpty()) - fileEncoding=pDlg->GetEncoding().toUtf8().getStr(); + fileEncoding = pDlg->GetEncoding().toUtf8().getStr(); } // we can fail because we are in headless mode, the user has cancelled conversion, ... else if (pDlg->hasUserCalledCancel()) return false; } } - catch (css::uno::Exception &e) + catch (css::uno::Exception& e) { SAL_WARN("writerperfect", "ignoring " << e); } - return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator, "", fileEncoding.c_str()); + return libwps::WPS_OK + == libwps::WPSDocument::parse(&rInput, &rGenerator, "", fileEncoding.c_str()); } -bool MSWorksImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MSWorksImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { libwps::WPSKind kind = libwps::WPS_TEXT; libwps::WPSCreator creator; bool needEncoding; - const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); + const libwps::WPSConfidence confidence + = libwps::WPSDocument::isFileFormatSupported(&rInput, kind, creator, needEncoding); if ((kind == libwps::WPS_TEXT) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT)) { @@ -111,7 +117,7 @@ bool MSWorksImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OU return false; } -void MSWorksImportFilter::doRegisterHandlers(OdtGenerator &rGenerator) +void MSWorksImportFilter::doRegisterHandlers(OdtGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/wks-ods", &handleEmbeddedWKSObject); } @@ -122,25 +128,23 @@ OUString SAL_CALL MSWorksImportFilter::getImplementationName() return OUString("com.sun.star.comp.Writer.MSWorksImportFilter"); } -sal_Bool SAL_CALL MSWorksImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MSWorksImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MSWorksImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MSWorksImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Writer_MSWorksImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MSWorksImportFilter(context)); } diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx index faa4096c9ab6..f9caea858b24 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.hxx +++ b/writerperfect/source/writer/MSWorksImportFilter.hxx @@ -23,18 +23,21 @@ class MSWorksImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit MSWorksImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit MSWorksImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdtGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/writer/MWAWImportFilter.cxx b/writerperfect/source/writer/MWAWImportFilter.cxx index b8bf3b51223e..7b166930cea1 100644 --- a/writerperfect/source/writer/MWAWImportFilter.cxx +++ b/writerperfect/source/writer/MWAWImportFilter.cxx @@ -15,19 +15,23 @@ #include "MWAWImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdgGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeGraphic(data, &exporter); } -static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; exporter.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); @@ -35,18 +39,20 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &) +bool MWAWImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdtGenerator& rGenerator, utl::MediaDescriptor&) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } -bool MWAWImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool MWAWImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { rTypeName.clear(); MWAWDocument::Type docType = MWAWDocument::MWAW_T_UNKNOWN; MWAWDocument::Kind docKind = MWAWDocument::MWAW_K_UNKNOWN; - const MWAWDocument::Confidence confidence = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); + const MWAWDocument::Confidence confidence + = MWAWDocument::isFileFormatSupported(&rInput, docType, docKind); if (confidence == MWAWDocument::MWAW_C_EXCELLENT) { @@ -54,28 +60,28 @@ bool MWAWImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUStr { switch (docType) { - case MWAWDocument::MWAW_T_CLARISWORKS: - rTypeName = "writer_ClarisWorks"; - break; - case MWAWDocument::MWAW_T_MACWRITE: - case MWAWDocument::MWAW_T_MACWRITEPRO: - rTypeName = "writer_MacWrite"; - break; - case MWAWDocument::MWAW_T_MARINERWRITE: - rTypeName = "writer_Mariner_Write"; - break; - case MWAWDocument::MWAW_T_MICROSOFTWORD: - rTypeName = "writer_Mac_Word"; - break; - case MWAWDocument::MWAW_T_MICROSOFTWORKS: - rTypeName = "writer_Mac_Works"; - break; - case MWAWDocument::MWAW_T_WRITENOW: - rTypeName = "writer_WriteNow"; - break; - default: - rTypeName = "MWAW_Text_Document"; - break; + case MWAWDocument::MWAW_T_CLARISWORKS: + rTypeName = "writer_ClarisWorks"; + break; + case MWAWDocument::MWAW_T_MACWRITE: + case MWAWDocument::MWAW_T_MACWRITEPRO: + rTypeName = "writer_MacWrite"; + break; + case MWAWDocument::MWAW_T_MARINERWRITE: + rTypeName = "writer_Mariner_Write"; + break; + case MWAWDocument::MWAW_T_MICROSOFTWORD: + rTypeName = "writer_Mac_Word"; + break; + case MWAWDocument::MWAW_T_MICROSOFTWORKS: + rTypeName = "writer_Mac_Works"; + break; + case MWAWDocument::MWAW_T_WRITENOW: + rTypeName = "writer_WriteNow"; + break; + default: + rTypeName = "MWAW_Text_Document"; + break; } } } @@ -83,10 +89,11 @@ bool MWAWImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUStr return !rTypeName.isEmpty(); } -void MWAWImportFilter::doRegisterHandlers(OdtGenerator &rGenerator) +void MWAWImportFilter::doRegisterHandlers(OdtGenerator& rGenerator) { rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", + &handleEmbeddedMWAWSpreadsheetObject); } // XServiceInfo @@ -95,25 +102,23 @@ OUString SAL_CALL MWAWImportFilter::getImplementationName() return OUString("com.sun.star.comp.Writer.MWAWImportFilter"); } -sal_Bool SAL_CALL MWAWImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL MWAWImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL MWAWImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL MWAWImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Writer_MWAWImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new MWAWImportFilter(context)); } diff --git a/writerperfect/source/writer/MWAWImportFilter.hxx b/writerperfect/source/writer/MWAWImportFilter.hxx index 0ddd1bd1c7a5..5ea1ad0c2bcf 100644 --- a/writerperfect/source/writer/MWAWImportFilter.hxx +++ b/writerperfect/source/writer/MWAWImportFilter.hxx @@ -23,18 +23,21 @@ class MWAWImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit MWAWImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit MWAWImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdtGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/writer/PagesImportFilter.cxx b/writerperfect/source/writer/PagesImportFilter.cxx index abcb3eb08764..6ff8cd1420f6 100644 --- a/writerperfect/source/writer/PagesImportFilter.cxx +++ b/writerperfect/source/writer/PagesImportFilter.cxx @@ -15,23 +15,25 @@ #include "PagesImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::XInterface; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; using libetonyek::EtonyekDocument; -bool PagesImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdtGenerator &rGenerator, utl::MediaDescriptor &) +bool PagesImportFilter::doImportDocument(librevenge::RVNGInputStream& rInput, + OdtGenerator& rGenerator, utl::MediaDescriptor&) { return EtonyekDocument::parse(&rInput, &rGenerator); } -bool PagesImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +bool PagesImportFilter::doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) { EtonyekDocument::Type type = EtonyekDocument::TYPE_UNKNOWN; const EtonyekDocument::Confidence confidence = EtonyekDocument::isSupported(&rInput, &type); - if ((confidence == EtonyekDocument::CONFIDENCE_EXCELLENT) && (type == EtonyekDocument::TYPE_PAGES)) + if ((confidence == EtonyekDocument::CONFIDENCE_EXCELLENT) + && (type == EtonyekDocument::TYPE_PAGES)) { rTypeName = "writer_ApplePages"; return true; @@ -46,25 +48,23 @@ OUString SAL_CALL PagesImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Writer.PagesImportFilter"); } -sal_Bool SAL_CALL PagesImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL PagesImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL PagesImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL PagesImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Writer_PagesImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new PagesImportFilter(context)); } diff --git a/writerperfect/source/writer/PagesImportFilter.hxx b/writerperfect/source/writer/PagesImportFilter.hxx index 376c9ff4430c..03cbefe9f3f6 100644 --- a/writerperfect/source/writer/PagesImportFilter.hxx +++ b/writerperfect/source/writer/PagesImportFilter.hxx @@ -22,17 +22,20 @@ class PagesImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit PagesImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit PagesImportFilter(const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &rDescriptor) override; + virtual bool doDetectFormat(librevenge::RVNGInputStream& rInput, OUString& rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream& rInput, OdtGenerator& rGenerator, + utl::MediaDescriptor& rDescriptor) override; }; #endif diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx index 1f3cccaac35f..95764afa4013 100644 --- a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx +++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx @@ -15,32 +15,39 @@ #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::Sequence; using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; -static bool handleEmbeddedSTOFFWriterGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +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) +static bool handleEmbeddedSTOFFWriterSpreadsheetObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, + const OdfStreamType streamType) { OdsGenerator exporter; - exporter.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFWriterGraphicObject); + 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 &) +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); + const STOFFDocument::Confidence confidence + = STOFFDocument::isFileFormatSupported(&rInput, docKind); OString aUtf8Passwd; - if (confidence==STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) + if (confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) { // try to ask for a password try @@ -57,35 +64,42 @@ bool StarOfficeWriterImportFilter::doImportDocument(librevenge::RVNGInputStream // ok, we will probably guess it } } - return STOFFDocument::STOFF_R_OK == STOFFDocument::parse(&rInput, &rGenerator, !aUtf8Passwd.isEmpty() ? aUtf8Passwd.getStr() : nullptr); + return STOFFDocument::STOFF_R_OK + == STOFFDocument::parse(&rInput, &rGenerator, + !aUtf8Passwd.isEmpty() ? aUtf8Passwd.getStr() : nullptr); } -bool StarOfficeWriterImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +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); + const STOFFDocument::Confidence confidence + = STOFFDocument::isFileFormatSupported(&rInput, docKind); - if (confidence == STOFFDocument::STOFF_C_EXCELLENT|| confidence == STOFFDocument::STOFF_C_SUPPORTED_ENCRYPTION) + 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; + case STOFFDocument::STOFF_K_TEXT: + rTypeName = "StarOffice_Writer"; + break; + default: + break; } } return !rTypeName.isEmpty(); } -void StarOfficeWriterImportFilter::doRegisterHandlers(OdtGenerator &rGenerator) +void StarOfficeWriterImportFilter::doRegisterHandlers(OdtGenerator& rGenerator) { - rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", &handleEmbeddedSTOFFWriterGraphicObject); - rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", &handleEmbeddedSTOFFWriterSpreadsheetObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-odg", + &handleEmbeddedSTOFFWriterGraphicObject); + rGenerator.registerEmbeddedObjectHandler("image/stoff-ods", + &handleEmbeddedSTOFFWriterSpreadsheetObject); } // XServiceInfo @@ -94,21 +108,20 @@ OUString SAL_CALL StarOfficeWriterImportFilter::getImplementationName() return OUString("org.libreoffice.comp.Writer.StarOfficeWriterImportFilter"); } -sal_Bool SAL_CALL StarOfficeWriterImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL StarOfficeWriterImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL StarOfficeWriterImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL StarOfficeWriterImportFilter::getSupportedServiceNames() { - return Sequence< OUString > {"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; + return Sequence<OUString>{ "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; } -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* org_libreoffice_comp_Writer_StarOfficeWriterImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new StarOfficeWriterImportFilter(context)); } diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx index 3202c77eda31..c84602ed8a8c 100644 --- a/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx +++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.hxx @@ -23,18 +23,22 @@ class StarOfficeWriterImportFilter : public writerperfect::ImportFilter<OdtGenerator> { public: - explicit StarOfficeWriterImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : writerperfect::ImportFilter<OdtGenerator>(rxContext) {} + explicit StarOfficeWriterImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : writerperfect::ImportFilter<OdtGenerator>(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; + 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, OdtGenerator &rGenerator, utl::MediaDescriptor &) override; - virtual void doRegisterHandlers(OdtGenerator &rGenerator) override; + 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 diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx index 4c6fc27060c6..4b0861c0d9da 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.cxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -31,25 +31,26 @@ #include "WordPerfectImportFilter.hxx" -using com::sun::star::uno::Sequence; -using com::sun::star::uno::Reference; +using com::sun::star::beans::PropertyValue; +using com::sun::star::document::XExtendedFilterDetection; using com::sun::star::uno::Any; -using com::sun::star::uno::UNO_QUERY; -using com::sun::star::uno::XInterface; using com::sun::star::uno::Exception; +using com::sun::star::uno::Reference; using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::XComponentContext; -using com::sun::star::beans::PropertyValue; -using com::sun::star::document::XExtendedFilterDetection; +using com::sun::star::uno::XInterface; -using com::sun::star::io::XInputStream; using com::sun::star::document::XImporter; +using com::sun::star::io::XInputStream; using com::sun::star::xml::sax::XDocumentHandler; using writerperfect::DocumentHandler; using writerperfect::WPXSvInputStream; -static bool handleEmbeddedWPGObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedWPGObject(const librevenge::RVNGBinaryData& data, + OdfDocumentHandler* pHandler, const OdfStreamType streamType) { OdgGenerator exporter; exporter.addDocumentHandler(pHandler, streamType); @@ -62,7 +63,8 @@ static bool handleEmbeddedWPGObject(const librevenge::RVNGBinaryData &data, OdfD return libwpg::WPGraphics::parse(data.getDataStream(), &exporter, fileFormat); } -static bool handleEmbeddedWPGImage(const librevenge::RVNGBinaryData &input, librevenge::RVNGBinaryData &output) +static bool handleEmbeddedWPGImage(const librevenge::RVNGBinaryData& input, + librevenge::RVNGBinaryData& output) { libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; @@ -81,16 +83,16 @@ static bool handleEmbeddedWPGImage(const librevenge::RVNGBinaryData &input, libr assert(1 == svgOutput.size()); output.clear(); - output.append(reinterpret_cast<const unsigned char *>(svgOutput[0].cstr()), svgOutput[0].size()); + output.append(reinterpret_cast<const unsigned char*>(svgOutput[0].cstr()), svgOutput[0].size()); return true; } -bool WordPerfectImportFilter::importImpl(const Sequence< css::beans::PropertyValue > &aDescriptor) +bool WordPerfectImportFilter::importImpl(const Sequence<css::beans::PropertyValue>& aDescriptor) { sal_Int32 nLength = aDescriptor.getLength(); - const PropertyValue *pValue = aDescriptor.getConstArray(); - Reference < XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) + const PropertyValue* pValue = aDescriptor.getConstArray(); + Reference<XInputStream> xInputStream; + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "InputStream") pValue[i].Value >>= xInputStream; @@ -118,7 +120,8 @@ bool WordPerfectImportFilter::importImpl(const Sequence< css::beans::PropertyVal return false; OUString aPasswd = aPasswdDlg.GetPassword(); aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); - if (libwpd::WPD_PASSWORD_MATCH_OK == libwpd::WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) + if (libwpd::WPD_PASSWORD_MATCH_OK + == libwpd::WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) break; else unsuccessfulAttempts++; @@ -128,13 +131,13 @@ bool WordPerfectImportFilter::importImpl(const Sequence< css::beans::PropertyVal } // An XML import service: what we push sax messages to. - Reference < XDocumentHandler > xInternalHandler( + Reference<XDocumentHandler> xInternalHandler( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.Writer.XMLOasisImporter", mxContext), css::uno::UNO_QUERY_THROW); // The XImporter sets up an empty target document for XDocumentHandler to write to. - Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY); + Reference<XImporter> xImporter(xInternalHandler, UNO_QUERY); xImporter->setTargetDocument(mxDoc); // OO Document Handler: abstract class to handle document SAX messages, concrete implementation here @@ -145,36 +148,38 @@ bool WordPerfectImportFilter::importImpl(const Sequence< css::beans::PropertyVal collector.addDocumentHandler(&aHandler, ODF_FLAT_XML); collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject); collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage); - return libwpd::WPD_OK == libwpd::WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? nullptr : aUtf8Passwd.getStr()); + return libwpd::WPD_OK + == libwpd::WPDocument::parse(&input, &collector, + aUtf8Passwd.isEmpty() ? nullptr : aUtf8Passwd.getStr()); } -sal_Bool SAL_CALL WordPerfectImportFilter::filter(const Sequence< css::beans::PropertyValue > &aDescriptor) +sal_Bool SAL_CALL +WordPerfectImportFilter::filter(const Sequence<css::beans::PropertyValue>& aDescriptor) { return importImpl(aDescriptor); } -void SAL_CALL WordPerfectImportFilter::cancel() -{ -} +void SAL_CALL WordPerfectImportFilter::cancel() {} // XImporter -void SAL_CALL WordPerfectImportFilter::setTargetDocument(const Reference< css::lang::XComponent > &xDoc) +void SAL_CALL +WordPerfectImportFilter::setTargetDocument(const Reference<css::lang::XComponent>& xDoc) { mxDoc = xDoc; } // XExtendedFilterDetection -OUString SAL_CALL WordPerfectImportFilter::detect(Sequence< PropertyValue > &Descriptor) +OUString SAL_CALL WordPerfectImportFilter::detect(Sequence<PropertyValue>& Descriptor) { libwpd::WPDConfidence confidence = libwpd::WPD_CONFIDENCE_NONE; OUString sTypeName; sal_Int32 nLength = Descriptor.getLength(); sal_Int32 location = nLength; - const PropertyValue *pValue = Descriptor.getConstArray(); - Reference < XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) + const PropertyValue* pValue = Descriptor.getConstArray(); + Reference<XInputStream> xInputStream; + for (sal_Int32 i = 0; i < nLength; i++) { if (pValue[i].Name == "TypeName") - location=i; + location = i; else if (pValue[i].Name == "InputStream") pValue[i].Value >>= xInputStream; } @@ -186,28 +191,26 @@ OUString SAL_CALL WordPerfectImportFilter::detect(Sequence< PropertyValue > &Des confidence = libwpd::WPDocument::isFileFormatSupported(&input); - if (confidence == libwpd::WPD_CONFIDENCE_EXCELLENT || confidence == libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) + if (confidence == libwpd::WPD_CONFIDENCE_EXCELLENT + || confidence == libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) sTypeName = "writer_WordPerfect_Document"; if (!sTypeName.isEmpty()) { if (location == nLength) { - Descriptor.realloc(nLength+1); + Descriptor.realloc(nLength + 1); Descriptor[location].Name = "TypeName"; } - Descriptor[location].Value <<=sTypeName; + Descriptor[location].Value <<= sTypeName; } return sTypeName; } - // XInitialization -void SAL_CALL WordPerfectImportFilter::initialize(const Sequence< Any > &/*aArguments*/) -{ -} +void SAL_CALL WordPerfectImportFilter::initialize(const Sequence<Any>& /*aArguments*/) {} // XServiceInfo OUString SAL_CALL WordPerfectImportFilter::getImplementationName() @@ -215,26 +218,23 @@ OUString SAL_CALL WordPerfectImportFilter::getImplementationName() return OUString("com.sun.star.comp.Writer.WordPerfectImportFilter"); } -sal_Bool SAL_CALL WordPerfectImportFilter::supportsService(const OUString &rServiceName) +sal_Bool SAL_CALL WordPerfectImportFilter::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -Sequence< OUString > SAL_CALL WordPerfectImportFilter::getSupportedServiceNames() +Sequence<OUString> SAL_CALL WordPerfectImportFilter::getSupportedServiceNames() { - Sequence < OUString > aRet(2); - OUString *pArray = aRet.getArray(); - pArray[0] = "com.sun.star.document.ImportFilter"; - pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; + Sequence<OUString> aRet(2); + OUString* pArray = aRet.getArray(); + pArray[0] = "com.sun.star.document.ImportFilter"; + pArray[1] = "com.sun.star.document.ExtendedTypeDetection"; return aRet; } - -extern "C" -SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_Writer_WordPerfectImportFilter_get_implementation( - css::uno::XComponentContext *const context, - const css::uno::Sequence<css::uno::Any> &) + css::uno::XComponentContext* const context, const css::uno::Sequence<css::uno::Any>&) { return cppu::acquire(new WordPerfectImportFilter(context)); } diff --git a/writerperfect/source/writer/WordPerfectImportFilter.hxx b/writerperfect/source/writer/WordPerfectImportFilter.hxx index 731fe5230228..163da40b5035 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.hxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.hxx @@ -25,43 +25,44 @@ /* 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 WordPerfectImportFilter : public cppu::WeakImplHelper - < - css::document::XFilter, - css::document::XImporter, - css::document::XExtendedFilterDetection, - css::lang::XInitialization, - css::lang::XServiceInfo - > +class WordPerfectImportFilter + : public cppu::WeakImplHelper<css::document::XFilter, css::document::XImporter, + css::document::XExtendedFilterDetection, + css::lang::XInitialization, css::lang::XServiceInfo> { - css::uno::Reference< css::uno::XComponentContext > mxContext; - css::uno::Reference< css::lang::XComponent > mxDoc; + css::uno::Reference<css::uno::XComponentContext> mxContext; + css::uno::Reference<css::lang::XComponent> mxDoc; /// @throws css::uno::RuntimeException - bool importImpl(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor); + bool importImpl(const css::uno::Sequence<css::beans::PropertyValue>& aDescriptor); public: - explicit WordPerfectImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) - : mxContext(rxContext) {} + explicit WordPerfectImportFilter( + const css::uno::Reference<css::uno::XComponentContext>& rxContext) + : mxContext(rxContext) + { + } // XFilter - virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor) override; + virtual sal_Bool SAL_CALL + filter(const css::uno::Sequence<css::beans::PropertyValue>& aDescriptor) override; virtual void SAL_CALL cancel() override; // XImporter - virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override; + virtual void SAL_CALL + setTargetDocument(const css::uno::Reference<css::lang::XComponent>& xDoc) override; //XExtendedFilterDetection - virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) override; + virtual OUString SAL_CALL + detect(css::uno::Sequence<css::beans::PropertyValue>& Descriptor) override; // XInitialization - virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override; + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override; // 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; - + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; }; #endif diff --git a/writerperfect/source/writer/exp/XMLBase64ImportContext.cxx b/writerperfect/source/writer/exp/XMLBase64ImportContext.cxx index 137bf01aff01..e7161e5295cf 100644 --- a/writerperfect/source/writer/exp/XMLBase64ImportContext.cxx +++ b/writerperfect/source/writer/exp/XMLBase64ImportContext.cxx @@ -17,22 +17,24 @@ namespace writerperfect { namespace exp { - -XMLBase64ImportContext::XMLBase64ImportContext(XMLImport &rImport) +XMLBase64ImportContext::XMLBase64ImportContext(XMLImport& rImport) : XMLImportContext(rImport) { } -void XMLBase64ImportContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLBase64ImportContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { } -void XMLBase64ImportContext::endElement(const OUString &/*rName*/) +void XMLBase64ImportContext::endElement(const OUString& /*rName*/) { - m_aBinaryData.append(static_cast<const unsigned char *>(m_aStream.GetBuffer()), m_aStream.GetSize()); + m_aBinaryData.append(static_cast<const unsigned char*>(m_aStream.GetBuffer()), + m_aStream.GetSize()); } -void XMLBase64ImportContext::characters(const OUString &rChars) +void XMLBase64ImportContext::characters(const OUString& rChars) { OUString aTrimmedChars(rChars.trim()); @@ -56,7 +58,7 @@ void XMLBase64ImportContext::characters(const OUString &rChars) } } -const librevenge::RVNGBinaryData &XMLBase64ImportContext::getBinaryData() const +const librevenge::RVNGBinaryData& XMLBase64ImportContext::getBinaryData() const { return m_aBinaryData; } diff --git a/writerperfect/source/writer/exp/XMLBase64ImportContext.hxx b/writerperfect/source/writer/exp/XMLBase64ImportContext.hxx index 6ad850a825c1..1fc1325fd2ce 100644 --- a/writerperfect/source/writer/exp/XMLBase64ImportContext.hxx +++ b/writerperfect/source/writer/exp/XMLBase64ImportContext.hxx @@ -20,18 +20,19 @@ namespace writerperfect { namespace exp { - /// Handler for <office:binary-data>. class XMLBase64ImportContext : public XMLImportContext { public: - XMLBase64ImportContext(XMLImport &rImport); + XMLBase64ImportContext(XMLImport& rImport); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; - const librevenge::RVNGBinaryData &getBinaryData() const; + const librevenge::RVNGBinaryData& getBinaryData() const; private: librevenge::RVNGBinaryData m_aBinaryData; diff --git a/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx b/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx index f8ac4d1bb082..e23f60932773 100644 --- a/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx +++ b/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx @@ -22,29 +22,29 @@ namespace exp class XMLTextNoteCitationContext : public XMLImportContext { public: - XMLTextNoteCitationContext(XMLImport &rImport, librevenge::RVNGPropertyList &rProperties); + XMLTextNoteCitationContext(XMLImport& rImport, librevenge::RVNGPropertyList& rProperties); - void SAL_CALL characters(const OUString &rCharacters) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL characters(const OUString& rCharacters) override; + void SAL_CALL endElement(const OUString& rName) override; private: - librevenge::RVNGPropertyList &m_rProperties; + librevenge::RVNGPropertyList& m_rProperties; OUString m_aCharacters; }; -XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport &rImport, - librevenge::RVNGPropertyList &rProperties) +XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport& rImport, + librevenge::RVNGPropertyList& rProperties) : XMLImportContext(rImport) , m_rProperties(rProperties) { } -void XMLTextNoteCitationContext::endElement(const OUString & /*rName*/) +void XMLTextNoteCitationContext::endElement(const OUString& /*rName*/) { m_rProperties.insert("librevenge:number", m_aCharacters.toUtf8().getStr()); } -void XMLTextNoteCitationContext::characters(const OUString &rCharacters) +void XMLTextNoteCitationContext::characters(const OUString& rCharacters) { m_aCharacters += rCharacters; } @@ -53,54 +53,54 @@ void XMLTextNoteCitationContext::characters(const OUString &rCharacters) class XMLFootnoteBodyImportContext : public XMLImportContext { public: - XMLFootnoteBodyImportContext(XMLImport &rImport, - const librevenge::RVNGPropertyList &rProperties); + XMLFootnoteBodyImportContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rProperties); rtl::Reference<XMLImportContext> - CreateChildContext(const OUString &rName, - const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; void SAL_CALL - startElement(const OUString &rName, - const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; private: - const librevenge::RVNGPropertyList &m_rProperties; + const librevenge::RVNGPropertyList& m_rProperties; }; XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext( - XMLImport &rImport, const librevenge::RVNGPropertyList &rProperties) + XMLImport& rImport, const librevenge::RVNGPropertyList& rProperties) : XMLImportContext(rImport) , m_rProperties(rProperties) { } rtl::Reference<XMLImportContext> XMLFootnoteBodyImportContext::CreateChildContext( - const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> & /*xAttribs*/) + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateTextChildContext(mrImport, rName); } void XMLFootnoteBodyImportContext::startElement( - const OUString & /*rName*/, - const css::uno::Reference<css::xml::sax::XAttributeList> & /*xAttribs*/) + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openFootnote(m_rProperties); } -void XMLFootnoteBodyImportContext::endElement(const OUString & /*rName*/) +void XMLFootnoteBodyImportContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeFootnote(); } -XMLFootnoteImportContext::XMLFootnoteImportContext(XMLImport &rImport) +XMLFootnoteImportContext::XMLFootnoteImportContext(XMLImport& rImport) : XMLImportContext(rImport) { } rtl::Reference<XMLImportContext> XMLFootnoteImportContext::CreateChildContext( - const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> & /*xAttribs*/) + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "text:note-citation") return new XMLTextNoteCitationContext(mrImport, m_aProperties); @@ -111,8 +111,8 @@ rtl::Reference<XMLImportContext> XMLFootnoteImportContext::CreateChildContext( } void XMLFootnoteImportContext::startElement( - const OUString & /*rName*/, - const css::uno::Reference<css::xml::sax::XAttributeList> & /*xAttribs*/) + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { } } // namespace exp diff --git a/writerperfect/source/writer/exp/XMLFootnoteImportContext.hxx b/writerperfect/source/writer/exp/XMLFootnoteImportContext.hxx index 489288a6387f..22594f2ddd76 100644 --- a/writerperfect/source/writer/exp/XMLFootnoteImportContext.hxx +++ b/writerperfect/source/writer/exp/XMLFootnoteImportContext.hxx @@ -24,15 +24,15 @@ namespace exp class XMLFootnoteImportContext : public XMLImportContext { public: - XMLFootnoteImportContext(XMLImport &rImport); + XMLFootnoteImportContext(XMLImport& rImport); rtl::Reference<XMLImportContext> - CreateChildContext(const OUString &rName, - const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; void SAL_CALL - startElement(const OUString &rName, - const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: librevenge::RVNGPropertyList m_aProperties; diff --git a/writerperfect/source/writer/exp/XMLSectionContext.cxx b/writerperfect/source/writer/exp/XMLSectionContext.cxx index 9d3621c4f346..bf88d0e174fb 100644 --- a/writerperfect/source/writer/exp/XMLSectionContext.cxx +++ b/writerperfect/source/writer/exp/XMLSectionContext.cxx @@ -18,23 +18,25 @@ namespace writerperfect { namespace exp { - -XMLSectionContext::XMLSectionContext(XMLImport &rImport) +XMLSectionContext::XMLSectionContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLSectionContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLSectionContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateTextChildContext(mrImport, rName); } -void XMLSectionContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLSectionContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openSection(librevenge::RVNGPropertyList()); } -void XMLSectionContext::endElement(const OUString &/*rName*/) +void XMLSectionContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeSection(); } diff --git a/writerperfect/source/writer/exp/XMLSectionContext.hxx b/writerperfect/source/writer/exp/XMLSectionContext.hxx index 9eeb69a311b4..20c4047c0c2e 100644 --- a/writerperfect/source/writer/exp/XMLSectionContext.hxx +++ b/writerperfect/source/writer/exp/XMLSectionContext.hxx @@ -16,16 +16,19 @@ namespace writerperfect { namespace exp { - /// Handler for <text:section>. class XMLSectionContext : public XMLImportContext { public: - XMLSectionContext(XMLImport &rImport); - - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + XMLSectionContext(XMLImport& rImport); + + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx index 78ea1b4d1e4b..37848e668593 100644 --- a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx +++ b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx @@ -20,35 +20,41 @@ namespace writerperfect { namespace exp { - /// Handler for <draw:text-box>. class XMLTextBoxContext : public XMLImportContext { public: - XMLTextBoxContext(XMLImport &rImport); + XMLTextBoxContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; }; -XMLTextBoxContext::XMLTextBoxContext(XMLImport &rImport) +XMLTextBoxContext::XMLTextBoxContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTextBoxContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextBoxContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateTextChildContext(mrImport, rName); } -void XMLTextBoxContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLTextBoxContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openTextBox(librevenge::RVNGPropertyList()); } -void XMLTextBoxContext::endElement(const OUString &/*rName*/) +void XMLTextBoxContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeTextBox(); } @@ -57,24 +63,29 @@ void XMLTextBoxContext::endElement(const OUString &/*rName*/) class XMLTextImageContext : public XMLImportContext { public: - XMLTextImageContext(XMLImport &rImport); + XMLTextImageContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; private: OString m_aMimeType; rtl::Reference<XMLBase64ImportContext> m_xBinaryData; }; -XMLTextImageContext::XMLTextImageContext(XMLImport &rImport) +XMLTextImageContext::XMLTextImageContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTextImageContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextImageContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "office:binary-data") { @@ -84,17 +95,18 @@ rtl::Reference<XMLImportContext> XMLTextImageContext::CreateChildContext(const O return nullptr; } -void XMLTextImageContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTextImageContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); if (rAttributeName == "loext:mime-type") m_aMimeType = OUStringToOString(xAttribs->getValueByIndex(i), RTL_TEXTENCODING_UTF8); } } -void XMLTextImageContext::endElement(const OUString &/*rName*/) +void XMLTextImageContext::endElement(const OUString& /*rName*/) { librevenge::RVNGPropertyList aPropertyList; @@ -105,12 +117,13 @@ void XMLTextImageContext::endElement(const OUString &/*rName*/) mrImport.GetGenerator().insertBinaryObject(aPropertyList); } -XMLTextFrameContext::XMLTextFrameContext(XMLImport &rImport) +XMLTextFrameContext::XMLTextFrameContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTextFrameContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextFrameContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "draw:image") return new XMLTextImageContext(mrImport); @@ -120,16 +133,18 @@ rtl::Reference<XMLImportContext> XMLTextFrameContext::CreateChildContext(const O return nullptr; } -void XMLTextFrameContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTextFrameContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "draw:style-name") - FillStyles(rAttributeValue, mrImport.GetAutomaticGraphicStyles(), mrImport.GetGraphicStyles(), aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticGraphicStyles(), + mrImport.GetGraphicStyles(), aPropertyList); else { OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8); @@ -140,7 +155,7 @@ void XMLTextFrameContext::startElement(const OUString &/*rName*/, const css::uno mrImport.GetGenerator().openFrame(aPropertyList); } -void XMLTextFrameContext::endElement(const OUString &/*rName*/) +void XMLTextFrameContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeFrame(); } diff --git a/writerperfect/source/writer/exp/XMLTextFrameContext.hxx b/writerperfect/source/writer/exp/XMLTextFrameContext.hxx index 076426e69ed9..fa8c52123afb 100644 --- a/writerperfect/source/writer/exp/XMLTextFrameContext.hxx +++ b/writerperfect/source/writer/exp/XMLTextFrameContext.hxx @@ -18,19 +18,22 @@ namespace writerperfect { namespace exp { - class XMLBase64ImportContext; /// Handler for <draw:frame>. class XMLTextFrameContext : public XMLImportContext { public: - XMLTextFrameContext(XMLImport &rImport); + XMLTextFrameContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/XMLTextListContext.cxx b/writerperfect/source/writer/exp/XMLTextListContext.cxx index 3a7698890759..5aae47876ec2 100644 --- a/writerperfect/source/writer/exp/XMLTextListContext.cxx +++ b/writerperfect/source/writer/exp/XMLTextListContext.cxx @@ -17,13 +17,13 @@ namespace writerperfect { namespace exp { - -XMLTextListContext::XMLTextListContext(XMLImport &rImport) +XMLTextListContext::XMLTextListContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTextListContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextListContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "text:list-item") return new XMLTextListItemContext(mrImport); diff --git a/writerperfect/source/writer/exp/XMLTextListContext.hxx b/writerperfect/source/writer/exp/XMLTextListContext.hxx index 8e9152f06058..d5145465da77 100644 --- a/writerperfect/source/writer/exp/XMLTextListContext.hxx +++ b/writerperfect/source/writer/exp/XMLTextListContext.hxx @@ -16,14 +16,15 @@ namespace writerperfect { namespace exp { - /// Handler for <text:list>. class XMLTextListContext : public XMLImportContext { public: - XMLTextListContext(XMLImport &rImport); + XMLTextListContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/XMLTextListItemContext.cxx b/writerperfect/source/writer/exp/XMLTextListItemContext.cxx index f75bb782ba6b..8651e9d8666c 100644 --- a/writerperfect/source/writer/exp/XMLTextListItemContext.cxx +++ b/writerperfect/source/writer/exp/XMLTextListItemContext.cxx @@ -18,13 +18,13 @@ namespace writerperfect { namespace exp { - -XMLTextListItemContext::XMLTextListItemContext(XMLImport &rImport) +XMLTextListItemContext::XMLTextListItemContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTextListItemContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextListItemContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "text:p" || rName == "text:h") return new XMLParaContext(mrImport); diff --git a/writerperfect/source/writer/exp/XMLTextListItemContext.hxx b/writerperfect/source/writer/exp/XMLTextListItemContext.hxx index cbca5bf7feac..c66fac6a2104 100644 --- a/writerperfect/source/writer/exp/XMLTextListItemContext.hxx +++ b/writerperfect/source/writer/exp/XMLTextListItemContext.hxx @@ -16,14 +16,15 @@ namespace writerperfect { namespace exp { - /// Handler for <text:list-item>. class XMLTextListItemContext : public XMLImportContext { public: - XMLTextListItemContext(XMLImport &rImport); + XMLTextListItemContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx index e02e83d5fdbf..f219cf711880 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.cxx @@ -17,24 +17,23 @@ using namespace com::sun::star; namespace { - /// Looks for rName in rStyles and fills rPropertyList based on that /// (rAutomaticStyles and rNamedStyles are a list of possible parents). -void FillStyle(const OUString &rName, - std::map<OUString, librevenge::RVNGPropertyList> &rStyles, - std::map<OUString, librevenge::RVNGPropertyList> &rAutomaticStyles, - std::map<OUString, librevenge::RVNGPropertyList> &rNamedStyles, - librevenge::RVNGPropertyList &rPropertyList) +void FillStyle(const OUString& rName, std::map<OUString, librevenge::RVNGPropertyList>& rStyles, + std::map<OUString, librevenge::RVNGPropertyList>& rAutomaticStyles, + std::map<OUString, librevenge::RVNGPropertyList>& rNamedStyles, + librevenge::RVNGPropertyList& rPropertyList) { auto itStyle = rStyles.find(rName); if (itStyle == rStyles.end()) return; - const librevenge::RVNGPropertyList &rStyle = itStyle->second; + const librevenge::RVNGPropertyList& rStyle = itStyle->second; if (rStyle["style:parent-style-name"]) { // Style has a parent. - OUString aParent = OStringToOUString(rStyle["style:parent-style-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8); + OUString aParent = OStringToOUString(rStyle["style:parent-style-name"]->getStr().cstr(), + RTL_TEXTENCODING_UTF8); if (!aParent.isEmpty()) writerperfect::exp::FillStyles(aParent, rAutomaticStyles, rNamedStyles, rPropertyList); } @@ -47,27 +46,26 @@ void FillStyle(const OUString &rName, rPropertyList.insert(itProp.key(), itProp()->clone()); } } - } namespace writerperfect { namespace exp { - /// Handler for <text:sequence>. class XMLTextSequenceContext : public XMLImportContext { public: - XMLTextSequenceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLTextSequenceContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; private: librevenge::RVNGPropertyList m_aPropertyList; }; -XMLTextSequenceContext::XMLTextSequenceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLTextSequenceContext::XMLTextSequenceContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLImportContext(rImport) { // Inherit properties from parent. @@ -76,7 +74,7 @@ XMLTextSequenceContext::XMLTextSequenceContext(XMLImport &rImport, const libreve m_aPropertyList.insert(itProp.key(), itProp()->clone()); } -void XMLTextSequenceContext::characters(const OUString &rChars) +void XMLTextSequenceContext::characters(const OUString& rChars) { mrImport.GetGenerator().openSpan(m_aPropertyList); @@ -90,18 +88,23 @@ void XMLTextSequenceContext::characters(const OUString &rChars) class XMLSpanContext : public XMLImportContext { public: - XMLSpanContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLSpanContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL characters(const OUString& rChars) override; private: librevenge::RVNGPropertyList m_aPropertyList; }; -XMLSpanContext::XMLSpanContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLSpanContext::XMLSpanContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLImportContext(rImport) { // Inherit properties from parent. @@ -110,19 +113,22 @@ XMLSpanContext::XMLSpanContext(XMLImport &rImport, const librevenge::RVNGPropert m_aPropertyList.insert(itProp.key(), itProp()->clone()); } -rtl::Reference<XMLImportContext> XMLSpanContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLSpanContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateParagraphOrSpanChildContext(mrImport, rName, m_aPropertyList); } -void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLSpanContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "text:style-name") - FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), m_aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), + m_aPropertyList); else { OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8); @@ -132,7 +138,7 @@ void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Ref } } -void XMLSpanContext::characters(const OUString &rChars) +void XMLSpanContext::characters(const OUString& rChars) { mrImport.GetGenerator().openSpan(m_aPropertyList); @@ -146,13 +152,14 @@ void XMLSpanContext::characters(const OUString &rChars) class XMLCharContext : public XMLImportContext { public: - XMLCharContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLCharContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); protected: librevenge::RVNGPropertyList m_aPropertyList; }; -XMLCharContext::XMLCharContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLCharContext::XMLCharContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLImportContext(rImport) { // Inherit properties from parent. @@ -165,17 +172,22 @@ XMLCharContext::XMLCharContext(XMLImport &rImport, const librevenge::RVNGPropert class XMLLineBreakContext : public XMLCharContext { public: - XMLLineBreakContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLLineBreakContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; -XMLLineBreakContext::XMLLineBreakContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLLineBreakContext::XMLLineBreakContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLCharContext(rImport, rPropertyList) { } -void XMLLineBreakContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLLineBreakContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openSpan(m_aPropertyList); mrImport.GetGenerator().insertLineBreak(); @@ -186,17 +198,22 @@ void XMLLineBreakContext::startElement(const OUString &/*rName*/, const css::uno class XMLSpaceContext : public XMLCharContext { public: - XMLSpaceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLSpaceContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; -XMLSpaceContext::XMLSpaceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLSpaceContext::XMLSpaceContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLCharContext(rImport, rPropertyList) { } -void XMLSpaceContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLSpaceContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openSpan(m_aPropertyList); mrImport.GetGenerator().insertSpace(); @@ -207,17 +224,21 @@ void XMLSpaceContext::startElement(const OUString &/*rName*/, const css::uno::Re class XMLTabContext : public XMLCharContext { public: - XMLTabContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); + XMLTabContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; -XMLTabContext::XMLTabContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLTabContext::XMLTabContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList) : XMLCharContext(rImport, rPropertyList) { } -void XMLTabContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLTabContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { mrImport.GetGenerator().openSpan(m_aPropertyList); mrImport.GetGenerator().insertTab(); @@ -228,19 +249,25 @@ void XMLTabContext::startElement(const OUString &/*rName*/, const css::uno::Refe class XMLTextFrameHyperlinkContext : public XMLImportContext { public: - XMLTextFrameHyperlinkContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; + XMLTextFrameHyperlinkContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList); + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; private: librevenge::RVNGPropertyList m_aPropertyList; PopupState m_ePopupState = PopupState::NONE; }; -XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( + XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList) : XMLImportContext(rImport) { // Inherit properties from parent. @@ -249,21 +276,24 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(XMLImport &rImport, c m_aPropertyList.insert(itProp.key(), itProp()->clone()); } -rtl::Reference<XMLImportContext> XMLTextFrameHyperlinkContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTextFrameHyperlinkContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateParagraphOrSpanChildContext(mrImport, rName, m_aPropertyList); } -void XMLTextFrameHyperlinkContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTextFrameHyperlinkContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "text:style-name") // This affects the nested span's properties. - FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), m_aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), + m_aPropertyList); else { if (rAttributeName == "xlink:href") @@ -284,13 +314,13 @@ void XMLTextFrameHyperlinkContext::startElement(const OUString &/*rName*/, const mrImport.GetGenerator().openLink(aPropertyList); } -void XMLTextFrameHyperlinkContext::endElement(const OUString &/*rName*/) +void XMLTextFrameHyperlinkContext::endElement(const OUString& /*rName*/) { if (m_ePopupState != PopupState::Ignore) mrImport.GetGenerator().closeLink(); } -void XMLTextFrameHyperlinkContext::characters(const OUString &rChars) +void XMLTextFrameHyperlinkContext::characters(const OUString& rChars) { mrImport.GetGenerator().openSpan(m_aPropertyList); @@ -304,19 +334,24 @@ void XMLTextFrameHyperlinkContext::characters(const OUString &rChars) class XMLHyperlinkContext : public XMLImportContext { public: - XMLHyperlinkContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + XMLHyperlinkContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList); + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; private: librevenge::RVNGPropertyList m_aPropertyList; PopupState m_ePopupState = PopupState::NONE; }; -XMLHyperlinkContext::XMLHyperlinkContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList) +XMLHyperlinkContext::XMLHyperlinkContext(XMLImport& rImport, + const librevenge::RVNGPropertyList& rPropertyList) : XMLImportContext(rImport) { // Inherit properties from parent. @@ -325,21 +360,24 @@ XMLHyperlinkContext::XMLHyperlinkContext(XMLImport &rImport, const librevenge::R m_aPropertyList.insert(itProp.key(), itProp()->clone()); } -rtl::Reference<XMLImportContext> XMLHyperlinkContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLHyperlinkContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateParagraphOrSpanChildContext(mrImport, rName, m_aPropertyList); } -void XMLHyperlinkContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLHyperlinkContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "text:style-name") // This affects the nested span's properties. - FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), m_aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), + m_aPropertyList); else { if (rAttributeName == "xlink:href") @@ -360,13 +398,13 @@ void XMLHyperlinkContext::startElement(const OUString &/*rName*/, const css::uno mrImport.GetGenerator().openLink(aPropertyList); } -void XMLHyperlinkContext::endElement(const OUString &/*rName*/) +void XMLHyperlinkContext::endElement(const OUString& /*rName*/) { if (m_ePopupState != PopupState::Ignore) mrImport.GetGenerator().closeLink(); } -void XMLHyperlinkContext::characters(const OUString &rChars) +void XMLHyperlinkContext::characters(const OUString& rChars) { mrImport.GetGenerator().openSpan(m_aPropertyList); @@ -376,12 +414,13 @@ void XMLHyperlinkContext::characters(const OUString &rChars) mrImport.GetGenerator().closeSpan(); } -XMLParaContext::XMLParaContext(XMLImport &rImport) +XMLParaContext::XMLParaContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLParaContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLParaContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "text:a") return new XMLHyperlinkContext(mrImport, m_aTextPropertyList); @@ -390,18 +429,21 @@ rtl::Reference<XMLImportContext> XMLParaContext::CreateChildContext(const OUStri return CreateParagraphOrSpanChildContext(mrImport, rName, m_aTextPropertyList); } -void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLParaContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "text:style-name") { m_aStyleName = rAttributeValue; - FillStyles(m_aStyleName, mrImport.GetAutomaticParagraphStyles(), mrImport.GetParagraphStyles(), aPropertyList); - FillStyles(m_aStyleName, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), m_aTextPropertyList); + FillStyles(m_aStyleName, mrImport.GetAutomaticParagraphStyles(), + mrImport.GetParagraphStyles(), aPropertyList); + FillStyles(m_aStyleName, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), + m_aTextPropertyList); mrImport.HandlePageSpan(aPropertyList); } else @@ -415,16 +457,17 @@ void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Ref mrImport.GetGenerator().openParagraph(aPropertyList); } -void XMLParaContext::endElement(const OUString &/*rName*/) +void XMLParaContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeParagraph(); } -void XMLParaContext::characters(const OUString &rChars) +void XMLParaContext::characters(const OUString& rChars) { librevenge::RVNGPropertyList aPropertyList; if (!m_aStyleName.isEmpty()) - FillStyles(m_aStyleName, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), aPropertyList); + FillStyles(m_aStyleName, mrImport.GetAutomaticTextStyles(), mrImport.GetTextStyles(), + aPropertyList); mrImport.GetGenerator().openSpan(aPropertyList); OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); @@ -433,7 +476,9 @@ void XMLParaContext::characters(const OUString &rChars) mrImport.GetGenerator().closeSpan(); } -rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rImport, const OUString &rName, const librevenge::RVNGPropertyList &rTextPropertyList) +rtl::Reference<XMLImportContext> +CreateParagraphOrSpanChildContext(XMLImport& rImport, const OUString& rName, + const librevenge::RVNGPropertyList& rTextPropertyList) { if (rName == "text:span") return new XMLSpanContext(rImport, rTextPropertyList); @@ -453,10 +498,10 @@ rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rI return nullptr; } -void FillStyles(const OUString &rName, - std::map<OUString, librevenge::RVNGPropertyList> &rAutomaticStyles, - std::map<OUString, librevenge::RVNGPropertyList> &rNamedStyles, - librevenge::RVNGPropertyList &rPropertyList) +void FillStyles(const OUString& rName, + std::map<OUString, librevenge::RVNGPropertyList>& rAutomaticStyles, + std::map<OUString, librevenge::RVNGPropertyList>& rNamedStyles, + librevenge::RVNGPropertyList& rPropertyList) { FillStyle(rName, rAutomaticStyles, rAutomaticStyles, rNamedStyles, rPropertyList); FillStyle(rName, rNamedStyles, rAutomaticStyles, rNamedStyles, rPropertyList); diff --git a/writerperfect/source/writer/exp/txtparai.hxx b/writerperfect/source/writer/exp/txtparai.hxx index ace8d740397a..b87a5762b7a3 100644 --- a/writerperfect/source/writer/exp/txtparai.hxx +++ b/writerperfect/source/writer/exp/txtparai.hxx @@ -20,18 +20,21 @@ namespace writerperfect { namespace exp { - /// Handler for <text:p>/<text:h>. class XMLParaContext : public XMLImportContext { public: - XMLParaContext(XMLImport &rImport); + XMLParaContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) override; + rtl::Reference<XMLImportContext> CreateChildContext( + const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; private: OUString m_aStyleName; @@ -40,14 +43,16 @@ private: }; /// Shared child context factory for paragraph and span contexts. -rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rImport, const OUString &rName, const librevenge::RVNGPropertyList &rTextPropertyList); +rtl::Reference<XMLImportContext> +CreateParagraphOrSpanChildContext(XMLImport& rImport, const OUString& rName, + const librevenge::RVNGPropertyList& rTextPropertyList); /// Looks for rName in rAutomaticStyles (and failing that, in rNamedStyles) and /// fills rPropertyList based on that. -void FillStyles(const OUString &rName, - std::map<OUString, librevenge::RVNGPropertyList> &rAutomaticStyles, - std::map<OUString, librevenge::RVNGPropertyList> &rNamedStyles, - librevenge::RVNGPropertyList &rPropertyList); +void FillStyles(const OUString& rName, + std::map<OUString, librevenge::RVNGPropertyList>& rAutomaticStyles, + std::map<OUString, librevenge::RVNGPropertyList>& rNamedStyles, + librevenge::RVNGPropertyList& rPropertyList); } // namespace exp } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx index 90cc66b9c80b..b8b7813e08ad 100644 --- a/writerperfect/source/writer/exp/txtstyli.cxx +++ b/writerperfect/source/writer/exp/txtstyli.cxx @@ -17,26 +17,29 @@ namespace writerperfect { namespace exp { - /// Handler for <style:paragraph-properties>. class XMLParagraphPropertiesContext : public XMLImportContext { public: - XMLParagraphPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLParagraphPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLParagraphPropertiesContext::XMLParagraphPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLParagraphPropertiesContext::XMLParagraphPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLParagraphPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLParagraphPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -50,21 +53,24 @@ void XMLParagraphPropertiesContext::startElement(const OUString &/*rName*/, cons class XMLTextPropertiesContext : public XMLImportContext { public: - XMLTextPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLTextPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLTextPropertiesContext::XMLTextPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLTextPropertiesContext::XMLTextPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLTextPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTextPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -78,21 +84,25 @@ void XMLTextPropertiesContext::startElement(const OUString &/*rName*/, const css class XMLGraphicPropertiesContext : public XMLImportContext { public: - XMLGraphicPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLGraphicPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLGraphicPropertiesContext::XMLGraphicPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLGraphicPropertiesContext::XMLGraphicPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLGraphicPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLGraphicPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -106,21 +116,25 @@ void XMLGraphicPropertiesContext::startElement(const OUString &/*rName*/, const class XMLPageLayoutPropertiesContext : public XMLImportContext { public: - XMLPageLayoutPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLPageLayoutPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLPageLayoutPropertiesContext::XMLPageLayoutPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLPageLayoutPropertiesContext::XMLPageLayoutPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLPageLayoutPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLPageLayoutPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -138,21 +152,24 @@ void XMLPageLayoutPropertiesContext::startElement(const OUString &/*rName*/, con class XMLTablePropertiesContext : public XMLImportContext { public: - XMLTablePropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLTablePropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLTablePropertiesContext::XMLTablePropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLTablePropertiesContext::XMLTablePropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLTablePropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTablePropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -160,7 +177,8 @@ void XMLTablePropertiesContext::startElement(const OUString &/*rName*/, const cs OString sValue = OUStringToOString(xAttribs->getValueByIndex(i), RTL_TEXTENCODING_UTF8); if (sName == "style:rel-width") // Make sure this is passed through as a string, and not parsed as a double. - mrStyle.GetTablePropertyList().insert(sName.getStr(), librevenge::RVNGPropertyFactory::newStringProp(sValue.getStr())); + mrStyle.GetTablePropertyList().insert( + sName.getStr(), librevenge::RVNGPropertyFactory::newStringProp(sValue.getStr())); else mrStyle.GetTablePropertyList().insert(sName.getStr(), sValue.getStr()); } @@ -170,21 +188,25 @@ void XMLTablePropertiesContext::startElement(const OUString &/*rName*/, const cs class XMLTableRowPropertiesContext : public XMLImportContext { public: - XMLTableRowPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLTableRowPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLTableRowPropertiesContext::XMLTableRowPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLTableRowPropertiesContext::XMLTableRowPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLTableRowPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableRowPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -198,21 +220,25 @@ void XMLTableRowPropertiesContext::startElement(const OUString &/*rName*/, const class XMLTableColumnPropertiesContext : public XMLImportContext { public: - XMLTableColumnPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLTableColumnPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLTableColumnPropertiesContext::XMLTableColumnPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLTableColumnPropertiesContext::XMLTableColumnPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLTableColumnPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableColumnPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -226,21 +252,25 @@ void XMLTableColumnPropertiesContext::startElement(const OUString &/*rName*/, co class XMLTableCellPropertiesContext : public XMLImportContext { public: - XMLTableCellPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle); + XMLTableCellPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLStyleContext &mrStyle; + XMLStyleContext& mrStyle; }; -XMLTableCellPropertiesContext::XMLTableCellPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle) +XMLTableCellPropertiesContext::XMLTableCellPropertiesContext(XMLImport& rImport, + XMLStyleContext& rStyle) : XMLImportContext(rImport) , mrStyle(rStyle) { } -void XMLTableCellPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableCellPropertiesContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { @@ -250,13 +280,14 @@ void XMLTableCellPropertiesContext::startElement(const OUString &/*rName*/, cons } } -XMLStyleContext::XMLStyleContext(XMLImport &rImport, XMLStylesContext &rStyles) - : XMLImportContext(rImport), - m_rStyles(rStyles) +XMLStyleContext::XMLStyleContext(XMLImport& rImport, XMLStylesContext& rStyles) + : XMLImportContext(rImport) + , m_rStyles(rStyles) { } -rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "style:paragraph-properties") return new XMLParagraphPropertiesContext(mrImport, *this); @@ -277,12 +308,13 @@ rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUStr return nullptr; } -void XMLStyleContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLStyleContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "style:name") m_aName = rAttributeValue; else if (rAttributeName == "style:family") @@ -300,7 +332,7 @@ void XMLStyleContext::startElement(const OUString &/*rName*/, const css::uno::Re } } -void XMLStyleContext::endElement(const OUString &rName) +void XMLStyleContext::endElement(const OUString& rName) { if (m_aName.isEmpty()) return; @@ -325,47 +357,38 @@ void XMLStyleContext::endElement(const OUString &rName) m_rStyles.GetCurrentMasterStyles()[m_aName] = m_aMasterPagePropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetTextPropertyList() -{ - return m_aTextPropertyList; -} +librevenge::RVNGPropertyList& XMLStyleContext::GetTextPropertyList() { return m_aTextPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetParagraphPropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetParagraphPropertyList() { return m_aParagraphPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetCellPropertyList() -{ - return m_aCellPropertyList; -} +librevenge::RVNGPropertyList& XMLStyleContext::GetCellPropertyList() { return m_aCellPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetColumnPropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetColumnPropertyList() { return m_aColumnPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetRowPropertyList() -{ - return m_aRowPropertyList; -} +librevenge::RVNGPropertyList& XMLStyleContext::GetRowPropertyList() { return m_aRowPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetTablePropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetTablePropertyList() { return m_aTablePropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetGraphicPropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetGraphicPropertyList() { return m_aGraphicPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetPageLayoutPropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetPageLayoutPropertyList() { return m_aPageLayoutPropertyList; } -librevenge::RVNGPropertyList &XMLStyleContext::GetMasterPagePropertyList() +librevenge::RVNGPropertyList& XMLStyleContext::GetMasterPagePropertyList() { return m_aMasterPagePropertyList; } diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx index 05d549ab2a79..f72f9e60d769 100644 --- a/writerperfect/source/writer/exp/txtstyli.hxx +++ b/writerperfect/source/writer/exp/txtstyli.hxx @@ -18,28 +18,31 @@ namespace writerperfect { namespace exp { - class XMLStylesContext; /// Handler for <style:style>. class XMLStyleContext : public XMLImportContext { public: - XMLStyleContext(XMLImport &rImport, XMLStylesContext &rStyles); + XMLStyleContext(XMLImport& rImport, XMLStylesContext& rStyles); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; - librevenge::RVNGPropertyList &GetTextPropertyList(); - librevenge::RVNGPropertyList &GetParagraphPropertyList(); - librevenge::RVNGPropertyList &GetCellPropertyList(); - librevenge::RVNGPropertyList &GetColumnPropertyList(); - librevenge::RVNGPropertyList &GetRowPropertyList(); - librevenge::RVNGPropertyList &GetTablePropertyList(); - librevenge::RVNGPropertyList &GetGraphicPropertyList(); - librevenge::RVNGPropertyList &GetPageLayoutPropertyList(); - librevenge::RVNGPropertyList &GetMasterPagePropertyList(); + librevenge::RVNGPropertyList& GetTextPropertyList(); + librevenge::RVNGPropertyList& GetParagraphPropertyList(); + librevenge::RVNGPropertyList& GetCellPropertyList(); + librevenge::RVNGPropertyList& GetColumnPropertyList(); + librevenge::RVNGPropertyList& GetRowPropertyList(); + librevenge::RVNGPropertyList& GetTablePropertyList(); + librevenge::RVNGPropertyList& GetGraphicPropertyList(); + librevenge::RVNGPropertyList& GetPageLayoutPropertyList(); + librevenge::RVNGPropertyList& GetMasterPagePropertyList(); private: OUString m_aName; @@ -53,7 +56,7 @@ private: librevenge::RVNGPropertyList m_aGraphicPropertyList; librevenge::RVNGPropertyList m_aPageLayoutPropertyList; librevenge::RVNGPropertyList m_aMasterPagePropertyList; - XMLStylesContext &m_rStyles; + XMLStylesContext& m_rStyles; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx index e8b735c44890..fca68bf7900d 100644 --- a/writerperfect/source/writer/exp/xmlfmt.cxx +++ b/writerperfect/source/writer/exp/xmlfmt.cxx @@ -19,69 +19,76 @@ namespace writerperfect { namespace exp { - -XMLStylesContext::XMLStylesContext(XMLImport &rImport, StyleType eType) - : XMLImportContext(rImport), - m_rParagraphStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticParagraphStyles() : mrImport.GetParagraphStyles()), - m_rTextStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticTextStyles() : mrImport.GetTextStyles()), - m_rCellStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticCellStyles() : mrImport.GetCellStyles()), - m_rColumnStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticColumnStyles() : mrImport.GetColumnStyles()), - m_rRowStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticRowStyles() : mrImport.GetRowStyles()), - m_rTableStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticTableStyles() : mrImport.GetTableStyles()), - m_rGraphicStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticGraphicStyles() : mrImport.GetGraphicStyles()), - m_rPageLayouts(mrImport.GetPageLayouts()), - m_rMasterStyles(mrImport.GetMasterStyles()) +XMLStylesContext::XMLStylesContext(XMLImport& rImport, StyleType eType) + : XMLImportContext(rImport) + , m_rParagraphStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticParagraphStyles() + : mrImport.GetParagraphStyles()) + , m_rTextStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticTextStyles() + : mrImport.GetTextStyles()) + , m_rCellStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticCellStyles() + : mrImport.GetCellStyles()) + , m_rColumnStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticColumnStyles() + : mrImport.GetColumnStyles()) + , m_rRowStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticRowStyles() + : mrImport.GetRowStyles()) + , m_rTableStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticTableStyles() + : mrImport.GetTableStyles()) + , m_rGraphicStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticGraphicStyles() + : mrImport.GetGraphicStyles()) + , m_rPageLayouts(mrImport.GetPageLayouts()) + , m_rMasterStyles(mrImport.GetMasterStyles()) { } -rtl::Reference<XMLImportContext> XMLStylesContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLStylesContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "style:style" || rName == "style:page-layout" || rName == "style:master-page") return new XMLStyleContext(mrImport, *this); return nullptr; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentParagraphStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentParagraphStyles() { return m_rParagraphStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentTextStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentTextStyles() { return m_rTextStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentCellStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentCellStyles() { return m_rCellStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentColumnStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentColumnStyles() { return m_rColumnStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentRowStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentRowStyles() { return m_rRowStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentTableStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentTableStyles() { return m_rTableStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentGraphicStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentGraphicStyles() { return m_rGraphicStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentPageLayouts() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentPageLayouts() { return m_rPageLayouts; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentMasterStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentMasterStyles() { return m_rMasterStyles; } @@ -90,10 +97,14 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentMa class XMLFontFaceContext : public XMLImportContext { public: - XMLFontFaceContext(XMLImport &rImport); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + XMLFontFaceContext(XMLImport& rImport); + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; OUString maName; }; @@ -102,23 +113,29 @@ public: class XMLFontFaceSrcContext : public XMLImportContext { public: - XMLFontFaceSrcContext(XMLImport &rImport, XMLFontFaceContext &rFontFace); + XMLFontFaceSrcContext(XMLImport& rImport, XMLFontFaceContext& rFontFace); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLFontFaceContext &mrFontFace; + XMLFontFaceContext& mrFontFace; }; /// Handler for <svg:font-face-uri>. class XMLFontFaceUriContext : public XMLImportContext { public: - XMLFontFaceUriContext(XMLImport &rImport, XMLFontFaceContext const &rFontFace); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + XMLFontFaceUriContext(XMLImport& rImport, XMLFontFaceContext const& rFontFace); + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; librevenge::RVNGPropertyList maPropertyList; @@ -130,25 +147,29 @@ private: class XMLFontFaceFormatContext : public XMLImportContext { public: - XMLFontFaceFormatContext(XMLImport &rImport, XMLFontFaceUriContext &rFontFaceUri); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + XMLFontFaceFormatContext(XMLImport& rImport, XMLFontFaceUriContext& rFontFaceUri); + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - XMLFontFaceUriContext &mrFontFaceUri; + XMLFontFaceUriContext& mrFontFaceUri; }; -XMLFontFaceFormatContext::XMLFontFaceFormatContext(XMLImport &rImport, XMLFontFaceUriContext &rFontFaceUri) +XMLFontFaceFormatContext::XMLFontFaceFormatContext(XMLImport& rImport, + XMLFontFaceUriContext& rFontFaceUri) : XMLImportContext(rImport) , mrFontFaceUri(rFontFaceUri) { } -void XMLFontFaceFormatContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLFontFaceFormatContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "svg:string") { OString aAttributeValueU8 = OUStringToOString(rAttributeValue, RTL_TEXTENCODING_UTF8); @@ -157,19 +178,21 @@ void XMLFontFaceFormatContext::startElement(const OUString &/*rName*/, const css } } -XMLFontFaceUriContext::XMLFontFaceUriContext(XMLImport &rImport, XMLFontFaceContext const &rFontFace) +XMLFontFaceUriContext::XMLFontFaceUriContext(XMLImport& rImport, + XMLFontFaceContext const& rFontFace) : XMLImportContext(rImport) { OString aNameU8 = OUStringToOString(rFontFace.maName, RTL_TEXTENCODING_UTF8); maPropertyList.insert("librevenge:name", aNameU8.getStr()); } -void XMLFontFaceUriContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLFontFaceUriContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "loext:font-style") { OString aAttributeValueU8 = OUStringToOString(rAttributeValue, RTL_TEXTENCODING_UTF8); @@ -183,14 +206,15 @@ void XMLFontFaceUriContext::startElement(const OUString &/*rName*/, const css::u } } -void XMLFontFaceUriContext::endElement(const OUString &/*rName*/) +void XMLFontFaceUriContext::endElement(const OUString& /*rName*/) { if (mxBinaryData.is()) maPropertyList.insert("office:binary-data", mxBinaryData->getBinaryData()); mrImport.GetGenerator().defineEmbeddedFont(maPropertyList); } -rtl::Reference<XMLImportContext> XMLFontFaceUriContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLFontFaceUriContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "office:binary-data") { @@ -204,13 +228,14 @@ rtl::Reference<XMLImportContext> XMLFontFaceUriContext::CreateChildContext(const return nullptr; } -XMLFontFaceSrcContext::XMLFontFaceSrcContext(XMLImport &rImport, XMLFontFaceContext &rFontFace) +XMLFontFaceSrcContext::XMLFontFaceSrcContext(XMLImport& rImport, XMLFontFaceContext& rFontFace) : XMLImportContext(rImport) , mrFontFace(rFontFace) { } -rtl::Reference<XMLImportContext> XMLFontFaceSrcContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLFontFaceSrcContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "svg:font-face-uri") return new XMLFontFaceUriContext(mrImport, mrFontFace); @@ -218,23 +243,25 @@ rtl::Reference<XMLImportContext> XMLFontFaceSrcContext::CreateChildContext(const return nullptr; } -XMLFontFaceContext::XMLFontFaceContext(XMLImport &rImport) +XMLFontFaceContext::XMLFontFaceContext(XMLImport& rImport) : XMLImportContext(rImport) { } -void XMLFontFaceContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLFontFaceContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "style:name") maName = rAttributeValue; } } -rtl::Reference<XMLImportContext> XMLFontFaceContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLFontFaceContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "svg:font-face-src") return new XMLFontFaceSrcContext(mrImport, *this); @@ -242,12 +269,13 @@ rtl::Reference<XMLImportContext> XMLFontFaceContext::CreateChildContext(const OU return nullptr; } -XMLFontFaceDeclsContext::XMLFontFaceDeclsContext(XMLImport &rImport) +XMLFontFaceDeclsContext::XMLFontFaceDeclsContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLFontFaceDeclsContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLFontFaceDeclsContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "style:font-face") return new XMLFontFaceContext(mrImport); diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx index 71c3c8e80ace..6f3211de258f 100644 --- a/writerperfect/source/writer/exp/xmlfmt.hxx +++ b/writerperfect/source/writer/exp/xmlfmt.hxx @@ -23,7 +23,6 @@ namespace writerperfect { namespace exp { - /// Handler for <office:automatic-styles>/<office:styles>. class XMLStylesContext : public XMLImportContext { @@ -33,38 +32,43 @@ public: StyleType_NONE, StyleType_AUTOMATIC }; - XMLStylesContext(XMLImport &rImport, StyleType eType); + XMLStylesContext(XMLImport& rImport, StyleType eType); + + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentParagraphStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentTextStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentCellStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentColumnStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentRowStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentTableStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentGraphicStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentPageLayouts(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCurrentMasterStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentParagraphStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTextStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentCellStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentColumnStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentRowStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTableStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentGraphicStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentPageLayouts(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentMasterStyles(); private: - std::map<OUString, librevenge::RVNGPropertyList> &m_rParagraphStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rTextStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rCellStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rColumnStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rRowStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rTableStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rGraphicStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rPageLayouts; - std::map<OUString, librevenge::RVNGPropertyList> &m_rMasterStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rParagraphStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rTextStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rCellStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rColumnStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rRowStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rTableStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rGraphicStyles; + std::map<OUString, librevenge::RVNGPropertyList>& m_rPageLayouts; + std::map<OUString, librevenge::RVNGPropertyList>& m_rMasterStyles; }; /// Handler for <office:font-face-decls>. class XMLFontFaceDeclsContext : public XMLImportContext { public: - XMLFontFaceDeclsContext(XMLImport &rImport); + XMLFontFaceDeclsContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/xmlictxt.cxx b/writerperfect/source/writer/exp/xmlictxt.cxx index ba5c06804dc4..02ac21ab73e3 100644 --- a/writerperfect/source/writer/exp/xmlictxt.cxx +++ b/writerperfect/source/writer/exp/xmlictxt.cxx @@ -17,46 +17,39 @@ namespace writerperfect { namespace exp { - -XMLImportContext::XMLImportContext(XMLImport &rImport) +XMLImportContext::XMLImportContext(XMLImport& rImport) : mrImport(rImport) { } -rtl::Reference<XMLImportContext> XMLImportContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +rtl::Reference<XMLImportContext> XMLImportContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { return mrImport.CreateContext(rName, xAttribs); } -void XMLImportContext::startDocument() -{ -} +void XMLImportContext::startDocument() {} -void XMLImportContext::endDocument() -{ -} +void XMLImportContext::endDocument() {} -void XMLImportContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +void XMLImportContext::startElement( + const OUString& /*rName*/, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { } -void XMLImportContext::endElement(const OUString &/*rName*/) -{ -} +void XMLImportContext::endElement(const OUString& /*rName*/) {} -void XMLImportContext::characters(const OUString &/*rChars*/) -{ -} +void XMLImportContext::characters(const OUString& /*rChars*/) {} -void XMLImportContext::ignorableWhitespace(const OUString &/*rWhitespaces*/) -{ -} +void XMLImportContext::ignorableWhitespace(const OUString& /*rWhitespaces*/) {} -void XMLImportContext::processingInstruction(const OUString &/*rTarget*/, const OUString &/*rData*/) +void XMLImportContext::processingInstruction(const OUString& /*rTarget*/, const OUString& /*rData*/) { } -void XMLImportContext::setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator> &/*xLocator*/) +void XMLImportContext::setDocumentLocator( + const css::uno::Reference<css::xml::sax::XLocator>& /*xLocator*/) { } diff --git a/writerperfect/source/writer/exp/xmlictxt.hxx b/writerperfect/source/writer/exp/xmlictxt.hxx index 622daccb368e..03801d104bcb 100644 --- a/writerperfect/source/writer/exp/xmlictxt.hxx +++ b/writerperfect/source/writer/exp/xmlictxt.hxx @@ -19,32 +19,33 @@ namespace writerperfect { namespace exp { - class XMLImport; /// Base class for a handler of a single XML element during ODF -> librevenge conversion. -class XMLImportContext : public cppu::WeakImplHelper - < - css::xml::sax::XDocumentHandler - > +class XMLImportContext : public cppu::WeakImplHelper<css::xml::sax::XDocumentHandler> { public: - XMLImportContext(XMLImport &rImport); + XMLImportContext(XMLImport& rImport); - virtual rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs); + virtual rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs); // XDocumentHandler void SAL_CALL startDocument() override; void SAL_CALL endDocument() override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; - void SAL_CALL ignorableWhitespace(const OUString &rWhitespaces) override; - void SAL_CALL processingInstruction(const OUString &rTarget, const OUString &rData) override; - void SAL_CALL setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator> &xLocator) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; + void SAL_CALL ignorableWhitespace(const OUString& rWhitespaces) override; + void SAL_CALL processingInstruction(const OUString& rTarget, const OUString& rData) override; + void SAL_CALL + setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator) override; protected: - XMLImport &mrImport; + XMLImport& mrImport; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index 5c22a5f911d7..6e647ccdadf8 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -36,18 +36,16 @@ namespace writerperfect { namespace exp { - namespace { /// Looks up mime type for a given image extension. -OUString GetMimeType(const OUString &rExtension) +OUString GetMimeType(const OUString& rExtension) { - static const std::unordered_map<OUString, OUString> vMimeTypes = - { - {"gif", "image/gif"}, - {"jpg", "image/jpeg"}, - {"png", "image/png"}, - {"svg", "image/svg+xml"}, + static const std::unordered_map<OUString, OUString> vMimeTypes = { + { "gif", "image/gif" }, + { "jpg", "image/jpeg" }, + { "png", "image/png" }, + { "svg", "image/svg+xml" }, }; auto it = vMimeTypes.find(rExtension); @@ -55,7 +53,8 @@ OUString GetMimeType(const OUString &rExtension) } /// Determines the base directory for cover images, XMP metadata, popup images. -OUString FindMediaDir(const OUString &rDocumentBaseURL, const uno::Sequence<beans::PropertyValue> &rFilterData) +OUString FindMediaDir(const OUString& rDocumentBaseURL, + const uno::Sequence<beans::PropertyValue>& rFilterData) { OUString aMediaDir; @@ -78,7 +77,7 @@ OUString FindMediaDir(const OUString &rDocumentBaseURL, const uno::Sequence<bean { aMediaDir = rtl::Uri::convertRelToAbs(rDocumentBaseURL, aURL.GetBase()) + "/"; } - catch (const rtl::MalformedUriException &) + catch (const rtl::MalformedUriException&) { DBG_UNHANDLED_EXCEPTION("writerperfect"); } @@ -86,7 +85,8 @@ OUString FindMediaDir(const OUString &rDocumentBaseURL, const uno::Sequence<bean } /// Picks up a cover image from the base directory. -OUString FindCoverImage(const OUString &rDocumentBaseURL, OUString &rMimeType, const uno::Sequence<beans::PropertyValue> &rFilterData) +OUString FindCoverImage(const OUString& rDocumentBaseURL, OUString& rMimeType, + const uno::Sequence<beans::PropertyValue>& rFilterData) { OUString aRet; @@ -111,16 +111,11 @@ OUString FindCoverImage(const OUString &rDocumentBaseURL, OUString &rMimeType, c if (rDocumentBaseURL.isEmpty()) return aRet; - static const std::initializer_list<OUStringLiteral> vExtensions = - { - "gif", - "jpg", - "png", - "svg" - }; + static const std::initializer_list<OUStringLiteral> vExtensions + = { "gif", "jpg", "png", "svg" }; OUString aMediaDir = FindMediaDir(rDocumentBaseURL, rFilterData); - for (const auto &rExtension : vExtensions) + for (const auto& rExtension : vExtensions) { aRet = aMediaDir + "cover." + rExtension; if (!aRet.isEmpty()) @@ -141,7 +136,10 @@ OUString FindCoverImage(const OUString &rDocumentBaseURL, OUString &rMimeType, c } /// Picks up XMP metadata from the base directory. -void FindXMPMetadata(const uno::Reference<uno::XComponentContext> &xContext, const OUString &rDocumentBaseURL, const uno::Sequence<beans::PropertyValue> &rFilterData, librevenge::RVNGPropertyList &rMetaData) +void FindXMPMetadata(const uno::Reference<uno::XComponentContext>& xContext, + const OUString& rDocumentBaseURL, + const uno::Sequence<beans::PropertyValue>& rFilterData, + librevenge::RVNGPropertyList& rMetaData) { // See if filter data contains metadata explicitly. OUString aValue; @@ -200,7 +198,7 @@ void FindXMPMetadata(const uno::Reference<uno::XComponentContext> &xContext, con { xParser->parseStream(aInputSource); } - catch (const uno::Exception &) + catch (const uno::Exception&) { DBG_UNHANDLED_EXCEPTION("writerperfect", "parseStream() failed"); return; @@ -212,17 +210,21 @@ void FindXMPMetadata(const uno::Reference<uno::XComponentContext> &xContext, con class XMLBodyContext : public XMLImportContext { public: - XMLBodyContext(XMLImport &rImport); + XMLBodyContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) override; }; -XMLBodyContext::XMLBodyContext(XMLImport &rImport) +XMLBodyContext::XMLBodyContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLBodyContext::CreateChildContext(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> +XMLBodyContext::CreateChildContext(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "office:text") return new XMLBodyContentContext(mrImport); @@ -233,20 +235,23 @@ rtl::Reference<XMLImportContext> XMLBodyContext::CreateChildContext(const OUStri class XMLOfficeDocContext : public XMLImportContext { public: - XMLOfficeDocContext(XMLImport &rImport); + XMLOfficeDocContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) override; // Handles metafile for a single page. - void HandleFixedLayoutPage(const FixedLayoutPage &rPage, bool bFirst); + void HandleFixedLayoutPage(const FixedLayoutPage& rPage, bool bFirst); }; -XMLOfficeDocContext::XMLOfficeDocContext(XMLImport &rImport) +XMLOfficeDocContext::XMLOfficeDocContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext( + const OUString& rName, const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "office:meta") return new XMLMetaDocumentContext(mrImport); @@ -266,7 +271,7 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O // Ignore text from doc model in the fixed layout case, instead // insert the page metafiles. bool bFirst = true; - for (const auto &rPage : mrImport.GetPageMetafiles()) + for (const auto& rPage : mrImport.GetPageMetafiles()) { HandleFixedLayoutPage(rPage, bFirst); if (bFirst) @@ -276,18 +281,19 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O return nullptr; } -void XMLOfficeDocContext::HandleFixedLayoutPage(const FixedLayoutPage &rPage, bool bFirst) +void XMLOfficeDocContext::HandleFixedLayoutPage(const FixedLayoutPage& rPage, bool bFirst) { uno::Reference<uno::XComponentContext> xCtx = mrImport.GetComponentContext(); uno::Reference<xml::sax::XWriter> xSaxWriter = xml::sax::Writer::create(xCtx); if (!xSaxWriter.is()) return; - uno::Sequence<uno::Any> aArguments = - { - uno::makeAny<uno::Sequence<beans::PropertyValue>>({comphelper::makePropertyValue("DTDString", false)}) - }; - uno::Reference<svg::XSVGWriter> xSVGWriter(xCtx->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.svg.SVGWriter", aArguments, xCtx), uno::UNO_QUERY); + uno::Sequence<uno::Any> aArguments = { uno::makeAny<uno::Sequence<beans::PropertyValue>>( + { comphelper::makePropertyValue("DTDString", false) }) }; + uno::Reference<svg::XSVGWriter> xSVGWriter( + xCtx->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.svg.SVGWriter", aArguments, xCtx), + uno::UNO_QUERY); if (!xSVGWriter.is()) return; @@ -310,7 +316,7 @@ void XMLOfficeDocContext::HandleFixedLayoutPage(const FixedLayoutPage &rPage, bo { // Name of chapters starting on this page. librevenge::RVNGPropertyListVector aChapterNames; - for (const auto &rName : rPage.aChapterNames) + for (const auto& rName : rPage.aChapterNames) { librevenge::RVNGPropertyList aChapter; aChapter.insert("librevenge:name", rName.toUtf8().getStr()); @@ -329,18 +335,22 @@ void XMLOfficeDocContext::HandleFixedLayoutPage(const FixedLayoutPage &rPage, bo librevenge::RVNGPropertyList aImageProperties; aImageProperties.insert("librevenge:mime-type", "image/svg+xml"); librevenge::RVNGBinaryData aBinaryData; - aBinaryData.append(static_cast<const unsigned char *>(aMemoryStream.GetBuffer()), aMemoryStream.GetSize()); + aBinaryData.append(static_cast<const unsigned char*>(aMemoryStream.GetBuffer()), + aMemoryStream.GetSize()); aImageProperties.insert("office:binary-data", aBinaryData); mrImport.GetGenerator().insertBinaryObject(aImageProperties); mrImport.GetGenerator().closeParagraph(); mrImport.GetGenerator().closePageSpan(); } -XMLImport::XMLImport(const uno::Reference<uno::XComponentContext> &xContext, librevenge::RVNGTextInterface &rGenerator, const OUString &rURL, const uno::Sequence<beans::PropertyValue> &rDescriptor, const std::vector<FixedLayoutPage> &rPageMetafiles) - : mrGenerator(rGenerator), - mxContext(xContext), - mbIsInPageSpan(false), - mrPageMetafiles(rPageMetafiles) +XMLImport::XMLImport(const uno::Reference<uno::XComponentContext>& xContext, + librevenge::RVNGTextInterface& rGenerator, const OUString& rURL, + const uno::Sequence<beans::PropertyValue>& rDescriptor, + const std::vector<FixedLayoutPage>& rPageMetafiles) + : mrGenerator(rGenerator) + , mxContext(xContext) + , mbIsInPageSpan(false) + , mrPageMetafiles(rPageMetafiles) { uno::Sequence<beans::PropertyValue> aFilterData; for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i) @@ -362,7 +372,8 @@ XMLImport::XMLImport(const uno::Reference<uno::XComponentContext> &xContext, lib SvFileStream aStream(aCoverImage, StreamMode::READ); SvMemoryStream aMemoryStream; aMemoryStream.WriteStream(aStream); - aBinaryData.append(static_cast<const unsigned char *>(aMemoryStream.GetBuffer()), aMemoryStream.GetSize()); + aBinaryData.append(static_cast<const unsigned char*>(aMemoryStream.GetBuffer()), + aMemoryStream.GetSize()); librevenge::RVNGPropertyList aCoverImageProperties; aCoverImageProperties.insert("office:binary-data", aBinaryData); aCoverImageProperties.insert("librevenge:mime-type", aMimeType.toUtf8().getStr()); @@ -374,34 +385,28 @@ XMLImport::XMLImport(const uno::Reference<uno::XComponentContext> &xContext, lib mxUriReferenceFactory = uri::UriReferenceFactory::create(mxContext); } -const librevenge::RVNGPropertyListVector &XMLImport::GetCoverImages() -{ - return maCoverImages; -} +const librevenge::RVNGPropertyListVector& XMLImport::GetCoverImages() { return maCoverImages; } -const librevenge::RVNGPropertyList &XMLImport::GetMetaData() -{ - return maMetaData; -} +const librevenge::RVNGPropertyList& XMLImport::GetMetaData() { return maMetaData; } namespace { /// Finds out if a file URL exists. -bool FileURLExists(const OUString &rURL) +bool FileURLExists(const OUString& rURL) { SvFileStream aStream(rURL, StreamMode::READ); return aStream.IsOpen(); } } -PopupState XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList) +PopupState XMLImport::FillPopupData(const OUString& rURL, librevenge::RVNGPropertyList& rPropList) { uno::Reference<uri::XUriReference> xUriRef; try { xUriRef = mxUriReferenceFactory->parse(rURL); } - catch (const uno::Exception &) + catch (const uno::Exception&) { DBG_UNHANDLED_EXCEPTION("writerperfect", "XUriReference::parse() failed"); } @@ -428,7 +433,8 @@ PopupState XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGProper librevenge::RVNGBinaryData aBinaryData; SvMemoryStream aMemoryStream; aMemoryStream.WriteStream(aStream); - aBinaryData.append(static_cast<const unsigned char *>(aMemoryStream.GetBuffer()), aMemoryStream.GetSize()); + aBinaryData.append(static_cast<const unsigned char*>(aMemoryStream.GetBuffer()), + aMemoryStream.GetSize()); rPropList.insert("office:binary-data", aBinaryData); INetURLObject aAbsURL(aAbs); @@ -438,119 +444,107 @@ PopupState XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGProper return PopupState::Consumed; } -const std::vector<FixedLayoutPage> &XMLImport::GetPageMetafiles() const -{ - return mrPageMetafiles; -} +const std::vector<FixedLayoutPage>& XMLImport::GetPageMetafiles() const { return mrPageMetafiles; } -const uno::Reference<uno::XComponentContext> &XMLImport::GetComponentContext() const +const uno::Reference<uno::XComponentContext>& XMLImport::GetComponentContext() const { return mxContext; } -rtl::Reference<XMLImportContext> XMLImport::CreateContext(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> +XMLImport::CreateContext(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "office:document") return new XMLOfficeDocContext(*this); return nullptr; } -librevenge::RVNGTextInterface &XMLImport::GetGenerator() const -{ - return mrGenerator; -} +librevenge::RVNGTextInterface& XMLImport::GetGenerator() const { return mrGenerator; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticTextStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticTextStyles() { return maAutomaticTextStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticParagraphStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticParagraphStyles() { return maAutomaticParagraphStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticCellStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticCellStyles() { return maAutomaticCellStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticColumnStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticColumnStyles() { return maAutomaticColumnStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticRowStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticRowStyles() { return maAutomaticRowStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticTableStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticTableStyles() { return maAutomaticTableStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticGraphicStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetAutomaticGraphicStyles() { return maAutomaticGraphicStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTextStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetTextStyles() { return maTextStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetParagraphStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetParagraphStyles() { return maParagraphStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetCellStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetCellStyles() { return maCellStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetColumnStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetColumnStyles() { return maColumnStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetRowStyles() -{ - return maRowStyles; -} +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetRowStyles() { return maRowStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTableStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetTableStyles() { return maTableStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetGraphicStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetGraphicStyles() { return maGraphicStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetPageLayouts() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetPageLayouts() { return maPageLayouts; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetMasterStyles() +std::map<OUString, librevenge::RVNGPropertyList>& XMLImport::GetMasterStyles() { return maMasterStyles; } -void XMLImport::startDocument() -{ - mrGenerator.startDocument(librevenge::RVNGPropertyList()); -} +void XMLImport::startDocument() { mrGenerator.startDocument(librevenge::RVNGPropertyList()); } -void XMLImport::endDocument() -{ - mrGenerator.endDocument(); -} +void XMLImport::endDocument() { mrGenerator.endDocument(); } -void XMLImport::startElement(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &xAttribs) +void XMLImport::startElement(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& xAttribs) { rtl::Reference<XMLImportContext> xContext; if (!maContexts.empty()) @@ -567,7 +561,7 @@ void XMLImport::startElement(const OUString &rName, const uno::Reference<xml::sa maContexts.push(xContext); } -void XMLImport::endElement(const OUString &rName) +void XMLImport::endElement(const OUString& rName) { if (maContexts.empty()) return; @@ -578,46 +572,42 @@ void XMLImport::endElement(const OUString &rName) maContexts.pop(); } -void XMLImport::characters(const OUString &rChars) +void XMLImport::characters(const OUString& rChars) { if (maContexts.top().is()) maContexts.top()->characters(rChars); } -void XMLImport::ignorableWhitespace(const OUString &/*rWhitespaces*/) -{ -} +void XMLImport::ignorableWhitespace(const OUString& /*rWhitespaces*/) {} -void XMLImport::processingInstruction(const OUString &/*rTarget*/, const OUString &/*rData*/) -{ -} +void XMLImport::processingInstruction(const OUString& /*rTarget*/, const OUString& /*rData*/) {} -void XMLImport::setDocumentLocator(const uno::Reference<xml::sax::XLocator> &/*xLocator*/) -{ -} +void XMLImport::setDocumentLocator(const uno::Reference<xml::sax::XLocator>& /*xLocator*/) {} -void XMLImport::HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList) +void XMLImport::HandlePageSpan(const librevenge::RVNGPropertyList& rPropertyList) { OUString sMasterPageName; OUString sLayoutName; if (rPropertyList["style:master-page-name"]) - sMasterPageName = OStringToOUString(rPropertyList["style:master-page-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8); + sMasterPageName = OStringToOUString( + rPropertyList["style:master-page-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8); else if (!GetIsInPageSpan()) sMasterPageName = "Standard"; if (sMasterPageName.getLength()) { - librevenge::RVNGPropertyList &rMasterPage = GetMasterStyles()[sMasterPageName]; + librevenge::RVNGPropertyList& rMasterPage = GetMasterStyles()[sMasterPageName]; if (rMasterPage["style:page-layout-name"]) { - sLayoutName = OStringToOUString(rMasterPage["style:page-layout-name"]->getStr().cstr(), RTL_TEXTENCODING_UTF8); + sLayoutName = OStringToOUString(rMasterPage["style:page-layout-name"]->getStr().cstr(), + RTL_TEXTENCODING_UTF8); } } if (sLayoutName.getLength()) { - librevenge::RVNGPropertyList &rPageLayout = GetPageLayouts()[sLayoutName]; + librevenge::RVNGPropertyList& rPageLayout = GetPageLayouts()[sLayoutName]; if (GetIsInPageSpan()) GetGenerator().closePageSpan(); diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx index 4ef4bf3f5c43..9d0dfd430d12 100644 --- a/writerperfect/source/writer/exp/xmlimp.hxx +++ b/writerperfect/source/writer/exp/xmlimp.hxx @@ -29,7 +29,6 @@ namespace writerperfect { namespace exp { - class XMLImportContext; /// Contains info about a fixed-layout page. @@ -54,13 +53,10 @@ enum class PopupState }; /// ODT export feeds this class to make librevenge calls. -class XMLImport : public cppu::WeakImplHelper - < - css::xml::sax::XDocumentHandler - > +class XMLImport : public cppu::WeakImplHelper<css::xml::sax::XDocumentHandler> { - librevenge::RVNGTextInterface &mrGenerator; - std::stack< rtl::Reference<XMLImportContext> > maContexts; + librevenge::RVNGTextInterface& mrGenerator; + std::stack<rtl::Reference<XMLImportContext>> maContexts; std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTextStyles; std::map<OUString, librevenge::RVNGPropertyList> maTextStyles; std::map<OUString, librevenge::RVNGPropertyList> maAutomaticParagraphStyles; @@ -80,59 +76,61 @@ class XMLImport : public cppu::WeakImplHelper librevenge::RVNGPropertyListVector maCoverImages; /// Author, date, etc -- overwrites what would be from the document out of the box. librevenge::RVNGPropertyList maMetaData; - const css::uno::Reference<css::uno::XComponentContext> &mxContext; + const css::uno::Reference<css::uno::XComponentContext>& mxContext; css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory; OUString maMediaDir; bool mbIsInPageSpan; - const std::vector<FixedLayoutPage> &mrPageMetafiles; + const std::vector<FixedLayoutPage>& mrPageMetafiles; public: - XMLImport(const css::uno::Reference<css::uno::XComponentContext> &xContext, librevenge::RVNGTextInterface &rGenerator, const OUString &rURL, const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor, const std::vector<FixedLayoutPage> &rPageMetafiles); - - rtl::Reference<XMLImportContext> CreateContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs); - - librevenge::RVNGTextInterface &GetGenerator() const; - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticTextStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticParagraphStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticCellStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticColumnStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticRowStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticTableStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticGraphicStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetTextStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetParagraphStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCellStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetColumnStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetRowStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetTableStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetGraphicStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetPageLayouts(); - std::map<OUString, librevenge::RVNGPropertyList> &GetMasterStyles(); - const librevenge::RVNGPropertyListVector &GetCoverImages(); - const librevenge::RVNGPropertyList &GetMetaData(); - PopupState FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList); - const std::vector<FixedLayoutPage> &GetPageMetafiles() const; - const css::uno::Reference<css::uno::XComponentContext> &GetComponentContext() const; - - bool GetIsInPageSpan() const - { - return mbIsInPageSpan; - } - void SetIsInPageSpan(bool bSet) - { - mbIsInPageSpan = bSet; - } - void HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList); + XMLImport(const css::uno::Reference<css::uno::XComponentContext>& xContext, + librevenge::RVNGTextInterface& rGenerator, const OUString& rURL, + const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor, + const std::vector<FixedLayoutPage>& rPageMetafiles); + + rtl::Reference<XMLImportContext> + CreateContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs); + + librevenge::RVNGTextInterface& GetGenerator() const; + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticTextStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticParagraphStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticCellStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticColumnStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticRowStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticTableStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticGraphicStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetTextStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetParagraphStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetCellStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetColumnStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetRowStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetTableStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetGraphicStyles(); + std::map<OUString, librevenge::RVNGPropertyList>& GetPageLayouts(); + std::map<OUString, librevenge::RVNGPropertyList>& GetMasterStyles(); + const librevenge::RVNGPropertyListVector& GetCoverImages(); + const librevenge::RVNGPropertyList& GetMetaData(); + PopupState FillPopupData(const OUString& rURL, librevenge::RVNGPropertyList& rPropList); + const std::vector<FixedLayoutPage>& GetPageMetafiles() const; + const css::uno::Reference<css::uno::XComponentContext>& GetComponentContext() const; + + bool GetIsInPageSpan() const { return mbIsInPageSpan; } + void SetIsInPageSpan(bool bSet) { mbIsInPageSpan = bSet; } + void HandlePageSpan(const librevenge::RVNGPropertyList& rPropertyList); // XDocumentHandler void SAL_CALL startDocument() override; void SAL_CALL endDocument() override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - void SAL_CALL characters(const OUString &rChars) override; - void SAL_CALL ignorableWhitespace(const OUString &rWhitespaces) override; - void SAL_CALL processingInstruction(const OUString &rTarget, const OUString &rData) override; - void SAL_CALL setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator> &xLocator) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; + void SAL_CALL characters(const OUString& rChars) override; + void SAL_CALL ignorableWhitespace(const OUString& rWhitespaces) override; + void SAL_CALL processingInstruction(const OUString& rTarget, const OUString& rData) override; + void SAL_CALL + setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator) override; }; } // namespace exp diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx b/writerperfect/source/writer/exp/xmlmetai.cxx index 7ee2024968ae..229dd82ff2d5 100644 --- a/writerperfect/source/writer/exp/xmlmetai.cxx +++ b/writerperfect/source/writer/exp/xmlmetai.cxx @@ -17,24 +17,24 @@ namespace writerperfect { namespace exp { - /// Handler for <dc:title>. class XMLDcTitleContext : public XMLImportContext { public: - XMLDcTitleContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + XMLDcTitleContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - XMLMetaDocumentContext &mrMeta; + XMLMetaDocumentContext& mrMeta; }; -XMLDcTitleContext::XMLDcTitleContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) - : XMLImportContext(rImport), mrMeta(rMeta) +XMLDcTitleContext::XMLDcTitleContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta) + : XMLImportContext(rImport) + , mrMeta(rMeta) { } -void XMLDcTitleContext::characters(const OUString &rChars) +void XMLDcTitleContext::characters(const OUString& rChars) { OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); if (!mrMeta.m_aPropertyList["dc:title"]) @@ -45,19 +45,20 @@ void XMLDcTitleContext::characters(const OUString &rChars) class XMLDcLanguageContext : public XMLImportContext { public: - XMLDcLanguageContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + XMLDcLanguageContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - XMLMetaDocumentContext &mrMeta; + XMLMetaDocumentContext& mrMeta; }; -XMLDcLanguageContext::XMLDcLanguageContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) - : XMLImportContext(rImport), mrMeta(rMeta) +XMLDcLanguageContext::XMLDcLanguageContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta) + : XMLImportContext(rImport) + , mrMeta(rMeta) { } -void XMLDcLanguageContext::characters(const OUString &rChars) +void XMLDcLanguageContext::characters(const OUString& rChars) { OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); if (!mrMeta.m_aPropertyList["dc:language"]) @@ -68,19 +69,20 @@ void XMLDcLanguageContext::characters(const OUString &rChars) class XMLDcDateContext : public XMLImportContext { public: - XMLDcDateContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + XMLDcDateContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - XMLMetaDocumentContext &mrMeta; + XMLMetaDocumentContext& mrMeta; }; -XMLDcDateContext::XMLDcDateContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) - : XMLImportContext(rImport), mrMeta(rMeta) +XMLDcDateContext::XMLDcDateContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta) + : XMLImportContext(rImport) + , mrMeta(rMeta) { } -void XMLDcDateContext::characters(const OUString &rChars) +void XMLDcDateContext::characters(const OUString& rChars) { OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); if (!mrMeta.m_aPropertyList["dc:date"]) @@ -91,19 +93,20 @@ void XMLDcDateContext::characters(const OUString &rChars) class XMLMetaGeneratorContext : public XMLImportContext { public: - XMLMetaGeneratorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + XMLMetaGeneratorContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - XMLMetaDocumentContext &mrMeta; + XMLMetaDocumentContext& mrMeta; }; -XMLMetaGeneratorContext::XMLMetaGeneratorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) - : XMLImportContext(rImport), mrMeta(rMeta) +XMLMetaGeneratorContext::XMLMetaGeneratorContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta) + : XMLImportContext(rImport) + , mrMeta(rMeta) { } -void XMLMetaGeneratorContext::characters(const OUString &rChars) +void XMLMetaGeneratorContext::characters(const OUString& rChars) { OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); mrMeta.m_aPropertyList.insert("meta:generator", librevenge::RVNGString(sCharU8.getStr())); @@ -113,26 +116,29 @@ void XMLMetaGeneratorContext::characters(const OUString &rChars) class XMLMetaInitialCreatorContext : public XMLImportContext { public: - XMLMetaInitialCreatorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + XMLMetaInitialCreatorContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta); - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - XMLMetaDocumentContext &mrMeta; + XMLMetaDocumentContext& mrMeta; }; -XMLMetaInitialCreatorContext::XMLMetaInitialCreatorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) - : XMLImportContext(rImport), mrMeta(rMeta) +XMLMetaInitialCreatorContext::XMLMetaInitialCreatorContext(XMLImport& rImport, + XMLMetaDocumentContext& rMeta) + : XMLImportContext(rImport) + , mrMeta(rMeta) { } -void XMLMetaInitialCreatorContext::characters(const OUString &rChars) +void XMLMetaInitialCreatorContext::characters(const OUString& rChars) { OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); if (!mrMeta.m_aPropertyList["meta:initial-creator"]) - mrMeta.m_aPropertyList.insert("meta:initial-creator", librevenge::RVNGString(sCharU8.getStr())); + mrMeta.m_aPropertyList.insert("meta:initial-creator", + librevenge::RVNGString(sCharU8.getStr())); } -XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport &rImport) +XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport& rImport) : XMLImportContext(rImport) { librevenge::RVNGPropertyList::Iter it(mrImport.GetMetaData()); @@ -141,7 +147,8 @@ XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport &rImport) m_aPropertyList.insert("librevenge:cover-images", mrImport.GetCoverImages()); } -rtl::Reference<XMLImportContext> XMLMetaDocumentContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLMetaDocumentContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "dc:title") return new XMLDcTitleContext(mrImport, *this); @@ -156,25 +163,22 @@ rtl::Reference<XMLImportContext> XMLMetaDocumentContext::CreateChildContext(cons return nullptr; } -void XMLMetaDocumentContext::endElement(const OUString &/*rName*/) +void XMLMetaDocumentContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().setDocumentMetaData(m_aPropertyList); } -XMPParser::XMPParser(librevenge::RVNGPropertyList &rMetaData) +XMPParser::XMPParser(librevenge::RVNGPropertyList& rMetaData) : mrMetaData(rMetaData) { } XMPParser::~XMPParser() = default; -void XMPParser::startDocument() -{ -} +void XMPParser::startDocument() {} void XMPParser::endDocument() { - if (!mrMetaData["dc:identifier"] && !m_aIdentifier.isEmpty()) mrMetaData.insert("dc:identifier", m_aIdentifier.toUtf8().getStr()); if (!mrMetaData["dc:title"] && !m_aTitle.isEmpty()) @@ -187,7 +191,8 @@ void XMPParser::endDocument() mrMetaData.insert("dc:date", m_aDate.toUtf8().getStr()); } -void XMPParser::startElement(const OUString &rName, const uno::Reference<xml::sax::XAttributeList> &/*xAttribs*/) +void XMPParser::startElement(const OUString& rName, + const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "dc:identifier") m_bInIdentifier = true; @@ -212,7 +217,7 @@ void XMPParser::startElement(const OUString &rName, const uno::Reference<xml::sa } } -void XMPParser::endElement(const OUString &rName) +void XMPParser::endElement(const OUString& rName) { if (rName == "dc:identifier") m_bInIdentifier = false; @@ -237,7 +242,7 @@ void XMPParser::endElement(const OUString &rName) } } -void XMPParser::characters(const OUString &rChars) +void XMPParser::characters(const OUString& rChars) { if (m_bInIdentifier) m_aIdentifier += rChars; @@ -251,17 +256,11 @@ void XMPParser::characters(const OUString &rChars) m_aDate += rChars; } -void XMPParser::ignorableWhitespace(const OUString &/*rWhitespace*/) -{ -} +void XMPParser::ignorableWhitespace(const OUString& /*rWhitespace*/) {} -void XMPParser::processingInstruction(const OUString &/*rTarget*/, const OUString &/*rData*/) -{ -} +void XMPParser::processingInstruction(const OUString& /*rTarget*/, const OUString& /*rData*/) {} -void XMPParser::setDocumentLocator(const uno::Reference<xml::sax::XLocator> &/*xLocator*/) -{ -} +void XMPParser::setDocumentLocator(const uno::Reference<xml::sax::XLocator>& /*xLocator*/) {} } // namespace exp } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/xmlmetai.hxx b/writerperfect/source/writer/exp/xmlmetai.hxx index d69818a8648b..296adec7f836 100644 --- a/writerperfect/source/writer/exp/xmlmetai.hxx +++ b/writerperfect/source/writer/exp/xmlmetai.hxx @@ -18,28 +18,26 @@ namespace writerperfect { namespace exp { - /// Handler for <office:meta>. class XMLMetaDocumentContext : public XMLImportContext { public: - XMLMetaDocumentContext(XMLImport &rImport); + XMLMetaDocumentContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL endElement(const OUString& rName) override; librevenge::RVNGPropertyList m_aPropertyList; }; /// Parses an XMP file. -class XMPParser: public cppu::WeakImplHelper - < - css::xml::sax::XDocumentHandler - > +class XMPParser : public cppu::WeakImplHelper<css::xml::sax::XDocumentHandler> { public: - explicit XMPParser(librevenge::RVNGPropertyList &rMetaData); + explicit XMPParser(librevenge::RVNGPropertyList& rMetaData); ~XMPParser() override; // XDocumentHandler @@ -47,20 +45,23 @@ public: void SAL_CALL endDocument() override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL endElement(const OUString& rName) override; - void SAL_CALL characters(const OUString &rChars) override; + void SAL_CALL characters(const OUString& rChars) override; - void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override; + void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; - void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override; + void SAL_CALL processingInstruction(const OUString& aTarget, const OUString& aData) override; - void SAL_CALL setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator> &xLocator) override; + void SAL_CALL + setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator) override; private: - librevenge::RVNGPropertyList &mrMetaData; + librevenge::RVNGPropertyList& mrMetaData; bool m_bInIdentifier = false; OUString m_aIdentifier; bool m_bInTitle = false; diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx index 82468e12a91a..b5c16388b750 100644 --- a/writerperfect/source/writer/exp/xmltbli.cxx +++ b/writerperfect/source/writer/exp/xmltbli.cxx @@ -19,19 +19,22 @@ namespace writerperfect { namespace exp { - /// Handler for <table:table-row>. class XMLTableRowContext : public XMLImportContext { public: - XMLTableRowContext(XMLImport &rImport); + XMLTableRowContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; int GetColumn() const; void SetColumn(int nColumn); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; private: int m_nColumn = 0; @@ -41,38 +44,45 @@ private: class XMLTableCellContext : public XMLImportContext { public: - XMLTableCellContext(XMLImport &rImport, XMLTableRowContext &rRow); + XMLTableCellContext(XMLImport& rImport, XMLTableRowContext& rRow); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; private: - XMLTableRowContext &m_rRow; + XMLTableRowContext& m_rRow; }; -XMLTableCellContext::XMLTableCellContext(XMLImport &rImport, XMLTableRowContext &rRow) - : XMLImportContext(rImport), - m_rRow(rRow) +XMLTableCellContext::XMLTableCellContext(XMLImport& rImport, XMLTableRowContext& rRow) + : XMLImportContext(rImport) + , m_rRow(rRow) { } -rtl::Reference<XMLImportContext> XMLTableCellContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTableCellContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateTextChildContext(mrImport, rName); } -void XMLTableCellContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableCellContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "table:style-name") - FillStyles(rAttributeValue, mrImport.GetAutomaticCellStyles(), mrImport.GetCellStyles(), aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticCellStyles(), mrImport.GetCellStyles(), + aPropertyList); else { OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8); @@ -85,7 +95,7 @@ void XMLTableCellContext::startElement(const OUString &/*rName*/, const css::uno m_rRow.SetColumn(m_rRow.GetColumn() + 1); } -void XMLTableCellContext::endElement(const OUString &/*rName*/) +void XMLTableCellContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeTableCell(); } @@ -94,40 +104,46 @@ void XMLTableCellContext::endElement(const OUString &/*rName*/) class XMLTableColumnContext : public XMLImportContext { public: - XMLTableColumnContext(XMLImport &rImport, librevenge::RVNGPropertyListVector &rColumns); + XMLTableColumnContext(XMLImport& rImport, librevenge::RVNGPropertyListVector& rColumns); - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; private: - librevenge::RVNGPropertyListVector &m_rColumns; + librevenge::RVNGPropertyListVector& m_rColumns; }; -XMLTableColumnContext::XMLTableColumnContext(XMLImport &rImport, librevenge::RVNGPropertyListVector &rColumns) - : XMLImportContext(rImport), - m_rColumns(rColumns) +XMLTableColumnContext::XMLTableColumnContext(XMLImport& rImport, + librevenge::RVNGPropertyListVector& rColumns) + : XMLImportContext(rImport) + , m_rColumns(rColumns) { } -void XMLTableColumnContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableColumnContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "table:style-name") - FillStyles(rAttributeValue, mrImport.GetAutomaticColumnStyles(), mrImport.GetColumnStyles(), aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticColumnStyles(), + mrImport.GetColumnStyles(), aPropertyList); } m_rColumns.append(aPropertyList); } -XMLTableRowContext::XMLTableRowContext(XMLImport &rImport) +XMLTableRowContext::XMLTableRowContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTableRowContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTableRowContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "table:table-cell") return new XMLTableCellContext(mrImport, *this); @@ -141,41 +157,38 @@ rtl::Reference<XMLImportContext> XMLTableRowContext::CreateChildContext(const OU return nullptr; } -void XMLTableRowContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableRowContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { librevenge::RVNGPropertyList aPropertyList; for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "table:style-name") - FillStyles(rAttributeValue, mrImport.GetAutomaticRowStyles(), mrImport.GetRowStyles(), aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticRowStyles(), mrImport.GetRowStyles(), + aPropertyList); } mrImport.GetGenerator().openTableRow(aPropertyList); } -void XMLTableRowContext::endElement(const OUString &/*rName*/) +void XMLTableRowContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeTableRow(); } -int XMLTableRowContext::GetColumn() const -{ - return m_nColumn; -} +int XMLTableRowContext::GetColumn() const { return m_nColumn; } -void XMLTableRowContext::SetColumn(int nColumn) -{ - m_nColumn = nColumn; -} +void XMLTableRowContext::SetColumn(int nColumn) { m_nColumn = nColumn; } -XMLTableContext::XMLTableContext(XMLImport &rImport) +XMLTableContext::XMLTableContext(XMLImport& rImport) : XMLImportContext(rImport) { } -rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { if (rName == "table:table-column") // Make sure columns are parsed before we open the table. @@ -197,16 +210,18 @@ rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUStr return nullptr; } -void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) +void XMLTableContext::startElement( + const OUString& /*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) { for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); + const OUString& rAttributeName = xAttribs->getNameByIndex(i); + const OUString& rAttributeValue = xAttribs->getValueByIndex(i); if (rAttributeName == "table:style-name") { - FillStyles(rAttributeValue, mrImport.GetAutomaticTableStyles(), mrImport.GetTableStyles(), m_aPropertyList); + FillStyles(rAttributeValue, mrImport.GetAutomaticTableStyles(), + mrImport.GetTableStyles(), m_aPropertyList); mrImport.HandlePageSpan(m_aPropertyList); } else @@ -218,7 +233,7 @@ void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Re } } -void XMLTableContext::endElement(const OUString &/*rName*/) +void XMLTableContext::endElement(const OUString& /*rName*/) { mrImport.GetGenerator().closeTable(); } diff --git a/writerperfect/source/writer/exp/xmltbli.hxx b/writerperfect/source/writer/exp/xmltbli.hxx index ed755731e9fc..6b7d7b267cbe 100644 --- a/writerperfect/source/writer/exp/xmltbli.hxx +++ b/writerperfect/source/writer/exp/xmltbli.hxx @@ -18,17 +18,20 @@ namespace writerperfect { namespace exp { - /// Handler for <table:table>. class XMLTableContext : public XMLImportContext { public: - XMLTableContext(XMLImport &rImport); + XMLTableContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + rtl::Reference<XMLImportContext> + CreateChildContext(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; + void SAL_CALL + startElement(const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override; + void SAL_CALL endElement(const OUString& rName) override; private: bool m_bTableOpened = false; diff --git a/writerperfect/source/writer/exp/xmltext.cxx b/writerperfect/source/writer/exp/xmltext.cxx index a6624b1f2115..1472a23c3763 100644 --- a/writerperfect/source/writer/exp/xmltext.cxx +++ b/writerperfect/source/writer/exp/xmltext.cxx @@ -21,24 +21,24 @@ namespace writerperfect { namespace exp { - -XMLBodyContentContext::XMLBodyContentContext(XMLImport &rImport) +XMLBodyContentContext::XMLBodyContentContext(XMLImport& rImport) : XMLImportContext(rImport) { } -void XMLBodyContentContext::endElement(const OUString &/*rName*/) +void XMLBodyContentContext::endElement(const OUString& /*rName*/) { if (mrImport.GetIsInPageSpan()) mrImport.GetGenerator().closePageSpan(); } -rtl::Reference<XMLImportContext> XMLBodyContentContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +rtl::Reference<XMLImportContext> XMLBodyContentContext::CreateChildContext( + const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) { return CreateTextChildContext(mrImport, rName); } -rtl::Reference<XMLImportContext> CreateTextChildContext(XMLImport &rImport, const OUString &rName) +rtl::Reference<XMLImportContext> CreateTextChildContext(XMLImport& rImport, const OUString& rName) { if (rName == "text:p" || rName == "text:h") return new XMLParaContext(rImport); diff --git a/writerperfect/source/writer/exp/xmltext.hxx b/writerperfect/source/writer/exp/xmltext.hxx index 1c9a1e131542..b635176ce4ce 100644 --- a/writerperfect/source/writer/exp/xmltext.hxx +++ b/writerperfect/source/writer/exp/xmltext.hxx @@ -16,19 +16,20 @@ namespace writerperfect { namespace exp { - /// Handler for <office:text>. class XMLBodyContentContext : public XMLImportContext { public: - XMLBodyContentContext(XMLImport &rImport); + XMLBodyContentContext(XMLImport& rImport); - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) override; - void SAL_CALL endElement(const OUString &rName) override; + rtl::Reference<XMLImportContext> CreateChildContext( + const OUString& rName, + const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/) override; + void SAL_CALL endElement(const OUString& rName) override; }; /// Context factory for body text, section, table cell, etc. -rtl::Reference<XMLImportContext> CreateTextChildContext(XMLImport &rImport, const OUString &rName); +rtl::Reference<XMLImportContext> CreateTextChildContext(XMLImport& rImport, const OUString& rName); } // namespace exp } // namespace writerperfect |