diff options
author | Noel <noelgrandin@gmail.com> | 2020-12-01 08:24:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-01 09:12:21 +0100 |
commit | 102fdc08b86599b9e538d2f38df865d56b3ec63d (patch) | |
tree | ad1b8d47cadf51d9c1e93d6a638863724f39289d /xmloff | |
parent | e5e3fc015520990df851e5d020219cb6c9d1eb11 (diff) |
fastparser in XMLIndexTemplateContext
Change-Id: Ifba92d0ea59630aff450e7b3a3468052e2f7cb19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106921
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLIndexTemplateContext.cxx | 51 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexTemplateContext.hxx | 5 |
2 files changed, 22 insertions, 34 deletions
diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx index 2c23fe3227f8..32e2ad5b4e27 100644 --- a/xmloff/source/text/XMLIndexTemplateContext.cxx +++ b/xmloff/source/text/XMLIndexTemplateContext.cxx @@ -95,44 +95,31 @@ void XMLIndexTemplateContext::addTemplateEntry( } -void XMLIndexTemplateContext::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLIndexTemplateContext::startFastElement( + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { // process two attributes: style-name, outline-level - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - if (XML_NAMESPACE_TEXT == nPrefix) + if (aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) ) { - if ( IsXMLToken( sLocalName, XML_STYLE_NAME ) ) - { - // style name - sStyleName = xAttrList->getValueByIndex(nAttr); - bStyleNameOK = true; - } - else if (eOutlineLevelAttrName != XML_TOKEN_INVALID) + // style name + sStyleName = aIter.toString(); + bStyleNameOK = true; + } + else if (eOutlineLevelAttrName != XML_TOKEN_INVALID && + aIter.getToken() == XML_ELEMENT(TEXT, eOutlineLevelAttrName)) + { + // we have an attr name! Then see if we have the attr, too. + // outline level + sal_uInt16 nTmp; + if (SvXMLUnitConverter::convertEnum(nTmp, aIter.toString(), pOutlineLevelNameMap)) { - // we have an attr name! Then see if we have the attr, too. - if (IsXMLToken(sLocalName, eOutlineLevelAttrName)) - { - // outline level - sal_uInt16 nTmp; - if (SvXMLUnitConverter::convertEnum( - nTmp, xAttrList->getValueByIndex(nAttr), - pOutlineLevelNameMap)) - { - nOutlineLevel = nTmp; - bOutlineLevelOK = true; - } - // else: illegal value -> ignore - } - // else: unknown attribute -> ignore + nOutlineLevel = nTmp; + bOutlineLevelOK = true; } - // else: we don't care about outline-level -> ignore + // else: illegal value -> ignore } // else: attribute not in text namespace -> ignore } diff --git a/xmloff/source/text/XMLIndexTemplateContext.hxx b/xmloff/source/text/XMLIndexTemplateContext.hxx index b1a5ede7eab9..2aa8a9db56c7 100644 --- a/xmloff/source/text/XMLIndexTemplateContext.hxx +++ b/xmloff/source/text/XMLIndexTemplateContext.hxx @@ -112,8 +112,9 @@ public: protected: - virtual void StartElement( - const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; + virtual void SAL_CALL startFastElement( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; |