diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-18 20:09:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-19 09:55:37 +0100 |
commit | fecb0bbb7f7d899b8465c6e785c0a45496141b6e (patch) | |
tree | d47cd0ee70fa3d2bd0447282efdc9f417b7032bc /xmloff | |
parent | d17404878b3629f501331979d6379837019cdf2a (diff) |
fastparser in SchXMLPlotAreaContext
Change-Id: I77eab3ebacaca4c3327f60fac0970330fc9fe10b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106072
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/SchXMLAxisContext.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLAxisContext.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLPlotAreaContext.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLPlotAreaContext.hxx | 13 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLSeries2Context.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLSeries2Context.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/ximp3dscene.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/draw/ximp3dscene.hxx | 3 |
8 files changed, 77 insertions, 75 deletions
diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx index ff4bd8d1066c..b4a6490e5a8d 100644 --- a/xmloff/source/chart/SchXMLAxisContext.cxx +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -101,7 +101,7 @@ private: } SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const OUString& rLocalName, + SvXMLImport& rImport, Reference< chart::XDiagram > const & xDiagram, std::vector< SchXMLAxis >& rAxes, OUString & rCategoriesAddress, @@ -109,7 +109,7 @@ SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, bool bAdaptWrongPercentScaleValues, bool bAdaptXAxisOrientationForOld2DBarCharts, bool& rbAxisPositionAttributeImported ) : - SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), + SvXMLImportContext( rImport ), m_rImportHelper( rImpHelper ), m_xDiagram( xDiagram ), m_rAxes( rAxes ), diff --git a/xmloff/source/chart/SchXMLAxisContext.hxx b/xmloff/source/chart/SchXMLAxisContext.hxx index 4c2ab3d07539..8cb8f78098e9 100644 --- a/xmloff/source/chart/SchXMLAxisContext.hxx +++ b/xmloff/source/chart/SchXMLAxisContext.hxx @@ -31,7 +31,7 @@ class SchXMLAxisContext : public SvXMLImportContext { public: SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const OUString& rLocalName, + SvXMLImport& rImport, css::uno::Reference< css::chart::XDiagram > const & xDiagram, std::vector< SchXMLAxis >& aAxes, OUString& rCategoriesAddress, diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index 7c0f8e5add61..4da56fd0f43b 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -399,24 +399,22 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri } } -SvXMLImportContextRef SchXMLPlotAreaContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLPlotAreaContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext* pContext = nullptr; - const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLocalName )) + switch(nElement) { - case XML_TOK_PA_COORDINATE_REGION_EXT: - case XML_TOK_PA_COORDINATE_REGION: + case XML_ELEMENT(CHART_EXT, XML_COORDINATE_REGION): + case XML_ELEMENT(CHART, XML_COORDINATE_REGION): { - pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning ); + pContext = new SchXMLCoordinateRegionContext( GetImport(), m_aInnerPositioning ); } break; - case XML_TOK_PA_AXIS: + case XML_ELEMENT(CHART, XML_AXIS): { bool bAddMissingXAxisForNetCharts = false; bool bAdaptWrongPercentScaleValues = false; @@ -442,17 +440,17 @@ SvXMLImportContextRef SchXMLPlotAreaContext::CreateChildContext( bAdaptXAxisOrientationForOld2DBarCharts = true; } - pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress, + pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), mxDiagram, maAxes, mrCategoriesAddress, bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported ); } break; - case XML_TOK_PA_SERIES: + case XML_ELEMENT(CHART, XML_SERIES): { if( mxNewDoc.is()) { pContext = new SchXMLSeries2Context( - mrImportHelper, GetImport(), rLocalName, + mrImportHelper, GetImport(), mxNewDoc, maAxes, mrSeriesDefaultsAndStyles.maSeriesStyleVector, mrSeriesDefaultsAndStyles.maRegressionStyleVector, @@ -467,32 +465,34 @@ SvXMLImportContextRef SchXMLPlotAreaContext::CreateChildContext( } break; - case XML_TOK_PA_WALL: - pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + case XML_ELEMENT(CHART, XML_WALL): + pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), mxDiagram, SchXMLWallFloorContext::CONTEXT_TYPE_WALL ); break; - case XML_TOK_PA_FLOOR: - pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + case XML_ELEMENT(CHART, XML_FLOOR): + pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), mxDiagram, SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR ); break; - case XML_TOK_PA_LIGHT_SOURCE: - pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList ); + case XML_ELEMENT(DR3D, XML_LIGHT): + pContext = maSceneImportHelper.create3DLightContext( xAttrList ); break; // elements for stock charts - case XML_TOK_PA_STOCK_GAIN: - pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + case XML_ELEMENT(CHART, XML_STOCK_GAIN_MARKER): + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), mxDiagram, SchXMLStockContext::CONTEXT_TYPE_GAIN ); break; - case XML_TOK_PA_STOCK_LOSS: - pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + case XML_ELEMENT(CHART, XML_STOCK_LOSS_MARKER): + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), mxDiagram, SchXMLStockContext::CONTEXT_TYPE_LOSS ); break; - case XML_TOK_PA_STOCK_RANGE: - pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, + case XML_ELEMENT(CHART, XML_STOCK_RANGE_LINE): + pContext = new SchXMLStockContext( mrImportHelper, GetImport(), mxDiagram, SchXMLStockContext::CONTEXT_TYPE_RANGE ); break; + default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); } return pContext; @@ -866,10 +866,8 @@ void SchXMLPositionAttributesHelper::readAutomaticPositioningProperties( XMLProp SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext( SvXMLImport& rImport - , sal_uInt16 nPrefix - , const OUString& rLocalName , SchXMLPositionAttributesHelper& rPositioning ) - : SvXMLImportContext( rImport, nPrefix, rLocalName ) + : SvXMLImportContext( rImport ) , m_rPositioning( rPositioning ) { } @@ -896,11 +894,9 @@ void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax SchXMLWallFloorContext::SchXMLWallFloorContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, uno::Reference< chart::XDiagram > const & xDiagram, ContextType eContextType ) : - SvXMLImportContext( rImport, nPrefix, rLocalName ), + SvXMLImportContext( rImport ), mrImportHelper( rImpHelper ), mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ), meContextType( eContextType ) @@ -944,11 +940,9 @@ void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttr SchXMLStockContext::SchXMLStockContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, uno::Reference< chart::XDiagram > const & xDiagram, ContextType eContextType ) : - SvXMLImportContext( rImport, nPrefix, rLocalName ), + SvXMLImportContext( rImport ), mrImportHelper( rImpHelper ), mxStockPropProvider( xDiagram, uno::UNO_QUERY ), meContextType( eContextType ) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx index 652394a14bb5..e4c17c156d41 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx @@ -101,10 +101,9 @@ public: virtual ~SchXMLPlotAreaContext() override; 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; private: @@ -212,8 +211,6 @@ class SchXMLCoordinateRegionContext : public SvXMLImportContext public: SchXMLCoordinateRegionContext( SvXMLImport& rImport - , sal_uInt16 nPrefix - , const OUString& rLocalName , SchXMLPositionAttributesHelper& rPositioning ); virtual ~SchXMLCoordinateRegionContext() override; virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override; @@ -239,8 +236,6 @@ private: public: SchXMLWallFloorContext( SchXMLImportHelper& rImportHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, css::uno::Reference< css::chart::XDiagram > const & xDiagram, ContextType eContextType ); virtual ~SchXMLWallFloorContext() override; @@ -265,8 +260,6 @@ private: public: SchXMLStockContext( SchXMLImportHelper& rImportHelper, SvXMLImport& rImport, - sal_uInt16 nPrefix, - const OUString& rLocalName, css::uno::Reference< css::chart::XDiagram > const & xDiagram, ContextType eContextType ); virtual ~SchXMLStockContext() override; diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index b046243897a9..5bcdbe688295 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -262,7 +262,7 @@ XMLPropStyleContext* lcl_GetStylePropContext( SchXMLSeries2Context::SchXMLSeries2Context( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const OUString& rLocalName, + SvXMLImport& rImport, const Reference< chart2::XChartDocument > & xNewDoc, std::vector< SchXMLAxis >& rAxes, ::std::vector< DataRowPointStyle >& rStyleVector, @@ -274,7 +274,7 @@ SchXMLSeries2Context::SchXMLSeries2Context( tSchXMLLSequencesPerIndex & rLSequencesPerIndex, bool& rGlobalChartTypeUsedBySeries, const awt::Size & rChartSize ) : - SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), + SvXMLImportContext( rImport ), mrImportHelper( rImpHelper ), mxNewDoc( xNewDoc ), mrAxes( rAxes ), diff --git a/xmloff/source/chart/SchXMLSeries2Context.hxx b/xmloff/source/chart/SchXMLSeries2Context.hxx index 22fb350b777c..b3ef3106cae5 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.hxx +++ b/xmloff/source/chart/SchXMLSeries2Context.hxx @@ -71,7 +71,7 @@ private: public: SchXMLSeries2Context( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const OUString& rLocalName, + SvXMLImport& rImport, const css::uno::Reference< css::chart2::XChartDocument > & xNewDoc, std::vector< SchXMLAxis >& rAxes, ::std::vector< DataRowPointStyle >& rStyleVector, diff --git a/xmloff/source/draw/ximp3dscene.cxx b/xmloff/source/draw/ximp3dscene.cxx index 9734e699cea1..58a55c578101 100644 --- a/xmloff/source/draw/ximp3dscene.cxx +++ b/xmloff/source/draw/ximp3dscene.cxx @@ -39,33 +39,25 @@ using namespace ::xmloff::token; SdXML3DLightContext::SdXML3DLightContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList) -: SvXMLImportContext( rImport, nPrfx, rLName), + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) +: SvXMLImportContext( rImport ), maDiffuseColor(0x00000000), maDirection(0.0, 0.0, 1.0), mbEnabled(false), mbSpecular(false) { // read attributes for the 3DScene - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); - const SvXMLTokenMap& rAttrTokenMap = GetImport().GetShapeImport()->Get3DLightAttrTokenMap(); - - switch(rAttrTokenMap.Get(nPrefix, aLocalName)) + OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - case XML_TOK_3DLIGHT_DIFFUSE_COLOR: + case XML_ELEMENT(DR3D, XML_DIFFUSE_COLOR): { ::sax::Converter::convertColor(maDiffuseColor, sValue); break; } - case XML_TOK_3DLIGHT_DIRECTION: + case XML_ELEMENT(DR3D, XML_DIRECTION): { ::basegfx::B3DVector aVal; SvXMLUnitConverter::convertB3DVector(aVal, sValue); @@ -79,16 +71,18 @@ SdXML3DLightContext::SdXML3DLightContext( } break; } - case XML_TOK_3DLIGHT_ENABLED: + case XML_ELEMENT(DR3D, XML_ENABLED): { (void)::sax::Converter::convertBool(mbEnabled, sValue); break; } - case XML_TOK_3DLIGHT_SPECULAR: + case XML_ELEMENT(DR3D, XML_SPECULAR): { (void)::sax::Converter::convertBool(mbSpecular, sValue); break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } } @@ -169,6 +163,30 @@ void SdXML3DSceneShapeContext::endFastElement(sal_Int32 nElement) SdXMLShapeContext::endFastElement(nElement); } +css::uno::Reference< css::xml::sax::XFastContextHandler > SdXML3DSceneShapeContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) +{ + SvXMLImportContextRef xContext; + switch (nElement) + { + // #i68101# + case XML_ELEMENT(SVG, XML_TITLE): + case XML_ELEMENT(SVG_COMPAT, XML_TITLE): + case XML_ELEMENT(SVG, XML_DESC): + case XML_ELEMENT(SVG_COMPAT, XML_DESC): + break; + case XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS): + break; + // look for local light context first + case XML_ELEMENT(DR3D, XML_LIGHT): + // dr3d:light inside dr3d:scene context + xContext = create3DLightContext( xAttrList ); + break; + } + return xContext.get(); +} + SvXMLImportContextRef SdXML3DSceneShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList>& xAttrList ) @@ -185,12 +203,6 @@ SvXMLImportContextRef SdXML3DSceneShapeContext::CreateChildContext( sal_uInt16 n { xContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape ); } - // look for local light context first - else if(nPrefix == XML_NAMESPACE_DR3D && IsXMLToken( rLocalName, XML_LIGHT ) ) - { - // dr3d:light inside dr3d:scene context - xContext = create3DLightContext( nPrefix, rLocalName, xAttrList ); - } // call GroupChildContext function at common ShapeImport if (!xContext) @@ -222,9 +234,9 @@ SdXML3DSceneAttributesHelper::SdXML3DSceneAttributesHelper( SvXMLImport& rImport } /** creates a 3d light context and adds it to the internal list for later processing */ -SvXMLImportContext * SdXML3DSceneAttributesHelper::create3DLightContext( sal_uInt16 nPrfx, const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList) +SvXMLImportContext * SdXML3DSceneAttributesHelper::create3DLightContext( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) { - const rtl::Reference<SdXML3DLightContext> xContext{new SdXML3DLightContext(mrImport, nPrfx, rLName, xAttrList)}; + const rtl::Reference<SdXML3DLightContext> xContext{new SdXML3DLightContext(mrImport, xAttrList)}; // remember SdXML3DLightContext for later evaluation maList.push_back(xContext); diff --git a/xmloff/source/draw/ximp3dscene.hxx b/xmloff/source/draw/ximp3dscene.hxx index f613442d257c..d8eb32a3e4a4 100644 --- a/xmloff/source/draw/ximp3dscene.hxx +++ b/xmloff/source/draw/ximp3dscene.hxx @@ -45,6 +45,9 @@ public: virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList>& 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, |