summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-21 09:32:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-21 16:01:41 +0200
commitee9f2f58a5a54f994ef055edf0dd675f81bbd8ae (patch)
treefaba2c96136afd9bb08493b56a3818cea1290dad /xmloff
parent7fef4817e96ca3e804e4a2c7d65afaf4c522f97f (diff)
use fast-parser in XMLIndexBibliographyConfigurationContext
Change-Id: If83d582978803c0e79bf59f4e0576410a1849289 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101133 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx11
-rw-r--r--xmloff/source/style/xmlstyle.cxx15
-rw-r--r--xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx47
3 files changed, 34 insertions, 39 deletions
diff --git a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
index e2f67f9ad495..4efc71336502 100644
--- a/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
+++ b/xmloff/inc/XMLIndexBibliographyConfigurationContext.hxx
@@ -56,9 +56,8 @@ public:
XMLIndexBibliographyConfigurationContext(
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 ~XMLIndexBibliographyConfigurationContext() override;
@@ -70,10 +69,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 03ac41d85077..d91180681e89 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -410,6 +410,16 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext(
{
pStyle = GetImport().GetDataStylesImport()->CreateChildContext(GetImport(), nElement,
xAttrList, *this);
+ if (pStyle)
+ return pStyle;
+ }
+
+ switch (nElement)
+ {
+ case XML_ELEMENT(TEXT, XML_BIBLIOGRAPHY_CONFIGURATION):
+ pStyle = new XMLIndexBibliographyConfigurationContext(
+ GetImport(), nElement, xAttrList);
+ break;
}
return pStyle;
@@ -478,11 +488,6 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPr
xAttrList);
break;
- case XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG:
- pStyle = new XMLIndexBibliographyConfigurationContext(
- GetImport(), p_nPrefix, rLocalName, xAttrList);
- break;
-
case XML_TOK_TEXT_LINENUMBERING_CONFIG:
pStyle = new XMLLineNumberingImportContext(
GetImport(), p_nPrefix, rLocalName, xAttrList);
diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
index 1046e8153318..c9937f562e6a 100644
--- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
+++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx
@@ -26,6 +26,7 @@
#include <xmloff/xmlnamespace.hxx>
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmluconv.hxx>
+#include <sal/log.hxx>
#include <sax/tools/converter.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -38,6 +39,7 @@ using namespace ::com::sun::star::uno;
using namespace ::xmloff::token;
using ::com::sun::star::xml::sax::XAttributeList;
+using ::com::sun::star::xml::sax::XFastAttributeList;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::lang::XMultiServiceFactory;
@@ -56,10 +58,9 @@ const OUStringLiteral gsLocale("Locale");
XMLIndexBibliographyConfigurationContext::XMLIndexBibliographyConfigurationContext(
SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLocalName,
- const Reference<XAttributeList> & xAttrList) :
- SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList, XmlStyleFamily::TEXT_BIBLIOGRAPHYCONFIG),
+ sal_Int32 nElement,
+ const Reference<XFastAttributeList> & xAttrList) :
+ SvXMLStyleContext(rImport, nElement, xAttrList, XmlStyleFamily::TEXT_BIBLIOGRAPHYCONFIG),
sSuffix(),
sPrefix(),
sAlgorithm(),
@@ -133,41 +134,33 @@ void XMLIndexBibliographyConfigurationContext::SetAttribute(
}
}
-SvXMLImportContextRef XMLIndexBibliographyConfigurationContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList> & xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexBibliographyConfigurationContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
// process children here and use default context!
- if ( ( nPrefix == XML_NAMESPACE_TEXT ) &&
- IsXMLToken( rLocalName, XML_SORT_KEY ) )
+ if ( nElement == XML_ELEMENT(TEXT, XML_SORT_KEY) )
{
OUString sKey;
bool bSort(true);
- sal_Int16 nLength = xAttrList->getLength();
- for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
- OUString sLocalName;
- sal_uInt16 nPrfx = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
- &sLocalName );
-
- if (nPrfx == XML_NAMESPACE_TEXT)
+ switch (aIter.getToken())
{
- if ( IsXMLToken( sLocalName, XML_KEY ) )
- {
- sKey = xAttrList->getValueByIndex(nAttr);
- }
- else if ( IsXMLToken( sLocalName, XML_SORT_ASCENDING ) )
+ case XML_ELEMENT(TEXT, XML_KEY):
+ sKey = aIter.toString();
+ break;
+ case XML_ELEMENT(TEXT, XML_SORT_ASCENDING):
{
bool bTmp(false);
- if (::sax::Converter::convertBool(
- bTmp, xAttrList->getValueByIndex(nAttr)))
- {
+ if (::sax::Converter::convertBool(bTmp, aIter.toString()))
bSort = bTmp;
- }
+ break;
}
+ default:
+ SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
+ break;
}
}