sc/qa/extras/macros-test.cxx | 9 sc/qa/extras/sccellrangeobj.cxx | 5 sc/qa/extras/scindexenumeration_tableconditionalentryenumeration.cxx | 20 - sc/qa/extras/scmodelobj.cxx | 6 sc/qa/extras/scpdfexport.cxx | 29 +- sc/qa/extras/scsubtotaldescriptorbase.cxx | 6 sc/qa/extras/scsubtotalfieldobj.cxx | 6 sc/qa/extras/sctableconditionalentryobj.cxx | 20 - sc/qa/extras/sctableconditionalformat.cxx | 19 - sc/qa/unit/bugfix-test.cxx | 13 - sc/qa/unit/chart2dataprovider.cxx | 21 - sc/qa/unit/copy_paste_test.cxx | 5 sc/qa/unit/jumbosheets-test.cxx | 5 sc/qa/unit/scshapetest.cxx | 5 sc/qa/unit/subsequent_export_test2.cxx | 9 sc/qa/unit/tiledrendering/tiledrendering.cxx | 36 +-- sc/qa/unit/uicalc/uicalc.cxx | 5 sc/source/core/data/documen3.cxx | 3 sc/source/core/data/documen5.cxx | 30 +- sc/source/core/data/dpfilteredcache.cxx | 9 sc/source/core/data/dpobject.cxx | 9 sc/source/core/data/dpoutput.cxx | 8 sc/source/core/data/dptabsrc.cxx | 7 sc/source/core/data/table5.cxx | 14 - sc/source/core/data/validat.cxx | 22 -- sc/source/core/tool/charthelper.cxx | 7 sc/source/core/tool/formulaparserpool.cxx | 3 sc/source/core/tool/interpr4.cxx | 5 sc/source/filter/excel/xichart.cxx | 7 sc/source/filter/excel/xiescher.cxx | 10 sc/source/filter/excel/xltoolbar.cxx | 6 sc/source/filter/excel/xltracer.cxx | 5 sc/source/filter/ftools/fapihelper.cxx | 5 sc/source/filter/inc/xltracer.hxx | 2 sc/source/filter/oox/autofilterbuffer.cxx | 20 + sc/source/filter/oox/drawingfragment.cxx | 9 sc/source/filter/oox/viewsettings.cxx | 7 sc/source/filter/oox/workbooksettings.cxx | 18 - sc/source/filter/xml/XMLCodeNameProvider.cxx | 10 sc/source/filter/xml/xmldrani.cxx | 2 sc/source/filter/xml/xmldrani.hxx | 2 sc/source/filter/xml/xmlexprt.cxx | 13 - sc/source/filter/xml/xmlimprt.cxx | 6 sc/source/filter/xml/xmlsorti.cxx | 39 +-- sc/source/ui/Accessibility/AccessibleCsvControl.cxx | 24 +- sc/source/ui/Accessibility/AccessibleDocument.cxx | 6 sc/source/ui/Accessibility/AccessiblePreviewTable.cxx | 2 sc/source/ui/cctrl/tbzoomsliderctrl.cxx | 10 sc/source/ui/docshell/docsh.cxx | 26 +- sc/source/ui/docshell/docsh4.cxx | 15 - sc/source/ui/drawfunc/fuins2.cxx | 27 +- sc/source/ui/miscdlgs/optsolver.cxx | 5 sc/source/ui/miscdlgs/solveroptions.cxx | 3 sc/source/ui/miscdlgs/solverutil.cxx | 7 sc/source/ui/unoobj/PivotTableDataSequence.cxx | 11 - sc/source/ui/unoobj/cellvaluebinding.cxx | 17 - sc/source/ui/unoobj/chartuno.cxx | 27 +- sc/source/ui/unoobj/condformatuno.cxx | 19 - sc/source/ui/unoobj/dapiuno.cxx | 3 sc/source/ui/unoobj/datauno.cxx | 14 - sc/source/ui/unoobj/docuno.cxx | 55 ++--- sc/source/ui/unoobj/eventuno.cxx | 3 sc/source/ui/unoobj/linkuno.cxx | 9 sc/source/ui/unoobj/servuno.cxx | 22 -- sc/source/ui/unoobj/shapeuno.cxx | 13 - sc/source/ui/unoobj/tokenuno.cxx | 3 sc/source/ui/unoobj/viewuno.cxx | 21 - sc/source/ui/vba/vbaeventshelper.cxx | 65 ++---- sc/source/ui/vba/vbaglobals.cxx | 11 - sc/source/ui/vba/vbapagesetup.cxx | 3 sc/source/ui/vba/vbarange.cxx | 107 +++++----- sc/source/ui/vba/vbatitle.hxx | 7 sc/source/ui/vba/vbaworkbook.cxx | 12 - sc/source/ui/vba/vbaworkbooks.cxx | 24 -- sc/source/ui/vba/vbawsfunction.cxx | 10 sc/source/ui/view/gridwin.cxx | 3 sc/source/ui/view/viewfun4.cxx | 6 sc/source/ui/view/viewfunc.cxx | 5 78 files changed, 502 insertions(+), 590 deletions(-)
New commits: commit f528fff9b58e95ed572b226c0fec29f9a0464725 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Oct 29 09:57:41 2021 +0300 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Oct 30 21:55:53 2021 +0200 Prepare for removal of non-const operator[] from Sequence in sc Change-Id: Ic49c0fda3e98aeda471e674b68d40464ddac1ea1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124382 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 759f416ae490..42797af572da 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -16,6 +16,7 @@ #include <editeng/borderline.hxx> #include <svx/svdpage.hxx> #include <unotools/mediadescriptor.hxx> +#include <comphelper/propertyvalue.hxx> #include <docsh.hxx> #include <document.hxx> @@ -115,9 +116,7 @@ void ScMacrosTest::saveAndReload(css::uno::Reference<css::lang::XComponent>& xCo { utl::TempFile aTempFile; aTempFile.EnableKillingFile(); - css::uno::Sequence<css::beans::PropertyValue> aArgs(1); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= rFilter; + css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) }; css::uno::Reference<css::frame::XStorable> xStorable(xComponent, css::uno::UNO_QUERY_THROW); xStorable->storeAsURL(aTempFile.GetURL(), aArgs); css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); @@ -378,9 +377,7 @@ void ScMacrosTest::testVba() if ( bWorkbooksHandling ) { - aParams.realloc(2); - aParams[ 0 ] <<= sTempDir; - aParams[ 1 ] <<= sTestFileName; + aParams = { uno::Any(sTempDir), uno::Any(sTestFileName) }; } SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx index 6be41e688461..41731973ef78 100644 --- a/sc/qa/extras/sccellrangeobj.cxx +++ b/sc/qa/extras/sccellrangeobj.cxx @@ -235,8 +235,9 @@ void ScCellRangeObj::testSortOOB() xSortable->sort(aEmptyDescriptor); uno::Sequence<util::SortField> aSort(1); - aSort[0].Field = 0xffffff; - aSort[0].SortAscending = true; + auto pSort = aSort.getArray(); + pSort[0].Field = 0xffffff; + pSort[0].SortAscending = true; uno::Sequence<beans::PropertyValue> aProps( comphelper::InitPropertySequence({ { "SortFields", uno::Any(aSort) } })); diff --git a/sc/qa/extras/scindexenumeration_tableconditionalentryenumeration.cxx b/sc/qa/extras/scindexenumeration_tableconditionalentryenumeration.cxx index 920988263d58..bf3a03f8c715 100644 --- a/sc/qa/extras/scindexenumeration_tableconditionalentryenumeration.cxx +++ b/sc/qa/extras/scindexenumeration_tableconditionalentryenumeration.cxx @@ -27,6 +27,8 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Reference.hxx> +#include <comphelper/propertyvalue.hxx> + using namespace css; using namespace css::uno; @@ -73,17 +75,13 @@ uno::Reference<uno::XInterface> ScIndexEnumeration_TableConditionalEntryEnumerat xSheet0->getCellByPosition(1, 4)->setValue(10); xSheet0->getCellByPosition(2, 0)->setValue(-5.15); - uno::Sequence<beans::PropertyValue> aConditions(5); - aConditions[0].Name = "StyleName"; - aConditions[0].Value <<= OUString("Result2"); - aConditions[1].Name = "Formula1"; - aConditions[1].Value <<= OUString("$Sheet1.$B$5"); - aConditions[2].Name = "Formula2"; - aConditions[2].Value <<= OUString(""); - aConditions[3].Name = "Operator"; - aConditions[3].Value <<= sheet::ConditionOperator_EQUAL; - aConditions[4].Name = "SourcePosition"; - aConditions[4].Value <<= table::CellAddress(0, 1, 5); + uno::Sequence<beans::PropertyValue> aConditions{ + comphelper::makePropertyValue("StyleName", OUString("Result2")), + comphelper::makePropertyValue("Formula1", OUString("$Sheet1.$B$5")), + comphelper::makePropertyValue("Formula2", OUString("")), + comphelper::makePropertyValue("Operator", sheet::ConditionOperator_EQUAL), + comphelper::makePropertyValue("SourcePosition", table::CellAddress(0, 1, 5)) + }; uno::Reference<beans::XPropertySet> xPropertySet(xSheet0, uno::UNO_QUERY_THROW); uno::Reference<sheet::XSheetConditionalEntries> xSCE( diff --git a/sc/qa/extras/scmodelobj.cxx b/sc/qa/extras/scmodelobj.cxx index c5fcbd41cb14..1a5dcd013b3a 100644 --- a/sc/qa/extras/scmodelobj.cxx +++ b/sc/qa/extras/scmodelobj.cxx @@ -93,12 +93,10 @@ uno::Reference<uno::XInterface> ScModelObj::init() uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW); - m_xCells.realloc(3); - m_xCells[0] = xSheet->getCellByPosition(4, 5); + m_xCells = { xSheet->getCellByPosition(4, 5), xSheet->getCellByPosition(5, 5), + xSheet->getCellByPosition(6, 5) }; m_xCells[0]->setValue(15); - m_xCells[1] = xSheet->getCellByPosition(5, 5); m_xCells[1]->setValue(10); - m_xCells[2] = xSheet->getCellByPosition(6, 5); m_xCells[2]->setFormula("= E6 * F6"); return xModel; diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index 825c4e248403..9ccfa8edc978 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -26,6 +26,7 @@ #include <editeng/fontitem.hxx> #include <osl/file.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #if USE_TLS_NSS #include <nss.h> @@ -96,9 +97,7 @@ void ScPDFExportTest::setUp() CPPUNIT_ASSERT(xDesktop.is()); // Create spreadsheet - uno::Sequence<beans::PropertyValue> args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + uno::Sequence<beans::PropertyValue> args{ comphelper::makePropertyValue("Hidden", true) }; mxComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, args); CPPUNIT_ASSERT(mxComponent.is()); @@ -196,22 +195,18 @@ ScPDFExportTest::exportToPDF(const uno::Reference<frame::XModel>& xModel, const } // init special pdf export params - css::uno::Sequence<css::beans::PropertyValue> aFilterData(3); - aFilterData[0].Name = "Selection"; - aFilterData[0].Value <<= xCellRange; - aFilterData[1].Name = "Printing"; - aFilterData[1].Value <<= sal_Int32(2); - aFilterData[2].Name = "ViewPDFAfterExport"; - aFilterData[2].Value <<= true; + css::uno::Sequence<css::beans::PropertyValue> aFilterData{ + comphelper::makePropertyValue("Selection", xCellRange), + comphelper::makePropertyValue("Printing", sal_Int32(2)), + comphelper::makePropertyValue("ViewPDFAfterExport", true) + }; // init set of params for storeToURL() call - css::uno::Sequence<css::beans::PropertyValue> seqArguments(3); - seqArguments[0].Name = "FilterData"; - seqArguments[0].Value <<= aFilterData; - seqArguments[1].Name = "FilterName"; - seqArguments[1].Value <<= OUString("calc_pdf_Export"); - seqArguments[2].Name = "URL"; - seqArguments[2].Value <<= sFileURL; + css::uno::Sequence<css::beans::PropertyValue> seqArguments{ + comphelper::makePropertyValue("FilterData", aFilterData), + comphelper::makePropertyValue("FilterName", OUString("calc_pdf_Export")), + comphelper::makePropertyValue("URL", sFileURL) + }; // call storeToURL() uno::Reference<lang::XComponent> xComponent(mxComponent, UNO_SET_THROW); diff --git a/sc/qa/extras/scsubtotaldescriptorbase.cxx b/sc/qa/extras/scsubtotaldescriptorbase.cxx index 7b2b14365fc8..0bae1c46d74e 100644 --- a/sc/qa/extras/scsubtotaldescriptorbase.cxx +++ b/sc/qa/extras/scsubtotaldescriptorbase.cxx @@ -107,10 +107,8 @@ uno::Reference<uno::XInterface> ScSubTotalDescriptorBase::init() uno::Reference<sheet::XSubTotalCalculatable> xSTC(xSheet, uno::UNO_QUERY_THROW); uno::Reference<sheet::XSubTotalDescriptor> xSTD = xSTC->createSubTotalDescriptor(true); - uno::Sequence<sheet::SubTotalColumn> xCols; - xCols.realloc(1); - xCols[0].Column = 5; - xCols[0].Function = sheet::GeneralFunction_SUM; + uno::Sequence<sheet::SubTotalColumn> xCols{ { /* Column */ 5, + /* Function */ sheet::GeneralFunction_SUM } }; xSTD->addNew(xCols, 10); return xSTD; diff --git a/sc/qa/extras/scsubtotalfieldobj.cxx b/sc/qa/extras/scsubtotalfieldobj.cxx index 991ee7bed436..ab1a9c377150 100644 --- a/sc/qa/extras/scsubtotalfieldobj.cxx +++ b/sc/qa/extras/scsubtotalfieldobj.cxx @@ -67,10 +67,8 @@ uno::Reference<uno::XInterface> ScSubTotalFieldObj::init() uno::Reference<sheet::XSubTotalDescriptor> xSubTotalDesc = xSubTotalCalc->createSubTotalDescriptor(true); - uno::Sequence<sheet::SubTotalColumn> xCols; - xCols.realloc(1); - xCols[0].Column = 5; - xCols[0].Function = sheet::GeneralFunction_SUM; + uno::Sequence<sheet::SubTotalColumn> xCols{ { /* Column */ 5, + /* Function */ sheet::GeneralFunction_SUM } }; xSubTotalDesc->addNew(xCols, 1); uno::Reference<container::XIndexAccess> xDescIndex(xSubTotalDesc, uno::UNO_QUERY_THROW); diff --git a/sc/qa/extras/sctableconditionalentryobj.cxx b/sc/qa/extras/sctableconditionalentryobj.cxx index 519ee8fad638..cd5286745387 100644 --- a/sc/qa/extras/sctableconditionalentryobj.cxx +++ b/sc/qa/extras/sctableconditionalentryobj.cxx @@ -28,6 +28,8 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/XInterface.hpp> +#include <comphelper/propertyvalue.hxx> + using namespace css; using namespace css::uno; using namespace com::sun::star; @@ -83,17 +85,13 @@ uno::Reference<uno::XInterface> ScTableConditionalEntryObj::init() xSheetConditionalEntries.set(xPropSet->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW); - uno::Sequence<beans::PropertyValue> aPropValue(5); - aPropValue[0].Name = SC_UNONAME_STYLENAME; - aPropValue[0].Value <<= OUString("Result2"); - aPropValue[1].Name = SC_UNONAME_FORMULA1; - aPropValue[1].Value <<= OUString("$Sheet1.$B$5"); - aPropValue[2].Name = SC_UNONAME_FORMULA2; - aPropValue[2].Value <<= OUString(""); - aPropValue[3].Name = SC_UNONAME_OPERATOR; - aPropValue[3].Value <<= sheet::ConditionOperator_EQUAL; - aPropValue[4].Name = SC_UNONAME_SOURCEPOS; - aPropValue[4].Value <<= table::CellAddress(0, 1, 5); + uno::Sequence<beans::PropertyValue> aPropValue{ + comphelper::makePropertyValue(SC_UNONAME_STYLENAME, OUString("Result2")), + comphelper::makePropertyValue(SC_UNONAME_FORMULA1, OUString("$Sheet1.$B$5")), + comphelper::makePropertyValue(SC_UNONAME_FORMULA2, OUString("")), + comphelper::makePropertyValue(SC_UNONAME_OPERATOR, sheet::ConditionOperator_EQUAL), + comphelper::makePropertyValue(SC_UNONAME_SOURCEPOS, table::CellAddress(0, 1, 5)) + }; xSheetConditionalEntries->addNew(aPropValue); uno::Reference<sheet::XSheetConditionalEntry> xSheetConditionalEntry( diff --git a/sc/qa/extras/sctableconditionalformat.cxx b/sc/qa/extras/sctableconditionalformat.cxx index e26664bf5c14..99e1ad04b56d 100644 --- a/sc/qa/extras/sctableconditionalformat.cxx +++ b/sc/qa/extras/sctableconditionalformat.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <cppu/unotype.hxx> using namespace css; @@ -123,17 +124,13 @@ uno::Reference<uno::XInterface> ScTableConditionalFormat::init() uno::Sequence<beans::PropertyValue> ScTableConditionalFormat::createCondition(const sal_Int32 nr) { - uno::Sequence<beans::PropertyValue> aPropValue(5); - aPropValue[0].Name = SC_UNONAME_STYLENAME; - aPropValue[0].Value <<= OUString("Result2"); - aPropValue[1].Name = SC_UNONAME_FORMULA1; - aPropValue[1].Value <<= "$Sheet1.$B$" + OUString::number(nr); - aPropValue[2].Name = SC_UNONAME_FORMULA2; - aPropValue[2].Value <<= OUString(""); - aPropValue[3].Name = SC_UNONAME_OPERATOR; - aPropValue[3].Value <<= sheet::ConditionOperator_EQUAL; - aPropValue[4].Name = SC_UNONAME_SOURCEPOS; - aPropValue[4].Value <<= table::CellAddress(0, 1, 5); + uno::Sequence<beans::PropertyValue> aPropValue{ + comphelper::makePropertyValue(SC_UNONAME_STYLENAME, OUString("Result2")), + comphelper::makePropertyValue(SC_UNONAME_FORMULA1, "$Sheet1.$B$" + OUString::number(nr)), + comphelper::makePropertyValue(SC_UNONAME_FORMULA2, OUString("")), + comphelper::makePropertyValue(SC_UNONAME_OPERATOR, sheet::ConditionOperator_EQUAL), + comphelper::makePropertyValue(SC_UNONAME_SOURCEPOS, table::CellAddress(0, 1, 5)) + }; return aPropValue; } diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 2f30ecb05296..7fd56122216e 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include "helper/qahelper.hxx" #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <svx/svdocapt.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> @@ -376,9 +377,7 @@ void ScFiltersTest::testTdf91979() uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext()); CPPUNIT_ASSERT(xDesktop.is()); - Sequence < beans::PropertyValue > args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + Sequence < beans::PropertyValue > args{ comphelper::makePropertyValue("Hidden", true) }; uno::Reference< lang::XComponent > xComponent = xDesktop->loadComponentFromURL( "private:factory/scalc", @@ -554,9 +553,7 @@ void ScFiltersTest::testTdf128951() CPPUNIT_ASSERT(xDesktop.is()); // 1. Create spreadsheet - css::uno::Sequence<css::beans::PropertyValue> aHiddenArgList(1); - aHiddenArgList[0].Name = "Hidden"; - aHiddenArgList[0].Value <<= true; + css::uno::Sequence aHiddenArgList{ comphelper::makePropertyValue("Hidden", true) }; css::uno::Reference<css::lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, aHiddenArgList); @@ -716,9 +713,7 @@ void ScFiltersTest::testTdf130725() CPPUNIT_ASSERT(xDesktop.is()); // 1. Create spreadsheet - css::uno::Sequence<css::beans::PropertyValue> aHiddenArgList(1); - aHiddenArgList[0].Name = "Hidden"; - aHiddenArgList[0].Value <<= true; + css::uno::Sequence aHiddenArgList{ comphelper::makePropertyValue("Hidden", true) }; css::uno::Reference<css::lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, aHiddenArgList); diff --git a/sc/qa/unit/chart2dataprovider.cxx b/sc/qa/unit/chart2dataprovider.cxx index 9435267decd9..31af9ba6eef9 100644 --- a/sc/qa/unit/chart2dataprovider.cxx +++ b/sc/qa/unit/chart2dataprovider.cxx @@ -8,6 +8,8 @@ */ #include <sal/config.h> + +#include <comphelper/propertyvalue.hxx> #include <test/bootstrapfixture.hxx> #include <docsh.hxx> @@ -46,19 +48,12 @@ static void lcl_createAndCheckDataProvider(ScDocument& rDoc, const OUString& cel uno::Reference<chart2::data::XDataProvider> xDataProvider = new ScChart2DataProvider(&rDoc); CPPUNIT_ASSERT(xDataProvider.is()); - uno::Sequence<beans::PropertyValue> aArgs(4); - - aArgs[0].Name = "CellRangeRepresentation"; - aArgs[0].Value <<= cellRange; - - aArgs[1].Name = "HasCategories"; - aArgs[1].Value <<= hasCategories; - - aArgs[2].Name = "FirstCellAsLabel"; - aArgs[2].Value <<= firstCellAsLabel; - - aArgs[3].Name = "DataRowSource"; - aArgs[3].Value <<= chart::ChartDataRowSource_COLUMNS; + uno::Sequence<beans::PropertyValue> aArgs{ + comphelper::makePropertyValue("CellRangeRepresentation", cellRange), + comphelper::makePropertyValue("HasCategories", hasCategories), + comphelper::makePropertyValue("FirstCellAsLabel", firstCellAsLabel), + comphelper::makePropertyValue("DataRowSource", chart::ChartDataRowSource_COLUMNS) + }; uno::Reference<chart2::data::XDataSource> xDataSource = xDataProvider->createDataSource(aArgs); CPPUNIT_ASSERT(xDataSource.is()); diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index 7b8bffdf069d..736d84621288 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -13,6 +13,7 @@ #include <test/bootstrapfixture.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <docsh.hxx> #include <docfunc.hxx> @@ -131,9 +132,7 @@ void ScCopyPasteTest::testCopyPasteXLS() xDocSh->DoClose(); // 5. Create a new Spreadsheet - Sequence < beans::PropertyValue > args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + Sequence < beans::PropertyValue > args{ comphelper::makePropertyValue("Hidden", true) }; uno::Reference< lang::XComponent > xComponent = xDesktop->loadComponentFromURL( "private:factory/scalc", diff --git a/sc/qa/unit/jumbosheets-test.cxx b/sc/qa/unit/jumbosheets-test.cxx index 345e84b166df..6f94332ab149 100644 --- a/sc/qa/unit/jumbosheets-test.cxx +++ b/sc/qa/unit/jumbosheets-test.cxx @@ -14,6 +14,7 @@ #include <vcl/scheduler.hxx> #include <vcl/keycodes.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <defaultsoptions.hxx> #include <scmod.hxx> @@ -85,9 +86,7 @@ void ScFiltersTest::testTdf133033() = frame::Desktop::create(::comphelper::getProcessComponentContext()); CPPUNIT_ASSERT(xDesktop.is()); - Sequence<beans::PropertyValue> args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + Sequence<beans::PropertyValue> args{ comphelper::makePropertyValue("Hidden", true) }; m_xCalcComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, args); CPPUNIT_ASSERT(m_xCalcComponent.is()); diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index ad957d28b278..f08a909aac68 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -115,9 +115,8 @@ void ScShapeTest::saveAndReload(css::uno::Reference<css::lang::XComponent>& xCom { utl::TempFile aTempFile; aTempFile.EnableKillingFile(); - css::uno::Sequence<css::beans::PropertyValue> aArgs(1); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= rFilter; // e.g. "calc8" + css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", + rFilter) }; // e.g. "calc8" css::uno::Reference<css::frame::XStorable> xStorable(xComponent, css::uno::UNO_QUERY_THROW); xStorable->storeAsURL(aTempFile.GetURL(), aArgs); css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 53aaedb48288..8144a3cb988e 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -65,6 +65,7 @@ #include <editeng/colritem.hxx> #include <formula/grammar.hxx> #include <unotools/useroptions.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/scopeguard.hxx> #include <unotools/syslocaleoptions.hxx> #include <tools/datetime.hxx> @@ -1788,9 +1789,7 @@ void ScExportTest2::testTdf143979() = css::frame::Desktop::create(comphelper::getProcessComponentContext()); CPPUNIT_ASSERT(xDesktop); - css::uno::Sequence<css::beans::PropertyValue> args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + css::uno::Sequence args{ comphelper::makePropertyValue("Hidden", true) }; css::uno::Reference<css::lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, args); @@ -1841,9 +1840,7 @@ void ScExportTest2::testTdf120502() = css::frame::Desktop::create(comphelper::getProcessComponentContext()); CPPUNIT_ASSERT(xDesktop); - css::uno::Sequence<css::beans::PropertyValue> args(1); - args[0].Name = "Hidden"; - args[0].Value <<= true; + css::uno::Sequence args{ comphelper::makePropertyValue("Hidden", true) }; css::uno::Reference<css::lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, args); diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index d8aef459e4d5..ba51cc996969 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -314,10 +314,8 @@ void ScTiledRenderingTest::testRowColumnSelections() CPPUNIT_ASSERT_EQUAL(aExpected, aResult); // Select the 10th row with shift modifier - aArgs[0].Name = "Row"; - aArgs[0].Value <<= static_cast<sal_Int32>(10 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_SHIFT; + aArgs = comphelper::InitPropertySequence({ { "Row", uno::Any(static_cast<sal_Int32>(10 - 1)) }, + { "Modifier", uno::Any(KEY_SHIFT) } }); comphelper::dispatchCommand(".uno:SelectRow", aArgs); // Check if all the rows from 5th to 10th get selected @@ -326,10 +324,8 @@ void ScTiledRenderingTest::testRowColumnSelections() CPPUNIT_ASSERT_EQUAL(aExpected, aResult); // Select the 10th row with ctrl modifier - aArgs[0].Name = "Row"; - aArgs[0].Value <<= static_cast<sal_Int32>(13 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_MOD1; + aArgs = comphelper::InitPropertySequence({ { "Row", uno::Any(static_cast<sal_Int32>(13 - 1)) }, + { "Modifier", uno::Any(KEY_MOD1) } }); comphelper::dispatchCommand(".uno:SelectRow", aArgs); // When we copy this, we don't get anything useful, but we must not crash @@ -340,10 +336,8 @@ void ScTiledRenderingTest::testRowColumnSelections() // TODO check that we really selected what we wanted here // Select Column 5 with ctrl modifier - aArgs[0].Name = "Col"; - aArgs[0].Value <<= static_cast<sal_Int32>(5 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_MOD1; + aArgs = comphelper::InitPropertySequence({ { "Col", uno::Any(static_cast<sal_Int32>(5 - 1)) }, + { "Modifier", uno::Any(KEY_MOD1) } }); comphelper::dispatchCommand(".uno:SelectColumn", aArgs); // When we copy this, we don't get anything useful, but we must not crash @@ -355,24 +349,18 @@ void ScTiledRenderingTest::testRowColumnSelections() // Test for deselection of already selected rows // First Deselect Row 13 because copy doesn't work for multiple selections - aArgs[0].Name = "Row"; - aArgs[0].Value <<= static_cast<sal_Int32>(13 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_MOD1; + aArgs = comphelper::InitPropertySequence({ { "Row", uno::Any(static_cast<sal_Int32>(13 - 1)) }, + { "Modifier", uno::Any(KEY_MOD1) } }); comphelper::dispatchCommand(".uno:SelectRow", aArgs); // Deselect row 10 - aArgs[0].Name = "Row"; - aArgs[0].Value <<= static_cast<sal_Int32>(10 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_MOD1; + aArgs = comphelper::InitPropertySequence({ { "Row", uno::Any(static_cast<sal_Int32>(10 - 1)) }, + { "Modifier", uno::Any(KEY_MOD1) } }); comphelper::dispatchCommand(".uno:SelectRow", aArgs); // Click at row 6 holding shift - aArgs[0].Name = "Row"; - aArgs[0].Value <<= static_cast<sal_Int32>(6 - 1); - aArgs[1].Name = "Modifier"; - aArgs[1].Value <<= KEY_SHIFT; + aArgs = comphelper::InitPropertySequence({ { "Row", uno::Any(static_cast<sal_Int32>(6 - 1)) }, + { "Modifier", uno::Any(KEY_SHIFT) } }); comphelper::dispatchCommand(".uno:SelectRow", aArgs); // only row 5 should remain selected diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 1abbf6342ed8..f2541660d42b 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -17,6 +17,7 @@ #include <vcl/scheduler.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/scopeguard.hxx> #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/frame/Desktop.hpp> @@ -152,9 +153,7 @@ ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponen { utl::TempFile aTempFile; aTempFile.EnableKillingFile(); - css::uno::Sequence<css::beans::PropertyValue> aArgs(1); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= rFilter; + css::uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) }; css::uno::Reference<css::frame::XStorable> xStorable(xComponent, css::uno::UNO_QUERY_THROW); xStorable->storeAsURL(aTempFile.GetURL(), aArgs); css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 6ab518566663..244293510b4c 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -680,8 +680,7 @@ bool ScDocument::HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bW // check if VBA event handlers exist if (bWithVbaEvents && mxVbaEvents.is()) try { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= nTab; + uno::Sequence< uno::Any > aArgs{ uno::Any(nTab) }; if (mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ) || mxVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaDocumentEventId( nEvent ), uno::Sequence< uno::Any >() )) return true; diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx index 045f67f91424..67421451e99e 100644 --- a/sc/source/core/data/documen5.cxx +++ b/sc/source/core/data/documen5.cxx @@ -80,19 +80,20 @@ static void lcl_SetChartParameters( const uno::Reference< chart2::data::XDataRec if ( !xReceiver.is() ) return; - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - "CellRangeRepresentation", -1, - uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - "HasCategories", -1, - uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - "FirstCellAsLabel", -1, - uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - "DataRowSource", -1, - uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE ); + uno::Sequence< beans::PropertyValue > aArgs{ + beans::PropertyValue( + "CellRangeRepresentation", -1, + uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "HasCategories", -1, + uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "FirstCellAsLabel", -1, + uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "DataRowSource", -1, + uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE ) + }; xReceiver->setArguments( aArgs ); } @@ -189,12 +190,13 @@ void ScDocument::SetChartRanges( std::u16string_view rChartName, const ::std::ve sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() ); uno::Sequence< OUString > aRangeStrings(nCount); + auto aRangeStringsRange = asNonConstRange(aRangeStrings); for( sal_Int32 nN=0; nN<nCount; nN++ ) { ScRangeList aScRangeList( rRangesVector[nN] ); OUString sRangeStr; aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() ); - aRangeStrings[nN]=sRangeStr; + aRangeStringsRange[nN]=sRangeStr; } ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings ); } diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx index 19b1782076c2..b47fc43aeb8c 100644 --- a/sc/source/core/data/dpfilteredcache.cxx +++ b/sc/source/core/data/dpfilteredcache.cxx @@ -303,12 +303,13 @@ void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence // Header first. Sequence<Any> headerRow(nColSize); + auto pRow = headerRow.getArray(); for (SCCOL nCol = 0; nCol < nColSize; ++nCol) { OUString str = getFieldName( nCol); Any any; any <<= str; - headerRow[nCol] = any; + pRow[nCol] = any; } tableData.push_back(headerRow); @@ -328,6 +329,7 @@ void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence // Insert this row into table. Sequence<Any> row(nColSize); + pRow = row.getArray(); for (SCCOL nCol = 0; nCol < nColSize; ++nCol) { Any any; @@ -340,7 +342,7 @@ void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence OUString string (pData->GetString() ); any <<= string; } - row[nCol] = any; + pRow[nCol] = any; } tableData.push_back(row); } @@ -348,8 +350,9 @@ void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence // convert vector to Sequence sal_Int32 nTabSize = static_cast<sal_Int32>(tableData.size()); rTabData.realloc(nTabSize); + auto pTabData = rTabData.getArray(); for (sal_Int32 i = 0; i < nTabSize; ++i) - rTabData[i] = tableData[i]; + pTabData[i] = tableData[i]; } void ScDPFilteredCache::clear() diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 1bab5ce8ba40..a5ff421649fd 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1002,8 +1002,9 @@ bool ScDPObject::GetMemberNames( sal_Int32 nDim, Sequence<OUString>& rNames ) size_t n = aMembers.size(); rNames.realloc(n); + auto pNames = rNames.getArray(); for (size_t i = 0; i < n; ++i) - rNames[i] = aMembers[i].maName; + pNames[i] = aMembers[i].maName; return true; } @@ -1148,8 +1149,9 @@ bool ScDPObject::GetDataFieldPositionData( sal_Int32 n = static_cast<sal_Int32>(aFilters.size()); rFilters.realloc(n); + auto pFilters = rFilters.getArray(); for (sal_Int32 i = 0; i < n; ++i) - rFilters[i] = aFilters[i]; + pFilters[i] = aFilters[i]; return true; } @@ -1385,8 +1387,9 @@ double ScDPObject::GetPivotData(const OUString& rDataFieldName, std::vector<shee size_t n = rFilters.size(); uno::Sequence<sheet::DataPilotFieldFilter> aFilters(n); + auto aFiltersRange = asNonConstRange(aFilters); for (size_t i = 0; i < n; ++i) - aFilters[i] = rFilters[i]; + aFiltersRange[i] = rFilters[i]; uno::Sequence<double> aRes = xDPResults->getFilteredResults(aFilters); if (static_cast<sal_Int32>(nDataIndex) >= aRes.getLength()) diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index ada646b361fc..1297fb136afb 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -18,6 +18,8 @@ */ #include <scitems.hxx> + +#include <comphelper/sequence.hxx> #include <editeng/borderline.hxx> #include <editeng/boxitem.hxx> #include <editeng/wghtitem.hxx> @@ -1302,13 +1304,9 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa { vector<DataPilotFieldFilter> aFilters; GetDataResultPositionData(aFilters, rPos); - sal_Int32 nSize = aFilters.size(); DataPilotTableResultData aResData; - aResData.FieldFilters.realloc(nSize); - for (sal_Int32 i = 0; i < nSize; ++i) - aResData.FieldFilters[i] = aFilters[i]; - + aResData.FieldFilters = comphelper::containerToSequence(aFilters); aResData.DataFieldIndex = 0; Reference<beans::XPropertySet> xPropSet(xSource, UNO_QUERY); if (xPropSet.is()) diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 03b3d2280e79..60dfde3a03bf 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -396,12 +396,7 @@ uno::Sequence<double> ScDPSource::getFilteredResults( const ScDPResultTree::ValuesType* pVals = maResFilterSet.getResults(aFilters); if (pVals && !pVals->empty()) { - size_t n = pVals->size(); - uno::Sequence<double> aRet(n); - for (size_t i = 0; i < n; ++i) - aRet[i] = (*pVals)[i]; - - return aRet; + return comphelper::containerToSequence(*pVals); } if (aFilters.getLength() == 1) diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index e885f4c704bd..9c030ae1ac6f 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -467,24 +467,16 @@ void ScTable::SetColBreak(SCCOL nCol, bool bPage, bool bManual) Sequence<TablePageBreakData> ScTable::GetRowBreakData() const { - using ::std::copy; using ::std::inserter; set<SCROW> aRowBreaks = maRowPageBreaks; copy(maRowManualBreaks.begin(), maRowManualBreaks.end(), inserter(aRowBreaks, aRowBreaks.begin())); - sal_Int32 i = 0; Sequence<TablePageBreakData> aSeq(aRowBreaks.size()); - - for (const SCROW nRow : aRowBreaks) - { - TablePageBreakData aData; - aData.Position = nRow; - aData.ManualBreak = HasRowManualBreak(nRow); - aSeq[i] = aData; - ++i; - } + std::transform(aRowBreaks.begin(), aRowBreaks.end(), aSeq.getArray(), [this](const SCROW nRow) { + return TablePageBreakData(nRow, HasRowManualBreak(nRow)); + }); return aSeq; } diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 150a5d187d2a..594f28c5f738 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -193,29 +193,21 @@ bool ScValidationData::DoScript( const ScAddress& rPos, const OUString& rInput, bool bScriptReturnedFalse = false; // default: do not abort - // Set up parameters - css::uno::Sequence< css::uno::Any > aParams(2); - // 1) entered or calculated value - OUString aValStr = rInput; - double nValue; - bool bIsValue = false; + css::uno::Any aParam0(rInput); if ( pCell ) // if cell exists, call interpret { - bIsValue = pCell->IsValue(); - if ( bIsValue ) - nValue = pCell->GetValue(); + if ( pCell->IsValue() ) + aParam0 <<= pCell->GetValue(); else - aValStr = pCell->GetString().getString(); + aParam0 <<= pCell->GetString().getString(); } - if ( bIsValue ) - aParams[0] <<= nValue; - else - aParams[0] <<= aValStr; // 2) Position of the cell OUString aPosStr(rPos.Format(ScRefFlags::VALID | ScRefFlags::TAB_3D, pDocument, pDocument->GetAddressConvention())); - aParams[1] <<= aPosStr; + + // Set up parameters + css::uno::Sequence< css::uno::Any > aParams{ aParam0, css::uno::Any(aPosStr) }; // use link-update flag to prevent closing the document // while the macro is running diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx index b3bda1c529f0..32315565ace5 100644 --- a/sc/source/core/tool/charthelper.cxx +++ b/sc/source/core/tool/charthelper.cxx @@ -24,6 +24,7 @@ #include <chartlis.hxx> #include <docuno.hxx> +#include <comphelper/propertyvalue.hxx> #include <svx/svditer.hxx> #include <svx/svdoole2.hxx> #include <svx/svdpage.hxx> @@ -415,9 +416,9 @@ void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument& rDoc, co ScRange aRange( rDoc.GetRange( nTab, aRectangle ) ); ScRangeList aChangeRanges( aRange ); - uno::Sequence< beans::PropertyValue > aProperties( 1 ); - aProperties[ 0 ].Name = "Name"; - aProperties[ 0 ].Value <<= aChartName; + uno::Sequence< beans::PropertyValue > aProperties{ + comphelper::makePropertyValue("Name", aChartName) + }; pModelObj->NotifyChanges( "insert-chart", aChangeRanges, aProperties ); } diff --git a/sc/source/core/tool/formulaparserpool.cxx b/sc/source/core/tool/formulaparserpool.cxx index 94c47fa903e8..00c5c9108063 100644 --- a/sc/source/core/tool/formulaparserpool.cxx +++ b/sc/source/core/tool/formulaparserpool.cxx @@ -90,8 +90,7 @@ Reference< XFormulaParser > ScParserFactoryMap::createFormulaParser( FactoryMap::const_iterator aIt = maFactories.find( rNamespace ); if( aIt != maFactories.end() ) try { - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= rxComponent; + Sequence< Any > aArgs{ Any(rxComponent) }; xParser.set( aIt->second->createInstanceWithArgumentsAndContext( aArgs, mxContext ), UNO_QUERY_THROW ); } catch( Exception& ) diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 93fb46657fb4..929844886b66 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3134,9 +3134,8 @@ static bool lcl_setVBARange( const ScRange& aRange, const ScDocument& rDok, SbxV { uno::Reference< uno::XInterface > xVBARange; uno::Reference<table::XCellRange> xCellRange = ScCellRangeObj::CreateRangeFromDoc( rDok, aRange ); - uno::Sequence< uno::Any > aArgs(2); - aArgs[0] = lcl_getSheetModule( xCellRange, &rDok ); - aArgs[1] <<= xCellRange; + uno::Sequence< uno::Any > aArgs{ lcl_getSheetModule( xCellRange, &rDok ), + uno::Any(xCellRange) }; xVBARange = ooo::vba::createVBAUnoAPIServiceWithArgs( rDok.GetDocumentShell(), "ooo.vba.excel.Range", aArgs ); if ( xVBARange.is() ) { diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index 718d34559068..bf6ffd4a2c23 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -2399,10 +2399,9 @@ Reference< XChartType > XclImpChType::CreateChartType( Reference< XDiagram > con case EXC_CHTYPECATEG_BAR: { ScfPropertySet aTypeProp( xChartType ); - Sequence< sal_Int32 > aInt32Seq( 2 ); - aInt32Seq[ 0 ] = aInt32Seq[ 1 ] = -maData.mnOverlap; + Sequence< sal_Int32 > aInt32Seq{ -maData.mnOverlap, -maData.mnOverlap }; aTypeProp.SetProperty( EXC_CHPROP_OVERLAPSEQ, aInt32Seq ); - aInt32Seq[ 0 ] = aInt32Seq[ 1 ] = maData.mnGap; + aInt32Seq = { maData.mnGap, maData.mnGap }; aTypeProp.SetProperty( EXC_CHPROP_GAPWIDTHSEQ, aInt32Seq ); } break; @@ -3117,7 +3116,7 @@ void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) co // minor increment Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements; rSubIncrementSeq.realloc( 1 ); - Any& rIntervalCount = rSubIncrementSeq[ 0 ].IntervalCount; + Any& rIntervalCount = rSubIncrementSeq.getArray()[ 0 ].IntervalCount; rIntervalCount.clear(); if( bLogScale ) { diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 883c77beaf0c..01ee80649778 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -51,6 +51,7 @@ #include <vcl/wmf.hxx> #include <comphelper/classids.hxx> #include <comphelper/documentinfo.hxx> +#include <o3tl/safeint.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -1926,8 +1927,7 @@ void XclImpControlHelper::ApplySheetLinkProps() const aValue.Name = SC_UNONAME_BOUNDCELL; aValue.Value <<= aApiAddress; - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(aValue) }; // create the CellValueBinding instance and set at the control model OUString aServiceName; @@ -1960,8 +1960,7 @@ void XclImpControlHelper::ApplySheetLinkProps() const aValue.Name = SC_UNONAME_CELLRANGE; aValue.Value <<= aApiRange; - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(aValue) }; // create the EntrySource instance and set at the control model Reference< XListEntrySource > xEntrySource( xFactory->createInstanceWithArguments( @@ -2897,8 +2896,7 @@ void XclImpDropDownObj::DoProcessControl( ScfPropertySet& rPropSet ) const // selection (do not set, if dropdown is linked to a cell) if( !HasCellLink() && (mnSelEntry > 0) ) { - Sequence< sal_Int16 > aSelSeq( 1 ); - aSelSeq[ 0 ] = mnSelEntry - 1; + Sequence< sal_Int16 > aSelSeq{ o3tl::narrowing<sal_Int16>(mnSelEntry - 1) }; rPropSet.SetProperty( "DefaultSelection", aSelSeq ); } } diff --git a/sc/source/filter/excel/xltoolbar.cxx b/sc/source/filter/excel/xltoolbar.cxx index c4178ccafea1..40759538405a 100644 --- a/sc/source/filter/excel/xltoolbar.cxx +++ b/sc/source/filter/excel/xltoolbar.cxx @@ -15,6 +15,7 @@ #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/ItemType.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <map> @@ -315,9 +316,8 @@ bool ScTBC::ImportToolBarControl( ScCTBWrapper& rWrapper, const css::uno::Refere if ( bBeginGroup ) { // insert spacer - uno::Sequence< beans::PropertyValue > sProps( 1 ); - sProps[ 0 ].Name = "Type"; - sProps[ 0 ].Value <<= ui::ItemType::SEPARATOR_LINE; + uno::Sequence sProps{ comphelper::makePropertyValue("Type", + ui::ItemType::SEPARATOR_LINE) }; toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) ); } toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( comphelper::containerToSequence(props) ) ); diff --git a/sc/source/filter/excel/xltracer.cxx b/sc/source/filter/excel/xltracer.cxx index c04d186a5a60..c6931dbf01d8 100644 --- a/sc/source/filter/excel/xltracer.cxx +++ b/sc/source/filter/excel/xltracer.cxx @@ -25,13 +25,10 @@ using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::PropertyValue; -XclTracer::XclTracer(const OUString& rDocUrl) +XclTracer::XclTracer(std::u16string_view /*rDocUrl*/) : mbEnabled(false) , maFirstTimes(eTraceLength, true) { - Sequence<PropertyValue> aConfigData(1); - aConfigData[0].Name = "DocumentURL"; - aConfigData[0].Value <<= rDocUrl; } XclTracer::~XclTracer() {} diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index b08f3bed1c5a..1d6e982120e4 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -288,6 +288,7 @@ ScfPropSetHelper::ScfPropSetHelper( const char* const* ppcPropNames ) : // resize member sequences size_t nSize = aPropNameVec.size(); maNameSeq.realloc( static_cast< sal_Int32 >( nSize ) ); + auto pNameSeq = maNameSeq.getArray(); maValueSeq.realloc( static_cast< sal_Int32 >( nSize ) ); maNameOrder.resize( nSize ); @@ -295,7 +296,7 @@ ScfPropSetHelper::ScfPropSetHelper( const char* const* ppcPropNames ) : sal_Int32 nSeqIdx = 0; for( auto& aPropName : aPropNameVec ) { - maNameSeq[ nSeqIdx ] = aPropName.first; + pNameSeq[ nSeqIdx ] = aPropName.first; maNameOrder[ aPropName.second ] = nSeqIdx; ++nSeqIdx; } @@ -361,7 +362,7 @@ Any* ScfPropSetHelper::GetNextAny() OSL_ENSURE( mnNextIdx < maNameOrder.size(), "ScfPropSetHelper::GetNextAny - sequence overflow" ); Any* pAny = nullptr; if( mnNextIdx < maNameOrder.size() ) - pAny = &maValueSeq[ maNameOrder[ mnNextIdx++ ] ]; + pAny = &maValueSeq.getArray()[ maNameOrder[ mnNextIdx++ ] ]; return pAny; } diff --git a/sc/source/filter/inc/xltracer.hxx b/sc/source/filter/inc/xltracer.hxx index 3286d45f46d0..eef1901398f3 100644 --- a/sc/source/filter/inc/xltracer.hxx +++ b/sc/source/filter/inc/xltracer.hxx @@ -50,7 +50,7 @@ enum XclTracerId class XclTracer final { public: - explicit XclTracer( const OUString& rDocUrl ); + explicit XclTracer( std::u16string_view rDocUrl ); ~XclTracer(); /** Returns true, if tracing is enabled. */ diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index 5779bd1e5e9c..6bffe8e53b25 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -170,8 +170,9 @@ void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, double fVal rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR; rFilterField.Operator = nOperator; rFilterField.Values.realloc(1); - rFilterField.Values[0].FilterType = FilterFieldType::NUMERIC; - rFilterField.Values[0].NumericValue = fValue; + auto pValues = rFilterField.Values.getArray(); + pValues[0].FilterType = FilterFieldType::NUMERIC; + pValues[0].NumericValue = fValue; } void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, const OUString& rValue ) @@ -181,8 +182,9 @@ void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, const OUStr rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR; rFilterField.Operator = nOperator; rFilterField.Values.realloc(1); - rFilterField.Values[0].FilterType = FilterFieldType::STRING; - rFilterField.Values[0].StringValue = rValue; + auto pValues = rFilterField.Values.getArray(); + pValues[0].FilterType = FilterFieldType::STRING; + pValues[0].StringValue = rValue; } void ApiFilterSettings::appendField(bool bAnd, util::Color aColor, bool bIsBackgroundColor) @@ -192,9 +194,10 @@ void ApiFilterSettings::appendField(bool bAnd, util::Color aColor, bool bIsBackg rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR; rFilterField.Operator = FilterOperator2::EQUAL; rFilterField.Values.realloc(1); - rFilterField.Values[0].FilterType + auto pValues = rFilterField.Values.getArray(); + pValues[0].FilterType = bIsBackgroundColor ? FilterFieldType::BACKGROUND_COLOR : FilterFieldType::TEXT_COLOR; - rFilterField.Values[0].ColorValue = aColor; + pValues[0].ColorValue = aColor; } void ApiFilterSettings::appendField( bool bAnd, const std::vector<std::pair<OUString, bool>>& rValues ) @@ -204,12 +207,13 @@ void ApiFilterSettings::appendField( bool bAnd, const std::vector<std::pair<OUSt rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR; rFilterField.Operator = FilterOperator2::EQUAL; rFilterField.Values.realloc(rValues.size()); + auto pValues = rFilterField.Values.getArray(); size_t i = 0; for( auto const& it : rValues ) { - rFilterField.Values[i].StringValue = it.first; - rFilterField.Values[i++].FilterType + pValues[i].StringValue = it.first; + pValues[i++].FilterType = it.second ? FilterFieldType::DATE : FilterFieldType::STRING; } } diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx index a366b17e0dd4..10927027d65e 100644 --- a/sc/source/filter/oox/drawingfragment.cxx +++ b/sc/source/filter/oox/drawingfragment.cxx @@ -20,6 +20,8 @@ #include <drawingfragment.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <comphelper/propertyvalue.hxx> + #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexContainer.hpp> @@ -80,11 +82,8 @@ void ShapeMacroAttacher::attachMacro( const OUString& rMacroUrl ) { Reference< XEventsSupplier > xSupplier( mxShape, UNO_QUERY_THROW ); Reference< XNameReplace > xEvents( xSupplier->getEvents(), UNO_SET_THROW ); - Sequence< PropertyValue > aEventProps( 2 ); - aEventProps[ 0 ].Name = "EventType"; - aEventProps[ 0 ].Value <<= OUString( "Script" ); - aEventProps[ 1 ].Name = "Script"; - aEventProps[ 1 ].Value <<= rMacroUrl; + Sequence aEventProps{ comphelper::makePropertyValue("EventType", OUString( "Script" )), + comphelper::makePropertyValue("Script", rMacroUrl) }; xEvents->replaceByName( "OnClick", Any( aEventProps ) ); } catch( Exception& ) diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx index 926289134d16..45a6a8fbcdd8 100644 --- a/sc/source/filter/oox/viewsettings.cxx +++ b/sc/source/filter/oox/viewsettings.cxx @@ -626,11 +626,8 @@ void ViewSettings::finalizeImport() if( aRangeProp.getProperty( aPos, PROP_Position ) && aRangeProp.getProperty( aSize, PROP_Size ) ) { // set the visible area as sequence of long at the media descriptor - Sequence< sal_Int32 > aWinExtent( 4 ); - aWinExtent[ 0 ] = aPos.X; - aWinExtent[ 1 ] = aPos.Y; - aWinExtent[ 2 ] = aPos.X + aSize.Width; - aWinExtent[ 3 ] = aPos.Y + aSize.Height; + Sequence< sal_Int32 > aWinExtent{ aPos.X, aPos.Y, + aPos.X + aSize.Width, aPos.Y + aSize.Height }; getBaseFilter().getMediaDescriptor()[ "WinExtent" ] <<= aWinExtent; } } diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx index ae2aa82e1a31..f23afc412012 100644 --- a/sc/source/filter/oox/workbooksettings.cxx +++ b/sc/source/filter/oox/workbooksettings.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/util/Date.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <comphelper/propertyvalue.hxx> #include <unotools/mediadescriptor.hxx> #include <oox/core/binarycodec.hxx> #include <oox/core/filterbase.hxx> @@ -212,16 +214,12 @@ void WorkbookSettings::finalizeImport() if (!maFileSharing.maHashValue.isEmpty()) { - Sequence<PropertyValue> aResult; - aResult.realloc(4); - aResult[0].Name = "algorithm-name"; - aResult[0].Value <<= maFileSharing.maAlgorithmName; - aResult[1].Name = "salt"; - aResult[1].Value <<= maFileSharing.maSaltValue; - aResult[2].Name = "iteration-count"; - aResult[2].Value <<= maFileSharing.mnSpinCount; - aResult[3].Name = "hash"; - aResult[3].Value <<= maFileSharing.maHashValue; + Sequence<PropertyValue> aResult{ + comphelper::makePropertyValue("algorithm-name", maFileSharing.maAlgorithmName), + comphelper::makePropertyValue("salt", maFileSharing.maSaltValue), + comphelper::makePropertyValue("iteration-count", maFileSharing.mnSpinCount), + comphelper::makePropertyValue("hash", maFileSharing.maHashValue) + }; aSettingsProp.setProperty(PROP_ModifyPasswordInfo, aResult); } diff --git a/sc/source/filter/xml/XMLCodeNameProvider.cxx b/sc/source/filter/xml/XMLCodeNameProvider.cxx index 103a157e447a..063729d5c2f8 100644 --- a/sc/source/filter/xml/XMLCodeNameProvider.cxx +++ b/sc/source/filter/xml/XMLCodeNameProvider.cxx @@ -20,6 +20,8 @@ #include "XMLCodeNameProvider.hxx" #include <document.hxx> #include <com/sun/star/beans/PropertyValue.hpp> + +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> using namespace com::sun::star; @@ -80,13 +82,10 @@ sal_Bool SAL_CALL XMLCodeNameProvider::hasByName( const OUString& aName ) uno::Any SAL_CALL XMLCodeNameProvider::getByName( const OUString& aName ) { uno::Any aRet; - uno::Sequence<beans::PropertyValue> aProps(1); - aProps[0].Name = gsCodeNameProp; if( aName == gsDocName ) { OUString sUCodeName( mpDoc->GetCodeName() ); - aProps[0].Value <<= sUCodeName; - aRet <<= aProps; + aRet <<= uno::Sequence{ comphelper::makePropertyValue(gsCodeNameProp, sUCodeName) }; return aRet; } @@ -97,8 +96,7 @@ uno::Any SAL_CALL XMLCodeNameProvider::getByName( const OUString& aName ) if( mpDoc->GetName( i, sSheetName ) && sSheetName == aName ) { mpDoc->GetCodeName( i, sCodeName ); - aProps[0].Value <<= sCodeName; - aRet <<= aProps; + aRet <<= uno::Sequence{ comphelper::makePropertyValue(gsCodeNameProp, sCodeName) }; return aRet; } } diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx index 9d596740ef74..a44168aebe7b 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -302,7 +302,7 @@ std::unique_ptr<ScDBData> ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr table::TableOrientation eOrient = mpQueryParam->bByRow ? table::TableOrientation_ROWS : table::TableOrientation_COLUMNS; aProperty.Value <<= eOrient; - aSortSequence[nOldSize] = aProperty; + aSortSequence.getArray()[nOldSize] = aProperty; ScSortParam aParam; ScSortDescriptor::FillSortParam(aParam, aSortSequence); diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx index 25e6d8c39d7d..a35074117c28 100644 --- a/sc/source/filter/xml/xmldrani.hxx +++ b/sc/source/filter/xml/xmldrani.hxx @@ -232,7 +232,7 @@ public: void AddSubTotalColumn(const css::sheet::SubTotalColumn& rSubTotalColumn) { aSubTotalRule.aSubTotalColumns.realloc(aSubTotalRule.aSubTotalColumns.getLength() + 1); - aSubTotalRule.aSubTotalColumns[aSubTotalRule.aSubTotalColumns.getLength() - 1] = rSubTotalColumn; + aSubTotalRule.aSubTotalColumns.getArray()[aSubTotalRule.aSubTotalColumns.getLength() - 1] = rSubTotalColumn; } }; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 1de7927c9634..cf68ebfb1854 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -5238,22 +5238,23 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& sal_Int32 nCount(rProps.getLength()); rProps.realloc(nCount + nPropsToAdd); + auto pProps = rProps.getArray(); if (!aTrackedChangesKey.isEmpty()) { - rProps[nCount].Name = "TrackedChangesProtectionKey"; - rProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear(); + pProps[nCount].Name = "TrackedChangesProtectionKey"; + pProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear(); ++nCount; } if( bVBACompat ) { - rProps[nCount].Name = "VBACompatibilityMode"; - rProps[nCount].Value <<= bVBACompat; + pProps[nCount].Name = "VBACompatibilityMode"; + pProps[nCount].Value <<= bVBACompat; ++nCount; } if( xCodeNameAccess.is() ) { - rProps[nCount].Name = "ScriptConfiguration"; - rProps[nCount].Value <<= xCodeNameAccess; + pProps[nCount].Name = "ScriptConfiguration"; + pProps[nCount].Value <<= xCodeNameAccess; ++nCount; } } diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 1658d4781a25..d2d36d634caf 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -749,6 +749,7 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa sal_Int32 nCount(aConfigProps.getLength()); css::uno::Sequence<css::beans::PropertyValue> aFilteredProps(nCount); + auto pFilteredProps = aFilteredProps.getArray(); sal_Int32 nFilteredPropsLen = 0; for (sal_Int32 i = nCount - 1; i >= 0; --i) { @@ -786,7 +787,7 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa } if (aConfigProps[i].Name != "LinkUpdateMode") { - aFilteredProps[nFilteredPropsLen++] = aConfigProps[i]; + pFilteredProps[nFilteredPropsLen++] = aConfigProps[i]; } } aFilteredProps.realloc(nFilteredPropsLen); @@ -1693,8 +1694,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream) { { "UserData", uno::Any(aUserData) }, })); - css::uno::Sequence<uno::Any> aOuterArgs(1); - aOuterArgs[0] <<= aAdaptorArgs; + css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) }; uno::Reference<lang::XInitialization> xInit(xInterface, uno::UNO_QUERY_THROW); xInit->initialize(aOuterArgs); diff --git a/sc/source/filter/xml/xmlsorti.cxx b/sc/source/filter/xml/xmlsorti.cxx index db12134a38b6..6fab95c1d383 100644 --- a/sc/source/filter/xml/xmlsorti.cxx +++ b/sc/source/filter/xml/xmlsorti.cxx @@ -134,29 +134,30 @@ void SAL_CALL ScXMLSortContext::endFastElement( sal_Int32 /*nElement*/ ) if (nAlgoLength) ++i; uno::Sequence <beans::PropertyValue> aSortDescriptor(7 + i); - aSortDescriptor[0].Name = SC_UNONAME_BINDFMT; - aSortDescriptor[0].Value <<= bBindFormatsToContent; - aSortDescriptor[1].Name = SC_UNONAME_COPYOUT; - aSortDescriptor[1].Value <<= bCopyOutputData; - aSortDescriptor[2].Name = SC_UNONAME_ISCASE; - aSortDescriptor[2].Value <<= bIsCaseSensitive; - aSortDescriptor[3].Name = SC_UNONAME_ISULIST; - aSortDescriptor[3].Value <<= bEnabledUserList; - aSortDescriptor[4].Name = SC_UNONAME_OUTPOS; - aSortDescriptor[4].Value <<= aOutputPosition; - aSortDescriptor[5].Name = SC_UNONAME_UINDEX; - aSortDescriptor[5].Value <<= nUserListIndex; - aSortDescriptor[6].Name = SC_UNONAME_SORTFLD; - aSortDescriptor[6].Value <<= aSortFields; + auto pSortDescriptor = aSortDescriptor.getArray(); + pSortDescriptor[0].Name = SC_UNONAME_BINDFMT; + pSortDescriptor[0].Value <<= bBindFormatsToContent; + pSortDescriptor[1].Name = SC_UNONAME_COPYOUT; + pSortDescriptor[1].Value <<= bCopyOutputData; + pSortDescriptor[2].Name = SC_UNONAME_ISCASE; + pSortDescriptor[2].Value <<= bIsCaseSensitive; + pSortDescriptor[3].Name = SC_UNONAME_ISULIST; + pSortDescriptor[3].Value <<= bEnabledUserList; + pSortDescriptor[4].Name = SC_UNONAME_OUTPOS; + pSortDescriptor[4].Value <<= aOutputPosition; + pSortDescriptor[5].Name = SC_UNONAME_UINDEX; + pSortDescriptor[5].Value <<= nUserListIndex; + pSortDescriptor[6].Name = SC_UNONAME_SORTFLD; + pSortDescriptor[6].Value <<= aSortFields; if (!maLanguageTagODF.isEmpty()) { - aSortDescriptor[7].Name = SC_UNONAME_COLLLOC; - aSortDescriptor[7].Value <<= maLanguageTagODF.getLanguageTag().getLocale( false); + pSortDescriptor[7].Name = SC_UNONAME_COLLLOC; + pSortDescriptor[7].Value <<= maLanguageTagODF.getLanguageTag().getLocale( false); } if (nAlgoLength) { - aSortDescriptor[6 + i].Name = SC_UNONAME_COLLALG; - aSortDescriptor[6 + i].Value <<= sAlgorithm; + pSortDescriptor[6 + i].Name = SC_UNONAME_COLLALG; + pSortDescriptor[6 + i].Value <<= sAlgorithm; } pDatabaseRangeContext->SetSortSequence(aSortDescriptor); } @@ -192,7 +193,7 @@ void ScXMLSortContext::AddSortField(const OUString& sFieldNumber, const OUString aSortField.FieldType = util::SortFieldType_NUMERIC; } aSortFields.realloc(aSortFields.getLength() + 1); - aSortFields[aSortFields.getLength() - 1] = aSortField; + aSortFields.getArray()[aSortFields.getLength() - 1] = aSortField; } ScXMLSortByContext::ScXMLSortByContext( ScXMLImport& rImport, diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx index 8bd4cef661bd..7db93dbe6d25 100644 --- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx +++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx @@ -237,13 +237,14 @@ static void lcl_FillFontAttributes( Sequence< PropertyValue >& rSeq, const vcl:: SvxLanguageItem aLangItem( rFont.GetLanguage(), ATTR_FONT_LANGUAGE ); sal_Int32 nIndex = lcl_ExpandSequence( rSeq, 7 ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharFontName", aFontItem, MID_FONT_FAMILY_NAME ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharFontFamily", aFontItem, MID_FONT_FAMILY ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharFontStyleName", aFontItem, MID_FONT_STYLE_NAME ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharFontCharSet", aFontItem, MID_FONT_PITCH ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharFontPitch", aFontItem, MID_FONT_CHAR_SET ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharHeight", aHeightItem, MID_FONTHEIGHT ); - lcl_FillProperty( rSeq[ nIndex++ ], "CharLocale", aLangItem, MID_LANG_LOCALE ); + auto pSeq = rSeq.getArray(); + lcl_FillProperty( pSeq[ nIndex++ ], "CharFontName", aFontItem, MID_FONT_FAMILY_NAME ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharFontFamily", aFontItem, MID_FONT_FAMILY ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharFontStyleName", aFontItem, MID_FONT_STYLE_NAME ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharFontCharSet", aFontItem, MID_FONT_PITCH ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharFontPitch", aFontItem, MID_FONT_CHAR_SET ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharHeight", aHeightItem, MID_FONTHEIGHT ); + lcl_FillProperty( pSeq[ nIndex++ ], "CharLocale", aLangItem, MID_LANG_LOCALE ); } ScAccessibleCsvRuler::ScAccessibleCsvRuler(ScCsvRuler& rRuler) @@ -300,8 +301,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessible css::uno::Reference<css::accessibility::XAccessible> xAccObj(static_cast<ScAccessibleCsvGrid*>(rGrid.GetAccessible())); if( xAccObj.is() ) { - Sequence< Reference< XInterface > > aSeq( 1 ); - aSeq[ 0 ] = xAccObj; + Sequence< Reference< XInterface > > aSeq{ xAccObj }; pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLER_FOR, aSeq ) ); } @@ -862,8 +862,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleR css::uno::Reference<css::accessibility::XAccessible> xAccObj(static_cast<ScAccessibleCsvGrid*>(rRuler.GetAccessible())); if( xAccObj.is() ) { - Sequence< Reference< XInterface > > aSeq( 1 ); - aSeq[ 0 ] = xAccObj; + Sequence< Reference< XInterface > > aSeq{ xAccObj }; pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLED_BY, aSeq ) ); } } @@ -959,11 +958,12 @@ Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleColumns ScCsvGrid& rGrid = implGetGrid(); Sequence< sal_Int32 > aSeq( implGetColumnCount() ); + auto pSeq = aSeq.getArray(); sal_Int32 nSeqIx = 0; sal_uInt32 nColIx = rGrid.GetFirstSelected(); for( ; nColIx != CSV_COLUMN_INVALID; ++nSeqIx, nColIx = rGrid.GetNextSelected( nColIx ) ) - aSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx ); + pSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx ); aSeq.realloc( nSeqIx ); return aSeq; diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 0ac7d931d6e6..913a2984421f 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -900,8 +900,7 @@ rtl::Reference<utl::AccessibleRelationSetHelper> ScChildrenShapes::GetRelationSe pRelationSet = new utl::AccessibleRelationSetHelper(); AccessibleRelation aRelation; - aRelation.TargetSet.realloc(1); - aRelation.TargetSet[0] = Get(pAccShapeData); + aRelation.TargetSet = { Get(pAccShapeData) }; aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR; pRelationSet->AddRelation(aRelation); @@ -1154,8 +1153,7 @@ uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const Sc } } AccessibleRelation aRelation; - aRelation.TargetSet.realloc(1); - aRelation.TargetSet[0] = xAccessible; + aRelation.TargetSet = { xAccessible }; aRelation.RelationType = AccessibleRelationType::CONTROLLED_BY; pRelationSet->AddRelation(aRelation); } diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx index 09f6cf59e522..2f2cb48f6b5c 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx @@ -536,7 +536,7 @@ uno::Sequence<OUString> SAL_CALL ScAccessiblePreviewTable::getSupportedServiceNa sal_Int32 nOldSize(aSequence.getLength()); aSequence.realloc(nOldSize + 1); - aSequence[nOldSize] = "com.sun.star.table.AccessibleTableView"; + aSequence.getArray()[nOldSize] = "com.sun.star.table.AccessibleTableView"; return aSequence; } diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx index 9ec585712587..7d3443bb029c 100644 --- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx +++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <tbzoomsliderctrl.hxx> + +#include <comphelper/propertyvalue.hxx> #include <vcl/InterimItemWindow.hxx> #include <vcl/event.hxx> #include <vcl/image.hxx> @@ -261,9 +263,7 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt ) css::uno::Any a; aZoomSliderItem.QueryValue( a ); - css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "ScalingFactor"; - aArgs[0].Value = a; + css::uno::Sequence aArgs{ comphelper::makePropertyValue("ScalingFactor", a) }; SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:ScalingFactor", aArgs ); @@ -298,9 +298,7 @@ bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt ) css::uno::Any a; aZoomSliderItem.QueryValue( a ); - css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "ScalingFactor"; - aArgs[0].Value = a; + css::uno::Sequence aArgs{ comphelper::makePropertyValue("ScalingFactor", a) }; SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:ScalingFactor", aArgs ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 7b7c727e8e1e..f0f82517a844 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -26,6 +26,7 @@ #include <editeng/justifyitem.hxx> #include <comphelper/fileformat.h> #include <comphelper/classids.hxx> +#include <comphelper/propertyvalue.hxx> #include <formula/errorcodes.hxx> #include <vcl/stdtext.hxx> #include <vcl/svapp.hxx> @@ -648,8 +649,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = m_aDocument.GetVbaEventProcessor(); if ( xVbaEvents.is() ) try { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[0] <<= pScHint->GetTab1(); + uno::Sequence< uno::Any > aArgs{ uno::Any(pScHint->GetTab1()) }; xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_NEWSHEET, aArgs ); } catch( uno::Exception& ) @@ -893,16 +893,19 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW ); // TODO/LATER: More entries from the MediaDescriptor might be interesting for the merge - uno::Sequence< beans::PropertyValue > aValues(1); - aValues[0].Name = "FilterName"; - aValues[0].Value <<= GetMedium()->GetFilter()->GetFilterName(); + uno::Sequence< beans::PropertyValue > aValues{ + comphelper::makePropertyValue( + "FilterName", + GetMedium()->GetFilter()->GetFilterName()) + }; const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false); if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() ) { aValues.realloc( 2 ); - aValues[1].Name = "Password"; - aValues[1].Value <<= pPasswordItem->GetValue(); + auto pValues = aValues.getArray(); + pValues[1].Name = "Password"; + pValues[1].Value <<= pPasswordItem->GetValue(); } SC_MOD()->SetInSharedDocSaving( true ); @@ -1049,8 +1052,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { uno::Any aWorkbook; aWorkbook <<= mxAutomationWorkbookObject; - uno::Sequence< uno::Any > aArgs(1); - aArgs[0] = aWorkbook; + uno::Sequence< uno::Any > aArgs{ aWorkbook }; SC_MOD()->CallAutomationApplicationEventSinks( "NewWorkbook", aArgs ); } break; @@ -1058,8 +1060,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { uno::Any aWorkbook; aWorkbook <<= mxAutomationWorkbookObject; - uno::Sequence< uno::Any > aArgs(1); - aArgs[0] = aWorkbook; + uno::Sequence< uno::Any > aArgs{ aWorkbook }; SC_MOD()->CallAutomationApplicationEventSinks( "WorkbookOpen", aArgs ); } break; @@ -2718,8 +2719,7 @@ bool ScDocShell::QuerySlotExecutable( sal_uInt16 nSlotId ) case SID_SAVEDOC: case SID_SAVEASDOC: nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE; - aArgs.realloc( 1 ); - aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); + aArgs = { uno::Any(nSlotId == SID_SAVEASDOC) }; break; case SID_PRINTDOC: case SID_PRINTDOCDIRECT: diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index bba2d90a0a71..e4fb0ee54627 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -60,6 +60,7 @@ using namespace ::com::sun::star; #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <docuno.hxx> #include <docsh.hxx> @@ -2724,9 +2725,7 @@ uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument() { SC_MOD()->SetInSharedDocLoading( true ); uno::Reference< frame::XDesktop2 > xLoader = frame::Desktop::create( ::comphelper::getProcessComponentContext() ); - uno::Sequence < beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "Hidden"; - aArgs[0].Value <<= true; + uno::Sequence aArgs{ comphelper::makePropertyValue("Hidden", true) }; if ( GetMedium() ) { @@ -2734,15 +2733,17 @@ uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument() if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() ) { aArgs.realloc( 2 ); - aArgs[1].Name = "Password"; - aArgs[1].Value <<= pPasswordItem->GetValue(); + auto pArgs = aArgs.getArray(); + pArgs[1].Name = "Password"; + pArgs[1].Value <<= pPasswordItem->GetValue(); } const SfxUnoAnyItem* pEncryptionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false); if (pEncryptionItem) { aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1].Name = "EncryptionData"; - aArgs[aArgs.getLength() - 1].Value = pEncryptionItem->GetValue(); + auto pArgs = aArgs.getArray(); + pArgs[aArgs.getLength() - 1].Name = "EncryptionData"; + pArgs[aArgs.getLength() - 1].Value = pEncryptionItem->GetValue(); } } diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 3b46a14e190d..df7a0c37d474 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -180,19 +180,20 @@ void lcl_ChartInit(const uno::Reference <embed::XEmbeddedObject>& xObj, ScViewDa } } - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - "CellRangeRepresentation", -1, - uno::makeAny( aRangeString ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - "HasCategories", -1, - uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - "FirstCellAsLabel", -1, - uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - "DataRowSource", -1, - uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE ); + uno::Sequence< beans::PropertyValue > aArgs{ + beans::PropertyValue( + "CellRangeRepresentation", -1, + uno::makeAny( aRangeString ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "HasCategories", -1, + uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "FirstCellAsLabel", -1, + uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "DataRowSource", -1, + uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE ) + }; try { diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index c331dddcb539..0905e67f91af 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -921,6 +921,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) * ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 ); aConstraints.realloc( nConstrPos + nAdd ); + auto pConstraints = aConstraints.getArray(); for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow) for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol) @@ -931,7 +932,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ), aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) ); - aConstraints[nConstrPos++] = aConstraint; + pConstraints[nConstrPos++] = aConstraint; } } } @@ -964,7 +965,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal } aConstraints.realloc( nConstrPos + 1 ); - aConstraints[nConstrPos++] = aConstraint; + aConstraints.getArray()[nConstrPos++] = aConstraint; } // copy old document values diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index 770520785b39..35d5f956797e 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -125,9 +125,10 @@ const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties( sal_Int32 nEntryCount = maProperties.getLength(); if (nEntryCount == m_xLbSettings->n_children()) { + auto maPropertiesRange = asNonConstRange(maProperties); for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos) { - uno::Any& rValue = maProperties[nEntryPos].Value; + uno::Any& rValue = maPropertiesRange[nEntryPos].Value; if (ScSolverOptionsString* pStringItem = reinterpret_cast<ScSolverOptionsString*>(m_xLbSettings->get_id(nEntryPos).toInt64())) { if (pStringItem->IsDouble()) diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx index df9fa8ae9883..6ba2707867e5 100644 --- a/sc/source/ui/miscdlgs/solverutil.cxx +++ b/sc/source/ui/miscdlgs/solverutil.cxx @@ -81,9 +81,9 @@ void ScSolverUtil::GetImplementations( uno::Sequence<OUString>& rImplNames, sDescription = sName; // use implementation name if no description available rImplNames.realloc( nCount+1 ); - rImplNames[nCount] = sName; + rImplNames.getArray()[nCount] = sName; rDescriptions.realloc( nCount+1 ); - rDescriptions[nCount] = sDescription; + rDescriptions.getArray()[nCount] = sDescription; ++nCount; } catch (const css::uno::Exception&) @@ -155,6 +155,7 @@ uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( std::u16string_vi const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); const sal_Int32 nSize = aPropSeq.getLength(); aDefaults.realloc(nSize); + auto pDefaults = aDefaults.getArray(); sal_Int32 nValid = 0; for (const beans::Property& rProp : aPropSeq) { @@ -162,7 +163,7 @@ uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( std::u16string_vi uno::TypeClass eClass = aValue.getValueTypeClass(); // only use properties of supported types if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE ) - aDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE ); + pDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE ); } aDefaults.realloc(nValid); diff --git a/sc/source/ui/unoobj/PivotTableDataSequence.cxx b/sc/source/ui/unoobj/PivotTableDataSequence.cxx index 330cca25dfb8..64384fb8962d 100644 --- a/sc/source/ui/unoobj/PivotTableDataSequence.cxx +++ b/sc/source/ui/unoobj/PivotTableDataSequence.cxx @@ -74,14 +74,15 @@ uno::Sequence<uno::Any> SAL_CALL PivotTableDataSequence::getData() throw uno::RuntimeException(); uno::Sequence<uno::Any> aSeq(m_aData.size()); + auto pSeq = aSeq.getArray(); size_t i = 0; for (ValueAndFormat const & rItem : m_aData) { if (rItem.m_eType == ValueType::Numeric) - aSeq[i] <<= double(rItem.m_fValue); + pSeq[i] <<= double(rItem.m_fValue); else if (rItem.m_eType == ValueType::String) - aSeq[i] <<= rItem.m_aString; + pSeq[i] <<= rItem.m_aString; i++; } @@ -97,11 +98,12 @@ uno::Sequence<double> SAL_CALL PivotTableDataSequence::getNumericalData() throw uno::RuntimeException(); uno::Sequence<double> aSeq(m_aData.size()); + auto pSeq = aSeq.getArray(); size_t i = 0; for (ValueAndFormat const & rItem : m_aData) { - aSeq[i] = rItem.m_fValue; + pSeq[i] = rItem.m_fValue; i++; } return aSeq; @@ -116,12 +118,13 @@ uno::Sequence<OUString> SAL_CALL PivotTableDataSequence::getTextualData() throw uno::RuntimeException(); uno::Sequence<OUString> aSeq(m_aData.size()); + auto pSeq = aSeq.getArray(); size_t i = 0; for (ValueAndFormat const & rItem : m_aData) { if (rItem.m_eType == ValueType::String) - aSeq[i] = rItem.m_aString; + pSeq[i] = rItem.m_aString; i++; } return aSeq; diff --git a/sc/source/ui/unoobj/cellvaluebinding.cxx b/sc/source/ui/unoobj/cellvaluebinding.cxx index ba72cf8e6c51..cba68f9cbc35 100644 --- a/sc/source/ui/unoobj/cellvaluebinding.cxx +++ b/sc/source/ui/unoobj/cellvaluebinding.cxx @@ -141,19 +141,21 @@ namespace calc Sequence< Type > aTypes( nCount ); if ( m_xCell.is() ) { + auto pTypes = aTypes.getArray(); + // an XCell can be used to set/get "double" values - aTypes[0] = ::cppu::UnoType<double>::get(); + pTypes[0] = ::cppu::UnoType<double>::get(); if ( m_xCellText.is() ) { // an XTextRange can be used to set/get "string" values - aTypes[1] = ::cppu::UnoType<OUString>::get(); + pTypes[1] = ::cppu::UnoType<OUString>::get(); // and additionally, we use it to handle booleans - aTypes[2] = ::cppu::UnoType<sal_Bool>::get(); + pTypes[2] = ::cppu::UnoType<sal_Bool>::get(); } // add sal_Int32 only if constructed as ListPositionCellBinding if ( m_bListPos ) - aTypes[nCount-1] = cppu::UnoType<sal_Int32>::get(); + pTypes[nCount-1] = cppu::UnoType<sal_Int32>::get(); } return aTypes; @@ -429,10 +431,11 @@ namespace calc Sequence< OUString > SAL_CALL OCellValueBinding::getSupportedServiceNames( ) { Sequence< OUString > aServices( m_bListPos ? 3 : 2 ); - aServices[ 0 ] = "com.sun.star.table.CellValueBinding"; - aServices[ 1 ] = "com.sun.star.form.binding.ValueBinding"; + auto pServices = aServices.getArray(); + pServices[ 0 ] = "com.sun.star.table.CellValueBinding"; + pServices[ 1 ] = "com.sun.star.form.binding.ValueBinding"; if ( m_bListPos ) - aServices[ 2 ] = "com.sun.star.table.ListPositionCellBinding"; + pServices[ 2 ] = "com.sun.star.table.ListPositionCellBinding"; return aServices; } diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 5300f91a0d3c..1de57336b2b4 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -223,19 +223,20 @@ void SAL_CALL ScChartsObj::addNewByName( const OUString& rName, xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); // set arguments - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - "CellRangeRepresentation", -1, - uno::makeAny( sRangeStr ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - "HasCategories", -1, - uno::makeAny( bRowHeaders ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - "FirstCellAsLabel", -1, - uno::makeAny( bColumnHeaders ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - "DataRowSource", -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + uno::Sequence< beans::PropertyValue > aArgs{ + beans::PropertyValue( + "CellRangeRepresentation", -1, + uno::makeAny( sRangeStr ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "HasCategories", -1, + uno::makeAny( bRowHeaders ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "FirstCellAsLabel", -1, + uno::makeAny( bColumnHeaders ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "DataRowSource", -1, + uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ) + }; xReceiver->setArguments( aArgs ); } diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 573d70a75794..4654efa6caf6 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -7,6 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <algorithm> #include <memory> #include <condformatuno.hxx> @@ -375,13 +378,9 @@ uno::Sequence<uno::Reference<sheet::XConditionalFormat> > ScCondFormatsObj::getC ScConditionalFormatList* pFormatList = getCoreObject(); size_t n = pFormatList->size(); uno::Sequence<uno::Reference<sheet::XConditionalFormat> > aCondFormats(n); - sal_Int32 i = 0; - for (const auto& rFormat : *pFormatList) - { - uno::Reference<sheet::XConditionalFormat> xCondFormat(new ScCondFormatObj(mpDocShell, this, rFormat->GetKey())); - aCondFormats[i] = xCondFormat; - ++i; - } + std::transform(pFormatList->begin(), pFormatList->end(), aCondFormats.getArray(), + [this](const auto& rFormat) + { return uno::Reference(new ScCondFormatObj(mpDocShell, this, rFormat->GetKey())); }); return aCondFormats; } @@ -954,9 +953,10 @@ uno::Any SAL_CALL ScColorScaleFormatObj::getPropertyValue( const OUString& aProp case ColorScaleEntries: { uno::Sequence<uno::Reference<sheet::XColorScaleEntry> > aEntries(getCoreObject()->size()); + auto aEntriesRange = asNonConstRange(aEntries); for (size_t i = 0; i < getCoreObject()->size(); ++i) { - aEntries[i] = new ScColorScaleEntryObj(this, i); + aEntriesRange[i] = new ScColorScaleEntryObj(this, i); } aAny <<= aEntries; } @@ -1638,9 +1638,10 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert { size_t nSize = getCoreObject()->size(); uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries(nSize); + auto aEntriesRange = asNonConstRange(aEntries); for (size_t i = 0; i < nSize; ++i) { - aEntries[i] = new ScIconSetEntryObj(this, i); + aEntriesRange[i] = new ScIconSetEntryObj(this, i); } aAny <<= aEntries; } diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 99de5a326b62..7d5a6e46a0ec 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -2043,8 +2043,9 @@ Sequence< sal_Int16 > ScDataPilotFieldObj::getSubtotals() const if ( nCount > 0 ) { aRet.realloc( nCount ); + auto pRet = aRet.getArray(); for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx ) - aRet[ nIdx ] = static_cast<sal_Int16>(pDim->GetSubTotalFunc( nIdx )); + pRet[ nIdx ] = static_cast<sal_Int16>(pDim->GetSubTotalFunc( nIdx )); } } } diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index e493a6b175c9..985f07cf47d4 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1267,14 +1267,14 @@ uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilt { aField.Operator = sheet::FilterOperator2::EMPTY; aField.Values.realloc(1); - aField.Values[0].NumericValue = 0; + aField.Values.getArray()[0].NumericValue = 0; bByEmpty = true; } else if (rEntry.IsQueryByNonEmpty()) { aField.Operator = sheet::FilterOperator2::NOT_EMPTY; aField.Values.realloc(1); - aField.Values[0].NumericValue = 0; + aField.Values.getArray()[0].NumericValue = 0; bByEmpty = true; } } @@ -1284,12 +1284,13 @@ uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilt const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); size_t nItemCount = rItems.size(); aField.Values.realloc(nItemCount); + auto pValues = aField.Values.getArray(); size_t j = 0; for (const auto& rItem : rItems) { - aField.Values[j].IsNumeric = rItem.meType != ScQueryEntry::ByString; - aField.Values[j].StringValue = rItem.maString.getString(); - aField.Values[j].NumericValue = rItem.mfVal; + pValues[j].IsNumeric = rItem.meType != ScQueryEntry::ByString; + pValues[j].StringValue = rItem.maString.getString(); + pValues[j].NumericValue = rItem.mfVal; ++j; } } @@ -2285,10 +2286,11 @@ uno::Sequence<OUString> SAL_CALL ScDatabaseRangesObj::getElementNames() { const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs(); uno::Sequence<OUString> aSeq(rDBs.size()); + auto aSeqRange = asNonConstRange(aSeq); size_t i = 0; for (const auto& rDB : rDBs) { - aSeq[i] = rDB->GetName(); + aSeqRange[i] = rDB->GetName(); ++i; } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 6a9d0d890556..11016aafb202 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -20,6 +20,8 @@ #include <config_feature_opencl.h> #include <scitems.hxx> + +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <editeng/brushitem.hxx> #include <editeng/editview.hxx> @@ -297,15 +299,10 @@ ScPrintUIOptions::ScPrintUIOptions() // create a choice for the range to print OUString aPrintRangeName( "PrintRange" ); - aChoices.realloc( 2 ); - aHelpIds.realloc( 2 ); - uno::Sequence< OUString > aWidgetIds( 2 ); - aChoices[0] = ScResId( SCSTR_PRINTOPT_PRINTALLPAGES ); - aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0"; - aWidgetIds[0] = "rbAllPages"; - aChoices[1] = ScResId( SCSTR_PRINTOPT_PRINTPAGES ); - aHelpIds[1] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1"; - aWidgetIds[1] = "rbRangePages"; + aChoices = { ScResId( SCSTR_PRINTOPT_PRINTALLPAGES ), ScResId( SCSTR_PRINTOPT_PRINTPAGES ) }; + aHelpIds = { ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0", + ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1" }; + uno::Sequence< OUString > aWidgetIds{ "rbAllPages", "rbRangePages" }; m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(), aHelpIds, aPrintRangeName, @@ -2585,19 +2582,15 @@ uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData( ) uno::Reference < container::XIndexContainer > xCont = document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ); xRet.set( xCont, uno::UNO_QUERY_THROW ); - uno::Sequence< beans::PropertyValue > aSeq; - aSeq.realloc(3); OUString sName; pDocShell->GetDocument().GetName( pDocShell->GetDocument().GetVisibleTab(), sName ); - OUString sOUName(sName); - aSeq[0].Name = SC_ACTIVETABLE; - aSeq[0].Value <<= sOUName; SCCOL nPosLeft = pDocShell->GetDocument().GetPosLeft(); - aSeq[1].Name = SC_POSITIONLEFT; - aSeq[1].Value <<= nPosLeft; SCROW nPosTop = pDocShell->GetDocument().GetPosTop(); - aSeq[2].Name = SC_POSITIONTOP; - aSeq[2].Value <<= nPosTop; + uno::Sequence< beans::PropertyValue > aSeq{ + comphelper::makePropertyValue(SC_ACTIVETABLE, sName), + comphelper::makePropertyValue(SC_POSITIONLEFT, nPosLeft), + comphelper::makePropertyValue(SC_POSITIONTOP, nPosTop) + }; xCont->insertByIndex( 0, uno::makeAny( aSeq ) ); } } @@ -3163,6 +3156,7 @@ void ScModelObj::NotifyChanges( const OUString& rOperation, const ScRangeList& r size_t nRangeCount = rRanges.size(); aEvent.Changes.realloc( static_cast< sal_Int32 >( nRangeCount ) ); + auto pChanges = aEvent.Changes.getArray(); for ( size_t nIndex = 0; nIndex < nRangeCount; ++nIndex ) { uno::Reference< table::XCellRange > xRangeObj; @@ -3177,7 +3171,7 @@ void ScModelObj::NotifyChanges( const OUString& rOperation, const ScRangeList& r xRangeObj.set( new ScCellRangeObj( pDocShell, rRange ) ); } - util::ElementChange& rChange = aEvent.Changes[ static_cast< sal_Int32 >( nIndex ) ]; + util::ElementChange& rChange = pChanges[ static_cast< sal_Int32 >( nIndex ) ]; rChange.Accessor <<= rOperation; rChange.Element <<= rProperties; rChange.ReplacedElement <<= xRangeObj; @@ -3238,8 +3232,7 @@ void ScModelObj::NotifyChanges( const OUString& rOperation, const ScRangeList& r else xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangesObj( pDocShell, aTabRanges ) ) ); - uno::Sequence<uno::Any> aParams(1); - aParams[0] <<= xTarget; + uno::Sequence<uno::Any> aParams{ uno::Any(xTarget) }; uno::Any aRet; uno::Sequence<sal_Int16> aOutArgsIndex; @@ -3282,8 +3275,7 @@ void ScModelObj::HandleCalculateEvents() try { uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW ); - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= nTab; + uno::Sequence< uno::Any > aArgs{ uno::Any(nTab) }; xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::CALCULATE ), aArgs ); } catch( uno::Exception& ) @@ -3406,18 +3398,20 @@ uno::Sequence< sheet::opencl::OpenCLPlatform > ScModelObj::getOpenCLPlatforms() sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo); uno::Sequence<sheet::opencl::OpenCLPlatform> aRet(aPlatformInfo.size()); + auto aRetRange = asNonConstRange(aRet); for(size_t i = 0; i < aPlatformInfo.size(); ++i) { - aRet[i].Name = aPlatformInfo[i].maName; - aRet[i].Vendor = aPlatformInfo[i].maVendor; + aRetRange[i].Name = aPlatformInfo[i].maName; + aRetRange[i].Vendor = aPlatformInfo[i].maVendor; - aRet[i].Devices.realloc(aPlatformInfo[i].maDevices.size()); + aRetRange[i].Devices.realloc(aPlatformInfo[i].maDevices.size()); + auto pDevices = aRetRange[i].Devices.getArray(); for(size_t j = 0; j < aPlatformInfo[i].maDevices.size(); ++j) { const OpenCLDeviceInfo& rDevice = aPlatformInfo[i].maDevices[j]; - aRet[i].Devices[j].Name = rDevice.maName; - aRet[i].Devices[j].Vendor = rDevice.maVendor; - aRet[i].Devices[j].Driver = rDevice.maDriver; + pDevices[j].Name = rDevice.maName; + pDevices[j].Vendor = rDevice.maVendor; + pDevices[j].Driver = rDevice.maDriver; } } @@ -3848,10 +3842,11 @@ uno::Sequence < uno::Reference< table::XCellRange > > SAL_CALL ScTableSheetsObj: throw lang::IllegalArgumentException(); xRet.realloc(nCount); + auto pRet = xRet.getArray(); for( size_t nIndex = 0; nIndex < nCount; nIndex++ ) { const ScRange & rRange = aRangeList[ nIndex ]; - xRet[nIndex] = new ScCellRangeObj(pDocShell, rRange); + pRet[nIndex] = new ScCellRangeObj(pDocShell, rRange); } return xRet; diff --git a/sc/source/ui/unoobj/eventuno.cxx b/sc/source/ui/unoobj/eventuno.cxx index c1d37d1d4490..48512812b164 100644 --- a/sc/source/ui/unoobj/eventuno.cxx +++ b/sc/source/ui/unoobj/eventuno.cxx @@ -145,8 +145,9 @@ uno::Sequence<OUString> SAL_CALL ScSheetEventsObj::getElementNames() { SolarMutexGuard aGuard; auto aNames = uno::Sequence<OUString>(int(ScSheetEventId::COUNT)); + auto pNames = aNames.getArray(); for (sal_Int32 nEvent=0; nEvent<int(ScSheetEventId::COUNT); ++nEvent) - aNames[nEvent] = ScSheetEvents::GetEventName(static_cast<ScSheetEventId>(nEvent)); + pNames[nEvent] = ScSheetEvents::GetEventName(static_cast<ScSheetEventId>(nEvent)); return aNames; } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index d58e19fc0b3e..8bafd796a430 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -1454,8 +1454,9 @@ Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllRows() mpTable->getAllRows(aRows); size_t nSize = aRows.size(); Sequence<sal_Int32> aRowsSeq(nSize); + auto aRowsSeqRange = asNonConstRange(aRowsSeq); for (size_t i = 0; i < nSize; ++i) - aRowsSeq[i] = aRows[i]; + aRowsSeqRange[i] = aRows[i]; return aRowsSeq; } @@ -1470,8 +1471,9 @@ Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllColumns(sal_Int32 mpTable->getAllCols(static_cast<SCROW>(nRow), aCols); size_t nSize = aCols.size(); Sequence<sal_Int32> aColsSeq(nSize); + auto aColsSeqRange = asNonConstRange(aColsSeq); for (size_t i = 0; i < nSize; ++i) - aColsSeq[i] = aCols[i]; + aColsSeqRange[i] = aCols[i]; return aColsSeq; } ... etc. - the rest is truncated
