diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-21 16:59:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-21 17:56:56 +0100 |
commit | 998308c363dfad03143591aa18256d2669b4da11 (patch) | |
tree | 1eec3bb9ab79fa54d3bfc37c6bc969349ab24909 /xmloff | |
parent | 63b7e282a598ff5dc9d665127f567b20adc56f24 (diff) |
use more FastParser in SvXMLStylesContext
Change-Id: I05c7314739246a864b16723c13bd8fbb4ef725e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87146
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/SchXMLImport.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLImport.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/chart/contexts.cxx | 28 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 46 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp_impl.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/ximpstyl.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMasterStylesContext.cxx | 6 |
9 files changed, 60 insertions, 54 deletions
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 73e726fe03d6..690038c80bf8 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -162,8 +162,7 @@ public: virtual ~SchXMLImport() throw () override; - SvXMLImportContext* CreateStylesContext( const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ); + SvXMLImportContext* CreateStylesContext(); // XImporter virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 3432da7906fd..354e4ae4cf85 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -529,15 +529,12 @@ SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement, return pContext; } -SvXMLImportContext* SchXMLImport::CreateStylesContext( - const OUString& rLocalName, - const Reference<xml::sax::XAttributeList>& xAttrList ) +SvXMLImportContext* SchXMLImport::CreateStylesContext() { //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!) SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() ); - SvXMLStylesContext* pStylesCtxt = - new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList ); + SvXMLStylesContext* pStylesCtxt = new SvXMLStylesContext( *this ); // set context at base class, so that all auto-style classes are imported SetAutoStyles( pStylesCtxt ); diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index d2059a1a44e7..218a91e194a2 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -84,26 +84,13 @@ SchXMLDocContext::~SchXMLDocContext() SvXMLImportContextRef SchXMLDocContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) + const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ ) { SvXMLImportContextRef xContext; const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap(); - SvXMLImportFlags nFlags = GetImport().getImportFlags(); switch( rTokenMap.Get( nPrefix, rLocalName )) { - case XML_TOK_DOC_AUTOSTYLES: - if( nFlags & SvXMLImportFlags::AUTOSTYLES ) - // not nice, but this is safe, as the SchXMLDocContext class can only by - // instantiated by the chart import class SchXMLImport (header is not exported) - xContext = - static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList ); - break; - case XML_TOK_DOC_STYLES: - // for draw styles containing gradients/hatches/markers and dashes - if( nFlags & SvXMLImportFlags::STYLES ) - xContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList ); - break; case XML_TOK_DOC_META: // we come here in the flat ODF file format, // if XDocumentPropertiesSupplier is not supported at the model @@ -122,6 +109,19 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::creat case XML_ELEMENT(OFFICE, XML_BODY): if( nFlags & SvXMLImportFlags::CONTENT ) return new SchXMLBodyContext_Impl( mrImportHelper, GetImport() ); + break; + case XML_ELEMENT(OFFICE, XML_STYLES): + // for draw styles containing gradients/hatches/markers and dashes + if( nFlags & SvXMLImportFlags::STYLES ) + return new SvXMLStylesContext( GetImport() ); + break; + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + if( nFlags & SvXMLImportFlags::AUTOSTYLES ) + // not nice, but this is safe, as the SchXMLDocContext class can only by + // instantiated by the chart import class SchXMLImport (header is not exported) + return + static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext(); + break; } return nullptr; } diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index b14251d98e6c..7ccf05c73ff4 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -129,24 +129,6 @@ SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext( xContext = GetSdImport().CreateFontDeclsContext( rLocalName, xAttrList ); break; } - case XML_TOK_DOC_STYLES: - { - if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES ) - { - // office:styles inside office:document - xContext = GetSdImport().CreateStylesContext(rLocalName, xAttrList); - } - break; - } - case XML_TOK_DOC_AUTOSTYLES: - { - if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES ) - { - // office:automatic-styles inside office:document - xContext = GetSdImport().CreateAutoStylesContext(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?"); @@ -197,6 +179,24 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::c } break; } + case XML_ELEMENT(OFFICE, XML_STYLES): + { + if( GetImport().getImportFlags() & SvXMLImportFlags::STYLES ) + { + // office:styles inside office:document + return GetSdImport().CreateStylesContext(); + } + break; + } + case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES): + { + if( GetImport().getImportFlags() & SvXMLImportFlags::AUTOSTYLES ) + { + // office:automatic-styles inside office:document + return GetSdImport().CreateAutoStylesContext(); + } + break; + } } return nullptr; } @@ -702,26 +702,24 @@ SvXMLImportContext *SdXMLImport::CreateMetaContext(const sal_Int32 /*nElement*/, return pContext; } -SvXMLStylesContext *SdXMLImport::CreateStylesContext(const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) +SvXMLStylesContext *SdXMLImport::CreateStylesContext() { if(GetShapeImport()->GetStylesContext()) return GetShapeImport()->GetStylesContext(); GetShapeImport()->SetStylesContext(new SdXMLStylesContext( - *this, rLocalName, xAttrList, false)); + *this, false)); return GetShapeImport()->GetStylesContext(); } -SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext(const OUString& rLocalName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList) +SvXMLStylesContext *SdXMLImport::CreateAutoStylesContext() { if(GetShapeImport()->GetAutoStylesContext()) return GetShapeImport()->GetAutoStylesContext(); GetShapeImport()->SetAutoStylesContext(new SdXMLStylesContext( - *this, rLocalName, xAttrList, true)); + *this, true)); return GetShapeImport()->GetAutoStylesContext(); } diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index 32f9690634f3..93fc2f242153 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -202,10 +202,8 @@ public: // the root element (i.e. office:document-meta) SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList); - SvXMLStylesContext* CreateStylesContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList); - SvXMLStylesContext* CreateAutoStylesContext(const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList); + SvXMLStylesContext* CreateStylesContext(); + SvXMLStylesContext* CreateAutoStylesContext(); SvXMLImportContext* CreateMasterStylesContext(); SvXMLImportContext *CreateFontDeclsContext(const OUString& rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ); diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index 4d0084bb9412..e1fc43066ddf 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -881,10 +881,8 @@ SvXMLImportContextRef SdXMLMasterPageContext::CreateChildContext( SdXMLStylesContext::SdXMLStylesContext( SdXMLImport& rImport, - const OUString& rLName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList, bool bIsAutoStyle) -: SvXMLStylesContext(rImport, XML_NAMESPACE_OFFICE, rLName, xAttrList), +: SvXMLStylesContext(rImport), mbIsAutoStyle(bIsAutoStyle) { Reference< uno::XComponentContext > xContext = rImport.GetComponentContext(); diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx index b9038609715f..6ca56fd7d3fc 100644 --- a/xmloff/source/draw/ximpstyl.hxx +++ b/xmloff/source/draw/ximpstyl.hxx @@ -205,8 +205,6 @@ public: SdXMLStylesContext( SdXMLImport& rImport, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList, bool bIsAutoStyle); virtual void EndElement() override; diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 352eba7cee7f..1c4bd1f4ea3c 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -754,10 +754,22 @@ SvXMLStylesContext::SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, { } +SvXMLStylesContext::SvXMLStylesContext( SvXMLImport& rImport, bool bAuto ) : + SvXMLImportContext( rImport ), + mpImpl( new SvXMLStylesContext_Impl( bAuto ) ) +{ +} + SvXMLStylesContext::~SvXMLStylesContext() { } +css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLStylesContext::createFastChildContext( + sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) +{ + return nullptr; +} + SvXMLImportContextRef SvXMLStylesContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & xAttrList ) diff --git a/xmloff/source/text/XMLTextMasterStylesContext.cxx b/xmloff/source/text/XMLTextMasterStylesContext.cxx index c8af93f582ba..228e36cc1ee9 100644 --- a/xmloff/source/text/XMLTextMasterStylesContext.cxx +++ b/xmloff/source/text/XMLTextMasterStylesContext.cxx @@ -44,6 +44,12 @@ XMLTextMasterStylesContext::XMLTextMasterStylesContext( { } +XMLTextMasterStylesContext::XMLTextMasterStylesContext( + SvXMLImport& rImport ) : + SvXMLStylesContext( rImport ) +{ +} + XMLTextMasterStylesContext::~XMLTextMasterStylesContext() { } |