diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-20 14:22:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-20 17:04:55 +0100 |
commit | 6d63302127be4f7ebc12369cde286d7e5114ad63 (patch) | |
tree | 399cb5aa7de27af990520f871c1c9cd130eb025f | |
parent | d6c56306140a9665cb80fd35b9711a93ffdffc46 (diff) |
fastparser in SdXMLLayerContext
Change-Id: I807c9028fa197079da79270f8d7ad9339d7bedf4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106228
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | xmloff/source/draw/layerimp.cxx | 49 | ||||
-rw-r--r-- | xmloff/source/draw/layerimp.hxx | 10 | ||||
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 4 |
3 files changed, 23 insertions, 40 deletions
diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx index ab809d320695..e7af0c3f5499 100644 --- a/xmloff/source/draw/layerimp.cxx +++ b/xmloff/source/draw/layerimp.cxx @@ -53,7 +53,7 @@ namespace { class SdXMLLayerContext : public SvXMLImportContext { public: - SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager ); + SdXMLLayerContext( SvXMLImport& rImport, const Reference< XFastAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager ); virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; @@ -69,30 +69,26 @@ private: } -SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager ) -: SvXMLImportContext(rImport, nPrefix, rLocalName) +SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, const Reference< XFastAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager ) +: SvXMLImportContext(rImport) , mxLayerManager( xLayerManager ) { - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString aLocalName; - if( GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &aLocalName ) == XML_NAMESPACE_DRAW ) + OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - const OUString sValue( xAttrList->getValueByIndex( i ) ); - - if( IsXMLToken( aLocalName, XML_NAME ) ) - { + case XML_ELEMENT(DRAW, XML_NAME): msName = sValue; - } - else if ( IsXMLToken( aLocalName, XML_DISPLAY)) - { + break; + case XML_ELEMENT(DRAW, XML_DISPLAY): msDisplay = sValue; - } - else if ( IsXMLToken( aLocalName, XML_PROTECTED)) - { + break; + case XML_ELEMENT(DRAW, XML_PROTECTED): msProtected = sValue; - } + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } @@ -172,16 +168,6 @@ void SdXMLLayerContext::endFastElement(sal_Int32 ) } -SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>&) -: SvXMLImportContext(rImport, nPrfx, rLocalName) -{ - Reference< XLayerSupplier > xLayerSupplier( rImport.GetModel(), UNO_QUERY ); - SAL_WARN_IF( !xLayerSupplier.is(), "xmloff", "xmloff::SdXMLLayerSetContext::SdXMLLayerSetContext(), XModel is not supporting XLayerSupplier!" ); - if( xLayerSupplier.is() ) - mxLayerManager = xLayerSupplier->getLayerManager(); -} - SdXMLLayerSetContext::SdXMLLayerSetContext( SvXMLImport& rImport ) : SvXMLImportContext(rImport) { @@ -195,10 +181,11 @@ SdXMLLayerSetContext::~SdXMLLayerSetContext() { } -SvXMLImportContextRef SdXMLLayerSetContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLLayerSetContext::createFastChildContext( + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - return new SdXMLLayerContext( GetImport(), nPrefix, rLocalName, xAttrList, mxLayerManager ); + return new SdXMLLayerContext( GetImport(), xAttrList, mxLayerManager ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/layerimp.hxx b/xmloff/source/draw/layerimp.hxx index aa1869473ddc..1f31916e5325 100644 --- a/xmloff/source/draw/layerimp.hxx +++ b/xmloff/source/draw/layerimp.hxx @@ -31,16 +31,12 @@ private: css::uno::Reference< css::container::XNameAccess > mxLayerManager; public: - - SdXMLLayerSetContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList); SdXMLLayerSetContext( SvXMLImport& rImport ); virtual ~SdXMLLayerSetContext() override; - virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const css::uno::Reference< css::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; }; #endif // INCLUDED_XMLOFF_SOURCE_DRAW_LAYERIMP_HXX diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index 10720869eaa3..9e4fc706fe96 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -1363,13 +1363,13 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLMasterStylesConte SvXMLImportContextRef SdXMLMasterStylesContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList) + const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/) { SvXMLImportContextRef xContext; if( (nPrefix == XML_NAMESPACE_DRAW) && IsXMLToken( rLocalName, XML_LAYER_SET ) ) { - xContext = new SdXMLLayerSetContext( GetImport(), nPrefix, rLocalName, xAttrList ); + xContext = new SdXMLLayerSetContext( GetImport() ); } return xContext; |