summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/ColorSets.hxx12
-rw-r--r--include/svx/dialog/ThemeDialog.hxx4
-rw-r--r--include/svx/svdmodel.hxx4
-rw-r--r--include/svx/svdpage.hxx2
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx2
-rw-r--r--sd/source/ui/docshell/docshell.cxx4
-rw-r--r--sd/source/ui/func/fuconstr.cxx2
-rw-r--r--sd/source/ui/func/fupage.cxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx4
-rw-r--r--sd/source/ui/unoidl/unopage.cxx4
-rw-r--r--svx/source/dialog/ThemeDialog.cxx19
-rw-r--r--svx/source/styles/ColorSets.cxx34
-rw-r--r--svx/source/svdraw/svdmodel.cxx24
-rw-r--r--svx/source/svdraw/svdpage.cxx25
-rw-r--r--sw/qa/core/theme/ThemeTest.cxx4
-rw-r--r--sw/source/core/model/ThemeColorChanger.cxx4
-rw-r--r--sw/source/core/unocore/unodraw.cxx2
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx2
-rw-r--r--sw/source/uibase/app/docst.cxx2
-rw-r--r--sw/source/uibase/shells/basesh.cxx6
-rw-r--r--sw/source/uibase/sidebar/ThemePanel.cxx22
-rw-r--r--sw/source/uibase/sidebar/ThemePanel.hxx2
22 files changed, 116 insertions, 70 deletions
diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx
index faec6d2c2249..cb096dab0e87 100644
--- a/include/svx/ColorSets.hxx
+++ b/include/svx/ColorSets.hxx
@@ -15,19 +15,21 @@
#include <sal/log.hxx>
#include <svx/svxdllapi.h>
#include <docmodel/theme/ColorSet.hxx>
+#include <optional>
namespace svx
{
class SVXCORE_DLLPUBLIC ColorSets
{
+private:
std::vector<model::ColorSet> maColorSets;
-public:
ColorSets();
- ~ColorSets();
-
void init();
- const std::vector<model::ColorSet>& getColorSets() const
+public:
+ static ColorSets& get();
+
+ const std::vector<model::ColorSet>& getColorSetVector() const
{
return maColorSets;
}
@@ -37,7 +39,7 @@ public:
return maColorSets[nIndex];
}
- const model::ColorSet& getColorSet(std::u16string_view rName);
+ model::ColorSet const* getColorSet(std::u16string_view rName) const;
void insert(model::ColorSet const& rColorSet);
};
diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx
index 1db4f2f43e6a..5d3fdc70f250 100644
--- a/include/svx/dialog/ThemeDialog.hxx
+++ b/include/svx/dialog/ThemeDialog.hxx
@@ -12,7 +12,6 @@
#include <svx/svxdllapi.h>
#include <vcl/weld.hxx>
#include <docmodel/theme/Theme.hxx>
-#include <svx/ColorSets.hxx>
#include <svx/svdpage.hxx>
#include <svx/theme/IThemeColorChanger.hxx>
#include <svx/dialog/ThemeColorValueSet.hxx>
@@ -23,7 +22,8 @@ class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController
{
private:
model::Theme* mpTheme;
- svx::ColorSets maColorSets;
+ std::vector<model::ColorSet> maColorSets;
+
std::shared_ptr<IThemeColorChanger> mpChanger;
std::unique_ptr<svx::ThemeColorValueSet> mxValueSetThemeColors;
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 63cc3bc1fb79..fe216d569919 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -538,8 +538,8 @@ public:
SfxStyleSheetBasePool* GetStyleSheetPool() const { return mxStyleSheetPool.get(); }
void SetStyleSheetPool(SfxStyleSheetBasePool* pPool) { mxStyleSheetPool=pPool; }
- void SetTheme(std::unique_ptr<model::Theme> pTheme);
- model::Theme* GetTheme();
+ void setTheme(std::unique_ptr<model::Theme> pTheme);
+ std::unique_ptr<model::Theme> const& getTheme() const;
void SetStarDrawPreviewMode(bool bPreview);
bool IsStarDrawPreviewMode() const { return m_bStarDrawPreviewMode; }
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 186a49a028f8..fde15ccedcd9 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -347,7 +347,7 @@ public:
SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
void SetTheme(std::unique_ptr<model::Theme> pTheme);
- model::Theme* GetTheme();
+ std::unique_ptr<model::Theme> const& GetTheme() const;
void dumpAsXml(xmlTextWriterPtr pWriter) const;
};
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 16208f48fb79..1ae7da9cc786 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1511,7 +1511,7 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro
model::Theme* pTheme = nullptr;
if (pMasterPage)
{
- pTheme = pMasterPage->getSdrPageProperties().GetTheme();
+ pTheme = pMasterPage->getSdrPageProperties().GetTheme().get();
}
// write theme per master
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index a8ec35e21cb7..3aacb189f826 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -492,10 +492,10 @@ std::vector<Color> DrawDocShell::GetThemeColors()
}
SdPage* pPage = pViewShell->getCurrentPage();
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme().get();
if (!pPage->IsMasterPage())
{
- pTheme = pPage->TRG_GetMasterPage().getSdrPageProperties().GetTheme();
+ pTheme = pPage->TRG_GetMasterPage().getSdrPageProperties().GetTheme().get();
}
if (!pTheme)
diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx
index ea8443d9183b..eee7094a78f8 100644
--- a/sd/source/ui/func/fuconstr.cxx
+++ b/sd/source/ui/func/fuconstr.cxx
@@ -379,7 +379,7 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
pThemePage = &pThemePage->TRG_GetMasterPage();
}
- model::Theme* pTheme = pThemePage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pThemePage->getSdrPageProperties().GetTheme();
if (pTheme)
{
// We construct an object on a page where the master page has a theme. Take the
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 7e353bba1c91..7416916f01e7 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -265,7 +265,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
if (mpDoc->GetDocumentType() == DocumentType::Impress && mpPage->IsMasterPage())
{
// A master slide may have a theme.
- model::Theme* pTheme = mpPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = mpPage->getSdrPageProperties().GetTheme();
if (pTheme)
{
uno::Any aTheme;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index b5c9e64a61bc..230633d66ad1 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1283,7 +1283,7 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam
{
SdrModel& rModel = getSdrModelFromUnoModel();
std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
- rModel.SetTheme(std::move(pTheme));
+ rModel.setTheme(std::move(pTheme));
}
break;
default:
@@ -1409,7 +1409,7 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property
case WID_MODEL_THEME:
{
SdrModel& rModel = getSdrModelFromUnoModel();
- model::Theme* pTheme = rModel.GetTheme();
+ auto const& pTheme = rModel.getTheme();
if (pTheme)
{
pTheme->ToAny(aAny);
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 7b467158651d..b9201adea71d 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1316,7 +1316,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
{
SdrPage* pPage = GetPage();
css::uno::Reference<css::util::XTheme> xTheme;
- auto* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
xTheme = new UnoTheme(*pTheme);
aAny <<= xTheme;
@@ -1326,7 +1326,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
case WID_PAGE_THEME_UNO_REPRESENTATION:
{
SdrPage* pPage = GetPage();
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
{
pTheme->ToAny(aAny);
diff --git a/svx/source/dialog/ThemeDialog.cxx b/svx/source/dialog/ThemeDialog.cxx
index 842a40203efa..9da0e48bf13b 100644
--- a/svx/source/dialog/ThemeDialog.cxx
+++ b/svx/source/dialog/ThemeDialog.cxx
@@ -11,6 +11,7 @@
#include <docmodel/theme/ThemeColor.hxx>
#include <docmodel/theme/ColorSet.hxx>
#include <docmodel/theme/Theme.hxx>
+#include <svx/ColorSets.hxx>
#include <vcl/svapp.hxx>
namespace svx
@@ -29,17 +30,19 @@ ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* pTheme,
mxValueSetThemeColors->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor());
mxValueSetThemeColors->SetDoubleClickHdl(LINK(this, ThemeDialog, DoubleClickValueSetHdl));
- maColorSets.init();
- maColorSets.insert(*mpTheme->GetColorSet());
+ if (mpTheme)
+ maColorSets.push_back(*mpTheme->GetColorSet());
+ auto const& rColorSetVector = ColorSets::get().getColorSetVector();
+ maColorSets.insert(maColorSets.end(), rColorSetVector.begin(), rColorSetVector.end());
- for (auto const& rColorSet : maColorSets.getColorSets())
+ for (auto const& rColorSet : maColorSets)
{
mxValueSetThemeColors->insert(rColorSet);
}
mxValueSetThemeColors->SetOptimalSize();
- if (!maColorSets.getColorSets().empty())
+ if (!rColorSetVector.empty())
mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0
}
@@ -55,9 +58,11 @@ void ThemeDialog::DoubleClickHdl()
sal_uInt32 nIndex = nItemId - 1;
- model::ColorSet const& rColorSet = maColorSets.getColorSet(nIndex);
-
- mpChanger->apply(rColorSet);
+ if (nIndex < maColorSets.size())
+ {
+ model::ColorSet const& rColorSet = maColorSets[nIndex];
+ mpChanger->apply(rColorSet);
+ }
}
} // end svx namespace
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 145babb7d98d..438a9a36b01c 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -19,10 +19,18 @@ namespace svx
{
ColorSets::ColorSets()
-{}
+{
+ init();
+}
+
+ColorSets& ColorSets::get()
+{
+ static std::optional<ColorSets> sColorSet;
+ if (!sColorSet)
+ sColorSet = ColorSets();
+ return *sColorSet;
+}
-ColorSets::~ColorSets()
-{}
void ColorSets::init()
{
@@ -140,19 +148,29 @@ void ColorSets::init()
}
}
-const model::ColorSet& ColorSets::getColorSet(std::u16string_view rName)
+model::ColorSet const* ColorSets::getColorSet(std::u16string_view rName) const
{
for (const model::ColorSet & rColorSet : maColorSets)
{
if (rColorSet.getName() == rName)
- return rColorSet;
+ return &rColorSet;
}
- return maColorSets[0];
+ return nullptr;
}
-void ColorSets::insert(model::ColorSet const& rColorSet)
+void ColorSets::insert(model::ColorSet const& rNewColorSet)
{
- maColorSets.push_back(rColorSet);
+ for (model::ColorSet& rColorSet : maColorSets)
+ {
+ if (rColorSet.getName() == rNewColorSet.getName())
+ {
+ rColorSet = rNewColorSet;
+ return;
+ }
+ }
+
+ // color set not found, so insert it
+ maColorSets.push_back(rNewColorSet);
}
} // end of namespace svx
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 47f2b517bf5e..5a577da212b3 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -73,6 +73,7 @@
#include <comphelper/diagnose_ex.hxx>
#include <tools/UnitConversion.hxx>
#include <docmodel/theme/Theme.hxx>
+#include <svx/ColorSets.hxx>
#include <svx/svditer.hxx>
#include <svx/svdoashp.hxx>
@@ -96,7 +97,18 @@ struct SdrModelImpl
, mbLegacySingleLineFontwork(false)
, mbConnectorUseSnapRect(false)
, mbIgnoreBreakAfterMultilineField(false)
+ , mpTheme(new model::Theme("Office"))
{}
+
+ void initTheme()
+ {
+ auto const* pColorSet = svx::ColorSets::get().getColorSet(u"LibreOffice");
+ if (pColorSet)
+ {
+ std::unique_ptr<model::ColorSet> pDefaultColorSet(new model::ColorSet(*pColorSet));
+ mpTheme->SetColorSet(std::move(pDefaultColorSet));
+ }
+ }
};
@@ -182,6 +194,8 @@ SdrModel::SdrModel(SfxItemPool* pPool, comphelper::IEmbeddedHelper* pEmbeddedHel
ImpSetOutlinerDefaults(m_pChainingOutliner.get(), true);
ImpCreateTables(bDisablePropertyFiles || utl::ConfigManager::IsFuzzing());
+
+ mpImpl->initTheme();
}
SdrModel::~SdrModel()
@@ -1550,9 +1564,15 @@ void SdrModel::SetStarDrawPreviewMode(bool bPreview)
}
}
-void SdrModel::SetTheme(std::unique_ptr<model::Theme> pTheme) { mpImpl->mpTheme = std::move(pTheme); }
+void SdrModel::setTheme(std::unique_ptr<model::Theme> pTheme)
+{
+ mpImpl->mpTheme = std::move(pTheme);
+}
-model::Theme* SdrModel::GetTheme() { return mpImpl->mpTheme.get(); }
+std::unique_ptr<model::Theme> const& SdrModel::getTheme() const
+{
+ return mpImpl->mpTheme;
+}
uno::Reference< uno::XInterface > const & SdrModel::getUnoModel()
{
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index cb2fb64e7e80..8a3c4049f7bf 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -45,6 +45,7 @@
#include <svx/xfillit0.hxx>
#include <svx/fmdpage.hxx>
#include <svx/theme/ThemeColorChanger.hxx>
+#include <svx/ColorSets.hxx>
#include <sdr/contact/viewcontactofsdrpage.hxx>
#include <svx/sdr/contact/viewobjectcontact.hxx>
@@ -1210,16 +1211,27 @@ static void ImpPageChange(SdrPage& rSdrPage)
}
SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
-: mpSdrPage(&rSdrPage),
- mpStyleSheet(nullptr),
- maProperties(
+ : mpSdrPage(&rSdrPage)
+ , mpStyleSheet(nullptr)
+ , maProperties(
mpSdrPage->getSdrModelFromSdrPage().GetItemPool(),
svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>)
{
- if(!rSdrPage.IsMasterPage())
+ if (!rSdrPage.IsMasterPage())
{
maProperties.Put(XFillStyleItem(drawing::FillStyle_NONE));
}
+
+ if (rSdrPage.getSdrModelFromSdrPage().IsWriter())
+ {
+ mpTheme.reset(new model::Theme("Office"));
+ auto const* pColorSet = svx::ColorSets::get().getColorSet(u"LibreOffice");
+ if (pColorSet)
+ {
+ std::unique_ptr<model::ColorSet> pDefaultColorSet(new model::ColorSet(*pColorSet));
+ mpTheme->SetColorSet(std::move(pDefaultColorSet));
+ }
+ }
}
SdrPageProperties::~SdrPageProperties()
@@ -1310,7 +1322,10 @@ void SdrPageProperties::SetTheme(std::unique_ptr<model::Theme> pTheme)
}
}
-model::Theme* SdrPageProperties::GetTheme() { return mpTheme.get(); }
+std::unique_ptr<model::Theme> const& SdrPageProperties::GetTheme() const
+{
+ return mpTheme;
+}
void SdrPageProperties::dumpAsXml(xmlTextWriterPtr pWriter) const
{
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index e3ed5548f528..5c95de1e7c38 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -49,7 +49,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExistsDOCX)
CPPUNIT_ASSERT(pDoc);
SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
CPPUNIT_ASSERT(pTheme);
CPPUNIT_ASSERT_EQUAL(OUString(u"Office Theme"), pTheme->GetName());
@@ -90,7 +90,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExistsODT)
CPPUNIT_ASSERT(pDoc);
SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
CPPUNIT_ASSERT(pTheme);
CPPUNIT_ASSERT_EQUAL(OUString(u"Office Theme"), pTheme->GetName());
diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx
index 589ca7e8cc17..9424e016ab72 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -151,7 +151,7 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet)
pDocument->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme().get();
if (pTheme)
{
pTheme->SetColorSet(std::make_unique<model::ColorSet>(rColorSet));
@@ -159,7 +159,7 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet)
else
{
pPage->getSdrPageProperties().SetTheme(std::make_unique<model::Theme>("Office"));
- pTheme = pPage->getSdrPageProperties().GetTheme();
+ pTheme = pPage->getSdrPageProperties().GetTheme().get();
pTheme->SetColorSet(std::make_unique<model::ColorSet>(rColorSet));
}
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index af4502e7449f..90536712cb7e 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -443,7 +443,7 @@ uno::Any SwFmDrawPage::getPropertyValue(const OUString& rPropertyName)
{
css::uno::Reference<css::util::XTheme> xTheme;
- auto* pTheme = GetSdrPage()->getSdrPageProperties().GetTheme();
+ auto const& pTheme = GetSdrPage()->getSdrPageProperties().GetTheme();
if (pTheme)
xTheme = new UnoTheme(*pTheme);
aAny <<= xTheme;
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
index 4392158ebccd..b219071a77e5 100644
--- a/sw/source/filter/xml/xmlfmte.cxx
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -205,7 +205,7 @@ void SwXMLExport::ExportThemeElement(const uno::Reference<drawing::XDrawPage>& x
if (!pPage)
return;
- auto* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (!pTheme)
return;
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 84aacfa1d47d..cd1e3dcde925 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1585,7 +1585,7 @@ std::vector<Color> SwDocShell::GetThemeColors()
SdrPage* pPage = m_xDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
if (!pPage)
return {};
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (!pTheme)
return {};
return pTheme->GetColors();
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 0006596a87fb..5e5d07565b5d 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -2217,7 +2217,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
if (pPage)
{
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
bDisable = false;
}
@@ -3058,11 +3058,11 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
if (pDocumentShell)
{
SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
{
std::shared_ptr<svx::IThemeColorChanger> pChanger(new sw::ThemeColorChanger(pDocumentShell));
- auto pDialog = std::make_shared<svx::ThemeDialog>(pMDI, pTheme, pChanger);
+ auto pDialog = std::make_shared<svx::ThemeDialog>(pMDI, pTheme.get(), pChanger);
weld::DialogController::runAsync(pDialog, [](int) {});
}
}
diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx
index 6a2647ebbbee..2dabadbba545 100644
--- a/sw/source/uibase/sidebar/ThemePanel.cxx
+++ b/sw/source/uibase/sidebar/ThemePanel.cxx
@@ -47,28 +47,15 @@ ThemePanel::ThemePanel(weld::Widget* pParent)
mxApplyButton->connect_clicked(LINK(this, ThemePanel, ClickHdl));
mxValueSetColors->SetDoubleClickHdl(LINK(this, ThemePanel, DoubleClickValueSetHdl));
- maColorSets.init();
-
- SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
- SwDoc* pDocument = pDocSh->GetDoc();
- if (pDocument)
- {
- SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
- model::Theme* pTheme = pPage->getSdrPageProperties().GetTheme();
- if (pTheme)
- maColorSets.insert(*pTheme->GetColorSet());
- }
-
- const std::vector<model::ColorSet>& aColorSets = maColorSets.getColorSets();
- for (size_t i = 0; i < aColorSets.size(); ++i)
+ auto const& rColorSets = svx::ColorSets::get();
+ for (model::ColorSet const& rColorSet : rColorSets.getColorSetVector())
{
- const model::ColorSet& rColorSet = aColorSets[i];
mxValueSetColors->insert(rColorSet);
}
mxValueSetColors->SetOptimalSize();
- if (!aColorSets.empty())
+ if (!rColorSets.getColorSetVector().empty())
mxValueSetColors->SelectItem(1); // ItemId 1, position 0
}
@@ -106,7 +93,8 @@ void ThemePanel::DoubleClickHdl()
return;
sal_uInt32 nIndex = nItemId - 1;
- model::ColorSet const& rColorSet = maColorSets.getColorSet(nIndex);
+ auto const& rColorSets = svx::ColorSets::get();
+ model::ColorSet const& rColorSet = rColorSets.getColorSet(nIndex);
ThemeColorChanger aChanger(pDocSh);
aChanger.apply(rColorSet);
diff --git a/sw/source/uibase/sidebar/ThemePanel.hxx b/sw/source/uibase/sidebar/ThemePanel.hxx
index 848d022ee0c6..12285286f546 100644
--- a/sw/source/uibase/sidebar/ThemePanel.hxx
+++ b/sw/source/uibase/sidebar/ThemePanel.hxx
@@ -43,8 +43,6 @@ private:
std::unique_ptr<weld::CustomWeld> mxValueSetColorsWin;
std::unique_ptr<weld::Button> mxApplyButton;
- svx::ColorSets maColorSets;
-
DECL_LINK(ClickHdl, weld::Button&, void);
DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
DECL_LINK(DoubleClickValueSetHdl, ValueSet*, void);