diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-28 11:46:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-28 21:03:49 +0200 |
commit | 5c38aa445986ee8650324412b2a78e68014101ac (patch) | |
tree | 4c283f9aba3230e3e97254342efd8a13c784c8ce | |
parent | 6e0bb3fc4e89ddb85ddf40889b11a0c0bd4ab607 (diff) |
use more fast-parser in SvXMLNumFormatContext
Change-Id: Ib0389fa53ce2516cdd1f9ad8e68d9209455b4359
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101534
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/xmloff/xmlimp.hxx | 1 | ||||
-rw-r--r-- | include/xmloff/xmlnumfi.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 23 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfi.cxx | 8 |
4 files changed, 19 insertions, 18 deletions
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 3b4cc7969be9..0f40ef548ceb 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -397,6 +397,7 @@ public: static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap); static OUString getNamespaceURIFromToken( sal_Int32 nToken ); static OUString getNamespacePrefixFromURI( const OUString& rURI ); + static sal_Int32 getTokenFromName(const OUString& sName); SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; } const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; } diff --git a/include/xmloff/xmlnumfi.hxx b/include/xmloff/xmlnumfi.hxx index f0eb16b728fa..2e0b258fd24c 100644 --- a/include/xmloff/xmlnumfi.hxx +++ b/include/xmloff/xmlnumfi.hxx @@ -159,9 +159,8 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, SvXMLStylesContext& rStyles ); SvXMLNumFormatContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList, + const OUString& rName, + const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList, const sal_Int32 nKey, LanguageType nLang, SvXMLStylesContext& rStyles ); diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 8fbc4a9d5d8c..cf8b32c054e2 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1637,7 +1637,7 @@ void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles ) { if (pAutoStyles && mxNumberStyles.is()) { - uno::Reference<xml::sax::XAttributeList> xAttrList; + uno::Reference<xml::sax::XFastAttributeList> xAttrList = new sax_fastparser::FastAttributeList(nullptr); const uno::Sequence<OUString> aStyleNames = mxNumberStyles->getElementNames(); for (const auto& name : aStyleNames) { @@ -1646,7 +1646,7 @@ void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles ) if (aAny >>= nKey) { SvXMLStyleContext* pContext = new SvXMLNumFormatContext( - *this, XML_NAMESPACE_NUMBER, name, xAttrList, nKey, + *this, name, xAttrList, nKey, GetDataStylesImport()->GetLanguageForKey(nKey), *pAutoStyles); pAutoStyles->AddStyle(*pContext); } @@ -2080,6 +2080,13 @@ OUString SvXMLImport::getNamespacePrefixFromURI( const OUString& rURI ) return OUString(); } +sal_Int32 SvXMLImport::getTokenFromName( const OUString& rName ) +{ + Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>( + OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr()), rName.getLength() ); + return xTokenHandler->getTokenFromUTF8( aLocalNameSeq ); +} + void SvXMLImport::initializeNamespaceMaps() { auto mapTokenToNamespace = [&]( sal_Int32 nToken, sal_Int32 nPrefix, sal_Int32 nNamespace ) @@ -2255,9 +2262,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName, mrImport->processNSAttributes(xAttrList); OUString aLocalName; sal_uInt16 nPrefix = mrImport->mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName ); - Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>( - OUStringToOString( aLocalName, RTL_TEXTENCODING_UTF8 ).getStr()), aLocalName.getLength() ); - sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::xTokenHandler->getTokenFromUTF8( aLocalNameSeq ); + sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName( aLocalName ); mxFastAttributes->clear(); sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -2271,9 +2276,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName, rAttrName, nullptr, &aLocalAttrName, &aNamespace)); if( XML_NAMESPACE_XMLNS != nAttrPrefix ) { - Sequence< sal_Int8 > aAttrSeq( reinterpret_cast<sal_Int8 const *>( - OUStringToOString( aLocalAttrName, RTL_TEXTENCODING_UTF8 ).getStr()), aLocalAttrName.getLength() ); - auto const nToken(SvXMLImport::xTokenHandler->getTokenFromUTF8(aAttrSeq)); + auto const nToken = SvXMLImport::getTokenFromName(aLocalAttrName); if (nToken == xmloff::XML_TOKEN_INVALID) { mxFastAttributes->addUnknown(aNamespace, @@ -2294,9 +2297,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::endElement( const OUString& rName ) { OUString aLocalName; sal_uInt16 nPrefix = mrImport->mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName ); - Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>( - OUStringToOString( aLocalName, RTL_TEXTENCODING_UTF8 ).getStr()), aLocalName.getLength() ); - sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::xTokenHandler->getTokenFromUTF8( aLocalNameSeq ); + sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName(aLocalName); mrImport->endFastElement( mnElement ); } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 676562b41b43..076b47cdaddf 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1278,11 +1278,11 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport, } SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const uno::Reference<xml::sax::XAttributeList>& xAttrList, + const OUString& rName, + const uno::Reference<xml::sax::XFastAttributeList>& xAttrList, const sal_Int32 nTempKey, LanguageType nLang, SvXMLStylesContext& rStyles ) : - SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, XmlStyleFamily::DATA_STYLE ), + SvXMLStyleContext( rImport, 0, xAttrList, XmlStyleFamily::DATA_STYLE ), pData( nullptr ), pStyles( &rStyles ), aMyConditions(), @@ -1308,7 +1308,7 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport, eDateSecs( XML_DEA_NONE ), bDateNoDefault( false ) { - SetAttribute(XML_NAMESPACE_STYLE, GetXMLToken(XML_NAME), rLName); + SetAttribute(XML_NAMESPACE_STYLE, GetXMLToken(XML_NAME), rName); } SvXMLNumFormatContext::~SvXMLNumFormatContext() |