[Libreoffice-commits] core.git: include/xmloff sw/source xmloff/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 23 14:11:28 UTC 2020
include/xmloff/table/XMLTableImport.hxx | 2 -
sw/source/filter/xml/xmlfmt.cxx | 17 ++++----
xmloff/source/draw/ximpstyl.cxx | 21 ++++++++--
xmloff/source/draw/ximpstyl.hxx | 3 +
xmloff/source/table/XMLTableImport.cxx | 64 +++++++++++++++++---------------
5 files changed, 63 insertions(+), 44 deletions(-)
New commits:
commit 1916366ff4d7f581ea2116e7411bab7f594425d4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 21 16:45:07 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 23 16:10:49 2020 +0200
use fastparser in CreateTableTemplateContext
Change-Id: Ic9274c30bfceba7d85d7c80ad259b3eab93ff618
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101175
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/xmloff/table/XMLTableImport.hxx b/include/xmloff/table/XMLTableImport.hxx
index f1d911616118..cb6e2da7b48c 100644
--- a/include/xmloff/table/XMLTableImport.hxx
+++ b/include/xmloff/table/XMLTableImport.hxx
@@ -49,7 +49,7 @@ public:
SvXMLImportContext* CreateTableContext( sal_uInt16 nPrfx, const OUString& rLName,
css::uno::Reference< css::table::XColumnRowRange > const & xColumnRowRange );
- SvXMLStyleContext* CreateTableTemplateContext( sal_uInt16 nPrfx, const OUString& rLName, const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
+ SvXMLStyleContext* CreateTableTemplateContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
const rtl::Reference< SvXMLImportPropertyMapper >& GetCellImportPropertySetMapper() const { return mxCellImportPropertySetMapper; }
const rtl::Reference< SvXMLImportPropertyMapper >& GetRowImportPropertySetMapper() const { return mxRowImportPropertySetMapper; }
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 49e1224cdb83..f07ec1c89cf7 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -751,9 +751,8 @@ class SwXMLStylesContext_Impl : public SvXMLStylesContext
protected:
using SvXMLStylesContext::CreateStyleChildContext;
- virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+ virtual SvXMLStyleContext *CreateStyleChildContext( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
sal_uInt16 nPrefix, const OUString& rLocalName,
@@ -784,19 +783,19 @@ public:
}
-SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleChildContext( sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList )
+SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList )
{
SvXMLStyleContext* pContext = nullptr;
- if(nPrefix == XML_NAMESPACE_TABLE && IsXMLToken(rLocalName, XML_TABLE_TEMPLATE))
+ if(nElement == XML_ELEMENT(TABLE, XML_TABLE_TEMPLATE))
{
rtl::Reference<XMLTableImport> xTableImport = GetImport().GetShapeImport()->GetShapeTableImport();
- pContext = xTableImport->CreateTableTemplateContext(nPrefix, rLocalName, xAttrList);
+ pContext = xTableImport->CreateTableTemplateContext(nElement, xAttrList);
}
if (!pContext)
- pContext = SvXMLStylesContext::CreateStyleChildContext(nPrefix, rLocalName, xAttrList);
+ pContext = SvXMLStylesContext::CreateStyleChildContext(nElement, xAttrList);
return pContext;
}
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index aafeade525b7..22a77b320d78 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -903,6 +903,22 @@ SdXMLStylesContext::SdXMLStylesContext(
mpNumFmtHelper = std::make_unique<SvXMLNumFmtHelper>( mpNumFormatter.get(), xContext );
}
+SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
+ sal_Int32 nElement,
+ const uno::Reference< xml::sax::XFastAttributeList >& xAttrList)
+{
+ SvXMLStyleContext* pContext = nullptr;
+ if( nElement == XML_ELEMENT(TABLE, XML_TABLE_TEMPLATE) )
+ {
+ pContext = GetImport().GetShapeImport()->GetShapeTableImport()->CreateTableTemplateContext(nElement, xAttrList );
+ if (pContext)
+ return pContext;
+ }
+
+ // call base class
+ return SvXMLStylesContext::CreateStyleChildContext(nElement, xAttrList);
+}
+
SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -960,11 +976,6 @@ SvXMLStyleContext* SdXMLStylesContext::CreateStyleChildContext(
}
}
- if(!pContext && (nPrefix == XML_NAMESPACE_TABLE) && IsXMLToken( rLocalName, XML_TABLE_TEMPLATE ) )
- {
- pContext = GetImport().GetShapeImport()->GetShapeTableImport()->CreateTableTemplateContext(nPrefix, rLocalName, xAttrList );
- }
-
// call base class
if(!pContext)
pContext = SvXMLStylesContext::CreateStyleChildContext(nPrefix, rLocalName, xAttrList);
diff --git a/xmloff/source/draw/ximpstyl.hxx b/xmloff/source/draw/ximpstyl.hxx
index d3922a8eb326..c85fb2880624 100644
--- a/xmloff/source/draw/ximpstyl.hxx
+++ b/xmloff/source/draw/ximpstyl.hxx
@@ -192,6 +192,9 @@ protected:
sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList) override;
+ virtual SvXMLStyleContext* CreateStyleChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList) override;
virtual SvXMLStyleContext *CreateStyleStyleChildContext(
XmlStyleFamily nFamily,
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 4e5ab54c486e..d5fdf6772545 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -157,11 +157,13 @@ public:
class XMLTableTemplateContext : public SvXMLStyleContext
{
public:
- XMLTableTemplateContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList );
+ XMLTableTemplateContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList );
- virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) override;
+ // Create child element.
+ 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 EndElement() override;
+ virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
virtual void CreateAndInsert( bool bOverwrite ) override;
protected:
@@ -234,9 +236,9 @@ SvXMLImportContext* XMLTableImport::CreateTableContext( sal_uInt16 nPrfx, const
return new XMLTableImportContext( xThis, nPrfx, rLName, xColumnRowRange );
}
-SvXMLStyleContext* XMLTableImport::CreateTableTemplateContext( sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList )
+SvXMLStyleContext* XMLTableImport::CreateTableTemplateContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList )
{
- return new XMLTableTemplateContext( mrImport, nPrfx, rLName, xAttrList );
+ return new XMLTableTemplateContext( mrImport, nElement, xAttrList );
}
void XMLTableImport::addTableTemplate( const OUString& rsStyleName, XMLTableTemplate& xTableTemplate )
@@ -745,8 +747,8 @@ void XMLCellImportContext::EndElement()
}
-XMLTableTemplateContext::XMLTableTemplateContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList )
-: SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, XmlStyleFamily::TABLE_TEMPLATE_ID, false )
+XMLTableTemplateContext::XMLTableTemplateContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList )
+: SvXMLStyleContext( rImport, nElement, xAttrList, XmlStyleFamily::TABLE_TEMPLATE_ID, false )
{
}
@@ -762,7 +764,7 @@ void XMLTableTemplateContext::SetAttribute( sal_uInt16 nPrefixKey,
}
}
-void XMLTableTemplateContext::EndElement()
+void XMLTableTemplateContext::endFastElement(sal_Int32 )
{
rtl::Reference< XMLTableImport > xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
if( xTableImport.is() )
@@ -776,47 +778,51 @@ void XMLTableTemplateContext::CreateAndInsert(bool bOverwrite)
xTableImport->insertTabletemplate(msTemplateStyleName, bOverwrite);
}
-SvXMLImportContextRef XMLTableTemplateContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTableTemplateContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- if( nPrefix == XML_NAMESPACE_TABLE )
+ if( IsTokenInNamespace(nElement, XML_NAMESPACE_TABLE) )
{
const TableStyleElement* pElements = getTableStyleMap();
- while( (pElements->meElement != XML_TOKEN_END) && !IsXMLToken( rLocalName, pElements->meElement ) )
+ sal_Int32 nLocalName = nElement & TOKEN_MASK;
+ while( (pElements->meElement != XML_TOKEN_END) && pElements->meElement != nLocalName)
pElements++;
if( pElements->meElement != XML_TOKEN_END )
{
- 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;
- sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( i ), &sAttrName );
- if( (nAttrPrefix == XML_NAMESPACE_TEXT || nAttrPrefix == XML_NAMESPACE_TABLE) &&
- IsXMLToken( sAttrName, XML_STYLE_NAME ) )
+ switch (aIter.getToken())
{
- maTableTemplate[pElements->msStyleName] = xAttrList->getValueByIndex( i );
- break;
+ case XML_ELEMENT(TEXT, XML_STYLE_NAME):
+ case XML_ELEMENT(TABLE, XML_STYLE_NAME):
+ maTableTemplate[pElements->msStyleName] = aIter.toString();
+ break;
+ default:
+ SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
}
}
}
- } else if (nPrefix == XML_NAMESPACE_LO_EXT) // Writer specific cell styles
+ } else if (IsTokenInNamespace(nElement, XML_NAMESPACE_LO_EXT)) // Writer specific cell styles
{
const TableStyleElement* pElements = getWriterSpecificTableStyleMap();
- while ((pElements->meElement != XML_TOKEN_END) && !IsXMLToken(rLocalName, pElements->meElement ))
+ sal_Int32 nLocalName = nElement & TOKEN_MASK;
+ while( (pElements->meElement != XML_TOKEN_END) && pElements->meElement != nLocalName)
pElements++;
if (pElements->meElement != XML_TOKEN_END)
{
- 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;
- sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(xAttrList->getNameByIndex( i ), &sAttrName);
- if( (nAttrPrefix == XML_NAMESPACE_TEXT || nAttrPrefix == XML_NAMESPACE_TABLE) &&
- IsXMLToken( sAttrName, XML_STYLE_NAME ) )
+ switch (aIter.getToken())
{
- maTableTemplate[pElements->msStyleName] = xAttrList->getValueByIndex(i);
- break;
+ case XML_ELEMENT(TEXT, XML_STYLE_NAME):
+ case XML_ELEMENT(TABLE, XML_STYLE_NAME):
+ maTableTemplate[pElements->msStyleName] = aIter.toString();
+ break;
+ default:
+ SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
}
}
}
More information about the Libreoffice-commits
mailing list