xmloff/inc/XMLLineNumberingImportContext.hxx                  |   11 +---
 xmloff/source/style/xmlstyle.cxx                              |   10 +--
 xmloff/source/text/XMLLineNumberingImportContext.cxx          |   24 +++------
 xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx |   26 +++-------
 xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx |   11 +---
 5 files changed, 31 insertions(+), 51 deletions(-)

New commits:
commit 6e64e2e2d23e8a776f6e7fe53f45f18145f80bda
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Aug 21 10:07:14 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 21 19:03:51 2020 +0200

    use fastparser in XMLLineNumberingImportContext
    
    Change-Id: Ib6e590eccffea94dccc4b943d3cf92124882c064
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101170
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/xmloff/inc/XMLLineNumberingImportContext.hxx 
b/xmloff/inc/XMLLineNumberingImportContext.hxx
index 90f7831b672e..852f3076d574 100644
--- a/xmloff/inc/XMLLineNumberingImportContext.hxx
+++ b/xmloff/inc/XMLLineNumberingImportContext.hxx
@@ -68,9 +68,8 @@ public:
 
     XMLLineNumberingImportContext(
         SvXMLImport& rImport,
-        sal_uInt16 nPrfx,
-        const OUString& rLocalName,
-        const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList);
+        sal_Int32 nElement,
+        const css::uno::Reference<css::xml::sax::XFastAttributeList> & 
xAttrList);
 
     virtual ~XMLLineNumberingImportContext() override;
 
@@ -86,10 +85,8 @@ private:
 
     virtual void CreateAndInsert(bool bOverwrite) override;
 
-    virtual SvXMLImportContextRef CreateChildContext(
-        sal_uInt16 nPrefix,
-        const OUString& rLocalName,
-        const css::uno::Reference<css::xml::sax::XAttributeList> & 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;
 };
 
 #endif
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 2a98fbfaf509..a4e3d158ccea 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -424,6 +424,11 @@ SvXMLStyleContext 
*SvXMLStylesContext::CreateStyleChildContext(
             pStyle = new XMLFootnoteConfigurationImportContext(
                 GetImport(), nElement, xAttrList);
             break;
+        case XML_ELEMENT(TEXT, XML_LINENUMBERING_CONFIGURATION):
+            pStyle = new XMLLineNumberingImportContext(
+                GetImport(), nElement, xAttrList);
+            break;
+
     }
 
     return pStyle;
@@ -486,11 +491,6 @@ SvXMLStyleContext 
*SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPr
                                                     rLocalName, xAttrList, 
true );
                 break;
 
-            case XML_TOK_TEXT_LINENUMBERING_CONFIG:
-                pStyle = new XMLLineNumberingImportContext(
-                    GetImport(), p_nPrefix, rLocalName, xAttrList);
-                break;
-
 
             // FillStyles
 
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx 
b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index 3c272c25214a..09de0382b780 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -40,6 +40,7 @@ using namespace ::xmloff::token;
 
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
 using ::com::sun::star::text::XLineNumberingProperties;
 
 
@@ -57,10 +58,9 @@ const OUStringLiteral 
gsSeparatorInterval("SeparatorInterval");
 
 XMLLineNumberingImportContext::XMLLineNumberingImportContext(
     SvXMLImport& rImport,
-    sal_uInt16 nPrfx,
-    const OUString& rLocalName,
-    const Reference<XAttributeList> & xAttrList)
-:   SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList, 
XmlStyleFamily::TEXT_LINENUMBERINGCONFIG)
+    sal_Int32 nElement,
+    const Reference<XFastAttributeList> & xAttrList)
+:   SvXMLStyleContext(rImport, nElement, xAttrList, 
XmlStyleFamily::TEXT_LINENUMBERINGCONFIG)
 ,   sNumFormat(GetXMLToken(XML_1))
 ,   sNumLetterSync(GetXMLToken(XML_FALSE))
 ,   nOffset(-1)
@@ -244,18 +244,12 @@ void XMLLineNumberingImportContext::CreateAndInsert(bool)
     xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType));
 }
 
-SvXMLImportContextRef XMLLineNumberingImportContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const Reference<XAttributeList> & /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
XMLLineNumberingImportContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
-    if ( (nPrefix == XML_NAMESPACE_TEXT) &&
-         IsXMLToken(rLocalName, XML_LINENUMBERING_SEPARATOR) )
-    {
-        return new XMLLineNumberingSeparatorImportContext(GetImport(),
-                                                          nPrefix, rLocalName,
-                                                          *this);
-    }
+    if ( nElement == XML_ELEMENT(TEXT, XML_LINENUMBERING_SEPARATOR) )
+        return new XMLLineNumberingSeparatorImportContext(GetImport(), *this);
     return nullptr;
 }
 
diff --git a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx 
b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
index c0d90be3983d..8d6269235ed6 100644
--- a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
@@ -37,10 +37,8 @@ using ::xmloff::token::XML_INCREMENT;
 
 XMLLineNumberingSeparatorImportContext::XMLLineNumberingSeparatorImportContext(
     SvXMLImport& rImport,
-    sal_uInt16 nPrfx,
-    const OUString& rLocalName,
     XMLLineNumberingImportContext& rLineNumbering) :
-        SvXMLImportContext(rImport, nPrfx, rLocalName),
+        SvXMLImportContext(rImport),
         rLineNumberingContext(rLineNumbering)
 {
 }
@@ -49,22 +47,16 @@ 
XMLLineNumberingSeparatorImportContext::~XMLLineNumberingSeparatorImportContext(
 {
 }
 
-void XMLLineNumberingSeparatorImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLLineNumberingSeparatorImportContext::startFastElement(
+    sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
 {
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 i=0; i<nLength; i++)
+    for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
     {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
-
-        if ( (nPrefix == XML_NAMESPACE_TEXT) &&
-             IsXMLToken(sLocalName, XML_INCREMENT) )
+        if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_INCREMENT) )
         {
             sal_Int32 nTmp;
-            if (::sax::Converter::convertNumber(
-                nTmp, xAttrList->getValueByIndex(i), 0))
+            if (::sax::Converter::convertNumber(nTmp, aIter.toString(), 0))
             {
                 
rLineNumberingContext.SetSeparatorIncrement(static_cast<sal_Int16>(nTmp));
             }
@@ -74,13 +66,13 @@ void XMLLineNumberingSeparatorImportContext::StartElement(
     }
 }
 
-void XMLLineNumberingSeparatorImportContext::Characters(
+void XMLLineNumberingSeparatorImportContext::characters(
     const OUString& rChars )
 {
     sSeparatorBuf.append(rChars);
 }
 
-void XMLLineNumberingSeparatorImportContext::EndElement()
+void XMLLineNumberingSeparatorImportContext::endFastElement(sal_Int32 )
 {
     rLineNumberingContext.SetSeparatorText(sSeparatorBuf.makeStringAndClear());
 }
diff --git a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx 
b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
index a42b28fe4e5b..c3ec804d6a34 100644
--- a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
+++ b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
@@ -43,21 +43,18 @@ public:
 
     XMLLineNumberingSeparatorImportContext(
         SvXMLImport& rImport,
-        sal_uInt16 nPrfx,
-        const OUString& rLocalName,
         XMLLineNumberingImportContext& rLineNumbering);
 
     virtual ~XMLLineNumberingSeparatorImportContext() override;
 
 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 >& ) 
override;
 
-    virtual void Characters( const OUString& rChars ) override;
+    virtual void SAL_CALL characters( const OUString& rChars ) override;
 
-    virtual void EndElement() override;
+    virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
 
 #endif
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to