From 57796f2724f004679f78eb144a93b9a03968317c Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Fri, 11 Jun 2021 14:52:29 +0200 Subject: Simplify Sequences initializations (writerfilter/writerperfect/x*) Change-Id: I1bd31fe6cf0f8aaf4f2cfe1d3d49e61a0633f361 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117057 Tested-by: Jenkins Reviewed-by: Julien Nabet --- xmloff/source/chart/SchXMLSeriesHelper.cxx | 9 ++------- xmloff/source/core/DomBuilderContext.cxx | 10 ++-------- xmloff/source/core/xmlexp.cxx | 3 +-- xmloff/source/draw/XMLImageMapContext.cxx | 3 +-- xmloff/source/draw/sdxmlimp.cxx | 3 +-- xmloff/source/draw/ximpshap.cxx | 4 +--- xmloff/source/draw/ximpstyl.cxx | 6 ++---- xmloff/source/meta/xmlmetai.cxx | 4 +--- xmloff/source/script/XMLEventImportHelper.cxx | 7 +------ xmloff/source/style/prstylei.cxx | 6 +----- xmloff/source/style/xmlbahdl.cxx | 10 ++++++---- xmloff/source/text/XMLSectionSourceDDEImportContext.cxx | 16 ++-------------- 12 files changed, 21 insertions(+), 60 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx index 380830b40fc6..9bccc3f83950 100644 --- a/xmloff/source/chart/SchXMLSeriesHelper.cxx +++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx @@ -170,9 +170,7 @@ uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPISeriesProp Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY ); if(xInit.is()) { - Sequence< uno::Any > aArguments(1); - aArguments[0] <<= xSeries; - xInit->initialize(aArguments); + xInit->initialize( { uno::Any(xSeries) }); } } } @@ -204,10 +202,7 @@ uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPIDataPointP Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY ); if(xInit.is()) { - Sequence< uno::Any > aArguments(2); - aArguments[0] <<= xSeries; - aArguments[1] <<= nPointIndex; - xInit->initialize(aArguments); + xInit->initialize({ uno::Any(xSeries), uno::Any(nPointIndex) }); } } } diff --git a/xmloff/source/core/DomBuilderContext.cxx b/xmloff/source/core/DomBuilderContext.cxx index b0ddefea764d..066d8e6038c4 100644 --- a/xmloff/source/core/DomBuilderContext.cxx +++ b/xmloff/source/core/DomBuilderContext.cxx @@ -176,11 +176,8 @@ void DomBuilderContext::HandleAttributes( case XML_NAMESPACE_UNKNOWN: // unknown namespace: illegal input. Raise Warning. { - Sequence aSeq(2); - aSeq[0] = rLocalName; - aSeq[1] = aValue; GetImport().SetError( - XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, aSeq ); + XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, { rLocalName, aValue } ); } break; default: @@ -202,11 +199,8 @@ void DomBuilderContext::HandleAttributes( if (!rUnknownAttrib.NamespaceURL.isEmpty()) { // unknown namespace: illegal input. Raise Warning. - Sequence aSeq(2); - aSeq[0] = rUnknownAttrib.Name; - aSeq[1] = rUnknownAttrib.Value; GetImport().SetError( - XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, aSeq ); + XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, { rUnknownAttrib.Name, rUnknownAttrib.Value } ); } else { diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index d355e4a0ff28..05d44229e321 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -2255,9 +2255,8 @@ void SvXMLExport::IgnorableWhitespace() } catch (const SAXException& e) { - Sequence aPars(0); SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, - aPars, e.Message, nullptr ); + {}, e.Message, nullptr ); } } diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 2f848115d69a..09958b7ca7f5 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -501,8 +501,7 @@ XMLImageMapContext::XMLImageMapContext( } catch(const css::uno::Exception& e) { - uno::Sequence aSeq(0); - rImport.SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, nullptr ); + rImport.SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, {}, e.Message, nullptr ); } } diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index b768eaf14d32..2776880934ec 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -515,8 +515,7 @@ void SdXMLImport::SetViewSettings(const css::uno::Sequence aSeq(0); - SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL ); + SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, {}, e.Message, NULL ); */ } } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index a1fdad1cc41c..068205635e75 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -490,9 +490,7 @@ void SdXMLShapeContext::AddShape(OUString const & serviceName) || serviceName == "com.sun.star.drawing.MediaShape" || serviceName == "com.sun.star.presentation.MediaShape") { - css::uno::Sequence args(1); - args[0] <<= GetImport().GetDocumentBase(); - xShape.set( xServiceFact->createInstanceWithArguments(serviceName, args), + xShape.set( xServiceFact->createInstanceWithArguments(serviceName, { css::uno::Any(GetImport().GetDocumentBase()) }), css::uno::UNO_QUERY); } else diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index a702872a736b..c9449a900b1f 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -1227,8 +1227,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc } catch(const Exception& e) { - uno::Sequence aSeq(0); - const_cast(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, nullptr ); + const_cast(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, {}, e.Message, nullptr ); } } @@ -1267,8 +1266,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc } catch( const Exception& e ) { - uno::Sequence aSeq(0); - const_cast(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, nullptr ); + const_cast(&GetSdImport())->SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, {}, e.Message, nullptr ); } } } diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx index 89dbc505fac5..457e2da4bff0 100644 --- a/xmloff/source/meta/xmlmetai.cxx +++ b/xmloff/source/meta/xmlmetai.cxx @@ -129,12 +129,10 @@ lcl_initDocumentProperties(SvXMLImport & rImport, uno::Reference const& xDocBuilder, uno::Reference const& xDocProps) { - uno::Sequence< uno::Any > aSeq(1); - aSeq[0] <<= xDocBuilder->getDocument(); uno::Reference< lang::XInitialization > const xInit(xDocProps, uno::UNO_QUERY_THROW); try { - xInit->initialize(aSeq); + xInit->initialize({ uno::Any(xDocBuilder->getDocument()) }); rImport.SetStatistics(xDocProps->getDocumentStatistics()); // convert all URLs from relative to absolute xDocProps->setTemplateURL(rImport.GetAbsoluteReference( diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx index 18b795ee1f3d..9796224f902d 100644 --- a/xmloff/source/script/XMLEventImportHelper.cxx +++ b/xmloff/source/script/XMLEventImportHelper.cxx @@ -140,13 +140,8 @@ SvXMLImportContext* XMLEventImportHelper::CreateContext( { pContext = new SvXMLImportContext(rImport); - Sequence aMsgParams(2); - - aMsgParams[0] = rXmlEventName; - aMsgParams[1] = rLanguage; - rImport.SetError(XMLERROR_FLAG_ERROR | XMLERROR_ILLEGAL_EVENT, - aMsgParams); + { rXmlEventName, rLanguage }); } diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index 3bf2c8ad8af6..e9ca87595f2b 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -480,15 +480,11 @@ void XMLPropStyleContext::Finish( bool bOverwrite ) // We can't set the parent style. For a proper // Error-Message, we should pass in the name of the // style, as well as the desired parent style. - Sequence aSequence(2); // getName() throws no non-Runtime exception: - aSequence[0] = mxStyle->getName(); - aSequence[1] = sParent; - GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_PARENT_STYLE_NOT_ALLOWED, - aSequence, e.Message, nullptr ); + { mxStyle->getName(), sParent }, e.Message, nullptr ); } } diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx index 7f928dfbf499..b1fa0c891c86 100644 --- a/xmloff/source/style/xmlbahdl.cxx +++ b/xmloff/source/style/xmlbahdl.cxx @@ -446,10 +446,12 @@ bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, cons sal_Int32 nIndex = 0; - Sequence< double > aHSL(3); - aHSL[0] = aTmp.getToken( 0, ',', nIndex ).toDouble(); - aHSL[1] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0; - aHSL[2] = aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0; + Sequence< double > aHSL + { + aTmp.getToken( 0, ',', nIndex ).toDouble(), + aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0, + aTmp.getToken( 0, ',', nIndex ).toDouble() / 100.0 + }; rValue <<= aHSL; bRet = true; } diff --git a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx index 3e98f5114100..e2d8f1ce8468 100644 --- a/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx +++ b/xmloff/source/text/XMLSectionSourceDDEImportContext.cxx @@ -93,20 +93,8 @@ void XMLSectionSourceDDEImportContext::startFastElement(sal_Int32 /*nElement*/, return; // use multi property set to force single update of connection #83654# - Sequence aNames(4); - Sequence aValues(4); - - aValues[0] <<= sApplication; - aNames[0] = "DDECommandFile"; - - aValues[1] <<= sTopic; - aNames[1] = "DDECommandType"; - - aValues[2] <<= sItem; - aNames[2] = "DDECommandElement"; - - aValues[3] <<= bAutomaticUpdate; - aNames[3] = "IsAutomaticUpdate"; + Sequence aNames { "DDECommandFile", "DDECommandType", "DDECommandElement", "IsAutomaticUpdate" }; + Sequence aValues { Any(sApplication), Any(sTopic), Any(sItem), Any(bAutomaticUpdate) }; Reference rMultiPropSet(rSectionPropertySet, UNO_QUERY); -- cgit