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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 19 09:33:56 UTC 2020


 xmloff/source/chart/SchXMLPlotAreaContext.cxx |   68 ++++++++++++--------------
 xmloff/source/chart/SchXMLPlotAreaContext.hxx |   30 ++++-------
 xmloff/source/chart/SchXMLSeries2Context.cxx  |    4 -
 3 files changed, 47 insertions(+), 55 deletions(-)

New commits:
commit 560baa7e6d04607408c9c5120099af09bc76e57c
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Wed Nov 18 20:19:47 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Nov 19 10:33:16 2020 +0100

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

diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index 4da56fd0f43b..1641a516e09c 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -583,8 +583,8 @@ void SchXMLPlotAreaContext::endFastElement(sal_Int32 )
     SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported );
 }
 
-SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
-    SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
+SchXMLDataLabelSpanContext::SchXMLDataLabelSpanContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels):
+    SvXMLImportContext( rImport ),
     mrLabels(rLabels)
 {
 }
@@ -599,42 +599,41 @@ void SchXMLDataLabelSpanContext::endFastElement(sal_Int32 )
     mrLabels.push_back(maCharBuffer.makeStringAndClear());
 }
 
-SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels):
-    SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName),
+SchXMLDataLabelParaContext::SchXMLDataLabelParaContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels):
+    SvXMLImportContext( rImport ),
     mrLabels(rLabels)
 {
 }
 
-SvXMLImportContextRef SchXMLDataLabelParaContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelParaContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
-    SvXMLImportContextRef xContext;
-    if ( IsXMLToken( rLocalName, XML_SPAN ) && nPrefix == XML_NAMESPACE_TEXT )
-        xContext = new SchXMLDataLabelSpanContext(GetImport(), rLocalName, mrLabels);
-    return xContext;
+    if ( nElement == XML_ELEMENT(TEXT, XML_SPAN) )
+        return new SchXMLDataLabelSpanContext(GetImport(), mrLabels);
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
+    return nullptr;
 }
 
-SchXMLDataLabelContext::SchXMLDataLabelContext(SvXMLImport& rImport, const OUString& rLocalName,
+SchXMLDataLabelContext::SchXMLDataLabelContext(SvXMLImport& rImport,
                                                ::std::vector<OUString>& rLabels,
                                                DataRowPointStyle& rDataLabelStyle)
-    : SvXMLImportContext(rImport, XML_NAMESPACE_CHART, rLocalName)
+    : SvXMLImportContext(rImport)
     , mrLabels(rLabels)
     , mrDataLabelStyle(rDataLabelStyle)
 {
 }
 
-SvXMLImportContextRef SchXMLDataLabelContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataLabelContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
-    SvXMLImportContextRef xContext;
-    if ( IsXMLToken( rLocalName, XML_P ) && nPrefix == XML_NAMESPACE_TEXT )
-        xContext = new SchXMLDataLabelParaContext(GetImport(), rLocalName, mrLabels);
-
-    return xContext;
+    if ( nElement == XML_ELEMENT(TEXT, XML_P) )
+        return new SchXMLDataLabelParaContext(GetImport(), mrLabels);
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
+    return nullptr;
 }
 
 void SchXMLDataLabelContext::StartElement(const uno::Reference<xml::sax::XAttributeList>& xAttrList)
@@ -674,14 +673,12 @@ void SchXMLDataLabelContext::StartElement(const uno::Reference<xml::sax::XAttrib
 }
 
 
-SchXMLDataPointContext::SchXMLDataPointContext(  SchXMLImportHelper& rImportHelper,
-                                                 SvXMLImport& rImport, const OUString& rLocalName,
+SchXMLDataPointContext::SchXMLDataPointContext(  SvXMLImport& rImport,
                                                  ::std::vector< DataRowPointStyle >& rStyleVector,
                                                  const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
                                                  sal_Int32& rIndex,
                                                  bool bSymbolSizeForSeriesIsMissingInFile ) :
-        SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
-        mrImportHelper( rImportHelper ),
+        SvXMLImportContext( rImport ),
         mrStyleVector( rStyleVector ),
         mrIndex( rIndex ),
         mDataPoint(DataRowPointStyle::DATA_POINT, xSeries, rIndex, 1, OUString{}),
@@ -690,21 +687,20 @@ SchXMLDataPointContext::SchXMLDataPointContext(  SchXMLImportHelper& rImportHelp
     mDataPoint.mbSymbolSizeForSeriesIsMissingInFile = bSymbolSizeForSeriesIsMissingInFile;
 }
 
-SvXMLImportContextRef SchXMLDataPointContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLDataPointContext::createFastChildContext(
+    sal_Int32 nElement,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
 {
     SvXMLImportContext* pContext = nullptr;
-    const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
-
-    switch( rTokenMap.Get( nPrefix, rLocalName ))
+    switch(nElement)
     {
-        case XML_TOK_SERIES_DATA_LABEL:
+        case XML_ELEMENT(CHART, XML_DATA_LABEL):
             mbHasLabelParagraph = true;
-            pContext = new SchXMLDataLabelContext(GetImport(), rLocalName, mDataPoint.mCustomLabels,
+            pContext = new SchXMLDataLabelContext(GetImport(), mDataPoint.mCustomLabels,
                                                   mDataLabel);
             break;
+        default:
+            XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
     }
     return pContext;
 }
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
index e4c17c156d41..7ecf80628734 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -144,7 +144,7 @@ private:
     ::std::vector<OUString>& mrLabels;
     OUStringBuffer maCharBuffer;
 public:
-    SchXMLDataLabelSpanContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels);
+    SchXMLDataLabelSpanContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels);
     virtual void SAL_CALL characters( const OUString& rChars ) override;
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
@@ -154,11 +154,10 @@ class SchXMLDataLabelParaContext: public SvXMLImportContext
 private:
     ::std::vector<OUString>& mrLabels;
 public:
-    SchXMLDataLabelParaContext( SvXMLImport& rImport, const OUString& rLocalName, ::std::vector<OUString>& rLabels);
-    virtual SvXMLImportContextRef CreateChildContext(
-        sal_uInt16 nPrefix,
-        const OUString& rLocalName,
-        const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
+    SchXMLDataLabelParaContext( SvXMLImport& rImport, ::std::vector<OUString>& rLabels);
+    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 SchXMLDataLabelContext: public SvXMLImportContext
@@ -167,20 +166,19 @@ private:
     ::std::vector<OUString>& mrLabels;
     DataRowPointStyle& mrDataLabelStyle;
 public:
-    SchXMLDataLabelContext(SvXMLImport& rImport, const OUString& rLocalName,
+    SchXMLDataLabelContext(SvXMLImport& rImport,
                             ::std::vector<OUString>& rLabels, DataRowPointStyle& rDataLabel);
 
     virtual void StartElement(const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList) 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 SchXMLDataPointContext : public SvXMLImportContext
 {
 private:
-    SchXMLImportHelper& mrImportHelper;
     ::std::vector<DataRowPointStyle>& mrStyleVector;
     bool mbHasLabelParagraph = false;
     sal_Int32& mrIndex;
@@ -189,8 +187,7 @@ private:
     DataRowPointStyle mDataLabel;
 
 public:
-    SchXMLDataPointContext(  SchXMLImportHelper& rImportHelper,
-                             SvXMLImport& rImport, const OUString& rLocalName,
+    SchXMLDataPointContext(  SvXMLImport& rImport,
                              ::std::vector< DataRowPointStyle >& rStyleVector,
                              const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
                              sal_Int32& rIndex,
@@ -199,10 +196,9 @@ public:
 
     virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) 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 SAL_CALL endFastElement(sal_Int32 nElement) override;
 };
 
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 5bcdbe688295..576d628d2fe5 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -722,13 +722,13 @@ SvXMLImportContextRef SchXMLSeries2Context::CreateChildContext(
             break;
 
         case XML_TOK_SERIES_DATA_POINT:
-            pContext = new SchXMLDataPointContext( mrImportHelper, GetImport(), rLocalName,
+            pContext = new SchXMLDataPointContext( GetImport(),
                                                    mrStyleVector, m_xSeries, mnDataPointIndex, mbSymbolSizeIsMissingInFile );
             break;
         case XML_TOK_SERIES_DATA_LABEL:
             // CustomLabels are useless for a data label element as child of a series, because it serves as default
             // for all data labels. But the ctor expects it, so use that of the mDataLabel struct as ersatz.
-            pContext = new SchXMLDataLabelContext(GetImport(), rLocalName, mDataLabel.mCustomLabels,
+            pContext = new SchXMLDataLabelContext(GetImport(), mDataLabel.mCustomLabels,
                                                   mDataLabel);
             break;
 


More information about the Libreoffice-commits mailing list