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

Mohammed Abdul Azeem azeemmysore at gmail.com
Sat Jul 1 04:32:29 UTC 2017


 sc/source/filter/xml/XMLCalculationSettingsContext.cxx |   69 +++----
 sc/source/filter/xml/XMLCalculationSettingsContext.hxx |    7 
 sc/source/filter/xml/XMLConsolidationContext.cxx       |   64 +++---
 sc/source/filter/xml/XMLConsolidationContext.hxx       |    7 
 sc/source/filter/xml/XMLDDELinksContext.cxx            |   11 -
 sc/source/filter/xml/XMLDDELinksContext.hxx            |    7 
 sc/source/filter/xml/XMLTrackedChangesContext.cxx      |   36 +--
 sc/source/filter/xml/XMLTrackedChangesContext.hxx      |    5 
 sc/source/filter/xml/datastreamimport.cxx              |   68 +++----
 sc/source/filter/xml/datastreamimport.hxx              |    6 
 sc/source/filter/xml/importcontext.cxx                 |    6 
 sc/source/filter/xml/importcontext.hxx                 |    4 
 sc/source/filter/xml/xmlbodyi.cxx                      |  109 ++++-------
 sc/source/filter/xml/xmlbodyi.hxx                      |    4 
 sc/source/filter/xml/xmlcvali.cxx                      |   11 -
 sc/source/filter/xml/xmlcvali.hxx                      |    7 
 sc/source/filter/xml/xmldpimp.cxx                      |   11 -
 sc/source/filter/xml/xmldpimp.hxx                      |    7 
 sc/source/filter/xml/xmldrani.cxx                      |  164 +++++++----------
 sc/source/filter/xml/xmldrani.hxx                      |   20 --
 sc/source/filter/xml/xmllabri.cxx                      |   11 -
 sc/source/filter/xml/xmllabri.hxx                      |    6 
 sc/source/filter/xml/xmlnexpi.cxx                      |   12 -
 sc/source/filter/xml/xmlnexpi.hxx                      |    6 
 sc/source/filter/xml/xmltabi.cxx                       |   16 -
 25 files changed, 284 insertions(+), 390 deletions(-)

New commits:
commit 4b5f5f868fa6a7c86535d251e77d8a6d956f2fa4
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date:   Thu Jun 29 23:39:07 2017 +0530

    Moving legacy contexts to FastContexts:
    
    ScXMLTrackedChangesContext
    ScXMLCalculationSettingsContext
    ScXMLContentValidationsContext
    ScXMLLabelRangesContext
    ScXMLNamedExpressionsContext
    ScXMLDatabaseRangesContext
    ScXMLDatabaseRangeContext
    ScXMLDataPilotTablesContext
    ScXMLConsolidationContext
    ScXMLDDELinksContext
    ScXMLDataStreamContext
    
    Change-Id: I702d30e01af5e3707d34303ddebc3d07913d67e3
    Reviewed-on: https://gerrit.libreoffice.org/39397
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index 452cd3f97836..f39ccebe5eb6 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -32,10 +32,9 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) :
+    ScXMLImportContext( rImport ),
     fIterationEpsilon(0.001),
     nIterationCount(100),
     nYear2000(1930),
@@ -49,53 +48,45 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r
     aNullDate.Day = 30;
     aNullDate.Month = 12;
     aNullDate.Year = 1899;
-    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName(xAttrList->getNameByIndex( i ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                            sAttrName, &aLocalName );
-        const OUString& sValue(xAttrList->getValueByIndex( i ));
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        if (nPrefix == XML_NAMESPACE_TABLE)
+        for( auto &aIter : *pAttribList )
         {
-            if (IsXMLToken(aLocalName, XML_CASE_SENSITIVE))
+            switch( aIter.getToken() )
             {
-                if (IsXMLToken(sValue, XML_FALSE))
+            case XML_ELEMENT( TABLE, XML_CASE_SENSITIVE ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bIgnoreCase = true;
-            }
-            else if (IsXMLToken(aLocalName, XML_PRECISION_AS_SHOWN))
-            {
-                if (IsXMLToken(sValue, XML_TRUE))
+                break;
+            case XML_ELEMENT( TABLE, XML_PRECISION_AS_SHOWN ):
+                if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
                     bCalcAsShown = true;
-            }
-            else if (IsXMLToken(aLocalName, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL))
-            {
-                if (IsXMLToken(sValue, XML_FALSE))
+                break;
+            case XML_ELEMENT( TABLE, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bMatchWholeCell = false;
-            }
-            else if (IsXMLToken(aLocalName, XML_AUTOMATIC_FIND_LABELS))
-            {
-                if (IsXMLToken(sValue, XML_FALSE))
+                break;
+            case XML_ELEMENT( TABLE, XML_AUTOMATIC_FIND_LABELS ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bLookUpLabels = false;
-            }
-            else if (IsXMLToken(aLocalName, XML_NULL_YEAR))
-            {
+                break;
+            case XML_ELEMENT( TABLE, XML_NULL_YEAR ):
                 sal_Int32 nTemp;
-                ::sax::Converter::convertNumber(nTemp, sValue);
+                ::sax::Converter::convertNumber( nTemp, aIter.toString() );
                 nYear2000 = static_cast<sal_uInt16>(nTemp);
-            }
-            else if (IsXMLToken(aLocalName, XML_USE_REGULAR_EXPRESSIONS))
-            {
+                break;
+            case XML_ELEMENT( TABLE, XML_USE_REGULAR_EXPRESSIONS ):
                 // Overwrite only the default (regex true) value, not wildcard.
-                if (eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken(sValue, XML_FALSE))
+                if( eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     eSearchType = utl::SearchParam::SearchType::Normal;
-            }
-            else if (IsXMLToken(aLocalName, XML_USE_WILDCARDS))
-            {
-                if (IsXMLToken(sValue, XML_TRUE))
+                break;
+            case XML_ELEMENT( TABLE, XML_USE_WILDCARDS ):
+                if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
                     eSearchType = utl::SearchParam::SearchType::Wildcard;
+                break;
             }
         }
     }
@@ -125,7 +116,7 @@ SvXMLImportContext *ScXMLCalculationSettingsContext::CreateChildContext( sal_uIn
     return pContext;
 }
 
-void ScXMLCalculationSettingsContext::EndElement()
+void SAL_CALL ScXMLCalculationSettingsContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     if (GetScImport().GetModel().is())
     {
diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
index 3ad233a39407..fb0cd553a673 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
@@ -41,9 +41,8 @@ class ScXMLCalculationSettingsContext : public ScXMLImportContext
     bool bMatchWholeCell;
 
 public:
-    ScXMLCalculationSettingsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLCalculationSettingsContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLCalculationSettingsContext() override;
 
@@ -55,7 +54,7 @@ public:
     void SetIterationStatus(const bool bValue) { bIsIterationEnabled = bValue; }
     void SetIterationCount(const sal_Int32 nValue) { nIterationCount = nValue; }
     void SetIterationEpsilon(const double fValue) { fIterationEpsilon = fValue; }
-    virtual void EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 Element ) override;
 };
 
 class ScXMLNullDateContext : public ScXMLImportContext
diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx
index 217327a4a8cb..8e27b573de7b 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.cxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.cxx
@@ -24,54 +24,50 @@
 #include "XMLConverter.hxx"
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
 
 using namespace ::com::sun::star;
 using namespace xmloff::token;
 
 ScXMLConsolidationContext::ScXMLConsolidationContext(
         ScXMLImport& rImport,
-        sal_uInt16 nPrfx,
-        const OUString& rLName,
-        const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+        sal_Int32 /*nElement*/,
+        const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) :
+    ScXMLImportContext( rImport ),
     eFunction( SUBTOTAL_FUNC_NONE ),
     bLinkToSource( false ),
     bTargetAddr(false)
 {
     rImport.LockSolarMutex();
-    if( !xAttrList.is() ) return;
-
-    sal_Int16               nAttrCount      = xAttrList->getLength();
-    const SvXMLTokenMap&    rAttrTokenMap   = GetScImport().GetConsolidationAttrTokenMap();
-
-    for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName  (xAttrList->getNameByIndex( nIndex ));
-        const OUString& sValue     (xAttrList->getValueByIndex( nIndex ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix      = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+        for( auto &aIter : *pAttribList )
         {
-            case XML_TOK_CONSOLIDATION_ATTR_FUNCTION:
-                eFunction = ScXMLConverter::GetSubTotalFuncFromString( sValue );
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES:
-                sSourceList = sValue;
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS:
-                {
-                    sal_Int32 nOffset(0);
-                    bTargetAddr = ScRangeStringConverter::GetAddressFromString(
-                        aTargetAddr, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
-                }
+            switch( aIter.getToken() )
+            {
+                case XML_ELEMENT( TABLE, XML_FUNCTION ):
+                    eFunction = ScXMLConverter::GetSubTotalFuncFromString( aIter.toString() );
+                break;
+                case XML_ELEMENT( TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES ):
+                    sSourceList = aIter.toString();
+                break;
+                case XML_ELEMENT( TABLE, XML_TARGET_CELL_ADDRESS ):
+                    {
+                        sal_Int32 nOffset(0);
+                        bTargetAddr = ScRangeStringConverter::GetAddressFromString(
+                            aTargetAddr, aIter.toString(), GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
+                    }
+                    break;
+                case XML_ELEMENT( TABLE, XML_USE_LABEL ):
+                    sUseLabel = aIter.toString();
                 break;
-            case XML_TOK_CONSOLIDATION_ATTR_USE_LABEL:
-                sUseLabel = sValue;
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE:
-                bLinkToSource = IsXMLToken(sValue, XML_TRUE);
-            break;
+                case XML_ELEMENT( TABLE, XML_LINK_TO_SOURCE_DATA ):
+                    bLinkToSource = IsXMLToken( aIter.toCString(), XML_TRUE );
+                break;
+            }
         }
     }
 }
@@ -89,7 +85,7 @@ SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext(
     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
-void ScXMLConsolidationContext::EndElement()
+void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     if (bTargetAddr)
     {
diff --git a/sc/source/filter/xml/XMLConsolidationContext.hxx b/sc/source/filter/xml/XMLConsolidationContext.hxx
index 499aab1ed55f..3a7ebf272331 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.hxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.hxx
@@ -40,9 +40,8 @@ private:
 public:
                                 ScXMLConsolidationContext(
                                     ScXMLImport& rImport,
-                                    sal_uInt16 nPrfx,
-                                    const OUString& rLName,
-                                    const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList
+                                    sal_Int32 nElement,
+                                    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList
                                     );
     virtual                     ~ScXMLConsolidationContext() override;
 
@@ -51,7 +50,7 @@ public:
                                     const OUString& rLocalName,
                                     const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList
                                     ) override;
-    virtual void                EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index 4b0260231ad8..dc179e1c1451 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -32,10 +32,9 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLDDELinksContext::ScXMLDDELinksContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) :
-    ScXMLImportContext( rImport, nPrfx, rLName )
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& /* xAttrList */ ) :
+    ScXMLImportContext( rImport )
 {
     // here are no attributes
     rImport.LockSolarMutex();
@@ -61,10 +60,6 @@ SvXMLImportContext *ScXMLDDELinksContext::CreateChildContext( sal_uInt16 nPrefix
     return pContext;
 }
 
-void ScXMLDDELinksContext::EndElement()
-{
-}
-
 ScXMLDDELinkContext::ScXMLDDELinkContext( ScXMLImport& rImport,
                                       sal_uInt16 nPrfx,
                                       const OUString& rLName,
diff --git a/sc/source/filter/xml/XMLDDELinksContext.hxx b/sc/source/filter/xml/XMLDDELinksContext.hxx
index 43cfccab9758..79ec32644e7d 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.hxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.hxx
@@ -28,17 +28,14 @@
 class ScXMLDDELinksContext : public ScXMLImportContext
 {
 public:
-    ScXMLDDELinksContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLDDELinksContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLDDELinksContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
-    virtual void EndElement() override;
 };
 
 struct ScDDELinkCell
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index e6b3427eb9a0..ab95b71bc461 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -384,33 +384,27 @@ public:
 };
 
 ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport& rImport,
-                                              sal_uInt16 nPrfx,
-                                                   const OUString& rLName,
-                                              const uno::Reference<xml::sax::XAttributeList>& xAttrList,
+                                              sal_Int32 /*nElement*/,
+                                              const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
                                               ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+    ScXMLImportContext( rImport ),
     pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
 {
     rImport.LockSolarMutex();
 
-    sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
-    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName(xAttrList->getNameByIndex( i ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                            sAttrName, &aLocalName ));
-        const OUString& sValue(xAttrList->getValueByIndex( i ));
-        if (nPrefix == XML_NAMESPACE_TABLE)
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
+
+        auto aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_PROTECTION_KEY ) ) );
+        if( aIter != pAttribList->end() )
         {
-            if (IsXMLToken(aLocalName, XML_PROTECTION_KEY))
+            if( !aIter.isEmpty() )
             {
-                if (!sValue.isEmpty())
-                {
-                    uno::Sequence<sal_Int8> aPass;
-                    ::sax::Converter::decodeBase64(aPass, sValue);
-                    pChangeTrackingImportHelper->SetProtection(aPass);
-                }
+                uno::Sequence<sal_Int8> aPass;
+                ::sax::Converter::decodeBase64( aPass, aIter.toString() );
+                pChangeTrackingImportHelper->SetProtection(aPass);
             }
         }
     }
@@ -457,10 +451,6 @@ SvXMLImportContext *ScXMLTrackedChangesContext::CreateChildContext( sal_uInt16 n
     return pContext;
 }
 
-void ScXMLTrackedChangesContext::EndElement()
-{
-}
-
 ScXMLChangeInfoContext::ScXMLChangeInfoContext(  ScXMLImport& rImport,
                                               sal_uInt16 nPrfx,
                                               const OUString& rLName,
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.hxx b/sc/source/filter/xml/XMLTrackedChangesContext.hxx
index c3313161f007..e059a8682abb 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.hxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.hxx
@@ -34,15 +34,14 @@ class ScXMLTrackedChangesContext : public ScXMLImportContext
     ScXMLChangeTrackingImportHelper*    pChangeTrackingImportHelper;
 
 public:
-    ScXMLTrackedChangesContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
+    ScXMLTrackedChangesContext( ScXMLImport& rImport, sal_Int32 nElement,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
                                       ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
     virtual ~ScXMLTrackedChangesContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                                     const OUString& rLocalName,
                                                     const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-    virtual void EndElement() override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/datastreamimport.cxx b/sc/source/filter/xml/datastreamimport.cxx
index a764718e0c33..5e19c5215c15 100644
--- a/sc/source/filter/xml/datastreamimport.cxx
+++ b/sc/source/filter/xml/datastreamimport.cxx
@@ -13,6 +13,7 @@
 #include <rangeutl.hxx>
 #include <importfilterdata.hxx>
 #include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <formula/grammar.hxx>
 
@@ -20,56 +21,51 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLDataStreamContext::ScXMLDataStreamContext(
-    ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
-    const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) :
-    ScXMLImportContext(rImport, nPrefix, rLocalName),
+    ScXMLImport& rImport, sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList ) :
+    ScXMLImportContext(rImport),
     mbRefreshOnEmpty(false),
     meInsertPos(sc::ImportPostProcessData::DataStream::InsertBottom)
 {
-    if (!xAttrList.is())
-        return;
-
-    const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataStreamAttrTokenMap();
-
-    for (sal_Int32 i = 0; i < xAttrList->getLength(); ++i)
+    if( xAttrList.is() )
     {
-        const OUString& rName = xAttrList->getNameByIndex(i);
-        OUString aLocalName;
-        sal_uInt16 nLocalPrefix =
-            GetScImport().GetNamespaceMap().GetKeyByAttrName(rName, &aLocalName);
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        const OUString& rVal = xAttrList->getValueByIndex(i);
-        switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
+        for( auto &aIter : *pAttribList )
         {
-            case XML_TOK_DATA_STREAM_ATTR_URL:
-                maURL = GetScImport().GetAbsoluteReference(rVal);
-            break;
-            case XML_TOK_DATA_STREAM_ATTR_RANGE:
+            switch ( aIter.getToken() )
             {
-                ScDocument* pDoc = GetScImport().GetDocument();
-                sal_Int32 nOffset = 0;
-                if (!ScRangeStringConverter::GetRangeFromString(
-                    maRange, rVal, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
-                    maRange.SetInvalid();
+                case XML_ELEMENT( XLINK, XML_HREF ):
+                    maURL = GetScImport().GetAbsoluteReference( aIter.toString() );
+                break;
+                case XML_ELEMENT( TABLE, XML_TARGET_RANGE_ADDRESS ):
+                {
+                    ScDocument* pDoc = GetScImport().GetDocument();
+                    sal_Int32 nOffset = 0;
+                    if (!ScRangeStringConverter::GetRangeFromString(
+                        maRange, aIter.toString(), pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
+                        maRange.SetInvalid();
+                }
+                break;
+                case XML_ELEMENT( CALC_EXT, XML_EMPTY_LINE_REFRESH ):
+                    mbRefreshOnEmpty = IsXMLToken( aIter.toCString(), XML_TRUE );
+                break;
+                case XML_ELEMENT( CALC_EXT, XML_INSERTION_POSITION ):
+                    meInsertPos = IsXMLToken( aIter.toCString(), XML_TOP ) ?
+                        sc::ImportPostProcessData::DataStream::InsertTop :
+                        sc::ImportPostProcessData::DataStream::InsertBottom;
+                break;
+                default:
+                    ;
             }
-            break;
-            case XML_TOK_DATA_STREAM_ATTR_EMPTY_LINE_REFRESH:
-                mbRefreshOnEmpty = IsXMLToken(rVal, XML_TRUE);
-            break;
-            case XML_TOK_DATA_STREAM_ATTR_INSERTION_POSITION:
-                meInsertPos = IsXMLToken(rVal, XML_TOP) ?
-                    sc::ImportPostProcessData::DataStream::InsertTop :
-                    sc::ImportPostProcessData::DataStream::InsertBottom;
-            break;
-            default:
-                ;
         }
     }
 }
 
 ScXMLDataStreamContext::~ScXMLDataStreamContext() {}
 
-void ScXMLDataStreamContext::EndElement()
+void SAL_CALL ScXMLDataStreamContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     if (!maRange.IsValid())
         // Range must be valid.
diff --git a/sc/source/filter/xml/datastreamimport.hxx b/sc/source/filter/xml/datastreamimport.hxx
index 0459b8d2fce4..91980ea2f4f0 100644
--- a/sc/source/filter/xml/datastreamimport.hxx
+++ b/sc/source/filter/xml/datastreamimport.hxx
@@ -24,12 +24,12 @@ class ScXMLDataStreamContext : public ScXMLImportContext
 
 public:
     ScXMLDataStreamContext(
-        ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
-        const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList );
+        ScXMLImport& rImport, sal_Int32 nElement,
+        const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList );
 
     virtual ~ScXMLDataStreamContext() override;
 
-    virtual void EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/importcontext.cxx b/sc/source/filter/xml/importcontext.cxx
index d0bceeddbcd7..3622c14ca018 100644
--- a/sc/source/filter/xml/importcontext.cxx
+++ b/sc/source/filter/xml/importcontext.cxx
@@ -42,4 +42,10 @@ void SAL_CALL ScXMLImportContext::characters(const OUString &)
 {
 }
 
+css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLImportContext::createFastChildContext(
+    sal_Int32/* nElement */, const css::uno::Reference< css::xml::sax::XFastAttributeList >&/* xAttrList */ )
+{
+    return new SvXMLImportContext( GetImport() );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/importcontext.hxx b/sc/source/filter/xml/importcontext.hxx
index 089b6c1027cb..8332fa5a5d37 100644
--- a/sc/source/filter/xml/importcontext.hxx
+++ b/sc/source/filter/xml/importcontext.hxx
@@ -33,6 +33,10 @@ public:
 
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 
+    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+        sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
+
+
 protected:
     ScXMLImport& GetScImport();
     const ScXMLImport& GetScImport() const;
diff --git a/sc/source/filter/xml/xmlbodyi.cxx b/sc/source/filter/xml/xmlbodyi.cxx
index 4aec839b76e7..e6f7bdfa8e7b 100644
--- a/sc/source/filter/xml/xmlbodyi.cxx
+++ b/sc/source/filter/xml/xmlbodyi.cxx
@@ -121,9 +121,9 @@ ScXMLBodyContext::~ScXMLBodyContext()
 {
 }
 
-SvXMLImportContext *ScXMLBodyContext::CreateChildContext( sal_uInt16 nPrefix,
-                                     const OUString& rLocalName,
-                                     const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
+        ScXMLBodyContext::createFastChildContext( sal_Int32 nElement,
+        const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
 {
     ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetScImport().GetModel())->GetSheetSaveData();
     if ( pSheetData && pSheetData->HasStartPos() )
@@ -135,94 +135,65 @@ SvXMLImportContext *ScXMLBodyContext::CreateChildContext( sal_uInt16 nPrefix,
 
     SvXMLImportContext *pContext = nullptr;
 
-    const SvXMLTokenMap& rTokenMap = GetScImport().GetBodyElemTokenMap();
-    switch( rTokenMap.Get( nPrefix, rLocalName ) )
+    switch( nElement )
     {
-    case XML_TOK_BODY_TRACKED_CHANGES :
+    case XML_ELEMENT( TABLE, XML_TRACKED_CHANGES ):
         pChangeTrackingImportHelper = GetScImport().GetChangeTrackingImportHelper();
         if (pChangeTrackingImportHelper)
-            pContext = new ScXMLTrackedChangesContext( GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
+            pContext = new ScXMLTrackedChangesContext( GetScImport(), nElement, xAttrList, pChangeTrackingImportHelper);
         break;
-    case XML_TOK_BODY_CALCULATION_SETTINGS :
-        pContext = new ScXMLCalculationSettingsContext( GetScImport(), nPrefix, rLocalName, xAttrList );
+    case XML_ELEMENT( TABLE, XML_CALCULATION_SETTINGS ):
+        pContext = new ScXMLCalculationSettingsContext( GetScImport(), nElement, xAttrList );
         bHadCalculationSettings = true;
         break;
-    case XML_TOK_BODY_CONTENT_VALIDATIONS :
-        pContext = new ScXMLContentValidationsContext( GetScImport(), nPrefix, rLocalName, xAttrList );
+    case XML_ELEMENT( TABLE, XML_CONTENT_VALIDATIONS ):
+        pContext = new ScXMLContentValidationsContext( GetScImport(), nElement, xAttrList );
         break;
-    case XML_TOK_BODY_LABEL_RANGES:
-        pContext = new ScXMLLabelRangesContext( GetScImport(), nPrefix, rLocalName, xAttrList );
+    case XML_ELEMENT( TABLE, XML_LABEL_RANGES ):
+        pContext = new ScXMLLabelRangesContext( GetScImport(), nElement, xAttrList );
+        break;
+    case XML_ELEMENT( TABLE, XML_TABLE ):
+        if (GetScImport().GetTables().GetCurrentSheet() >= MAXTAB)
+        {
+            GetScImport().SetRangeOverflowType(SCWARN_IMPORT_SHEET_OVERFLOW);
+            pContext = new ScXMLEmptyContext(GetScImport() );
+        }
+        else
+        {
+            pContext = new ScXMLTableContext( GetScImport(), xAttrList );
+        }
         break;
-    case XML_TOK_BODY_NAMED_EXPRESSIONS:
+    case XML_ELEMENT( TABLE, XML_NAMED_EXPRESSIONS ):
         pContext = new ScXMLNamedExpressionsContext (
-            GetScImport(), nPrefix, rLocalName, xAttrList,
+            GetScImport(), nElement, xAttrList,
             new ScXMLNamedExpressionsContext::GlobalInserter(GetScImport()) );
         break;
-    case XML_TOK_BODY_DATABASE_RANGES:
-        pContext = new ScXMLDatabaseRangesContext ( GetScImport(), nPrefix, rLocalName,
+    case XML_ELEMENT( TABLE, XML_DATABASE_RANGES ):
+        pContext = new ScXMLDatabaseRangesContext ( GetScImport(), nElement,
                                                         xAttrList );
         break;
-    case XML_TOK_BODY_DATABASE_RANGE:
-        pContext = new ScXMLDatabaseRangeContext ( GetScImport(), nPrefix, rLocalName,
+    case XML_ELEMENT( TABLE, XML_DATABASE_RANGE ):
+        pContext = new ScXMLDatabaseRangeContext ( GetScImport(), nElement,
                                                         xAttrList );
         break;
-    case XML_TOK_BODY_DATA_PILOT_TABLES:
-        pContext = new ScXMLDataPilotTablesContext ( GetScImport(), nPrefix, rLocalName,
+    case XML_ELEMENT( TABLE, XML_DATA_PILOT_TABLES ):
+        pContext = new ScXMLDataPilotTablesContext ( GetScImport(), nElement,
                                                         xAttrList );
         break;
-    case XML_TOK_BODY_CONSOLIDATION:
-        pContext = new ScXMLConsolidationContext ( GetScImport(), nPrefix, rLocalName,
+    case XML_ELEMENT( TABLE, XML_CONSOLIDATION ):
+        pContext = new ScXMLConsolidationContext ( GetScImport(), nElement,
                                                         xAttrList );
         break;
-    case XML_TOK_BODY_DDE_LINKS:
-        pContext = new ScXMLDDELinksContext ( GetScImport(), nPrefix, rLocalName,
+    case XML_ELEMENT( TABLE, XML_DDE_LINKS ):
+        pContext = new ScXMLDDELinksContext ( GetScImport(), nElement,
                                                         xAttrList );
         break;
-    case XML_TOK_BODY_DATA_STREAM_SOURCE:
-        pContext = new ScXMLDataStreamContext(GetScImport(), nPrefix, rLocalName, xAttrList);
+    case XML_ELEMENT( CALC_EXT, XML_DATA_STREAM_SOURCE ):
+        pContext = new ScXMLDataStreamContext(GetScImport(), nElement, xAttrList);
         break;
     }
 
     if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
-
-    return pContext;
-}
-
-uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
-        ScXMLBodyContext::createFastChildContext( sal_Int32 nElement,
-        const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
-{
-    ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetScImport().GetModel())->GetSheetSaveData();
-    if ( pSheetData && pSheetData->HasStartPos() )
-    {
-        // stream part to copy ends before the next child element
-        sal_Int32 nEndOffset = GetScImport().GetByteOffset();
-        pSheetData->EndStreamPos( nEndOffset );
-    }
-
-    SvXMLImportContext *pContext = nullptr;
-
-    switch( nElement )
-    {
-    case XML_ELEMENT( TABLE, XML_TABLE ):
-        if (GetScImport().GetTables().GetCurrentSheet() >= MAXTAB)
-        {
-            GetScImport().SetRangeOverflowType(SCWARN_IMPORT_SHEET_OVERFLOW);
-            pContext = new ScXMLEmptyContext(GetScImport() );
-        }
-        else
-        {
-            pContext = new ScXMLTableContext( GetScImport(), xAttrList );
-        }
-        break;
-
-    // TODO: handle all other cases
-    default:
-        pContext = new SvXMLImportContext( GetImport() );
-    }
-
-    if( !pContext )
         pContext = new SvXMLImportContext( GetImport() );
 
     return pContext;
@@ -240,7 +211,7 @@ void SAL_CALL ScXMLBodyContext::characters(const OUString &)
     // otherwise ignore
 }
 
-void SAL_CALL ScXMLBodyContext::endFastElement(sal_Int32 /*nElement*/)
+void SAL_CALL ScXMLBodyContext::endFastElement(sal_Int32 nElement)
 {
     ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetScImport().GetModel())->GetSheetSaveData();
     if ( pSheetData && pSheetData->HasStartPos() )
@@ -261,8 +232,8 @@ void SAL_CALL ScXMLBodyContext::endFastElement(sal_Int32 /*nElement*/)
     if (!bHadCalculationSettings)
     {
         // #111055#; set calculation settings defaults if there is no calculation settings element
-        rtl::Reference<ScXMLCalculationSettingsContext> pContext( new ScXMLCalculationSettingsContext(GetScImport(), XML_NAMESPACE_TABLE, GetXMLToken(XML_CALCULATION_SETTINGS), nullptr) );
-        pContext->EndElement();
+        rtl::Reference<ScXMLCalculationSettingsContext> pContext( new ScXMLCalculationSettingsContext(GetScImport(), nElement, nullptr) );
+        pContext->endFastElement( nElement );
     }
 
     ScXMLImport::MutexGuard aGuard(GetScImport());
diff --git a/sc/source/filter/xml/xmlbodyi.hxx b/sc/source/filter/xml/xmlbodyi.hxx
index e0b9db6458e1..a6cc7d629021 100644
--- a/sc/source/filter/xml/xmlbodyi.hxx
+++ b/sc/source/filter/xml/xmlbodyi.hxx
@@ -46,10 +46,6 @@ public:
 
     virtual ~ScXMLBodyContext() override;
 
-    virtual SvXMLImportContext *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>& xAttrList ) override;
diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx
index af76bf829149..286928e35bdd 100644
--- a/sc/source/filter/xml/xmlcvali.cxx
+++ b/sc/source/filter/xml/xmlcvali.cxx
@@ -140,10 +140,9 @@ public:
 };
 
 ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) :
-    ScXMLImportContext( rImport, nPrfx, rLName )
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& /* xAttrList */ ) :
+    ScXMLImportContext( rImport )
 {
     // here are no attributes
 }
@@ -172,10 +171,6 @@ SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( sal_uInt
     return pContext;
 }
 
-void ScXMLContentValidationsContext::EndElement()
-{
-}
-
 ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
                                       sal_uInt16 nPrfx,
                                       const OUString& rLName,
diff --git a/sc/source/filter/xml/xmlcvali.hxx b/sc/source/filter/xml/xmlcvali.hxx
index e353d73f4b19..c19a9fa5849a 100644
--- a/sc/source/filter/xml/xmlcvali.hxx
+++ b/sc/source/filter/xml/xmlcvali.hxx
@@ -32,17 +32,14 @@ class ScXMLContentValidationsContext : public ScXMLImportContext
 {
 public:
 
-    ScXMLContentValidationsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLContentValidationsContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLContentValidationsContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
-    virtual void EndElement() override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index c8e0d366a76b..481bd976b3f8 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -56,10 +56,9 @@ using ::com::sun::star::uno::Reference;
 using ::com::sun::star::xml::sax::XAttributeList;
 
 ScXMLDataPilotTablesContext::ScXMLDataPilotTablesContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) :
-    ScXMLImportContext( rImport, nPrfx, rLName )
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& /* xAttrList */ ) :
+    ScXMLImportContext( rImport )
 {
     // has no Attributes
     rImport.LockSolarMutex();
@@ -93,10 +92,6 @@ SvXMLImportContext *ScXMLDataPilotTablesContext::CreateChildContext( sal_uInt16
     return pContext;
 }
 
-void ScXMLDataPilotTablesContext::EndElement()
-{
-}
-
 ScXMLDataPilotTableContext::GrandTotalItem::GrandTotalItem() :
     mbVisible(true) {}
 
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 2b9b6698f6d0..5b48837fe8b5 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -52,17 +52,14 @@ class ScXMLDataPilotTablesContext : public ScXMLImportContext
 {
 public:
 
-    ScXMLDataPilotTablesContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLDataPilotTablesContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLDataPilotTablesContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
-    virtual void EndElement() override;
 };
 
 class ScXMLDataPilotTableContext : public ScXMLImportContext
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index eab22def3a85..f75322824351 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -53,10 +53,9 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLDatabaseRangesContext::ScXMLDatabaseRangesContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) :
-    ScXMLImportContext( rImport, nPrfx, rLName )
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& /* xAttrList */ ) :
+    ScXMLImportContext( rImport )
 {
     // has no attributes
     rImport.LockSolarMutex();
@@ -67,38 +66,31 @@ ScXMLDatabaseRangesContext::~ScXMLDatabaseRangesContext()
     GetScImport().UnlockSolarMutex();
 }
 
-SvXMLImportContext *ScXMLDatabaseRangesContext::CreateChildContext( sal_uInt16 nPrefix,
-                                            const OUString& rLName,
-                                            const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
+uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDatabaseRangesContext::createFastChildContext(
+                                      sal_Int32 nElement,
+                                      const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
 {
     SvXMLImportContext *pContext = nullptr;
 
-    const SvXMLTokenMap& rTokenMap = GetScImport().GetDatabaseRangesElemTokenMap();
-    switch( rTokenMap.Get( nPrefix, rLName ) )
+    switch( nElement )
     {
-        case XML_TOK_DATABASE_RANGE :
+        case XML_ELEMENT( TABLE, XML_DATABASE_RANGE ):
         {
-            pContext = new ScXMLDatabaseRangeContext( GetScImport(), nPrefix,
-                                                          rLName, xAttrList);
+            pContext = new ScXMLDatabaseRangeContext( GetScImport(), nElement, xAttrList );
         }
         break;
     }
 
     if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+        pContext = new SvXMLImportContext( GetImport() );
 
     return pContext;
 }
 
-void ScXMLDatabaseRangesContext::EndElement()
-{
-}
-
 ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) :
+    ScXMLImportContext( rImport ),
     mpQueryParam(new ScQueryParam),
     sDatabaseRangeName(STR_DB_LOCAL_NONAME),
     aSortSequence(),
@@ -125,76 +117,74 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
     meRangeType(ScDBCollection::GlobalNamed)
 {
     nSourceType = sheet::DataImportMode_NONE;
-    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDatabaseRangeAttrTokenMap();
-    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName(xAttrList->getNameByIndex( i ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                            sAttrName, &aLocalName );
-        const OUString& sValue(xAttrList->getValueByIndex( i ));
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+        for( auto &aIter : *pAttribList )
         {
-            case XML_TOK_DATABASE_RANGE_ATTR_NAME :
-            {
-                sDatabaseRangeName = sValue;
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_IS_SELECTION :
-            {
-                bIsSelection = IsXMLToken(sValue, XML_TRUE);
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_STYLES :
-            {
-                bKeepFormats = IsXMLToken(sValue, XML_TRUE);
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_ON_UPDATE_KEEP_SIZE :
-            {
-                bMoveCells = !IsXMLToken(sValue, XML_TRUE);
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_HAS_PERSISTENT_DATA :
-            {
-                bStripData = !IsXMLToken(sValue, XML_TRUE);
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_ORIENTATION :
-            {
-                bByRow = !IsXMLToken(sValue, XML_COLUMN);
-                mpQueryParam->bByRow = bByRow;
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_CONTAINS_HEADER :
-            {
-                bHasHeader = IsXMLToken(sValue, XML_TRUE);
-                mpQueryParam->bHasHeader = bHasHeader;
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_DISPLAY_FILTER_BUTTONS :
-            {
-                bAutoFilter = IsXMLToken(sValue, XML_TRUE);
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS :
+            switch( aIter.getToken() )
             {
-                ScDocument* pDoc = GetScImport().GetDocument();
-                sal_Int32 nOffset = 0;
-                if (!ScRangeStringConverter::GetRangeFromString(
-                    maRange, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset))
-                    mbValidRange = false;
-            }
-            break;
-            case XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY :
-            {
-                double fTime;
-                if (::sax::Converter::convertDuration( fTime, sValue ))
-                    nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
+                case XML_ELEMENT( TABLE, XML_NAME ):
+                {
+                    sDatabaseRangeName = aIter.toString();
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_IS_SELECTION ):
+                {
+                    bIsSelection = IsXMLToken( aIter.toCString(), XML_TRUE );
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_ON_UPDATE_KEEP_STYLES ):
+                {
+                    bKeepFormats = IsXMLToken( aIter.toCString(), XML_TRUE );
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_ON_UPDATE_KEEP_SIZE ):
+                {
+                    bMoveCells = !IsXMLToken( aIter.toCString(), XML_TRUE );
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_HAS_PERSISTENT_DATA ):
+                {
+                    bStripData = !IsXMLToken( aIter.toCString(), XML_TRUE );
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_ORIENTATION ):
+                {
+                    bByRow = !IsXMLToken( aIter.toCString(), XML_COLUMN );
+                    mpQueryParam->bByRow = bByRow;
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_CONTAINS_HEADER ):
+                {
+                    bHasHeader = IsXMLToken( aIter.toCString(), XML_TRUE );
+                    mpQueryParam->bHasHeader = bHasHeader;
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_DISPLAY_FILTER_BUTTONS ):
+                {
+                    bAutoFilter = IsXMLToken( aIter.toCString(), XML_TRUE );
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_TARGET_RANGE_ADDRESS ):
+                {
+                    ScDocument* pDoc = GetScImport().GetDocument();
+                    sal_Int32 nOffset = 0;
+                    if (!ScRangeStringConverter::GetRangeFromString(
+                        maRange, aIter.toString(), pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset))
+                        mbValidRange = false;
+                }
+                break;
+                case XML_ELEMENT( TABLE, XML_REFRESH_DELAY ):
+                {
+                    double fTime;
+                    if (::sax::Converter::convertDuration( fTime, aIter.toString() ))
+                        nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
+                }
+                break;
             }
-            break;
         }
     }
 
@@ -420,7 +410,7 @@ bool setAutoFilterFlags(ScDocument& rDoc, const ScDBData& rData)
 
 }
 
-void ScXMLDatabaseRangeContext::EndElement()
+void SAL_CALL ScXMLDatabaseRangeContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     ScDocument* pDoc = GetScImport().GetDocument();
     if (!pDoc)
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index afdc1cf8d014..65d5bd64a35f 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -39,17 +39,14 @@ class ScXMLDatabaseRangesContext : public ScXMLImportContext
 {
 public:
 
-    ScXMLDatabaseRangesContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLDatabaseRangesContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLDatabaseRangesContext() override;
 
-    virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
-                                     const OUString& rLocalName,
-                                     const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
-    virtual void EndElement() override;
+    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+                        sal_Int32 nElement,
+                        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
 };
 
 struct ScSubTotalRule
@@ -96,9 +93,8 @@ class ScXMLDatabaseRangeContext : public ScXMLImportContext
 
 public:
 
-    ScXMLDatabaseRangeContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLDatabaseRangeContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLDatabaseRangeContext() override;
 
@@ -106,7 +102,7 @@ public:
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
 
-    virtual void EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
 
     void SetDatabaseName(const OUString& sTempDatabaseName) { sDatabaseName = sTempDatabaseName; }
     void SetConnectionResource(const OUString& sTempConRes) { sConnectionResource = sTempConRes; }
diff --git a/sc/source/filter/xml/xmllabri.cxx b/sc/source/filter/xml/xmllabri.cxx
index 49fcd87d8844..0712a600f35c 100644
--- a/sc/source/filter/xml/xmllabri.cxx
+++ b/sc/source/filter/xml/xmllabri.cxx
@@ -27,10 +27,9 @@ using namespace xmloff::token;
 
 ScXMLLabelRangesContext::ScXMLLabelRangesContext(
         ScXMLImport& rImport,
-        sal_uInt16 nPrefix,
-        const OUString& rLName,
-        const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ ):
-    ScXMLImportContext( rImport, nPrefix, rLName )
+        sal_Int32 /*nElement*/,
+        const uno::Reference< xml::sax::XFastAttributeList >& /* xAttrList */ ):
+    ScXMLImportContext( rImport )
 {
     rImport.LockSolarMutex();
 }
@@ -60,10 +59,6 @@ SvXMLImportContext* ScXMLLabelRangesContext::CreateChildContext(
     return pContext;
 }
 
-void ScXMLLabelRangesContext::EndElement()
-{
-}
-
 ScXMLLabelRangeContext::ScXMLLabelRangeContext(
         ScXMLImport& rImport,
         sal_uInt16 nPrfx,
diff --git a/sc/source/filter/xml/xmllabri.hxx b/sc/source/filter/xml/xmllabri.hxx
index e0f78b7f098a..aab26fb46e5d 100644
--- a/sc/source/filter/xml/xmllabri.hxx
+++ b/sc/source/filter/xml/xmllabri.hxx
@@ -28,9 +28,8 @@ class ScXMLLabelRangesContext : public ScXMLImportContext
 public:
                                 ScXMLLabelRangesContext(
                                     ScXMLImport& rImport,
-                                    sal_uInt16 nPrefix,
-                                    const OUString& rLName,
-                                    const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList
+                                    sal_Int32 nElement,
+                                    const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList
                                     );
     virtual                     ~ScXMLLabelRangesContext() override;
 
@@ -39,7 +38,6 @@ public:
                                     const OUString& rLocalName,
                                     const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList
                                     ) override;
-    virtual void                EndElement() override;
 };
 
 class ScXMLLabelRangeContext : public ScXMLImportContext
diff --git a/sc/source/filter/xml/xmlnexpi.cxx b/sc/source/filter/xml/xmlnexpi.cxx
index 963336954915..5f7f4735e113 100644
--- a/sc/source/filter/xml/xmlnexpi.cxx
+++ b/sc/source/filter/xml/xmlnexpi.cxx
@@ -47,10 +47,10 @@ void ScXMLNamedExpressionsContext::SheetLocalInserter::insert(ScMyNamedExpressio
 }
 
 ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext(
-    ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
-    const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
+    ScXMLImport& rImport, sal_Int32 /*nElement*/,
+    const uno::Reference<xml::sax::XFastAttributeList>& /* xAttrList */,
     Inserter* pInserter ) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+    ScXMLImportContext( rImport ),
     mpInserter(pInserter)
 {
     rImport.LockSolarMutex();
@@ -86,12 +86,6 @@ SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( sal_uInt16
     return pContext;
 }
 
-void ScXMLNamedExpressionsContext::EndElement()
-{
-    // happens in ScXMLImport::EndDocument()
-    // because it has to be set after the Database Ranges
-}
-
 ScXMLNamedRangeContext::ScXMLNamedRangeContext(
     ScXMLImport& rImport,
     sal_uInt16 nPrfx,
diff --git a/sc/source/filter/xml/xmlnexpi.hxx b/sc/source/filter/xml/xmlnexpi.hxx
index 342ea7d104fb..3df717f674ff 100644
--- a/sc/source/filter/xml/xmlnexpi.hxx
+++ b/sc/source/filter/xml/xmlnexpi.hxx
@@ -70,8 +70,8 @@ public:
     };
 
     ScXMLNamedExpressionsContext(
-        ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
-        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
+        ScXMLImport& rImport, sal_Int32 nElement,
+        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
         Inserter* pInserter );
 
     virtual ~ScXMLNamedExpressionsContext() override;
@@ -80,8 +80,6 @@ public:
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
 
-    virtual void EndElement() override;
-
 private:
     std::shared_ptr<Inserter> mpInserter;
 };
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 0567a1a4521c..c9cdb1b00a5b 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -228,14 +228,6 @@ SvXMLImportContext *ScXMLTableContext::CreateChildContext( sal_uInt16 nPrefix,
 
     switch (nToken)
     {
-    case XML_TOK_TABLE_NAMED_EXPRESSIONS:
-    {
-        SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
-        pContext = new ScXMLNamedExpressionsContext(
-            GetScImport(), nPrefix, rLName, xAttrList,
-            new ScXMLNamedExpressionsContext::SheetLocalInserter(GetScImport(), nTab));
-    }
-        break;
     case XML_TOK_TABLE_COL_GROUP:
         pContext = new ScXMLTableColsContext( GetScImport(), nPrefix,
                                                    rLName, xAttrList,
@@ -328,6 +320,14 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
 
     switch ( nElement )
     {
+    case XML_ELEMENT( TABLE, XML_NAMED_EXPRESSIONS ):
+    {
+        SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
+        pContext = new ScXMLNamedExpressionsContext(
+            GetScImport(), nElement, xAttrList,
+            new ScXMLNamedExpressionsContext::SheetLocalInserter(GetScImport(), nTab));
+    }
+        break;
     case XML_ELEMENT( TABLE, XML_TABLE_ROW_GROUP ):
         pContext = new ScXMLTableRowsContext( GetScImport(), xAttrList,
                                                    false, true );


More information about the Libreoffice-commits mailing list