include/oox/drawingml/theme.hxx               |    8 ++++---
 include/svx/ColorSets.hxx                     |   22 ++++++++++----------
 oox/source/drawingml/themeelementscontext.cxx |   17 +++++++++++----
 svx/source/styles/ColorSets.cxx               |   28 ++++++++++++++------------
 4 files changed, 44 insertions(+), 31 deletions(-)

New commits:
commit 77d1b32832cafab03eb858b3b37eeeaf61b51cc4
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Dec 12 21:48:17 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Jan 20 07:12:16 2023 +0000

    svx: use array for colors in ColorSet, add consts, rename vars
    
    Use std::array for colors in ColorSet as there are always only 12
    colors for a color scheme.
    Add "const" to getters where appropriate.
    Rename maColorSetName to maName in ColorSet - long variable name
    is not needed.
    
    Change-Id: Iacb976a22af2d2585d627b0ba65d98cbe1b825c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143994
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 29c2bba1f3ef216d226c97197185066880fc1ab5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145839
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx
index 692e683218e8..6b4504ebb877 100644
--- a/include/svx/ColorSets.hxx
+++ b/include/svx/ColorSets.hxx
@@ -11,6 +11,7 @@
 #ifndef INCLUDED_SVX_COLORSETS_HXX
 #define INCLUDED_SVX_COLORSETS_HXX
 
+#include <array>
 #include <vector>
 
 #include <rtl/ustring.hxx>
@@ -52,19 +53,17 @@ constexpr ThemeColorType convertToThemeColorType(sal_Int32 
nIndex)
 
 class SVXCORE_DLLPUBLIC ColorSet
 {
-    OUString maColorSetName;
-    std::vector<Color> maColors;
+    OUString maName;
+    std::array<Color, 12> maColors;
+
 public:
-    ColorSet(OUString aName);
+    ColorSet(OUString const& rName);
 
-    void add(sal_uInt32 nIndex, ::Color aColorData)
-    {
-        maColors[nIndex] = aColorData;
-    }
+    void add(sal_uInt32 nIndex, Color aColorData);
 
     const OUString& getName() const
     {
-        return maColorSetName;
+        return maName;
     }
 
     Color getColor(ThemeColorType nType) const
@@ -88,7 +87,7 @@ public:
         return maColorSets;
     }
 
-    const ColorSet& getColorSet(sal_uInt32 nIndex)
+    const ColorSet& getColorSet(sal_uInt32 nIndex) const
     {
         return maColorSets[nIndex];
     }
@@ -99,14 +98,15 @@ public:
 /// A named theme has a named color set.
 class SVXCORE_DLLPUBLIC Theme
 {
+private:
     OUString maName;
     std::unique_ptr<ColorSet> mpColorSet;
 
 public:
-    Theme(OUString sName);
-    ~Theme();
+    Theme(OUString const& rName);
 
     void SetColorSet(std::unique_ptr<ColorSet> pColorSet);
+    const ColorSet* GetColorSet() const;
     ColorSet* GetColorSet();
 
     void SetName(const OUString& rName);
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 6af2ee6313bc..bb8009fdc5be 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -93,7 +93,7 @@ void UpdateFillColorSet(const 
uno::Reference<beans::XPropertySet>& xShape, const
 
 void UpdateSdrObject(svx::Theme* pTheme, SdrObject* pObject)
 {
-    svx::ColorSet* pColorSet = pTheme->GetColorSet();
+    const svx::ColorSet* pColorSet = pTheme->GetColorSet();
     if (!pColorSet)
     {
         return;
@@ -126,20 +126,21 @@ void UpdateSdrObject(svx::Theme* pTheme, SdrObject* 
pObject)
 namespace svx
 {
 
-ColorSet::ColorSet(OUString aColorSetName)
-    : maColorSetName(std::move(aColorSetName))
-    , maColors(12)
+ColorSet::ColorSet(OUString const& rName)
+    : maName(rName)
 {}
 
-ColorSets::ColorSets()
-{}
+void ColorSet::add(sal_uInt32 nIndex, Color aColorData)
+{
+    maColors[nIndex] = aColorData;
+}
 
 void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ColorSet"));
     (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maColorSetName"),
-                                      
BAD_CAST(maColorSetName.toUtf8().getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maName"),
+                                      BAD_CAST(maName.toUtf8().getStr()));
 
     for (const auto& rColor : maColors)
     {
@@ -153,6 +154,9 @@ void ColorSet::dumpAsXml(xmlTextWriterPtr pWriter) const
     (void)xmlTextWriterEndElement(pWriter);
 }
 
+ColorSets::ColorSets()
+{}
+
 ColorSets::~ColorSets()
 {}
 
@@ -234,15 +238,15 @@ const ColorSet& 
ColorSets::getColorSet(std::u16string_view rName)
     return maColorSets[0];
 }
 
-Theme::Theme(OUString aName)
-    : maName(std::move(aName))
+Theme::Theme(OUString const& rName)
+    : maName(rName)
 {
 }
 
-Theme::~Theme() {}
-
 void Theme::SetColorSet(std::unique_ptr<ColorSet> pColorSet) { mpColorSet = 
std::move(pColorSet); }
 
+const ColorSet* Theme::GetColorSet() const { return mpColorSet.get(); }
+
 ColorSet* Theme::GetColorSet() { return mpColorSet.get(); }
 
 void Theme::SetName(const OUString& rName) { maName = rName; }
commit 66975322637917db719526e3c63f558f36db1c6a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Dec 12 21:41:50 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Jan 20 07:12:06 2023 +0000

    oox: rename name variables that are imported into oox::Theme
    
    Rename names for font scheme and format scheme in oox::Theme so
    it is easier to know for what they are used for.
    
    Change-Id: I83e2978c407ab7f264de4a161575b086bc5efc03
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143993
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit cffe7884342f249e82780a46f9aba4213e9dd378)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145838
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx
index 34347923b669..f7b4a262ffb8 100644
--- a/include/oox/drawingml/theme.hxx
+++ b/include/oox/drawingml/theme.hxx
@@ -57,8 +57,9 @@ class TextFont;
 class OOX_DLLPUBLIC Theme
 {
 public:
-    void                     setStyleName( const OUString& rStyleName ) { 
maStyleName = rStyleName; }
-    void setThemeName(const OUString& rThemeName) { maThemeName = rThemeName; }
+    void setThemeName(OUString const& rName) { maThemeName = rName; }
+    void setFormatSchemeName(OUString const& rName) { maFormatSchemeName = 
rName; }
+    void setFontSchemeName(OUString const& rName) { maFontSchemeName = rName; }
 
     ClrScheme&               getClrScheme() { return maClrScheme; }
     const ClrScheme&         getClrScheme() const { return maClrScheme; }
@@ -101,8 +102,9 @@ public:
     void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& 
xDrawPage) const;
 
 private:
-    OUString            maStyleName;
     OUString            maThemeName;
+    OUString            maFontSchemeName;
+    OUString            maFormatSchemeName;
     ClrScheme           maClrScheme;
     FillStyleList       maFillStyleList;
     FillStyleList       maBgFillStyleList;
diff --git a/oox/source/drawingml/themeelementscontext.cxx 
b/oox/source/drawingml/themeelementscontext.cxx
index 9ff178c00cd1..2cb9d12ab020 100644
--- a/oox/source/drawingml/themeelementscontext.cxx
+++ b/oox/source/drawingml/themeelementscontext.cxx
@@ -214,17 +214,24 @@ ContextHandlerRef ThemeElementsContext::onCreateContext( 
sal_Int32 nElement, con
     switch( nElement )
     {
         case A_TOKEN( clrScheme ):  // CT_ColorScheme
+        {
             if (rAttribs.hasAttribute(XML_name))
-            {
                 
mrTheme.getClrScheme().SetName(rAttribs.getStringDefaulted(XML_name));
-            }
-            return new clrSchemeContext( *this, mrTheme.getClrScheme() );
+            return new clrSchemeContext(*this, mrTheme.getClrScheme());
+        }
         case A_TOKEN( fontScheme ): // CT_FontScheme
-            return new FontSchemeContext( *this, mrTheme.getFontScheme() );
+        {
+            if (rAttribs.hasAttribute(XML_name))
+                
mrTheme.setFontSchemeName(rAttribs.getStringDefaulted(XML_name));
+            return new FontSchemeContext(*this, mrTheme.getFontScheme());
+        }
 
         case A_TOKEN( fmtScheme ):  // CT_StyleMatrix
-            mrTheme.setStyleName( rAttribs.getStringDefaulted( XML_name ) );
+        {
+            if (rAttribs.hasAttribute(XML_name))
+                
mrTheme.setFormatSchemeName(rAttribs.getStringDefaulted(XML_name));
             return this;
+        }
 
         case A_TOKEN( fillStyleLst ):   // CT_FillStyleList
             return new FillStyleListContext( *this, mrTheme.getFillStyleList() 
);

Reply via email to