summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-02-25 19:12:23 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-04-08 07:56:19 +0200
commit4f347ebabad6355014889f0a81b107dc774590fe (patch)
tree377e010ec06cf3aed7caf5d04cddf28518fbc676
parentad5756f0529a80fbb537979bcfd9de7a83a69805 (diff)
use shared_ptr for model::Theme instead of unique_ptr
Also change other cases to use the shared_ptr so there is no need to do copies and replace some of docmodel/theme/Theme.hxximports with forward declarations. Change-Id: I4588cb25e05e5f3e535011fffb68a8075b05aecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147691 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--docmodel/source/uno/UnoTheme.cxx9
-rw-r--r--include/docmodel/uno/UnoTheme.hxx17
-rw-r--r--include/oox/drawingml/theme.hxx2
-rw-r--r--include/oox/export/ThemeExport.hxx7
-rw-r--r--include/svx/dialog/ThemeDialog.hxx6
-rw-r--r--include/svx/svdmodel.hxx4
-rw-r--r--include/svx/svdpage.hxx8
-rw-r--r--oox/qa/unit/drawingml.cxx9
-rw-r--r--oox/source/drawingml/shape.cxx1
-rw-r--r--oox/source/drawingml/theme.cxx9
-rw-r--r--oox/source/export/ThemeExport.cxx1
-rw-r--r--sd/qa/filter/eppt/eppt.cxx7
-rw-r--r--sd/qa/unit/uiimpress.cxx7
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx1
-rw-r--r--sd/source/ui/docshell/docshell.cxx1
-rw-r--r--sd/source/ui/func/fuconstr.cxx1
-rw-r--r--sd/source/ui/func/fupage.cxx5
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx5
-rw-r--r--sd/source/ui/unoidl/unopage.cxx16
-rw-r--r--svx/source/svdraw/svdmodel.cxx8
-rw-r--r--svx/source/svdraw/svdpage.cxx7
-rw-r--r--sw/qa/core/theme/ThemeTest.cxx1
-rw-r--r--sw/source/core/model/ThemeColorChanger.cxx1
-rw-r--r--sw/source/core/unocore/unodraw.cxx7
-rw-r--r--xmloff/inc/XMLThemeContext.hxx8
-rw-r--r--xmloff/qa/unit/draw.cxx16
-rw-r--r--xmloff/qa/unit/text.cxx7
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx9
-rw-r--r--xmloff/source/style/XMLThemeContext.cxx8
29 files changed, 111 insertions, 77 deletions
diff --git a/docmodel/source/uno/UnoTheme.cxx b/docmodel/source/uno/UnoTheme.cxx
index 80d2735be47b..30d3f827fea2 100644
--- a/docmodel/source/uno/UnoTheme.cxx
+++ b/docmodel/source/uno/UnoTheme.cxx
@@ -13,15 +13,16 @@
#include <cppuhelper/queryinterface.hxx>
#include <o3tl/enumrange.hxx>
#include <comphelper/sequence.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace css;
-OUString UnoTheme::getName() { return maTheme.GetName(); }
+OUString UnoTheme::getName() { return mpTheme->GetName(); }
css::uno::Sequence<sal_Int32> UnoTheme::getColorSet()
{
std::vector<sal_Int32> aColorScheme(12);
- auto* pColorSet = maTheme.GetColorSet();
+ auto* pColorSet = mpTheme->GetColorSet();
if (pColorSet)
{
size_t i = 0;
@@ -40,9 +41,9 @@ css::uno::Sequence<sal_Int32> UnoTheme::getColorSet()
namespace model::theme
{
-uno::Reference<util::XTheme> createXTheme(model::Theme const& rTheme)
+uno::Reference<util::XTheme> createXTheme(std::shared_ptr<model::Theme> const& pTheme)
{
- return new UnoTheme(rTheme);
+ return new UnoTheme(pTheme);
}
} // end model::theme
diff --git a/include/docmodel/uno/UnoTheme.hxx b/include/docmodel/uno/UnoTheme.hxx
index f1abc4ccaede..4ca033b8e9c4 100644
--- a/include/docmodel/uno/UnoTheme.hxx
+++ b/include/docmodel/uno/UnoTheme.hxx
@@ -19,20 +19,24 @@
#include <utility>
#include <docmodel/dllapi.h>
-#include <docmodel/theme/Theme.hxx>
+
+namespace model
+{
+class Theme;
+}
class DOCMODEL_DLLPUBLIC UnoTheme final : public cppu::WeakImplHelper<css::util::XTheme>
{
private:
- model::Theme maTheme;
+ std::shared_ptr<model::Theme> mpTheme;
public:
- UnoTheme(model::Theme const& rTheme)
- : maTheme(rTheme)
+ UnoTheme(std::shared_ptr<model::Theme> const& pTheme)
+ : mpTheme(pTheme)
{
}
- model::Theme const& getTheme() const { return maTheme; }
+ std::shared_ptr<model::Theme> const& getTheme() const { return mpTheme; }
// XTheme
OUString SAL_CALL getName() override;
@@ -41,6 +45,7 @@ public:
namespace model::theme
{
-DOCMODEL_DLLPUBLIC css::uno::Reference<css::util::XTheme> createXTheme(model::Theme const& rTheme);
+DOCMODEL_DLLPUBLIC css::uno::Reference<css::util::XTheme>
+createXTheme(std::shared_ptr<model::Theme> const& pTheme);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx
index a779472b5331..c2408ec1c015 100644
--- a/include/oox/drawingml/theme.hxx
+++ b/include/oox/drawingml/theme.hxx
@@ -107,7 +107,7 @@ public:
const css::uno::Reference<css::xml::dom::XDocument>& getFragment() const { return mxFragment; }
void setFragment( const css::uno::Reference< css::xml::dom::XDocument>& xRef ) { mxFragment=xRef; }
- std::unique_ptr<model::Theme> createSvxTheme() const;
+ std::shared_ptr<model::Theme> createSvxTheme() const;
void addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage) const;
private:
diff --git a/include/oox/export/ThemeExport.hxx b/include/oox/export/ThemeExport.hxx
index 69f048afbaa0..1889709ab352 100644
--- a/include/oox/export/ThemeExport.hxx
+++ b/include/oox/export/ThemeExport.hxx
@@ -12,7 +12,12 @@
#include <sal/config.h>
#include <oox/dllapi.h>
#include <oox/core/xmlfilterbase.hxx>
-#include <docmodel/theme/Theme.hxx>
+
+namespace model
+{
+class Theme;
+class FontScheme;
+}
namespace oox
{
diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx
index 5d3fdc70f250..aa068f9528c1 100644
--- a/include/svx/dialog/ThemeDialog.hxx
+++ b/include/svx/dialog/ThemeDialog.hxx
@@ -11,11 +11,15 @@
#include <svx/svxdllapi.h>
#include <vcl/weld.hxx>
-#include <docmodel/theme/Theme.hxx>
#include <svx/svdpage.hxx>
#include <svx/theme/IThemeColorChanger.hxx>
#include <svx/dialog/ThemeColorValueSet.hxx>
+namespace model
+{
+class Theme;
+}
+
namespace svx
{
class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index fe216d569919..69beb4646175 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);
- std::unique_ptr<model::Theme> const& getTheme() const;
+ void setTheme(std::shared_ptr<model::Theme> const& pTheme);
+ std::shared_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 fde15ccedcd9..7443c408814d 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -30,7 +30,6 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <svx/svdobj.hxx>
-#include <docmodel/theme/Theme.hxx>
#include <unotools/weakref.hxx>
#include <memory>
#include <optional>
@@ -39,6 +38,7 @@
// predefines
+namespace model { class Theme; }
namespace reportdesign { class OSection; }
namespace sdr::contact { class ViewContact; }
class SdrPage;
@@ -317,7 +317,7 @@ private:
// data
SdrPage* mpSdrPage;
SfxStyleSheet* mpStyleSheet;
- std::unique_ptr<model::Theme> mpTheme;
+ std::shared_ptr<model::Theme> mpTheme;
SfxItemSet maProperties;
// internal helpers
@@ -346,8 +346,8 @@ public:
void SetStyleSheet(SfxStyleSheet* pStyleSheet);
SfxStyleSheet* GetStyleSheet() const { return mpStyleSheet;}
- void SetTheme(std::unique_ptr<model::Theme> pTheme);
- std::unique_ptr<model::Theme> const& GetTheme() const;
+ void SetTheme(std::shared_ptr<model::Theme> const& pTheme);
+ std::shared_ptr<model::Theme> const& GetTheme() const;
void dumpAsXml(xmlTextWriterPtr pWriter) const;
};
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index 994006e76113..c468fd126584 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -32,6 +32,7 @@
#include <docmodel/uno/UnoThemeColor.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <comphelper/sequenceashashmap.hxx>
@@ -383,13 +384,13 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
CPPUNIT_ASSERT(xTheme.is());
auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
CPPUNIT_ASSERT(pUnoTheme);
- auto const& rTheme = pUnoTheme->getTheme();
+ auto pTheme = pUnoTheme->getTheme();
- CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), rTheme.GetName());
- CPPUNIT_ASSERT_EQUAL(OUString("Office"), rTheme.GetColorSet()->getName());
+ CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), pTheme->GetName());
+ CPPUNIT_ASSERT_EQUAL(OUString("Office"), pTheme->GetColorSet()->getName());
CPPUNIT_ASSERT_EQUAL(Color(0x954F72),
- rTheme.GetColorSet()->getColor(model::ThemeColorType::FollowedHyperlink));
+ pTheme->GetColorSet()->getColor(model::ThemeColorType::FollowedHyperlink));
// Check the reference to that theme:
uno::Reference<drawing::XShapes> xDrawPageShapes(xDrawPage, uno::UNO_QUERY);
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index e3923c1b647d..41d2befad1a7 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -110,6 +110,7 @@
#include <sal/log.hxx>
#include <svx/sdtaitm.hxx>
#include <oox/drawingml/diagram/diagram.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx
index f4ebe63e00e2..b108d8106322 100644
--- a/oox/source/drawingml/theme.cxx
+++ b/oox/source/drawingml/theme.cxx
@@ -109,9 +109,10 @@ const TextFont* Theme::resolveFont( std::u16string_view rName ) const
return nullptr;
}
-std::unique_ptr<model::Theme> Theme::createSvxTheme() const
+std::shared_ptr<model::Theme> Theme::createSvxTheme() const
{
- auto pTheme = std::make_unique<model::Theme>(maThemeName);
+ auto pTheme = std::make_shared<model::Theme>(maThemeName);
+
auto pColorSet = std::make_unique<model::ColorSet>(maClrScheme.GetName());
maClrScheme.fill(*pColorSet);
pTheme->SetColorSet(std::move(pColorSet));
@@ -184,9 +185,7 @@ void Theme::addTheme(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPa
if (!pPage)
return;
- std::unique_ptr<model::Theme> pTheme = createSvxTheme();
-
- pPage->getSdrPageProperties().SetTheme(std::move(pTheme));
+ pPage->getSdrPageProperties().SetTheme(createSvxTheme());
}
} // namespace oox::drawingml
diff --git a/oox/source/export/ThemeExport.cxx b/oox/source/export/ThemeExport.cxx
index 6733a70b2057..3abc2cb1adb6 100644
--- a/oox/source/export/ThemeExport.cxx
+++ b/oox/source/export/ThemeExport.cxx
@@ -13,6 +13,7 @@
#include <oox/token/properties.hxx>
#include <oox/token/tokens.hxx>
#include <oox/export/utils.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <sax/fshelper.hxx>
#include <sax/fastattribs.hxx>
#include <unordered_map>
diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx
index 738539c5eff7..6c73ccec5c2b 100644
--- a/sd/qa/filter/eppt/eppt.cxx
+++ b/sd/qa/filter/eppt/eppt.cxx
@@ -16,6 +16,7 @@
#include <test/xmldocptr.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace ::com::sun::star;
@@ -61,7 +62,7 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeExport)
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
- model::Theme aTheme("mytheme");
+ auto pTheme = std::make_shared<model::Theme>("mytheme");
std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("mycolorscheme"));
pColorSet->add(model::ThemeColorType::Dark1, 0x1);
pColorSet->add(model::ThemeColorType::Light1, 0x2);
@@ -75,9 +76,9 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeExport)
pColorSet->add(model::ThemeColorType::Accent6, 0xa);
pColorSet->add(model::ThemeColorType::Hyperlink, 0xb);
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xc);
- aTheme.SetColorSet(std::move(pColorSet));
+ pTheme->SetColorSet(std::move(pColorSet));
- xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(aTheme)));
+ xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(pTheme)));
// When exporting to PPTX:
save("Impress Office Open XML");
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index d9f71fcbb7a1..9c295a531b8c 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -46,6 +46,7 @@
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <drawdoc.hxx>
#include <DrawDocShell.hxx>
@@ -1151,7 +1152,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testThemeShapeInsert)
uno::Reference<beans::XPropertySet> xMasterPage(xMasterPageTarget->getMasterPage(),
uno::UNO_QUERY);
- model::Theme aTheme("mytheme");
+ auto pTheme = std::make_shared<model::Theme>("mytheme");
std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("mycolorscheme"));
pColorSet->add(model::ThemeColorType::Dark1, 0x0);
pColorSet->add(model::ThemeColorType::Light1, 0x1);
@@ -1165,9 +1166,9 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testThemeShapeInsert)
pColorSet->add(model::ThemeColorType::Accent6, 0x9);
pColorSet->add(model::ThemeColorType::Hyperlink, 0xa);
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb);
- aTheme.SetColorSet(std::move(pColorSet));
+ pTheme->SetColorSet(std::move(pColorSet));
- xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(aTheme)));
+ xMasterPage->setPropertyValue("Theme", uno::Any(model::theme::createXTheme(pTheme)));
// When inserting a shape:
uno::Sequence<beans::PropertyValue> aArgs = {
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index f857f10bec7f..dd555514650a 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -56,6 +56,7 @@
#include <comphelper/diagnose_ex.hxx>
#include <oox/export/utils.hxx>
+#include <docmodel/theme/Theme.hxx>
#include "pptx-animations.hxx"
#include "../ppt/pptanimations.hxx"
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index 3aacb189f826..fd564bcc8f4a 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -61,6 +61,7 @@
#include <comphelper/lok.hxx>
#include <DrawViewShell.hxx>
#include <sdpage.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace sd;
#define ShellClass_DrawDocShell
diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx
index eee7094a78f8..3f3085b60d20 100644
--- a/sd/source/ui/func/fuconstr.cxx
+++ b/sd/source/ui/func/fuconstr.cxx
@@ -29,6 +29,7 @@
#include <svx/xflclit.hxx>
#include <svx/xlineit0.hxx>
#include <svx/xlnclit.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <app.hrc>
#include <strings.hrc>
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 7416916f01e7..27a794124b0c 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -48,6 +48,7 @@
#include <editeng/pbinitem.hxx>
#include <sfx2/opengrf.hxx>
#include <sal/log.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <strings.hrc>
#include <sdpage.hxx>
@@ -573,8 +574,8 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
auto it = pGrabBag->GetGrabBag().find("Theme");
if (it != pGrabBag->GetGrabBag().end())
{
- std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(it->second);
- pMasterPage->getSdrPageProperties().SetTheme(std::move(pTheme));
+ std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(it->second);
+ pMasterPage->getSdrPageProperties().SetTheme(pTheme);
}
else
{
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index ca741e9bb53f..e5a231d4d405 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -131,6 +131,7 @@
#include <tools/json_writer.hxx>
#include <tools/UnitConversion.hxx>
#include <svx/ColorSets.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <app.hrc>
@@ -1283,8 +1284,8 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam
case WID_MODEL_THEME:
{
SdrModel& rModel = getSdrModelFromUnoModel();
- std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
- rModel.setTheme(std::move(pTheme));
+ std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
+ rModel.setTheme(pTheme);
}
break;
default:
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 65008effaa12..87508052da87 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -76,6 +76,7 @@
#include <tools/debug.hxx>
#include <tools/stream.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <o3tl/string_view.hxx>
using ::com::sun::star::animations::XAnimationNode;
@@ -984,8 +985,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
if (aValue >>= xTheme)
{
auto& rUnoTheme = dynamic_cast<UnoTheme&>(*xTheme);
- std::unique_ptr<model::Theme> pTheme(new model::Theme(rUnoTheme.getTheme()));
- pPage->getSdrPageProperties().SetTheme(std::move(pTheme));
+ pPage->getSdrPageProperties().SetTheme(rUnoTheme.getTheme());
}
break;
}
@@ -993,8 +993,8 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
case WID_PAGE_THEME_UNO_REPRESENTATION:
{
SdrPage* pPage = GetPage();
- std::unique_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
- pPage->getSdrPageProperties().SetTheme(std::move(pTheme));
+ std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
+ pPage->getSdrPageProperties().SetTheme(pTheme);
break;
}
@@ -1316,9 +1316,9 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
{
SdrPage* pPage = GetPage();
css::uno::Reference<css::util::XTheme> xTheme;
- auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
- xTheme = new UnoTheme(*pTheme);
+ xTheme = model::theme::createXTheme(pTheme);
aAny <<= xTheme;
break;
}
@@ -1326,11 +1326,9 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
case WID_PAGE_THEME_UNO_REPRESENTATION:
{
SdrPage* pPage = GetPage();
- auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
+ auto pTheme = pPage->getSdrPageProperties().GetTheme();
if (pTheme)
- {
pTheme->ToAny(aAny);
- }
else
{
beans::PropertyValues aValues;
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 6f243113c0e1..c3716a4a3efa 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -88,7 +88,7 @@ struct SdrModelImpl
bool mbLegacySingleLineFontwork; // tdf#148000 compatibility flag
bool mbConnectorUseSnapRect; // tdf#149756 compatibility flag
bool mbIgnoreBreakAfterMultilineField; ///< tdf#148966 compatibility flag
- std::unique_ptr<model::Theme> mpTheme;
+ std::shared_ptr<model::Theme> mpTheme;
SdrModelImpl()
: mpUndoManager(nullptr)
@@ -1563,12 +1563,12 @@ void SdrModel::SetStarDrawPreviewMode(bool bPreview)
}
}
-void SdrModel::setTheme(std::unique_ptr<model::Theme> pTheme)
+void SdrModel::setTheme(std::shared_ptr<model::Theme> const& pTheme)
{
- mpImpl->mpTheme = std::move(pTheme);
+ mpImpl->mpTheme = pTheme;
}
-std::unique_ptr<model::Theme> const& SdrModel::getTheme() const
+std::shared_ptr<model::Theme> const& SdrModel::getTheme() const
{
return mpImpl->mpTheme;
}
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 280e5d2f8c70..235fc58da508 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -54,6 +54,7 @@
#include <svl/hint.hxx>
#include <rtl/strbuf.hxx>
#include <libxml/xmlwriter.h>
+#include <docmodel/theme/Theme.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -1300,9 +1301,9 @@ void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
ImpPageChange(*mpSdrPage);
}
-void SdrPageProperties::SetTheme(std::unique_ptr<model::Theme> pTheme)
+void SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme)
{
- mpTheme = std::move(pTheme);
+ mpTheme = pTheme;
if (mpTheme && mpTheme->GetColorSet() && mpSdrPage->IsMasterPage())
{
@@ -1322,7 +1323,7 @@ void SdrPageProperties::SetTheme(std::unique_ptr<model::Theme> pTheme)
}
}
-std::unique_ptr<model::Theme> const& SdrPageProperties::GetTheme() const
+std::shared_ptr<model::Theme> const& SdrPageProperties::GetTheme() const
{
return mpTheme;
}
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index 5c95de1e7c38..f13063bc30ac 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -17,6 +17,7 @@
#include <IDocumentDrawModelAccess.hxx>
#include <svx/svdpage.hxx>
#include <docmodel/uno/UnoThemeColor.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace css;
diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx
index 9424e016ab72..dd198c14723e 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -26,6 +26,7 @@
#include <svx/svdpage.hxx>
#include <svx/svditer.hxx>
#include <docmodel/uno/UnoThemeColor.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <editeng/unoprnms.hxx>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 90536712cb7e..7337ce297895 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -406,8 +406,7 @@ void SwFmDrawPage::setPropertyValue(const OUString& rPropertyName, const uno::An
if (aValue >>= xTheme)
{
auto& rUnoTheme = dynamic_cast<UnoTheme&>(*xTheme);
- std::unique_ptr<model::Theme> pTheme(new model::Theme(rUnoTheme.getTheme()));
- pPage->getSdrPageProperties().SetTheme(std::move(pTheme));
+ pPage->getSdrPageProperties().SetTheme(rUnoTheme.getTheme());
}
}
break;
@@ -443,9 +442,9 @@ uno::Any SwFmDrawPage::getPropertyValue(const OUString& rPropertyName)
{
css::uno::Reference<css::util::XTheme> xTheme;
- auto const& pTheme = GetSdrPage()->getSdrPageProperties().GetTheme();
+ auto pTheme = GetSdrPage()->getSdrPageProperties().GetTheme();
if (pTheme)
- xTheme = new UnoTheme(*pTheme);
+ xTheme = model::theme::createXTheme(pTheme);
aAny <<= xTheme;
}
break;
diff --git a/xmloff/inc/XMLThemeContext.hxx b/xmloff/inc/XMLThemeContext.hxx
index 50889a0ddf98..b85932d4cb41 100644
--- a/xmloff/inc/XMLThemeContext.hxx
+++ b/xmloff/inc/XMLThemeContext.hxx
@@ -14,14 +14,18 @@
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
-#include <docmodel/theme/Theme.hxx>
#include <docmodel/theme/ColorSet.hxx>
+namespace model
+{
+class Theme;
+}
+
/// Imports the theme
class XMLThemeContext : public SvXMLImportContext
{
css::uno::Reference<css::drawing::XDrawPage> m_xPage;
- model::Theme maTheme;
+ std::shared_ptr<model::Theme> mpTheme;
public:
XMLThemeContext(SvXMLImport& rImport,
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index 74a62edbd35f..ba68685d094a 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -31,6 +31,7 @@
#include <svx/svdomedia.hxx>
#include <docmodel/uno/UnoThemeColor.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace ::com::sun::star;
@@ -126,7 +127,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport)
xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY);
- model::Theme aTheme("mytheme");
+ auto pTheme = std::make_shared<model::Theme>("mytheme");
std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("mycolorscheme"));
pColorSet->add(model::ThemeColorType::Dark1, 0x0);
pColorSet->add(model::ThemeColorType::Light1, 0x1);
@@ -140,9 +141,9 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport)
pColorSet->add(model::ThemeColorType::Accent6, 0x9);
pColorSet->add(model::ThemeColorType::Hyperlink, 0xa);
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xb);
- aTheme.SetColorSet(std::move(pColorSet));
+ pTheme->SetColorSet(std::move(pColorSet));
- uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(aTheme);
+ uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme);
xMasterPage->setPropertyValue("Theme", uno::Any(xTheme));
// Export to ODP:
@@ -219,13 +220,14 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport)
CPPUNIT_ASSERT(xTheme.is());
auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get());
CPPUNIT_ASSERT(pUnoTheme);
- auto const& rTheme = pUnoTheme->getTheme();
+ auto pTheme = pUnoTheme->getTheme();
+ CPPUNIT_ASSERT(pTheme);
- CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), rTheme.GetName());
- CPPUNIT_ASSERT_EQUAL(OUString("Office"), rTheme.GetColorSet()->getName());
+ CPPUNIT_ASSERT_EQUAL(OUString("Office Theme"), pTheme->GetName());
+ CPPUNIT_ASSERT_EQUAL(OUString("Office"), pTheme->GetColorSet()->getName());
CPPUNIT_ASSERT_EQUAL(Color(0x954F72),
- rTheme.GetColorSet()->getColor(model::ThemeColorType::FollowedHyperlink));
+ pTheme->GetColorSet()->getColor(model::ThemeColorType::FollowedHyperlink));
}
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 5d3a9cf4ac99..532d97774e2f 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -25,6 +25,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <unotools/tempfile.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace ::com::sun::star;
@@ -959,7 +960,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testThemeExport)
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xPageProps(xDrawPage, uno::UNO_QUERY);
- model::Theme aTheme("My Theme");
+ auto pTheme = std::make_shared<model::Theme>("My Theme");
std::unique_ptr<model::ColorSet> pColorSet(new model::ColorSet("My Color Scheme"));
pColorSet->add(model::ThemeColorType::Dark1, 0x101010);
pColorSet->add(model::ThemeColorType::Light1, 0x202020);
@@ -973,9 +974,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testThemeExport)
pColorSet->add(model::ThemeColorType::Accent6, 0xa0a0a0);
pColorSet->add(model::ThemeColorType::Hyperlink, 0xb0b0b0);
pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xc0c0c0);
- aTheme.SetColorSet(std::move(pColorSet));
+ pTheme->SetColorSet(std::move(pColorSet));
- uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(aTheme);
+ uno::Reference<util::XTheme> xTheme = model::theme::createXTheme(pTheme);
xPageProps->setPropertyValue("Theme", uno::Any(xTheme));
// Export to ODT:
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index bc7d5e6ad35d..c237fe12470b 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -74,6 +74,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/util/Color.hpp>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
#include <o3tl/enumrange.hxx>
using namespace ::com::sun::star;
@@ -2383,13 +2384,13 @@ void SdXMLExport::ExportThemeElement(const uno::Reference<drawing::XDrawPage>& x
if (!pUnoTheme)
return;
- auto const& rTheme = pUnoTheme->getTheme();
+ auto pTheme = pUnoTheme->getTheme();
- if (!rTheme.GetName().isEmpty())
- AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, rTheme.GetName());
+ if (!pTheme->GetName().isEmpty())
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pTheme->GetName());
SvXMLElementExport aTheme(*this, XML_NAMESPACE_LO_EXT, XML_THEME, true, true);
- auto* pColorSet = rTheme.GetColorSet();
+ auto* pColorSet = pTheme->GetColorSet();
if (!pColorSet->getName().isEmpty())
AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pColorSet->getName());
SvXMLElementExport aColorTable(*this, XML_NAMESPACE_LO_EXT, XML_COLOR_TABLE, true, true);
diff --git a/xmloff/source/style/XMLThemeContext.cxx b/xmloff/source/style/XMLThemeContext.cxx
index 8a9a5cdbc558..e35aed99c46f 100644
--- a/xmloff/source/style/XMLThemeContext.cxx
+++ b/xmloff/source/style/XMLThemeContext.cxx
@@ -26,6 +26,7 @@
#include <comphelper/sequence.hxx>
#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
using namespace css;
using namespace xmloff::token;
@@ -35,6 +36,7 @@ XMLThemeContext::XMLThemeContext(SvXMLImport& rImport,
css::uno::Reference<css::drawing::XDrawPage> const& xPage)
: SvXMLImportContext(rImport)
, m_xPage(xPage)
+ , mpTheme(new model::Theme)
{
for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList))
{
@@ -43,7 +45,7 @@ XMLThemeContext::XMLThemeContext(SvXMLImport& rImport,
case XML_ELEMENT(LO_EXT, XML_NAME):
{
OUString aName = rAttribute.toString();
- maTheme.SetName(aName);
+ mpTheme->SetName(aName);
break;
}
}
@@ -53,7 +55,7 @@ XMLThemeContext::XMLThemeContext(SvXMLImport& rImport,
XMLThemeContext::~XMLThemeContext()
{
uno::Reference<beans::XPropertySet> xPropertySet(m_xPage, uno::UNO_QUERY);
- uno::Reference<util::XTheme> xTheme(new UnoTheme(maTheme));
+ auto xTheme = model::theme::createXTheme(mpTheme);
xPropertySet->setPropertyValue("Theme", uno::Any(xTheme));
}
@@ -62,7 +64,7 @@ uno::Reference<xml::sax::XFastContextHandler> SAL_CALL XMLThemeContext::createFa
{
if (nElement == XML_ELEMENT(LO_EXT, XML_COLOR_TABLE))
{
- return new XMLColorTableContext(GetImport(), xAttribs, maTheme);
+ return new XMLColorTableContext(GetImport(), xAttribs, *mpTheme);
}
return nullptr;