[Libreoffice-commits] core.git: include/xmloff sc/source xmloff/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 23 10:15:14 UTC 2020
include/xmloff/XMLTextMasterPageContext.hxx | 8 ++-
include/xmloff/XMLTextMasterStylesContext.hxx | 5 --
sc/source/filter/xml/xmlstyli.cxx | 16 ++----
sc/source/filter/xml/xmlstyli.hxx | 10 +---
xmloff/source/text/XMLTextMasterPageContext.cxx | 54 +++++++++-------------
xmloff/source/text/XMLTextMasterStylesContext.cxx | 12 ++--
6 files changed, 47 insertions(+), 58 deletions(-)
New commits:
commit fecf3807f0229450617f35b36e14db14c7c17c87
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 21 15:52:21 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 23 12:14:28 2020 +0200
use fastparser in XMLTextMasterStylesContext
Change-Id: I2eaae244264ca9ab726d8e69a3e53a76481b5a36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101173
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/xmloff/XMLTextMasterPageContext.hxx b/include/xmloff/XMLTextMasterPageContext.hxx
index 53091947bf61..ad58d69eb269 100644
--- a/include/xmloff/XMLTextMasterPageContext.hxx
+++ b/include/xmloff/XMLTextMasterPageContext.hxx
@@ -52,12 +52,14 @@ protected:
public:
- XMLTextMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
+ XMLTextMasterPageContext( SvXMLImport& rImport, sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
bool bOverwrite );
virtual ~XMLTextMasterPageContext() override;
+ virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
+
virtual SvXMLImportContextRef CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
diff --git a/include/xmloff/XMLTextMasterStylesContext.hxx b/include/xmloff/XMLTextMasterStylesContext.hxx
index 45b253759fde..423092f0cf17 100644
--- a/include/xmloff/XMLTextMasterStylesContext.hxx
+++ b/include/xmloff/XMLTextMasterStylesContext.hxx
@@ -28,9 +28,8 @@ class XMLOFF_DLLPUBLIC XMLTextMasterStylesContext : 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,
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index c000fc2ab0fd..d9dd0761e287 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -916,17 +916,15 @@ ScXMLMasterStylesContext::~ScXMLMasterStylesContext()
}
SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< XAttributeList > & xAttrList )
+ sal_Int32 nElement,
+ const uno::Reference< XFastAttributeList > & xAttrList )
{
SvXMLStyleContext *pContext(nullptr);
- if( (XML_NAMESPACE_STYLE == nPrefix) &&
- IsXMLToken(rLocalName, XML_MASTER_PAGE) &&
+ if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE) &&
InsertStyleFamily( XmlStyleFamily::MASTER_PAGE ) )
pContext = new ScMasterPageContext(
- GetImport(), nPrefix, rLocalName, xAttrList,
+ GetImport(), nElement, xAttrList,
!GetImport().GetTextImport()->IsInsertMode() );
// any other style will be ignored here!
@@ -950,10 +948,10 @@ void ScXMLMasterStylesContext::endFastElement(sal_Int32 )
ScMasterPageContext::ScMasterPageContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const uno::Reference< XAttributeList > & xAttrList,
+ sal_Int32 nElement,
+ const uno::Reference< XFastAttributeList > & xAttrList,
bool bOverwrite ) :
- XMLTextMasterPageContext( rImport, nPrfx, rLName, xAttrList, bOverwrite ),
+ XMLTextMasterPageContext( rImport, nElement, xAttrList, bOverwrite ),
bContainsRightHeader(false),
bContainsRightFooter(false)
{
diff --git a/sc/source/filter/xml/xmlstyli.hxx b/sc/source/filter/xml/xmlstyli.hxx
index 221ef801a8e9..e9658cc7c614 100644
--- a/sc/source/filter/xml/xmlstyli.hxx
+++ b/sc/source/filter/xml/xmlstyli.hxx
@@ -170,9 +170,8 @@ class ScXMLMasterStylesContext : 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,
@@ -198,9 +197,8 @@ class ScMasterPageContext : public XMLTextMasterPageContext
public:
- ScMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
- const OUString& rLName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
+ ScMasterPageContext( SvXMLImport& rImport, sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
bool bOverwrite );
virtual ~ScMasterPageContext() override;
diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx
index 1b70be760b25..c5b98ea4cc34 100644
--- a/xmloff/source/text/XMLTextMasterPageContext.cxx
+++ b/xmloff/source/text/XMLTextMasterPageContext.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <o3tl/any.hxx>
+#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <xmloff/namespacemap.hxx>
#include <xmloff/xmlnamespace.hxx>
@@ -67,10 +68,10 @@ Reference < XStyle > XMLTextMasterPageContext::Create()
const OUStringLiteral gsFollowStyle( "FollowStyle" );
XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const Reference< XAttributeList > & xAttrList,
+ sal_Int32 nElement,
+ const Reference< XFastAttributeList > & xAttrList,
bool bOverwrite )
-: SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, XmlStyleFamily::MASTER_PAGE )
+: SvXMLStyleContext( rImport, nElement, xAttrList, XmlStyleFamily::MASTER_PAGE )
, bInsertHeader( false )
, bInsertFooter( false )
, bInsertHeaderLeft( false )
@@ -81,35 +82,28 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport,
, bFooterInserted( false )
{
OUString sName, sDisplayName;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for( sal_Int16 i=0; i < nAttrCount; i++ )
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
- const OUString& rAttrName = xAttrList->getNameByIndex( i );
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
- if( XML_NAMESPACE_STYLE == nPrefix )
+ const OUString aValue = aIter.toString();
+ switch (aIter.getToken())
{
- if( IsXMLToken( aLocalName, XML_NAME ) )
- {
- sName = xAttrList->getValueByIndex( i );
- }
- else if( IsXMLToken( aLocalName, XML_DISPLAY_NAME ) )
- {
- sDisplayName = xAttrList->getValueByIndex( i );
- }
- else if( IsXMLToken( aLocalName, XML_NEXT_STYLE_NAME ) )
- {
- sFollow = xAttrList->getValueByIndex( i );
- }
- else if( IsXMLToken( aLocalName, XML_PAGE_LAYOUT_NAME ) )
- {
- sPageMasterName = xAttrList->getValueByIndex( i );
- }
- }
- else if (XML_NAMESPACE_DRAW == nPrefix
- && IsXMLToken(aLocalName, XML_STYLE_NAME))
- {
- m_sDrawingPageStyle = xAttrList->getValueByIndex(i);
+ case XML_ELEMENT(STYLE, XML_NAME):
+ sName = aValue;
+ break;
+ case XML_ELEMENT(STYLE, XML_DISPLAY_NAME):
+ sDisplayName = aValue;
+ break;
+ case XML_ELEMENT(STYLE, XML_NEXT_STYLE_NAME):
+ sFollow = aValue;
+ break;
+ case XML_ELEMENT(STYLE, XML_PAGE_LAYOUT_NAME):
+ sPageMasterName = aValue;
+ break;
+ case XML_ELEMENT(DRAW, XML_STYLE_NAME):
+ m_sDrawingPageStyle = aValue;
+ break;
+ default:
+ SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
}
}
diff --git a/xmloff/source/text/XMLTextMasterStylesContext.cxx b/xmloff/source/text/XMLTextMasterStylesContext.cxx
index 388f2a019a54..46e7e83522e2 100644
--- a/xmloff/source/text/XMLTextMasterStylesContext.cxx
+++ b/xmloff/source/text/XMLTextMasterStylesContext.cxx
@@ -47,18 +47,16 @@ XMLTextMasterStylesContext::~XMLTextMasterStylesContext()
}
SvXMLStyleContext *XMLTextMasterStylesContext::CreateStyleChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference< XAttributeList > & xAttrList )
+ sal_Int32 nElement,
+ const Reference< XFastAttributeList > & xAttrList )
{
SvXMLStyleContext *pContext = nullptr;
- if( XML_NAMESPACE_STYLE == nPrefix &&
- IsXMLToken( rLocalName, XML_MASTER_PAGE ) &&
+ if( nElement == XML_ELEMENT(STYLE, XML_MASTER_PAGE) &&
InsertStyleFamily( XmlStyleFamily::MASTER_PAGE ) )
pContext = new XMLTextMasterPageContext(
- GetImport(), nPrefix, rLocalName,
- xAttrList,
+ GetImport(), nElement,
+ xAttrList,
!GetImport().GetTextImport()->IsInsertMode() );
// any other style will be ignored here!
More information about the Libreoffice-commits
mailing list