[Libreoffice-commits] core.git: xmloff/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 1 08:12:58 UTC 2020


 xmloff/source/text/XMLIndexTemplateContext.cxx |   51 +++++++++----------------
 xmloff/source/text/XMLIndexTemplateContext.hxx |    5 +-
 2 files changed, 22 insertions(+), 34 deletions(-)

New commits:
commit 102fdc08b86599b9e538d2f38df865d56b3ec63d
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Tue Dec 1 08:24:03 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 1 09:12:21 2020 +0100

    fastparser in XMLIndexTemplateContext
    
    Change-Id: Ifba92d0ea59630aff450e7b3a3468052e2f7cb19
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106921
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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;
 


More information about the Libreoffice-commits mailing list