diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-22 09:55:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-22 09:37:08 +0100 |
commit | e9262376f0acbe67a544d7e391992c9943ed6d8b (patch) | |
tree | 690d30eaa5172f3188827091927e46a11708b508 | |
parent | 6f6a64952d9aa4826e83ad94c2a6de2344cbe2de (diff) |
use fastparser for XMLFontStylesContext
Change-Id: I7b273cdc0f90f2a8c9527d1f19fed97672a74741
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87175
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/xmloff/XMLFontStylesContext.hxx | 6 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlfilter.cxx | 30 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlfilter.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 6 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 46 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp_impl.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/XMLFontStylesContext.cxx | 4 |
10 files changed, 46 insertions, 86 deletions
diff --git a/include/xmloff/XMLFontStylesContext.hxx b/include/xmloff/XMLFontStylesContext.hxx index 7759a57d81e5..5f97f9b772aa 100644 --- a/include/xmloff/XMLFontStylesContext.hxx +++ b/include/xmloff/XMLFontStylesContext.hxx @@ -51,11 +51,7 @@ class XMLOFF_DLLPUBLIC XMLFontStylesContext final : public SvXMLStylesContext public: - - XMLFontStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, - rtl_TextEncoding eDfltEnc ); + XMLFontStylesContext( SvXMLImport& rImport, rtl_TextEncoding eDfltEnc ); ~XMLFontStylesContext() override; diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index fcd130727dae..46ed887f092c 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -621,8 +621,16 @@ public: 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 + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override { + ORptFilter & rImport(static_cast<ORptFilter&>(GetImport())); + switch (nElement) + { + case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return rImport.CreateFontDeclsContext(); + break; + } return nullptr; } @@ -644,10 +652,6 @@ public: // don't use the autostyles from the styles-document for the progress pContext = rImport.CreateStylesContext(rLocalName, xAttrList, true); break; - case XML_TOK_CONTENT_FONTDECLS: - rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = rImport.CreateFontDeclsContext(rLocalName, xAttrList); - break; case XML_TOK_CONTENT_MASTERSTYLES: { SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(rImport, nPrefix, rLocalName, xAttrList);//CreateMasterStylesContext( rLocalName,xAttrList ); @@ -709,6 +713,10 @@ public: case XML_ELEMENT(OFFICE, XML_BODY): return new RptXMLDocumentBodyContext(rImport); break; + case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): + rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); + return rImport.CreateFontDeclsContext(); + break; } return nullptr; } @@ -727,10 +735,6 @@ public: rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); pContext = rImport.CreateStylesContext(rLocalName, xAttrList, true); break; - case XML_TOK_CONTENT_FONTDECLS: - rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - pContext = rImport.CreateFontDeclsContext(rLocalName, xAttrList); - break; default: break; } @@ -1023,14 +1027,10 @@ SvXMLImportContext* ORptFilter::CreateStylesContext(const OUString& rLocalName, return pContext; } -SvXMLImportContext *ORptFilter::CreateFontDeclsContext( - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *ORptFilter::CreateFontDeclsContext() { XMLFontStylesContext *pFSContext = - new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, - rLocalName, xAttrList, - osl_getThreadTextEncoding() ); + new XMLFontStylesContext( *this, osl_getThreadTextEncoding() ); SetFontDecls( pFSContext ); return pFSContext; } diff --git a/reportdesign/source/filter/xml/xmlfilter.hxx b/reportdesign/source/filter/xml/xmlfilter.hxx index 6257832567fa..ec8ba1509e67 100644 --- a/reportdesign/source/filter/xml/xmlfilter.hxx +++ b/reportdesign/source/filter/xml/xmlfilter.hxx @@ -96,8 +96,7 @@ public: SvXMLImportContext* CreateStylesContext(const OUString& rLocalName, const Reference< XAttributeList>& xAttrList, bool bIsAutoStyle ); SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement); - SvXMLImportContext* CreateFontDeclsContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext* CreateFontDeclsContext(); protected: // SvXMLImport virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement, diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index fdc16dfd477d..c6875dcb9438 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -353,10 +353,6 @@ SvXMLImportContextRef ScXMLDocContext_Impl::CreateChildContext( sal_uInt16 nPref const SvXMLTokenMap& rTokenMap(GetScImport().GetDocElemTokenMap()); switch( rTokenMap.Get( nPrefix, rLocalName ) ) { - case XML_TOK_DOC_FONTDECLS: - if (GetScImport().getImportFlags() & SvXMLImportFlags::FONTDECLS) - pContext = GetScImport().CreateFontDeclsContext(nPrefix, rLocalName, xAttrList); - break; case XML_TOK_DOC_MASTERSTYLES: if (GetScImport().getImportFlags() & SvXMLImportFlags::MASTERSTYLES) pContext = new ScXMLMasterStylesContext( GetImport(), nPrefix, rLocalName, @@ -398,6 +394,10 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL if (GetScImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES) pContext = GetScImport().CreateStylesContext( true); break; + case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): + if (GetScImport().getImportFlags() & SvXMLImportFlags::FONTDECLS) + pContext = GetScImport().CreateFontDeclsContext(); + break; //TODO: handle all other cases } @@ -742,11 +742,10 @@ void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& aArgument xInfoSet->getPropertyValue(SC_UNO_ODS_IMPORT_STYLES) >>= mbImportStyles; } -SvXMLImportContext *ScXMLImport::CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) +SvXMLImportContext *ScXMLImport::CreateFontDeclsContext() { XMLFontStylesContext *pFSContext = new XMLFontStylesContext( - *this, nPrefix, rLocalName, xAttrList, osl_getThreadTextEncoding()); + *this, osl_getThreadTextEncoding()); SetFontDecls(pFSContext); SvXMLImportContext* pContext = pFSContext; return pContext; diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index a471a44a7975..b887796f730e 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -309,10 +309,8 @@ public: // namespace office // NB: in contrast to other CreateFooContexts, this particular one handles // the root element (i.e. office:document-meta) - SvXMLImportContext *CreateMetaContext( - const sal_Int32 nElement ); - SvXMLImportContext *CreateFontDeclsContext(const sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList); + SvXMLImportContext *CreateMetaContext( sal_Int32 nElement ); + SvXMLImportContext *CreateFontDeclsContext(); SvXMLImportContext *CreateScriptContext(); SvXMLImportContext *CreateStylesContext( bool bAutoStyles ); diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 1735a9716140..743eb5ef1325 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -235,6 +235,9 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c case XML_ELEMENT(OFFICE, XML_MASTER_STYLES): return GetSwImport().CreateMasterStylesContext(); break; + case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): + return GetSwImport().CreateFontDeclsContext(); + break; } return nullptr; } @@ -242,17 +245,13 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) + const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) { SvXMLImportContext *pContext = nullptr; const SvXMLTokenMap& rTokenMap = GetSwImport().GetDocElemTokenMap(); switch( rTokenMap.Get( nPrefix, rLocalName ) ) { - case XML_TOK_DOC_FONTDECLS: - pContext = GetSwImport().CreateFontDeclsContext( rLocalName, - xAttrList ); - break; case XML_TOK_DOC_META: OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); break; @@ -1192,14 +1191,10 @@ XMLShapeImportHelper* SwXMLImport::CreateShapeImport() return new SvTextShapeImportHelper( *this ); } -SvXMLImportContext *SwXMLImport::CreateFontDeclsContext( - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *SwXMLImport::CreateFontDeclsContext() { XMLFontStylesContext *pFSContext = - new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, - rLocalName, xAttrList, - osl_getThreadTextEncoding() ); + new XMLFontStylesContext( *this, osl_getThreadTextEncoding() ); SetFontDecls( pFSContext ); return pFSContext; } diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index 10c064b7846c..eaa5a151645a 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -137,9 +137,7 @@ public: SvXMLImportContext *CreateScriptContext(); SvXMLImportContext *CreateStylesContext( bool bAuto ); SvXMLImportContext *CreateMasterStylesContext(); - SvXMLImportContext *CreateFontDeclsContext( - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext *CreateFontDeclsContext(); SvXMLImportContext *CreateBodyContentContext( const OUString& rLocalName ); SfxStyleFamily GetStyleFamilyMask() const { return m_nStyleFamilyMask; } bool IsInsertMode() const { return m_bInsert; } diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 7ccf05c73ff4..d41b52b88173 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -91,10 +91,6 @@ protected: public: SdXMLDocContext_Impl( SdXMLImport& rImport ); - virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::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 >& xAttrList ) override; @@ -114,31 +110,6 @@ SdXMLDocContext_Impl::SdXMLDocContext_Impl( { } -SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) -{ - SvXMLImportContextRef xContext; - - const SvXMLTokenMap& rTokenMap = GetSdImport().GetDocElemTokenMap(); - switch(rTokenMap.Get(nPrefix, rLocalName)) - { - case XML_TOK_DOC_FONTDECLS: - { - xContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList ); - break; - } - case XML_TOK_DOC_META: - { - SAL_INFO("xmloff.draw", "XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); - break; - } - } - - return xContext; -} - uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::createFastChildContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { @@ -197,6 +168,16 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::c } break; } + case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS): + { + return GetSdImport().CreateFontDeclsContext(); + break; + } + case XML_ELEMENT(OFFICE, XML_META): + { + SAL_INFO("xmloff.draw", "XML_ELEMENT(OFFICE, XML_META): should not have come here, maybe document is invalid?"); + break; + } } return nullptr; } @@ -731,13 +712,10 @@ SvXMLImportContext* SdXMLImport::CreateMasterStylesContext() return mxMasterStylesContext.get(); } -SvXMLImportContext *SdXMLImport::CreateFontDeclsContext(const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLImportContext *SdXMLImport::CreateFontDeclsContext() { XMLFontStylesContext *pFSContext = - new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE, - rLocalName, xAttrList, - osl_getThreadTextEncoding() ); + new XMLFontStylesContext( *this, osl_getThreadTextEncoding() ); SetFontDecls( pFSContext ); return pFSContext; } diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index 93fc2f242153..dc304c92a263 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -205,8 +205,7 @@ public: SvXMLStylesContext* CreateStylesContext(); SvXMLStylesContext* CreateAutoStylesContext(); SvXMLImportContext* CreateMasterStylesContext(); - SvXMLImportContext *CreateFontDeclsContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); + SvXMLImportContext *CreateFontDeclsContext(); // Styles and AutoStyles contexts diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx index 3a2840baa6e9..9c3fbb9feb39 100644 --- a/xmloff/source/style/XMLFontStylesContext.cxx +++ b/xmloff/source/style/XMLFontStylesContext.cxx @@ -366,10 +366,8 @@ SvXMLStyleContext *XMLFontStylesContext::CreateStyleChildContext( XMLFontStylesContext::XMLFontStylesContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & xAttrList, rtl_TextEncoding eDfltEnc ) : - SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ), + SvXMLStylesContext( rImport ), pFamilyNameHdl( new XMLFontFamilyNamePropHdl ), pFamilyHdl( new XMLFontFamilyPropHdl ), pPitchHdl( new XMLFontPitchPropHdl ), |