diff options
author | Noel <noelgrandin@gmail.com> | 2020-11-19 15:30:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-19 19:31:38 +0100 |
commit | 8eb9688529d345d30e427126f4f1b2afa37a8b87 (patch) | |
tree | 3a11fa2733ce88997e4b42a14445d832d419c2a2 /xmloff | |
parent | 46aaf4e4e611a48c3c5b8338c9a19814094c563a (diff) |
fastparser in dropdownfield
Change-Id: I4b09f78b0f4d2ad40a7aec8e2d5d722b7a1ee18b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106166
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 17 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 58 |
2 files changed, 31 insertions, 44 deletions
diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index f899be5d137a..bebc30a5b135 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -890,10 +890,9 @@ public: sal_uInt16 nPrfx, const OUString& sLocalName); - 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; }; /** import dde field declaration (<text:dde-connection-decl>) */ @@ -901,9 +900,7 @@ class XMLDdeFieldDeclImportContext final : public SvXMLImportContext { public: - XMLDdeFieldDeclImportContext(SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& sLocalName); + XMLDdeFieldDeclImportContext(SvXMLImport& rImport); // create fieldmaster virtual void SAL_CALL startFastElement( @@ -1137,10 +1134,8 @@ public: sal_uInt16 nPrfx, const OUString& sLocalName); - 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; private: /// process attribute values diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 3c0be357b23a..121664d1973c 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2719,16 +2719,16 @@ XMLDdeFieldDeclsImportContext::XMLDdeFieldDeclsImportContext( { } -SvXMLImportContextRef XMLDdeFieldDeclsImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList> & /*xAttrList*/ ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDdeFieldDeclsImportContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) { - if ( (XML_NAMESPACE_TEXT == nPrefix) && - (IsXMLToken(rLocalName, XML_DDE_CONNECTION_DECL)) ) + if ( nElement == XML_ELEMENT(TEXT, XML_DDE_CONNECTION_DECL) ) { - return new XMLDdeFieldDeclImportContext(GetImport(), nPrefix, rLocalName); + return new XMLDdeFieldDeclImportContext(GetImport()); } + else + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); return nullptr; } @@ -2736,13 +2736,9 @@ SvXMLImportContextRef XMLDdeFieldDeclsImportContext::CreateChildContext( // import dde field declaration -XMLDdeFieldDeclImportContext::XMLDdeFieldDeclImportContext( - SvXMLImport& rImport, sal_uInt16 nPrfx, - const OUString& sLocalName) -: SvXMLImportContext(rImport, nPrfx, sLocalName) +XMLDdeFieldDeclImportContext::XMLDdeFieldDeclImportContext(SvXMLImport& rImport) +: SvXMLImportContext(rImport) { - DBG_ASSERT(XML_NAMESPACE_TEXT == nPrfx, "wrong prefix"); - DBG_ASSERT(IsXMLToken(sLocalName, XML_DDE_CONNECTION_DECL), "wrong name"); } void XMLDdeFieldDeclImportContext::startFastElement( @@ -3628,56 +3624,52 @@ XMLDropDownFieldImportContext::XMLDropDownFieldImportContext( bValid = true; } -static bool lcl_ProcessLabel( const SvXMLImport& rImport, - const Reference<XAttributeList>& xAttrList, +static bool lcl_ProcessLabel( + const Reference<XFastAttributeList>& xAttrList, OUString& rLabel, bool& rIsSelected ) { bool bValid = false; - sal_Int16 nLength = xAttrList->getLength(); - for( sal_Int16 n = 0; n < nLength; n++ ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - sal_uInt16 nPrefix = rImport.GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(n), &sLocalName ); - OUString sValue = xAttrList->getValueByIndex(n); - - if( nPrefix == XML_NAMESPACE_TEXT ) + OUString sValue = aIter.toString(); + switch (aIter.getToken()) { - if( IsXMLToken( sLocalName, XML_VALUE ) ) + case XML_ELEMENT(TEXT, XML_VALUE): { rLabel = sValue; bValid = true; + break; } - else if( IsXMLToken( sLocalName, XML_CURRENT_SELECTED ) ) + case XML_ELEMENT(TEXT, XML_CURRENT_SELECTED): { bool bTmp(false); if (::sax::Converter::convertBool( bTmp, sValue )) rIsSelected = bTmp; + break; } + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } return bValid; } -SvXMLImportContextRef XMLDropDownFieldImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList>& xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDropDownFieldImportContext::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if( nPrefix == XML_NAMESPACE_TEXT && - IsXMLToken( rLocalName, XML_LABEL ) ) + if( nElement == XML_ELEMENT(TEXT, XML_LABEL) ) { OUString sLabel; bool bIsSelected = false; - if( lcl_ProcessLabel( GetImport(), xAttrList, sLabel, bIsSelected ) ) + if( lcl_ProcessLabel( xAttrList, sLabel, bIsSelected ) ) { if( bIsSelected ) nSelected = static_cast<sal_Int32>( aLabels.size() ); aLabels.push_back( sLabel ); } } - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return new SvXMLImportContext( GetImport() ); } void XMLDropDownFieldImportContext::ProcessAttribute( |