summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-06-30 01:39:50 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-07-04 08:40:20 +0200
commit20dbfa10d851b9df67fab561c3b86cba4f55cc8a (patch)
treef928379317ae361aaefe2efacc28900fb0d49b29 /include
parent80569dc996a9a814ad7c2e729f30443debdbc6fe (diff)
sc: OOXML export of theme colors for text and background
Change-Id: Ifd0d8184c9210caa5ca099767baa5dbbf8783f36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153785 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/docmodel/color/ComplexColor.hxx5
-rw-r--r--include/oox/export/ColorExportUtils.hxx55
2 files changed, 60 insertions, 0 deletions
diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx
index 4952d91ac217..e9597b15186b 100644
--- a/include/docmodel/color/ComplexColor.hxx
+++ b/include/docmodel/color/ComplexColor.hxx
@@ -100,6 +100,11 @@ public:
ThemeColorType getSchemeType() const { return meSchemeType; }
+ bool isValidSchemeType() const
+ {
+ return meType == model::ColorType::Scheme && meSchemeType != ThemeColorType::Unknown;
+ }
+
Color getRGBColor() const { return Color(mnComponent1, mnComponent2, mnComponent3); }
std::vector<Transformation> const& getTransformations() const { return maTransformations; }
diff --git a/include/oox/export/ColorExportUtils.hxx b/include/oox/export/ColorExportUtils.hxx
new file mode 100644
index 000000000000..63716a10839d
--- /dev/null
+++ b/include/oox/export/ColorExportUtils.hxx
@@ -0,0 +1,55 @@
+/* -*- 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 <sal/config.h>
+
+#include <docmodel/color/ComplexColor.hxx>
+
+namespace oox
+{
+static double convertColorTransformsToTintOrShade(model::ComplexColor const& rComplexColor)
+{
+ sal_Int16 nLumMod = 10'000;
+ sal_Int16 nLumOff = 0;
+
+ for (auto const& rTransform : rComplexColor.getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumMod)
+ nLumMod = rTransform.mnValue;
+ if (rTransform.meType == model::TransformationType::LumOff)
+ nLumOff = rTransform.mnValue;
+ }
+
+ if (nLumMod == 10'000 && nLumOff == 0)
+ return 0.0;
+
+ double fTint = 0.0;
+
+ if (nLumOff > 0) // tint
+ fTint = double(nLumOff) / 10'000.0;
+ else
+ fTint = -double(10'000 - nLumMod) / 10'000.0;
+
+ return fTint;
+}
+
+static sal_Int32 convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType)
+{
+ if (eType == model::ThemeColorType::Unknown)
+ return -1;
+
+ constexpr std::array<sal_Int32, 12> constMap = { 1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11 };
+
+ return constMap[sal_Int32(eType)];
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */