summaryrefslogtreecommitdiff
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
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>
-rw-r--r--docmodel/Library_docmodel.mk1
-rw-r--r--docmodel/source/theme/Theme.cxx7
-rw-r--r--docmodel/source/uno/UnoTheme.cxx50
-rw-r--r--include/docmodel/theme/Theme.hxx2
-rw-r--r--include/docmodel/uno/UnoTheme.hxx46
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/util/XTheme.idl34
7 files changed, 141 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: */
diff --git a/include/docmodel/theme/Theme.hxx b/include/docmodel/theme/Theme.hxx
index 1f6a91762964..6ef239fc7578 100644
--- a/include/docmodel/theme/Theme.hxx
+++ b/include/docmodel/theme/Theme.hxx
@@ -136,6 +136,8 @@ private:
public:
Theme(OUString const& rName);
+ Theme(Theme const& rTheme);
+
void setFontScheme(FontScheme const& rFontScheme) { maFontScheme = rFontScheme; }
FontScheme const& getFontScheme() const { return maFontScheme; }
diff --git a/include/docmodel/uno/UnoTheme.hxx b/include/docmodel/uno/UnoTheme.hxx
new file mode 100644
index 000000000000..f1abc4ccaede
--- /dev/null
+++ b/include/docmodel/uno/UnoTheme.hxx
@@ -0,0 +1,46 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/servicehelper.hxx>
+
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/util/XTheme.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <utility>
+#include <docmodel/dllapi.h>
+#include <docmodel/theme/Theme.hxx>
+
+class DOCMODEL_DLLPUBLIC UnoTheme final : public cppu::WeakImplHelper<css::util::XTheme>
+{
+private:
+ model::Theme maTheme;
+
+public:
+ UnoTheme(model::Theme const& rTheme)
+ : maTheme(rTheme)
+ {
+ }
+
+ model::Theme const& getTheme() const { return maTheme; }
+
+ // XTheme
+ OUString SAL_CALL getName() override;
+ css::uno::Sequence<sal_Int32> SAL_CALL getColorSet() override;
+};
+
+namespace model::theme
+{
+DOCMODEL_DLLPUBLIC css::uno::Reference<css::util::XTheme> createXTheme(model::Theme const& rTheme);
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index bdc6f53a1087..0f8c58db702d 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4170,6 +4170,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\
XCloseBroadcaster \
XCloseListener \
XCloseable \
+ XTheme \
XThemeColor \
XDataEditor \
XDataEditorListener \
diff --git a/offapi/com/sun/star/util/XTheme.idl b/offapi/com/sun/star/util/XTheme.idl
new file mode 100644
index 000000000000..0efa1847aaed
--- /dev/null
+++ b/offapi/com/sun/star/util/XTheme.idl
@@ -0,0 +1,34 @@
+/* -*- 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/.
+ */
+
+module com { module sun { module star { module util {
+
+/** Theme interface
+
+ @since LibreOffice 7.6
+*/
+interface XTheme
+{
+ /** Get the name of the theme */
+ string getName();
+
+ /** Get the color set defined for the theme.
+
+ The color set is a sequence of 12 colors:
+ Dark 1, Light 1, Dark 2, Light 2,
+ Accent 1, Accent 2, Accent 3, Accent 4, Accent 5, Accent6,
+ Hyperlink, FollowedHyperlink
+
+ */
+ sequence<com::sun::star::util::Color> getColorSet();
+};
+
+}; }; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */