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-02-17 05:23:19 +0000
commitb09436929a8a2c8671939fac7b8b0c23cc5d3967 (patch)
tree09412371872a5365c30d55a362f51988367c4420 /docmodel
parente53463191c851e81fd0798718c03e5ec7f56f2f5 (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> (cherry picked from commit 312f83bcf52d2f681eb9fa1bbdbb98bfd063a3b4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146447 Tested-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: */