From 4477baeba5aec71098f374cf0b4bd4591e048809 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 17 Oct 2021 11:37:25 +0200 Subject: Simplify Sequences in xmloff (+ merge 2 SetError) Change-Id: If4055bbeb858b1b87ecb3f8c0b87da4b008e3c16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123716 Tested-by: Jenkins Reviewed-by: Julien Nabet --- xmloff/source/core/xmlimp.cxx | 11 +------- xmloff/source/script/XMLScriptContextFactory.cxx | 12 +++------ .../source/script/XMLStarBasicContextFactory.cxx | 16 ++++++------ xmloff/source/style/prstylei.cxx | 10 +++++--- xmloff/source/style/xmlimppr.cxx | 5 +--- .../XMLIndexBibliographyConfigurationContext.cxx | 17 +++++-------- xmloff/source/text/txtflde.cxx | 29 ++++++++++------------ 7 files changed, 37 insertions(+), 63 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 7ba2c127fb3b..0d47a7a813ef 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1042,9 +1042,7 @@ void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen } uno::Reference const xInit(mxParser, uno::UNO_QUERY_THROW); - uno::Sequence args(1); - args[0] <<= OUString("IgnoreMissingNSDecl"); - xInit->initialize( args ); + xInit->initialize( { makeAny(OUString("IgnoreMissingNSDecl")) }); } // XServiceInfo @@ -1744,13 +1742,6 @@ void SvXMLImport::SetError( SetError( nId, rMsgParams, "", nullptr ); } -void SvXMLImport::SetError( - sal_Int32 nId) -{ - Sequence aSeq(0); - SetError( nId, aSeq ); -} - void SvXMLImport::SetError( sal_Int32 nId, const OUString& rMsg1) diff --git a/xmloff/source/script/XMLScriptContextFactory.cxx b/xmloff/source/script/XMLScriptContextFactory.cxx index 3b535771470f..c5d7cb2d0d05 100644 --- a/xmloff/source/script/XMLScriptContextFactory.cxx +++ b/xmloff/source/script/XMLScriptContextFactory.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include #include @@ -52,15 +53,8 @@ SvXMLImportContext* XMLScriptContextFactory::CreateContext( // else: ignore } - Sequence aValues(2); - - // EventType - aValues[0].Name = gsEventType; - aValues[0].Value <<= OUString(gsScript); - - // URL - aValues[1].Name = gsURL; - aValues[1].Value <<= sURLVal; + Sequence aValues{ comphelper::makePropertyValue(gsEventType, OUString(gsScript)), + comphelper::makePropertyValue(gsURL, sURLVal) }; // add values for event now rEvents->AddEventValues(rApiEventName, aValues); diff --git a/xmloff/source/script/XMLStarBasicContextFactory.cxx b/xmloff/source/script/XMLStarBasicContextFactory.cxx index a0c9d7b0c193..73d6482daa9f 100644 --- a/xmloff/source/script/XMLStarBasicContextFactory.cxx +++ b/xmloff/source/script/XMLStarBasicContextFactory.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include #include @@ -79,15 +80,12 @@ SvXMLImportContext* XMLStarBasicContextFactory::CreateContext( sMacroNameVal = sMacroNameVal.copy( rDoc.getLength()+1 ); } - Sequence aValues(3); - - // EventType - aValues[0].Name = gsEventType; - aValues[0].Value <<= OUString(gsStarBasic); - - // library name - aValues[1].Name = gsLibrary; - aValues[1].Value <<= sLibraryVal; + Sequence aValues + { + comphelper::makePropertyValue(gsEventType, OUString(gsStarBasic)), + comphelper::makePropertyValue(gsLibrary, sLibraryVal), + comphelper::makePropertyValue(gsMacroName, sMacroNameVal) + }; // macro name aValues[2].Name = gsMacroName; diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index 5cd856b209e8..016204277b54 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -332,10 +332,12 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite ) Reference < XAutoStyle > xAutoStyle = xAutoFamily->insertStyle( aValues ); if( xAutoStyle.is() ) { - Sequence< OUString > aPropNames(1); - aPropNames[0] = GetFamily() == XmlStyleFamily::TEXT_PARAGRAPH ? - OUStringLiteral(u"ParaAutoStyleName") : - OUStringLiteral(u"CharAutoStyleName"); + Sequence< OUString > aPropNames + { + (GetFamily() == XmlStyleFamily::TEXT_PARAGRAPH)? + OUString("ParaAutoStyleName"): + OUString("CharAutoStyleName") + }; Sequence< Any > aAny = xAutoStyle->getPropertyValues( aPropNames ); if( aAny.hasElements() ) { diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx index f90aa7a75b9b..e8ecf4109772 100644 --- a/xmloff/source/style/xmlimppr.cxx +++ b/xmloff/source/style/xmlimppr.cxx @@ -266,12 +266,9 @@ void SvXMLImportPropertyMapper::importXMLAttribute( if( !bNoWarning && ((nFlags & MID_FLAG_MULTI_PROPERTY) == 0) ) { - Sequence aSeq(2); - aSeq[0] = rAttrName; - aSeq[1] = sValue; rImport.SetError( XMLERROR_FLAG_WARNING | XMLERROR_STYLE_ATTR_VALUE, - aSeq ); + { rAttrName, sValue } ); } } } diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx index 799cd47a8724..246a804a7e99 100644 --- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include "XMLIndexBibliographyEntryContext.hxx" #include @@ -152,17 +153,11 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexBibliographyCo if (SvXMLUnitConverter::convertEnum(nKey, sKey, aBibliographyDataFieldMap)) { - Sequence aKey(2); - - PropertyValue aNameValue; - aNameValue.Name = gsSortKey; - aNameValue.Value <<= static_cast(nKey); - aKey[0] = aNameValue; - - PropertyValue aSortValue; - aSortValue.Name = gsIsSortAscending; - aSortValue.Value <<= bSort; - aKey[1] = aSortValue; + Sequence aKey + { + comphelper::makePropertyValue(gsSortKey, static_cast(nKey)), + comphelper::makePropertyValue(gsIsSortAscending, bSort) + }; aSortKeys.push_back(aKey); } diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index e899e083b980..1fe5da65caf6 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -22,6 +22,7 @@ * * export of all text fields */ +#include #include #include #include @@ -2268,7 +2269,6 @@ void XMLTextFieldExport::ExportMacro( { // some strings we'll need OUString sEventType( "EventType" ); - OUString sPropertyScriptURL( "ScriptURL" ); // the description attribute @@ -2285,30 +2285,27 @@ void XMLTextFieldExport::ExportMacro( // 1) build sequence of PropertyValues Sequence aSeq; OUString sName; - rPropSet->getPropertyValue( sPropertyScriptURL ) >>= sName; + rPropSet->getPropertyValue("ScriptURL") >>= sName; // if the ScriptURL property is not empty then this is a Scripting // Framework URL, otherwise treat it as a Basic Macro if (!sName.isEmpty()) { OUString sScript( "Script" ); - aSeq = Sequence (2); - PropertyValue* pArr = aSeq.getArray(); - pArr[0].Name = sEventType; - pArr[0].Value <<= sScript; - pArr[1].Name = sScript; - pArr[1].Value = rPropSet->getPropertyValue( sPropertyScriptURL ); + aSeq = Sequence + { + comphelper::makePropertyValue(sEventType, sScript), + comphelper::makePropertyValue(sScript, sName) + }; } else { - aSeq = Sequence (3); - PropertyValue* pArr = aSeq.getArray(); - pArr[0].Name = sEventType; - pArr[0].Value <<= OUString("StarBasic"); - pArr[1].Name = "Library"; - pArr[1].Value = rPropSet->getPropertyValue( "MacroLibrary" ); - pArr[2].Name = "MacroName"; - pArr[2].Value = rPropSet->getPropertyValue( "MacroName" ); + aSeq = Sequence + { + comphelper::makePropertyValue(sEventType, OUString("StarBasic")), + comphelper::makePropertyValue("Library", rPropSet->getPropertyValue( "MacroLibrary" )), + comphelper::makePropertyValue("MacroName", rPropSet->getPropertyValue( "MacroName" )) + }; } // 2) export the sequence -- cgit