diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-22 10:46:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-22 11:57:57 +0100 |
commit | da38bffa324a11441c1b8e3cd935d142141ae9ac (patch) | |
tree | c0adfbcf0ba64de37cb1bb865f80ace50e6369ed /sw | |
parent | d768757872ad25219fa291acd623ab98924acaaa (diff) |
use fastparser in SwXMLBodyContext_Impl
Change-Id: I0745fb6eb0a46b1c564cd0f1c596aed5206549b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87181
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 | 37 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltext.cxx | 23 |
3 files changed, 31 insertions, 31 deletions
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 743eb5ef1325..416dba1b12bc 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -129,19 +129,16 @@ class SwXMLBodyContext_Impl : public SvXMLImportContext public: - SwXMLBodyContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName ); + SwXMLBodyContext_Impl( SwXMLImport& rImport ); - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; } -SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName) : - SvXMLImportContext( rImport, nPrfx, rLName ) +SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport ) : + SvXMLImportContext( rImport ) { // tdf#107211: if at this point we don't have a defined char style "Default" // or "Default Style", add a mapping for it as it is not written @@ -169,12 +166,11 @@ SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport, } } -SvXMLImportContextRef SwXMLBodyContext_Impl::CreateChildContext( - sal_uInt16 /*nPrefix*/, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLBodyContext_Impl::createFastChildContext( + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) { - return GetSwImport().CreateBodyContentContext( rLocalName ); + return GetSwImport().CreateBodyContentContext(); } namespace { @@ -238,6 +234,13 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): return GetSwImport().CreateFontDeclsContext(); break; + case XML_ELEMENT(OFFICE, XML_META): + OSL_FAIL(" XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?"); + break; + case XML_ELEMENT(OFFICE, XML_BODY): + GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return new SwXMLBodyContext_Impl( GetSwImport() ); + break; } return nullptr; } @@ -252,14 +255,6 @@ SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext( const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap(); switch( rTokenMap.Get( nPrefix, rLocalName ) ) { - case XML_TOK_DOC_META: - OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); - break; - case XML_TOK_DOC_BODY: - GetSwImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = new SwXMLBodyContext_Impl( GetSwImport(), nPrefix, - rLocalName ); - break; case XML_TOK_DOC_XFORMS: pContext = createXFormsModelContext(GetImport(), nPrefix, rLocalName); break; diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index eaa5a151645a..b06f43d0168a 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -138,7 +138,7 @@ public: SvXMLImportContext *CreateStylesContext( bool bAuto ); SvXMLImportContext *CreateMasterStylesContext(); SvXMLImportContext *CreateFontDeclsContext(); - SvXMLImportContext *CreateBodyContentContext( const OUString& rLocalName ); + SvXMLImportContext *CreateBodyContentContext(); SfxStyleFamily GetStyleFamilyMask() const { return m_nStyleFamilyMask; } bool IsInsertMode() const { return m_bInsert; } bool IsStylesOnlyMode() const { return !m_bLoadDoc; } diff --git a/sw/source/filter/xml/xmltext.cxx b/sw/source/filter/xml/xmltext.cxx index 5514d9cc0efe..e4bf212a3124 100644 --- a/sw/source/filter/xml/xmltext.cxx +++ b/sw/source/filter/xml/xmltext.cxx @@ -32,22 +32,28 @@ class SwXMLBodyContentContext_Impl : public SvXMLImportContext public: - SwXMLBodyContentContext_Impl( SwXMLImport& rImport, const OUString& rLName ); + SwXMLBodyContentContext_Impl( SwXMLImport& rImport ); + + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override + { return nullptr; } virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< xml::sax::XAttributeList > & xAttrList ) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + // The body element's text:global attribute can be ignored, because // we must have the correct object shell already. - virtual void EndElement() override; + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; }; } -SwXMLBodyContentContext_Impl::SwXMLBodyContentContext_Impl( SwXMLImport& rImport, - const OUString& rLName ) : - SvXMLImportContext( rImport, XML_NAMESPACE_OFFICE, rLName ) +SwXMLBodyContentContext_Impl::SwXMLBodyContentContext_Impl( SwXMLImport& rImport ) : + SvXMLImportContext( rImport ) { } @@ -62,19 +68,18 @@ SvXMLImportContextRef SwXMLBodyContentContext_Impl::CreateChildContext( return pContext; } -void SwXMLBodyContentContext_Impl::EndElement() +void SwXMLBodyContentContext_Impl::endFastElement(sal_Int32 ) { /* Code moved to SwXMLOmport::endDocument */ GetImport().GetTextImport()->SetOutlineStyles( false ); } -SvXMLImportContext *SwXMLImport::CreateBodyContentContext( - const OUString& rLocalName ) +SvXMLImportContext *SwXMLImport::CreateBodyContentContext() { SvXMLImportContext *pContext = nullptr; if( !IsStylesOnlyMode() ) - pContext = new SwXMLBodyContentContext_Impl( *this, rLocalName ); + pContext = new SwXMLBodyContentContext_Impl( *this ); return pContext; } |