diff options
-rw-r--r-- | editeng/source/uno/unotext.cxx | 12 | ||||
-rw-r--r-- | include/xmloff/xmltoken.hxx | 13 | ||||
-rw-r--r-- | include/xmloff/xmltypes.hxx | 1 | ||||
-rw-r--r-- | schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 25 | ||||
-rw-r--r-- | xmloff/qa/unit/data/refer-to-theme.odp | bin | 0 -> 14488 bytes | |||
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/text/txtprhdl.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/text/txtprmap.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 13 |
11 files changed, 138 insertions, 15 deletions
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 5ae3ffac7522..5dee56643009 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -41,6 +41,7 @@ #include <editeng/editeng.hxx> #include <editeng/outliner.hxx> #include <editeng/unoipset.hxx> +#include <editeng/colritem.hxx> #include <comphelper/sequence.hxx> #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> @@ -1132,6 +1133,17 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf if(bItemStateSet) { + if (pMap->nWID == EE_CHAR_COLOR && pMap->nMemberId == MID_COLOR_THEME_INDEX) + { + // Theme can be DEFAULT_VALUE, even if the same pool item has a color which is a + // DIRECT_VALUE. + const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR); + if (pColor->GetThemeIndex() == -1) + { + eItemState = SfxItemState::DEFAULT; + } + } + switch( eItemState ) { case SfxItemState::SET: diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index dfdacf58c5ff..67885e78cc21 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -3441,6 +3441,19 @@ namespace xmloff::token { XML_LINKED_STYLE_NAME, XML_THEME, + XML_THEME_COLOR, + XML_DK1, + XML_LT1, + XML_DK2, + XML_LT2, + XML_ACCENT1, + XML_ACCENT2, + XML_ACCENT3, + XML_ACCENT4, + XML_ACCENT5, + XML_ACCENT6, + XML_HLINK, + XML_FOLHLINK, XML_TOKEN_END }; diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx index 625e3a5b9c68..3711e5d5db52 100644 --- a/include/xmloff/xmltypes.hxx +++ b/include/xmloff/xmltypes.hxx @@ -293,6 +293,7 @@ #define XML_TYPE_GRAPHIC (XML_TEXT_TYPES_START + 127) #define XML_SW_TYPE_PRESPAGE_BACKSIZE (XML_TEXT_TYPES_START + 128) #define XML_SW_TYPE_RTLGUTTER (XML_TEXT_TYPES_START + 129) +#define XML_TYPE_THEME_COLOR (XML_TEXT_TYPES_START + 130) #endif // INCLUDED_XMLOFF_XMLTYPES_HXX diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng index 6e0a301b047f..e24d3a5e8c8e 100644 --- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng @@ -2093,6 +2093,31 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. <rng:ref name="zeroToHundredPercent"/> </rng:attribute> </rng:optional> + <!-- TODO no proposal --> + <rng:optional> + <rng:attribute name="loext:theme-color"> + <rng:choice> + <!-- Background 1 --> + <rng:value>dk1</rng:value> + <!-- Text 1 --> + <rng:value>lt1</rng:value> + <!-- Background 2 --> + <rng:value>dk2</rng:value> + <!-- Text 2 --> + <rng:value>lt2</rng:value> + <rng:value>accent1</rng:value> + <rng:value>accent2</rng:value> + <rng:value>accent3</rng:value> + <rng:value>accent4</rng:value> + <rng:value>accent5</rng:value> + <rng:value>accent6</rng:value> + <!-- Hyperlink --> + <rng:value>hlink</rng:value> + <!-- Followed hyperlink --> + <rng:value>folHlink</rng:value> + </rng:choice> + </rng:attribute> + </rng:optional> </rng:define> <rng:define name="style-text-properties-attlist" combine="interleave"> diff --git a/xmloff/qa/unit/data/refer-to-theme.odp b/xmloff/qa/unit/data/refer-to-theme.odp Binary files differnew file mode 100644 index 000000000000..83bad49b5f56 --- /dev/null +++ b/xmloff/qa/unit/data/refer-to-theme.odp diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index cd991e691d7c..a61ef6de2717 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -177,6 +177,30 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport) CPPUNIT_ASSERT_EQUAL(static_cast<util::Color>(0x954F72), aColorScheme[11]); } +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme) +{ + // Given a document that refers to a theme color: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "refer-to-theme.odp"; + + // When loading and saving that document: + getComponent() = loadFromDesktop(aURL); + utl::TempFile aTempFile; + save("impress8", aTempFile); + + // Make sure the export result has the theme reference: + std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "content.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + // 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"); + assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "theme-color", + "accent1"); + assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "theme-color", + "accent1"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index caf15a395e03..fd486a313aae 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3444,6 +3444,19 @@ namespace xmloff::token { TOKEN("linked-style-name", XML_LINKED_STYLE_NAME ), TOKEN("theme", XML_THEME ), + TOKEN("theme-color", XML_THEME_COLOR ), + TOKEN("dk1", XML_DK1 ), + TOKEN("lt1", XML_LT1 ), + TOKEN("dk2", XML_DK2 ), + TOKEN("lt2", XML_LT2 ), + TOKEN("accent1", XML_ACCENT1 ), + TOKEN("accent2", XML_ACCENT2 ), + TOKEN("accent3", XML_ACCENT3 ), + TOKEN("accent4", XML_ACCENT4 ), + TOKEN("accent5", XML_ACCENT5 ), + TOKEN("accent6", XML_ACCENT6 ), + TOKEN("hlink", XML_HLINK ), + TOKEN("folHlink", XML_FOLHLINK ), #if OSL_DEBUG_LEVEL > 0 diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 9388cedb25e4..b789f7342d90 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2410,26 +2410,26 @@ void SdXMLExport::ExportThemeElement(const uno::Reference<drawing::XDrawPage>& x } SvXMLElementExport aColorTable(*this, XML_NAMESPACE_LO_EXT, XML_COLOR_TABLE, true, true); - static const std::u16string_view aColorNames[] = { - u"dk1", // Background 1 - u"lt1", // Text 1 - u"dk2", // Background 2 - u"lt2", // Text 2 - u"accent1", // Accent 1 - u"accent2", // Accent 2 - u"accent3", // Accent 3 - u"accent4", // Accent 4 - u"accent5", // Accent 5 - u"accent6", // Accent 6 - u"hlink", // Hyperlink - u"folHlink", // Followed hyperlink + static const XMLTokenEnum aColorTokens[] = { + XML_DK1, // Background 1 + XML_LT1, // Text 1 + XML_DK2, // Background 2 + XML_LT2, // Text 2 + XML_ACCENT1, + XML_ACCENT2, + XML_ACCENT3, + XML_ACCENT4, + XML_ACCENT5, + XML_ACCENT6, + XML_HLINK, // Hyperlink + XML_FOLHLINK, // Followed hyperlink }; for (size_t nColor = 0; nColor < aColors.size(); ++nColor) { // Import goes via svx::Theme::FromAny(), which sanitizes user input. - assert(nColor < SAL_N_ELEMENTS(aColorNames)); + assert(nColor < SAL_N_ELEMENTS(aColorTokens)); - AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, OUString(aColorNames[nColor])); + AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, GetXMLToken(aColorTokens[nColor])); OUStringBuffer sValue; sax::Converter::convertColor(sValue, aColors[nColor]); diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index 2068c9b934a6..22fbe4174dd6 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -249,6 +249,23 @@ SvXMLEnumMapEntry<drawing::TextVerticalAdjust> const pXML_VerticalAlign_Enum[] = { XML_TOKEN_INVALID, drawing::TextVerticalAdjust(0) } }; +SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[] = +{ + { 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 @@ -1412,6 +1429,9 @@ static const XMLPropertyHandler *GetPropertyHandler case XML_TYPE_GRAPHIC: pHdl = new XMLGraphicPropertyHandler; break; + case XML_TYPE_THEME_COLOR: + pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID); + break; default: { OSL_ENSURE(false, "XMLPropertyHandler missing (!)"); diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 2e8297d7947e..f51db1aa2ab6 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -138,6 +138,7 @@ XMLPropertyMapEntry const aXMLParaPropMap[] = MT_ED( "CharColor", STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ), MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharColorTheme", XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT @@ -481,6 +482,7 @@ XMLPropertyMapEntry const aXMLTextPropMap[] = MT_ED( "CharColor", STYLE, USE_WINDOW_FONT_COLOR, XML_TYPE_ISAUTOCOLOR|MID_FLAG_MERGE_PROPERTY, 0 ), MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharColorTheme", XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR | XML_TYPE_PROP_TEXT, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index abc66bd73034..12de9d78a22d 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3188,4 +3188,17 @@ rtl symmetric linked-style-name theme +theme-color +dk1 +lt1 +dk2 +lt2 +accent1 +accent2 +accent3 +accent4 +accent5 +accent6 +hlink +folHlink TOKEN_END_DUMMY |