xmloff/inc/MultiPropertySetHelper.hxx          |   12 ++++------
 xmloff/source/style/MultiPropertySetHelper.cxx |   19 ++++-----------
 xmloff/source/text/txtparae.cxx                |   30 +++++++++++--------------
 3 files changed, 24 insertions(+), 37 deletions(-)

New commits:
commit 7dafe7d3b61060b8e9469594c86ed49e55874c78
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri May 3 10:25:08 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 6 08:26:15 2024 +0200

    replace createFromAscii with OUString literals in MultiPropertySetHelper
    
    Change-Id: I4b4cef2d7afac3963ab9b3f2fda10d11b754fd00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167165
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/xmloff/inc/MultiPropertySetHelper.hxx 
b/xmloff/inc/MultiPropertySetHelper.hxx
index 9d539fa26287..f081e92572da 100644
--- a/xmloff/inc/MultiPropertySetHelper.hxx
+++ b/xmloff/inc/MultiPropertySetHelper.hxx
@@ -21,6 +21,7 @@
 #include <rtl/ustring.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 #include <memory>
+#include <span>
 
 namespace com::sun::star
 {
@@ -62,10 +63,7 @@ class XPropertySetInfo;
 class MultiPropertySetHelper
 {
     /// names of all properties
-    std::unique_ptr<OUString[]> pPropertyNames;
-
-    /// length of pPropertyNames array
-    sal_Int16 nLength;
+    std::span<const OUString> pPropertyNames;
 
     /// the sequence of property names that the current (multi)
     /// property set implementation supports
@@ -85,7 +83,7 @@ class MultiPropertySetHelper
     css::uno::Any aEmptyAny;
 
 public:
-    MultiPropertySetHelper(const char** pNames);
+    MultiPropertySetHelper(std::span<const OUString> pNames);
 
     ~MultiPropertySetHelper();
 
@@ -169,7 +167,7 @@ const css::uno::Any& 
MultiPropertySetHelper::getValue(sal_Int16 nValueNo)
 {
     assert(pValues && "called getValue() without calling getValues()");
     assert(pSequenceIndex && "called getValue() without calling 
hasProperties()");
-    assert(nValueNo < nLength);
+    assert(o3tl::make_unsigned(nValueNo) < pPropertyNames.size());
 
     sal_Int16 nIndex = pSequenceIndex[nValueNo];
     return (nIndex != -1) ? pValues[nIndex] : aEmptyAny;
@@ -178,7 +176,7 @@ const css::uno::Any& 
MultiPropertySetHelper::getValue(sal_Int16 nValueNo)
 bool MultiPropertySetHelper::hasProperty(sal_Int16 nValueNo)
 {
     assert(pSequenceIndex && "called hasProperty() without calling 
hasProperties()");
-    assert(nValueNo < nLength);
+    assert(o3tl::make_unsigned(nValueNo) < pPropertyNames.size());
 
     return pSequenceIndex[nValueNo] != -1;
 }
diff --git a/xmloff/source/style/MultiPropertySetHelper.cxx 
b/xmloff/source/style/MultiPropertySetHelper.cxx
index 7636278ebef6..e8c469942ca2 100644
--- a/xmloff/source/style/MultiPropertySetHelper.cxx
+++ b/xmloff/source/style/MultiPropertySetHelper.cxx
@@ -34,18 +34,10 @@ using ::com::sun::star::uno::UNO_QUERY;
 
 
 MultiPropertySetHelper::MultiPropertySetHelper(
-    const char** pNames ) :
-        nLength( 0 ),
+    std::span<const OUString> pNames ) :
+        pPropertyNames( pNames ),
         pValues( nullptr )
 {
-    // first count the elements
-    for( const char** pPtr = pNames; *pPtr != nullptr; pPtr++ )
-        nLength++;
-
-    // allocate array and create strings
-    pPropertyNames.reset( new OUString[nLength] );
-    for( sal_Int16 i = 0; i < nLength; i++ )
-        pPropertyNames[i] = OUString::createFromAscii( pNames[i] );
 }
 
 
@@ -62,13 +54,12 @@ void MultiPropertySetHelper::hasProperties(
 
     // allocate sequence index
     if ( !pSequenceIndex )
-        pSequenceIndex.reset( new sal_Int16[nLength] );
+        pSequenceIndex.reset( new sal_Int16[pPropertyNames.size()] );
 
     // construct pSequenceIndex
     sal_Int16 nNumberOfProperties = 0;
-    sal_Int16 i;
 
-    for( i = 0; i < nLength; i++ )
+    for( size_t i = 0; i < pPropertyNames.size(); i++ )
     {
         // ask for property
         bool bHasProperty =
@@ -84,7 +75,7 @@ void MultiPropertySetHelper::hasProperties(
     if ( aPropertySequence.getLength() != nNumberOfProperties )
         aPropertySequence.realloc( nNumberOfProperties );
     OUString* pPropertySequence = aPropertySequence.getArray();
-    for( i = 0; i < nLength; i ++ )
+    for( size_t i = 0; i < pPropertyNames.size(); i ++ )
     {
         sal_Int16 nIndex = pSequenceIndex[i];
         if ( nIndex != -1 )
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index b0671175e547..4bafc7a33640 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -470,12 +470,11 @@ static bool txtparae_bContainsIllegalCharacters = false;
 // For the export pass all properties can be queried using a multi property
 // set.
 
-static const char* aParagraphPropertyNamesAuto[] =
+constexpr OUString aParagraphPropertyNamesAuto[] =
 {
-    "NumberingRules",
-    "ParaConditionalStyleName",
-    "ParaStyleName",
-    nullptr
+    u"NumberingRules"_ustr,
+    u"ParaConditionalStyleName"_ustr,
+    u"ParaStyleName"_ustr
 };
 
 namespace {
@@ -489,16 +488,15 @@ enum eParagraphPropertyNamesEnumAuto
 
 }
 
-static const char* aParagraphPropertyNames[] =
+constexpr OUString aParagraphPropertyNames[] =
 {
-    "NumberingIsNumber",
-    "NumberingStyleName",
-    "OutlineLevel",
-    "ParaConditionalStyleName",
-    "ParaStyleName",
-    "TextSection",
-    "OutlineContentVisible",
-    nullptr
+    u"NumberingIsNumber"_ustr,
+    u"NumberingStyleName"_ustr,
+    u"OutlineLevel"_ustr,
+    u"ParaConditionalStyleName"_ustr,
+    u"ParaStyleName"_ustr,
+    u"TextSection"_ustr,
+    u"OutlineContentVisible"_ustr
 };
 
 namespace {
@@ -1830,8 +1828,8 @@ void XMLTextParagraphExport::exportTextContentEnumeration(
     Reference<XTextSection> xCurrentTextSection(rBaseSection);
 
     MultiPropertySetHelper aPropSetHelper(
-                               bAutoStyles ? aParagraphPropertyNamesAuto :
-                                          aParagraphPropertyNames );
+                               bAutoStyles ? std::span<const 
OUString>(aParagraphPropertyNamesAuto) :
+                                          std::span<const 
OUString>(aParagraphPropertyNames) );
 
     bool bHoldElement = false;
     Reference < XTextContent > xTxtCntnt;

Reply via email to