xmloff: use XThemeColor in ODF, change the format for themes
Change the xmloff filter to use XThemeColor and the associated proprties (CharColorThemeReference and FillColorThemeReference). Change the ODF format for referencing a theme color - make it an element instead a series of attributes on the *-properties style element. Change-Id: I0fa7d8ebffecc02897b7fe9824d6f1776ef36380 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144923 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
parent
a6d44c4684
commit
3eb53d327f
30 changed files with 597 additions and 169 deletions
|
@ -202,7 +202,7 @@
|
|||
#define CTF_FILLSTYLE (XML_TEXT_CTF_START + 173)
|
||||
#define CTF_FILLCOLOR (XML_TEXT_CTF_START + 174)
|
||||
#define CTF_PAGENUMBEROFFSET (XML_TEXT_CTF_START + 175)
|
||||
|
||||
#define CTF_THEME_COLOR (XML_TEXT_CTF_START + 176)
|
||||
|
||||
enum class TextPropMap {
|
||||
TEXT = 0,
|
||||
|
|
|
@ -3481,8 +3481,8 @@ namespace xmloff::token {
|
|||
XML_LINKED_STYLE_NAME,
|
||||
|
||||
XML_THEME,
|
||||
XML_THEME_COLOR,
|
||||
XML_FILL_THEME_COLOR,
|
||||
XML_CHAR_COLOR_THEME_REFERENCE,
|
||||
XML_FILL_COLOR_THEME_REFERENCE,
|
||||
XML_DK1,
|
||||
XML_LT1,
|
||||
XML_DK2,
|
||||
|
@ -3495,10 +3495,6 @@ namespace xmloff::token {
|
|||
XML_ACCENT6,
|
||||
XML_HLINK,
|
||||
XML_FOLHLINK,
|
||||
XML_COLOR_LUM_MOD,
|
||||
XML_COLOR_LUM_OFF,
|
||||
XML_FILL_COLOR_LUM_MOD,
|
||||
XML_FILL_COLOR_LUM_OFF,
|
||||
|
||||
XML_CONTENT_CONTROL,
|
||||
XML_SHOWING_PLACE_HOLDER,
|
||||
|
|
BIN
oox/qa/unit/data/ReferenceShapeFill.odp
Normal file
BIN
oox/qa/unit/data/ReferenceShapeFill.odp
Normal file
Binary file not shown.
Binary file not shown.
|
@ -353,27 +353,20 @@ CPPUNIT_TEST_FIXTURE(Test, testReferToTheme)
|
|||
assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff", 0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testReferToThemeShapeFill)
|
||||
CPPUNIT_TEST_FIXTURE(Test, testThemeColor_ShapeFill)
|
||||
{
|
||||
// Given an ODP file that contains references to a theme for shape fill:
|
||||
loadFromURL(u"refer-to-theme-shape-fill.odp");
|
||||
loadFromURL(u"ReferenceShapeFill.odp");
|
||||
|
||||
// When saving that document:
|
||||
save("Impress Office Open XML");
|
||||
|
||||
// Then make sure the shape fill color is a scheme color:
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - Expected: 1
|
||||
// - Actual : 0
|
||||
// i.e. the <a:schemeClr> element was not written. Note that this was already working from PPTX
|
||||
// files via grab-bags, so this test intentionally uses an ODP file as input.
|
||||
// Then make sure the shape fill color is a scheme color.
|
||||
// Note that this was already working from PPTX files via grab-bags,
|
||||
//so this test intentionally uses an ODP file as input.
|
||||
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
|
||||
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr", "val", "accent1");
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - XPath '//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod' number of nodes is incorrect
|
||||
// i.e. the effects of the themed color were lost.
|
||||
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod", "val", "40000");
|
||||
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumOff", "val", "60000");
|
||||
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr", "val", "accent6");
|
||||
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod", "val", "75000");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testTdf146690_endParagraphRunPropertiesNewLinesTextSize)
|
||||
|
|
|
@ -1798,22 +1798,6 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
|
|||
<rng:ref name="color"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<!-- TODO(vmiklos) no proposal for theme color of shape fill -->
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:fill-theme-color">
|
||||
<rng:ref name="theme-color"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:fill-color-lum-mod">
|
||||
<rng:ref name="zeroToHundredPercent"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:fill-color-lum-off">
|
||||
<rng:ref name="zeroToHundredPercent"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="draw:secondary-fill-color">
|
||||
<rng:ref name="color"/>
|
||||
|
@ -2310,22 +2294,6 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
|
|||
<rng:ref name="zeroToHundredPercent"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<!-- TODO(vmiklos) no proposal for theme color of shape text -->
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:theme-color">
|
||||
<rng:ref name="theme-color"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:color-lum-mod">
|
||||
<rng:ref name="zeroToHundredPercent"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:color-lum-off">
|
||||
<rng:ref name="zeroToHundredPercent"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
</rng:define>
|
||||
|
||||
<rng:define name="style-text-properties-attlist" combine="interleave">
|
||||
|
@ -3297,6 +3265,8 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
|
|||
</rng:optional>
|
||||
</rng:element>
|
||||
</rng:define>
|
||||
|
||||
<!-- Theme Elements -->
|
||||
<rng:define name="theme-color">
|
||||
<rng:choice>
|
||||
<!-- Background 1 -->
|
||||
|
@ -3320,6 +3290,59 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
|
|||
</rng:choice>
|
||||
</rng:define>
|
||||
|
||||
<rng:define name="loext-transformation">
|
||||
<rng:element name="loext:transformation">
|
||||
<rng:attribute name="loext:type">
|
||||
<rng:ref name="string"/>
|
||||
</rng:attribute>
|
||||
<rng:attribute name="loext:value">
|
||||
<rng:ref name="integer"/>
|
||||
</rng:attribute>
|
||||
</rng:element>
|
||||
</rng:define>
|
||||
|
||||
<rng:define name="loext-theme-color-reference-attlist">
|
||||
<rng:interleave>
|
||||
<rng:optional>
|
||||
<rng:attribute name="loext:type">
|
||||
<rng:ref name="theme-color"/>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
</rng:interleave>
|
||||
</rng:define>
|
||||
|
||||
<rng:define name="loext-char-color-theme-reference">
|
||||
<rng:element name="loext:char-color-theme-reference">
|
||||
<rng:ref name="loext-theme-color-reference-attlist"/>
|
||||
<rng:zeroOrMore>
|
||||
<rng:ref name="loext-transformation"/>
|
||||
</rng:zeroOrMore>
|
||||
</rng:element>
|
||||
</rng:define>
|
||||
|
||||
<rng:define name="loext-fill-color-theme-reference">
|
||||
<rng:element name="loext:fill-color-theme-reference">
|
||||
<rng:ref name="loext-theme-color-reference-attlist"/>
|
||||
<rng:zeroOrMore>
|
||||
<rng:ref name="loext-transformation"/>
|
||||
</rng:zeroOrMore>
|
||||
</rng:element>
|
||||
</rng:define>
|
||||
|
||||
<!-- TODO no proposal -->
|
||||
<rng:define name="style-text-properties-elements" combine="interleave">
|
||||
<rng:optional>
|
||||
<rng:ref name="loext-char-color-theme-reference"/>
|
||||
</rng:optional>
|
||||
</rng:define>
|
||||
|
||||
<!-- TODO no proposal -->
|
||||
<rng:define name="style-graphic-properties-elements" combine="interleave">
|
||||
<rng:optional>
|
||||
<rng:ref name="loext-fill-color-theme-reference"/>
|
||||
</rng:optional>
|
||||
</rng:define>
|
||||
|
||||
<!-- https://issues.oasis-open.org/browse/OFFICE-4136 -->
|
||||
<rng:define name="draw-frame-attlist" combine="interleave">
|
||||
<rng:optional>
|
||||
|
|
|
@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,xmloff_draw, \
|
|||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
docmodel \
|
||||
embobj \
|
||||
sal \
|
||||
subsequenttest \
|
||||
|
|
|
@ -41,6 +41,7 @@ $(eval $(call gb_CppunitTest_use_libraries,xmloff_uxmloff, \
|
|||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
docmodel \
|
||||
i18nlangtag \
|
||||
sal \
|
||||
salhelper \
|
||||
|
|
|
@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_libraries,xo,\
|
|||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
docmodel \
|
||||
i18nlangtag \
|
||||
sal \
|
||||
salhelper \
|
||||
|
@ -339,6 +340,8 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
|
|||
xmloff/source/text/XMLTextCharStyleNamesElementExport \
|
||||
xmloff/source/text/XMLTextColumnsContext \
|
||||
xmloff/source/text/XMLTextColumnsExport \
|
||||
xmloff/source/text/XMLThemeColorContext \
|
||||
xmloff/source/text/XMLThemeColorExport \
|
||||
xmloff/source/text/XMLTextFrameContext \
|
||||
xmloff/source/text/XMLTextFrameHyperlinkContext \
|
||||
xmloff/source/text/XMLTextHeaderFooterContext \
|
||||
|
|
33
xmloff/inc/XMLThemeColorContext.hxx
Normal file
33
xmloff/inc/XMLThemeColorContext.hxx
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* -*- 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 <memory>
|
||||
#include "XMLElementPropertyContext.hxx"
|
||||
#include <docmodel/uno/UnoThemeColor.hxx>
|
||||
|
||||
class XMLThemeColorContext final : public XMLElementPropertyContext
|
||||
{
|
||||
model::ThemeColor aThemeColor;
|
||||
sal_Int32 mnRootElement;
|
||||
|
||||
public:
|
||||
XMLThemeColorContext(SvXMLImport& rImport, sal_Int32 nElement,
|
||||
const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
|
||||
const XMLPropertyState& rProp, std::vector<XMLPropertyState>& rProps);
|
||||
|
||||
css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
|
||||
sal_Int32 nElement,
|
||||
const css::uno::Reference<css::xml::sax::XFastAttributeList>& AttrList) override;
|
||||
|
||||
void SAL_CALL endFastElement(sal_Int32 nElement) override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
30
xmloff/inc/XMLThemeColorExport.hxx
Normal file
30
xmloff/inc/XMLThemeColorExport.hxx
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* -*- 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/types.h>
|
||||
#include <rtl/ustring.hxx>
|
||||
|
||||
namespace com::sun::star::uno
|
||||
{
|
||||
class Any;
|
||||
}
|
||||
class SvXMLExport;
|
||||
|
||||
class XMLThemeColorExport
|
||||
{
|
||||
SvXMLExport& mrExport;
|
||||
|
||||
public:
|
||||
XMLThemeColorExport(SvXMLExport& rExport);
|
||||
|
||||
void exportXML(const css::uno::Any& rAny, sal_uInt16 nPrefix, const OUString& rLocalName);
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -9,39 +9,38 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <xmloff/xmlprhdl.hxx>
|
||||
#include <docmodel/uno/UnoThemeColor.hxx>
|
||||
|
||||
using namespace ::xmloff::token;
|
||||
using namespace css;
|
||||
|
||||
class XMLThemeColorHandler : public XMLPropertyHandler
|
||||
{
|
||||
public:
|
||||
bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue,
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue,
|
||||
bool exportXML(OUString& /*rStrExpValue*/, const css::uno::Any& /*rValue*/,
|
||||
const SvXMLUnitConverter&) const override
|
||||
{
|
||||
sal_Int16 nThemeIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(rValue >>= nThemeIndex) || nThemeIndex == -1) // Default
|
||||
return false;
|
||||
bool equals(const css::uno::Any& rAny1, const css::uno::Any& rAny2) const override
|
||||
{
|
||||
uno::Reference<util::XThemeColor> xThemeColor1;
|
||||
uno::Reference<util::XThemeColor> xThemeColor2;
|
||||
rAny1 >>= xThemeColor1;
|
||||
rAny2 >>= xThemeColor2;
|
||||
model::ThemeColor aThemeColor1;
|
||||
model::ThemeColor aThemeColor2;
|
||||
model::theme::setFromXThemeColor(aThemeColor1, xThemeColor1);
|
||||
model::theme::setFromXThemeColor(aThemeColor2, xThemeColor2);
|
||||
|
||||
OUStringBuffer aOutBuffer;
|
||||
bool bReturn = SvXMLUnitConverter::convertEnum(aOutBuffer, nThemeIndex,
|
||||
pXML_ThemeColor_Enum, XML_NONE);
|
||||
rStrExpValue = aOutBuffer.makeStringAndClear();
|
||||
|
||||
return bReturn;
|
||||
return aThemeColor1 == aThemeColor2;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -56,9 +56,7 @@ inline constexpr OUStringLiteral PROP_CharBottomBorder = u"CharBottomBorder";
|
|||
inline constexpr OUStringLiteral PROP_CharBottomBorderDistance = u"CharBottomBorderDistance";
|
||||
inline constexpr OUStringLiteral PROP_CharCaseMap = u"CharCaseMap";
|
||||
inline constexpr OUStringLiteral PROP_CharColor = u"CharColor";
|
||||
inline constexpr OUStringLiteral PROP_CharColorLumMod = u"CharColorLumMod";
|
||||
inline constexpr OUStringLiteral PROP_CharColorLumOff = u"CharColorLumOff";
|
||||
inline constexpr OUStringLiteral PROP_CharColorTheme = u"CharColorTheme";
|
||||
inline constexpr OUStringLiteral PROP_CharColorThemeReference = u"CharColorThemeReference";
|
||||
inline constexpr OUStringLiteral PROP_CharCombineIsOn = u"CharCombineIsOn";
|
||||
inline constexpr OUStringLiteral PROP_CharCombinePrefix = u"CharCombinePrefix";
|
||||
inline constexpr OUStringLiteral PROP_CharCombineSuffix = u"CharCombineSuffix";
|
||||
|
@ -209,9 +207,7 @@ inline constexpr OUStringLiteral PROP_FillBitmapSizeX = u"FillBitmapSizeX";
|
|||
inline constexpr OUStringLiteral PROP_FillBitmapSizeY = u"FillBitmapSizeY";
|
||||
inline constexpr OUStringLiteral PROP_FillColor = u"FillColor";
|
||||
inline constexpr OUStringLiteral PROP_FillColor2 = u"FillColor2";
|
||||
inline constexpr OUStringLiteral PROP_FillColorLumMod = u"FillColorLumMod";
|
||||
inline constexpr OUStringLiteral PROP_FillColorLumOff = u"FillColorLumOff";
|
||||
inline constexpr OUStringLiteral PROP_FillColorTheme = u"FillColorTheme";
|
||||
inline constexpr OUStringLiteral PROP_FillColorThemeReference = u"FillColorThemeReference";
|
||||
inline constexpr OUStringLiteral PROP_FillGradientName = u"FillGradientName";
|
||||
inline constexpr OUStringLiteral PROP_FillGradientStepCount = u"FillGradientStepCount";
|
||||
inline constexpr OUStringLiteral PROP_FillHatchName = u"FillHatchName";
|
||||
|
|
BIN
xmloff/qa/unit/data/Reference-ThemeColors-TextAndFill.pptx
Normal file
BIN
xmloff/qa/unit/data/Reference-ThemeColors-TextAndFill.pptx
Normal file
Binary file not shown.
BIN
xmloff/qa/unit/data/ReferenceShapeFill.pptx
Normal file
BIN
xmloff/qa/unit/data/ReferenceShapeFill.pptx
Normal file
Binary file not shown.
Binary file not shown.
|
@ -29,6 +29,7 @@
|
|||
#include <svx/unopage.hxx>
|
||||
#include <svx/svdpage.hxx>
|
||||
#include <svx/svdomedia.hxx>
|
||||
#include <docmodel/uno/UnoThemeColor.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
|
@ -39,6 +40,33 @@ public:
|
|||
XmloffDrawTest();
|
||||
void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
|
||||
uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex);
|
||||
|
||||
uno::Reference<beans::XPropertySet>
|
||||
getShapeTextPortion(sal_uInt32 nIndex, uno::Reference<drawing::XShape> const& xShape)
|
||||
{
|
||||
uno::Reference<beans::XPropertySet> xPortion;
|
||||
|
||||
uno::Reference<container::XEnumerationAccess> xEnumAccess(xShape, uno::UNO_QUERY);
|
||||
if (!xEnumAccess->hasElements())
|
||||
return xPortion;
|
||||
uno::Reference<container::XEnumeration> xEnum(xEnumAccess->createEnumeration());
|
||||
uno::Reference<text::XTextContent> xTextContent;
|
||||
xEnum->nextElement() >>= xTextContent;
|
||||
if (!xTextContent.is())
|
||||
return xPortion;
|
||||
|
||||
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextContent, uno::UNO_QUERY);
|
||||
uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
|
||||
sal_uInt32 nCurrent = 0;
|
||||
xPortion = uno::Reference<beans::XPropertySet>(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
while (nIndex != nCurrent)
|
||||
{
|
||||
++nCurrent;
|
||||
xPortion
|
||||
= uno::Reference<beans::XPropertySet>(xParaEnum->nextElement(), uno::UNO_QUERY);
|
||||
}
|
||||
return xPortion;
|
||||
}
|
||||
};
|
||||
|
||||
XmloffDrawTest::XmloffDrawTest()
|
||||
|
@ -188,65 +216,201 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport)
|
|||
CPPUNIT_ASSERT_EQUAL(static_cast<util::Color>(0x954F72), aColorScheme[11]);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme)
|
||||
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
|
||||
{
|
||||
// Given a document that refers to a theme color:
|
||||
loadFromURL(u"refer-to-theme.odp");
|
||||
loadFromURL(u"Reference-ThemeColors-TextAndFill.pptx");
|
||||
save("impress8");
|
||||
|
||||
// Make sure the export result has the theme reference:
|
||||
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - XPath '//style:style[@style:name='T1']/style:text-properties' no attribute 'theme-color' exist
|
||||
// i.e. only the direct color was written, but not the theme reference.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties", "theme-color",
|
||||
"accent1");
|
||||
assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties",
|
||||
"color-lum-mod");
|
||||
assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties",
|
||||
"color-lum-off");
|
||||
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "theme-color",
|
||||
"accent1");
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - XPath '//style:style[@style:name='T2']/style:text-properties' no attribute 'color-lum-mod' exist
|
||||
// i.e. effects on a referenced theme color were lost.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "color-lum-mod",
|
||||
"40%");
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "color-lum-off",
|
||||
"60%");
|
||||
// Text color
|
||||
OString aStyle1(
|
||||
"//style:style[@style:name='T2']/style:text-properties/loext:char-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aStyle1, "type", "accent3");
|
||||
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "value", "2000");
|
||||
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "type", "lumoff");
|
||||
assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[2]", "value", "8000");
|
||||
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "theme-color",
|
||||
"accent1");
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "color-lum-mod",
|
||||
"75%");
|
||||
assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties",
|
||||
"color-lum-off");
|
||||
OString aStyle2(
|
||||
"//style:style[@style:name='T3']/style:text-properties/loext:char-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aStyle2, "type", "accent3");
|
||||
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "value", "6000");
|
||||
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "type", "lumoff");
|
||||
assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[2]", "value", "4000");
|
||||
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - XPath '//style:style[@style:name='gr2']/style:graphic-properties' no attribute 'fill-theme-color' exist
|
||||
// i.e. only the direct color was written, but not the theme reference.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr2']/style:graphic-properties",
|
||||
"fill-theme-color", "accent1");
|
||||
OString aStyle3(
|
||||
"//style:style[@style:name='T4']/style:text-properties/loext:char-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aStyle3, "type", "accent3");
|
||||
assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "value", "5000");
|
||||
|
||||
// Shape fill, 60% lighter.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr3']/style:graphic-properties",
|
||||
"fill-theme-color", "accent1");
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - XPath '//style:style[@style:name='gr3']/style:graphic-properties' no attribute 'fill-color-lum-mod' exist
|
||||
// i.e. the themed color was fine, but its effects were lost.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr3']/style:graphic-properties",
|
||||
"fill-color-lum-mod", "40%");
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr3']/style:graphic-properties",
|
||||
"fill-color-lum-off", "60%");
|
||||
// Shapes fill color
|
||||
OString aShape1("//style:style[@style:name='gr1']/style:graphic-properties/"
|
||||
"loext:fill-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aShape1, "type", "accent2");
|
||||
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "value", "2000");
|
||||
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "type", "lumoff");
|
||||
assertXPath(pXmlDoc, aShape1 + "/loext:transformation[2]", "value", "8000");
|
||||
|
||||
// Shape fill, 25% darker.
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr4']/style:graphic-properties",
|
||||
"fill-theme-color", "accent1");
|
||||
assertXPath(pXmlDoc, "//style:style[@style:name='gr4']/style:graphic-properties",
|
||||
"fill-color-lum-mod", "75%");
|
||||
assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='gr4']/style:graphic-properties",
|
||||
"fill-color-lum-off");
|
||||
OString aShape2("//style:style[@style:name='gr2']/style:graphic-properties/"
|
||||
"loext:fill-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aShape2, "type", "accent2");
|
||||
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "value", "6000");
|
||||
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "type", "lumoff");
|
||||
assertXPath(pXmlDoc, aShape2 + "/loext:transformation[2]", "value", "4000");
|
||||
|
||||
OString aShape3("//style:style[@style:name='gr3']/style:graphic-properties/"
|
||||
"loext:fill-color-theme-reference");
|
||||
assertXPath(pXmlDoc, aShape3, "type", "accent2");
|
||||
assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "type", "lummod");
|
||||
assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "value", "5000");
|
||||
|
||||
// reload
|
||||
load(maTempFile.GetURL());
|
||||
|
||||
// check fill color theme
|
||||
{
|
||||
uno::Reference<drawing::XShape> xShape(getShape(0));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
|
||||
auto const& rTrans2 = aThemeColor.getTransformations()[1];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
|
||||
}
|
||||
{
|
||||
uno::Reference<drawing::XShape> xShape(getShape(1));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
|
||||
auto const& rTrans2 = aThemeColor.getTransformations()[1];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
|
||||
}
|
||||
{
|
||||
uno::Reference<drawing::XShape> xShape(getShape(2));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
|
||||
}
|
||||
|
||||
// Char color theme
|
||||
// Shape 4
|
||||
{
|
||||
// Check the first text portion properties
|
||||
uno::Reference<drawing::XShape> xShape(getShape(3));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
||||
CPPUNIT_ASSERT(xPortion.is());
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
|
||||
auto const& rTrans2 = aThemeColor.getTransformations()[1];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
|
||||
}
|
||||
// Shape 5
|
||||
{
|
||||
// Check the first text portion properties
|
||||
uno::Reference<drawing::XShape> xShape(getShape(4));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
||||
CPPUNIT_ASSERT(xPortion.is());
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
|
||||
auto const& rTrans2 = aThemeColor.getTransformations()[1];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
|
||||
}
|
||||
// Shape 6
|
||||
{
|
||||
// Check the first text portion properties
|
||||
uno::Reference<drawing::XShape> xShape(getShape(5));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
|
||||
CPPUNIT_ASSERT(xPortion.is());
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
|
||||
auto const& rTrans1 = aThemeColor.getTransformations()[0];
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColor_ShapeFill)
|
||||
{
|
||||
loadFromURL(u"ReferenceShapeFill.pptx");
|
||||
save("impress8");
|
||||
// reload
|
||||
load(maTempFile.GetURL());
|
||||
|
||||
// check fill color theme
|
||||
uno::Reference<drawing::XShape> xShape(getShape(0));
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
|
||||
CPPUNIT_ASSERT(xThemeColor.is());
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType());
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
|
||||
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
|
||||
aThemeColor.getTransformations()[0].meType);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), aThemeColor.getTransformations()[0].mnValue);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape)
|
||||
|
|
|
@ -3484,8 +3484,8 @@ namespace xmloff::token {
|
|||
TOKEN("linked-style-name", XML_LINKED_STYLE_NAME ),
|
||||
|
||||
TOKEN("theme", XML_THEME ),
|
||||
TOKEN("theme-color", XML_THEME_COLOR ),
|
||||
TOKEN("fill-theme-color", XML_FILL_THEME_COLOR ),
|
||||
TOKEN("char-color-theme-reference", XML_CHAR_COLOR_THEME_REFERENCE),
|
||||
TOKEN("fill-color-theme-reference", XML_FILL_COLOR_THEME_REFERENCE),
|
||||
TOKEN("dk1", XML_DK1 ),
|
||||
TOKEN("lt1", XML_LT1 ),
|
||||
TOKEN("dk2", XML_DK2 ),
|
||||
|
@ -3498,10 +3498,6 @@ namespace xmloff::token {
|
|||
TOKEN("accent6", XML_ACCENT6 ),
|
||||
TOKEN("hlink", XML_HLINK ),
|
||||
TOKEN("folHlink", XML_FOLHLINK ),
|
||||
TOKEN("color-lum-mod", XML_COLOR_LUM_MOD ),
|
||||
TOKEN("color-lum-off", XML_COLOR_LUM_OFF ),
|
||||
TOKEN("fill-color-lum-mod", XML_FILL_COLOR_LUM_MOD ),
|
||||
TOKEN("fill-color-lum-off", XML_FILL_COLOR_LUM_OFF ),
|
||||
|
||||
TOKEN("content-control", XML_CONTENT_CONTROL ),
|
||||
TOKEN("showing-place-holder", XML_SHOWING_PLACE_HOLDER ),
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <XMLShapePropertySetContext.hxx>
|
||||
#include <XMLTextColumnsContext.hxx>
|
||||
#include <XMLThemeColorContext.hxx>
|
||||
#include <xmloff/xmlimp.hxx>
|
||||
#include <xmloff/xmlnumi.hxx>
|
||||
#include <xmltabi.hxx>
|
||||
|
@ -81,6 +82,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLShapePropertySetCon
|
|||
rProperties );
|
||||
case CTF_TEXTCOLUMNS:
|
||||
return new XMLTextColumnsContext(GetImport(), nElement, xAttrList, rProp, rProperties);
|
||||
|
||||
case CTF_THEME_COLOR:
|
||||
return new XMLThemeColorContext(GetImport(), nElement, xAttrList, rProp, rProperties);
|
||||
}
|
||||
|
||||
return SvXMLPropertySetContext::createFastChildContext( nElement,
|
||||
|
|
|
@ -109,9 +109,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
|
|||
GMAP( PROP_FillStyle, XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, CTF_FILLSTYLE ),
|
||||
GMAP_D(PROP_FillColor, XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, CTF_FILLCOLOR ),
|
||||
GMAP_D(PROP_FillColor2, XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0),
|
||||
GMAPV( PROP_FillColorTheme, XML_NAMESPACE_LO_EXT, XML_FILL_THEME_COLOR, XML_TYPE_THEME_COLOR, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
|
||||
GMAPV( PROP_FillColorLumMod, XML_NAMESPACE_LO_EXT, XML_FILL_COLOR_LUM_MOD, XML_TYPE_PERCENT100, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
|
||||
GMAPV( PROP_FillColorLumOff, XML_NAMESPACE_LO_EXT, XML_FILL_COLOR_LUM_OFF, XML_TYPE_PERCENT100, 0, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
|
||||
GMAPV( PROP_FillColorThemeReference, XML_NAMESPACE_LO_EXT, XML_FILL_COLOR_THEME_REFERENCE, XML_TYPE_THEME_COLOR|MID_FLAG_ELEMENT_ITEM, CTF_THEME_COLOR, SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
|
||||
GMAP( PROP_FillGradientName, XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLGRADIENTNAME ),
|
||||
GMAP( PROP_FillGradientStepCount, XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0 ),
|
||||
GMAP( PROP_FillHatchName, XML_NAMESPACE_DRAW, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLHATCHNAME ),
|
||||
|
|
|
@ -98,9 +98,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > PagePropertySetContext
|
|||
break;
|
||||
|
||||
case CTF_PM_TEXTCOLUMNS:
|
||||
return new XMLTextColumnsContext( GetImport(), nElement,
|
||||
xAttrList, rProp,
|
||||
rProperties );
|
||||
return new XMLTextColumnsContext(GetImport(), nElement, xAttrList, rProp, rProperties);
|
||||
break;
|
||||
|
||||
case CTF_PM_FTN_LINE_WEIGHT:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <tools/debug.hxx>
|
||||
#include "XMLTextPropertySetContext.hxx"
|
||||
#include <XMLTextColumnsContext.hxx>
|
||||
#include <XMLThemeColorContext.hxx>
|
||||
#include <XMLBackgroundImageContext.hxx>
|
||||
#include "XMLSectionFootnoteConfigImport.hxx"
|
||||
|
||||
|
@ -28,7 +29,6 @@
|
|||
#include <xmltabi.hxx>
|
||||
#include "txtdropi.hxx"
|
||||
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
|
@ -69,6 +69,10 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextPropertySetCont
|
|||
rProperties );
|
||||
break;
|
||||
|
||||
case CTF_THEME_COLOR:
|
||||
return new XMLThemeColorContext(GetImport(), nElement, xAttrList, rProp, rProperties);
|
||||
break;
|
||||
|
||||
case CTF_DROPCAPFORMAT:
|
||||
{
|
||||
DBG_ASSERT( rProp.mnIndex >= 2 &&
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <xmloff/XMLEventsImportContext.hxx>
|
||||
#include <XMLShapePropertySetContext.hxx>
|
||||
#include <XMLTextColumnsContext.hxx>
|
||||
#include <XMLThemeColorContext.hxx>
|
||||
#include <XMLBackgroundImageContext.hxx>
|
||||
#include <xmloff/txtprmap.hxx>
|
||||
#include <xmloff/xmltypes.hxx>
|
||||
|
@ -89,6 +90,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextShapePropertySe
|
|||
rProperties );
|
||||
break;
|
||||
|
||||
case CTF_THEME_COLOR:
|
||||
return new XMLThemeColorContext(GetImport(), nElement, xAttrList, rProp, rProperties);
|
||||
|
||||
case CTF_BACKGROUND_URL:
|
||||
DBG_ASSERT( rProp.mnIndex >= 3 &&
|
||||
CTF_BACKGROUND_TRANSPARENCY ==
|
||||
|
|
116
xmloff/source/text/XMLThemeColorContext.cxx
Normal file
116
xmloff/source/text/XMLThemeColorContext.cxx
Normal file
|
@ -0,0 +1,116 @@
|
|||
/* -*- 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 <sal/config.h>
|
||||
|
||||
#include <sal/log.hxx>
|
||||
#include <sax/tools/converter.hxx>
|
||||
#include <xmloff/xmluconv.hxx>
|
||||
#include <xmloff/namespacemap.hxx>
|
||||
#include <xmloff/xmlnamespace.hxx>
|
||||
#include <xmloff/xmlimp.hxx>
|
||||
#include <xmloff/xmltoken.hxx>
|
||||
#include <xmloff/xmlement.hxx>
|
||||
#include <xmloff/xmlprhdl.hxx>
|
||||
#include <XMLThemeColorContext.hxx>
|
||||
|
||||
using namespace css;
|
||||
using namespace xmloff::token;
|
||||
|
||||
SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[]
|
||||
= { { XML_NONE, -1 }, { XML_DK1, 0 }, { XML_LT1, 1 }, { XML_DK2, 2 },
|
||||
{ XML_LT2, 3 }, { XML_ACCENT1, 4 }, { XML_ACCENT2, 5 }, { XML_ACCENT3, 6 },
|
||||
{ XML_ACCENT4, 7 }, { XML_ACCENT5, 8 }, { XML_ACCENT6, 9 }, { XML_HLINK, 10 },
|
||||
{ XML_FOLHLINK, 11 }, { XML_TOKEN_INVALID, 0 } };
|
||||
|
||||
XMLThemeColorContext::XMLThemeColorContext(
|
||||
SvXMLImport& rImport, sal_Int32 nElement,
|
||||
const uno::Reference<xml::sax::XFastAttributeList>& xAttrList, const XMLPropertyState& rProp,
|
||||
std::vector<XMLPropertyState>& rProps)
|
||||
: XMLElementPropertyContext(rImport, nElement, rProp, rProps)
|
||||
, mnRootElement(nElement)
|
||||
{
|
||||
for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
|
||||
{
|
||||
switch (aIter.getToken())
|
||||
{
|
||||
case XML_ELEMENT(LO_EXT, XML_TYPE):
|
||||
{
|
||||
sal_Int16 nValue = -1;
|
||||
if (SvXMLUnitConverter::convertEnum(nValue, aIter.toView(), pXML_ThemeColor_Enum))
|
||||
{
|
||||
aThemeColor.setType(model::convertToThemeColorType(nValue));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
XMLOFF_WARN_UNKNOWN("xmloff", aIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
css::uno::Reference<css::xml::sax::XFastContextHandler>
|
||||
XMLThemeColorContext::createFastChildContext(
|
||||
sal_Int32 nElement, const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList)
|
||||
{
|
||||
if (nElement == XML_ELEMENT(LO_EXT, XML_TRANSFORMATION))
|
||||
{
|
||||
auto eTransformationType = model::TransformationType::Undefined;
|
||||
sal_Int16 nTransformationValue = 0;
|
||||
for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
|
||||
{
|
||||
switch (aIter.getToken())
|
||||
{
|
||||
case XML_ELEMENT(LO_EXT, XML_TYPE):
|
||||
{
|
||||
const OUString aValue = aIter.toString();
|
||||
if (aValue == u"tint")
|
||||
eTransformationType = model::TransformationType::Tint;
|
||||
else if (aValue == u"shade")
|
||||
eTransformationType = model::TransformationType::Shade;
|
||||
else if (aValue == u"lumoff")
|
||||
eTransformationType = model::TransformationType::LumOff;
|
||||
else if (aValue == u"lummod")
|
||||
eTransformationType = model::TransformationType::LumMod;
|
||||
break;
|
||||
}
|
||||
case XML_ELEMENT(LO_EXT, XML_VALUE):
|
||||
{
|
||||
sal_Int32 nValue;
|
||||
if (::sax::Converter::convertNumber(nValue, aIter.toView(), SHRT_MIN, SHRT_MAX))
|
||||
nTransformationValue = static_cast<sal_Int16>(nValue);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
XMLOFF_WARN_UNKNOWN("xmloff", aIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
aThemeColor.addTransformation({ eTransformationType, nTransformationValue });
|
||||
return this;
|
||||
}
|
||||
XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void XMLThemeColorContext::endFastElement(sal_Int32 nElement)
|
||||
{
|
||||
if (nElement == mnRootElement)
|
||||
{
|
||||
if (aThemeColor.getType() != model::ThemeColorType::Unknown)
|
||||
{
|
||||
aProp.maValue <<= model::theme::createXThemeColor(aThemeColor);
|
||||
SetInsert(true);
|
||||
}
|
||||
}
|
||||
XMLElementPropertyContext::endFastElement(nElement);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
85
xmloff/source/text/XMLThemeColorExport.cxx
Normal file
85
xmloff/source/text/XMLThemeColorExport.cxx
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* -*- 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 <XMLThemeColorExport.hxx>
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <docmodel/uno/UnoThemeColor.hxx>
|
||||
#include <xmloff/xmltoken.hxx>
|
||||
#include <xmloff/xmlnamespace.hxx>
|
||||
#include <xmloff/xmluconv.hxx>
|
||||
#include <xmloff/xmlexp.hxx>
|
||||
#include <array>
|
||||
|
||||
using namespace css;
|
||||
using namespace ::xmloff::token;
|
||||
|
||||
XMLThemeColorExport::XMLThemeColorExport(SvXMLExport& rExport)
|
||||
: mrExport(rExport)
|
||||
{
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const std::array<XMLTokenEnum, 12> constThemeColorTypeToToken{
|
||||
XML_DK1, XML_LT1, XML_DK2, XML_LT2, XML_ACCENT1, XML_ACCENT2,
|
||||
XML_ACCENT3, XML_ACCENT4, XML_ACCENT5, XML_ACCENT6, XML_HLINK, XML_FOLHLINK
|
||||
};
|
||||
}
|
||||
|
||||
void XMLThemeColorExport::exportXML(const uno::Any& rAny, sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName)
|
||||
{
|
||||
uno::Reference<util::XThemeColor> xThemeColor;
|
||||
rAny >>= xThemeColor;
|
||||
if (!xThemeColor.is())
|
||||
return;
|
||||
|
||||
model::ThemeColor aThemeColor;
|
||||
model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
|
||||
if (aThemeColor.getType() == model::ThemeColorType::Unknown)
|
||||
return;
|
||||
|
||||
XMLTokenEnum nToken = constThemeColorTypeToToken[sal_Int16(aThemeColor.getType())];
|
||||
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_TYPE, nToken);
|
||||
SvXMLElementExport aThemeColorElement(mrExport, nPrefix, rLocalName, true, true);
|
||||
|
||||
for (auto const& rTransform : aThemeColor.getTransformations())
|
||||
{
|
||||
OUString aType;
|
||||
switch (rTransform.meType)
|
||||
{
|
||||
case model::TransformationType::Tint:
|
||||
aType = "tint";
|
||||
break;
|
||||
case model::TransformationType::Shade:
|
||||
aType = "shade";
|
||||
break;
|
||||
case model::TransformationType::LumMod:
|
||||
aType = "lummod";
|
||||
break;
|
||||
case model::TransformationType::LumOff:
|
||||
aType = "lumoff";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!aType.isEmpty())
|
||||
{
|
||||
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_TYPE, aType);
|
||||
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_VALUE,
|
||||
OUString::number(rTransform.mnValue));
|
||||
SvXMLElementExport aTransformElement(mrExport, XML_NAMESPACE_LO_EXT, XML_TRANSFORMATION,
|
||||
true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -72,6 +72,12 @@ void XMLTextExportPropertySetMapper::handleElementItem(
|
|||
pThis->maTextColumnsExport.exportXML( rProperty.maValue );
|
||||
break;
|
||||
|
||||
case CTF_THEME_COLOR:
|
||||
pThis->maThemeColorExport.exportXML(rProperty.maValue,
|
||||
getPropertySetMapper()->GetEntryNameSpace(rProperty.mnIndex),
|
||||
getPropertySetMapper()->GetEntryXMLName(rProperty.mnIndex));
|
||||
break;
|
||||
|
||||
case CTF_BACKGROUND_URL:
|
||||
{
|
||||
const Any *pPos = nullptr, *pFilter = nullptr, *pTrans = nullptr;
|
||||
|
@ -210,6 +216,7 @@ XMLTextExportPropertySetMapper::XMLTextExportPropertySetMapper(
|
|||
maDropCapExport( rExp ),
|
||||
maTabStopExport( rExp ),
|
||||
maTextColumnsExport( rExp ),
|
||||
maThemeColorExport(rExp),
|
||||
maBackgroundImageExport( rExp )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <xmltabe.hxx>
|
||||
#include <XMLTextColumnsExport.hxx>
|
||||
#include <XMLBackgroundImageExport.hxx>
|
||||
#include <XMLThemeColorExport.hxx>
|
||||
|
||||
class SvXMLExport;
|
||||
class XMLTextExportPropertySetMapper: public SvXMLExportPropertyMapper
|
||||
|
@ -52,6 +53,7 @@ private:
|
|||
XMLTextDropCapExport maDropCapExport;
|
||||
SvxXMLTabStopExport maTabStopExport;
|
||||
XMLTextColumnsExport maTextColumnsExport;
|
||||
XMLThemeColorExport maThemeColorExport;
|
||||
XMLBackgroundImageExport maBackgroundImageExport;
|
||||
|
||||
/** Application-specific filter. By default do nothing. */
|
||||
|
|
|
@ -250,24 +250,6 @@ SvXMLEnumMapEntry<drawing::TextVerticalAdjust> const pXML_VerticalAlign_Enum[] =
|
|||
{ XML_TOKEN_INVALID, drawing::TextVerticalAdjust(0) }
|
||||
};
|
||||
|
||||
SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[] =
|
||||
{
|
||||
{ XML_NONE, -1 },
|
||||
{ XML_DK1, 0 },
|
||||
{ XML_LT1, 1 },
|
||||
{ XML_DK2, 2 },
|
||||
{ XML_LT2, 3 },
|
||||
{ XML_ACCENT1, 4 },
|
||||
{ XML_ACCENT2, 5 },
|
||||
{ XML_ACCENT3, 6 },
|
||||
{ XML_ACCENT4, 7 },
|
||||
{ XML_ACCENT5, 8 },
|
||||
{ XML_ACCENT6, 9 },
|
||||
{ XML_HLINK, 10 },
|
||||
{ XML_FOLHLINK, 11 },
|
||||
{ XML_TOKEN_INVALID, 0 }
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
class XMLDropCapPropHdl_Impl : public XMLPropertyHandler
|
||||
|
|
|
@ -139,9 +139,7 @@ XMLPropertyMapEntry const aXMLParaPropMap[] =
|
|||
MT_ED( PROP_CharColor, STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ),
|
||||
MAP_EXT_I( PROP_CharTransparence, XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharTransparence, XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorTheme, XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorLumMod, XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_MOD, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorLumOff, XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_OFF, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorThemeReference, XML_NAMESPACE_LO_EXT, XML_CHAR_COLOR_THEME_REFERENCE, XML_TYPE_THEME_COLOR|XML_TYPE_PROP_TEXT|MID_FLAG_ELEMENT_ITEM, CTF_THEME_COLOR),
|
||||
// RES_CHRATR_CONTOUR
|
||||
MT_E( PROP_CharContoured, STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ),
|
||||
// RES_CHRATR_CROSSEDOUT
|
||||
|
@ -488,9 +486,7 @@ XMLPropertyMapEntry const aXMLTextPropMap[] =
|
|||
MT_ED( PROP_CharColor, STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ),
|
||||
MAP_EXT_I( PROP_CharTransparence, XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharTransparence, XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorTheme, XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorLumMod, XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_MOD, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorLumOff, XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_OFF, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0),
|
||||
MAP_EXT( PROP_CharColorThemeReference, XML_NAMESPACE_LO_EXT, XML_CHAR_COLOR_THEME_REFERENCE, XML_TYPE_THEME_COLOR|XML_TYPE_PROP_TEXT|MID_FLAG_ELEMENT_ITEM, CTF_THEME_COLOR),
|
||||
// RES_CHRATR_CONTOUR
|
||||
MT_E( PROP_CharContoured, STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ),
|
||||
// RES_CHRATR_CROSSEDOUT
|
||||
|
@ -1037,6 +1033,7 @@ XMLPropertyMapEntry const aXMLCellPropMap[] =
|
|||
// text properties
|
||||
MT_ED( PROP_CharColor, FO, COLOR, XML_TYPE_COLORAUTO|MID_FLAG_MERGE_PROPERTY, 0 ),
|
||||
MT_ED( PROP_CharColor, STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ),
|
||||
MAP_EXT( PROP_CharColorThemeReference, XML_NAMESPACE_LO_EXT, XML_CHAR_COLOR_THEME_REFERENCE, XML_TYPE_THEME_COLOR|XML_TYPE_PROP_TEXT|MID_FLAG_ELEMENT_ITEM, CTF_THEME_COLOR),
|
||||
MT_E( PROP_CharShadowed, FO, TEXT_SHADOW, XML_TYPE_TEXT_SHADOWED, 0 ),
|
||||
MT_E( PROP_CharContoured, STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ),
|
||||
MT_E( PROP_CharStrikeout, STYLE, TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ),
|
||||
|
|
|
@ -3228,8 +3228,8 @@ rtl
|
|||
symmetric
|
||||
linked-style-name
|
||||
theme
|
||||
theme-color
|
||||
fill-theme-color
|
||||
char-color-theme-reference
|
||||
fill-color-theme-reference
|
||||
dk1
|
||||
lt1
|
||||
dk2
|
||||
|
@ -3242,10 +3242,6 @@ accent5
|
|||
accent6
|
||||
hlink
|
||||
folHlink
|
||||
color-lum-mod
|
||||
color-lum-off
|
||||
fill-color-lum-mod
|
||||
fill-color-lum-off
|
||||
content-control
|
||||
showing-place-holder
|
||||
checked-state
|
||||
|
|
Loading…
Reference in a new issue