summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-21 10:07:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-21 19:03:51 +0200
commit6e64e2e2d23e8a776f6e7fe53f45f18145f80bda (patch)
tree0c2cc65283781609a1b48ba926d4436f85184b27
parent6dcdf182e773d11f959c5dca1c5a6b9d8205bdee (diff)
use fastparser in XMLLineNumberingImportContext
Change-Id: Ib6e590eccffea94dccc4b943d3cf92124882c064 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101170 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--xmloff/inc/XMLLineNumberingImportContext.hxx11
-rw-r--r--xmloff/source/style/xmlstyle.cxx10
-rw-r--r--xmloff/source/text/XMLLineNumberingImportContext.cxx24
-rw-r--r--xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx26
-rw-r--r--xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx11
5 files changed, 31 insertions, 51 deletions
diff --git a/xmloff/inc/XMLLineNumberingImportContext.hxx b/xmloff/inc/XMLLineNumberingImportContext.hxx
index 90f7831b672e..852f3076d574 100644
--- a/xmloff/inc/XMLLineNumberingImportContext.hxx
+++ b/xmloff/inc/XMLLineNumberingImportContext.hxx
@@ -68,9 +68,8 @@ public:
XMLLineNumberingImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList);
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList);
virtual ~XMLLineNumberingImportContext() override;
@@ -86,10 +85,8 @@ private:
virtual void CreateAndInsert(bool bOverwrite) 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;
};
#endif
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 2a98fbfaf509..a4e3d158ccea 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -424,6 +424,11 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext(
pStyle = new XMLFootnoteConfigurationImportContext(
GetImport(), nElement, xAttrList);
break;
+ case XML_ELEMENT(TEXT, XML_LINENUMBERING_CONFIGURATION):
+ pStyle = new XMLLineNumberingImportContext(
+ GetImport(), nElement, xAttrList);
+ break;
+
}
return pStyle;
@@ -486,11 +491,6 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPr
rLocalName, xAttrList, true );
break;
- case XML_TOK_TEXT_LINENUMBERING_CONFIG:
- pStyle = new XMLLineNumberingImportContext(
- GetImport(), p_nPrefix, rLocalName, xAttrList);
- break;
-
// FillStyles
diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx
index 3c272c25214a..09de0382b780 100644
--- a/xmloff/source/text/XMLLineNumberingImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx
@@ -40,6 +40,7 @@ using namespace ::xmloff::token;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
using ::com::sun::star::text::XLineNumberingProperties;
@@ -57,10 +58,9 @@ const OUStringLiteral gsSeparatorInterval("SeparatorInterval");
XMLLineNumberingImportContext::XMLLineNumberingImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
- const Reference<XAttributeList> & xAttrList)
-: SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList, XmlStyleFamily::TEXT_LINENUMBERINGCONFIG)
+ sal_Int32 nElement,
+ const Reference<XFastAttributeList> & xAttrList)
+: SvXMLStyleContext(rImport, nElement, xAttrList, XmlStyleFamily::TEXT_LINENUMBERINGCONFIG)
, sNumFormat(GetXMLToken(XML_1))
, sNumLetterSync(GetXMLToken(XML_FALSE))
, nOffset(-1)
@@ -244,18 +244,12 @@ void XMLLineNumberingImportContext::CreateAndInsert(bool)
xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType));
}
-SvXMLImportContextRef XMLLineNumberingImportContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList> & /*xAttrList*/ )
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLLineNumberingImportContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
{
- if ( (nPrefix == XML_NAMESPACE_TEXT) &&
- IsXMLToken(rLocalName, XML_LINENUMBERING_SEPARATOR) )
- {
- return new XMLLineNumberingSeparatorImportContext(GetImport(),
- nPrefix, rLocalName,
- *this);
- }
+ if ( nElement == XML_ELEMENT(TEXT, XML_LINENUMBERING_SEPARATOR) )
+ return new XMLLineNumberingSeparatorImportContext(GetImport(), *this);
return nullptr;
}
diff --git a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
index c0d90be3983d..8d6269235ed6 100644
--- a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
+++ b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.cxx
@@ -37,10 +37,8 @@ using ::xmloff::token::XML_INCREMENT;
XMLLineNumberingSeparatorImportContext::XMLLineNumberingSeparatorImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
XMLLineNumberingImportContext& rLineNumbering) :
- SvXMLImportContext(rImport, nPrfx, rLocalName),
+ SvXMLImportContext(rImport),
rLineNumberingContext(rLineNumbering)
{
}
@@ -49,22 +47,16 @@ XMLLineNumberingSeparatorImportContext::~XMLLineNumberingSeparatorImportContext(
{
}
-void XMLLineNumberingSeparatorImportContext::StartElement(
- const Reference<XAttributeList> & xAttrList)
+void XMLLineNumberingSeparatorImportContext::startFastElement(
+ sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- sal_Int16 nLength = xAttrList->getLength();
- for(sal_Int16 i=0; i<nLength; i++)
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
-
- if ( (nPrefix == XML_NAMESPACE_TEXT) &&
- IsXMLToken(sLocalName, XML_INCREMENT) )
+ if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_INCREMENT) )
{
sal_Int32 nTmp;
- if (::sax::Converter::convertNumber(
- nTmp, xAttrList->getValueByIndex(i), 0))
+ if (::sax::Converter::convertNumber(nTmp, aIter.toString(), 0))
{
rLineNumberingContext.SetSeparatorIncrement(static_cast<sal_Int16>(nTmp));
}
@@ -74,13 +66,13 @@ void XMLLineNumberingSeparatorImportContext::StartElement(
}
}
-void XMLLineNumberingSeparatorImportContext::Characters(
+void XMLLineNumberingSeparatorImportContext::characters(
const OUString& rChars )
{
sSeparatorBuf.append(rChars);
}
-void XMLLineNumberingSeparatorImportContext::EndElement()
+void XMLLineNumberingSeparatorImportContext::endFastElement(sal_Int32 )
{
rLineNumberingContext.SetSeparatorText(sSeparatorBuf.makeStringAndClear());
}
diff --git a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
index a42b28fe4e5b..c3ec804d6a34 100644
--- a/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
+++ b/xmloff/source/text/XMLLineNumberingSeparatorImportContext.hxx
@@ -43,21 +43,18 @@ public:
XMLLineNumberingSeparatorImportContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
XMLLineNumberingImportContext& rLineNumbering);
virtual ~XMLLineNumberingSeparatorImportContext() override;
protected:
- virtual void StartElement(
- const css::uno::Reference<
- css::xml::sax::XAttributeList> & xAttrList) override;
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
- virtual void Characters( const OUString& rChars ) override;
+ virtual void SAL_CALL characters( const OUString& rChars ) override;
- virtual void EndElement() override;
+ virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
};
#endif