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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 21 07:30:46 UTC 2019


 xmloff/source/text/XMLSectionSourceImportContext.cxx |   52 +++++--------------
 xmloff/source/text/XMLSectionSourceImportContext.hxx |    6 +-
 2 files changed, 18 insertions(+), 40 deletions(-)

New commits:
commit ccdcc25a085299bda45bc5ea4b3594e856f2d315
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Dec 20 15:12:15 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Dec 21 08:29:31 2019 +0100

    convert XMLSectionSourceImportContext to FastParser APIs
    
    Change-Id: I488d0e521a445055a33a7972d78005047b2c5b2f
    Reviewed-on: https://gerrit.libreoffice.org/85647
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/text/XMLSectionSourceImportContext.cxx b/xmloff/source/text/XMLSectionSourceImportContext.cxx
index 2ae4e671f7c0..82e01979ab0c 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.cxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.cxx
@@ -32,6 +32,7 @@
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::uno::Reference;
 using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::text;
@@ -52,54 +53,31 @@ XMLSectionSourceImportContext::~XMLSectionSourceImportContext()
 {
 }
 
-namespace {
-enum XMLSectionSourceToken
-{
-    XML_TOK_SECTION_XLINK_HREF,
-    XML_TOK_SECTION_TEXT_FILTER_NAME,
-    XML_TOK_SECTION_TEXT_SECTION_NAME
-};
-
-}
-
-static const SvXMLTokenMapEntry aSectionSourceTokenMap[] =
-{
-    { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF },
-    { XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME },
-    { XML_NAMESPACE_TEXT, XML_SECTION_NAME,
-                                        XML_TOK_SECTION_TEXT_SECTION_NAME },
-    XML_TOKEN_MAP_END
-};
-
 
-void XMLSectionSourceImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLSectionSourceImportContext::startFastElement(sal_Int32 /*nElement*/,
+    const Reference<XFastAttributeList> & xAttrList)
 {
-    static const SvXMLTokenMap aTokenMap(aSectionSourceTokenMap);
     OUString sURL;
     OUString sFilterName;
     OUString sSectionName;
 
-    sal_Int16 nLength = xAttrList->getLength();
-    for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
-    {
-        OUString sLocalName;
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
-            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
-                              &sLocalName );
+    sax_fastparser::FastAttributeList *pAttribList =
+            sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
 
-        switch (aTokenMap.Get(nPrefix, sLocalName))
+    for (auto &aIter : *pAttribList)
+    {
+        switch (aIter.getToken())
         {
-            case XML_TOK_SECTION_XLINK_HREF:
-                sURL = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(XLINK, XML_HREF):
+                sURL = aIter.toString();
                 break;
 
-            case XML_TOK_SECTION_TEXT_FILTER_NAME:
-                sFilterName = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(TEXT, XML_FILTER_NAME):
+                sFilterName = aIter.toString();
                 break;
 
-            case XML_TOK_SECTION_TEXT_SECTION_NAME:
-                sSectionName = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(TEXT, XML_SECTION_NAME):
+                sSectionName = aIter.toString();
                 break;
 
             default:
@@ -127,7 +105,7 @@ void XMLSectionSourceImportContext::StartElement(
     }
 }
 
-void XMLSectionSourceImportContext::EndElement()
+void XMLSectionSourceImportContext::endFastElement(sal_Int32 /*nElement*/)
 {
     // this space intentionally left blank.
 }
diff --git a/xmloff/source/text/XMLSectionSourceImportContext.hxx b/xmloff/source/text/XMLSectionSourceImportContext.hxx
index 865e9753ff6f..838375ff7e78 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.hxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.hxx
@@ -45,10 +45,10 @@ 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 EndElement() override;
+    virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
 
 #endif


More information about the Libreoffice-commits mailing list