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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 8 06:51:26 UTC 2020


 sc/source/filter/xml/xmlexternaltabi.cxx |   54 +++++----------
 sc/source/filter/xml/xmlimprt.cxx        |  110 -------------------------------
 sc/source/filter/xml/xmlimprt.hxx        |   12 ---
 3 files changed, 20 insertions(+), 156 deletions(-)

New commits:
commit 491992d0229afedba29b14778c918f6f9d2d7a07
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Mon Dec 7 20:28:01 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 8 07:50:37 2020 +0100

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

diff --git a/sc/source/filter/xml/xmlexternaltabi.cxx b/sc/source/filter/xml/xmlexternaltabi.cxx
index 2ac0c7750465..a09d294f17ca 100644
--- a/sc/source/filter/xml/xmlexternaltabi.cxx
+++ b/sc/source/filter/xml/xmlexternaltabi.cxx
@@ -36,6 +36,7 @@
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::xml::sax;
+using namespace ::xmloff::token;
 
 using ::com::sun::star::uno::Reference;
 
@@ -124,23 +125,21 @@ Reference< XFastContextHandler > SAL_CALL ScXMLExternalRefRowsContext::createFas
     // #i101319# row elements inside group, rows or header-rows
     // are treated like row elements directly in the table element
 
-    const SvXMLTokenMap& rTokenMap = GetScImport().GetTableRowsElemTokenMap();
-    sal_uInt16 nToken = rTokenMap.Get( nElement );
     sax_fastparser::FastAttributeList *pAttribList =
         &sax_fastparser::castToFastAttributeList( xAttrList );
 
-    switch (nToken)
+    switch (nElement)
     {
-        case XML_TOK_TABLE_ROWS_ROW_GROUP:
-        case XML_TOK_TABLE_ROWS_HEADER_ROWS:
-        case XML_TOK_TABLE_ROWS_ROWS:
+        case XML_ELEMENT(TABLE, XML_TABLE_ROW_GROUP):
+        case XML_ELEMENT(TABLE, XML_TABLE_HEADER_ROWS):
+        case XML_ELEMENT(TABLE, XML_TABLE_ROWS):
             return new ScXMLExternalRefRowsContext(
                 GetScImport(), mrExternalRefInfo);
-        case XML_TOK_TABLE_ROWS_ROW:
+        case XML_ELEMENT(TABLE, XML_TABLE_ROW):
             return new ScXMLExternalRefRowContext(
                 GetScImport(), pAttribList, mrExternalRefInfo);
         default:
-            ;
+            XMLOFF_WARN_UNKNOWN_ELEMENT("sc", nElement);
     }
     return nullptr;
 }
@@ -155,15 +154,11 @@ ScXMLExternalRefRowContext::ScXMLExternalRefRowContext(
 {
     mrExternalRefInfo.mnCol = 0;
 
-    const SvXMLTokenMap& rAttrTokenMap = mrScImport.GetTableRowAttrTokenMap();
-    if ( !rAttrList.is() )
-        return;
-
     for (auto &it : *rAttrList)
     {
-        switch ( rAttrTokenMap.Get( it.getToken() ) )
+        switch (it.getToken())
         {
-            case XML_TOK_TABLE_ROW_ATTR_REPEATED:
+            case XML_ELEMENT(TABLE, XML_NUMBER_ROWS_REPEATED):
             {
                 mnRepeatRowCount = std::max(it.toInt32(), static_cast<sal_Int32>(1));
             }
@@ -179,12 +174,10 @@ ScXMLExternalRefRowContext::~ScXMLExternalRefRowContext()
 Reference< XFastContextHandler > SAL_CALL ScXMLExternalRefRowContext::createFastChildContext(
     sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList )
 {
-    const SvXMLTokenMap& rTokenMap = mrScImport.GetTableRowElemTokenMap();
-    sal_uInt16 nToken = rTokenMap.Get( nElement );
     sax_fastparser::FastAttributeList *pAttribList =
         &sax_fastparser::castToFastAttributeList( xAttrList );
 
-    if (nToken == XML_TOK_TABLE_ROW_CELL || nToken == XML_TOK_TABLE_ROW_COVERED_CELL)
+    if (nElement == XML_ELEMENT(TABLE, XML_TABLE_CELL) || nElement == XML_ELEMENT(TABLE, XML_COVERED_TABLE_CELL))
         return new ScXMLExternalRefCellContext(mrScImport, pAttribList, mrExternalRefInfo);
 
     return nullptr;
@@ -235,15 +228,11 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
 {
     using namespace ::xmloff::token;
 
-    const SvXMLTokenMap& rTokenMap = rImport.GetTableRowCellAttrTokenMap();
-    if ( !rAttrList.is() )
-        return;
-
     for (auto &it : *rAttrList)
     {
-        switch ( rTokenMap.Get( it.getToken() ) )
+        switch ( it.getToken() )
         {
-            case XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME:
+            case XML_ELEMENT(TABLE, XML_STYLE_NAME):
             {
                 XMLTableStylesContext* pStyles = static_cast<XMLTableStylesContext*>(mrScImport.GetAutoStyles());
                 const XMLTableStyleContext* pStyle = static_cast<const XMLTableStyleContext*>(
@@ -252,17 +241,17 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
                     mnNumberFormat = const_cast<XMLTableStyleContext*>(pStyle)->GetNumberFormat();
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED:
+            case XML_ELEMENT(TABLE, XML_NUMBER_COLUMNS_REPEATED):
             {
                 mnRepeatCount = ::std::max( it.toInt32(), static_cast<sal_Int32>(1) );
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE:
+            case XML_ELEMENT(OFFICE, XML_VALUE_TYPE):
             {
                 mnCellType = ScXMLImport::GetCellType( it.toCString(), it.getLength() );
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE:
+            case XML_ELEMENT(OFFICE, XML_VALUE):
             {
                 if ( !it.isEmpty() )
                 {
@@ -272,7 +261,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
                 }
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE:
+            case XML_ELEMENT(OFFICE, XML_DATE_VALUE):
             {
                 if ( !it.isEmpty() && mrScImport.SetNullDateOnUnitConverter() )
                 {
@@ -282,7 +271,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
                 }
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE:
+            case XML_ELEMENT(OFFICE, XML_TIME_VALUE):
             {
                 if ( !it.isEmpty() )
                 {
@@ -292,7 +281,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
                 }
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE:
+            case XML_ELEMENT(OFFICE, XML_STRING_VALUE):
             {
                 if ( !it.isEmpty() )
                 {
@@ -302,7 +291,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
                 }
             }
             break;
-            case XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE:
+            case XML_ELEMENT(OFFICE, XML_BOOLEAN_VALUE):
             {
                 if ( !it.isEmpty() )
                 {
@@ -325,10 +314,7 @@ ScXMLExternalRefCellContext::~ScXMLExternalRefCellContext()
 Reference< XFastContextHandler > SAL_CALL ScXMLExternalRefCellContext::createFastChildContext(
     sal_Int32 nElement, const Reference< XFastAttributeList >& /*xAttrList*/ )
 {
-    const SvXMLTokenMap& rTokenMap = mrScImport.GetTableRowCellElemTokenMap();
-    sal_uInt16 nToken = rTokenMap.Get( nElement );
-
-    if (nToken == XML_TOK_TABLE_ROW_CELL_P)
+    if (nElement == XML_ELEMENT(TEXT, XML_P))
         return new ScXMLExternalRefCellTextContext(mrScImport, *this);
 
     return nullptr;
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 6af5959a66e9..1111f2349b99 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -172,34 +172,6 @@ Calc_XMLOasisSettingsImporter_get_implementation(
             { "com.sun.star.comp.Calc.XMLOasisSettingsImporter" } )));
 }
 
-const SvXMLTokenMap& ScXMLImport::GetTableRowCellAttrTokenMap()
-{
-    static const SvXMLTokenMapEntry aTableRowCellAttrTokenMap[] =
-    {
-        { XML_NAMESPACE_TABLE,  XML_STYLE_NAME,                     XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME              },
-        { XML_NAMESPACE_TABLE,  XML_CONTENT_VALIDATION_NAME,        XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME },
-        { XML_NAMESPACE_TABLE,  XML_NUMBER_ROWS_SPANNED,            XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS            },
-        { XML_NAMESPACE_TABLE,  XML_NUMBER_COLUMNS_SPANNED,         XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS            },
-        { XML_NAMESPACE_TABLE,  XML_NUMBER_MATRIX_COLUMNS_SPANNED,  XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS     },
-        { XML_NAMESPACE_TABLE,  XML_NUMBER_MATRIX_ROWS_SPANNED,     XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS     },
-        { XML_NAMESPACE_TABLE,  XML_NUMBER_COLUMNS_REPEATED,        XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED                },
-        { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE,                     XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE              },
-        { XML_NAMESPACE_CALC_EXT, XML_VALUE_TYPE,                   XML_TOK_TABLE_ROW_CELL_ATTR_NEW_VALUE_TYPE          },
-        { XML_NAMESPACE_OFFICE, XML_VALUE,                          XML_TOK_TABLE_ROW_CELL_ATTR_VALUE                   },
-        { XML_NAMESPACE_OFFICE, XML_DATE_VALUE,                     XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE              },
-        { XML_NAMESPACE_OFFICE, XML_TIME_VALUE,                     XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE              },
-        { XML_NAMESPACE_OFFICE, XML_STRING_VALUE,                   XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE            },
-        { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE,                  XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE           },
-        { XML_NAMESPACE_TABLE,  XML_FORMULA,                        XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA                 },
-        { XML_NAMESPACE_OFFICE, XML_CURRENCY,                       XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY                },
-        XML_TOKEN_MAP_END
-    };
-
-    if ( !pTableRowCellAttrTokenMap )
-        pTableRowCellAttrTokenMap.reset(new SvXMLTokenMap( aTableRowCellAttrTokenMap ));
-    return *pTableRowCellAttrTokenMap;
-}
-
 namespace {
 
 // NB: virtually inherit so we can multiply inherit properly
@@ -332,81 +304,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     return pContext;
 }
 
-const SvXMLTokenMap& ScXMLImport::GetTableRowsElemTokenMap()
-{
-    if( !pTableRowsElemTokenMap )
-    {
-        static const SvXMLTokenMapEntry aTableRowsElemTokenMap[] =
-        {
-            { XML_NAMESPACE_TABLE, XML_TABLE_ROW_GROUP,     XML_TOK_TABLE_ROWS_ROW_GROUP    },
-            { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS,   XML_TOK_TABLE_ROWS_HEADER_ROWS  },
-            { XML_NAMESPACE_TABLE, XML_TABLE_ROWS,          XML_TOK_TABLE_ROWS_ROWS         },
-            { XML_NAMESPACE_TABLE, XML_TABLE_ROW,           XML_TOK_TABLE_ROWS_ROW          },
-            XML_TOKEN_MAP_END
-        };
-
-        pTableRowsElemTokenMap.reset(new SvXMLTokenMap( aTableRowsElemTokenMap ));
-    } // if( !pTableRowsElemTokenMap )
-
-    return *pTableRowsElemTokenMap;
-}
-
-const SvXMLTokenMap& ScXMLImport::GetTableRowElemTokenMap()
-{
-    if( !pTableRowElemTokenMap )
-    {
-        static const SvXMLTokenMapEntry aTableRowTokenMap[] =
-        {
-            { XML_NAMESPACE_TABLE, XML_TABLE_CELL,      XML_TOK_TABLE_ROW_CELL              },
-            { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL,  XML_TOK_TABLE_ROW_COVERED_CELL      },
-            XML_TOKEN_MAP_END
-        };
-
-        pTableRowElemTokenMap.reset(new SvXMLTokenMap( aTableRowTokenMap ));
-    } // if( !pTableRowElemTokenMap )
-
-    return *pTableRowElemTokenMap;
-}
-
-const SvXMLTokenMap& ScXMLImport::GetTableRowAttrTokenMap()
-{
-    if( !pTableRowAttrTokenMap )
-    {
-        static const SvXMLTokenMapEntry aTableRowAttrTokenMap[] =
-        {
-            { XML_NAMESPACE_TABLE, XML_STYLE_NAME,                  XML_TOK_TABLE_ROW_ATTR_STYLE_NAME           },
-            { XML_NAMESPACE_TABLE, XML_VISIBILITY,                  XML_TOK_TABLE_ROW_ATTR_VISIBILITY           },
-            { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED,        XML_TOK_TABLE_ROW_ATTR_REPEATED             },
-            { XML_NAMESPACE_TABLE, XML_DEFAULT_CELL_STYLE_NAME,     XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME },
-            //  { XML_NAMESPACE_TABLE, XML_USE_OPTIMAL_HEIGHT,          XML_TOK_TABLE_ROW_ATTR_USE_OPTIMAL_HEIGHT   },
-            XML_TOKEN_MAP_END
-        };
-
-        pTableRowAttrTokenMap.reset(new SvXMLTokenMap( aTableRowAttrTokenMap ));
-    } // if( !pTableRowAttrTokenMap )
-
-    return *pTableRowAttrTokenMap;
-}
-
-const SvXMLTokenMap& ScXMLImport::GetTableRowCellElemTokenMap()
-{
-    if( !pTableRowCellElemTokenMap )
-    {
-        static const SvXMLTokenMapEntry aTableRowCellTokenMap[] =
-        {
-            { XML_NAMESPACE_TEXT,   XML_P,                  XML_TOK_TABLE_ROW_CELL_P                    },
-            { XML_NAMESPACE_TABLE,  XML_SUB_TABLE,          XML_TOK_TABLE_ROW_CELL_TABLE                },
-            { XML_NAMESPACE_OFFICE, XML_ANNOTATION,         XML_TOK_TABLE_ROW_CELL_ANNOTATION           },
-            { XML_NAMESPACE_TABLE,  XML_DETECTIVE,          XML_TOK_TABLE_ROW_CELL_DETECTIVE            },
-            { XML_NAMESPACE_TABLE,  XML_CELL_RANGE_SOURCE,  XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE    },
-            XML_TOKEN_MAP_END
-        };
-
-        pTableRowCellElemTokenMap.reset(new SvXMLTokenMap( aTableRowCellTokenMap ));
-    } // if( !pTableRowCellElemTokenMap )
-
-    return *pTableRowCellElemTokenMap;
-}
 
 void ScXMLImport::SetPostProcessData( sc::ImportPostProcessData* p )
 {
@@ -494,13 +391,6 @@ ScXMLImport::ScXMLImport(
 
 ScXMLImport::~ScXMLImport() throw()
 {
-    //  delete pI18NMap;
-    pTableRowsElemTokenMap.reset();
-    pTableRowElemTokenMap.reset();
-    pTableRowAttrTokenMap.reset();
-    pTableRowCellElemTokenMap.reset();
-    pTableRowCellAttrTokenMap.reset();
-
     pChangeTrackingImportHelper.reset();
     pNumberFormatAttributesExportHelper.reset();
     pStyleNumberFormats.reset();
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index cb7d3be4b65f..f0f246be02d5 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -219,12 +219,6 @@ class ScXMLImport: public SvXMLImport
     rtl::Reference < XMLPropertySetMapper >       xRowStylesPropertySetMapper;
     rtl::Reference < XMLPropertySetMapper >       xTableStylesPropertySetMapper;
 
-    std::unique_ptr<SvXMLTokenMap>           pTableRowsElemTokenMap;
-    std::unique_ptr<SvXMLTokenMap>           pTableRowElemTokenMap;
-    std::unique_ptr<SvXMLTokenMap>           pTableRowAttrTokenMap;
-    std::unique_ptr<SvXMLTokenMap>           pTableRowCellElemTokenMap;
-    std::unique_ptr<SvXMLTokenMap>           pTableRowCellAttrTokenMap;
-
     sc::ImportPostProcessData* mpPostProcessData; /// Lift cycle managed elsewhere, no need to delete.
 
     ScMyTables              aTables;
@@ -309,12 +303,6 @@ public:
     const rtl::Reference < XMLPropertySetMapper >& GetRowStylesPropertySetMapper() const { return xRowStylesPropertySetMapper; }
     const rtl::Reference < XMLPropertySetMapper >& GetTableStylesPropertySetMapper() const { return xTableStylesPropertySetMapper; }
 
-    const SvXMLTokenMap& GetTableRowsElemTokenMap();
-    const SvXMLTokenMap& GetTableRowElemTokenMap();
-    const SvXMLTokenMap& GetTableRowAttrTokenMap();
-    const SvXMLTokenMap& GetTableRowCellElemTokenMap();
-    const SvXMLTokenMap& GetTableRowCellAttrTokenMap();
-
     void SetPostProcessData( sc::ImportPostProcessData* p );
     sc::ImportPostProcessData* GetPostProcessData() { return mpPostProcessData;}
 


More information about the Libreoffice-commits mailing list