summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-09-20 19:27:09 +0200
committerTomaž Vajngerl <quikee@gmail.com>2023-01-20 07:10:52 +0000
commit93388cd7dcdf93f543274b153572dad94fc5165a (patch)
tree373d9c46038fa9892348f3b2e2296b9d61675eac /xmloff
parent9c2adfdfed56b19adf90e7ec3f0b8fbf1c819784 (diff)
sw: support for reading back theme color from OOXML
OOXML supports theme colors and tint/shade value that additionally changed the theme color. Read back which theme color + tint/shade value was applied in the resulting color and add this attributes as properties to be used by writer. In sidebar theme panel the changing the theme colors now doesn't takes this into account and changes the colors correctly. Change-Id: I3a2d49d485fd37a1611483ee0bb5e6034ac5f88e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143697 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit df9f3f3fd81d4f81ee2ff984d1e19999abea2963) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145833 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/XMLThemeColorHandler.hxx49
-rw-r--r--xmloff/inc/enummaps.hxx2
-rw-r--r--xmloff/source/draw/sdpropls.cxx3
-rw-r--r--xmloff/source/text/txtprhdl.cxx6
4 files changed, 56 insertions, 4 deletions
diff --git a/xmloff/inc/XMLThemeColorHandler.hxx b/xmloff/inc/XMLThemeColorHandler.hxx
new file mode 100644
index 000000000000..e98ef725682c
--- /dev/null
+++ b/xmloff/inc/XMLThemeColorHandler.hxx
@@ -0,0 +1,49 @@
+/* -*- 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 <xmloff/xmlprhdl.hxx>
+
+using namespace ::xmloff::token;
+
+class XMLThemeColorHandler : public XMLPropertyHandler
+{
+public:
+ bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue,
+ const SvXMLUnitConverter&) const override
+ {
+ sal_Int16 nValue;
+ bool bReturn = SvXMLUnitConverter::convertEnum(nValue, rStrImpValue, pXML_ThemeColor_Enum);
+
+ if (bReturn)
+ rValue <<= nValue;
+
+ return bReturn;
+ }
+
+ bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue,
+ const SvXMLUnitConverter&) const override
+ {
+ sal_Int16 nThemeIndex;
+ rValue >>= nThemeIndex;
+
+ if (nThemeIndex == -1) // Default
+ return false;
+
+ OUStringBuffer aOutBuffer;
+ bool bReturn = SvXMLUnitConverter::convertEnum(aOutBuffer, nThemeIndex,
+ pXML_ThemeColor_Enum, XML_NONE);
+ rStrExpValue = aOutBuffer.makeStringAndClear();
+
+ return bReturn;
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/inc/enummaps.hxx b/xmloff/inc/enummaps.hxx
index a170559af996..4d061a736967 100644
--- a/xmloff/inc/enummaps.hxx
+++ b/xmloff/inc/enummaps.hxx
@@ -19,6 +19,6 @@ template <typename EnumT> struct SvXMLEnumMapEntry;
extern SvXMLEnumMapEntry<css::drawing::FillStyle> const aXML_FillStyle_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::RectanglePoint> const aXML_RefPoint_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::BitmapMode> const aXML_BitmapMode_EnumMap[];
-extern SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[];
+extern SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[];
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index e7223409b6f0..6c8731942782 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -60,6 +60,7 @@
#include <XMLIsPercentagePropertyHandler.hxx>
#include <XMLPercentOrMeasurePropertyHandler.hxx>
#include <XMLTextColumnsPropertyHandler.hxx>
+#include <XMLThemeColorHandler.hxx>
#include <animations.hxx>
#include <sax/tools/converter.hxx>
#include <xmlsdtypes.hxx>
@@ -1308,7 +1309,7 @@ const XMLPropertyHandler* XMLSdPropHdlFactory::GetPropertyHandler( sal_Int32 nTy
pHdl = new XMLTextColumnsPropertyHandler;
break;
case XML_TYPE_THEME_COLOR:
- pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID);
+ pHdl = new XMLThemeColorHandler;
break;
}
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 22fbe4174dd6..a4450ce230f4 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.cxx
@@ -56,6 +56,7 @@
#include <XMLFillBitmapSizePropertyHandler.hxx>
#include <XMLBitmapLogicalSizePropertyHandler.hxx>
#include <XMLBitmapRepeatOffsetPropertyHandler.hxx>
+#include <XMLThemeColorHandler.hxx>
#include <vcl/graph.hxx>
using namespace ::com::sun::star;
@@ -249,8 +250,9 @@ SvXMLEnumMapEntry<drawing::TextVerticalAdjust> const pXML_VerticalAlign_Enum[] =
{ XML_TOKEN_INVALID, drawing::TextVerticalAdjust(0) }
};
-SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[] =
+SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[] =
{
+ { XML_NONE, -1 },
{ XML_DK1, 0 },
{ XML_LT1, 1 },
{ XML_DK2, 2 },
@@ -1430,7 +1432,7 @@ static const XMLPropertyHandler *GetPropertyHandler
pHdl = new XMLGraphicPropertyHandler;
break;
case XML_TYPE_THEME_COLOR:
- pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID);
+ pHdl = new XMLThemeColorHandler;
break;
default:
{