stoc/source/corereflection/criface.cxx | 3 stoc/source/implementationregistration/implreg.cxx | 8 +- stoc/source/javaloader/javaloader.cxx | 2 stoc/source/javavm/interact.cxx | 4 - stoc/source/security/file_policy.cxx | 4 - stoc/source/servicemanager/servicemanager.cxx | 16 ++-- stoc/source/simpleregistry/simpleregistry.cxx | 15 ++-- svtools/source/brwbox/brwbox3.cxx | 8 +- svtools/source/config/miscopt.cxx | 5 - svtools/source/config/slidesorterbaropt.cxx | 13 ++- svtools/source/control/inettbc.cxx | 10 +- svtools/source/dialogs/addresstemplate.cxx | 19 ++--- svtools/source/dialogs/colrdlg.cxx | 19 ++--- svtools/source/filter/DocumentToGraphicRenderer.cxx | 53 ++++----------- svtools/source/filter/SvFilterOptionsDialog.cxx | 2 svtools/source/filter/exportdialog.cxx | 18 ++--- svtools/source/misc/bindablecontrolhelper.cxx | 8 -- svtools/source/misc/imageresourceaccess.cxx | 14 +--- svtools/source/misc/templatefoldercache.cxx | 7 -- svtools/source/uno/svtxgridcontrol.cxx | 14 ++-- svtools/source/uno/toolboxcontroller.cxx | 5 - svtools/source/uno/unoevent.cxx | 69 ++++---------------- svtools/source/uno/wizard/unowizard.cxx | 3 23 files changed, 131 insertions(+), 188 deletions(-)
New commits: commit d4b63c4562ec4c612df675502fd35c7c88bc432d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Oct 29 10:11:20 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Oct 31 15:49:34 2021 +0100 Prepare for removal of non-const operator[] from Sequence in svtools Change-Id: I614a97e5e2328c787ce19612a88839e234d54382 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124396 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx index 5b113724561e..32401d312829 100644 --- a/svtools/source/brwbox/brwbox3.cxx +++ b/svtools/source/brwbox/brwbox3.cxx @@ -482,9 +482,10 @@ void BrowseBox::GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) co if( nCount ) { _rRows.realloc( nCount ); - _rRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow(); + auto pRows = _rRows.getArray(); + pRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow(); for( sal_Int32 nIndex = 1; nIndex < nCount; ++nIndex ) - _rRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow(); + pRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow(); DBG_ASSERT( const_cast< BrowseBox* >( this )->NextSelectedRow() == BROWSER_ENDOFSELECTION, "BrowseBox::GetAllSelectedRows - too many selected rows found" ); } @@ -498,6 +499,7 @@ void BrowseBox::GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumn return; _rColumns.realloc( nCount ); + auto pColumns = _rColumns.getArray(); sal_Int32 nIndex = 0; const size_t nRangeCount = pColumnSel->GetRangeCount(); @@ -509,7 +511,7 @@ void BrowseBox::GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumn { DBG_ASSERT( nIndex < nCount, "GetAllSelectedColumns - range overflow" ); - _rColumns[ nIndex ] = nCol; + pColumns[ nIndex ] = nCol; ++nIndex; } } diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx index 7e05cc030e73..1da6ba473eba 100644 --- a/svtools/source/config/miscopt.cxx +++ b/svtools/source/config/miscopt.cxx @@ -310,6 +310,7 @@ void SvtMiscOptions_Impl::ImplCommit() Sequence< OUString > seqNames = GetPropertyNames (); sal_Int32 nCount = seqNames.getLength(); Sequence< Any > seqValues ( nCount ); + auto seqValuesRange = asNonConstRange(seqValues); for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) { switch( nProperty ) @@ -317,7 +318,7 @@ void SvtMiscOptions_Impl::ImplCommit() case PROPERTYHANDLE_SYMBOLSET : { if ( !m_bIsSymbolsSizeRO ) - seqValues[nProperty] <<= m_nSymbolsSize; + seqValuesRange[nProperty] <<= m_nSymbolsSize; break; } @@ -331,7 +332,7 @@ void SvtMiscOptions_Impl::ImplCommit() else { value = GetIconTheme(); } - seqValues[nProperty] <<= value; + seqValuesRange[nProperty] <<= value; } break; } diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx index 2e4a4a3da587..1ff23bcaed34 100644 --- a/svtools/source/config/slidesorterbaropt.cxx +++ b/svtools/source/config/slidesorterbaropt.cxx @@ -264,38 +264,39 @@ void SvtSlideSorterBarOptions_Impl::ImplCommit() // Get names of supported properties, create a list for values and copy current values to it. sal_Int32 nCount = m_seqPropertyNames.getLength(); Sequence< Any > seqValues ( nCount ); + auto seqValuesRange = asNonConstRange(seqValues); for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) { switch( nProperty ) { case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW: { - seqValues[nProperty] <<= m_bVisibleImpressView; + seqValuesRange[nProperty] <<= m_bVisibleImpressView; break; } case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW: { - seqValues[nProperty] <<= m_bVisibleOutlineView; + seqValuesRange[nProperty] <<= m_bVisibleOutlineView; break; } case PROPERTYHANDLE_VISIBLE_NOTESVIEW: { - seqValues[nProperty] <<= m_bVisibleNotesView; + seqValuesRange[nProperty] <<= m_bVisibleNotesView; break; } case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW: { - seqValues[nProperty] <<= m_bVisibleHandoutView; + seqValuesRange[nProperty] <<= m_bVisibleHandoutView; break; } case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW: { - seqValues[nProperty] <<= m_bVisibleSlideSorterView; + seqValuesRange[nProperty] <<= m_bVisibleSlideSorterView; break; } case PROPERTYHANDLE_VISIBLE_DRAWVIEW: { - seqValues[nProperty] <<= m_bVisibleDrawView; + seqValuesRange[nProperty] <<= m_bVisibleDrawView; break; } diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 9d78a805c18d..147ce77a4b14 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -463,10 +463,12 @@ void SvtMatchContext_Impl::doExecute() css::ucb::XUniversalContentBroker > ucb( css::ucb::UniversalContentBroker::create( ctx)); - css::uno::Sequence< css::beans::Property > prop(1); - prop[0].Name = "IsFolder"; - prop[0].Handle = -1; - prop[0].Type = cppu::UnoType< bool >::get(); + css::uno::Sequence< css::beans::Property > prop{ + { /* Name */ "IsFolder", + /* Handle */ -1, + /* Type */ cppu::UnoType< bool >::get(), + /* Attributes */ {} } + }; css::uno::Any res; css::uno::Reference< css::ucb::XCommandProcessor > proc( diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index b7d787b53aae..6f29151e308f 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -24,6 +24,7 @@ #include <svtools/svtresid.hxx> #include <tools/debug.hxx> #include <comphelper/interaction.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/string.hxx> #include <unotools/configitem.hxx> #include <vcl/stdtext.hxx> @@ -338,8 +339,7 @@ void AssignmentPersistentData::ImplCommit() void AssignmentPersistentData::setStringProperty(const char* _pLocalName, const OUString& _rValue) { Sequence< OUString > aNames { OUString::createFromAscii(_pLocalName) }; - Sequence< Any > aValues(1); - aValues[0] <<= _rValue; + Sequence< Any > aValues{ Any(_rValue) }; PutProperties(aNames, aValues); } @@ -362,13 +362,14 @@ void AssignmentPersistentData::ImplCommit() // Fields/<field> OUString sFieldElementNodePath = sDescriptionNodePath + "/" + _rLogicalName; - Sequence< PropertyValue > aNewFieldDescription(2); - // Fields/<field>/ProgrammaticFieldName - aNewFieldDescription[0].Name = sFieldElementNodePath + "/ProgrammaticFieldName"; - aNewFieldDescription[0].Value <<= _rLogicalName; - // Fields/<field>/AssignedFieldName - aNewFieldDescription[1].Name = sFieldElementNodePath + "/AssignedFieldName"; - aNewFieldDescription[1].Value <<= _rAssignment; + Sequence< PropertyValue > aNewFieldDescription{ + // Fields/<field>/ProgrammaticFieldName + comphelper::makePropertyValue(sFieldElementNodePath + "/ProgrammaticFieldName", + _rLogicalName), + // Fields/<field>/AssignedFieldName + comphelper::makePropertyValue(sFieldElementNodePath + "/AssignedFieldName", + _rAssignment) + }; // just set the new value bool bSuccess = diff --git a/svtools/source/dialogs/colrdlg.cxx b/svtools/source/dialogs/colrdlg.cxx index e1966ae382bd..27008ccfcd28 100644 --- a/svtools/source/dialogs/colrdlg.cxx +++ b/svtools/source/dialogs/colrdlg.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/cui/ColorPicker.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <svtools/colrdlg.hxx> #include <svtools/dialogclosedlistener.hxx> @@ -71,11 +72,10 @@ short SvColorDialog::Execute(weld::Window* pParent) Reference< XExecutableDialog > xDialog = css::cui::ColorPicker::createWithParent(xContext, xParent); Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW ); - Sequence< PropertyValue > props( 2 ); - props[0].Name = OUString( sColor ); - props[0].Value <<= maColor; - props[1].Name = "Mode"; - props[1].Value <<= static_cast<sal_Int16>(meMode); + Sequence< PropertyValue > props{ + comphelper::makePropertyValue(OUString( sColor ), maColor), + comphelper::makePropertyValue("Mode", static_cast<sal_Int16>(meMode)) + }; xPropertyAccess->setPropertyValues( props ); @@ -116,11 +116,10 @@ void SvColorDialog::ExecuteAsync(weld::Window* pParent, const std::function<void mxDialog = css::cui::AsynchronousColorPicker::createWithParent(xContext, xParent); Reference< XPropertyAccess > xPropertyAccess( mxDialog, UNO_QUERY_THROW ); - Sequence< PropertyValue > props( 2 ); - props[0].Name = OUString( sColor ); - props[0].Value <<= maColor; - props[1].Name = "Mode"; - props[1].Value <<= static_cast<sal_Int16>(meMode); + Sequence< PropertyValue > props{ + comphelper::makePropertyValue(OUString( sColor ), maColor), + comphelper::makePropertyValue("Mode", static_cast<sal_Int16>(meMode)) + }; xPropertyAccess->setPropertyValues( props ); diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx index 29ec30b94808..af64b7b8496a 100644 --- a/svtools/source/filter/DocumentToGraphicRenderer.cxx +++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx @@ -19,6 +19,7 @@ #include <svtools/DocumentToGraphicRenderer.hxx> +#include <comphelper/propertyvalue.hxx> #include <vcl/gdimtf.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/svapp.hxx> @@ -131,17 +132,10 @@ Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage, uno::Any selection( getSelection()); - PropertyValues renderProperties; - - renderProperties.realloc( 4 ); - renderProperties[0].Name = "IsPrinter"; - renderProperties[0].Value <<= true; - renderProperties[1].Name = "RenderDevice"; - renderProperties[1].Value <<= xDevice; - renderProperties[2].Name = "View"; - renderProperties[2].Value <<= mxController; - renderProperties[3].Name = "RenderToGraphic"; - renderProperties[3].Value <<= true; + PropertyValues renderProperties{ comphelper::makePropertyValue("IsPrinter", true), + comphelper::makePropertyValue("RenderDevice", xDevice), + comphelper::makePropertyValue("View", mxController), + comphelper::makePropertyValue("RenderToGraphic", true) }; awt::Size aSize; awt::Size aCalcPageSize; @@ -209,20 +203,14 @@ Graphic DocumentToGraphicRenderer::renderToGraphic( double fScaleX = aTargetSizePixel.Width() / static_cast<double>(aDocumentSizePixel.Width()); double fScaleY = aTargetSizePixel.Height() / static_cast<double>(aDocumentSizePixel.Height()); - PropertyValues renderProps; - renderProps.realloc( 6 ); - renderProps[0].Name = "IsPrinter"; - renderProps[0].Value <<= true; - renderProps[1].Name = "RenderDevice"; - renderProps[1].Value <<= xDevice; - renderProps[2].Name = "View"; - renderProps[2].Value <<= mxController; - renderProps[3].Name = "RenderToGraphic"; - renderProps[3].Value <<= true; - renderProps[4].Name = "HasPDFExtOutDevData"; - renderProps[4].Value <<= bExtOutDevData; - renderProps[5].Name = "PageRange"; - renderProps[5].Value <<= OUString::number(nCurrentPage); + PropertyValues renderProps{ + comphelper::makePropertyValue("IsPrinter", true), + comphelper::makePropertyValue("RenderDevice", xDevice), + comphelper::makePropertyValue("View", mxController), + comphelper::makePropertyValue("RenderToGraphic", true), + comphelper::makePropertyValue("HasPDFExtOutDevData", bExtOutDevData), + comphelper::makePropertyValue("PageRange", OUString::number(nCurrentPage)) + }; GDIMetaFile aMtf; @@ -285,17 +273,10 @@ sal_Int32 DocumentToGraphicRenderer::getPageCount() uno::Any selection( getSelection() ); - PropertyValues renderProperties; - - renderProperties.realloc( 4 ); - renderProperties[0].Name = "IsPrinter"; - renderProperties[0].Value <<= true; - renderProperties[1].Name = "RenderDevice"; - renderProperties[1].Value <<= xDevice; - renderProperties[2].Name = "View"; - renderProperties[2].Value <<= mxController; - renderProperties[3].Name = "RenderToGraphic"; - renderProperties[3].Value <<= true; + PropertyValues renderProperties{ comphelper::makePropertyValue("IsPrinter", true), + comphelper::makePropertyValue("RenderDevice", xDevice), + comphelper::makePropertyValue("View", mxController), + comphelper::makePropertyValue("RenderToGraphic", true) }; sal_Int32 nPages = mxRenderable->getRendererCount( selection, renderProperties ); diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx index 698e49e0725a..5d0926ace1ab 100644 --- a/svtools/source/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter/SvFilterOptionsDialog.cxx @@ -156,7 +156,7 @@ uno::Sequence< beans::PropertyValue > SvFilterOptionsDialog::getPropertyValues() maMediaDescriptor.realloc( ++nCount ); // the "FilterData" Property is an Any that will contain our PropertySequence of Values - auto& item = maMediaDescriptor[ i ]; + auto& item = maMediaDescriptor.getArray()[ i ]; item.Name = "FilterData"; item.Value <<= maFilterDataSequence; return maMediaDescriptor; diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx index 5accd1482cd1..76d90f7b8e06 100644 --- a/svtools/source/filter/exportdialog.cxx +++ b/svtools/source/filter/exportdialog.cxx @@ -21,6 +21,7 @@ #include <algorithm> +#include <comphelper/propertyvalue.hxx> #include <o3tl/safeint.hxx> #include <tools/stream.hxx> #include <tools/fract.hxx> @@ -333,9 +334,8 @@ awt::Size ExportDialog::GetOriginalSize() aTransformation.m11 = aViewTransformation.get(1,1); aTransformation.m12 = aViewTransformation.get(1,2); - uno::Sequence< beans::PropertyValue > aViewInformation( 1 ); - aViewInformation[ 0 ].Value <<= aTransformation; - aViewInformation[ 0 ].Name = "ViewTransformation"; + uno::Sequence< beans::PropertyValue > aViewInformation{ comphelper::makePropertyValue( + "ViewTransformation", aTransformation) }; if ( mxShape.is() ) aShapesRange = GetShapeRangeForXShape( mxShape, xPrimitiveFactory, aViewInformation ); @@ -480,13 +480,11 @@ void ExportDialog::GetGraphicStream() uno::Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() ); OUString sFormat( maExt ); - uno::Sequence< beans::PropertyValue > aDescriptor( 3 ); - aDescriptor[0].Name = "OutputStream"; - aDescriptor[0].Value <<= xOutputStream; - aDescriptor[1].Name = "FilterName"; - aDescriptor[1].Value <<= sFormat; - aDescriptor[2].Name = "FilterData"; - aDescriptor[2].Value <<= aNewFilterData; + uno::Sequence< beans::PropertyValue > aDescriptor{ + comphelper::makePropertyValue("OutputStream", xOutputStream), + comphelper::makePropertyValue("FilterName", sFormat), + comphelper::makePropertyValue("FilterData", aNewFilterData) + }; uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create( mxContext ); diff --git a/svtools/source/misc/bindablecontrolhelper.cxx b/svtools/source/misc/bindablecontrolhelper.cxx index 0fe8d85034f4..95cdcca2a431 100644 --- a/svtools/source/misc/bindablecontrolhelper.cxx +++ b/svtools/source/misc/bindablecontrolhelper.cxx @@ -96,9 +96,7 @@ BindableControlHelper::ApplyListSourceAndBindableData( const css::uno::Reference aArg1.Name = "BoundCell"; aArg1.Value <<= aAddress; - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= aArg1; - + uno::Sequence< uno::Any > aArgs{ uno::Any(aArg1) }; uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), uno::UNO_QUERY ); xBindable->setValueBinding( xBinding ); } @@ -130,9 +128,7 @@ BindableControlHelper::ApplyListSourceAndBindableData( const css::uno::Reference aArg1.Name = "CellRange"; aArg1.Value <<= aAddress; - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= aArg1; - + uno::Sequence< uno::Any > aArgs{ uno::Any(aArg1) }; uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( "com.sun.star.table.CellRangeListSource", aArgs ), uno::UNO_QUERY ); xListEntrySink->setListEntrySource( xSource ); } diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx index fc12981a3460..66c458c911e6 100644 --- a/svtools/source/misc/imageresourceaccess.cxx +++ b/svtools/source/misc/imageresourceaccess.cxx @@ -25,6 +25,8 @@ #include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/io/XStream.hpp> + +#include <comphelper/propertyvalue.hxx> #include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <tools/stream.hxx> @@ -125,9 +127,8 @@ std::unique_ptr<SvStream> getImageStream(uno::Reference<uno::XComponentContext> uno::Reference<graphic::XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(rxContext); // let it create a graphic from the given URL - uno::Sequence<beans::PropertyValue> aMediaProperties(1); - aMediaProperties[0].Name = "URL"; - aMediaProperties[0].Value <<= rImageResourceURL; + uno::Sequence<beans::PropertyValue> aMediaProperties{ comphelper::makePropertyValue( + "URL", rImageResourceURL) }; uno::Reference<graphic::XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties)); OSL_ENSURE(xGraphic.is(), "GraphicAccess::getImageStream: the provider did not give us a graphic object!"); @@ -140,11 +141,8 @@ std::unique_ptr<SvStream> getImageStream(uno::Reference<uno::XComponentContext> new OSeekableInputStreamWrapper(*pMemBuffer), new OSeekableOutputStreamWrapper(*pMemBuffer)); - aMediaProperties.realloc(2); - aMediaProperties[0].Name = "OutputStream"; - aMediaProperties[0].Value <<= xBufferAccess; - aMediaProperties[1].Name = "MimeType"; - aMediaProperties[1].Value <<= OUString("image/png"); + aMediaProperties = { comphelper::makePropertyValue("OutputStream", xBufferAccess), + comphelper::makePropertyValue("MimeType", OUString("image/png")) }; xProvider->storeGraphic(xGraphic, aMediaProperties); pMemBuffer->Seek(0); diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx index cf9d5e5aace6..d92d22d62686 100644 --- a/svtools/source/misc/templatefoldercache.cxx +++ b/svtools/source/misc/templatefoldercache.cxx @@ -535,11 +535,8 @@ namespace svt { // create a content for the current folder root Reference< XResultSet > xResultSet; - Sequence< OUString > aContentProperties( 4); - aContentProperties[0] = "Title"; - aContentProperties[1] = "DateModified"; - aContentProperties[2] = "DateCreated"; - aContentProperties[3] = "IsFolder"; + Sequence< OUString > aContentProperties{ "Title", "DateModified", "DateCreated", + "IsFolder" }; // get the set of sub contents in the folder try diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 91fd08ac18b3..e394c803e42e 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -36,6 +36,8 @@ #include <vcl/svapp.hxx> +#include <algorithm> + using css::uno::Reference; using css::uno::Exception; using css::uno::UNO_QUERY; @@ -540,10 +542,8 @@ Any SVTXGridControl::getProperty( const OUString& PropertyName ) else { Sequence< css::util::Color > aAPIColors( aColors->size() ); - for ( size_t i=0; i<aColors->size(); ++i ) - { - aAPIColors[i] = sal_Int32(aColors->at(i)); - } + std::transform(aColors->begin(), aColors->end(), aAPIColors.getArray(), + [](const auto& color) { return sal_Int32(color); }); aPropertyValue <<= aAPIColors; } } @@ -728,8 +728,9 @@ Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelectedRows() sal_Int32 selectionCount = pTable->GetSelectedRowCount(); Sequence< sal_Int32 > selectedRows( selectionCount ); + auto selectedRowsRange = asNonConstRange(selectedRows); for ( sal_Int32 i=0; i<selectionCount; ++i ) - selectedRows[i] = pTable->GetSelectedRowIndex(i); + selectedRowsRange[i] = pTable->GetSelectedRowIndex(i); return selectedRows; } @@ -871,8 +872,9 @@ void SVTXGridControl::ImplCallItemListeners() sal_Int32 const nSelectedRowCount( pTable->GetSelectedRowCount() ); aEvent.SelectedRowIndexes.realloc( nSelectedRowCount ); + auto pSelectedRowIndexes = aEvent.SelectedRowIndexes.getArray(); for ( sal_Int32 i=0; i<nSelectedRowCount; ++i ) - aEvent.SelectedRowIndexes[i] = pTable->GetSelectedRowIndex( i ); + pSelectedRowIndexes[i] = pTable->GetSelectedRowIndex( i ); m_aSelectionListeners.selectionChanged( aEvent ); } } diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx index c18e4c9abae7..a105bfb3b757 100644 --- a/svtools/source/uno/toolboxcontroller.cxx +++ b/svtools/source/uno/toolboxcontroller.cxx @@ -31,6 +31,7 @@ #include <vcl/toolbox.hxx> #include <vcl/weldutils.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> const int TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE = 1; constexpr OUStringLiteral TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE = u"SupportsVisible"; @@ -346,11 +347,9 @@ void SAL_CALL ToolboxController::execute( sal_Int16 KeyModifier ) try { css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs( 1 ); // Provide key modifier information to dispatch function - aArgs[0].Name = "KeyModifier"; - aArgs[0].Value <<= KeyModifier; + Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue("KeyModifier", KeyModifier) }; aTargetURL.Complete = aCommandURL; if ( m_xUrlTransformer.is() ) diff --git a/svtools/source/uno/unoevent.cxx b/svtools/source/uno/unoevent.cxx index 873ef4132300..3a0a9cad75ea 100644 --- a/svtools/source/uno/unoevent.cxx +++ b/svtools/source/uno/unoevent.cxx @@ -18,6 +18,8 @@ */ #include <com/sun/star/beans/PropertyValue.hpp> + +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/supportsservice.hxx> #include <osl/diagnose.h> #include <sfx2/event.hxx> @@ -54,31 +56,13 @@ void getAnyFromMacro(Any& rAny, const SvxMacro& rMacro) case STARBASIC: { // create sequence - Sequence<PropertyValue> aSequence(3); - Any aTmp; - - // create type - PropertyValue aTypeValue; - aTypeValue.Name = sEventType; - aTmp <<= OUString(sStarBasic); - aTypeValue.Value = aTmp; - aSequence[0] = aTypeValue; - - // macro name - PropertyValue aNameValue; - aNameValue.Name = sMacroName; - const OUString& sNameTmp(rMacro.GetMacName()); - aTmp <<= sNameTmp; - aNameValue.Value = aTmp; - aSequence[1] = aNameValue; - - // library name - PropertyValue aLibValue; - aLibValue.Name = sLibrary; - const OUString& sLibTmp(rMacro.GetLibName()); - aTmp <<= sLibTmp; - aLibValue.Value = aTmp; - aSequence[2] = aLibValue; + Sequence<PropertyValue> aSequence( + // create type + { comphelper::makePropertyValue(sEventType, OUString(sStarBasic)), + // macro name + comphelper::makePropertyValue(sMacroName, rMacro.GetMacName()), + // library name + comphelper::makePropertyValue(sLibrary, rMacro.GetLibName()) }); rAny <<= aSequence; bRetValueOK = true; @@ -87,23 +71,11 @@ void getAnyFromMacro(Any& rAny, const SvxMacro& rMacro) case EXTENDED_STYPE: { // create sequence - Sequence<PropertyValue> aSequence(2); - Any aTmp; - - // create type - PropertyValue aTypeValue; - aTypeValue.Name = sEventType; - aTmp <<= OUString(sScript); - aTypeValue.Value = aTmp; - aSequence[0] = aTypeValue; - - // macro name - PropertyValue aNameValue; - aNameValue.Name = sScript; - const OUString& sNameTmp(rMacro.GetMacName()); - aTmp <<= sNameTmp; - aNameValue.Value = aTmp; - aSequence[1] = aNameValue; + Sequence<PropertyValue> aSequence( + // create type + { comphelper::makePropertyValue(sEventType, OUString(sScript)), + // macro name + comphelper::makePropertyValue(sScript, rMacro.GetMacName()) }); rAny <<= aSequence; bRetValueOK = true; @@ -121,15 +93,7 @@ void getAnyFromMacro(Any& rAny, const SvxMacro& rMacro) return; // create "None" macro - Sequence<PropertyValue> aSequence(1); - - PropertyValue aKindValue; - aKindValue.Name = sEventType; - Any aTmp; - aTmp <<= OUString(sNone); - aKindValue.Value = aTmp; - aSequence[0] = aKindValue; - + Sequence<PropertyValue> aSequence{ comphelper::makePropertyValue(sEventType, OUString(sNone)) }; rAny <<= aSequence; } @@ -284,9 +248,10 @@ Sequence<OUString> SvBaseEventDescriptor::getElementNames() { // create and fill sequence Sequence<OUString> aSequence(mnMacroItems); + auto aSequenceRange = asNonConstRange(aSequence); for( sal_Int16 i = 0; i < mnMacroItems; i++) { - aSequence[i] = OUString::createFromAscii( mpSupportedMacroItems[i].mpEventName ); + aSequenceRange[i] = OUString::createFromAscii( mpSupportedMacroItems[i].mpEventName ); } return aSequence; diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx index ea028304737a..9c503d37e114 100644 --- a/svtools/source/uno/wizard/unowizard.cxx +++ b/svtools/source/uno/wizard/unowizard.cxx @@ -226,8 +226,7 @@ namespace { if ( !aMultiplePaths.hasElements() ) { - aMultiplePaths.realloc(1); - aMultiplePaths[0] = aSinglePath; + aMultiplePaths = { aSinglePath }; } lcl_checkPaths( aMultiplePaths, *this ); // if we survived this, the paths are valid, and we're done here ... commit 1a5ddf061ef53fb9feda0ee319fa36cadef020da Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Oct 29 10:08:39 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Oct 31 15:49:25 2021 +0100 Prepare for removal of non-const operator[] from Sequence in stoc Change-Id: I2aabd9a1c764ae69a933bdb4df635ebb0c91f0cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124393 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index de8f9380a2f7..88dcc29ffdb7 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -743,8 +743,9 @@ Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses() if (!_xSuperClasses.hasElements()) { typelib_InterfaceTypeDescription * pType = getTypeDescr(); _xSuperClasses.realloc(pType->nBaseTypes); + auto pSuperClasses = _xSuperClasses.getArray(); for (sal_Int32 i = 0; i < pType->nBaseTypes; ++i) { - _xSuperClasses[i] = getReflection()->forType( + pSuperClasses[i] = getReflection()->forType( &pType->ppBaseTypes[i]->aBase); OSL_ASSERT(_xSuperClasses[i].is()); } diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 912ed434d29e..d0d57055b59d 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -674,18 +674,18 @@ void delete_all_singleton_entries( catch (registry::InvalidValueException &) { } - OUString const * p = registered_implnames.getConstArray(); + auto aNonConstRange = asNonConstRange(registered_implnames); sal_Int32 nOrigRegLength = registered_implnames.getLength(); sal_Int32 nNewLength = nOrigRegLength; for ( sal_Int32 n = nOrigRegLength; n--; ) { - OUString const & registered_implname = p[ n ]; + OUString const & registered_implname = registered_implnames[ n ]; for (auto const& impl_name : impl_names) { if (impl_name == registered_implname) { - registered_implnames[ n ] = p[ nNewLength -1 ]; + aNonConstRange[ n ] = registered_implnames[ nNewLength -1 ]; --nNewLength; } } @@ -890,7 +890,7 @@ void insert_singletons( { // append and write back implnames.realloc( implnames.getLength() +1 ); - implnames[ implnames.getLength() -1 ] = implname; + implnames.getArray()[ implnames.getLength() -1 ] = implname; xRegisteredImplNames->setAsciiListValue( implnames ); } } diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx index 08a6e94b9318..dfb281ae99fb 100644 --- a/stoc/source/javaloader/javaloader.cxx +++ b/stoc/source/javaloader/javaloader.cxx @@ -136,7 +136,7 @@ const css::uno::Reference<XImplementationLoader> & JavaComponentLoader::getJavaL // underlying JavaVM pointer: Sequence<sal_Int8> processID(17); rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8 *>(processID.getArray())); - processID[16] = 1; + processID.getArray()[16] = 1; // We get a non-refcounted pointer to a jvmaccess::UnoVirtualMachine // from the XJavaVM service (the pointer is guaranteed to be valid diff --git a/stoc/source/javavm/interact.cxx b/stoc/source/javavm/interact.cxx index 4836a0710c2d..d1399c065a89 100644 --- a/stoc/source/javavm/interact.cxx +++ b/stoc/source/javavm/interact.cxx @@ -81,10 +81,8 @@ bool InteractionRequest::RetryContinuation::isSelected() const InteractionRequest::InteractionRequest(css::uno::Any const & rRequest): m_aRequest(rRequest) { - m_aContinuations.realloc(2); m_xRetryContinuation = new RetryContinuation; - m_aContinuations[0] = new AbortContinuation; - m_aContinuations[1] = m_xRetryContinuation.get(); + m_aContinuations = { new AbortContinuation, m_xRetryContinuation }; } css::uno::Any SAL_CALL InteractionRequest::getRequest() diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx index 85825886b9ea..11c54444adef 100644 --- a/stoc/source/security/file_policy.cxx +++ b/stoc/source/security/file_policy.cxx @@ -444,14 +444,14 @@ void FilePolicy::refresh() Sequence< Any > perms( userPermissions[ userId ] ); sal_Int32 len = perms.getLength(); perms.realloc( len +1 ); - perms[ len ] = perm; + perms.getArray()[ len ] = perm; userPermissions[ userId ] = perms; } else { sal_Int32 len = defaultPermissions.getLength(); defaultPermissions.realloc( len +1 ); - defaultPermissions[ len ] = perm; + defaultPermissions.getArray()[ len ] = perm; } token = reader.assureToken(); // next permissions token diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 82f0335a0808..5fb5b3962495 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -641,9 +641,8 @@ Reference<XPropertySetInfo > OServiceManager::getPropertySetInfo() check_undisposed(); if (! m_xPropertyInfo.is()) { - Sequence< beans::Property > seq( 1 ); - seq[ 0 ] = beans::Property( - "DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 ); + Sequence< beans::Property > seq{ beans::Property( + "DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 ) }; Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); MutexGuard aGuard( m_mutex ); @@ -1422,12 +1421,11 @@ Reference<XPropertySetInfo > ORegistryServiceManager::getPropertySetInfo() check_undisposed(); if (! m_xPropertyInfo.is()) { - Sequence< beans::Property > seq( 2 ); - seq[ 0 ] = beans::Property( - "DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0 ); - seq[ 1 ] = beans::Property( - "Registry", -1, cppu::UnoType<decltype(m_xRegistry)>::get(), - beans::PropertyAttribute::READONLY ); + Sequence< beans::Property > seq{ + beans::Property("DefaultContext", -1, cppu::UnoType<decltype(m_xContext)>::get(), 0), + beans::Property("Registry", -1, cppu::UnoType<decltype(m_xRegistry)>::get(), + beans::PropertyAttribute::READONLY) + }; Reference< beans::XPropertySetInfo > xInfo( new PropertySetInfo_Impl( seq ) ); MutexGuard aGuard( m_mutex ); diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 6175de241400..0b7fae2b8641 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -305,8 +305,9 @@ css::uno::Sequence< sal_Int32 > Key::getLongListValue() static_cast< OWeakObject * >(this)); } css::uno::Sequence< sal_Int32 > value(static_cast< sal_Int32 >(n)); + auto aValueRange = asNonConstRange(value); for (sal_uInt32 i = 0; i < n; ++i) { - value[static_cast< sal_Int32 >(i)] = list.getElement(i); + aValueRange[static_cast< sal_Int32 >(i)] = list.getElement(i); } return value; } @@ -446,11 +447,12 @@ css::uno::Sequence< OUString > Key::getAsciiListValue() static_cast< OWeakObject * >(this)); } css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n)); + auto aValueRange = asNonConstRange(value); for (sal_uInt32 i = 0; i < n; ++i) { char * el = list.getElement(i); sal_Int32 size = rtl_str_getLength(el); if (!rtl_convertStringToUString( - &value[static_cast< sal_Int32 >(i)].pData, el, size, + &aValueRange[static_cast< sal_Int32 >(i)].pData, el, size, RTL_TEXTENCODING_UTF8, (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | @@ -600,8 +602,9 @@ css::uno::Sequence< OUString > Key::getStringListValue() static_cast< OWeakObject * >(this)); } css::uno::Sequence< OUString > value(static_cast< sal_Int32 >(n)); + auto aValueRange = asNonConstRange(value); for (sal_uInt32 i = 0; i < n; ++i) { - value[static_cast< sal_Int32 >(i)] = list.getElement(i); + aValueRange[static_cast< sal_Int32 >(i)] = list.getElement(i); } return value; } @@ -758,8 +761,9 @@ Key::openKeys() } css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > keys(static_cast< sal_Int32 >(n)); + auto aKeysRange = asNonConstRange(keys); for (sal_uInt32 i = 0; i < n; ++i) { - keys[static_cast< sal_Int32 >(i)] = new Key( + aKeysRange[static_cast< sal_Int32 >(i)] = new Key( registry_, list.getElement(i)); } return keys; @@ -784,8 +788,9 @@ css::uno::Sequence< OUString > Key::getKeyNames() static_cast< OWeakObject * >(this)); } css::uno::Sequence< OUString > names(static_cast< sal_Int32 >(n)); + auto aNamesRange = asNonConstRange(names); for (sal_uInt32 i = 0; i < n; ++i) { - names[static_cast< sal_Int32 >(i)] = list.getElement(i); + aNamesRange[static_cast< sal_Int32 >(i)] = list.getElement(i); } return names; }