sw/source/core/edit/edlingu.cxx           |    6 ++----
 sw/source/core/unocore/unoredline.cxx     |   25 +++++++++++--------------
 sw/source/core/unocore/unostyle.cxx       |   16 ++++++++--------
 sw/source/ui/dbui/addresslistdialog.cxx   |   18 ++++++++----------
 sw/source/ui/dbui/mmlayoutpage.cxx        |   12 ++++++------
 sw/source/ui/dbui/mmresultdialogs.cxx     |   10 ++--------
 sw/source/ui/dbui/selectdbtabledialog.cxx |   20 ++++++++------------
 sw/source/ui/envelp/mailmrge.cxx          |   15 +++++++--------
 sw/source/ui/vba/vbadocuments.cxx         |    4 +---
 sw/source/uibase/dbui/mmconfigitem.cxx    |   23 ++++++++---------------
 sw/source/uibase/uiview/view2.cxx         |   29 +++++++++++++----------------
 11 files changed, 74 insertions(+), 104 deletions(-)

New commits:
commit ed652a6af731c5cd024c245013923717b7764a60
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun Feb 6 14:05:46 2022 +0100
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Mon Feb 7 07:05:17 2022 +0100

    Simplify sequences uses in sw (2)
    
    Change-Id: Ic4b3136414d778990e179e36162ca61327cb13f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129578
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index a393afdb225c..3c0d8b2e8524 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -55,6 +55,7 @@
 #include <docsh.hxx>
 #include <txatbase.hxx>
 #include <txtfrm.hxx>
+#include <comphelper/propertyvalue.hxx>
 
 using namespace ::svx;
 using namespace ::com::sun::star;
@@ -945,10 +946,7 @@ uno::Reference< XSpellAlternatives >
                     // than returning e.g. 16 suggestions and using only the
                     // first 7. Thus we hand down the value to use to that
                     // implementation here by providing an additional 
parameter.
-                    Sequence< PropertyValue > aPropVals(1);
-                    PropertyValue &rVal = aPropVals.getArray()[0];
-                    rVal.Name = UPN_MAX_NUMBER_OF_SUGGESTIONS;
-                    rVal.Value <<= sal_Int16(7);
+                    Sequence< PropertyValue > aPropVals ( { 
comphelper::makePropertyValue( UPN_MAX_NUMBER_OF_SUGGESTIONS, sal_Int16(7)) } );
 
                     xSpellAlt = xSpell->spell( aWord, 
static_cast<sal_uInt16>(eActLang), aPropVals );
                 }
diff --git a/sw/source/core/unocore/unoredline.cxx 
b/sw/source/core/unocore/unoredline.cxx
index f0d784658f57..197a5542b072 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -20,6 +20,7 @@
 #include <sal/config.h>
 #include <sal/log.hxx>
 #include <com/sun/star/text/XTextSection.hpp>
+#include <comphelper/propertyvalue.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <vcl/svapp.hxx>
 
@@ -175,24 +176,20 @@ SwXRedlinePortion::~SwXRedlinePortion()
 
 static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const 
SwRangeRedline& rRedline)
 {
-    uno::Sequence<beans::PropertyValue> aValues(4);
-
     const SwRedlineData* pNext = rRedline.GetRedlineData().Next();
     if(pNext)
     {
-        beans::PropertyValue* pValues = aValues.getArray();
-        pValues[0].Name = UNO_NAME_REDLINE_AUTHOR;
-        // GetAuthorString(n) walks the SwRedlineData* chain;
-        // here we always need element 1
-        pValues[0].Value <<= rRedline.GetAuthorString(1);
-        pValues[1].Name = UNO_NAME_REDLINE_DATE_TIME;
-        pValues[1].Value <<= pNext->GetTimeStamp().GetUNODateTime();
-        pValues[2].Name = UNO_NAME_REDLINE_COMMENT;
-        pValues[2].Value <<= pNext->GetComment();
-        pValues[3].Name = UNO_NAME_REDLINE_TYPE;
-        pValues[3].Value <<= SwRedlineTypeToOUString(pNext->GetType());
+        return
+        {
+            // GetAuthorString(n) walks the SwRedlineData* chain;
+            // here we always need element 1
+            comphelper::makePropertyValue(UNO_NAME_REDLINE_AUTHOR, 
rRedline.GetAuthorString(1)),
+            comphelper::makePropertyValue(UNO_NAME_REDLINE_DATE_TIME, 
pNext->GetTimeStamp().GetUNODateTime()),
+            comphelper::makePropertyValue(UNO_NAME_REDLINE_COMMENT, 
pNext->GetComment()),
+            comphelper::makePropertyValue(UNO_NAME_REDLINE_TYPE, 
SwRedlineTypeToOUString(pNext->GetType()))
+        };
     }
-    return aValues;
+    return uno::Sequence<beans::PropertyValue>(4);
 }
 
 uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index b19758648ddf..40b9878f59a2 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -21,6 +21,7 @@
 
 #include <o3tl/safeint.hxx>
 #include <o3tl/string_view.hxx>
+#include <comphelper/propertysequence.hxx>
 #include <hintids.hxx>
 #include <vcl/svapp.hxx>
 #include <svl/hint.hxx>
@@ -598,15 +599,14 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& 
rURL,
 uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions()
 {
     SolarMutexGuard aGuard;
-    uno::Sequence< beans::PropertyValue > aSeq(5);
-    beans::PropertyValue* pArray = aSeq.getArray();
     const uno::Any aVal(true);
-    pArray[0] = beans::PropertyValue(UNO_NAME_LOAD_TEXT_STYLES, -1, aVal, 
beans::PropertyState_DIRECT_VALUE);
-    pArray[1] = beans::PropertyValue(UNO_NAME_LOAD_FRAME_STYLES, -1, aVal, 
beans::PropertyState_DIRECT_VALUE);
-    pArray[2] = beans::PropertyValue(UNO_NAME_LOAD_PAGE_STYLES, -1, aVal, 
beans::PropertyState_DIRECT_VALUE);
-    pArray[3] = beans::PropertyValue(UNO_NAME_LOAD_NUMBERING_STYLES, -1, aVal, 
beans::PropertyState_DIRECT_VALUE);
-    pArray[4] = beans::PropertyValue(UNO_NAME_OVERWRITE_STYLES, -1, aVal, 
beans::PropertyState_DIRECT_VALUE);
-    return aSeq;
+    return comphelper::InitPropertySequence({
+        { UNO_NAME_LOAD_TEXT_STYLES, aVal },
+        { UNO_NAME_LOAD_FRAME_STYLES, aVal },
+        { UNO_NAME_LOAD_PAGE_STYLES, aVal },
+        { UNO_NAME_LOAD_NUMBERING_STYLES, aVal },
+        { UNO_NAME_OVERWRITE_STYLES, aVal }
+    });
 }
 
 static bool lcl_GetHeaderFooterItem(
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx 
b/sw/source/ui/dbui/addresslistdialog.cxx
index f80fe38d6b92..1a5f972869ab 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <swtypes.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include "addresslistdialog.hxx"
 #include "selectdbtabledialog.hxx"
 #include "createaddresslistdialog.hxx"
@@ -355,16 +356,13 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, 
weld::Button&, void)
         uno::Sequence<OUString> aFilters { sNewName };
         xDataProperties->setPropertyValue("TableFilter", Any(aFilters));
 
-        uno::Sequence<PropertyValue> aInfo(4);
-        PropertyValue* pInfo = aInfo.getArray();
-        pInfo[0].Name = "FieldDelimiter";
-        pInfo[0].Value <<= OUString('\t');
-        pInfo[1].Name = "StringDelimiter";
-        pInfo[1].Value <<= OUString('"');
-        pInfo[2].Name = "Extension";
-        pInfo[2].Value <<= aURL.getExtension();//"csv";
-        pInfo[3].Name = "CharSet";
-        pInfo[3].Value <<= OUString("UTF-8");
+        uno::Sequence<PropertyValue> aInfo
+        {
+            comphelper::makePropertyValue("FieldDelimiter", OUString('\t')),
+            comphelper::makePropertyValue("StringDelimiter", OUString('"')),
+            comphelper::makePropertyValue("Extension", aURL.getExtension()), 
//"csv
+            comphelper::makePropertyValue("CharSet", OUString("UTF-8"))
+        };
         xDataProperties->setPropertyValue("Info", Any(aInfo));
 
         uno::Reference<sdb::XDocumentDataSource> xDS(xNewInstance, 
UNO_QUERY_THROW);
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx 
b/sw/source/ui/dbui/mmlayoutpage.cxx
index 0c8ebd8bf3c3..f8ca8b957e22 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -24,6 +24,7 @@
 #include <mailmergehelper.hxx>
 #include <unotools.hxx>
 #include <comphelper/string.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <i18nutil/unicode.hxx>
 #include <unotools/tempfile.hxx>
 #include <uitool.hxx>
@@ -98,13 +99,12 @@ 
SwMailMergeLayoutPage::SwMailMergeLayoutPage(weld::Container* pPage, SwMailMerge
         aTempFile.EnableKillingFile();
     }
     SwView* pView = m_pWizard->GetSwView();
-    uno::Sequence< beans::PropertyValue > aValues(2);
-    beans::PropertyValue* pValues = aValues.getArray();
-    pValues[0].Name = "FilterName";
-    pValues[0].Value <<= pSfxFlt->GetFilterName();
     // Don't save embedded data set! It would steal it from current document.
-    pValues[1].Name = "NoEmbDataSet";
-    pValues[1].Value <<= true;
+    uno::Sequence< beans::PropertyValue > aValues =
+    {
+        comphelper::makePropertyValue("FilterName", pSfxFlt->GetFilterName()),
+        comphelper::makePropertyValue("NoEmbDataSet", true)
+    };
 
     uno::Reference< frame::XStorable > xStore( 
pView->GetDocShell()->GetModel(), uno::UNO_QUERY);
     xStore->storeToURL( m_sExampleURL, aValues   );
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx 
b/sw/source/ui/dbui/mmresultdialogs.cxx
index 9fb2a0e98919..0e01be311588 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -583,10 +583,7 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, 
weld::Button&, void)
 
     if (m_xSaveAsOneRB->get_active())
     {
-        uno::Sequence< beans::PropertyValue > aValues(1);
-        beans::PropertyValue* pValues = aValues.getArray();
-        pValues[0].Name = "FilterName";
-        pValues[0].Value <<= sFilter;
+        uno::Sequence< beans::PropertyValue > aValues { 
comphelper::makePropertyValue("FilterName", sFilter) };
 
         uno::Reference< frame::XStorable > xStore( 
pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
         ErrCode nErrorCode = ERRCODE_NONE;
@@ -1082,10 +1079,7 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, 
SendDocumentsHdl_Impl, weld::Button&, voi
             FILTER_XML,
             SwDocShell::Factory().GetFilterContainer() );
 
-    uno::Sequence< beans::PropertyValue > aValues(1);
-    beans::PropertyValue* pValues = aValues.getArray();
-    pValues[0].Name = "FilterName";
-    pValues[0].Value <<= pTargetSfxFlt->GetFilterName();
+    uno::Sequence< beans::PropertyValue > aValues { 
comphelper::makePropertyValue("FilterName", pTargetSfxFlt->GetFilterName()) };
 
     uno::Reference< frame::XStorable > xStore( 
pTargetView->GetDocShell()->GetModel(), uno::UNO_QUERY);
     xStore->storeToURL( sTargetTempURL, aValues   );
diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx 
b/sw/source/ui/dbui/selectdbtabledialog.cxx
index 3622a074193e..62f8da5cfe86 100644
--- a/sw/source/ui/dbui/selectdbtabledialog.cxx
+++ b/sw/source/ui/dbui/selectdbtabledialog.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <o3tl/safeint.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <swtypes.hxx>
 #include "selectdbtabledialog.hxx"
 #include "dbtablepreviewdialog.hxx"
@@ -103,18 +104,13 @@ IMPL_LINK_NOARG(SwSelectDBTableDialog, PreviewHdl, 
weld::Button&, void)
         xPrSet->getPropertyValue("Name") >>= sDataSourceName;
     }
     OSL_ENSURE(!sDataSourceName.isEmpty(), "no data source found");
-    Sequence<PropertyValue> aProperties(5);
-    PropertyValue* pProperties = aProperties.getArray();
-    pProperties[0].Name = "DataSourceName";
-    pProperties[0].Value <<= sDataSourceName;
-    pProperties[1].Name = "Command";
-    pProperties[1].Value <<= sTableOrQuery;
-    pProperties[2].Name = "CommandType";
-    pProperties[2].Value <<= nCommandType;
-    pProperties[3].Name = "ShowTreeView";
-    pProperties[3].Value <<= false;
-    pProperties[4].Name = "ShowTreeViewButton";
-    pProperties[4].Value <<= false;
+    Sequence<PropertyValue> aProperties{
+        comphelper::makePropertyValue("DataSourceName", sDataSourceName),
+        comphelper::makePropertyValue("Command", sTableOrQuery),
+        comphelper::makePropertyValue("CommandType", nCommandType),
+        comphelper::makePropertyValue("ShowTreeView", false),
+        comphelper::makePropertyValue("ShowTreeViewButton", false)
+    };
 
     SwDBTablePreviewDialog aDlg(m_xDialog.get(), aProperties);
     aDlg.run();
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index a2e899a77910..8c65eb766788 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -19,6 +19,7 @@
 
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
+#include <comphelper/propertyvalue.hxx>
 
 #include <tools/urlobj.hxx>
 #include <svl/urihelper.hxx>
@@ -191,14 +192,12 @@ SwMailMergeDlg::SwMailMergeDlg(weld::Window* pParent, 
SwWrtShell& rShell,
                                            "",
                                            0x0C);
             if(xD.is()) {
-                Sequence<PropertyValue> aProperties(3);
-                PropertyValue* pProperties = aProperties.getArray();
-                pProperties[0].Name = "DataSourceName";
-                pProperties[0].Value <<= rSourceName;
-                pProperties[1].Name = "Command";
-                pProperties[1].Value <<= rTableName;
-                pProperties[2].Name = "CommandType";
-                pProperties[2].Value <<= nCommandType;
+                Sequence<PropertyValue> aProperties
+                {
+                    comphelper::makePropertyValue("DataSourceName", 
rSourceName),
+                    comphelper::makePropertyValue("Command", rTableName),
+                    comphelper::makePropertyValue("CommandType", nCommandType),
+                };
                 xD->dispatch(aURL, aProperties);
                 m_xBeamerWin->show();
             }
diff --git a/sw/source/ui/vba/vbadocuments.cxx 
b/sw/source/ui/vba/vbadocuments.cxx
index 9398fcc6b1be..63360919c845 100644
--- a/sw/source/ui/vba/vbadocuments.cxx
+++ b/sw/source/ui/vba/vbadocuments.cxx
@@ -122,9 +122,7 @@ SwVbaDocuments::Open( const OUString& Filename, const 
uno::Any& /*ConfirmConvers
     else
         osl::FileBase::getFileURLFromSystemPath( Filename, aURL );
 
-    uno::Sequence< beans::PropertyValue > sProps(0);
-
-    uno::Reference <text::XTextDocument> xSpreadDoc( openDocument( Filename, 
ReadOnly, sProps ), uno::UNO_QUERY_THROW );
+    uno::Reference <text::XTextDocument> xSpreadDoc( openDocument( Filename, 
ReadOnly, {}), uno::UNO_QUERY_THROW );
     uno::Any aRet = getDocument( mxContext, xSpreadDoc, Application() );
     uno::Reference< word::XDocument > xDocument( aRet, uno::UNO_QUERY );
     if ( xDocument.is() )
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx 
b/sw/source/uibase/dbui/mmconfigitem.cxx
index cd46d6b386eb..200cbec1a478 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -19,6 +19,7 @@
 
 
 #include <mmconfigitem.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <vector>
 #include <swtypes.hxx>
 #include <com/sun/star/uno/Any.hxx>
@@ -559,21 +560,13 @@ void  SwMailMergeConfigItem_Impl::ImplCommit()
             OUString sSlash = "/";
             OUString sNodePath = cAddressDataAssignments + sSlash + sNewNode + 
sSlash;
             //only one new entry is written
-            Sequence< PropertyValue > aNewValues(4);
-            PropertyValue* pNewValues = aNewValues.getArray();
-            pNewValues[0].Name = sNodePath;
-            pNewValues[0].Name += cDataSourceName;
-            pNewValues[0].Value <<= rAssignment.aDBData.sDataSource;
-            pNewValues[1].Name = sNodePath;
-            pNewValues[1].Name += cDataTableName;
-            pNewValues[1].Value <<= rAssignment.aDBData.sCommand;
-            pNewValues[2].Name = sNodePath;
-            pNewValues[2].Name += cDataCommandType;
-            pNewValues[2].Value <<= rAssignment.aDBData.nCommandType;
-            pNewValues[3].Name = sNodePath;
-            pNewValues[3].Name += cDBColumnAssignments;
-            pNewValues[3].Value <<= rAssignment.aDBColumnAssignments;
-
+            Sequence< PropertyValue > aNewValues
+            {
+                comphelper::makePropertyValue(sNodePath + cDataSourceName, 
rAssignment.aDBData.sDataSource),
+                comphelper::makePropertyValue(sNodePath + cDataTableName, 
rAssignment.aDBData.sCommand),
+                comphelper::makePropertyValue(sNodePath + cDataCommandType, 
rAssignment.aDBData.nCommandType),
+                comphelper::makePropertyValue(sNodePath + 
cDBColumnAssignments, rAssignment.aDBColumnAssignments)
+            };
             SetSetProperties(cAddressDataAssignments, aNewValues);
         }
     }
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index c6e2ff5db8f1..088de02af581 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
 #include <com/sun/star/linguistic2/XDictionary.hpp>
+#include <comphelper/propertyvalue.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <SwCapObjType.hxx>
 #include <SwStyleNameMapper.hxx>
@@ -1310,14 +1311,12 @@ void SwView::Execute(SfxRequest &rReq)
                     rSh.EnterStdMode(); // force change in text shell; 
necessary for mixing DB fields
                     AttrChangedNotify(nullptr);
 
-                    Sequence<PropertyValue> aProperties(3);
-                    PropertyValue* pValues = aProperties.getArray();
-                    pValues[0].Name = "DataSourceName";
-                    pValues[1].Name = "Command";
-                    pValues[2].Name = "CommandType";
-                    pValues[0].Value <<= aData.sDataSource;
-                    pValues[1].Value <<= aData.sCommand;
-                    pValues[2].Value <<= aData.nCommandType;
+                    Sequence<PropertyValue> aProperties
+                    {
+                        comphelper::makePropertyValue("DataSourceName", 
aData.sDataSource),
+                        comphelper::makePropertyValue("Command", 
aData.sCommand),
+                        comphelper::makePropertyValue("CommandType", 
aData.nCommandType)
+                    };
                     pDBManager->ExecuteFormLetter(rSh, aProperties);
                 }
             }
@@ -2714,14 +2713,12 @@ void SwView::GenerateFormLetter(bool 
bUseCurrentDocument)
 
         if (pDBManager)
         {
-            Sequence<PropertyValue> aProperties(3);
-            PropertyValue* pValues = aProperties.getArray();
-            pValues[0].Name = "DataSourceName";
-            pValues[1].Name = "Command";
-            pValues[2].Name = "CommandType";
-            pValues[0].Value <<= aData.sDataSource;
-            pValues[1].Value <<= aData.sCommand;
-            pValues[2].Value <<= aData.nCommandType;
+            Sequence<PropertyValue> aProperties
+            {
+                comphelper::makePropertyValue("DataSourceName", 
aData.sDataSource),
+                comphelper::makePropertyValue("Command", aData.sCommand),
+                comphelper::makePropertyValue("CommandType", 
aData.nCommandType),
+            };
             pDBManager->ExecuteFormLetter(GetWrtShell(), aProperties);
         }
     }

Reply via email to