diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-15 09:18:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-15 09:18:34 +0100 |
commit | dde274e70ceed15f517814ee86453837d228ffdc (patch) | |
tree | 8a34a6e5874bb42484e7aec57cffbdeb37bfcf65 /xmloff | |
parent | b43f64f430bc19c07f6b5d457a9168de5fb9de69 (diff) |
use FastParser for SchXMLImport
Change-Id: Ib43f109dce8226d29b19c141010e4480147933ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86825
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/SchXMLImport.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLImport.cxx | 38 | ||||
-rw-r--r-- | xmloff/source/chart/contexts.cxx | 72 | ||||
-rw-r--r-- | xmloff/source/chart/contexts.hxx | 23 |
4 files changed, 44 insertions, 94 deletions
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 2a1080bf1eec..73e726fe03d6 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -152,11 +152,6 @@ class SchXMLImport final : public SvXMLImport private: rtl::Reference<SchXMLImportHelper> maImportHelper; - 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; diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 9f8a59e0fe52..3432da7906fd 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -498,38 +498,6 @@ SchXMLImport::~SchXMLImport() throw () // create the main context (subcontexts are created // by the one created here) -SvXMLImportContext *SchXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList >& xAttrList ) -{ - SvXMLImportContext* pContext = nullptr; - - // accept <office:document> - if( XML_NAMESPACE_OFFICE == nPrefix && - ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) || - IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) )) - { - pContext = new SchXMLDocContext(*maImportHelper, *this, nPrefix, rLocalName); - } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && - ( IsXMLToken(rLocalName, XML_DOCUMENT) || - (IsXMLToken(rLocalName, XML_DOCUMENT_META) - && (getImportFlags() & SvXMLImportFlags::META) )) ) - { - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), uno::UNO_QUERY); - // mst@: right now, this seems to be not supported, so it is untested - if (!xDPS.is()) { - pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META)) - ? SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList) - : new SchXMLDocContext(*maImportHelper, *this, nPrefix, rLocalName); - } - } else { - pContext = SvXMLImport::CreateDocumentContext(nPrefix, rLocalName, xAttrList); - } - - return pContext; -} - SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { @@ -552,7 +520,11 @@ SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement, } } break; - default: break; + // accept <office:document> + case XML_ELEMENT(OFFICE, XML_DOCUMENT_STYLES): + case XML_ELEMENT(OFFICE, XML_DOCUMENT_CONTENT): + pContext = new SchXMLDocContext(*maImportHelper, *this, nElement); + break; } return pContext; } diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index 9f4a178590cf..9c668b89ee7e 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -41,45 +41,28 @@ private: public: SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName ); + SvXMLImport& rImport ); - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; }; } SchXMLBodyContext_Impl::SchXMLBodyContext_Impl( - SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName ) : - SvXMLImportContext( rImport, nPrfx, rLName ), + SchXMLImportHelper& rImpHelper, SvXMLImport& rImport ) : + SvXMLImportContext( rImport ), mrImportHelper( rImpHelper ) { } -SvXMLImportContextRef SchXMLBodyContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & ) +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLBodyContext_Impl::createFastChildContext( + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { - return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix, - rLocalName ); -} - -SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLName ) : - SvXMLImportContext( rImport, nPrefix, rLName ), - mrImportHelper( rImpHelper ) -{ - SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) || - ( !IsXMLToken( rLName, XML_DOCUMENT ) && - !IsXMLToken( rLName, XML_DOCUMENT_META) && - !IsXMLToken( rLName, XML_DOCUMENT_STYLES) && - !IsXMLToken( rLName, XML_DOCUMENT_CONTENT) ), "xmloff.chart", "SchXMLDocContext instantiated with no <office:document> element" ); + return new SchXMLBodyContext( mrImportHelper, GetImport(), nElement ); } SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper, @@ -126,22 +109,21 @@ SvXMLImportContextRef SchXMLDocContext::CreateChildContext( // if XDocumentPropertiesSupplier is not supported at the model xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); break; - case XML_TOK_DOC_BODY: - if( nFlags & SvXMLImportFlags::CONTENT ) - xContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName ); - break; } - // call parent when no own context was created - if (!xContext) - xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); - return xContext; } uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::createFastChildContext( - sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) + sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { + SvXMLImportFlags nFlags = GetImport().getImportFlags(); + switch (nElement) + { + case XML_ELEMENT(OFFICE, XML_BODY): + if( nFlags & SvXMLImportFlags::CONTENT ) + return new SchXMLBodyContext_Impl( mrImportHelper, GetImport() ); + } return nullptr; } @@ -171,20 +153,20 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLFlatDocContext_Im SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLName ) : - SvXMLImportContext( rImport, nPrefix, rLName ), + sal_Int32 nElement ) : + SvXMLImportContext( rImport ), mrImportHelper( rImpHelper ) { - SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) || - !IsXMLToken( rLName, XML_CHART ), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" ); + SAL_WARN_IF( nElement != XML_ELEMENT(OFFICE, XML_CHART), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" ); } SchXMLBodyContext::~SchXMLBodyContext() {} -void SchXMLBodyContext::EndElement() +css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLBodyContext::createFastChildContext( + sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) { + return nullptr; } SvXMLImportContextRef SchXMLBodyContext::CreateChildContext( @@ -209,10 +191,6 @@ SvXMLImportContextRef SchXMLBodyContext::CreateChildContext( // i99104 handle null date correctly xContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList); } - else - { - xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); - } return xContext; } diff --git a/xmloff/source/chart/contexts.hxx b/xmloff/source/chart/contexts.hxx index 26f988b433ee..84cfef57b974 100644 --- a/xmloff/source/chart/contexts.hxx +++ b/xmloff/source/chart/contexts.hxx @@ -43,16 +43,13 @@ public: SchXMLDocContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLName ); - - SchXMLDocContext( - SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, sal_Int32 nElement ); virtual ~SchXMLDocContext() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -73,6 +70,10 @@ public: sal_Int32 i_nElement, const css::uno::Reference<css::document::XDocumentProperties>& i_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 >& xAttrList ) override; }; @@ -86,11 +87,15 @@ public: SchXMLBodyContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLName ); + sal_Int32 nElement ); virtual ~SchXMLBodyContext() override; - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + + 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 SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, |