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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 17 12:13:38 UTC 2020


 xmloff/source/chart/SchXMLChartContext.cxx    |   95 +++++++++++++++++---------
 xmloff/source/chart/SchXMLChartContext.hxx    |    6 +
 xmloff/source/chart/SchXMLLegendContext.cxx   |    4 -
 xmloff/source/chart/SchXMLLegendContext.hxx   |    2 
 xmloff/source/chart/SchXMLPlotAreaContext.cxx |    4 -
 xmloff/source/chart/SchXMLPlotAreaContext.hxx |    2 
 xmloff/source/chart/SchXMLTableContext.cxx    |    3 
 xmloff/source/chart/SchXMLTableContext.hxx    |    1 
 8 files changed, 75 insertions(+), 42 deletions(-)

New commits:
commit 746532883f95f2c93ac2f94a578d2a37efdce7ab
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Mon Nov 16 19:54:42 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Nov 17 13:13:01 2020 +0100

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

diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index cbef46fa0ab0..a183d0b1e5f4 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -303,11 +303,10 @@ static void lcl_setDataProvider(uno::Reference<chart2::XChartDocument> const & x
     }
 }
 
-void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+void SchXMLChartContext::startFastElement( sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
 {
     // parse attributes
-    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetChartAttrTokenMap();
 
     uno::Reference< embed::XVisualObject > xVisualObject( mrImportHelper.GetChartDocument(), uno::UNO_QUERY);
     SAL_WARN_IF(!xVisualObject.is(), "xmloff.chart", "need xVisualObject for page size");
@@ -318,22 +317,18 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
     OUString aOldChartTypeName;
     bool bHasAddin = false;
 
-    for( sal_Int16 i = 0; i < nAttrCount; i++ )
+    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
     {
-        OUString sAttrName = xAttrList->getNameByIndex( i );
-        OUString aLocalName;
-        OUString aValue = xAttrList->getValueByIndex( i );
-        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
-
-        switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+        OUString aValue = aIter.toString();
+        switch( aIter.getToken() )
         {
-            case XML_TOK_CHART_DATA_PILOT_SOURCE:
+            case XML_ELEMENT(LO_EXT, XML_DATA_PILOT_SOURCE):
                 msDataPilotSource = aValue;
                 break;
-            case XML_TOK_CHART_HREF:
+            case XML_ELEMENT(XLINK, XML_HREF):
                 m_aXLinkHRefAttributeToIndicateDataProvider = aValue;
                 break;
-            case XML_TOK_CHART_CLASS:
+            case XML_ELEMENT(CHART, XML_CLASS):
                 {
                     OUString sClassName;
                     sal_uInt16 nClassPrefix =
@@ -367,26 +362,30 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
                 }
                 break;
 
-            case XML_TOK_CHART_WIDTH:
+            case XML_ELEMENT(SVG, XML_WIDTH):
+            case XML_ELEMENT(SVG_COMPAT, XML_WIDTH):
                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
                         maChartSize.Width, aValue );
                 break;
 
-            case XML_TOK_CHART_HEIGHT:
+            case XML_ELEMENT(SVG, XML_HEIGHT):
+            case XML_ELEMENT(SVG_COMPAT, XML_HEIGHT):
                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
                         maChartSize.Height, aValue );
                 break;
 
-            case XML_TOK_CHART_STYLE_NAME:
+            case XML_ELEMENT(CHART, XML_STYLE_NAME):
                 sAutoStyleName = aValue;
                 break;
 
-            case XML_TOK_CHART_COL_MAPPING:
+            case XML_ELEMENT(CHART, XML_COLUMN_MAPPING):
                 msColTrans = aValue;
                 break;
-            case XML_TOK_CHART_ROW_MAPPING:
+            case XML_ELEMENT(CHART,  XML_ROW_MAPPING):
                 msRowTrans = aValue;
                 break;
+            default:
+                XMLOFF_WARN_UNKNOWN("xmloff", aIter);
         }
     }
 
@@ -1019,20 +1018,18 @@ void SchXMLChartContext::MergeSeriesForStockChart()
     }
 }
 
-SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
 {
     SvXMLImportContext* pContext = nullptr;
-    const SvXMLTokenMap& rTokenMap = mrImportHelper.GetChartElemTokenMap();
     uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
     uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
 
-    switch( rTokenMap.Get( nPrefix, rLocalName ))
+    switch(nElement)
     {
-        case XML_TOK_CHART_PLOT_AREA:
-            pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(), rLocalName,
+        case XML_ELEMENT(CHART, XML_PLOT_AREA):
+            pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(),
                                                   m_aXLinkHRefAttributeToIndicateDataProvider,
                                                   msCategoriesAddress,
                                                   msChartAddress, m_bHasRangeAtPlotArea, mbAllRangeAddressesAvailable,
@@ -1043,7 +1040,7 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
                                                   maLSequencesPerIndex, maChartSize );
             break;
 
-        case XML_TOK_CHART_TITLE:
+        case XML_ELEMENT(CHART, XML_TITLE):
             if( xDoc.is())
             {
                 if( xProp.is())
@@ -1056,7 +1053,7 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
             }
             break;
 
-        case XML_TOK_CHART_SUBTITLE:
+        case XML_ELEMENT(CHART, XML_SUBTITLE):
             if( xDoc.is())
             {
                 if( xProp.is())
@@ -1069,14 +1066,14 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
             }
             break;
 
-        case XML_TOK_CHART_LEGEND:
-            pContext = new SchXMLLegendContext( mrImportHelper, GetImport(), rLocalName );
+        case XML_ELEMENT(CHART, XML_LEGEND):
+            pContext = new SchXMLLegendContext( mrImportHelper, GetImport() );
             break;
 
-        case XML_TOK_CHART_TABLE:
+        case  XML_ELEMENT(TABLE, XML_TABLE):
             {
                 SchXMLTableContext * pTableContext =
-                    new SchXMLTableContext( mrImportHelper, GetImport(), rLocalName, maTable );
+                    new SchXMLTableContext( mrImportHelper, GetImport(), maTable );
                 m_bHasTableElement = true;
                 // #i85913# take into account column- and row- mapping for
                 // charts with own data only for those which were not copied
@@ -1105,6 +1102,40 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
             }
             break;
 
+        default:
+            break;
+    }
+
+    return pContext;
+}
+
+SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
+    sal_uInt16 nPrefix,
+    const OUString& rLocalName,
+    const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+    SvXMLImportContext* pContext = nullptr;
+    const SvXMLTokenMap& rTokenMap = mrImportHelper.GetChartElemTokenMap();
+    uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+    uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
+
+    switch( rTokenMap.Get( nPrefix, rLocalName ))
+    {
+        case XML_TOK_CHART_PLOT_AREA:
+            break;
+
+        case XML_TOK_CHART_TITLE:
+            break;
+
+        case XML_TOK_CHART_SUBTITLE:
+            break;
+
+        case XML_TOK_CHART_LEGEND:
+            break;
+
+        case XML_TOK_CHART_TABLE:
+            break;
+
         default:
             // try importing as an additional shape
             if( ! mxDrawPage.is())
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index afc15a16f12e..ce1868b0adc3 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -79,8 +79,12 @@ public:
                         SvXMLImport& rImport );
     virtual ~SchXMLChartContext() override;
 
-    virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
+    virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
     virtual void 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 >& AttrList ) override;
     virtual SvXMLImportContextRef CreateChildContext(
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
diff --git a/xmloff/source/chart/SchXMLLegendContext.cxx b/xmloff/source/chart/SchXMLLegendContext.cxx
index d58738b5387b..e043edb1f65f 100644
--- a/xmloff/source/chart/SchXMLLegendContext.cxx
+++ b/xmloff/source/chart/SchXMLLegendContext.cxx
@@ -80,8 +80,8 @@ struct theLegendAttributeTokenMap : public rtl::Static< LegendAttributeTokenMap,
 
 }//end anonymous namespace
 
-SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const OUString& rLocalName ) :
-    SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport ) :
+    SvXMLImportContext( rImport ),
     mrImportHelper( rImpHelper )
 {
 }
diff --git a/xmloff/source/chart/SchXMLLegendContext.hxx b/xmloff/source/chart/SchXMLLegendContext.hxx
index 2d0c46981229..548237bc284b 100644
--- a/xmloff/source/chart/SchXMLLegendContext.hxx
+++ b/xmloff/source/chart/SchXMLLegendContext.hxx
@@ -27,7 +27,7 @@
 class SchXMLLegendContext : public SvXMLImportContext
 {
 public:
-    SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const OUString& rLocalName );
+    SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport );
     virtual ~SchXMLLegendContext() override;
 
     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index 7dd72350dacf..7c0f8e5add61 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -119,7 +119,7 @@ SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
 
 SchXMLPlotAreaContext::SchXMLPlotAreaContext(
     SchXMLImportHelper& rImpHelper,
-    SvXMLImport& rImport, const OUString& rLocalName,
+    SvXMLImport& rImport,
     const OUString& rXLinkHRefAttributeToIndicateDataProvider,
     OUString& rCategoriesAddress,
     OUString& rChartAddress,
@@ -132,7 +132,7 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext(
     const OUString& aChartTypeServiceName,
     tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
     const awt::Size & rChartSize ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+        SvXMLImportContext( rImport ),
         mrImportHelper( rImpHelper ),
         mrCategoriesAddress( rCategoriesAddress ),
         mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
index 83aa55e4d6a2..652394a14bb5 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -85,7 +85,7 @@ class SchXMLPlotAreaContext : public SvXMLImportContext
 {
 public:
     SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
-                           SvXMLImport& rImport, const OUString& rLocalName,
+                           SvXMLImport& rImport,
                            const OUString& rXLinkHRefAttributeToIndicateDataProvider,
                            OUString& rCategoriesAddress,
                            OUString& rChartAddress,
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index 49206329c86d..c0c88c1274a4 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -197,9 +197,8 @@ bool lcl_tableOfRangeMatches(
 // class SchXMLTableContext
 SchXMLTableContext::SchXMLTableContext( SchXMLImportHelper& rImpHelper,
                                         SvXMLImport& rImport,
-                                        const OUString& rLName,
                                         SchXMLTable& aTable ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLName ),
+        SvXMLImportContext( rImport ),
         mrImportHelper( rImpHelper ),
         mrTable( aTable ),
         mbHasRowPermutation( false ),
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx
index faca076e5230..e9d2eb004387 100644
--- a/xmloff/source/chart/SchXMLTableContext.hxx
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -50,7 +50,6 @@ private:
 public:
     SchXMLTableContext( SchXMLImportHelper& rImpHelper,
                         SvXMLImport& rImport,
-                        const OUString& rLocalName,
                         SchXMLTable& aTable );
     virtual ~SchXMLTableContext() override;
 


More information about the Libreoffice-commits mailing list