diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-15 12:47:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-15 19:49:25 +0100 |
commit | fd14abf1346128826dcb30dda2cc674cc4d998ce (patch) | |
tree | 1ea857baf73beb0eb15b408eba7fda77d5ac3783 /sw | |
parent | 14b36a16b225bf7c988f118d499a7287c47cd83e (diff) |
use more FastParser in SwXMLImport
Change-Id: I27207e1ac00d783296deb9b0309b7b62cb5a15eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86837
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 65 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.hxx | 4 |
2 files changed, 21 insertions, 48 deletions
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index a15cc9f9efb1..9f56a8f2fb06 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -190,10 +190,6 @@ protected: // #i69629# SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); } public: - - SwXMLDocContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName ); - SwXMLDocContext_Impl( SwXMLImport& rImport ); virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, @@ -202,16 +198,13 @@ public: virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; + + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} }; } -SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName ) : - SvXMLImportContext( rImport, nPrfx, rLName ) -{ -} - SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport ) : SvXMLImportContext( rImport ) { @@ -288,6 +281,10 @@ public: SwXMLOfficeDocContext_Impl( SwXMLImport& rImport, const Reference< document::XDocumentProperties >& xDocProps); + virtual void SAL_CALL startFastElement( sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override + { SvXMLMetaDocumentContext::startFastElement(nElement, xAttrList); } + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override; }; @@ -333,25 +330,20 @@ class SwXMLDocStylesContext_Impl : public SwXMLDocContext_Impl { public: - SwXMLDocStylesContext_Impl( SwXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName ); + SwXMLDocStylesContext_Impl( SwXMLImport& rImport ); - virtual void EndElement() override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; } -SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl( - SwXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - SwXMLDocContext_Impl( rImport, nPrfx, rLName ) +SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl( SwXMLImport& rImport ) : + SvXMLImportContext( rImport ), + SwXMLDocContext_Impl( rImport ) { } -void SwXMLDocStylesContext_Impl::EndElement() +void SwXMLDocStylesContext_Impl::endFastElement(sal_Int32 ) { // assign paragraph styles to list levels of outline style after all styles // are imported and finished. @@ -368,29 +360,6 @@ const SvXMLTokenMap& SwXMLImport::GetDocElemTokenMap() return *m_pDocElemTokenMap; } -SvXMLImportContext *SwXMLImport::CreateDocumentContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) -{ - SvXMLImportContext *pContext = nullptr; - - // #i69629# - own subclasses for <office:document> and <office:document-styles> - if( XML_NAMESPACE_OFFICE==nPrefix && - ( IsXMLToken( rLocalName, XML_DOCUMENT_SETTINGS ) || - IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT ) )) - pContext = new SwXMLDocContext_Impl( *this, nPrefix, rLocalName ); - else if ( XML_NAMESPACE_OFFICE==nPrefix && - IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ) - { - pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName ); - } - else - pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList); - - return pContext; -} - SvXMLImportContext *SwXMLImport::CreateFastContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { @@ -409,6 +378,14 @@ SvXMLImportContext *SwXMLImport::CreateFastContext( sal_Int32 nElement, pContext = new SwXMLOfficeDocContext_Impl( *this, xDocProps ); } break; + // #i69629# - own subclasses for <office:document> and <office:document-styles> + case XML_ELEMENT(OFFICE, XML_DOCUMENT_SETTINGS): + case XML_ELEMENT(OFFICE, XML_DOCUMENT_CONTENT): + pContext = new SwXMLDocContext_Impl( *this ); + break; + case XML_ELEMENT(OFFICE, XML_DOCUMENT_STYLES): + pContext = new SwXMLDocStylesContext_Impl( *this ); + break; } return pContext; } diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index ed2317c73866..986b4a99bea9 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -101,10 +101,6 @@ class SwXMLImport: public SvXMLImport protected: - virtual SvXMLImportContext *CreateDocumentContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override; - virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override; |