diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 08:12:46 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 13:15:25 +0200 |
commit | 4b2ad350213ececdbb1002b3ada87791dc126b20 (patch) | |
tree | f944fa48bc5782704b5c9421216663f765a39520 | |
parent | 4c71240a8e09f253d6156036485ed78449863f64 (diff) |
Prepare for removal of non-const operator[] from Sequence in cui
Change-Id: Ib359c029099cf86ccdebefd014d4a9bd91d57eba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124356
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | cui/source/customize/SvxConfigPageHelper.cxx | 67 | ||||
-rw-r--r-- | cui/source/customize/SvxNotebookbarConfigPage.cxx | 7 | ||||
-rw-r--r-- | cui/source/customize/acccfg.cxx | 9 | ||||
-rw-r--r-- | cui/source/customize/cfg.cxx | 59 | ||||
-rw-r--r-- | cui/source/customize/cfgutil.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/QrCodeGenDialog.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/SignSignatureLineDialog.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/SpellAttrib.hxx | 19 | ||||
-rw-r--r-- | cui/source/dialogs/colorpicker.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/cuicharmap.cxx | 35 | ||||
-rw-r--r-- | cui/source/dialogs/insdlg.cxx | 13 | ||||
-rw-r--r-- | cui/source/dialogs/scriptdlg.cxx | 10 | ||||
-rw-r--r-- | cui/source/options/cfgchart.cxx | 10 | ||||
-rw-r--r-- | cui/source/options/optaboutconfig.cxx | 36 | ||||
-rw-r--r-- | cui/source/options/optgdlg.cxx | 21 | ||||
-rw-r--r-- | cui/source/options/optinet2.cxx | 3 | ||||
-rw-r--r-- | cui/source/options/optupdt.cxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 10 | ||||
-rw-r--r-- | cui/source/tabpages/tpcolor.cxx | 16 |
19 files changed, 150 insertions, 192 deletions
diff --git a/cui/source/customize/SvxConfigPageHelper.cxx b/cui/source/customize/SvxConfigPageHelper.cxx index 39044173b8ed..52265ef093e6 100644 --- a/cui/source/customize/SvxConfigPageHelper.cxx +++ b/cui/source/customize/SvxConfigPageHelper.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/ui/ImageType.hpp> #include <com/sun/star/ui/ItemType.hpp> +#include <comphelper/propertyvalue.hxx> #include <comphelper/random.hxx> #include <svtools/imgdef.hxx> #include <svtools/miscopt.hxx> @@ -361,29 +362,20 @@ bool SvxConfigPageHelper::GetToolbarItemData( css::uno::Sequence<css::beans::PropertyValue> SvxConfigPageHelper::ConvertSvxConfigEntry(const SvxConfigEntry* pEntry) { - css::uno::Sequence<css::beans::PropertyValue> aPropSeq(4); - - aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL; - aPropSeq[0].Value <<= pEntry->GetCommand(); - - aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE; - aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT; - // If the name has not been changed, then the label can be stored // as an empty string. // It will be initialised again later using the command to label map. - aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL; - if (!pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty()) - { - aPropSeq[2].Value <<= OUString(); - } - else - { - aPropSeq[2].Value <<= pEntry->GetName(); - } - - aPropSeq[3].Name = ITEM_DESCRIPTOR_STYLE; - aPropSeq[3].Value <<= static_cast<sal_Int16>(pEntry->GetStyle()); + OUString sLabel; + if (pEntry->HasChangedName() || pEntry->GetCommand().isEmpty()) + sLabel = pEntry->GetName(); + + css::uno::Sequence<css::beans::PropertyValue> aPropSeq{ + comphelper::makePropertyValue(ITEM_DESCRIPTOR_COMMANDURL, pEntry->GetCommand()), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::DEFAULT), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_LABEL, sLabel), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_STYLE, + static_cast<sal_Int16>(pEntry->GetStyle())) + }; return aPropSeq; } @@ -391,32 +383,21 @@ SvxConfigPageHelper::ConvertSvxConfigEntry(const SvxConfigEntry* pEntry) css::uno::Sequence<css::beans::PropertyValue> SvxConfigPageHelper::ConvertToolbarEntry(const SvxConfigEntry* pEntry) { - css::uno::Sequence<css::beans::PropertyValue> aPropSeq(5); - - aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL; - aPropSeq[0].Value <<= pEntry->GetCommand(); - - aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE; - aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT; - // If the name has not been changed, then the label can be stored // as an empty string. // It will be initialised again later using the command to label map. - aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL; - if (!pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty()) - { - aPropSeq[2].Value <<= OUString(); - } - else - { - aPropSeq[2].Value <<= pEntry->GetName(); - } - - aPropSeq[3].Name = ITEM_DESCRIPTOR_ISVISIBLE; - aPropSeq[3].Value <<= pEntry->IsVisible(); - - aPropSeq[4].Name = ITEM_DESCRIPTOR_STYLE; - aPropSeq[4].Value <<= static_cast<sal_Int16>(pEntry->GetStyle()); + OUString sLabel; + if (pEntry->HasChangedName() || pEntry->GetCommand().isEmpty()) + sLabel = pEntry->GetName(); + + css::uno::Sequence<css::beans::PropertyValue> aPropSeq{ + comphelper::makePropertyValue(ITEM_DESCRIPTOR_COMMANDURL, pEntry->GetCommand()), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::DEFAULT), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_LABEL, sLabel), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_ISVISIBLE, pEntry->IsVisible()), + comphelper::makePropertyValue(ITEM_DESCRIPTOR_STYLE, + static_cast<sal_Int16>(pEntry->GetStyle())) + }; return aPropSeq; } diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index 43b792af8955..631c3b3c460f 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -476,22 +476,23 @@ static void EditRegistryFile(std::u16string_view sUIItemId, const OUString& sSet Sequence<OUString> aOldEntries = CustomNotebookbarGenerator::getCustomizedUIItem(sNotebookbarInterface); Sequence<OUString> aNewEntries(aOldEntries.getLength() + 1); + auto pNewEntries = aNewEntries.getArray(); for (int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++) { sal_Int32 rPos = 0; OUString sFirstValue = aOldEntries[nIdx].getToken(rPos, ',', rPos); if (sFirstValue == sUIItemId) { - aOldEntries[nIdx] = sSetEntry; + aOldEntries.getArray()[nIdx] = sSetEntry; nFlag = 1; break; } - aNewEntries[nIdx] = aOldEntries[nIdx]; + pNewEntries[nIdx] = aOldEntries[nIdx]; } if (nFlag == 0) { - aNewEntries[aOldEntries.getLength()] = sSetEntry; + pNewEntries[aOldEntries.getLength()] = sSetEntry; CustomNotebookbarGenerator::setCustomizedUIItem(aNewEntries, sNotebookbarInterface); } else diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx index 9745120f3591..476b10d2e8e4 100644 --- a/cui/source/customize/acccfg.cxx +++ b/cui/source/customize/acccfg.cxx @@ -1319,9 +1319,8 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, LoadHdl, sfx2::FileDialogHelper*, void // don't forget to release the storage afterwards! uno::Reference<lang::XSingleServiceFactory> xStorageFactory( embed::StorageFactory::create(m_xContext)); - uno::Sequence<uno::Any> lArgs(2); - lArgs[0] <<= sCfgName; - lArgs[1] <<= css::embed::ElementModes::READ; + uno::Sequence<uno::Any> lArgs{ uno::Any(sCfgName), + uno::Any(css::embed::ElementModes::READ) }; xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW); uno::Reference<embed::XStorage> xUIConfig @@ -1390,9 +1389,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SaveHdl, sfx2::FileDialogHelper*, void { uno::Reference<lang::XSingleServiceFactory> xStorageFactory( embed::StorageFactory::create(m_xContext)); - uno::Sequence<uno::Any> lArgs(2); - lArgs[0] <<= sCfgName; - lArgs[1] <<= embed::ElementModes::WRITE; + uno::Sequence<uno::Any> lArgs{ uno::Any(sCfgName), uno::Any(embed::ElementModes::WRITE) }; xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW); diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index dbf17c120e4d..943dc83247d4 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -87,6 +87,7 @@ #include <com/sun/star/util/thePathSettings.hpp> #include <comphelper/documentinfo.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> @@ -275,12 +276,10 @@ SaveInData::SaveInData( bDocConfig( isDocConfig ), bReadOnly( false ), m_xCfgMgr( xCfgMgr ), - m_xParentCfgMgr( xParentCfgMgr ) + m_xParentCfgMgr( xParentCfgMgr ), + m_aSeparatorSeq{ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, + css::ui::ItemType::SEPARATOR_LINE) } { - m_aSeparatorSeq.realloc( 1 ); - m_aSeparatorSeq[0].Name = ITEM_DESCRIPTOR_TYPE; - m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE; - if ( bDocConfig ) { uno::Reference< css::ui::XUIConfigurationPersistence > @@ -603,8 +602,9 @@ void MenuSaveInData::Apply( sal_Int32 nIndex = aPropValueSeq.getLength(); aPropValueSeq.realloc( nIndex + 1 ); - aPropValueSeq[nIndex].Name = m_aDescriptorContainer; - aPropValueSeq[nIndex].Value <<= xSubMenuBar; + auto pPropValueSeq = aPropValueSeq.getArray(); + pPropValueSeq[nIndex].Name = m_aDescriptorContainer; + pPropValueSeq[nIndex].Value <<= xSubMenuBar; rMenuBar->insertByIndex( rMenuBar->getCount(), uno::Any( aPropValueSeq )); ApplyMenu( xSubMenuBar, rFactory, entryData ); @@ -631,8 +631,9 @@ void SaveInData::ApplyMenu( sal_Int32 nIndex = aPropValueSeq.getLength(); aPropValueSeq.realloc( nIndex + 1 ); - aPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER; - aPropValueSeq[nIndex].Value <<= xSubMenuBar; + auto pPropValueSeq = aPropValueSeq.getArray(); + pPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER; + pPropValueSeq[nIndex].Value <<= xSubMenuBar; rMenuBar->insertByIndex( rMenuBar->getCount(), uno::Any( aPropValueSeq )); @@ -2394,8 +2395,9 @@ void ToolbarSaveInData::ApplyToolbar( sal_Int32 nIndex = aPropValueSeq.getLength(); aPropValueSeq.realloc( nIndex + 1 ); - aPropValueSeq[nIndex].Name = m_aDescriptorContainer; - aPropValueSeq[nIndex].Value <<= xSubMenuBar; + auto pPropValueSeq = aPropValueSeq.getArray(); + pPropValueSeq[nIndex].Name = m_aDescriptorContainer; + pPropValueSeq[nIndex].Value <<= xSubMenuBar; rToolbarBar->insertByIndex( rToolbarBar->getCount(), uno::Any( aPropValueSeq )); @@ -2555,9 +2557,10 @@ void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar ) // After reloading, ensure that the icon is reset of each entry // in the toolbar uno::Sequence< OUString > aURLSeq( 1 ); + auto pURLSeq = aURLSeq.getArray(); for (auto const& entry : *pToolbar->GetEntries()) { - aURLSeq[ 0 ] = entry->GetCommand(); + pURLSeq[ 0 ] = entry->GetCommand(); try { @@ -2738,9 +2741,8 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow, uno::Reference< lang::XSingleServiceFactory > xStorageFactory( css::embed::FileSystemStorageFactory::create( xComponentContext ) ); - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= aDirectory; - aArgs[ 1 ] <<= css::embed::ElementModes::READWRITE; + uno::Sequence< uno::Any > aArgs{ uno::Any(aDirectory), + uno::Any(css::embed::ElementModes::READWRITE) }; uno::Reference< css::embed::XStorage > xStorage( xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); @@ -2762,9 +2764,10 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow, } uno::Sequence< OUString > name( 1 ); + auto pname = name.getArray(); for (auto const& elem : aImageInfo1) { - name[ 0 ] = elem.first; + pname[ 0 ] = elem.first; uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( SvxConfigPageHelper::GetImageType(), name ); if ( graphics.hasElements() ) { @@ -2796,7 +2799,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow, // large growth factor, expecting many entries for (auto const& elem : aImageInfo) { - name[ 0 ] = elem.first; + pname[ 0 ] = elem.first; uno::Sequence< uno::Reference< graphic::XGraphic> > graphics; try @@ -2920,13 +2923,8 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void) bool SvxIconSelectorDialog::ReplaceGraphicItem( const OUString& aURL ) { - uno::Sequence< OUString > URLs(1); - uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 ); - uno::Reference< graphic::XGraphic > xGraphic; - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = "URL"; - aMediaProps[0].Value <<= aURL; + uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) }; css::awt::Size aSize; bool bOK = false; @@ -2962,7 +2960,6 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem( size_t nPos = nId - 1; assert(nPos == m_xTbSymbol->GetItemPos(nId)); m_xTbSymbol->RemoveItem(nId); - aMediaProps[0].Value <<= aURL; Image aImage( xGraphic ); if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) ) @@ -2975,9 +2972,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem( m_aGraphics[nPos] = Graphic(aImage.GetBitmapEx()).GetXGraphic(); - URLs[0] = aURL; - aImportGraph[ 0 ] = xGraphic; - m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), URLs, aImportGraph ); + m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), { aURL }, { xGraphic } ); m_xImportedImageManager->store(); bResult = true; @@ -3132,11 +3127,8 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL ) { bool result = false; - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = "URL"; + uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) }; - uno::Reference< graphic::XGraphic > xGraphic; - aMediaProps[0].Value <<= aURL; try { uno::Reference< beans::XPropertySet > props = @@ -3144,7 +3136,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL ) uno::Any a = props->getPropertyValue("SizePixel"); - xGraphic = m_xGraphProvider->queryGraphic( aMediaProps ); + uno::Reference< graphic::XGraphic > xGraphic = m_xGraphProvider->queryGraphic( aMediaProps ); if ( xGraphic.is() ) { bool bOK = true; @@ -3168,8 +3160,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL ) m_xTbSymbol->InsertItem(m_aGraphics.size(), aImage, aURL); uno::Sequence<OUString> aImportURL { aURL }; - uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 ); - aImportGraph[ 0 ] = xGraphic; + uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph{ xGraphic }; m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph ); if ( m_xImportedImageManager->isModified() ) { diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index dc6b073eea6d..c68db3540114 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -486,8 +486,8 @@ void CuiConfigGroupListBox::InitModule() for (i1=0; i1<c1; ++i1) { - sal_Int16& rGroupID = lGroups[i1]; - OUString sGroupID = OUString::number(rGroupID); + sal_Int16 nGroupID = lGroups[i1]; + OUString sGroupID = OUString::number(nGroupID); OUString sGroupName ; try @@ -499,7 +499,7 @@ void CuiConfigGroupListBox::InitModule() catch(const css::container::NoSuchElementException&) { continue; } - aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, rGroupID ) ); + aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, nGroupID ) ); m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())), sGroupName); } diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index 9a42e4ddc057..d2a0f42878ff 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -10,6 +10,7 @@ #include <QrCodeGenDialog.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <tools/stream.hxx> #include <dialmgr.hxx> #include <strings.hrc> @@ -256,9 +257,8 @@ void QrCodeGenDialog::Apply() Reference<XComponentContext> xContext(comphelper::getProcessComponentContext()); Reference<XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(xContext); - Sequence<PropertyValue> aMediaProperties(1); - aMediaProperties[0].Name = "InputStream"; - aMediaProperties[0].Value <<= xInputStream; + Sequence<PropertyValue> aMediaProperties{ comphelper::makePropertyValue("InputStream", + xInputStream) }; Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties)); bool bIsExistingQRCode = m_xExistingShapeProperties.is(); diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 7af20b36445a..83d108290ade 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -17,6 +17,7 @@ #include <comphelper/graphicmimetype.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <sfx2/filedlghelper.hxx> #include <sfx2/objsh.hxx> #include <svx/xoutbmp.hxx> @@ -134,9 +135,8 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, loadImage, weld::Button&, void) return; Reference<XGraphicProvider> xProvider = GraphicProvider::create(xContext); - Sequence<PropertyValue> aMediaProperties(1); - aMediaProperties[0].Name = "URL"; - aMediaProperties[0].Value <<= aSelectedFiles[0]; + Sequence<PropertyValue> aMediaProperties{ comphelper::makePropertyValue("URL", + aSelectedFiles[0]) }; m_xSignatureImage = xProvider->queryGraphic(aMediaProperties); m_sOriginalImageBtnLabel = m_xBtnLoadImage->get_label(); diff --git a/cui/source/dialogs/SpellAttrib.hxx b/cui/source/dialogs/SpellAttrib.hxx index c086fe3d086a..d732aad69ba1 100644 --- a/cui/source/dialogs/SpellAttrib.hxx +++ b/cui/source/dialogs/SpellAttrib.hxx @@ -86,16 +86,15 @@ struct SpellErrorDescription css::uno::Sequence<css::uno::Any> toSequence() const { - css::uno::Sequence<css::uno::Any> aEntries(9); - aEntries[0] <<= bIsGrammarError; - aEntries[1] <<= sErrorText; - aEntries[2] <<= sDialogTitle; - aEntries[3] <<= sExplanation; - aEntries[4] <<= sExplanationURL; - aEntries[5] <<= aLocale; - aEntries[6] <<= xGrammarChecker; - aEntries[7] <<= aSuggestions; - aEntries[8] <<= sRuleId; + css::uno::Sequence<css::uno::Any> aEntries{ css::uno::Any(bIsGrammarError), + css::uno::Any(sErrorText), + css::uno::Any(sDialogTitle), + css::uno::Any(sExplanation), + css::uno::Any(sExplanationURL), + css::uno::Any(aLocale), + css::uno::Any(xGrammarChecker), + css::uno::Any(aSuggestions), + css::uno::Any(sRuleId) }; return aEntries; } diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 397e275c663a..3b9a81dddde3 100644 --- a/cui/source/dialogs/colorpicker.cxx +++ b/cui/source/dialogs/colorpicker.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/awt/XWindow.hpp> + +#include <comphelper/propertyvalue.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/basemutex.hxx> @@ -1292,9 +1294,7 @@ Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( ) // XPropertyAccess Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues( ) { - Sequence< PropertyValue > props(1); - props[0].Name = gsColorKey; - props[0].Value <<= mnColor; + Sequence< PropertyValue > props{ comphelper::makePropertyValue(gsColorKey, mnColor) }; return props; } diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index c727af51fc87..b5a6dc106aae 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -36,6 +36,7 @@ #include <officecfg/Office/Common.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/dispatchcommand.hxx> #include <dialmgr.hxx> @@ -341,12 +342,14 @@ void SvxCharacterMap::updateRecentCharacterList(const OUString& sTitle, const OU maRecentCharFontList.push_front(rFont); css::uno::Sequence< OUString > aRecentCharList(maRecentCharList.size()); + auto aRecentCharListRange = asNonConstRange(aRecentCharList); css::uno::Sequence< OUString > aRecentCharFontList(maRecentCharFontList.size()); + auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList); for (size_t i = 0; i < maRecentCharList.size(); ++i) { - aRecentCharList[i] = maRecentCharList[i]; - aRecentCharFontList[i] = maRecentCharFontList[i]; + aRecentCharListRange[i] = maRecentCharList[i]; + aRecentCharFontListRange[i] = maRecentCharFontList[i]; } std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); @@ -378,12 +381,14 @@ void SvxCharacterMap::updateFavCharacterList(const OUString& sTitle, const OUStr maFavCharFontList.push_back(rFont); css::uno::Sequence< OUString > aFavCharList(maFavCharList.size()); + auto aFavCharListRange = asNonConstRange(aFavCharList); css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size()); + auto aFavCharFontListRange = asNonConstRange(aFavCharFontList); for (size_t i = 0; i < maFavCharList.size(); ++i) { - aFavCharList[i] = maFavCharList[i]; - aFavCharFontList[i] = maFavCharFontList[i]; + aFavCharListRange[i] = maFavCharList[i]; + aFavCharFontListRange[i] = maFavCharFontList[i]; } std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); @@ -429,12 +434,14 @@ void SvxCharacterMap::deleteFavCharacterFromList(std::u16string_view sTitle, std } css::uno::Sequence< OUString > aFavCharList(maFavCharList.size()); + auto aFavCharListRange = asNonConstRange(aFavCharList); css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size()); + auto aFavCharFontListRange = asNonConstRange(aFavCharFontList); for (size_t i = 0; i < maFavCharList.size(); ++i) { - aFavCharList[i] = maFavCharList[i]; - aFavCharFontList[i] = maFavCharFontList[i]; + aFavCharListRange[i] = maFavCharList[i]; + aFavCharFontListRange[i] = maFavCharFontList[i]; } std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); @@ -635,12 +642,10 @@ void SvxCharacterMap::insertCharToDoc(const OUString& sGlyph) return; if (m_xFrame.is()) { - uno::Sequence<beans::PropertyValue> aArgs(2); - aArgs[0].Name = "Symbols"; - aArgs[0].Value <<= sGlyph; - - aArgs[1].Name = "FontName"; - aArgs[1].Value <<= aFont.GetFamilyName(); + uno::Sequence<beans::PropertyValue> aArgs{ + comphelper::makePropertyValue("Symbols", sGlyph), + comphelper::makePropertyValue("FontName", aFont.GetFamilyName()) + }; comphelper::dispatchCommand(".uno:InsertSymbol", m_xFrame, aArgs); updateRecentCharacterList(sGlyph, aFont.GetFamilyName()); @@ -784,12 +789,14 @@ IMPL_LINK(SvxCharacterMap, RecentClearClickHdl, SvxCharView*, rView, void) } css::uno::Sequence< OUString > aRecentCharList(maRecentCharList.size()); + auto aRecentCharListRange = asNonConstRange(aRecentCharList); css::uno::Sequence< OUString > aRecentCharFontList(maRecentCharFontList.size()); + auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList); for (size_t i = 0; i < maRecentCharList.size(); ++i) { - aRecentCharList[i] = maRecentCharList[i]; - aRecentCharFontList[i] = maRecentCharFontList[i]; + aRecentCharListRange[i] = maRecentCharList[i]; + aRecentCharFontListRange[i] = maRecentCharFontList[i]; } std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx index 2440d2ef0c0d..868d9a4f26fd 100644 --- a/cui/source/dialogs/insdlg.cxx +++ b/cui/source/dialogs/insdlg.cxx @@ -46,6 +46,7 @@ #include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <comphelper/classids.hxx> +#include <comphelper/propertyvalue.hxx> #include <sfx2/filedlghelper.hxx> #include <sfx2/frmdescr.hxx> #include <sfx2/viewsh.hxx> @@ -288,17 +289,15 @@ short SvInsertOleDlg::run() if ( !aFileName.isEmpty() ) { - // create MediaDescriptor for file to create object from - uno::Sequence < beans::PropertyValue > aMedium( 2 ); - aMedium[0].Name = "URL"; - aMedium[0].Value <<= aFileName; - uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); uno::Reference< task::XInteractionHandler2 > xInteraction( task::InteractionHandler::createWithParent(xContext, nullptr) ); - aMedium[1].Name = "InteractionHandler"; - aMedium[1].Value <<= xInteraction; + // create MediaDescriptor for file to create object from + uno::Sequence < beans::PropertyValue > aMedium{ + comphelper::makePropertyValue("URL", aFileName), + comphelper::makePropertyValue("InteractionHandler", xInteraction) + }; // create object from media descriptor diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx index 4b4092f9c760..3ba92fc337cf 100644 --- a/cui/source/dialogs/scriptdlg.cxx +++ b/cui/source/dialogs/scriptdlg.cxx @@ -811,9 +811,8 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry) // open up parent node (which ensures it's loaded) m_xScriptsBox->expand_row(rEntry); - Sequence< Any > args( 1 ); - args[ 0 ] <<= aNewName; - Sequence< Any > outArgs( 0 ); + Sequence< Any > args{ Any(aNewName) }; + Sequence< Any > outArgs; Sequence< sal_Int16 > outIndex; try { @@ -893,9 +892,8 @@ void SvxScriptOrgDialog::renameEntry(const weld::TreeIter& rEntry) aNewName = aNewDlg.GetObjectName(); - Sequence< Any > args( 1 ); - args[ 0 ] <<= aNewName; - Sequence< Any > outArgs( 0 ); + Sequence< Any > args{ Any(aNewName) }; + Sequence< Any > outArgs; Sequence< sal_Int16 > outIndex; try { diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx index 525761c3c86c..5649c4ea53f3 100644 --- a/cui/source/options/cfgchart.cxx +++ b/cui/source/options/cfgchart.cxx @@ -160,10 +160,9 @@ bool SvxChartColorTable::operator==( const SvxChartColorTable & _rOther ) const SvxChartOptions::SvxChartOptions() : ::utl::ConfigItem( "Office.Chart" ), - mbIsInitialized( false ) + mbIsInitialized( false ), + maPropertyNames{ "DefaultColor/Series" } { - maPropertyNames.realloc( 1 ); - maPropertyNames[ 0 ] = "DefaultColor/Series"; } SvxChartOptions::~SvxChartOptions() @@ -239,13 +238,14 @@ void SvxChartOptions::ImplCommit() // convert list to sequence const size_t nCount = maDefColors.size(); uno::Sequence< sal_Int64 > aColors( nCount ); + auto aColorsRange = asNonConstRange(aColors); for( size_t i=0; i < nCount; i++ ) { Color aData = maDefColors.getColor( i ); - aColors[ i ] = sal_uInt32(aData); + aColorsRange[ i ] = sal_uInt32(aData); } - aValues[ 0 ] <<= aColors; + aValues.getArray()[0] <<= aColors; } PutProperties( aNames, aValues ); diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 1f5adbf73b11..55941f765dd9 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -27,9 +27,9 @@ #include <sal/log.hxx> #include <tools/diagnose_ex.h> +#include <algorithm> #include <memory> #include <vector> -#include <iostream> using namespace ::com::sun::star; using namespace com::sun::star::uno; @@ -487,8 +487,7 @@ Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& aProperty.Name = "nodepath"; aProperty.Value <<= sNodePath; - uno::Sequence< uno::Any > aArgumentList( 1 ); - aArgumentList[0] <<= aProperty; + uno::Sequence< uno::Any > aArgumentList{ uno::Any(aProperty) }; OUString sAccessString; @@ -688,10 +687,9 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) //create appropriate sequence with same size as string sequence uno::Sequence< sal_Int16 > seqShort( seqStr.size() ); //convert all strings to appropriate type - for( size_t i = 0; i < seqStr.size(); ++i ) - { - seqShort[i] = static_cast<sal_Int16>(seqStr[i].toInt32()); - } + std::transform(seqStr.begin(), seqStr.end(), seqShort.getArray(), + [](const auto& str) + { return static_cast<sal_Int16>(str.toInt32()); }); pProperty->Value <<= seqShort; } else if( sPropertyType == "[]long" ) @@ -699,40 +697,32 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) std::vector< OUString > seqStrLong = commaStringToSequence( sNewValue ); uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() ); - for( size_t i = 0; i < seqStrLong.size(); ++i ) - { - seqLong[i] = seqStrLong[i].toInt32(); - } + std::transform(seqStrLong.begin(), seqStrLong.end(), seqLong.getArray(), + [](const auto& str) { return str.toInt32(); }); pProperty->Value <<= seqLong; } else if( sPropertyType == "[]hyper" ) { std::vector< OUString > seqStrHyper = commaStringToSequence( sNewValue ); uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() ); - for( size_t i = 0; i < seqStrHyper.size(); ++i ) - { - seqHyper[i] = seqStrHyper[i].toInt64(); - } + std::transform(seqStrHyper.begin(), seqStrHyper.end(), seqHyper.getArray(), + [](const auto& str) { return str.toInt64(); }); pProperty->Value <<= seqHyper; } else if( sPropertyType == "[]double" ) { std::vector< OUString > seqStrDoub = commaStringToSequence( sNewValue ); uno::Sequence< double > seqDoub( seqStrDoub.size() ); - for( size_t i = 0; i < seqStrDoub.size(); ++i ) - { - seqDoub[i] = seqStrDoub[i].toDouble(); - } + std::transform(seqStrDoub.begin(), seqStrDoub.end(), seqDoub.getArray(), + [](const auto& str) { return str.toDouble(); }); pProperty->Value <<= seqDoub; } else if( sPropertyType == "[]float" ) { std::vector< OUString > seqStrFloat = commaStringToSequence( sNewValue ); uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() ); - for( size_t i = 0; i < seqStrFloat.size(); ++i ) - { - seqFloat[i] = seqStrFloat[i].toFloat(); - } + std::transform(seqStrFloat.begin(), seqStrFloat.end(), seqFloat.getArray(), + [](const auto& str) { return str.toFloat(); }); pProperty->Value <<= seqFloat; } else if( sPropertyType == "[]string" ) diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 30b98e8de55f..5e010bff340d 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * @@ -38,6 +38,7 @@ #include <unotools/syslocaleoptions.hxx> #include <sfx2/objsh.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <svtools/langtab.hxx> #include <editeng/unolingu.hxx> #include <editeng/langitem.hxx> @@ -594,9 +595,8 @@ IMPL_LINK_NOARG(OfaViewTabPage, OnRunGPTestClick, weld::Button&, void) IMPL_STATIC_LINK_NOARG(OfaViewTabPage, OnMoreIconsClick, weld::Button&, void) { - css::uno::Sequence<css::beans::PropertyValue> aArgs(1); - aArgs[0].Name = "AdditionsTag"; - aArgs[0].Value <<= OUString("Icons"); + css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + "AdditionsTag", OUString("Icons")) }; comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); } @@ -1070,12 +1070,9 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon Reference< XMultiServiceFactory > theConfigProvider( css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext())); - Sequence< Any > theArgs(1); - Reference< XNameAccess > theNameAccess; - // find out which locales are currently installed and add them to the listbox - theArgs[0] <<= NamedValue("nodepath", Any(OUString(sInstalledLocalesPath))); - theNameAccess.set( + Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sInstalledLocalesPath)))) }; + Reference< XNameAccess > theNameAccess( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW ); seqInstalledLanguages = theNameAccess->getElementNames(); LanguageType aLang = LANGUAGE_DONTKNOW; @@ -1106,8 +1103,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon m_xUserInterfaceLB->set_active(0); // find out whether the user has a specific locale specified - Sequence< Any > theArgs2(1); - theArgs2[0] <<= NamedValue("nodepath", Any(OUString(sUserLocalePath))); + Sequence< Any > theArgs2{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) }; theNameAccess.set( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW ); if (theNameAccess->hasByName(sUserLocaleKey)) @@ -1276,8 +1272,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) Reference< XMultiServiceFactory > theConfigProvider( css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext())); - Sequence< Any > theArgs(1); - theArgs[0] <<= NamedValue("nodepath", Any(OUString(sUserLocalePath))); + Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) }; Reference< XPropertySet >xProp( theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW ); if ( m_sUserLocaleValue != aLangString) diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index e01433516ff7..be01007e026c 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -170,8 +170,7 @@ SvxProxyTabPage::SvxProxyTabPage(weld::Container* pPage, weld::DialogController* aProperty.Name = "nodepath"; aProperty.Value <<= OUString( "org.openoffice.Inet/Settings" ); - Sequence< Any > aArgumentList( 1 ); - aArgumentList[0] <<= aProperty; + Sequence< Any > aArgumentList{ Any(aProperty) }; m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess", diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index f6351edda30d..6b0dbe2cd2cd 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -368,8 +368,7 @@ IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, weld::Button&, void) aProperty.Name = "nodepath"; aProperty.Value <<= OUString("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob"); - uno::Sequence< uno::Any > aArgumentList( 1 ); - aArgumentList[0] <<= aProperty; + uno::Sequence< uno::Any > aArgumentList{ uno::Any(aProperty) }; uno::Reference< container::XNameAccess > xNameAccess( xConfigProvider->createInstanceWithArguments( diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index d4a482f0e007..ade080a1436a 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -50,6 +50,7 @@ #include <com/sun/star/text/XNumberingFormatter.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <svx/svxids.hrc> #include <algorithm> @@ -970,11 +971,10 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi Graphic aScaledGraphic( aBitmap ); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - Sequence< PropertyValue > aFilterData( 2 ); - aFilterData[ 0 ].Name = "Compression"; - aFilterData[ 0 ].Value <<= sal_Int32(-1) ; - aFilterData[ 1 ].Name = "Quality"; - aFilterData[ 1 ].Value <<= sal_Int32(1); + Sequence< PropertyValue > aFilterData{ + comphelper::makePropertyValue("Compression", sal_Int32(-1)), + comphelper::makePropertyValue("Quality", sal_Int32(1)) + }; sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() ); rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData ); diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index a5f2e7b7aa98..5669f73adc76 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -36,6 +36,7 @@ #include <officecfg/Office/Common.hxx> #include <osl/diagnose.h> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertyvalue.hxx> using namespace com::sun::star; @@ -365,8 +366,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) sal_Int32 nSize = aCustomColorList.getLength(); aCustomColorList.realloc( nSize + 1 ); aCustomColorNameList.realloc( nSize + 1 ); - aCustomColorList[nSize] = sal_Int32(aCurrentColor); - aCustomColorNameList[nSize] = aName; + aCustomColorList.getArray()[nSize] = sal_Int32(aCurrentColor); + aCustomColorNameList.getArray()[nSize] = aName; officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); @@ -411,12 +412,14 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); + auto aCustomColorListRange = asNonConstRange(aCustomColorList); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); + auto aCustomColorNameListRange = asNonConstRange(aCustomColorNameList); sal_Int32 nSize = aCustomColorList.getLength() - 1; for(sal_Int32 nIndex = static_cast<sal_Int32>(nPos);nIndex < nSize;nIndex++) { - aCustomColorList[nIndex] = aCustomColorList[nIndex+1]; - aCustomColorNameList[nIndex] = aCustomColorNameList[nIndex+1]; + aCustomColorListRange[nIndex] = aCustomColorList[nIndex+1]; + aCustomColorNameListRange[nIndex] = aCustomColorNameList[nIndex+1]; } aCustomColorList.realloc(nSize); aCustomColorNameList.realloc(nSize); @@ -544,9 +547,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModeHdl_Impl, weld::Toggleable&, voi IMPL_STATIC_LINK_NOARG(SvxColorTabPage, OnMoreColorsClick, weld::Button&, void) { - css::uno::Sequence<css::beans::PropertyValue> aArgs(1); - aArgs[0].Name = "AdditionsTag"; - aArgs[0].Value <<= OUString("Color Palette"); + css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue( + "AdditionsTag", OUString("Color Palette")) }; comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); } |