xmloff/source/chart/SchXMLTableContext.cxx    |  141 +++++++++++---------------
 xmloff/source/chart/SchXMLTableContext.hxx    |   40 ++-----
 xmloff/source/chart/SchXMLTextListContext.cxx |    3 
 xmloff/source/chart/SchXMLTextListContext.hxx |    1 
 4 files changed, 80 insertions(+), 105 deletions(-)

New commits:
commit 85c02385564f42dcaad270e8123fc3109b9ebbba
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Nov 18 20:46:19 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Nov 19 14:00:50 2020 +0100

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

diff --git a/xmloff/source/chart/SchXMLTableContext.cxx 
b/xmloff/source/chart/SchXMLTableContext.cxx
index a6119fae5eb2..1c2b912a7717 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -214,37 +214,37 @@ SchXMLTableContext::~SchXMLTableContext()
 {
 }
 
-SvXMLImportContextRef SchXMLTableContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLTableContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContext* pContext = nullptr;
-    const SvXMLTokenMap& rTokenMap = mrImportHelper.GetTableElemTokenMap();
 
-    switch( rTokenMap.Get( nPrefix, rLocalName ))
+    switch(nElement)
     {
-        case XML_TOK_TABLE_HEADER_COLS:
+        case XML_ELEMENT(TABLE, XML_TABLE_HEADER_COLUMNS):
             mrTable.bHasHeaderColumn = true;
             [[fallthrough]];
-        case XML_TOK_TABLE_COLUMNS:
-            pContext = new SchXMLTableColumnsContext( GetImport(), rLocalName, 
mrTable );
+        case XML_ELEMENT(TABLE, XML_TABLE_COLUMNS):
+            pContext = new SchXMLTableColumnsContext( GetImport(), mrTable );
             break;
 
-        case XML_TOK_TABLE_COLUMN:
-            pContext = new SchXMLTableColumnContext( GetImport(), rLocalName, 
mrTable );
+        case XML_ELEMENT(TABLE, XML_TABLE_COLUMN):
+            pContext = new SchXMLTableColumnContext( GetImport(), mrTable );
             break;
 
-        case XML_TOK_TABLE_HEADER_ROWS:
+        case XML_ELEMENT(TABLE, XML_TABLE_HEADER_ROWS):
             mrTable.bHasHeaderRow = true;
             [[fallthrough]];
-        case XML_TOK_TABLE_ROWS:
-            pContext = new SchXMLTableRowsContext( mrImportHelper, 
GetImport(), rLocalName, mrTable );
+        case XML_ELEMENT(TABLE, XML_TABLE_ROWS):
+            pContext = new SchXMLTableRowsContext( mrImportHelper, 
GetImport(), mrTable );
             break;
 
-        case XML_TOK_TABLE_ROW:
-            pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), 
rLocalName, mrTable );
+        case XML_ELEMENT(TABLE, XML_TABLE_ROW):
+            pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), 
mrTable );
             break;
+        default:
+            XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
     }
 
     return pContext;
@@ -386,9 +386,8 @@ void SchXMLTableContext::setColumnPermutation( const 
uno::Sequence< sal_Int32 >
 // class SchXMLTableColumnsContext
 SchXMLTableColumnsContext::SchXMLTableColumnsContext(
     SvXMLImport& rImport,
-    const OUString& rLocalName,
     SchXMLTable& aTable ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrTable( aTable )
 {
 }
@@ -397,18 +396,16 @@ SchXMLTableColumnsContext::~SchXMLTableColumnsContext()
 {
 }
 
-SvXMLImportContextRef SchXMLTableColumnsContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLTableColumnsContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContext* pContext = nullptr;
 
-    if( nPrefix == XML_NAMESPACE_TABLE &&
-        IsXMLToken( rLocalName, XML_TABLE_COLUMN ) )
-    {
-        pContext = new SchXMLTableColumnContext( GetImport(), rLocalName, 
mrTable );
-    }
+    if( nElement == XML_ELEMENT(TABLE, XML_TABLE_COLUMN) )
+        pContext = new SchXMLTableColumnContext( GetImport(), mrTable );
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
 
     return pContext;
 }
@@ -416,9 +413,8 @@ SvXMLImportContextRef 
SchXMLTableColumnsContext::CreateChildContext(
 // class SchXMLTableColumnContext
 SchXMLTableColumnContext::SchXMLTableColumnContext(
     SvXMLImport& rImport,
-    const OUString& rLocalName,
     SchXMLTable& aTable ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrTable( aTable )
 {
 }
@@ -477,9 +473,8 @@ SchXMLTableColumnContext::~SchXMLTableColumnContext()
 SchXMLTableRowsContext::SchXMLTableRowsContext(
     SchXMLImportHelper& rImpHelper,
     SvXMLImport& rImport,
-    const OUString& rLocalName,
     SchXMLTable& aTable ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrImportHelper( rImpHelper ),
         mrTable( aTable )
 {
@@ -489,18 +484,16 @@ SchXMLTableRowsContext::~SchXMLTableRowsContext()
 {
 }
 
-SvXMLImportContextRef SchXMLTableRowsContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLTableRowsContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContext* pContext = nullptr;
 
-    if( nPrefix == XML_NAMESPACE_TABLE &&
-        IsXMLToken( rLocalName, XML_TABLE_ROW ) )
-    {
-        pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), 
rLocalName, mrTable );
-    }
+    if( nElement == XML_ELEMENT(TABLE, XML_TABLE_ROW) )
+        pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), 
mrTable );
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
 
     return pContext;
 }
@@ -509,9 +502,8 @@ SvXMLImportContextRef 
SchXMLTableRowsContext::CreateChildContext(
 SchXMLTableRowContext::SchXMLTableRowContext(
     SchXMLImportHelper& rImpHelper,
     SvXMLImport& rImport,
-    const OUString& rLocalName,
     SchXMLTable& aTable ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrImportHelper( rImpHelper ),
         mrTable( aTable )
 {
@@ -528,21 +520,20 @@ SchXMLTableRowContext::~SchXMLTableRowContext()
 {
 }
 
-SvXMLImportContextRef SchXMLTableRowContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLTableRowContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContext* pContext = nullptr;
 
     // <table:table-cell> element
-    if( nPrefix == XML_NAMESPACE_TABLE &&
-        IsXMLToken(rLocalName, XML_TABLE_CELL ) )
+    if( nElement == XML_ELEMENT(TABLE, XML_TABLE_CELL) )
     {
-        pContext = new SchXMLTableCellContext( mrImportHelper, GetImport(), 
rLocalName, mrTable );
+        pContext = new SchXMLTableCellContext( mrImportHelper, GetImport(), 
mrTable );
     }
     else
     {
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
         assert(false);
     }
 
@@ -564,14 +555,11 @@ private:
 
 public:
     SchXMLRangeSomewhereContext( SvXMLImport& rImport,
-                            sal_uInt16 nPrefix,
-                            const OUString& rLocalName,
                             OUString& rRangeString );
 
-    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;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
 
@@ -581,8 +569,8 @@ public:
 // class SchXMLTableCellContext
 SchXMLTableCellContext::SchXMLTableCellContext(
     SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
-    const OUString& rLocalName, SchXMLTable& aTable)
-    : SvXMLImportContext(rImport, XML_NAMESPACE_TABLE, rLocalName)
+    SchXMLTable& aTable)
+    : SvXMLImportContext(rImport)
     , mrImportHelper(rImpHelper)
     , mrTable(aTable)
     , mbReadText(false)
@@ -644,35 +632,36 @@ void SchXMLTableCellContext::StartElement( const 
uno::Reference< xml::sax::XAttr
         mrTable.nMaxColumnIndex = mrTable.nColumnIndex;
 }
 
-SvXMLImportContextRef SchXMLTableCellContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLTableCellContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContext* pContext = nullptr;
 
     // <text:list> element
-    if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST ) && 
mbReadText )
+    if( nElement == XML_ELEMENT(TEXT, XML_LIST ) && mbReadText )
     {
         SchXMLCell& rCell = mrTable.aData[ mrTable.nRowIndex ][ 
mrTable.nColumnIndex ];
         rCell.aComplexString = Sequence< OUString >();
         rCell.eType = SCH_CELL_TYPE_COMPLEX_STRING;
-        pContext = new SchXMLTextListContext( GetImport(), rLocalName, 
rCell.aComplexString );
+        pContext = new SchXMLTextListContext( GetImport(), 
rCell.aComplexString );
         mbReadText = false;//don't apply text from <text:p>
     }
     // <text:p> element - read text (and range from text:id old version)
-    else if( (nPrefix == XML_NAMESPACE_TEXT ||
-                nPrefix == XML_NAMESPACE_LO_EXT) && IsXMLToken( rLocalName, 
XML_P ) )
+    else if( nElement == XML_ELEMENT(TEXT, XML_P) ||
+            nElement == XML_ELEMENT(LO_EXT, XML_P) )
     {
         pContext = new SchXMLParagraphContext( GetImport(), maCellContent, 
&maRangeId );
     }
     // <draw:g> element - read range
-    else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_G ) )
+    else if( nElement == XML_ELEMENT(DRAW, XML_G) )
     {
         //#i113950# previously the range was exported to attribute text:id, 
but that attribute does not allow arbitrary strings anymore
         //so we need to find an alternative to save that range info for 
copy/paste scenario ... -> use description at an empty group element for now
-        pContext = new SchXMLRangeSomewhereContext( GetImport(), nPrefix, 
rLocalName, maRangeId );
+        pContext = new SchXMLRangeSomewhereContext( GetImport(), maRangeId );
     }
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
 
     return pContext;
 }
@@ -1044,24 +1033,22 @@ void 
SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
 }
 
 SchXMLRangeSomewhereContext::SchXMLRangeSomewhereContext( SvXMLImport& rImport,
-                                                sal_uInt16 nPrefix,
-                                                const OUString& rLocalName,
                                                 OUString& rRangeString ) :
-        SvXMLImportContext( rImport, nPrefix, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrRangeString( rRangeString )
 {
 }
 
-SvXMLImportContextRef SchXMLRangeSomewhereContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > 
SchXMLRangeSomewhereContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
-    if( XML_NAMESPACE_SVG == nPrefix && IsXMLToken( rLocalName, XML_DESC ) )
+    if( nElement == XML_ELEMENT(SVG, XML_DESC) )
     {
-        return new XMLStringBufferImportContext(
-            GetImport(), nPrefix, rLocalName, maRangeStringBuffer );
+        return new XMLStringBufferImportContext( GetImport(), 
maRangeStringBuffer );
     }
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
     return nullptr;
 }
 
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx 
b/xmloff/source/chart/SchXMLTableContext.hxx
index e9d2eb004387..179a071f3046 100644
--- a/xmloff/source/chart/SchXMLTableContext.hxx
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -53,10 +53,9 @@ public:
                         SchXMLTable& aTable );
     virtual ~SchXMLTableContext() 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;
     virtual void StartElement( const css::uno::Reference< 
css::xml::sax::XAttributeList >& xAttrList ) override;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 
@@ -93,14 +92,12 @@ private:
 
 public:
     SchXMLTableColumnsContext( SvXMLImport& rImport,
-                               const OUString& rLocalName,
                                SchXMLTable& aTable );
     virtual ~SchXMLTableColumnsContext() 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;
 };
 
 class SchXMLTableColumnContext : public SvXMLImportContext
@@ -110,7 +107,6 @@ private:
 
 public:
     SchXMLTableColumnContext( SvXMLImport& rImport,
-                              const OUString& rLocalName,
                               SchXMLTable& aTable );
     virtual ~SchXMLTableColumnContext() override;
     virtual void StartElement( const css::uno::Reference< 
css::xml::sax::XAttributeList >& xAttrList ) override;
@@ -127,14 +123,12 @@ private:
 public:
     SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper,
                             SvXMLImport& rImport,
-                            const OUString& rLocalName,
                             SchXMLTable& aTable );
     virtual ~SchXMLTableRowsContext() 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;
 };
 
 class SchXMLTableRowContext : public SvXMLImportContext
@@ -146,14 +140,12 @@ private:
 public:
     SchXMLTableRowContext( SchXMLImportHelper& rImpHelper,
                            SvXMLImport& rImport,
-                           const OUString& rLocalName,
                            SchXMLTable& aTable );
     virtual ~SchXMLTableRowContext() 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;
 };
 
 // classes for cells and their content
@@ -170,14 +162,12 @@ private:
 public:
     SchXMLTableCellContext( SchXMLImportHelper& rImpHelper,
                             SvXMLImport& rImport,
-                            const OUString& rLocalName,
                             SchXMLTable& aTable );
     virtual ~SchXMLTableCellContext() 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;
     virtual void StartElement( const css::uno::Reference< 
css::xml::sax::XAttributeList >& xAttrList ) override;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
diff --git a/xmloff/source/chart/SchXMLTextListContext.cxx 
b/xmloff/source/chart/SchXMLTextListContext.cxx
index b49964726e72..29c2321e1196 100644
--- a/xmloff/source/chart/SchXMLTextListContext.cxx
+++ b/xmloff/source/chart/SchXMLTextListContext.cxx
@@ -68,9 +68,8 @@ SvXMLImportContextRef 
SchXMLListItemContext::CreateChildContext(
 
 SchXMLTextListContext::SchXMLTextListContext(
         SvXMLImport& rImport
-        , const OUString& rLocalName
         , Sequence< OUString>& rTextList )
-        : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName )
+        : SvXMLImportContext( rImport )
         , m_rTextList( rTextList )
         , m_aTextVector()
 {
diff --git a/xmloff/source/chart/SchXMLTextListContext.hxx 
b/xmloff/source/chart/SchXMLTextListContext.hxx
index 05893eb6c415..90ebd17bb9cc 100644
--- a/xmloff/source/chart/SchXMLTextListContext.hxx
+++ b/xmloff/source/chart/SchXMLTextListContext.hxx
@@ -31,7 +31,6 @@ class SchXMLTextListContext : public SvXMLImportContext
 {
 public:
     SchXMLTextListContext( SvXMLImport& rImport,
-                            const OUString& rLocalName,
                             css::uno::Sequence< OUString>& rTextList );
     virtual ~SchXMLTextListContext() override;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to