o3tl/qa/BigEndianTypesTest.cxx                 |    3 +
 oox/source/drawingml/fontworkhelpers.cxx       |   41 +++++++++++--------------
 oox/source/drawingml/textbodyproperties.cxx    |    4 +-
 oox/source/export/ColorExportUtils.cxx         |    4 +-
 oox/source/export/ThemeExport.cxx              |    6 +--
 oox/source/ppt/presentationfragmenthandler.cxx |    7 ++--
 6 files changed, 32 insertions(+), 33 deletions(-)

New commits:
commit ff2b5cfed65a4d34d12c233f75ec60a7ef30c6e4
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Aug 10 21:44:44 2025 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Aug 18 11:51:55 2025 +0200

    use std::to_array when constexpr std::array is used
    
    So it is not needed to write the number of elements in the array,
    as this is done by the compiler.
    
    This is similar to frozen::make_* functions (or better, those
    functions are similar to to_array).
    
    Change-Id: Ie589607fae0326ac8a01ebaee2e1b1cbec35bfdc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189322
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins

diff --git a/o3tl/qa/BigEndianTypesTest.cxx b/o3tl/qa/BigEndianTypesTest.cxx
index dccb0c172344..7522e3460f59 100644
--- a/o3tl/qa/BigEndianTypesTest.cxx
+++ b/o3tl/qa/BigEndianTypesTest.cxx
@@ -51,7 +51,8 @@ struct BigEndian32
 };
 
 // Test data
-constexpr std::array<sal_uInt8, 8> aDataArray = { 0x01, 0x02, 0x03, 0x04, 
0x05, 0x06, 0x07, 0x08 };
+constexpr auto aDataArray
+    = std::to_array<sal_uInt8>({ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
0x08 });
 
 class BigEndianTypesTest : public CppUnit::TestFixture
 {
diff --git a/oox/source/drawingml/fontworkhelpers.cxx 
b/oox/source/drawingml/fontworkhelpers.cxx
index c37bad867b48..23e72f3bb3d5 100644
--- a/oox/source/drawingml/fontworkhelpers.cxx
+++ b/oox/source/drawingml/fontworkhelpers.cxx
@@ -852,14 +852,15 @@ void FontworkHelpers::collectCharColorProps(const 
uno::Reference<text::XText>& r
                 continue;
 
             // We have found a non-empty run. Collect its simple color 
properties.
-            const std::array<OUString, 6> aNamesArray
-                = { u"CharColor"_ustr,      u"CharLumMod"_ustr,       
u"CharLumOff"_ustr,
-                    u"CharColorTheme"_ustr, u"CharComplexColor"_ustr, 
u"CharTransparence"_ustr };
-            for (const auto& propName : aNamesArray)
+            static constexpr auto aNamesArray = 
std::to_array<std::u16string_view>(
+                { u"CharColor", u"CharLumMod", u"CharLumOff", 
u"CharColorTheme",
+                  u"CharComplexColor", u"CharTransparence" });
+            for (const auto& sName : aNamesArray)
             {
-                if (xRunPropSetInfo->hasPropertyByName(propName))
+                OUString aPropertyName(sName);
+                if (xRunPropSetInfo->hasPropertyByName(aPropertyName))
                     rCharPropVec.push_back(comphelper::makePropertyValue(
-                        propName, xRunPropSet->getPropertyValue(propName)));
+                        aPropertyName, 
xRunPropSet->getPropertyValue(aPropertyName)));
             }
             return;
         }
@@ -910,15 +911,13 @@ void FontworkHelpers::applyPropsToRuns(const 
std::vector<beans::PropertyValue>&
 }
 namespace
 {
-constexpr const std::array<std::u16string_view, 5> aCharPropNames{
-    u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", 
u"CharComplexColor",
-    u"CharTransparence"
-};
+constexpr auto aCharPropNames = std::to_array<std::u16string_view>(
+    { u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", 
u"CharComplexColor",
+      u"CharTransparence" });
 
-constexpr const std::array<std::u16string_view, 5> aShapePropNames{
-    u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", 
u"FillComplexColor",
-    u"FillTransparence"
-};
+constexpr auto aShapePropNames = std::to_array<std::u16string_view>(
+    { u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", 
u"FillComplexColor",
+      u"FillTransparence" });
 }
 
 void FontworkHelpers::createCharFillPropsFromShape(
@@ -1046,15 +1045,13 @@ typedef std::multimap<sal_Int32, GradientStopColor> 
ColorMapType;
 
 namespace
 {
-constexpr const std::array<std::u16string_view, 12> W14ColorNames{
-    u"tx1",     u"bg1",     u"tx2",     u"bg2",     u"accent1", u"accent2",
-    u"accent3", u"accent4", u"accent5", u"accent6", u"hlink",   u"folHlink"
-};
+constexpr auto W14ColorNames = std::to_array<std::u16string_view>(
+    { u"tx1", u"bg1", u"tx2", u"bg2", u"accent1", u"accent2", u"accent3", 
u"accent4", u"accent5",
+      u"accent6", u"hlink", u"folHlink" });
 
-constexpr const std::array<std::u16string_view, 12> WColorNames{
-    u"text1",   u"background1", u"text2",   u"background2", u"accent1",   
u"accent2",
-    u"accent3", u"accent4",     u"accent5", u"accent6",     u"hyperlink", 
u"followedHyperlink"
-};
+constexpr auto WColorNames = std::to_array<std::u16string_view>(
+    { u"text1", u"background1", u"text2", u"background2", u"accent1", 
u"accent2", u"accent3",
+      u"accent4", u"accent5", u"accent6", u"hyperlink", u"followedHyperlink" 
});
 
 // Returns the string to be used in w14:schemeClr in case of w14:textOutline 
or w14:textFill
 OUString lcl_getW14MarkupStringForThemeColor(const model::ComplexColor& 
rComplexColor)
diff --git a/oox/source/drawingml/textbodyproperties.cxx 
b/oox/source/drawingml/textbodyproperties.cxx
index ff501e40c413..3b885003fd4f 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -72,12 +72,12 @@ void TextBodyProperties::pushTextDistances(Size const& 
rTextAreaSize)
         rValue.reset();
 
     sal_Int32 nOff = 0;
-    static constexpr const std::array<sal_Int32, 4> aProps {
+    static constexpr auto aProps = std::to_array<sal_Int32>({
         PROP_TextLeftDistance,
         PROP_TextUpperDistance,
         PROP_TextRightDistance,
         PROP_TextLowerDistance
-    };
+    });
 
     switch (moTextPreRotation.value_or(0))
     {
diff --git a/oox/source/export/ColorExportUtils.cxx 
b/oox/source/export/ColorExportUtils.cxx
index d46ab493b5ab..86bb2f0298aa 100644
--- a/oox/source/export/ColorExportUtils.cxx
+++ b/oox/source/export/ColorExportUtils.cxx
@@ -50,8 +50,8 @@ sal_Int32 
convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType)
     // 0 -> 1, 1 -> 0
     // 2 -> 3, 3 -> 2
     // everything else stays the same
-    static constexpr std::array<sal_Int32, 12> constThemeColorMapToXmlMap
-        = { 1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11 };
+    static constexpr auto constThemeColorMapToXmlMap
+        = std::to_array<sal_Int32>({ 1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11 });
 
     return constThemeColorMapToXmlMap[sal_Int32(eType)];
 }
diff --git a/oox/source/export/ThemeExport.cxx 
b/oox/source/export/ThemeExport.cxx
index 51d1943ade1b..87504c583e88 100644
--- a/oox/source/export/ThemeExport.cxx
+++ b/oox/source/export/ThemeExport.cxx
@@ -872,9 +872,9 @@ bool ThemeExport::writeFormatScheme(model::FormatScheme 
const& rFormatScheme)
 
 bool ThemeExport::writeColorSet(model::Theme const& rTheme)
 {
-    static const constexpr std::array<sal_Int32, 12> constTokenArray
-        = { XML_dk1,     XML_lt1,     XML_dk2,     XML_lt2,     XML_accent1, 
XML_accent2,
-            XML_accent3, XML_accent4, XML_accent5, XML_accent6, XML_hlink,   
XML_folHlink };
+    static constexpr auto constTokenArray = std::to_array<sal_Int32>(
+        { XML_dk1, XML_lt1, XML_dk2, XML_lt2, XML_accent1, XML_accent2, 
XML_accent3, XML_accent4,
+          XML_accent5, XML_accent6, XML_hlink, XML_folHlink });
 
     const auto& pColorSet = rTheme.getColorSet();
     if (!pColorSet)
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index f5b2d40eea0e..4e6d7edd510e 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -385,10 +385,11 @@ void 
PresentationFragmentHandler::saveColorMapToGrabBag(const oox::drawingml::Cl
             static constexpr OUString aGrabBagPropName = 
u"InteropGrabBag"_ustr;
             if (xPropsInfo.is() && 
xPropsInfo->hasPropertyByName(aGrabBagPropName))
             {
-                static const constexpr std::array<sal_Int32, 12> 
constTokenArray
-                    = { XML_bg1,     XML_tx1,     XML_bg2,     XML_tx2,
+                static constexpr auto constTokenArray = 
std::to_array<sal_Int32>({
+                        XML_bg1,     XML_tx1,     XML_bg2,     XML_tx2,
                         XML_accent1, XML_accent2, XML_accent3, XML_accent4,
-                        XML_accent5, XML_accent6, XML_hlink,   XML_folHlink };
+                        XML_accent5, XML_accent6, XML_hlink,   XML_folHlink
+                });
 
                 comphelper::SequenceAsHashMap aClrMapHashMap;
                 comphelper::SequenceAsHashMap aGrabBag(

Reply via email to