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

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


 xmloff/source/text/XMLFootnoteImportContext.cxx |   33 +++++++-----------------
 xmloff/source/text/XMLFootnoteImportContext.hxx |    5 ++-
 2 files changed, 13 insertions(+), 25 deletions(-)

New commits:
commit 048eebd2f282634ffa2b7b2bc29436adae96769a
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Tue Dec 1 10:21:52 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 1 15:09:27 2020 +0100

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

diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx
index 95a30097675e..7ea3ba22f4ac 100644
--- a/xmloff/source/text/XMLFootnoteImportContext.cxx
+++ b/xmloff/source/text/XMLFootnoteImportContext.cxx
@@ -73,8 +73,9 @@ XMLFootnoteImportContext::XMLFootnoteImportContext(
 {
 }
 
-void XMLFootnoteImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLFootnoteImportContext::startFastElement(
+    sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
 {
     // create footnote
     Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),
@@ -84,18 +85,11 @@ void XMLFootnoteImportContext::StartElement(
 
     // create endnote or footnote
     bool bIsEndnote = false;
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 nAttr1 = 0; nAttr1 < nLength; nAttr1++)
+    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
     {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr1),
-                              &sLocalName );
-        if( XML_NAMESPACE_TEXT == nPrefix && IsXMLToken( sLocalName,
-                                                        XML_NOTE_CLASS ) )
+        if( aIter.getToken() == XML_ELEMENT(TEXT, XML_NOTE_CLASS) )
         {
-            const OUString& rValue = xAttrList->getValueByIndex( nAttr1 );
-            if( IsXMLToken( rValue, XML_ENDNOTE ) )
+            if( IsXMLToken( aIter.toString(), XML_ENDNOTE ) )
                 bIsEndnote = true;
             break;
         }
@@ -111,15 +105,9 @@ void XMLFootnoteImportContext::StartElement(
     rHelper.InsertTextContent(xTextContent);
 
     // process id attribute
-    for(sal_Int16 nAttr2 = 0; nAttr2 < nLength; nAttr2++)
+    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
     {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr2),
-                              &sLocalName );
-
-        if ( (XML_NAMESPACE_TEXT == nPrefix) &&
-             IsXMLToken( sLocalName, XML_ID )   )
+        if( aIter.getToken() == XML_ELEMENT(TEXT, XML_ID) )
         {
             // get ID ...
             Reference<XPropertySet> xPropertySet(xTextContent, UNO_QUERY);
@@ -128,9 +116,8 @@ void XMLFootnoteImportContext::StartElement(
             aAny >>= nID;
 
             // ... and insert into map
-            rHelper.InsertFootnoteID(
-                xAttrList->getValueByIndex(nAttr2),
-                nID);
+            rHelper.InsertFootnoteID( aIter.toString(), nID);
+            break;
         }
     }
 
diff --git a/xmloff/source/text/XMLFootnoteImportContext.hxx b/xmloff/source/text/XMLFootnoteImportContext.hxx
index ff2acc296988..6c20b1a331cd 100644
--- a/xmloff/source/text/XMLFootnoteImportContext.hxx
+++ b/xmloff/source/text/XMLFootnoteImportContext.hxx
@@ -61,8 +61,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