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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 21 10:08:26 UTC 2019


 xmloff/source/text/XMLSectionSourceDDEImportContext.cxx |   63 ++++------------
 xmloff/source/text/XMLSectionSourceDDEImportContext.hxx |    6 -
 2 files changed, 20 insertions(+), 49 deletions(-)

New commits:
commit df1e9136d7ed8b1fbe87f128bd1e843020921413
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Dec 20 15:18:04 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Dec 21 11:07:04 2019 +0100

    convert XMLSectionSourceDDEImportContext to FastParser API
    
    Change-Id: I4a2ca35d75a352d5f2b763114de9e9151125f001
    Reviewed-on: https://gerrit.libreoffice.org/85648
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx
index 658056968b16..34a5dedc4ac0 100644
--- a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx
+++ b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx
@@ -33,7 +33,7 @@
 using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::beans::XMultiPropertySet;
 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;
@@ -53,63 +53,34 @@ XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext()
 {
 }
 
-namespace {
-
-enum XMLSectionSourceDDEToken
-{
-    XML_TOK_SECTION_DDE_APPLICATION,
-    XML_TOK_SECTION_DDE_TOPIC,
-    XML_TOK_SECTION_DDE_ITEM,
-    XML_TOK_SECTION_IS_AUTOMATIC_UPDATE
-};
-
-}
-
-static const SvXMLTokenMapEntry aSectionSourceDDETokenMap[] =
-{
-    { XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
-          XML_TOK_SECTION_DDE_APPLICATION },
-    { XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, XML_TOK_SECTION_DDE_TOPIC },
-    { XML_NAMESPACE_OFFICE, XML_DDE_ITEM, XML_TOK_SECTION_DDE_ITEM },
-    { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE,
-          XML_TOK_SECTION_IS_AUTOMATIC_UPDATE },
-    XML_TOKEN_MAP_END
-};
-
-
-void XMLSectionSourceDDEImportContext::StartElement(
-    const Reference<XAttributeList> & xAttrList)
+void XMLSectionSourceDDEImportContext::startFastElement(sal_Int32 /*nElement*/,
+    const Reference<XFastAttributeList> & xAttrList)
 {
-    static const SvXMLTokenMap aTokenMap(aSectionSourceDDETokenMap);
     OUString sApplication;
     OUString sTopic;
     OUString sItem;
     bool bAutomaticUpdate = false;
 
-    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_DDE_APPLICATION:
-                sApplication = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(OFFICE, XML_DDE_APPLICATION):
+                sApplication = aIter.toString();
                 break;
-            case XML_TOK_SECTION_DDE_TOPIC:
-                sTopic = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(OFFICE, XML_DDE_TOPIC):
+                sTopic = aIter.toString();
                 break;
-            case XML_TOK_SECTION_DDE_ITEM:
-                sItem = xAttrList->getValueByIndex(nAttr);
+            case XML_ELEMENT(OFFICE, XML_DDE_ITEM):
+                sItem = aIter.toString();
                 break;
-            case XML_TOK_SECTION_IS_AUTOMATIC_UPDATE:
+            case XML_ELEMENT(OFFICE, XML_AUTOMATIC_UPDATE):
             {
                 bool bTmp(false);
-                if (::sax::Converter::convertBool(
-                    bTmp, xAttrList->getValueByIndex(nAttr)))
+                if (::sax::Converter::convertBool(bTmp, aIter.toString()))
                 {
                     bAutomaticUpdate = bTmp;
                 }
@@ -151,7 +122,7 @@ void XMLSectionSourceDDEImportContext::StartElement(
 
 }
 
-void XMLSectionSourceDDEImportContext::EndElement()
+void XMLSectionSourceDDEImportContext::endFastElement(sal_Int32 /*nElement*/)
 {
     // nothing to be done!
 }
diff --git a/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx b/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx
index 8d6c2b1ddcc9..a67058f680cb 100644
--- a/xmloff/source/text/XMLSectionSourceDDEImportContext.hxx
+++ b/xmloff/source/text/XMLSectionSourceDDEImportContext.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