diff options
43 files changed, 456 insertions, 454 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 4bae1c14a570..fa95d74ca458 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -395,8 +395,9 @@ ErrCode SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString & TransformItems( SID_OPENDOC, *pNew, aArgs ); sal_Int32 nLength = aArgs.getLength(); aArgs.realloc( nLength + 1 ); - aArgs[nLength].Name = "Title"; - aArgs[nLength].Value <<= xDoc->GetTitle( SFX_TITLE_DETECT ); + auto pArgs = aArgs.getArray(); + pArgs[nLength].Name = "Title"; + pArgs[nLength].Value <<= xDoc->GetTitle( SFX_TITLE_DETECT ); xModel->attachResource( OUString(), aArgs ); } diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 830ad973cd25..6be2bfc85d40 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -43,6 +43,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <svtools/addresstemplate.hxx> @@ -1404,9 +1405,8 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) case SID_MORE_DICTIONARIES: { - uno::Sequence<beans::PropertyValue> aArgs(1); - aArgs[0].Name = "AdditionsTag"; - aArgs[0].Value <<= OUString("Dictionary"); + uno::Sequence<beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + "AdditionsTag", OUString("Dictionary")) }; comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); break; } diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 5d0e582b03a6..ee4e2c32b955 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -566,11 +566,8 @@ void IndexTabPage_Impl::InitializeIndex() css::uno::Reference< css::beans::XPropertySetInfo > xInfo = aCnt.getProperties(); if ( xInfo->hasPropertyByName( PROPERTY_ANCHORREF ) ) { - css::uno::Sequence< OUString > aPropSeq( 4 ); - aPropSeq[0] = PROPERTY_KEYWORDLIST; - aPropSeq[1] = PROPERTY_KEYWORDREF; - aPropSeq[2] = PROPERTY_ANCHORREF; - aPropSeq[3] = PROPERTY_TITLEREF; + css::uno::Sequence< OUString > aPropSeq{ PROPERTY_KEYWORDLIST, PROPERTY_KEYWORDREF, + PROPERTY_ANCHORREF, PROPERTY_TITLEREF }; // abi: use one possibly remote call only css::uno::Sequence< css::uno::Any > aAnySeq = diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index b6be7cad2fc6..8d221e07d90e 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -46,6 +46,7 @@ #include <sfx2/docfilt.hxx> #include <sfx2/fcontnr.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <comphelper/extract.hxx> @@ -283,20 +284,15 @@ IMPL_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused*/, vo Sequence< OUString > sFiles = xPicker->getSelectedFiles(); int nFiles = sFiles.getLength(); - int nArgs=3; - Sequence< PropertyValue > aArgs(3); - css::uno::Reference < css::task::XInteractionHandler2 > xInteraction( task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), nullptr) ); - aArgs[0].Name = "InteractionHandler"; - aArgs[0].Value <<= xInteraction; - - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= sal_Int16(css::document::MacroExecMode::USE_CONFIG); - - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= sal_Int16(css::document::UpdateDocMode::ACCORDING_TO_CONFIG); + int nArgs=3; + Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("InteractionHandler", xInteraction), + comphelper::makePropertyValue("MacroExecutionMode", sal_Int16(css::document::MacroExecMode::USE_CONFIG)), + comphelper::makePropertyValue("UpdateDocMode", sal_Int16(css::document::UpdateDocMode::ACCORDING_TO_CONFIG)) + }; // use the filedlghelper to get the current filter name, // because it removes the extensions before you get the filter name. @@ -317,8 +313,9 @@ IMPL_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused*/, vo if ( bReadOnly ) { aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = "ReadOnly"; - aArgs[nArgs-1].Value <<= bReadOnly; + auto pArgs = aArgs.getArray(); + pArgs[nArgs-1].Name = "ReadOnly"; + pArgs[nArgs-1].Value <<= bReadOnly; } // Get version string @@ -332,8 +329,9 @@ IMPL_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused*/, vo sal_Int16 uVersion = static_cast<sal_Int16>(iVersion); aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = "Version"; - aArgs[nArgs-1].Value <<= uVersion; + auto pArgs = aArgs.getArray(); + pArgs[nArgs-1].Name = "Version"; + pArgs[nArgs-1].Value <<= uVersion; } // Retrieve the current filter @@ -357,8 +355,9 @@ IMPL_LINK( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused*/, vo if ( !aFilterName.isEmpty() ) { aArgs.realloc( ++nArgs ); - aArgs[nArgs-1].Name = "FilterName"; - aArgs[nArgs-1].Value <<= aFilterName; + auto pArgs = aArgs.getArray(); + pArgs[nArgs-1].Name = "FilterName"; + pArgs[nArgs-1].Value <<= aFilterName; } } } diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm index e36958ec3740..7e8bf071c95f 100644 --- a/sfx2/source/appl/shutdowniconaqua.mm +++ b/sfx2/source/appl/shutdowniconaqua.mm @@ -244,13 +244,14 @@ class RecentFilesStringLength : public ::cppu::WeakImplHelper< css::util::XStrin const RecentMenuEntry& rRecentFile = (*m_pRecentFilesItems)[ nIndex ]; int NUM_OF_PICKLIST_ARGS = 3; css::uno::Sequence< css::beans::PropertyValue > aArgsList( NUM_OF_PICKLIST_ARGS ); + css::beans::PropertyValue* pArgsList = aArgsList.getArray(); - aArgsList[0].Name = "Referer"; - aArgsList[0].Value <<= OUString( "private:user" ); + pArgsList[0].Name = "Referer"; + pArgsList[0].Value <<= OUString( "private:user" ); // documents in the picklist will never be opened as templates - aArgsList[1].Name = "AsTemplate"; - aArgsList[1].Value <<= false; + pArgsList[1].Name = "AsTemplate"; + pArgsList[1].Value <<= false; OUString aFilter( rRecentFile.aFilter ); sal_Int32 nPos = aFilter.indexOf( '|' ); @@ -261,15 +262,16 @@ class RecentFilesStringLength : public ::cppu::WeakImplHelper< css::util::XStrin if ( nPos < ( aFilter.getLength() - 1 ) ) aFilterOptions = aFilter.copy( nPos+1 ); - aArgsList[2].Name = "FilterOptions"; - aArgsList[2].Value <<= aFilterOptions; + pArgsList[2].Name = "FilterOptions"; + pArgsList[2].Value <<= aFilterOptions; aFilter = aFilter.copy( 0, nPos-1 ); aArgsList.realloc( ++NUM_OF_PICKLIST_ARGS ); + pArgsList = aArgsList.getArray(); } - aArgsList[NUM_OF_PICKLIST_ARGS-1].Name = "FilterName"; - aArgsList[NUM_OF_PICKLIST_ARGS-1].Value <<= aFilter; + pArgsList[NUM_OF_PICKLIST_ARGS-1].Name = "FilterName"; + pArgsList[NUM_OF_PICKLIST_ARGS-1].Value <<= aFilter; ShutdownIcon::OpenURL( rRecentFile.aURL, "_default", aArgsList ); } diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index 99f5c5796d08..eb5b5662a817 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -23,6 +23,7 @@ #include <vcl/svapp.hxx> #include <sfx2/charwin.hxx> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertyvalue.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -98,12 +99,9 @@ void SvxCharView::InsertCharToDoc() if (GetText().isEmpty()) return; - uno::Sequence<beans::PropertyValue> aArgs(2); - aArgs[0].Name = "Symbols"; - aArgs[0].Value <<= GetText(); - - aArgs[1].Name = "FontName"; - aArgs[1].Value <<= maFont.GetFamilyName(); + uno::Sequence<beans::PropertyValue> aArgs{ comphelper::makePropertyValue("Symbols", GetText()), + comphelper::makePropertyValue( + "FontName", maFont.GetFamilyName()) }; comphelper::dispatchCommand(".uno:InsertSymbol", aArgs); } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index e4965467ed0e..6c6b3134404d 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1706,10 +1706,11 @@ void SfxDispatcher::ExecutePopup( vcl::Window *pWin, const Point *pPos ) void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, const Point* pPos ) { - css::uno::Sequence< css::uno::Any > aArgs( 3 ); - aArgs[0] <<= comphelper::makePropertyValue( "Value", rResName ); - aArgs[1] <<= comphelper::makePropertyValue( "Frame", GetFrame()->GetFrame().GetFrameInterface() ); - aArgs[2] <<= comphelper::makePropertyValue( "IsContextMenu", true ); + css::uno::Sequence< css::uno::Any > aArgs{ + css::uno::Any(comphelper::makePropertyValue( "Value", rResName )), + css::uno::Any(comphelper::makePropertyValue( "Frame", GetFrame()->GetFrame().GetFrameInterface() )), + css::uno::Any(comphelper::makePropertyValue( "IsContextMenu", true )) + }; css::uno::Reference< css::uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); css::uno::Reference< css::frame::XPopupMenuController > xPopupController( diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index 3da4bfb88818..f942b1ffbb15 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -68,9 +68,7 @@ bool IsDocEncrypted(const OUString& rURL) { uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create(xContext); - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= rURL; - aArgs[1] <<= embed::ElementModes::READ; + uno::Sequence<uno::Any> aArgs{ uno::Any(rURL), uno::Any(embed::ElementModes::READ) }; uno::Reference<embed::XStorage> xDocStorage ( xStorageFactory->createInstanceWithArguments(aArgs), uno::UNO_QUERY); diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx index 0d0648f222a8..6f046e3dc6e8 100644 --- a/sfx2/source/control/recentdocsviewitem.cxx +++ b/sfx2/source/control/recentdocsviewitem.cxx @@ -9,6 +9,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/util/URLTransformer.hpp> + +#include <comphelper/propertyvalue.hxx> #include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <i18nutil/paper.hxx> @@ -189,13 +191,9 @@ void RecentDocsViewItem::OpenDocument() Reference<util::XURLTransformer> xTrans(util::URLTransformer::create(::comphelper::getProcessComponentContext())); xTrans->parseStrict(aTargetURL); - aArgsList.realloc(2); - aArgsList[0].Name = "Referer"; - aArgsList[0].Value <<= OUString("private:user"); - - // documents will never be opened as templates - aArgsList[1].Name = "AsTemplate"; - aArgsList[1].Value <<= false; + aArgsList = { comphelper::makePropertyValue("Referer", OUString("private:user")), + // documents will never be opened as templates + comphelper::makePropertyValue("AsTemplate", false) }; xDispatch = xDesktop->queryDispatch(aTargetURL, "_default", 0); diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index cac6ad5175a0..964a256b19a7 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -355,7 +355,7 @@ void SfxRequest_Impl::Record aStatement.aArgs[0].Value >>= aStr; rArgs[0].Value >>= aNew; aStr += aNew; - aStatement.aArgs[0].Value <<= aStr; + aStatement.aArgs.getArray()[0].Value <<= aStr; aElement <<= aStatement; xReplace->replaceByIndex( nCount-1, aElement ); return; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 284376d974fd..04de9a437550 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -66,9 +66,7 @@ BitmapEx ThumbnailView::readThumbnail(const OUString &msURL) { uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create(xContext); - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= msURL; - aArgs[1] <<= embed::ElementModes::READ; + uno::Sequence<uno::Any> aArgs{ uno::Any(msURL), uno::Any(embed::ElementModes::READ) }; uno::Reference<embed::XStorage> xDocStorage ( xStorageFactory->createInstanceWithArguments(aArgs), uno::UNO_QUERY); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index a095d5a656fb..b01500814bc9 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -437,52 +437,53 @@ void SfxDispatchController_Impl::addParametersToArgs( const css::util::URL& aURL sal_Int32 nLen = rArgs.getLength(); rArgs.realloc( nLen+1 ); - rArgs[nLen].Name = aParamName; + auto pArgs = rArgs.getArray(); + pArgs[nLen].Name = aParamName; if ( aParamType.isEmpty() ) { // Default: LONG - rArgs[nLen].Value <<= aValue.toInt32(); + pArgs[nLen].Value <<= aValue.toInt32(); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BOOL], 4 )) { // sal_Bool support - rArgs[nLen].Value <<= aValue.toBoolean(); + pArgs[nLen].Value <<= aValue.toBoolean(); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_BYTE], 4 )) { // sal_uInt8 support - rArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); + pArgs[nLen].Value <<= sal_Int8( aValue.toInt32() ); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_LONG], 4 )) { // LONG support - rArgs[nLen].Value <<= aValue.toInt32(); + pArgs[nLen].Value <<= aValue.toInt32(); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_SHORT], 5 )) { // SHORT support - rArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); + pArgs[nLen].Value <<= sal_Int16( aValue.toInt32() ); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_HYPER], 5 )) { // HYPER support - rArgs[nLen].Value <<= aValue.toInt64(); + pArgs[nLen].Value <<= aValue.toInt64(); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_FLOAT], 5 )) { // FLOAT support - rArgs[nLen].Value <<= aValue.toFloat(); + pArgs[nLen].Value <<= aValue.toFloat(); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_STRING], 6 )) { // STRING support - rArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); + pArgs[nLen].Value <<= INetURLObject::decode( aValue, INetURLObject::DecodeMechanism::WithCharset ); } else if ( aParamType.equalsAsciiL( URLTypeNames[URLType_DOUBLE], 6)) { // DOUBLE support - rArgs[nLen].Value <<= aValue.toDouble(); + pArgs[nLen].Value <<= aValue.toDouble(); } } while ( nIndex >= 0 ); @@ -609,7 +610,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, // we offer dispatches for SID_JUMPTOMARK if the URL points to a bookmark inside the document // so we must retrieve this as an argument from the parsed URL lNewArgs.realloc( lNewArgs.getLength()+1 ); - auto& el = lNewArgs[lNewArgs.getLength()-1]; + auto& el = lNewArgs.getArray()[lNewArgs.getLength()-1]; el.Name = "Bookmark"; el.Value <<= aURL.Mark; } @@ -651,8 +652,9 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, // have an argument that has the same name as the master slot and type is SfxStringItem. sal_Int32 nIndex = lNewArgs.getLength(); lNewArgs.realloc( nIndex+1 ); - lNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); - lNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); + auto plNewArgs = lNewArgs.getArray(); + plNewArgs[nIndex].Name = OUString::createFromAscii( pSlot->pUnoName ); + plNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); } eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 3a95cef10e51..e67eeee27c6b 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -35,6 +35,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <sfx2/app.hxx> #include <officecfg/Office/Common.hxx> @@ -658,15 +659,12 @@ IMPL_LINK(BackingWindow, CreateContextMenuHdl, ThumbnailViewItem*, pItem, void) IMPL_LINK(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem, void) { - uno::Sequence< PropertyValue > aArgs(4); - aArgs[0].Name = "AsTemplate"; - aArgs[0].Value <<= true; - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= MacroExecMode::USE_CONFIG; - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; - aArgs[3].Name = "InteractionHandler"; - aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ); + uno::Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("AsTemplate", true), + comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG), + comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG), + comphelper::makePropertyValue("InteractionHandler", task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr )) + }; TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem); @@ -683,13 +681,11 @@ IMPL_LINK(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem, void) IMPL_LINK(BackingWindow, EditTemplateHdl, ThumbnailViewItem*, pItem, void) { - uno::Sequence< PropertyValue > aArgs(3); - aArgs[0].Name = "AsTemplate"; - aArgs[0].Value <<= false; - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= MacroExecMode::USE_CONFIG; - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; + uno::Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("AsTemplate", false), + comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG), + comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG), + }; TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 7462f840d1ec..e702c7c9457f 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -28,6 +28,7 @@ #include <unotools/localedatawrapper.hxx> #include <unotools/cmdoptions.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/stl_types.hxx> #include <comphelper/xmlsechelper.hxx> #include <unotools/useroptions.hxx> @@ -1519,12 +1520,9 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() StoreCustomProperties(); Sequence< beans::PropertyValue > aPropertiesSeq(GetTotalLineCount()); - - for (sal_uInt32 i = 0; i < GetTotalLineCount(); ++i) - { - aPropertiesSeq[i].Name = m_aCustomProperties[i]->m_sName; - aPropertiesSeq[i].Value = m_aCustomProperties[i]->m_aValue; - } + std::transform( + m_aCustomProperties.begin(), m_aCustomProperties.end(), aPropertiesSeq.getArray(), + [](const auto& el) { return comphelper::makePropertyValue(el->m_sName, el->m_aValue); }); return aPropertiesSeq; } @@ -2150,28 +2148,30 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() const { Sequence< document::CmisProperty > aPropertiesSeq( m_aCmisPropertiesLines.size() ); + auto aPropertiesSeqRange = asNonConstRange(aPropertiesSeq); sal_Int32 i = 0; for ( auto& rxLine : m_aCmisPropertiesLines ) { CmisPropertyLine* pLine = rxLine.get(); - aPropertiesSeq[i].Id = pLine->m_sId; - aPropertiesSeq[i].Type = pLine->m_sType; - aPropertiesSeq[i].Updatable = pLine->m_bUpdatable; - aPropertiesSeq[i].Required = pLine->m_bRequired; - aPropertiesSeq[i].OpenChoice = pLine->m_bOpenChoice; - aPropertiesSeq[i].MultiValued = pLine->m_bMultiValued; + aPropertiesSeqRange[i].Id = pLine->m_sId; + aPropertiesSeqRange[i].Type = pLine->m_sType; + aPropertiesSeqRange[i].Updatable = pLine->m_bUpdatable; + aPropertiesSeqRange[i].Required = pLine->m_bRequired; + aPropertiesSeqRange[i].OpenChoice = pLine->m_bOpenChoice; + aPropertiesSeqRange[i].MultiValued = pLine->m_bMultiValued; OUString sPropertyName = pLine->m_xName->get_label(); if ( !sPropertyName.isEmpty() ) { - aPropertiesSeq[i].Name = sPropertyName; + aPropertiesSeqRange[i].Name = sPropertyName; OUString sType = pLine->m_xType->get_label(); if ( CMIS_TYPE_DECIMAL == sType ) { sal_uInt32 nIndex = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM ); Sequence< double > seqValue( pLine->m_aValues.size( ) ); + auto seqValueRange = asNonConstRange(seqValue); sal_Int32 k = 0; for ( const auto& rxValue : pLine->m_aValues ) { @@ -2180,16 +2180,17 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ). IsNumberFormat( sValue, nIndex, dValue ); if ( bIsNum ) - seqValue[k] = dValue; + seqValueRange[k] = dValue; ++k; } - aPropertiesSeq[i].Value <<= seqValue; + aPropertiesSeqRange[i].Value <<= seqValue; } else if ( CMIS_TYPE_INTEGER == sType ) { sal_uInt32 nIndex = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM ); Sequence< sal_Int64 > seqValue( pLine->m_aValues.size( ) ); + auto seqValueRange = asNonConstRange(seqValue); sal_Int32 k = 0; for ( const auto& rxValue : pLine->m_aValues ) { @@ -2198,27 +2199,29 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ). IsNumberFormat( sValue, nIndex, dValue ); if ( bIsNum ) - seqValue[k] = static_cast<sal_Int64>(dValue); + seqValueRange[k] = static_cast<sal_Int64>(dValue); ++k; } - aPropertiesSeq[i].Value <<= seqValue; + aPropertiesSeqRange[i].Value <<= seqValue; } else if ( CMIS_TYPE_BOOL == sType ) { Sequence<sal_Bool> seqValue( pLine->m_aYesNos.size( ) ); + sal_Bool* pseqValue = seqValue.getArray(); sal_Int32 k = 0; for ( const auto& rxYesNo : pLine->m_aYesNos ) { bool bValue = rxYesNo->m_xYesButton->get_active(); - seqValue[k] = bValue; + pseqValue[k] = bValue; ++k; } - aPropertiesSeq[i].Value <<= seqValue; + aPropertiesSeqRange[i].Value <<= seqValue; } else if ( CMIS_TYPE_DATETIME == sType ) { Sequence< util::DateTime > seqValue( pLine->m_aDateTimes.size( ) ); + auto seqValueRange = asNonConstRange(seqValue); sal_Int32 k = 0; for ( const auto& rxDateTime : pLine->m_aDateTimes ) { @@ -2228,22 +2231,23 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con aTmpTime.GetMin(), aTmpTime.GetHour(), aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear(), true ); - seqValue[k] = aDateTime; + seqValueRange[k] = aDateTime; ++k; } - aPropertiesSeq[i].Value <<= seqValue; + aPropertiesSeqRange[i].Value <<= seqValue; } else { Sequence< OUString > seqValue( pLine->m_aValues.size( ) ); + auto seqValueRange = asNonConstRange(seqValue); sal_Int32 k = 0; for ( const auto& rxValue : pLine->m_aValues ) { OUString sValue( rxValue->m_xValueEdit->get_text() ); - seqValue[k] = sValue; + seqValueRange[k] = sValue; ++k; } - aPropertiesSeq[i].Value <<= seqValue; + aPropertiesSeqRange[i].Value <<= seqValue; } } ++i; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 35fc5d166e11..23c2b097a23c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -611,7 +611,7 @@ void FileDialogHelper_Impl::updateVersions() const uno::Sequence < util::RevisionTag > xVersions = SfxMedium::GetVersionList( xStorage ); aEntries.realloc( xVersions.getLength() + 1 ); - aEntries[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ); + aEntries.getArray()[0] = SfxResId( STR_SFX_FILEDLG_ACTUALVERSION ); std::transform(xVersions.begin(), xVersions.end(), std::next(aEntries.getArray()), [](const util::RevisionTag& rVersion) -> OUString { return rVersion.Identifier; }); @@ -1036,6 +1036,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( auto xWindow = GetFrameInterface(); Sequence < Any > aInitArguments(!xWindow.is() ? 3 : 4); + auto pInitArguments = aInitArguments.getArray(); // This is a hack. We currently know that the internal file picker implementation // supports the extended arguments as specified below. @@ -1044,30 +1045,30 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( // b) adjust the implementation of the system file picker to that it recognizes it if ( mbSystemPicker ) { - aInitArguments[0] <<= nTemplateDescription; + pInitArguments[0] <<= nTemplateDescription; if (xWindow.is()) - aInitArguments[1] <<= xWindow; + pInitArguments[1] <<= xWindow; } else { - aInitArguments[0] <<= NamedValue( + pInitArguments[0] <<= NamedValue( "TemplateDescription", makeAny( nTemplateDescription ) ); - aInitArguments[1] <<= NamedValue( + pInitArguments[1] <<= NamedValue( "StandardDir", makeAny( sStandardDir ) ); - aInitArguments[2] <<= NamedValue( + pInitArguments[2] <<= NamedValue( "DenyList", makeAny( rDenyList ) ); if (xWindow.is()) - aInitArguments[3] <<= NamedValue("ParentWindow", makeAny(xWindow)); + pInitArguments[3] <<= NamedValue("ParentWindow", makeAny(xWindow)); } try @@ -1149,10 +1150,7 @@ css::uno::Reference<css::ui::dialogs::XFolderPicker2> createFolderPicker(const c uno::Reference< XInitialization > xInit(xRet, UNO_QUERY); if (xInit.is()) { - Sequence<Any> aInitArguments(2); - - aInitArguments[0] <<= sal_Int32(0); - aInitArguments[1] <<= pPreferredParent->GetXWindow(); + Sequence<Any> aInitArguments{ Any(sal_Int32(0)), Any(pPreferredParent->GetXWindow()) }; try { @@ -2672,6 +2670,7 @@ Sequence< OUString > FileDialogHelper::GetSelectedFiles() const if ( nFiles > 1 ) { aResultSeq = Sequence< OUString >( nFiles-1 ); + auto pResultSeq = aResultSeq.getArray(); INetURLObject aPath( lFiles[0] ); aPath.setFinalSlash(); @@ -2683,7 +2682,7 @@ Sequence< OUString > FileDialogHelper::GetSelectedFiles() const else aPath.setName( lFiles[i] ); - aResultSeq[i-1] = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + pResultSeq[i-1] = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); } } else diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index dcdc1a1a32c3..195fa09dd9bc 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -1016,12 +1016,13 @@ namespace sfx2 if ( !aImportantFilterGroup.empty() ) { Sequence< StringPair > aFilters( aImportantFilterGroup.size() ); + auto pFilters = aFilters.getArray(); for ( sal_Int32 i = 0; i < static_cast<sal_Int32>(aImportantFilterGroup.size()); i++ ) { - aFilters[i].First = addExtension( aImportantFilterGroup[i].aUIName, + pFilters[i].First = addExtension( aImportantFilterGroup[i].aUIName, aImportantFilterGroup[i].aWildcard, false, _rFileDlgImpl ); - aFilters[i].Second = aImportantFilterGroup[i].aWildcard; + pFilters[i].Second = aImportantFilterGroup[i].aWildcard; } try @@ -1036,12 +1037,13 @@ namespace sfx2 if ( !aFilterGroup.empty() ) { Sequence< StringPair > aFilters( aFilterGroup.size() ); + auto pFilters = aFilters.getArray(); for ( sal_Int32 i = 0; i < static_cast<sal_Int32>(aFilterGroup.size()); i++ ) { - aFilters[i].First = addExtension( aFilterGroup[i].aUIName, + pFilters[i].First = addExtension( aFilterGroup[i].aUIName, aFilterGroup[i].aWildcard, false, _rFileDlgImpl ); - aFilters[i].Second = aFilterGroup[i].aWildcard; + pFilters[i].Second = aFilterGroup[i].aWildcard; } try diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index 503efaae7ecf..382a677369f4 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -52,6 +52,7 @@ #include <tools/urlobj.hxx> #include <unotools/useroptions.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/string.hxx> #include <vcl/svapp.hxx> @@ -149,7 +150,6 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( if( xFilterDialog.is() && xFilterProperties.is() ) { - uno::Sequence< beans::PropertyValue > aPropsForDialog(1); uno::Reference< document::XExporter > xExporter( xFilterDialog, uno::UNO_QUERY ); if ( rType == PDF_DOCUMENT_TYPE ) @@ -157,13 +157,15 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( //add an internal property, used to tell the dialog we want to set a different //string for the ok button //used in filter/source/pdf/impdialog.cxx - uno::Sequence< beans::PropertyValue > aFilterDataValue(1); - aFilterDataValue[0].Name = "_OkButtonString"; - aFilterDataValue[0].Value <<= SfxResId(STR_PDF_EXPORT_SEND ); + uno::Sequence< beans::PropertyValue > aFilterDataValue{ + comphelper::makePropertyValue("_OkButtonString", + SfxResId(STR_PDF_EXPORT_SEND )) + }; //add to the filterdata property, the only one the PDF export filter dialog will care for - aPropsForDialog[0].Name = "FilterData"; - aPropsForDialog[0].Value <<= aFilterDataValue; + uno::Sequence< beans::PropertyValue > aPropsForDialog{ + comphelper::makePropertyValue("FilterData", aFilterDataValue) + }; //when executing the dialog will merge the persistent FilterData properties xFilterProperties->setPropertyValues( aPropsForDialog ); @@ -184,8 +186,9 @@ SfxMailModel::SaveResult SfxMailModel::ShowFilterOptionsDialog( { //found the filterdata, add to the storing argument rArgs.realloc( ++rNumArgs ); - rArgs[rNumArgs-1].Name = pProp->Name; - rArgs[rNumArgs-1].Value = pProp->Value; + auto pArgs = rArgs.getArray(); + pArgs[rNumArgs-1].Name = pProp->Name; + pArgs[rNumArgs-1].Value = pProp->Value; } eRet = SAVE_SUCCESSFUL; } @@ -308,10 +311,11 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( { // Retrieve filter from type css::uno::Sequence< css::beans::NamedValue > aQuery( bSendAsPDF ? 3 : 2 ); - aQuery[0].Name = "Type"; - aQuery[0].Value <<= aTypeName; - aQuery[1].Name = "DocumentService"; - aQuery[1].Value <<= aModule; + auto pQuery = aQuery.getArray(); + pQuery[0].Name = "Type"; + pQuery[0].Value <<= aTypeName; + pQuery[1].Name = "DocumentService"; + pQuery[1].Value <<= aModule; if( bSendAsPDF ) { // #i91419# @@ -319,8 +323,8 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( // exact flag value as detailed in the filter configuration to get it // this seems to be a bug // without flags we get an import filter here, which is also unwanted - aQuery[2].Name = "Flags"; - aQuery[2].Value <<= sal_Int32(0x80042); // EXPORT ALIEN 3RDPARTY + pQuery[2].Name = "Flags"; + pQuery[2].Value <<= sal_Int32(0x80042); // SfxFilterFlags: EXPORT ALIEN 3RDPARTY } css::uno::Reference< css::container::XEnumeration > xEnumeration = @@ -461,11 +465,10 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( OUString aFileURL = aFilePathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - sal_Int32 nNumArgs(0); + sal_Int32 nNumArgs(1); static const OUStringLiteral aPasswordPropName( u"Password" ); - css::uno::Sequence< css::beans::PropertyValue > aArgs( ++nNumArgs ); - aArgs[nNumArgs-1].Name = "FilterName"; - aArgs[nNumArgs-1].Value <<= aFilterName; + css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue( + "FilterName", aFilterName) }; ::comphelper::SequenceAsHashMap aMediaDescrPropsHM( xModel->getArgs() ); OUString aPassword = aMediaDescrPropsHM.getUnpackedValueOrDefault( @@ -474,8 +477,9 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( if ( !aPassword.isEmpty() ) { aArgs.realloc( ++nNumArgs ); - aArgs[nNumArgs-1].Name = aPasswordPropName; - aArgs[nNumArgs-1].Value <<= aPassword; + auto pArgs = aArgs.getArray(); + pArgs[nNumArgs-1].Name = aPasswordPropName; + pArgs[nNumArgs-1].Value <<= aPassword; } bool bNeedsPreparation = false; @@ -600,8 +604,9 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( { // We need 1:1 copy of the document to preserve an added signature. aArgs.realloc( ++nNumArgs ); - aArgs[nNumArgs-1].Name = "CopyStreamIfPossible"; - aArgs[nNumArgs-1].Value <<= true; + auto pArgs = aArgs.getArray(); + pArgs[nNumArgs-1].Name = "CopyStreamIfPossible"; + pArgs[nNumArgs-1].Value <<= true; try { @@ -715,8 +720,8 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css: if ( nToCount > 1 ) { Sequence< OUString > aCcRecipientSeq( nToCount - 1 ); - for ( size_t i = 1; i < nToCount; ++i ) - aCcRecipientSeq[i - 1] = mpToList->at(i); + std::copy_n(std::next(mpToList->begin()), aCcRecipientSeq.getLength(), + aCcRecipientSeq.getArray()); xSimpleMailMessage->setCcRecipient( aCcRecipientSeq ); } diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index ef056973efe6..12a8f9ff3a51 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -32,6 +32,7 @@ #include <svl/stritem.hxx> #include <svl/style.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/ModuleManager.hpp> @@ -633,9 +634,8 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, LoadFactoryStyleFilter_Hdl, SfxObjectShe void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell const * i_pObjSh, sal_Int32 i_nFilter ) { OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" ); - Sequence< PropertyValue > lProps(1); - lProps[0].Name = "ooSetupFactoryStyleFilter"; - lProps[0].Value <<= i_nFilter | (m_bWantHierarchical ? 0x1000 : 0); + Sequence< PropertyValue > lProps{ comphelper::makePropertyValue( + "ooSetupFactoryStyleFilter", i_nFilter | (m_bWantHierarchical ? 0x1000 : 0)) }; xModuleManager->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) ); } diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index fd31efd621a9..2c57215c39fd 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -77,6 +77,7 @@ #include <i18nlangtag/languagetag.hxx> #include <optional> +#include <algorithm> #include <utility> #include <vector> #include <map> @@ -724,9 +725,8 @@ SfxDocumentMetaData::getMetaList(const char* i_name) const std::vector<css::uno::Reference<css::xml::dom::XNode> > const & vec = m_metaList.find(name)->second; css::uno::Sequence< OUString> ret(vec.size()); - for (size_t i = 0; i < vec.size(); ++i) { - ret[i] = getNodeText(vec.at(i)); - } + std::transform(vec.begin(), vec.end(), ret.getArray(), + [](const auto& node) { return getNodeText(node); }); return ret; } @@ -1757,8 +1757,7 @@ SfxDocumentMetaData::loadFromStorage( } catch (const css::uno::Exception &) { input.sSystemId = s_meta; } - css::uno::Sequence< css::uno::Any > args(1); - args[0] <<= xPropArg; + css::uno::Sequence< css::uno::Any > args{ css::uno::Any(xPropArg) }; // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler css::uno::Reference<XInterface> xFilter = @@ -1837,9 +1836,7 @@ SfxDocumentMetaData::storeToStorage( // set base URL css::uno::Reference<css::beans::XPropertySet> xPropArg = getURLProperties(Medium); - css::uno::Sequence< css::uno::Any > args(2); - args[0] <<= xSaxWriter; - args[1] <<= xPropArg; + css::uno::Sequence< css::uno::Any > args{ css::uno::Any(xSaxWriter), css::uno::Any(xPropArg) }; css::uno::Reference<css::document::XExporter> xExp( xMsf->createInstanceWithArgumentsAndContext( @@ -2101,21 +2098,22 @@ void SfxDocumentMetaData::createUserDefined() if ( m_xUserDefined.is() ) return; - css::uno::Sequence<css::uno::Type> types(13); - types[ 0] = ::cppu::UnoType<bool>::get(); - types[ 1] = ::cppu::UnoType< OUString>::get(); - types[ 2] = ::cppu::UnoType<css::util::DateTime>::get(); - types[ 3] = ::cppu::UnoType<css::util::Date>::get(); - types[ 4] = ::cppu::UnoType<css::util::DateTimeWithTimezone>::get(); - types[ 5] = ::cppu::UnoType<css::util::DateWithTimezone>::get(); - types[ 6] = ::cppu::UnoType<css::util::Duration>::get(); - types[ 7] = ::cppu::UnoType<float>::get(); - types[ 8] = ::cppu::UnoType<double>::get(); - types[ 9] = ::cppu::UnoType<sal_Int16>::get(); - types[10] = ::cppu::UnoType<sal_Int32>::get(); - types[11] = ::cppu::UnoType<sal_Int64>::get(); - // Time is supported for backward compatibility with OOo 3.x, x<=2 - types[12] = ::cppu::UnoType<css::util::Time>::get(); + css::uno::Sequence<css::uno::Type> types{ + ::cppu::UnoType<bool>::get(), + ::cppu::UnoType< OUString>::get(), + ::cppu::UnoType<css::util::DateTime>::get(), + ::cppu::UnoType<css::util::Date>::get(), + ::cppu::UnoType<css::util::DateTimeWithTimezone>::get(), + ::cppu::UnoType<css::util::DateWithTimezone>::get(), + ::cppu::UnoType<css::util::Duration>::get(), + ::cppu::UnoType<float>::get(), + ::cppu::UnoType<double>::get(), + ::cppu::UnoType<sal_Int16>::get(), + ::cppu::UnoType<sal_Int32>::get(), + ::cppu::UnoType<sal_Int64>::get(), + // Time is supported for backward compatibility with OOo 3.x, x<=2 + ::cppu::UnoType<css::util::Time>::get() + }; // #i94175#: ODF allows empty user-defined property names! m_xUserDefined.set( css::beans::PropertyBag::createWithTypes( m_xContext, types, true/*AllowEmptyPropertyName*/, false/*AutomaticAddition*/ ), diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx index 93c5ab52ab47..cc041670f997 100644 --- a/sfx2/source/doc/docfac.cxx +++ b/sfx2/source/doc/docfac.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <unotools/moduleoptions.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/configurationhelper.hxx> @@ -200,20 +201,19 @@ void SfxObjectFactory::SetSystemTemplate( const OUString& rServiceName, const OU OUString aFilterName = aProps2.getUnpackedValueOrDefault("PreferredFilter", OUString() ); - uno::Sequence< beans::PropertyValue > aArgs( 3 ); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= aFilterName; - aArgs[1].Name = "AsTemplate"; - aArgs[1].Value <<= true; - aArgs[2].Name = "URL"; - aArgs[2].Value <<= rTemplateName; + uno::Sequence< beans::PropertyValue > aArgs{ + comphelper::makePropertyValue("FilterName", aFilterName), + comphelper::makePropertyValue("AsTemplate", true), + comphelper::makePropertyValue("URL", rTemplateName) + }; uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( rServiceName ), uno::UNO_QUERY ); xLoadable->load( aArgs ); aArgs.realloc( 2 ); - aArgs[1].Name = "Overwrite"; - aArgs[1].Value <<= true; + auto pArgs = aArgs.getArray(); + pArgs[1].Name = "Overwrite"; + pArgs[1].Value <<= true; uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY ); xStorable->storeToURL( sUserTemplateURL, aArgs ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index fde26ee2911a..374ca83a81eb 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -75,6 +75,7 @@ #include <unotools/tempfile.hxx> #include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/interaction.hxx> #include <comphelper/sequence.hxx> #include <comphelper/simplefileaccessinteraction.hxx> @@ -526,9 +527,10 @@ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) { ::rtl::Reference< ::ucbhelper::InteractionRequest > xInteractionRequestImpl = new ::ucbhelper::InteractionRequest( uno::makeAny( document::ChangedByOthersRequest() ) ); - uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 3 ); - aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ); - aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ); + uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations{ + new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ), + new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ) + }; xInteractionRequestImpl->setContinuations( aContinuations ); xHandler->handle( xInteractionRequestImpl ); @@ -1096,14 +1098,15 @@ SfxMedium::ShowLockResult SfxMedium::ShowLockedDocumentDialog(const LockFileEntr } uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations(nContinuations); - aContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ); - aContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ); - aContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() ); + auto pContinuations = aContinuations.getArray(); + pContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ); + pContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() ); + pContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() ); if (nContinuations > 3) { // We use InteractionRetry to reflect that user wants to // ignore the (stale?) alien lock file and open/overwrite the document - aContinuations[3] = new ::ucbhelper::InteractionRetry(xInteractionRequestImpl.get()); + pContinuations[3] = new ::ucbhelper::InteractionRetry(xInteractionRequestImpl.get()); } xInteractionRequestImpl->setContinuations( aContinuations ); @@ -1187,11 +1190,10 @@ bool SfxMedium::ShowReadOnlyOpenDialog() OUString(), uno::Reference<uno::XInterface>(), aDocumentURL))); if (xInteractionRequestImpl != nullptr) { - sal_Int32 nContinuations = 2; - uno::Sequence<uno::Reference<task::XInteractionContinuation>> aContinuations( - nContinuations); - aContinuations[0] = new ::ucbhelper::InteractionAbort(xInteractionRequestImpl.get()); - aContinuations[1] = new ::ucbhelper::InteractionApprove(xInteractionRequestImpl.get()); + uno::Sequence<uno::Reference<task::XInteractionContinuation>> aContinuations{ + new ::ucbhelper::InteractionAbort(xInteractionRequestImpl.get()), + new ::ucbhelper::InteractionApprove(xInteractionRequestImpl.get()) + }; xInteractionRequestImpl->setContinuations(aContinuations); xHandler->handle(xInteractionRequestImpl); ::rtl::Reference<::ucbhelper::InteractionContinuation> xSelected @@ -1231,9 +1233,10 @@ bool SfxMedium::ShowLockFileProblemDialog(MessageDlg nWhichDlg) break; } - uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations(2); - aContinuations[0] = new ::ucbhelper::InteractionAbort(xIgnoreRequestImpl.get()); - aContinuations[1] = new ::ucbhelper::InteractionApprove(xIgnoreRequestImpl.get()); + uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations{ + new ::ucbhelper::InteractionAbort(xIgnoreRequestImpl.get()), + new ::ucbhelper::InteractionApprove(xIgnoreRequestImpl.get()) + }; xIgnoreRequestImpl->setContinuations(aContinuations); xHandler->handle(xIgnoreRequestImpl); @@ -1693,6 +1696,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempFile ) return pImpl->xStorage; uno::Sequence< uno::Any > aArgs( 2 ); + auto pArgs = aArgs.getArray(); // the medium should be retrieved before temporary file creation // to let the MediaDescriptor be filled with the streams @@ -1720,44 +1724,45 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempFile ) if( pxProgressItem && ( pxProgressItem->GetValue() >>= xStatusIndicator ) ) xProgressHandler.set( new utl::ProgressHandlerWrap( xStatusIndicator ) ); - uno::Sequence< beans::PropertyValue > aAddProps( 2 ); - aAddProps[0].Name = "RepairPackage"; - aAddProps[0].Value <<= true; - aAddProps[1].Name = "StatusIndicator"; - aAddProps[1].Value <<= xProgressHandler; + uno::Sequence< beans::PropertyValue > aAddProps{ + comphelper::makePropertyValue("RepairPackage", true), + comphelper::makePropertyValue("StatusIndicator", xProgressHandler) + }; // the first arguments will be filled later aArgs.realloc( 3 ); - aArgs[2] <<= aAddProps; + pArgs = aArgs.getArray(); + pArgs[2] <<= aAddProps; } if ( pImpl->xStream.is() ) { // since the storage is based on temporary stream we open it always read-write - aArgs[0] <<= pImpl->xStream; - aArgs[1] <<= embed::ElementModes::READWRITE; + pArgs[0] <<= pImpl->xStream; + pArgs[1] <<= embed::ElementModes::READWRITE; pImpl->bStorageBasedOnInStream = true; if (pImpl->m_bDisableFileSync) { // Forward NoFileSync to the storage factory. - aArgs.realloc(3); + aArgs.realloc(3); // ??? this may re-write the data added above for pRepairItem + pArgs = aArgs.getArray(); uno::Sequence<beans::PropertyValue> aProperties( comphelper::InitPropertySequence({ { "NoFileSync", uno::makeAny(true) } })); - aArgs[2] <<= aProperties; + pArgs[2] <<= aProperties; } } else if ( pImpl->xInputStream.is() ) { // since the storage is based on temporary stream we open it always read-write - aArgs[0] <<= pImpl->xInputStream; - aArgs[1] <<= embed::ElementModes::READ; + pArgs[0] <<= pImpl->xInputStream; + pArgs[1] <<= embed::ElementModes::READ; pImpl->bStorageBasedOnInStream = true; } else { CloseStreams_Impl(); - aArgs[0] <<= pImpl->m_aName; - aArgs[1] <<= embed::ElementModes::READ; + pArgs[0] <<= pImpl->m_aName; + pArgs[1] <<= embed::ElementModes::READ; pImpl->bStorageBasedOnInStream = false; } @@ -1806,7 +1811,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempFile ) else // nVersion > 0; pVersion->GetValue() != 0 was the condition to this block nVersion--; - util::RevisionTag& rTag = pImpl->aVersions[nVersion]; + const util::RevisionTag& rTag = pImpl->aVersions[nVersion]; { // Open SubStorage for all versions uno::Reference < embed::XStorage > xSub = pImpl->xStorage->openStorageElement( "Versions", @@ -3715,7 +3720,7 @@ void SfxMedium::AddVersion_Impl( util::RevisionTag& rRevision ) OUString aRevName = "Version" + OUString::number( nKey + 1 ); pImpl->aVersions.realloc( nLength+1 ); rRevision.Identifier = aRevName; - pImpl->aVersions[nLength] = rRevision; + pImpl->aVersions.getArray()[nLength] = rRevision; } void SfxMedium::RemoveVersion_Impl( const OUString& rName ) @@ -4348,14 +4353,15 @@ bool SfxMedium::CallApproveHandler(const uno::Reference< task::XInteractionHandl try { uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( bAllowAbort ? 2 : 1 ); + auto pContinuations = aContinuations.getArray(); ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove ); - aContinuations[ 0 ] = pApprove.get(); + pContinuations[ 0 ] = pApprove.get(); if ( bAllowAbort ) { ::rtl::Reference< ::comphelper::OInteractionAbort > pAbort( new ::comphelper::OInteractionAbort ); - aContinuations[ 1 ] = pAbort.get(); + pContinuations[ 1 ] = pAbort.get(); } xHandler->handle(::framework::InteractionRequest::CreateRequest(rRequest, aContinuations)); @@ -4620,11 +4626,10 @@ IMPL_STATIC_LINK(SfxMedium, ShowReloadEditableDialog, void*, p, void) OUString(), uno::Reference<uno::XInterface>(), aDocumentURL))); if (xInteractionRequestImpl != nullptr) { - sal_Int32 nContinuations = 2; - uno::Sequence<uno::Reference<task::XInteractionContinuation>> aContinuations( - nContinuations); - aContinuations[0] = new ::ucbhelper::InteractionAbort(xInteractionRequestImpl.get()); - aContinuations[1] = new ::ucbhelper::InteractionApprove(xInteractionRequestImpl.get()); + uno::Sequence<uno::Reference<task::XInteractionContinuation>> aContinuations{ + new ::ucbhelper::InteractionAbort(xInteractionRequestImpl.get()), + new ::ucbhelper::InteractionApprove(xInteractionRequestImpl.get()) + }; xInteractionRequestImpl->setContinuations(aContinuations); xHandler->handle(xInteractionRequestImpl); ::rtl::Reference<::ucbhelper::InteractionContinuation> xSelected diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index bc2a2b34570c..04c997564405 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -30,6 +30,7 @@ #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <ucbhelper/content.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -823,9 +824,7 @@ bool SfxDocumentTemplates::CopyFrom { uno::Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "Hidden"; - aArgs[0].Value <<= true; + Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("Hidden", true) }; INetURLObject aTemplURL( rName ); uno::Reference< XDocumentPropertiesSupplier > xDocPropsSupplier; diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 7a036226bbec..41aff2bd93c7 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -27,6 +27,7 @@ #include <unotools/pathoptions.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/string.hxx> @@ -699,10 +700,7 @@ bool SfxDocTplService_Impl::addEntry( Content& rParentFolder, if ( ! Content::create( aLinkURL, maCmdEnv, comphelper::getProcessComponentContext(), aLink ) ) { - Sequence< Any > aValues(3); - aValues[0] <<= rTitle; - aValues[1] <<= false; - aValues[2] <<= rTargetURL; + Sequence< Any > aValues{ Any(rTitle), Any(false), Any(rTargetURL) }; try { @@ -742,10 +740,7 @@ bool SfxDocTplService_Impl::createFolder( const OUString& rNewFolderURL, { try { - Sequence< Any > aValues(2); - aValues[0] <<= aFolderName; - aValues[1] <<= true; - + Sequence< Any > aValues{ Any(aFolderName), Any(true) }; OUString aType; if ( bFsysFolder ) @@ -799,10 +794,7 @@ bool SfxDocTplService_Impl::CreateNewUniqueFolderWithPrefix( const OUString& aPa try { - Sequence< Any > aValues(2); - aValues[0] <<= aTryName; - aValues[1] <<= true; - + Sequence< Any > aValues{ Any(aTryName), Any(true) }; bCreated = aParent.insertNewContent( TYPE_FSYS_FOLDER, { TITLE, IS_FOLDER }, aValues, aNewFolder ); } catch( ucb::NameClashException& ) @@ -859,10 +851,7 @@ OUString SfxDocTplService_Impl::CreateNewUniqueFileWithPrefix( const OUString& a try { - Sequence< Any > aValues(2); - aValues[0] <<= aTryName; - aValues[1] <<= true; - + Sequence< Any > aValues{ Any(aTryName), Any(true) }; bCreated = aParent.insertNewContent( TYPE_FSYS_FILE, { TITLE, IS_DOCUMENT }, aValues, aNewFile ); } catch( ucb::NameClashException& ) @@ -1785,11 +1774,10 @@ bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName, } // store template - uno::Sequence< PropertyValue > aStoreArgs( 2 ); - aStoreArgs[0].Name = "FilterName"; - aStoreArgs[0].Value <<= aFilterName; - aStoreArgs[1].Name = "DocumentTitle"; - aStoreArgs[1].Value <<= rTemplateName; + uno::Sequence< PropertyValue > aStoreArgs{ + comphelper::makePropertyValue("FilterName", aFilterName), + comphelper::makePropertyValue("DocumentTitle", rTemplateName) + }; if( !::utl::UCBContentHelper::EqualURLs( aNewTemplateTargetURL, rStorable->getLocation() )) rStorable->storeToURL( aNewTemplateTargetURL, aStoreArgs ); diff --git a/sfx2/source/doc/exoticfileloadexception.cxx b/sfx2/source/doc/exoticfileloadexception.cxx index 4993c0640a47..91dc9c273929 100644 --- a/sfx2/source/doc/exoticfileloadexception.cxx +++ b/sfx2/source/doc/exoticfileloadexception.cxx @@ -18,16 +18,13 @@ ExoticFileLoadException::ExoticFileLoadException(const OUString& rURL, const OUString& rFilterUIName) : m_xAbort(new comphelper::OInteractionAbort) , m_xApprove(new comphelper::OInteractionApprove) + , m_lContinuations{ m_xApprove, m_xAbort } { document::ExoticFileLoadException aReq; aReq.URL = rURL; aReq.FilterUIName = rFilterUIName; m_aRequest <<= aReq; - - m_lContinuations.realloc(2); - m_lContinuations[0] = m_xApprove; - m_lContinuations[1] = m_xAbort; } bool ExoticFileLoadException::isApprove() const diff --git a/sfx2/source/doc/exoticfileloadexception.hxx b/sfx2/source/doc/exoticfileloadexception.hxx index 99cb542e2a27..8204d6f55426 100644 --- a/sfx2/source/doc/exoticfileloadexception.hxx +++ b/sfx2/source/doc/exoticfileloadexception.hxx @@ -33,9 +33,9 @@ public: // member private: css::uno::Any m_aRequest; - css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> m_lContinuations; css::uno::Reference<css::task::XInteractionContinuation> m_xAbort; css::uno::Reference<css::task::XInteractionContinuation> m_xApprove; + css::uno::Sequence<css::uno::Reference<css::task::XInteractionContinuation>> m_lContinuations; }; #endif diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 6371d10112e4..b309625206a5 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -38,6 +38,7 @@ #include <tools/stream.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <o3tl/char16_t2wchar_t.hxx> #include <o3tl/string_view.hxx> @@ -210,18 +211,16 @@ bool GraphicHelper::getThumbnailReplacement_Impl(std::u16string_view rResID, con uno::Reference< graphic::XGraphicProvider > xGraphProvider(graphic::GraphicProvider::create(xContext)); const OUString aURL{OUString::Concat("private:graphicrepository/") + rResID}; - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = "URL"; - aMediaProps[0].Value <<= aURL; + uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", + aURL) }; uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps ); if ( xGraphic.is() ) { - uno::Sequence< beans::PropertyValue > aStoreProps( 2 ); - aStoreProps[0].Name = "OutputStream"; - aStoreProps[0].Value <<= xStream; - aStoreProps[1].Name = "MimeType"; - aStoreProps[1].Value <<= OUString("image/png"); + uno::Sequence< beans::PropertyValue > aStoreProps{ + comphelper::makePropertyValue("OutputStream", xStream), + comphelper::makePropertyValue("MimeType", OUString("image/png")) + }; xGraphProvider->storeGraphic( xGraphic, aStoreProps ); bResult = true; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 3a2b5a7b3da9..4c50b5e19f27 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -59,6 +59,7 @@ #include <tools/urlobj.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/mimeconfighelper.hxx> #include <comphelper/lok.hxx> @@ -1124,10 +1125,10 @@ bool ModelData_Impl::ShowDocumentInfoDialog(const std::function< void () >& aFun 0 ); if ( xDispatch.is() ) { - uno::Sequence< beans::PropertyValue > aProperties(1); uno::Reference< lang::XUnoTunnel > aAsyncFunc(new AsyncFunc(aFunc)); - aProperties[0].Name = "AsyncFunc"; - aProperties[0].Value <<= aAsyncFunc; + uno::Sequence< beans::PropertyValue > aProperties{ + comphelper::makePropertyValue("AsyncFunc", aAsyncFunc) + }; xDispatch->dispatch( aURL, aProperties ); bDialogUsed = true; } diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index eff4588b3b5f..58a387527e4a 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <officecfg/Office/Common.hxx> @@ -184,11 +185,10 @@ sal_Bool SAL_CALL IFrameObject::load( uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); xTrans->parseStrict( aTargetURL ); - uno::Sequence < beans::PropertyValue > aProps(2); - aProps[0].Name = "PluginMode"; - aProps[0].Value <<= sal_Int16(2); - aProps[1].Name = "ReadOnly"; - aProps[1].Value <<= true; + uno::Sequence < beans::PropertyValue > aProps{ + comphelper::makePropertyValue("PluginMode", sal_Int16(2)), + comphelper::makePropertyValue("ReadOnly", true) + }; uno::Reference < frame::XDispatch > xDisp = mxFrame->queryDispatch( aTargetURL, "_self", 0 ); if ( xDisp.is() ) xDisp->dispatch( aTargetURL, aProps ); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 07d889a4f47b..da72e53b2118 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1419,8 +1419,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); if ( xProps.is() ) { - Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] = *pCaller; + Sequence< uno::Any > aArgs{ *pCaller }; xProps->setPropertyValue("Caller", uno::makeAny( aArgs ) ); } } @@ -1690,11 +1689,11 @@ bool SfxObjectShell::UseInteractionToHandleError( try { uno::Any aInteraction; - uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations(2); rtl::Reference<::comphelper::OInteractionAbort> pAbort = new ::comphelper::OInteractionAbort(); rtl::Reference<::comphelper::OInteractionApprove> pApprove = new ::comphelper::OInteractionApprove(); - lContinuations[0] = pAbort; - lContinuations[1] = pApprove; + uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations{ + pAbort, pApprove + }; task::ErrorCodeRequest aErrorCode; aErrorCode.ErrCode = sal_uInt32(nError); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 3b8f347d7250..68e3c842f405 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -352,9 +352,10 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto { } - aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; - aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; - aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + auto pEncryptionAlgs = aEncryptionAlgs.getArray(); + pEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + pEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; + pEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; } try @@ -482,8 +483,9 @@ bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) TransformItems( SID_OPENDOC, *pSet, aArgs ); sal_Int32 nLength = aArgs.getLength(); aArgs.realloc( nLength + 1 ); - aArgs[nLength].Name = "Title"; - aArgs[nLength].Value <<= GetTitle( SFX_TITLE_DETECT ); + auto pArgs = aArgs.getArray(); + pArgs[nLength].Name = "Title"; + pArgs[nLength].Value <<= GetTitle( SFX_TITLE_DETECT ); xModel->attachResource( OUString(), aArgs ); if (!utl::ConfigManager::IsFuzzing()) impl_addToModelCollection(xModel); @@ -2230,24 +2232,26 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, if ( !bHasInputStream ) { aArgs.realloc ( ++nEnd ); - aArgs[nEnd-1].Name = sInputStream; - aArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XInputStream > ( new utl::OSeekableInputStreamWrapper ( *rMedium.GetInStream() ) ); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = sInputStream; + pArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XInputStream > ( new utl::OSeekableInputStreamWrapper ( *rMedium.GetInStream() ) ); } if ( !bHasBaseURL ) { aArgs.realloc ( ++nEnd ); - aArgs[nEnd-1].Name = "DocumentBaseURL"; - aArgs[nEnd-1].Value <<= rMedium.GetBaseURL(); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = "DocumentBaseURL"; + pArgs[nEnd-1].Value <<= rMedium.GetBaseURL(); } if (xInsertPosition.is()) { - aArgs.realloc( ++nEnd ); - aArgs[nEnd-1].Name = "InsertMode"; - aArgs[nEnd-1].Value <<= true; - aArgs.realloc( ++nEnd ); - aArgs[nEnd-1].Name = "TextInsertModeRange"; - aArgs[nEnd-1].Value <<= xInsertPosition; + aArgs.realloc( nEnd += 2 ); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-2].Name = "InsertMode"; + pArgs[nEnd-2].Value <<= true; + pArgs[nEnd-1].Name = "TextInsertModeRange"; + pArgs[nEnd-1].Value <<= xInsertPosition; } // #i119492# During loading, some OLE objects like chart will be set @@ -2423,37 +2427,42 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) if ( !bHasOutputStream ) { aArgs.realloc ( ++nEnd ); - aArgs[nEnd-1].Name = sOutputStream; - aArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XOutputStream > ( new utl::OOutputStreamWrapper ( *rMedium.GetOutStream() ) ); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = sOutputStream; + pArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XOutputStream > ( new utl::OOutputStreamWrapper ( *rMedium.GetOutStream() ) ); } // add stream as well, for OOX export and maybe others if ( !bHasStream ) { aArgs.realloc ( ++nEnd ); - aArgs[nEnd-1].Name = sStream; - aArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XStream > ( new utl::OStreamWrapper ( *rMedium.GetOutStream() ) ); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = sStream; + pArgs[nEnd-1].Value <<= css::uno::Reference < css::io::XStream > ( new utl::OStreamWrapper ( *rMedium.GetOutStream() ) ); } if ( !bHasBaseURL ) { aArgs.realloc ( ++nEnd ); - aArgs[nEnd-1].Name = "DocumentBaseURL"; - aArgs[nEnd-1].Value <<= rMedium.GetBaseURL( true ); + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = "DocumentBaseURL"; + pArgs[nEnd-1].Value <<= rMedium.GetBaseURL( true ); } if( !bHasFilterName ) { aArgs.realloc( ++nEnd ); - aArgs[nEnd-1].Name = "FilterName"; - aArgs[nEnd-1].Value <<= aFilterName; + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = "FilterName"; + pArgs[nEnd-1].Value <<= aFilterName; } if (bIsRedactMode) { aArgs.realloc( ++nEnd ); - aArgs[nEnd-1].Name = "IsRedactMode"; - aArgs[nEnd-1].Value <<= bIsRedactMode; + auto pArgs = aArgs.getArray(); + pArgs[nEnd-1].Name = "IsRedactMode"; + pArgs[nEnd-1].Value <<= bIsRedactMode; } return xFilter->filter( aArgs ); @@ -2878,6 +2887,7 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& if(aFilterName == "writer_pdf_Export" && pNewFile->GetItemSet()) { uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions(2); + auto pSaveToFilterDataOptions = aSaveToFilterDataOptions.getArray(); bool bRet = false; for(int i = 0 ; i< rArgs.getLength() ; ++i) @@ -2885,14 +2895,14 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& auto aProp = rArgs[i]; if(aProp.Name == "EncryptFile") { - aSaveToFilterDataOptions[0].Name = aProp.Name; - aSaveToFilterDataOptions[0].Value = aProp.Value; + pSaveToFilterDataOptions[0].Name = aProp.Name; + pSaveToFilterDataOptions[0].Value = aProp.Value; bRet = true; } if(aProp.Name == "DocumentOpenPassword") { - aSaveToFilterDataOptions[1].Name = aProp.Name; - aSaveToFilterDataOptions[1].Value = aProp.Value; + pSaveToFilterDataOptions[1].Name = aProp.Name; + pSaveToFilterDataOptions[1].Value = aProp.Value; bRet = true; } } diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index cb4fd94571be..2f0874ea976e 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -582,6 +582,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& ::utl::TempFile* pUCBPrintTempFile = nullptr; uno::Sequence < beans::PropertyValue > aCheckedArgs( rOptions.getLength() ); + auto pCheckedArgs = aCheckedArgs.getArray(); sal_Int32 nProps = 0; bool bWaitUntilEnd = false; sal_Int16 nDuplexMode = css::view::DuplexMode::UNKNOWN; @@ -618,12 +619,13 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& OUString sFileURL; if (::osl::FileBase::getFileURLFromSystemPath(sSystemPath,sFileURL)!=::osl::FileBase::E_None) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= sFileURL; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= sFileURL; // and append the local filename aCheckedArgs.realloc( aCheckedArgs.getLength()+1 ); - aCheckedArgs[nProps].Name = "LocalFileName"; - aCheckedArgs[nProps++].Value <<= sTemp; + pCheckedArgs = aCheckedArgs.getArray(); + pCheckedArgs[nProps].Name = "LocalFileName"; + pCheckedArgs[nProps++].Value <<= sTemp; } else // It's a valid URL. but now we must know, if it is a local one or not. @@ -634,12 +636,13 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // And we have to use the system notation of the incoming URL. // But it into the descriptor and let the slot be executed at // the end of this method. - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= sTemp; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= sTemp; // and append the local filename aCheckedArgs.realloc( aCheckedArgs.getLength()+1 ); - aCheckedArgs[nProps].Name = "LocalFileName"; - aCheckedArgs[nProps++].Value <<= sPath; + pCheckedArgs = aCheckedArgs.getArray(); + pCheckedArgs[nProps].Name = "LocalFileName"; + pCheckedArgs[nProps++].Value <<= sPath; } else { @@ -657,8 +660,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& pUCBPrintTempFile->EnableKillingFile(); //FIXME: does it work? - aCheckedArgs[nProps].Name = "LocalFileName"; - aCheckedArgs[nProps++].Value <<= pUCBPrintTempFile->GetFileName(); + pCheckedArgs[nProps].Name = "LocalFileName"; + pCheckedArgs[nProps++].Value <<= pUCBPrintTempFile->GetFileName(); sUcbUrl = sURL; } } @@ -669,8 +672,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& sal_Int32 nCopies = 0; if ( !( rProp.Value >>= nCopies ) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= nCopies; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= nCopies; } // Collate-Property @@ -680,8 +683,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& bool bTemp; if ( !(rProp.Value >>= bTemp) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = "Collate"; - aCheckedArgs[nProps++].Value <<= bTemp; + pCheckedArgs[nProps].Name = "Collate"; + pCheckedArgs[nProps++].Value <<= bTemp; } else if ( rProp.Name == "SinglePrintJobs" ) @@ -689,8 +692,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& bool bTemp; if ( !(rProp.Value >>= bTemp) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = "SinglePrintJobs"; - aCheckedArgs[nProps++].Value <<= bTemp; + pCheckedArgs[nProps].Name = "SinglePrintJobs"; + pCheckedArgs[nProps++].Value <<= bTemp; } // Pages-Property @@ -699,8 +702,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& OUString sTemp; if( !(rProp.Value >>= sTemp) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= sTemp; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= sTemp; } // MonitorVisible @@ -708,8 +711,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& { if( !(rProp.Value >>= bMonitor) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= bMonitor; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= bMonitor; } // Wait @@ -717,16 +720,16 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& { if ( !(rProp.Value >>= bWaitUntilEnd) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= bWaitUntilEnd; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= bWaitUntilEnd; } else if ( rProp.Name == "DuplexMode" ) { if ( !(rProp.Value >>= nDuplexMode ) ) throw css::lang::IllegalArgumentException(); - aCheckedArgs[nProps].Name = rProp.Name; - aCheckedArgs[nProps++].Value <<= nDuplexMode; + pCheckedArgs[nProps].Name = rProp.Name; + pCheckedArgs[nProps++].Value <<= nDuplexMode; } } diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 6918f0ddf142..88d87f18da4b 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <algorithm> #include <memory> #include <config_features.h> @@ -62,6 +65,7 @@ #include <comphelper/multicontainer2.hxx> #include <cppuhelper/exc_hlp.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/namedvaluecollection.hxx> #include <o3tl/safeint.hxx> @@ -380,7 +384,7 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell const * pObjectShell ) { sal_Int32 nLen = m_aLockedFrames.getLength(); m_aLockedFrames.realloc( nLen + 1 ); - m_aLockedFrames[nLen] = xFrame; + m_aLockedFrames.getArray()[nLen] = xFrame; } catch( Exception& ) { @@ -983,8 +987,9 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< }; seqArgsNew.realloc( ++nNewLength ); - seqArgsNew[ nNewLength - 1 ].Name = "WinExtent"; - seqArgsNew[ nNewLength - 1 ].Value <<= aRectSeq; + auto pseqArgsNew = seqArgsNew.getArray(); + pseqArgsNew[ nNewLength - 1 ].Name = "WinExtent"; + pseqArgsNew[ nNewLength - 1 ].Value <<= aRectSeq; } if (requestedArgs.empty() || requestedArgs.count(u"PreusedFilterName")) @@ -992,8 +997,9 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< if ( !m_pData->m_aPreusedFilterName.isEmpty() ) { seqArgsNew.realloc( ++nNewLength ); - seqArgsNew[ nNewLength - 1 ].Name = "PreusedFilterName"; - seqArgsNew[ nNewLength - 1 ].Value <<= m_pData->m_aPreusedFilterName; + auto pseqArgsNew = seqArgsNew.getArray(); + pseqArgsNew[ nNewLength - 1 ].Name = "PreusedFilterName"; + pseqArgsNew[ nNewLength - 1 ].Value <<= m_pData->m_aPreusedFilterName; } } @@ -1013,8 +1019,9 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< }; seqArgsNew.realloc( ++nNewLength ); - seqArgsNew[ nNewLength - 1 ].Name = "DocumentBorder"; - seqArgsNew[ nNewLength - 1 ].Value <<= aBorderSeq; + auto pseqArgsNew = seqArgsNew.getArray(); + pseqArgsNew[ nNewLength - 1 ].Name = "DocumentBorder"; + pseqArgsNew[ nNewLength - 1 ].Value <<= aBorderSeq; } } @@ -1034,10 +1041,10 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< // since it is not supported by transformer seqArgsNew.realloc( ++nNewLength ); - seqArgsNew[ nNewLength - 1 ] = rOrg; + seqArgsNew.getArray()[ nNewLength - 1 ] = rOrg; aFinalCache.realloc( ++nFinalLength ); - aFinalCache[ nFinalLength - 1 ] = rOrg; + aFinalCache.getArray()[ nFinalLength - 1 ] = rOrg; } } @@ -2225,57 +2232,58 @@ Sequence< datatransfer::DataFlavor > SAL_CALL SfxBaseModel::getTransferDataFlavo const sal_Int32 nSuppFlavors = GraphicHelper::supportsMetaFileHandle_Impl() ? 10 : 8; Sequence< datatransfer::DataFlavor > aFlavorSeq( nSuppFlavors ); + auto pFlavorSeq = aFlavorSeq.getArray(); - aFlavorSeq[0].MimeType = + pFlavorSeq[0].MimeType = "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\""; - aFlavorSeq[0].HumanPresentableName = "GDIMetaFile"; - aFlavorSeq[0].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[0].HumanPresentableName = "GDIMetaFile"; + pFlavorSeq[0].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[1].MimeType = + pFlavorSeq[1].MimeType = "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\""; - aFlavorSeq[1].HumanPresentableName = "GDIMetaFile"; - aFlavorSeq[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[1].HumanPresentableName = "GDIMetaFile"; + pFlavorSeq[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[2].MimeType = + pFlavorSeq[2].MimeType = "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" ; - aFlavorSeq[2].HumanPresentableName = "Enhanced Windows MetaFile"; - aFlavorSeq[2].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[2].HumanPresentableName = "Enhanced Windows MetaFile"; + pFlavorSeq[2].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[3].MimeType = + pFlavorSeq[3].MimeType = "application/x-openoffice-wmf;windows_formatname=\"Image WMF\""; - aFlavorSeq[3].HumanPresentableName = "Windows MetaFile"; - aFlavorSeq[3].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[3].HumanPresentableName = "Windows MetaFile"; + pFlavorSeq[3].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[4].MimeType = + pFlavorSeq[4].MimeType = "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\""; - aFlavorSeq[4].HumanPresentableName = "Star Object Descriptor (XML)"; - aFlavorSeq[4].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[4].HumanPresentableName = "Star Object Descriptor (XML)"; + pFlavorSeq[4].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[5].MimeType = + pFlavorSeq[5].MimeType = "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\""; - aFlavorSeq[5].HumanPresentableName = "Star Embed Source (XML)"; - aFlavorSeq[5].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[5].HumanPresentableName = "Star Embed Source (XML)"; + pFlavorSeq[5].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[6].MimeType = + pFlavorSeq[6].MimeType = "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\""; - aFlavorSeq[6].HumanPresentableName = "Bitmap"; - aFlavorSeq[6].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[6].HumanPresentableName = "Bitmap"; + pFlavorSeq[6].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aFlavorSeq[7].MimeType = "image/png"; - aFlavorSeq[7].HumanPresentableName = "PNG"; - aFlavorSeq[7].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); + pFlavorSeq[7].MimeType = "image/png"; + pFlavorSeq[7].HumanPresentableName = "PNG"; + pFlavorSeq[7].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); if ( nSuppFlavors == 10 ) { - aFlavorSeq[8].MimeType = + pFlavorSeq[8].MimeType = "application/x-openoffice-emf;windows_formatname=\"Image EMF\""; - aFlavorSeq[8].HumanPresentableName = "Enhanced Windows MetaFile"; - aFlavorSeq[8].DataType = cppu::UnoType<sal_uInt64>::get(); + pFlavorSeq[8].HumanPresentableName = "Enhanced Windows MetaFile"; + pFlavorSeq[8].DataType = cppu::UnoType<sal_uInt64>::get(); - aFlavorSeq[9].MimeType = + pFlavorSeq[9].MimeType = "application/x-openoffice-wmf;windows_formatname=\"Image WMF\""; - aFlavorSeq[9].HumanPresentableName = "Windows MetaFile"; - aFlavorSeq[9].DataType = cppu::UnoType<sal_uInt64>::get(); + pFlavorSeq[9].HumanPresentableName = "Windows MetaFile"; + pFlavorSeq[9].DataType = cppu::UnoType<sal_uInt64>::get(); } return aFlavorSeq; @@ -2604,13 +2612,11 @@ void SAL_CALL SfxBaseModel::checkIn( sal_Bool bIsMajor, const OUString& rMessage try { - Sequence< beans::PropertyValue > aProps( 3 ); - aProps[0].Name = "VersionMajor"; - aProps[0].Value <<= bIsMajor; - aProps[1].Name = "VersionComment"; - aProps[1].Value <<= rMessage; - aProps[2].Name = "CheckIn"; - aProps[2].Value <<= true; + Sequence< beans::PropertyValue > aProps{ + comphelper::makePropertyValue("VersionMajor", bIsMajor), + comphelper::makePropertyValue("VersionComment", rMessage), + comphelper::makePropertyValue("CheckIn", true) + }; const OUString sName( pMedium->GetName( ) ); storeSelf( aProps ); @@ -2803,7 +2809,7 @@ static void addTitle_Impl( Sequence < beans::PropertyValue >& rSeq, const OUStri { sal_Int32 nCount = rSeq.getLength(); rSeq.realloc( nCount+1 ); - auto& el = rSeq[nCount]; + auto& el = rSeq.getArray()[nCount]; el.Name = "Title"; el.Value <<= rTitle; } @@ -3450,7 +3456,7 @@ Sequence< OUString > SAL_CALL SfxBaseModel::getDocumentSubStoragesNames() if ( xStorage->isStorageElement( rName ) ) { aResult.realloc( ++nResultSize ); - aResult[ nResultSize - 1 ] = rName; + aResult.getArray()[ nResultSize - 1 ] = rName; } } @@ -3559,7 +3565,7 @@ static void ConvertSlotsToCommands( SfxObjectShell const * pDoc, Reference< cont aStrBuf.appendAscii( pSlot->GetUnoName() ); aCommand = aStrBuf.makeStringAndClear(); - aSeqPropValue[nIndex].Value <<= aCommand; + aSeqPropValue.getArray()[nIndex].Value <<= aCommand; rToolbarDefinition->replaceByIndex( i, Any( aSeqPropValue )); } } @@ -4074,10 +4080,9 @@ Reference< container::XEnumeration > SAL_CALL SfxBaseModel::getControllers() SfxModelGuard aGuard( *this ); sal_Int32 c = m_pData->m_seqControllers.size(); - sal_Int32 i = 0; Sequence< Any > lEnum(c); - for (i=0; i<c; ++i) - lEnum[i] <<= m_pData->m_seqControllers[i]; + std::transform(m_pData->m_seqControllers.begin(), m_pData->m_seqControllers.end(), + lEnum.getArray(), [](const auto& x) { return css::uno::makeAny(x); }); return new ::comphelper::OAnyEnumeration(lEnum); } @@ -4092,8 +4097,9 @@ Sequence< OUString > SAL_CALL SfxBaseModel::getAvailableViewControllerNames() const sal_Int16 nViewFactoryCount = rDocumentFactory.GetViewFactoryCount(); Sequence< OUString > aViewNames( nViewFactoryCount ); + auto aViewNamesRange = asNonConstRange(aViewNames); for ( sal_Int16 nViewNo = 0; nViewNo < nViewFactoryCount; ++nViewNo ) - aViewNames[nViewNo] = rDocumentFactory.GetViewFactory( nViewNo ).GetAPIViewName(); + aViewNamesRange[nViewNo] = rDocumentFactory.GetViewFactory( nViewNo ).GetAPIViewName(); return aViewNames; } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index dcfd3e53753a..0561c5f380dc 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -13,6 +13,7 @@ #include <sfx2/module.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/string.hxx> #include <comphelper/storagehelper.hxx> #include <sfx2/app.hxx> @@ -652,9 +653,8 @@ void SfxTemplateManagerDlg::ImportActionHdl() void SfxTemplateManagerDlg::ExtensionsActionHdl() { - uno::Sequence<beans::PropertyValue> aArgs(1); - aArgs[0].Name = "AdditionsTag"; - aArgs[0].Value <<= OUString("Templates"); + uno::Sequence<beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + "AdditionsTag", OUString("Templates")) }; comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); } @@ -708,17 +708,13 @@ IMPL_LINK(SfxTemplateManagerDlg, CreateContextMenuHdl, ThumbnailViewItem*, pItem IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem, void) { - uno::Sequence< PropertyValue > aArgs(5); - aArgs[0].Name = "AsTemplate"; - aArgs[0].Value <<= true; - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= MacroExecMode::USE_CONFIG; - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; - aArgs[3].Name = "InteractionHandler"; - aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ); - aArgs[4].Name = "ReadOnly"; - aArgs[4].Value <<= true; + uno::Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("AsTemplate", true), + comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG), + comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG), + comphelper::makePropertyValue("InteractionHandler", task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr )), + comphelper::makePropertyValue("ReadOnly", true) + }; TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem); @@ -735,13 +731,11 @@ IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem, voi IMPL_LINK(SfxTemplateManagerDlg, EditTemplateHdl, ThumbnailViewItem*, pItem, void) { - uno::Sequence< PropertyValue > aArgs(3); - aArgs[0].Name = "AsTemplate"; - aArgs[0].Value <<= false; - aArgs[1].Name = "MacroExecutionMode"; - aArgs[1].Value <<= MacroExecMode::USE_CONFIG; - aArgs[2].Name = "UpdateDocMode"; - aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG; + uno::Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("AsTemplate", false), + comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG), + comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG) + }; uno::Reference< XStorable > xStorable; TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem); diff --git a/sfx2/source/doc/zoomitem.cxx b/sfx2/source/doc/zoomitem.cxx index ff30802cc863..60f193e85388 100644 --- a/sfx2/source/doc/zoomitem.cxx +++ b/sfx2/source/doc/zoomitem.cxx @@ -20,8 +20,12 @@ #include <sfx2/zoomitem.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> + +#include <comphelper/propertyvalue.hxx> #include <osl/diagnose.h> +#include <cassert> + SfxPoolItem* SvxZoomItem::CreateDefault() { return new SvxZoomItem; } @@ -66,13 +70,12 @@ bool SvxZoomItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const { case 0: { - css::uno::Sequence< css::beans::PropertyValue > aSeq( ZOOM_PARAMS ); - aSeq[0].Name = ZOOM_PARAM_VALUE; - aSeq[0].Value <<= sal_Int32( GetValue() ); - aSeq[1].Name = ZOOM_PARAM_VALUESET; - aSeq[1].Value <<= sal_Int16( nValueSet ); - aSeq[2].Name = ZOOM_PARAM_TYPE; - aSeq[2].Value <<= sal_Int16( eType ); + css::uno::Sequence< css::beans::PropertyValue > aSeq{ + comphelper::makePropertyValue(ZOOM_PARAM_VALUE, sal_Int32( GetValue() )), + comphelper::makePropertyValue(ZOOM_PARAM_VALUESET, sal_Int16( nValueSet )), + comphelper::makePropertyValue(ZOOM_PARAM_TYPE, sal_Int16( eType )) + }; + assert(aSeq.getLength() == ZOOM_PARAMS); rVal <<= aSeq; break; } diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx index 0db4f7729008..0966d1c5a6ec 100644 --- a/sfx2/source/inet/inettbc.cxx +++ b/sfx2/source/inet/inettbc.cxx @@ -25,6 +25,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/util/XURLTransformer.hpp> + +#include <comphelper/propertyvalue.hxx> #include <svl/stritem.hxx> #include <unotools/historyoptions.hxx> #include <vcl/toolbox.hxx> @@ -144,11 +146,10 @@ void SfxURLToolBoxControl_Impl::OpenURL( const OUString& rName ) const if ( !xDispatch.is() ) return; - Sequence< PropertyValue > aArgs( 2 ); - aArgs[0].Name = "Referer"; - aArgs[0].Value <<= OUString( "private:user" ); - aArgs[1].Name = "FileName"; - aArgs[1].Value <<= aName; + Sequence< PropertyValue > aArgs{ + comphelper::makePropertyValue("Referer", OUString( "private:user" )), + comphelper::makePropertyValue("FileName", aName) + }; SfxURLToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxURLToolBoxControl_Impl::ExecuteInfo; pExecuteInfo->xDispatch = xDispatch; diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index aba0d718c7d0..0208a5f412a5 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -397,9 +397,10 @@ uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createE throw css::lang::DisposedException(); } uno::Sequence<uno::Any> models(m_lModels.size()); + auto modelsRange = asNonConstRange(models); for (size_t i = 0; i < m_lModels.size(); ++i) { - models[i] <<= m_lModels[i]; + modelsRange[i] <<= m_lModels[i]; } uno::Reference<container::XEnumeration> xEnum(new ::comphelper::OAnyEnumeration(models)); // <- SAFE diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 51a48642586e..664d6c42b479 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -67,6 +67,7 @@ css::uno::Sequence<OUString> BuildContextList (const ContextList& rContextList) const ::std::vector<ContextList::Entry>& entries = rContextList.GetEntries(); css::uno::Sequence<OUString> result(entries.size()); + auto resultRange = asNonConstRange(result); tools::Long i = 0; for (auto const& entry : entries) @@ -86,7 +87,7 @@ css::uno::Sequence<OUString> BuildContextList (const ContextList& rContextList) if (!menuCommand.isEmpty()) element += ", "+menuCommand; - result[i] = element; + resultRange[i] = element; ++i; } diff --git a/sfx2/source/sidebar/UnoDecks.cxx b/sfx2/source/sidebar/UnoDecks.cxx index 519840698df5..cbd9d1c214e7 100644 --- a/sfx2/source/sidebar/UnoDecks.cxx +++ b/sfx2/source/sidebar/UnoDecks.cxx @@ -19,6 +19,8 @@ #include <vcl/svapp.hxx> +#include <algorithm> + using namespace css; using namespace ::sfx2::sidebar; @@ -64,14 +66,8 @@ uno::Sequence< OUString > SAL_CALL SfxUnoDecks::getElementNames() xFrame->getController()); deckList.realloc(aDecks.size()); - - tools::Long n = 0; - - for (const auto& rDeck : aDecks) - { - deckList[n] = rDeck.msId; - n++; - } + std::transform(aDecks.begin(), aDecks.end(), deckList.getArray(), + [](const auto& rDeck) { return rDeck.msId; }); } return deckList; diff --git a/sfx2/source/sidebar/UnoPanels.cxx b/sfx2/source/sidebar/UnoPanels.cxx index a35c559f3e81..40ebdbeb979f 100644 --- a/sfx2/source/sidebar/UnoPanels.cxx +++ b/sfx2/source/sidebar/UnoPanels.cxx @@ -19,6 +19,8 @@ #include <vcl/svapp.hxx> +#include <algorithm> + using namespace css; using namespace ::sfx2::sidebar; @@ -72,14 +74,8 @@ uno::Sequence< OUString > SAL_CALL SfxUnoPanels::getElementNames() xFrame->getController()); panelList.realloc(aPanels.size()); - - tools::Long n = 0; - - for (const auto& rPanel : aPanels) - { - panelList[n] = rPanel.msId; - n++; - } + std::transform(aPanels.begin(), aPanels.end(), panelList.getArray(), + [](const auto& rPanel) { return rPanel.msId; }); } return panelList; diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 82b811bb94f5..eef20a921171 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -63,6 +63,7 @@ #include <svtools/soerr.hxx> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/exc_hlp.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -901,9 +902,9 @@ ErrCode SfxInPlaceClient::DoVerb(sal_Int32 nVerb) try { SfxStoringHelper aHelper; - uno::Sequence< beans::PropertyValue > aDispatchArgs( 1 ); - aDispatchArgs[0].Name = "SaveTo"; - aDispatchArgs[0].Value <<= true; + uno::Sequence< beans::PropertyValue > aDispatchArgs{ + comphelper::makePropertyValue("SaveTo", true) + }; aHelper.GUIStoreModel( xEmbModel, u"SaveAs", diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx index 5f29a9981904..1097c0a3c39b 100644 --- a/sfx2/source/view/lokcharthelper.cxx +++ b/sfx2/source/view/lokcharthelper.cxx @@ -10,6 +10,7 @@ #include <sfx2/lokcharthelper.hxx> #include <comphelper/lok.hxx> +#include <comphelper/propertyvalue.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <sfx2/ipclient.hxx> #include <sfx2/lokhelper.hxx> @@ -315,10 +316,11 @@ bool LokChartHelper::setTextSelection(int nType, int nX, int nY) // that are converted to hmm util::URL aURL; aURL.Path = "LOKSetTextSelection"; - uno::Sequence< beans::PropertyValue > aArgs(3); - aArgs[0].Value <<= static_cast<sal_Int32>(nType); - aArgs[1].Value <<= static_cast<sal_Int32>(nChartWinX); - aArgs[2].Value <<= static_cast<sal_Int32>(nChartWinY); + uno::Sequence< beans::PropertyValue > aArgs{ + comphelper::makePropertyValue({}, static_cast<sal_Int32>(nType)), // Why no name? + comphelper::makePropertyValue({}, static_cast<sal_Int32>(nChartWinX)), + comphelper::makePropertyValue({}, static_cast<sal_Int32>(nChartWinY)) + }; xDispatcher->dispatch(aURL, aArgs); } return true; diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 603d31d41b33..dbf84dde0d3c 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -22,6 +22,8 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/view/XRenderable.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> + +#include <comphelper/propertyvalue.hxx> #include <officecfg/Office/Common.hxx> #include <sal/log.hxx> #include <svl/itempool.hxx> @@ -131,12 +133,11 @@ SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter, for (const auto& rProp : rProps) setValue( rProp.Name, rProp.Value ); - Sequence< beans::PropertyValue > aRenderOptions( 3 ); - aRenderOptions[0].Name = "ExtraPrintUIOptions"; - aRenderOptions[1].Name = "View" ; - aRenderOptions[1].Value = i_rViewProp; - aRenderOptions[2].Name = "IsPrinter"; - aRenderOptions[2].Value <<= true; + Sequence< beans::PropertyValue > aRenderOptions{ + comphelper::makePropertyValue("ExtraPrintUIOptions", Any{}), + comphelper::makePropertyValue("View", i_rViewProp), + comphelper::makePropertyValue("IsPrinter", true) + }; try { const Sequence< beans::PropertyValue > aRenderParms( mxRenderable->getRenderer( 0 , getSelectionObject(), aRenderOptions ) ); @@ -209,9 +210,8 @@ Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const mxDevice.set( pXDevice ); } - Sequence< beans::PropertyValue > aRenderOptions( 1 ); - aRenderOptions[ 0 ].Name = "RenderDevice"; - aRenderOptions[ 0 ].Value <<= mxDevice; + Sequence< beans::PropertyValue > aRenderOptions{ comphelper::makePropertyValue( + "RenderDevice", mxDevice) }; aRenderOptions = getJobProperties( aRenderOptions ); return aRenderOptions; @@ -733,6 +733,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // we have to increase the capacity of aProps sal_Int32 nLen = aProps.getLength(); aProps.realloc( nLen + 1 ); + auto pProps = aProps.getArray(); // HACK: writer sets the SID_SELECTION item when printing directly and expects // to get only the selection document in that case (see getSelectionObject) @@ -741,14 +742,14 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // it would be better if writer handled this internally if( nId == SID_PRINTDOCDIRECT ) { - aProps[nLen].Name = "PrintSelectionOnly"; - aProps[nLen].Value <<= bSelection; + pProps[nLen].Name = "PrintSelectionOnly"; + pProps[nLen].Value <<= bSelection; } else // if nId == SID_PRINTDOC ; nothing to do with the previous HACK { // should the printer selection and properties dialogue display an help button - aProps[nLen].Name = "HideHelpButton"; - aProps[nLen].Value <<= bPrintOnHelp; + pProps[nLen].Name = "HideHelpButton"; + pProps[nLen].Value <<= bPrintOnHelp; } ExecPrint( aProps, bIsAPI, (nId == SID_PRINTDOCDIRECT) ); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index ee77dcadbde0..7b86b27cabf6 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -57,6 +57,7 @@ #include <framework/actiontriggerhelper.hxx> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/settings.hxx> @@ -623,9 +624,9 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) OUString aFileURL = aFilePathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= aFilterName; + css::uno::Sequence< css::beans::PropertyValue > aArgs{ + comphelper::makePropertyValue("FilterName", aFilterName) + }; // Store document in the html format try |