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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 1 15:31:05 UTC 2020


 xmloff/source/text/XMLChangedRegionImportContext.cxx |   31 ++++++++-----------
 xmloff/source/text/XMLChangedRegionImportContext.hxx |    5 +--
 2 files changed, 17 insertions(+), 19 deletions(-)

New commits:
commit 380e3fdc8a0ca86429ab44669820f09dad1a6fb8
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Tue Dec 1 10:24:14 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 1 16:30:21 2020 +0100

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

diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx
index aa257bf50ef8..a0f11b97d3ff 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.cxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx
@@ -50,42 +50,39 @@ XMLChangedRegionImportContext::~XMLChangedRegionImportContext()
 {
 }
 
-void XMLChangedRegionImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLChangedRegionImportContext::startFastElement(
+    sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
 {
     // process attributes: id
     bool bHaveXmlId( false );
-    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 );
-
-        const OUString sValue = xAttrList->getValueByIndex(nAttr);
-        if (XML_NAMESPACE_XML == nPrefix)
+        const OUString sValue = aIter.toString();
+        switch(aIter.getToken())
         {
-            if (IsXMLToken(sLocalName, XML_ID))
+            case XML_ELEMENT(XML, XML_ID):
             {
                 sID = sValue;
                 bHaveXmlId = true;
+                break;
             }
-        }
-        else if (XML_NAMESPACE_TEXT == nPrefix)
-        {
-            if (IsXMLToken(sLocalName, XML_ID))
+            case XML_ELEMENT(TEXT, XML_ID):
             {
                 if (!bHaveXmlId) { sID = sValue; }
+                break;
             }
-            else if( IsXMLToken( sLocalName, XML_MERGE_LAST_PARAGRAPH ) )
+            case XML_ELEMENT(TEXT, XML_MERGE_LAST_PARAGRAPH):
             {
                 bool bTmp(false);
                 if (::sax::Converter::convertBool(bTmp, sValue))
                 {
                     bMergeLastPara = bTmp;
                 }
+                break;
             }
+            default:
+                XMLOFF_WARN_UNKNOWN("xmloff", aIter);
         }
     }
 }
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.hxx b/xmloff/source/text/XMLChangedRegionImportContext.hxx
index 2964790f8fcc..97c545cbb58c 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.hxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.hxx
@@ -57,8 +57,9 @@ public:
 
     virtual ~XMLChangedRegionImportContext() override;
 
-    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 css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
         sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;


More information about the Libreoffice-commits mailing list