sw/inc/unocrsrhelper.hxx          |    5 +++++
 sw/source/core/unocore/unoobj.cxx |   21 +++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit c11acfa916302e2af9ecc4c1657ac7461148bfcf
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun Oct 30 15:01:02 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Oct 30 16:42:11 2022 +0100

    tdf#126788 avoid temporary Sequence
    
    Change-Id: Id2cc39529aa26429e929704271db450abe6bd1e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142040
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx
index c52601cdfefa..11ae6b366e79 100644
--- a/sw/inc/unocrsrhelper.hxx
+++ b/sw/inc/unocrsrhelper.hxx
@@ -171,6 +171,11 @@ namespace SwUnoCursorHelper
             const css::uno::Sequence< css::beans::PropertyValue > &
             rPropertyValues,
             const SetAttrMode nAttrMode = SetAttrMode::DEFAULT);
+    void SetPropertyValues(
+            SwPaM& rPaM,
+            const SfxItemPropertySet & rPropSet,
+            o3tl::span< const css::beans::PropertyValue > aPropertyValues,
+            const SetAttrMode nAttrMode = SetAttrMode::DEFAULT);
     /// @throws css::beans::UnknownPropertyException
     /// @throws css::lang::WrappedTargetException
     /// @throws css::uno::RuntimeException
diff --git a/sw/source/core/unocore/unoobj.cxx 
b/sw/source/core/unocore/unoobj.cxx
index 0bc921fa8f00..3933bef5d31d 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1884,9 +1884,8 @@ void SwUnoCursorHelper::SetPropertyValue(
     const uno::Any& rValue,
     const SetAttrMode nAttrMode)
 {
-    uno::Sequence< beans::PropertyValue > aValues{ 
comphelper::makePropertyValue(rPropertyName,
-                                                                               
  rValue)};
-    SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode);
+    beans::PropertyValue aVal { comphelper::makePropertyValue(rPropertyName, 
rValue) };
+    SetPropertyValues(rPaM, rPropSet, o3tl::span<beans::PropertyValue>(&aVal, 
1), nAttrMode);
 }
 
 // FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
@@ -1906,7 +1905,17 @@ void SwUnoCursorHelper::SetPropertyValues(
     const uno::Sequence< beans::PropertyValue > &rPropertyValues,
     const SetAttrMode nAttrMode)
 {
-    if (!rPropertyValues.hasElements())
+    SetPropertyValues(rPaM, rPropSet,
+        o3tl::span<const 
beans::PropertyValue>(rPropertyValues.getConstArray(), 
rPropertyValues.getLength()),
+        nAttrMode);
+}
+
+void SwUnoCursorHelper::SetPropertyValues(
+    SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
+    o3tl::span< const beans::PropertyValue > aPropertyValues,
+    const SetAttrMode nAttrMode)
+{
+    if (aPropertyValues.empty())
         return;
 
     SwDoc& rDoc = rPaM.GetDoc();
@@ -1915,8 +1924,8 @@ void SwUnoCursorHelper::SetPropertyValues(
     // Build set of attributes we want to fetch
     WhichRangesContainer aRanges;
     std::vector<std::pair<const SfxItemPropertyMapEntry*, const uno::Any&>> 
aEntries;
-    aEntries.reserve(rPropertyValues.getLength());
-    for (const auto& rPropVal : rPropertyValues)
+    aEntries.reserve(aPropertyValues.size());
+    for (const auto& rPropVal : aPropertyValues)
     {
         const OUString &rPropertyName = rPropVal.Name;
 

Reply via email to