[Libreoffice-commits] core.git: xmloff/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Nov 15 18:00:02 UTC 2020
xmloff/source/chart/SchXMLAxisContext.cxx | 101 +++++++----------------------
xmloff/source/chart/SchXMLAxisContext.hxx | 7 --
xmloff/source/chart/SchXMLChartContext.cxx | 7 --
xmloff/source/chart/SchXMLChartContext.hxx | 2
4 files changed, 34 insertions(+), 83 deletions(-)
New commits:
commit 478ab71e97bc567ad2ed8a7b7d00ffd41d7c203b
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Nov 15 12:05:26 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Nov 15 18:59:23 2020 +0100
fastparser in SchXMLAxisContext
Change-Id: Idcc6426707f8f2019b4af0a5ef5979aa60944d11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105893
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx
index 511c2c776546..e7e059af7a7d 100644
--- a/xmloff/source/chart/SchXMLAxisContext.cxx
+++ b/xmloff/source/chart/SchXMLAxisContext.cxx
@@ -80,8 +80,6 @@ private:
public:
SchXMLCategoriesContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
OUString& rAddress );
virtual void StartElement( const Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
};
@@ -90,7 +88,6 @@ class DateScaleContext : public SvXMLImportContext
{
public:
DateScaleContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix, const OUString& rLocalName,
const Reference< beans::XPropertySet >& rAxisProps );
virtual void StartElement( const Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
@@ -611,92 +608,51 @@ void SchXMLAxisContext::SetAxisTitle()
}
}
-namespace
-{
-enum AxisChildTokens
-{
- XML_TOK_AXIS_TITLE,
- XML_TOK_AXIS_CATEGORIES,
- XML_TOK_AXIS_GRID,
- XML_TOK_AXIS_DATE_SCALE,
- XML_TOK_AXIS_DATE_SCALE_EXT
-};
-
-const SvXMLTokenMapEntry aAxisChildTokenMap[] =
+css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLAxisContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE },
- { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES },
- { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID },
- { XML_NAMESPACE_CHART, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE },
- { XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE_EXT },
- XML_TOKEN_MAP_END
-};
-
-class AxisChildTokenMap : public SvXMLTokenMap
-{
-public:
- AxisChildTokenMap(): SvXMLTokenMap( aAxisChildTokenMap ) {}
- virtual ~AxisChildTokenMap() {}
-};
-
-//a AxisChildTokenMap Singleton
-struct theAxisChildTokenMap : public rtl::Static< AxisChildTokenMap, theAxisChildTokenMap > {};
-}
-
-SvXMLImportContextRef SchXMLAxisContext::CreateChildContext(
- sal_uInt16 p_nPrefix,
- const OUString& rLocalName,
- const Reference< xml::sax::XAttributeList >& xAttrList )
-{
- SvXMLImportContext* pContext = nullptr;
- const SvXMLTokenMap& rTokenMap = theAxisChildTokenMap::get();
-
- switch( rTokenMap.Get( p_nPrefix, rLocalName ))
+ switch( nElement )
{
- case XML_TOK_AXIS_TITLE:
+ case XML_ELEMENT(CHART, XML_TITLE):
{
Reference< drawing::XShape > xTitleShape = getTitleShape();
- pContext = new SchXMLTitleContext( m_rImportHelper, GetImport(), rLocalName,
+ return new SchXMLTitleContext( m_rImportHelper, GetImport(),
m_aCurrentAxis.aTitle,
xTitleShape );
}
break;
- case XML_TOK_AXIS_CATEGORIES:
- pContext = new SchXMLCategoriesContext( GetImport(),
- p_nPrefix, rLocalName,
- m_rCategoriesAddress );
+ case XML_ELEMENT(CHART, XML_CATEGORIES):
m_aCurrentAxis.bHasCategories = true;
+ return new SchXMLCategoriesContext( GetImport(),
+ m_rCategoriesAddress );
break;
- case XML_TOK_AXIS_DATE_SCALE:
- case XML_TOK_AXIS_DATE_SCALE_EXT:
- pContext = new DateScaleContext( GetImport(),
- p_nPrefix, rLocalName, m_xAxisProps );
+ case XML_ELEMENT(CHART, XML_DATE_SCALE):
+ case XML_ELEMENT(CHART_EXT, XML_DATE_SCALE):
m_bDateScaleImported = true;
+ return new DateScaleContext( GetImport(), m_xAxisProps );
break;
- case XML_TOK_AXIS_GRID:
+ case XML_ELEMENT(CHART, XML_GRID):
{
- sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
bool bIsMajor = true; // default value for class is "major"
OUString sAutoStyleName;
- 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 );
-
- if( nPrefix == XML_NAMESPACE_CHART )
+ switch (aIter.getToken())
{
- if( IsXMLToken( aLocalName, XML_CLASS ) )
- {
- if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) )
+ case XML_ELEMENT(CHART, XML_CLASS):
+ if( IsXMLToken( aIter.toString(), XML_MINOR ) )
bIsMajor = false;
- }
- else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
- sAutoStyleName = xAttrList->getValueByIndex( i );
+ break;
+ case XML_ELEMENT(CHART, XML_STYLE_NAME):
+ sAutoStyleName = aIter.toString();
+ break;
+ default:
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
}
@@ -707,10 +663,11 @@ SvXMLImportContextRef SchXMLAxisContext::CreateChildContext(
break;
default:
+ XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
break;
}
- return pContext;
+ return nullptr;
}
void SchXMLAxisContext::endFastElement(sal_Int32 )
@@ -868,10 +825,8 @@ void SchXMLAxisContext::CorrectAxisPositions( const Reference< chart2::XChartDoc
SchXMLCategoriesContext::SchXMLCategoriesContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
OUString& rAddress ) :
- SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ SvXMLImportContext( rImport ),
mrAddress( rAddress )
{
}
@@ -896,10 +851,8 @@ void SchXMLCategoriesContext::StartElement( const Reference< xml::sax::XAttribut
DateScaleContext::DateScaleContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference< beans::XPropertySet >& rAxisProps ) :
- SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ SvXMLImportContext( rImport ),
m_xAxisProps( rAxisProps )
{
}
diff --git a/xmloff/source/chart/SchXMLAxisContext.hxx b/xmloff/source/chart/SchXMLAxisContext.hxx
index ae7d7d54049d..5706c564f1f3 100644
--- a/xmloff/source/chart/SchXMLAxisContext.hxx
+++ b/xmloff/source/chart/SchXMLAxisContext.hxx
@@ -43,10 +43,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 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;
static void CorrectAxisPositions( const css::uno::Reference< css::chart2::XChartDocument >& xNewDoc,
const OUString& rChartTypeServiceName,
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 2a78204499ad..b8ec262621f4 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -1052,7 +1052,7 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
}
uno::Reference< drawing::XShape > xTitleShape = xDoc->getTitle();
pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
- rLocalName, maMainTitle, xTitleShape );
+ maMainTitle, xTitleShape );
}
break;
@@ -1065,7 +1065,7 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext(
}
uno::Reference< drawing::XShape > xTitleShape = xDoc->getSubTitle();
pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
- rLocalName, maSubTitle, xTitleShape );
+ maSubTitle, xTitleShape );
}
break;
@@ -1162,10 +1162,9 @@ void SchXMLChartContext::InitChart(
}
SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
- const OUString& rLocalName,
OUString& rTitle,
uno::Reference< drawing::XShape > const & xTitleShape ) :
- SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ SvXMLImportContext( rImport ),
mrImportHelper( rImpHelper ),
mrTitle( rTitle ),
mxTitleShape( xTitleShape )
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index 830966fb2e95..5081decd2412 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -134,7 +134,7 @@ private:
public:
SchXMLTitleContext( SchXMLImportHelper& rImpHelper,
- SvXMLImport& rImport, const OUString& rLocalName,
+ SvXMLImport& rImport,
OUString& rTitle,
css::uno::Reference< css::drawing::XShape > const & xTitleShape );
virtual ~SchXMLTitleContext() override;
More information about the Libreoffice-commits
mailing list