diff options
author | Noel <noelgrandin@gmail.com> | 2020-12-01 09:39:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-01 09:55:03 +0100 |
commit | 7673b027daed248d1be4dd1a773bfc0334a00c53 (patch) | |
tree | 544522f4af8ac5f018a8ee4f3604c07e5ae4555f /xmloff/source | |
parent | d6d80c4e1783b4459bd4a8fbcbdfeebe416c1cb5 (diff) |
fastparser in XMLIndexTabStopEntryContext
Change-Id: Ic9d6f70ec0f62d3a4f6fe744d0334d01b131c118
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106923
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source')
4 files changed, 38 insertions, 37 deletions
diff --git a/xmloff/source/text/XMLIndexSimpleEntryContext.cxx b/xmloff/source/text/XMLIndexSimpleEntryContext.cxx index 1317331ade71..be728eac98f8 100644 --- a/xmloff/source/text/XMLIndexSimpleEntryContext.cxx +++ b/xmloff/source/text/XMLIndexSimpleEntryContext.cxx @@ -26,6 +26,7 @@ #include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> +#include <sal/log.hxx> #include <com/sun/star/container/XNameContainer.hpp> @@ -54,21 +55,16 @@ XMLIndexSimpleEntryContext::~XMLIndexSimpleEntryContext() { } -void XMLIndexSimpleEntryContext::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLIndexSimpleEntryContext::startFastElement( + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { // we know only one attribute: style-name - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - if ( (XML_NAMESPACE_TEXT == nPrefix) && - IsXMLToken(sLocalName, XML_STYLE_NAME) ) + if(aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME)) { - m_sCharStyleName = xAttrList->getValueByIndex(nAttr); + m_sCharStyleName = aIter.toString(); OUString sDisplayStyleName = GetImport().GetStyleDisplayName( XmlStyleFamily::TEXT_TEXT, m_sCharStyleName ); // #142494#: Check if style exists @@ -79,6 +75,8 @@ void XMLIndexSimpleEntryContext::StartElement( else m_bCharStyleNameOK = false; } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } // if we have a style name, set it! diff --git a/xmloff/source/text/XMLIndexSimpleEntryContext.hxx b/xmloff/source/text/XMLIndexSimpleEntryContext.hxx index beb816832749..dbce23d8c588 100644 --- a/xmloff/source/text/XMLIndexSimpleEntryContext.hxx +++ b/xmloff/source/text/XMLIndexSimpleEntryContext.hxx @@ -64,8 +64,9 @@ public: protected: /** process parameters */ - 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 >& xAttrList ) override; /** call FillPropertyValues and insert into template */ virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexTabStopEntryContext.cxx b/xmloff/source/text/XMLIndexTabStopEntryContext.cxx index 9c9e195c60fc..1c785c53cc4d 100644 --- a/xmloff/source/text/XMLIndexTabStopEntryContext.cxx +++ b/xmloff/source/text/XMLIndexTabStopEntryContext.cxx @@ -57,60 +57,61 @@ XMLIndexTabStopEntryContext::~XMLIndexTabStopEntryContext() { } -void XMLIndexTabStopEntryContext::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLIndexTabStopEntryContext::startFastElement( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { // process three attributes: type, position, leader char - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - OUString sAttr = xAttrList->getValueByIndex(nAttr); - if (XML_NAMESPACE_STYLE == nPrefix) + OUString sValue = aIter.toString(); + switch(aIter.getToken()) { - if ( IsXMLToken( sLocalName, XML_TYPE ) ) + case XML_ELEMENT(STYLE, XML_TYPE): { // if it's neither left nor right, value is // ignored. Since left is default, we only need to // check for right - bTabRightAligned = IsXMLToken( sAttr, XML_RIGHT ); + bTabRightAligned = IsXMLToken( sValue, XML_RIGHT ); + break; } - else if ( IsXMLToken( sLocalName, XML_POSITION ) ) + case XML_ELEMENT(STYLE, XML_POSITION): { sal_Int32 nTmp; if (GetImport().GetMM100UnitConverter(). - convertMeasureToCore(nTmp, sAttr)) + convertMeasureToCore(nTmp, sValue)) { nTabPosition = nTmp; bTabPositionOK = true; } + break; } - else if ( IsXMLToken( sLocalName, XML_LEADER_CHAR ) ) + case XML_ELEMENT(STYLE, XML_LEADER_CHAR): { - sLeaderChar = sAttr; + sLeaderChar = sValue; // valid only, if we have a char! - bLeaderCharOK = !sAttr.isEmpty(); + bLeaderCharOK = !sValue.isEmpty(); + break; } - // #i21237# - else if ( IsXMLToken( sLocalName, XML_WITH_TAB ) ) + case XML_ELEMENT(STYLE, XML_WITH_TAB): { + // #i21237# bool bTmp(false); - if (::sax::Converter::convertBool(bTmp, sAttr)) + if (::sax::Converter::convertBool(bTmp, sValue)) bWithTab = bTmp; + break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); // else: unknown style: attribute -> ignore } - // else: no style attribute -> ignore } // how many entries? #i21237# m_nValues += 2 + (bTabPositionOK ? 1 : 0) + (bLeaderCharOK ? 1 : 0); // now try parent class (for character style) - XMLIndexSimpleEntryContext::StartElement( xAttrList ); + XMLIndexSimpleEntryContext::startFastElement( nElement, xAttrList ); } void XMLIndexTabStopEntryContext::FillPropertyValues( diff --git a/xmloff/source/text/XMLIndexTabStopEntryContext.hxx b/xmloff/source/text/XMLIndexTabStopEntryContext.hxx index a4f32d9ce28c..0803a78ad348 100644 --- a/xmloff/source/text/XMLIndexTabStopEntryContext.hxx +++ b/xmloff/source/text/XMLIndexTabStopEntryContext.hxx @@ -55,8 +55,9 @@ public: 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 >& xAttrList ) override; /** fill property values for this template entry */ virtual void FillPropertyValues( |