diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-21 15:52:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-23 12:14:28 +0200 |
commit | fecf3807f0229450617f35b36e14db14c7c17c87 (patch) | |
tree | a7ae3b5fa617f0a92f30063fa7189613fb183ce7 /xmloff | |
parent | 2ddf7c865d78f421417a27f3266188461ee8db0d (diff) |
use fastparser in XMLTextMasterStylesContext
Change-Id: I2eaae244264ca9ab726d8e69a3e53a76481b5a36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101173
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLTextMasterPageContext.cxx | 54 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMasterStylesContext.cxx | 12 |
2 files changed, 29 insertions, 37 deletions
diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx index 1b70be760b25..c5b98ea4cc34 100644 --- a/xmloff/source/text/XMLTextMasterPageContext.cxx +++ b/xmloff/source/text/XMLTextMasterPageContext.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <o3tl/any.hxx> +#include <sal/log.hxx> #include <osl/diagnose.h> #include <xmloff/namespacemap.hxx> #include <xmloff/xmlnamespace.hxx> @@ -67,10 +68,10 @@ Reference < XStyle > XMLTextMasterPageContext::Create() const OUStringLiteral gsFollowStyle( "FollowStyle" ); XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > & xAttrList, + sal_Int32 nElement, + const Reference< XFastAttributeList > & xAttrList, bool bOverwrite ) -: SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, XmlStyleFamily::MASTER_PAGE ) +: SvXMLStyleContext( rImport, nElement, xAttrList, XmlStyleFamily::MASTER_PAGE ) , bInsertHeader( false ) , bInsertFooter( false ) , bInsertHeaderLeft( false ) @@ -81,35 +82,28 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport, , bFooterInserted( false ) { OUString sName, sDisplayName; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); - if( XML_NAMESPACE_STYLE == nPrefix ) + const OUString aValue = aIter.toString(); + switch (aIter.getToken()) { - if( IsXMLToken( aLocalName, XML_NAME ) ) - { - sName = xAttrList->getValueByIndex( i ); - } - else if( IsXMLToken( aLocalName, XML_DISPLAY_NAME ) ) - { - sDisplayName = xAttrList->getValueByIndex( i ); - } - else if( IsXMLToken( aLocalName, XML_NEXT_STYLE_NAME ) ) - { - sFollow = xAttrList->getValueByIndex( i ); - } - else if( IsXMLToken( aLocalName, XML_PAGE_LAYOUT_NAME ) ) - { - sPageMasterName = xAttrList->getValueByIndex( i ); - } - } - else if (XML_NAMESPACE_DRAW == nPrefix - && IsXMLToken(aLocalName, XML_STYLE_NAME)) - { - m_sDrawingPageStyle = xAttrList->getValueByIndex(i); + case XML_ELEMENT(STYLE, XML_NAME): + sName = aValue; + break; + case XML_ELEMENT(STYLE, XML_DISPLAY_NAME): + sDisplayName = aValue; + break; + case XML_ELEMENT(STYLE, XML_NEXT_STYLE_NAME): + sFollow = aValue; + break; + case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME): + sPageMasterName = aValue; + break; + case XML_ELEMENT(DRAW, XML_STYLE_NAME): + m_sDrawingPageStyle = aValue; + break; + default: + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString()); } } diff --git a/xmloff/source/text/XMLTextMasterStylesContext.cxx b/xmloff/source/text/XMLTextMasterStylesContext.cxx index 388f2a019a54..46e7e83522e2 100644 --- a/xmloff/source/text/XMLTextMasterStylesContext.cxx +++ b/xmloff/source/text/XMLTextMasterStylesContext.cxx @@ -47,18 +47,16 @@ XMLTextMasterStylesContext::~XMLTextMasterStylesContext() } SvXMLStyleContext *XMLTextMasterStylesContext::CreateStyleChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< XAttributeList > & xAttrList ) + sal_Int32 nElement, + const Reference< XFastAttributeList > & xAttrList ) { SvXMLStyleContext *pContext = nullptr; - if( XML_NAMESPACE_STYLE == nPrefix && - IsXMLToken( rLocalName, XML_MASTER_PAGE ) && + if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE) && InsertStyleFamily( XmlStyleFamily::MASTER_PAGE ) ) pContext = new XMLTextMasterPageContext( - GetImport(), nPrefix, rLocalName, - xAttrList, + GetImport(), nElement, + xAttrList, !GetImport().GetTextImport()->IsInsertMode() ); // any other style will be ignored here! |