summaryrefslogtreecommitdiff
path: root/docmodel
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-01-27 12:13:29 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-01-28 12:52:52 +0000
commit312f83bcf52d2f681eb9fa1bbdbb98bfd063a3b4 (patch)
treeb488bdd6024b0ba6f8f2641781b4fcad69d5edb8 /docmodel
parent10c340c2b59dd677d6f598901506b08ff2cbd49c (diff)
introduce XTheme and UnoTheme implementation
Needed to transprt model::Theme around using throught UNO API as xmloff can't access SdrPage directly. Change-Id: I5931e42352186d62e7f09b112d8e8c9e4fb79440 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146224 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'docmodel')
-rw-r--r--docmodel/Library_docmodel.mk1
-rw-r--r--docmodel/source/theme/Theme.cxx7
-rw-r--r--docmodel/source/uno/UnoTheme.cxx50
3 files changed, 58 insertions, 0 deletions
diff --git a/docmodel/Library_docmodel.mk b/docmodel/Library_docmodel.mk
index 7974027a7a9e..8db7d0fa6f93 100644
--- a/docmodel/Library_docmodel.mk
+++ b/docmodel/Library_docmodel.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_Library_Library,docmodel))
$(eval $(call gb_Library_add_exception_objects,docmodel,\
docmodel/source/uno/UnoThemeColor \
+ docmodel/source/uno/UnoTheme \
docmodel/source/theme/ColorSet \
docmodel/source/theme/Theme \
))
diff --git a/docmodel/source/theme/Theme.cxx b/docmodel/source/theme/Theme.cxx
index 0f8ff8002870..5f755b0774a3 100644
--- a/docmodel/source/theme/Theme.cxx
+++ b/docmodel/source/theme/Theme.cxx
@@ -29,6 +29,13 @@ Theme::Theme(OUString const& rName)
{
}
+Theme::Theme(Theme const& rTheme)
+ : maName(rTheme.maName)
+ , mpColorSet(new ColorSet(*rTheme.GetColorSet()))
+ , maFontScheme(rTheme.maFontScheme)
+{
+}
+
void Theme::SetColorSet(std::unique_ptr<model::ColorSet> pColorSet)
{
mpColorSet = std::move(pColorSet);
diff --git a/docmodel/source/uno/UnoTheme.cxx b/docmodel/source/uno/UnoTheme.cxx
new file mode 100644
index 000000000000..80d2735be47b
--- /dev/null
+++ b/docmodel/source/uno/UnoTheme.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/ThemeColorType.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <o3tl/enumrange.hxx>
+#include <comphelper/sequence.hxx>
+
+using namespace css;
+
+OUString UnoTheme::getName() { return maTheme.GetName(); }
+
+css::uno::Sequence<sal_Int32> UnoTheme::getColorSet()
+{
+ std::vector<sal_Int32> aColorScheme(12);
+ auto* pColorSet = maTheme.GetColorSet();
+ if (pColorSet)
+ {
+ size_t i = 0;
+
+ for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>())
+ {
+ if (eThemeColorType == model::ThemeColorType::Unknown)
+ continue;
+ Color aColor = pColorSet->getColor(eThemeColorType);
+ aColorScheme[i] = sal_Int32(aColor);
+ i++;
+ }
+ }
+ return comphelper::containerToSequence(aColorScheme);
+}
+
+namespace model::theme
+{
+uno::Reference<util::XTheme> createXTheme(model::Theme const& rTheme)
+{
+ return new UnoTheme(rTheme);
+}
+
+} // end model::theme
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */