LibreOffice Module oox (master) 1
color.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <algorithm>
22#include <unordered_map>
23#include <math.h>
24#include <osl/diagnose.h>
25#include <sal/log.hxx>
29#include <oox/token/namespaces.hxx>
30#include <oox/token/tokens.hxx>
31
32namespace oox::drawingml {
33
34namespace {
35
37struct PresetColorsPool
38{
39 typedef ::std::vector< ::Color > ColorVector;
40
41 ColorVector maDmlColors;
42 ColorVector maVmlColors;
43 ColorVector maHighlightColors;
44
45 explicit PresetColorsPool();
46};
47
48PresetColorsPool::PresetColorsPool() :
49 maDmlColors( static_cast< size_t >( XML_TOKEN_COUNT ), API_RGB_TRANSPARENT ),
50 maVmlColors( static_cast< size_t >( XML_TOKEN_COUNT ), API_RGB_TRANSPARENT ),
51 maHighlightColors( static_cast<size_t>(XML_TOKEN_COUNT), API_RGB_TRANSPARENT )
52{
53 // predefined colors in DrawingML (map XML token identifiers to RGB values)
54 static const std::pair<sal_Int32, ::Color> spnDmlColors[] =
55 {
56 {XML_aliceBlue, ::Color(0xF0F8FF)}, {XML_antiqueWhite, ::Color(0xFAEBD7)},
57 {XML_aqua, ::Color(0x00FFFF)}, {XML_aquamarine, ::Color(0x7FFFD4)},
58 {XML_azure, ::Color(0xF0FFFF)}, {XML_beige, ::Color(0xF5F5DC)},
59 {XML_bisque, ::Color(0xFFE4C4)}, {XML_black, ::Color(0x000000)},
60 {XML_blanchedAlmond, ::Color(0xFFEBCD)}, {XML_blue, ::Color(0x0000FF)},
61 {XML_blueViolet, ::Color(0x8A2BE2)}, {XML_brown, ::Color(0xA52A2A)},
62 {XML_burlyWood, ::Color(0xDEB887)}, {XML_cadetBlue, ::Color(0x5F9EA0)},
63 {XML_chartreuse, ::Color(0x7FFF00)}, {XML_chocolate, ::Color(0xD2691E)},
64 {XML_coral, ::Color(0xFF7F50)}, {XML_cornflowerBlue, ::Color(0x6495ED)},
65 {XML_cornsilk, ::Color(0xFFF8DC)}, {XML_crimson, ::Color(0xDC143C)},
66 {XML_cyan, ::Color(0x00FFFF)}, {XML_deepPink, ::Color(0xFF1493)},
67 {XML_deepSkyBlue, ::Color(0x00BFFF)}, {XML_dimGray, ::Color(0x696969)},
68 {XML_dkBlue, ::Color(0x00008B)}, {XML_dkCyan, ::Color(0x008B8B)},
69 {XML_dkGoldenrod, ::Color(0xB8860B)}, {XML_dkGray, ::Color(0xA9A9A9)},
70 {XML_dkGreen, ::Color(0x006400)}, {XML_dkKhaki, ::Color(0xBDB76B)},
71 {XML_dkMagenta, ::Color(0x8B008B)}, {XML_dkOliveGreen, ::Color(0x556B2F)},
72 {XML_dkOrange, ::Color(0xFF8C00)}, {XML_dkOrchid, ::Color(0x9932CC)},
73 {XML_dkRed, ::Color(0x8B0000)}, {XML_dkSalmon, ::Color(0xE9967A)},
74 {XML_dkSeaGreen, ::Color(0x8FBC8B)}, {XML_dkSlateBlue, ::Color(0x483D8B)},
75 {XML_dkSlateGray, ::Color(0x2F4F4F)}, {XML_dkTurquoise, ::Color(0x00CED1)},
76 {XML_dkViolet, ::Color(0x9400D3)}, {XML_dodgerBlue, ::Color(0x1E90FF)},
77 {XML_firebrick, ::Color(0xB22222)}, {XML_floralWhite, ::Color(0xFFFAF0)},
78 {XML_forestGreen, ::Color(0x228B22)}, {XML_fuchsia, ::Color(0xFF00FF)},
79 {XML_gainsboro, ::Color(0xDCDCDC)}, {XML_ghostWhite, ::Color(0xF8F8FF)},
80 {XML_gold, ::Color(0xFFD700)}, {XML_goldenrod, ::Color(0xDAA520)},
81 {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)},
82 {XML_greenYellow, ::Color(0xADFF2F)}, {XML_honeydew, ::Color(0xF0FFF0)},
83 {XML_hotPink, ::Color(0xFF69B4)}, {XML_indianRed, ::Color(0xCD5C5C)},
84 {XML_indigo, ::Color(0x4B0082)}, {XML_ivory, ::Color(0xFFFFF0)},
85 {XML_khaki, ::Color(0xF0E68C)}, {XML_lavender, ::Color(0xE6E6FA)},
86 {XML_lavenderBlush, ::Color(0xFFF0F5)}, {XML_lawnGreen, ::Color(0x7CFC00)},
87 {XML_lemonChiffon, ::Color(0xFFFACD)}, {XML_lime, ::Color(0x00FF00)},
88 {XML_limeGreen, ::Color(0x32CD32)}, {XML_linen, ::Color(0xFAF0E6)},
89 {XML_ltBlue, ::Color(0xADD8E6)}, {XML_ltCoral, ::Color(0xF08080)},
90 {XML_ltCyan, ::Color(0xE0FFFF)}, {XML_ltGoldenrodYellow, ::Color(0xFAFA78)},
91 {XML_ltGray, ::Color(0xD3D3D3)}, {XML_ltGreen, ::Color(0x90EE90)},
92 {XML_ltPink, ::Color(0xFFB6C1)}, {XML_ltSalmon, ::Color(0xFFA07A)},
93 {XML_ltSeaGreen, ::Color(0x20B2AA)}, {XML_ltSkyBlue, ::Color(0x87CEFA)},
94 {XML_ltSlateGray, ::Color(0x778899)}, {XML_ltSteelBlue, ::Color(0xB0C4DE)},
95 {XML_ltYellow, ::Color(0xFFFFE0)}, {XML_magenta, ::Color(0xFF00FF)},
96 {XML_maroon, ::Color(0x800000)}, {XML_medAquamarine, ::Color(0x66CDAA)},
97 {XML_medBlue, ::Color(0x0000CD)}, {XML_medOrchid, ::Color(0xBA55D3)},
98 {XML_medPurple, ::Color(0x9370DB)}, {XML_medSeaGreen, ::Color(0x3CB371)},
99 {XML_medSlateBlue, ::Color(0x7B68EE)}, {XML_medSpringGreen, ::Color(0x00FA9A)},
100 {XML_medTurquoise, ::Color(0x48D1CC)}, {XML_medVioletRed, ::Color(0xC71585)},
101 {XML_midnightBlue, ::Color(0x191970)}, {XML_mintCream, ::Color(0xF5FFFA)},
102 {XML_mistyRose, ::Color(0xFFE4E1)}, {XML_moccasin, ::Color(0xFFE4B5)},
103 {XML_navajoWhite, ::Color(0xFFDEAD)}, {XML_navy, ::Color(0x000080)},
104 {XML_oldLace, ::Color(0xFDF5E6)}, {XML_olive, ::Color(0x808000)},
105 {XML_oliveDrab, ::Color(0x6B8E23)}, {XML_orange, ::Color(0xFFA500)},
106 {XML_orangeRed, ::Color(0xFF4500)}, {XML_orchid, ::Color(0xDA70D6)},
107 {XML_paleGoldenrod, ::Color(0xEEE8AA)}, {XML_paleGreen, ::Color(0x98FB98)},
108 {XML_paleTurquoise, ::Color(0xAFEEEE)}, {XML_paleVioletRed, ::Color(0xDB7093)},
109 {XML_papayaWhip, ::Color(0xFFEFD5)}, {XML_peachPuff, ::Color(0xFFDAB9)},
110 {XML_peru, ::Color(0xCD853F)}, {XML_pink, ::Color(0xFFC0CB)},
111 {XML_plum, ::Color(0xDDA0DD)}, {XML_powderBlue, ::Color(0xB0E0E6)},
112 {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)},
113 {XML_rosyBrown, ::Color(0xBC8F8F)}, {XML_royalBlue, ::Color(0x4169E1)},
114 {XML_saddleBrown, ::Color(0x8B4513)}, {XML_salmon, ::Color(0xFA8072)},
115 {XML_sandyBrown, ::Color(0xF4A460)}, {XML_seaGreen, ::Color(0x2E8B57)},
116 {XML_seaShell, ::Color(0xFFF5EE)}, {XML_sienna, ::Color(0xA0522D)},
117 {XML_silver, ::Color(0xC0C0C0)}, {XML_skyBlue, ::Color(0x87CEEB)},
118 {XML_slateBlue, ::Color(0x6A5ACD)}, {XML_slateGray, ::Color(0x708090)},
119 {XML_snow, ::Color(0xFFFAFA)}, {XML_springGreen, ::Color(0x00FF7F)},
120 {XML_steelBlue, ::Color(0x4682B4)}, {XML_tan, ::Color(0xD2B48C)},
121 {XML_teal, ::Color(0x008080)}, {XML_thistle, ::Color(0xD8BFD8)},
122 {XML_tomato, ::Color(0xFF6347)}, {XML_turquoise, ::Color(0x40E0D0)},
123 {XML_violet, ::Color(0xEE82EE)}, {XML_wheat, ::Color(0xF5DEB3)},
124 {XML_white, ::Color(0xFFFFFF)}, {XML_whiteSmoke, ::Color(0xF5F5F5)},
125 {XML_yellow, ::Color(0xFFFF00)}, {XML_yellowGreen, ::Color(0x9ACD32)}
126 };
127 for(auto const& nEntry : spnDmlColors)
128 maDmlColors[ static_cast< size_t >(nEntry.first) ] = nEntry.second;
129
130 // predefined colors in VML (map XML token identifiers to RGB values)
131 static const std::pair<sal_Int32, ::Color> spnVmlColors[] =
132 {
133 {XML_aqua, ::Color(0x00FFFF)}, {XML_black, ::Color(0x000000)},
134 {XML_blue, ::Color(0x0000FF)}, {XML_fuchsia, ::Color(0xFF00FF)},
135 {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)},
136 {XML_lime, ::Color(0x00FF00)}, {XML_maroon, ::Color(0x800000)},
137 {XML_navy, ::Color(0x000080)}, {XML_olive, ::Color(0x808000)},
138 {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)},
139 {XML_silver, ::Color(0xC0C0C0)}, {XML_teal, ::Color(0x008080)},
140 {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)}
141 };
142 for(auto const& nEntry : spnVmlColors)
143 maVmlColors[ static_cast< size_t >(nEntry.first) ] = nEntry.second;
144
145 // predefined highlight colors in DML (map XML token identifiers to RGB values)
146 static const std::pair<sal_Int32, ::Color> spnHighlightColors[] =
147 {
148 // tdf#131841 Predefined color for OOXML highlight.
149 {XML_black, ::Color(0x000000)}, {XML_blue, ::Color(0x0000FF)},
150 {XML_cyan, ::Color(0x00FFFF)}, {XML_darkBlue, ::Color(0x00008B)},
151 {XML_darkCyan, ::Color(0x008B8B)}, {XML_darkGray, ::Color(0xA9A9A9)},
152 {XML_darkGreen, ::Color(0x006400)}, {XML_darkMagenta, ::Color(0x800080)},
153 {XML_darkRed, ::Color(0x8B0000)}, {XML_darkYellow, ::Color(0x808000)},
154 {XML_green, ::Color(0x00FF00)}, {XML_lightGray, ::Color(0xD3D3D3)},
155 {XML_magenta, ::Color(0xFF00FF)}, {XML_red, ::Color(0xFF0000)},
156 {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)}
157 };
158 for (auto const& nEntry : spnHighlightColors)
159 maHighlightColors[static_cast<size_t>(nEntry.first)] = nEntry.second;
160}
161
162PresetColorsPool& StaticPresetColorsPool()
163{
164 static PresetColorsPool thePool;
165 return thePool;
166}
167
168const double DEC_GAMMA = 2.3;
169const double INC_GAMMA = 1.0 / DEC_GAMMA;
170
171void lclRgbToRgbComponents( sal_Int32& ornR, sal_Int32& ornG, sal_Int32& ornB, ::Color nRgb )
172{
173 ornR = nRgb.GetRed();
174 ornG = nRgb.GetGreen();
175 ornB = nRgb.GetBlue();
176}
177
178sal_Int32 lclRgbComponentsToRgb( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB )
179{
180 return static_cast< sal_Int32 >( (nR << 16) | (nG << 8) | nB );
181}
182
183sal_Int32 lclRgbCompToCrgbComp( sal_Int32 nRgbComp )
184{
185 return static_cast< sal_Int32 >( nRgbComp * MAX_PERCENT / 255 );
186}
187
188sal_Int32 lclCrgbCompToRgbComp( sal_Int32 nCrgbComp )
189{
190 return static_cast< sal_Int32 >( nCrgbComp * 255 / MAX_PERCENT );
191}
192
193sal_Int32 lclGamma( sal_Int32 nComp, double fGamma )
194{
195 return static_cast< sal_Int32 >( pow( static_cast< double >( nComp ) / MAX_PERCENT, fGamma ) * MAX_PERCENT + 0.5 );
196}
197
198void lclSetValue( sal_Int32& ornValue, sal_Int32 nNew, sal_Int32 nMax = MAX_PERCENT )
199{
200 OSL_ENSURE( (0 <= nNew) && (nNew <= nMax), "lclSetValue - invalid value" );
201 if( (0 <= nNew) && (nNew <= nMax) )
202 ornValue = nNew;
203}
204
205void lclModValue( sal_Int32& ornValue, sal_Int32 nMod, sal_Int32 nMax = MAX_PERCENT )
206{
207 OSL_ENSURE( (0 <= nMod), "lclModValue - invalid modificator" );
208 ornValue = getLimitedValue< sal_Int32, double >( static_cast< double >( ornValue ) * nMod / MAX_PERCENT, 0, nMax );
209}
210
211void lclOffValue( sal_Int32& ornValue, sal_Int32 nOff, sal_Int32 nMax = MAX_PERCENT )
212{
213 OSL_ENSURE( (-nMax <= nOff) && (nOff <= nMax), "lclOffValue - invalid offset" );
214 ornValue = getLimitedValue< sal_Int32, sal_Int32 >( ornValue + nOff, 0, nMax );
215}
216
217} // namespace
218
220{
221 static std::unordered_map<OUString, model::ThemeColorType> const aSchemeColorNameToIndex{
226 { u"accent1", model::ThemeColorType::Accent1 },
227 { u"accent2", model::ThemeColorType::Accent2 },
228 { u"accent3", model::ThemeColorType::Accent3 },
229 { u"accent4", model::ThemeColorType::Accent4 },
230 { u"accent5", model::ThemeColorType::Accent5 },
231 { u"accent6", model::ThemeColorType::Accent6 },
241 { u"light2", model::ThemeColorType::Light2 },
243 { u"background1", model::ThemeColorType::Light1 },
245 { u"background2", model::ThemeColorType::Light2 },
246 { u"hyperlink", model::ThemeColorType::Hyperlink },
247 { u"followedHyperlink", model::ThemeColorType::FollowedHyperlink}
248 };
249
250 auto aIterator = aSchemeColorNameToIndex.find(rSchemeName);
251 if (aIterator == aSchemeColorNameToIndex.end())
253 else
254 return aIterator->second;
255}
256
258 meMode( COLOR_UNUSED ),
259 mnC1( 0 ),
260 mnC2( 0 ),
261 mnC3( 0 ),
262 mnAlpha( MAX_PERCENT )
263{
264}
265
266::Color Color::getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb )
267{
268 /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
269 able to catch the existing vector entries without corresponding XML
270 token identifier. */
271 ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maDmlColors, nToken, API_RGB_TRANSPARENT );
272 return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
273}
274
275::Color Color::getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb )
276{
277 /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
278 able to catch the existing vector entries without corresponding XML
279 token identifier. */
280 ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maVmlColors, nToken, API_RGB_TRANSPARENT );
281 return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
282}
283
284::Color Color::getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb)
285{
286 /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be
287 able to catch the existing vector entries without corresponding XML
288 token identifier. */
290 return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb;
291}
292
294{
296}
297
299{
300 setSrgbClr(sal_Int32(nRgb));
301}
302
303void Color::setSrgbClr( sal_Int32 nRgb )
304{
305 OSL_ENSURE( (0 <= nRgb) && (nRgb <= 0xFFFFFF), "Color::setSrgbClr - invalid RGB value" );
307 lclRgbToRgbComponents( mnC1, mnC2, mnC3, ::Color(ColorTransparency, nRgb) );
308}
309
310void Color::setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB )
311{
312 OSL_ENSURE( (0 <= nR) && (nR <= MAX_PERCENT), "Color::setScrgbClr - invalid red value" );
313 OSL_ENSURE( (0 <= nG) && (nG <= MAX_PERCENT), "Color::setScrgbClr - invalid green value" );
314 OSL_ENSURE( (0 <= nB) && (nB <= MAX_PERCENT), "Color::setScrgbClr - invalid blue value" );
316 mnC1 = getLimitedValue< sal_Int32, sal_Int32 >( nR, 0, MAX_PERCENT );
317 mnC2 = getLimitedValue< sal_Int32, sal_Int32 >( nG, 0, MAX_PERCENT );
318 mnC3 = getLimitedValue< sal_Int32, sal_Int32 >( nB, 0, MAX_PERCENT );
319}
320
321void Color::setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum )
322{
323 OSL_ENSURE( (0 <= nHue) && (nHue <= MAX_DEGREE), "Color::setHslClr - invalid hue value" );
324 OSL_ENSURE( (0 <= nSat) && (nSat <= MAX_PERCENT), "Color::setHslClr - invalid saturation value" );
325 OSL_ENSURE( (0 <= nLum) && (nLum <= MAX_PERCENT), "Color::setHslClr - invalid luminance value" );
327 mnC1 = getLimitedValue< sal_Int32, sal_Int32 >( nHue, 0, MAX_DEGREE );
328 mnC2 = getLimitedValue< sal_Int32, sal_Int32 >( nSat, 0, MAX_PERCENT );
329 mnC3 = getLimitedValue< sal_Int32, sal_Int32 >( nLum, 0, MAX_PERCENT );
330}
331
332void Color::setPrstClr( sal_Int32 nToken )
333{
335 OSL_ENSURE( sal_Int32(nRgbValue) >= 0, "Color::setPrstClr - invalid preset color token" );
336 if( sal_Int32(nRgbValue) >= 0 )
337 setSrgbClr( nRgbValue );
338}
339
340void Color::setHighlight(sal_Int32 nToken)
341{
343 OSL_ENSURE( sal_Int32(nRgbValue) >= 0, "Color::setPrstClr - invalid preset color token" );
344 if ( sal_Int32(nRgbValue) >= 0 )
345 setSrgbClr( nRgbValue );
346}
347
348void Color::setSchemeClr( sal_Int32 nToken )
349{
350 OSL_ENSURE( nToken != XML_TOKEN_INVALID, "Color::setSchemeClr - invalid color token" );
351 meMode = (nToken == XML_phClr) ? COLOR_PH : COLOR_SCHEME;
352 mnC1 = nToken;
353}
354
355void Color::setPaletteClr( sal_Int32 nPaletteIdx )
356{
357 OSL_ENSURE( nPaletteIdx >= 0, "Color::setPaletteClr - invalid palette index" );
359 mnC1 = nPaletteIdx;
360}
361
362void Color::setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb )
363{
364 OSL_ENSURE( (-1 <= nLastRgb) && (nLastRgb <= 0xFFFFFF), "Color::setSysClr - invalid RGB value" );
366 mnC1 = nToken;
367 mnC2 = nLastRgb;
368}
369
370void Color::addTransformation( sal_Int32 nElement, sal_Int32 nValue )
371{
372 /* Execute alpha transformations directly, store other transformations in
373 a vector, they may depend on a scheme base color which will be resolved
374 in Color::getColor(). */
375 sal_Int32 nToken = getBaseToken( nElement );
376 switch( nToken )
377 {
378 case XML_alpha: lclSetValue( mnAlpha, nValue ); break;
379 case XML_alphaMod: lclModValue( mnAlpha, nValue ); break;
380 case XML_alphaOff: lclOffValue( mnAlpha, nValue ); break;
381 default: maTransforms.emplace_back( nToken, nValue );
382 }
383 sal_Int32 nSize = maInteropTransformations.getLength();
384 maInteropTransformations.realloc(nSize + 1);
385 auto pInteropTransformations = maInteropTransformations.getArray();
386 pInteropTransformations[nSize].Name = getColorTransformationName( nToken );
387 pInteropTransformations[nSize].Value <<= nValue;
388}
389
391{
392 sal_Int32 nValue = getLimitedValue< sal_Int32, double >( fTint * MAX_PERCENT + 0.5, -MAX_PERCENT, MAX_PERCENT );
393 if( nValue < 0 )
394 maTransforms.emplace_back( XML_shade, nValue + MAX_PERCENT );
395 else if( nValue > 0 )
396 maTransforms.emplace_back( XML_tint, MAX_PERCENT - nValue );
397}
398
400{
401 sal_Int32 nValue = getLimitedValue< sal_Int32, double >( fTint * MAX_PERCENT + 0.5, -MAX_PERCENT, MAX_PERCENT );
402 maTransforms.emplace_back( XLS_TOKEN( tint ), nValue );
403}
404
406{
407 maTransforms.clear();
408 maInteropTransformations.realloc(0);
410}
411
412OUString Color::getColorTransformationName( sal_Int32 nElement )
413{
414 switch( nElement )
415 {
416 case XML_red: return "red";
417 case XML_redMod: return "redMod";
418 case XML_redOff: return "redOff";
419 case XML_green: return "green";
420 case XML_greenMod: return "greenMod";
421 case XML_greenOff: return "greenOff";
422 case XML_blue: return "blue";
423 case XML_blueMod: return "blueMod";
424 case XML_blueOff: return "blueOff";
425 case XML_alpha: return "alpha";
426 case XML_alphaMod: return "alphaMod";
427 case XML_alphaOff: return "alphaOff";
428 case XML_hue: return "hue";
429 case XML_hueMod: return "hueMod";
430 case XML_hueOff: return "hueOff";
431 case XML_sat: return "sat";
432 case XML_satMod: return "satMod";
433 case XML_satOff: return "satOff";
434 case XML_lum: return "lum";
435 case XML_lumMod: return "lumMod";
436 case XML_lumOff: return "lumOff";
437 case XML_shade: return "shade";
438 case XML_tint: return "tint";
439 case XML_gray: return "gray";
440 case XML_comp: return "comp";
441 case XML_inv: return "inv";
442 case XML_gamma: return "gamma";
443 case XML_invGamma: return "invGamma";
444 }
445 SAL_WARN( "oox.drawingml", "Color::getColorTransformationName - unexpected transformation type" );
446 return OUString();
447}
448
449sal_Int32 Color::getColorTransformationToken( std::u16string_view sName )
450{
451 if( sName == u"red" )
452 return XML_red;
453 else if( sName == u"redMod" )
454 return XML_redMod;
455 else if( sName == u"redOff" )
456 return XML_redOff;
457 else if( sName == u"green" )
458 return XML_green;
459 else if( sName == u"greenMod" )
460 return XML_greenMod;
461 else if( sName == u"greenOff" )
462 return XML_greenOff;
463 else if( sName == u"blue" )
464 return XML_blue;
465 else if( sName == u"blueMod" )
466 return XML_blueMod;
467 else if( sName == u"blueOff" )
468 return XML_blueOff;
469 else if( sName == u"alpha" )
470 return XML_alpha;
471 else if( sName == u"alphaMod" )
472 return XML_alphaMod;
473 else if( sName == u"alphaOff" )
474 return XML_alphaOff;
475 else if( sName == u"hue" )
476 return XML_hue;
477 else if( sName == u"hueMod" )
478 return XML_hueMod;
479 else if( sName == u"hueOff" )
480 return XML_hueOff;
481 else if( sName == u"sat" )
482 return XML_sat;
483 else if( sName == u"satMod" )
484 return XML_satMod;
485 else if( sName == u"satOff" )
486 return XML_satOff;
487 else if( sName == u"lum" )
488 return XML_lum;
489 else if( sName == u"lumMod" )
490 return XML_lumMod;
491 else if( sName == u"lumOff" )
492 return XML_lumOff;
493 else if( sName == u"shade" )
494 return XML_shade;
495 else if( sName == u"tint" )
496 return XML_tint;
497 else if( sName == u"gray" )
498 return XML_gray;
499 else if( sName == u"comp" )
500 return XML_comp;
501 else if( sName == u"inv" )
502 return XML_inv;
503 else if( sName == u"gamma" )
504 return XML_gamma;
505 else if( sName == u"invGamma" )
506 return XML_invGamma;
507
508 SAL_WARN( "oox.drawingml", "Color::getColorTransformationToken - unexpected transformation type" );
509 return XML_TOKEN_INVALID;
510}
511
512bool Color::equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const
513{
514 if (getColor(rGraphicHelper, nPhClr) != rOther.getColor(rGraphicHelper, nPhClr))
515 return false;
516
517 return getTransparency() == rOther.getTransparency();
518}
519
521{
523}
524
525sal_Int16 Color::getTintOrShade() const
526{
527 for(auto const& aTransform : maTransforms)
528 {
529 switch(aTransform.mnToken)
530 {
531 case XML_tint:
532 // from 1000th percent to 100th percent...
533 return aTransform.mnValue/10;
534 case XML_shade:
535 // from 1000th percent to 100th percent...
536 return -aTransform.mnValue/10;
537 }
538 }
539 return 0;
540}
541
542sal_Int16 Color::getLumMod() const
543{
544 for (const auto& rTransform : maTransforms)
545 {
546 if (rTransform.mnToken != XML_lumMod)
547 {
548 continue;
549 }
550
551 // From 1000th percent to 100th percent.
552 return rTransform.mnValue / 10;
553 }
554
555 return 10000;
556}
557
558sal_Int16 Color::getLumOff() const
559{
560 for (const auto& rTransform : maTransforms)
561 {
562 if (rTransform.mnToken != XML_lumOff)
563 {
564 continue;
565 }
566
567 // From 1000th percent to 100th percent.
568 return rTransform.mnValue / 10;
569 }
570
571 return 0;
572}
573
574::Color Color::getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr ) const
575{
576 const sal_Int32 nTempC1 = mnC1;
577 const sal_Int32 nTempC2 = mnC2;
578 const sal_Int32 nTempC3 = mnC3;
579 const ColorMode eTempMode = meMode;
580
581 switch( meMode )
582 {
583 case COLOR_UNUSED: mnC1 = sal_Int32(API_RGB_TRANSPARENT); break;
584
585 case COLOR_RGB: break; // nothing to do
586 case COLOR_CRGB: break; // nothing to do
587 case COLOR_HSL: break; // nothing to do
588
589 case COLOR_SCHEME: setResolvedRgb( rGraphicHelper.getSchemeColor( mnC1 ) ); break;
590 case COLOR_PALETTE: setResolvedRgb( rGraphicHelper.getPaletteColor( mnC1 ) ); break;
591 case COLOR_SYSTEM: setResolvedRgb( rGraphicHelper.getSystemColor( mnC1, ::Color(ColorTransparency, mnC2) ) ); break;
592 case COLOR_PH: setResolvedRgb( nPhClr ); break;
593
594 case COLOR_FINAL: return ::Color(ColorTransparency, mnC1);
595 }
596
597 // if color is UNUSED or turns to UNUSED in setResolvedRgb, do not perform transformations
598 if( meMode != COLOR_UNUSED )
599 {
600 for (auto const& transform : maTransforms)
601 {
602 switch( transform.mnToken )
603 {
604 case XML_red: toCrgb(); lclSetValue( mnC1, transform.mnValue ); break;
605 case XML_redMod: toCrgb(); lclModValue( mnC1, transform.mnValue ); break;
606 case XML_redOff: toCrgb(); lclOffValue( mnC1, transform.mnValue ); break;
607 case XML_green: toCrgb(); lclSetValue( mnC2, transform.mnValue ); break;
608 case XML_greenMod: toCrgb(); lclModValue( mnC2, transform.mnValue ); break;
609 case XML_greenOff: toCrgb(); lclOffValue( mnC2, transform.mnValue ); break;
610 case XML_blue: toCrgb(); lclSetValue( mnC3, transform.mnValue ); break;
611 case XML_blueMod: toCrgb(); lclModValue( mnC3, transform.mnValue ); break;
612 case XML_blueOff: toCrgb(); lclOffValue( mnC3, transform.mnValue ); break;
613
614 case XML_hue: toHsl(); lclSetValue( mnC1, transform.mnValue, MAX_DEGREE ); break;
615 case XML_hueMod: toHsl(); lclModValue( mnC1, transform.mnValue, MAX_DEGREE ); break;
616 case XML_hueOff: toHsl(); lclOffValue( mnC1, transform.mnValue, MAX_DEGREE ); break;
617 case XML_sat: toHsl(); lclSetValue( mnC2, transform.mnValue ); break;
618 case XML_satMod: toHsl(); lclModValue( mnC2, transform.mnValue ); break;
619 case XML_satOff: toHsl(); lclOffValue( mnC2, transform.mnValue ); break;
620
621 case XML_lum:
622 toHsl();
623 lclSetValue( mnC3, transform.mnValue );
624 // if color changes to black or white, it will stay gray if luminance changes again
625 if( (mnC3 == 0) || (mnC3 == MAX_PERCENT) ) mnC2 = 0;
626 break;
627 case XML_lumMod:
628 toHsl();
629 lclModValue( mnC3, transform.mnValue );
630 // if color changes to black or white, it will stay gray if luminance changes again
631 if( (mnC3 == 0) || (mnC3 == MAX_PERCENT) ) mnC2 = 0;
632 break;
633 case XML_lumOff:
634 toHsl();
635 lclOffValue( mnC3, transform.mnValue );
636 // if color changes to black or white, it will stay gray if luminance changes again
637 if( (mnC3 == 0) || (mnC3 == MAX_PERCENT) ) mnC2 = 0;
638 break;
639
640 case XML_shade:
641 // shade: 0% = black, 100% = original color
642 toCrgb();
643 OSL_ENSURE( (0 <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT), "Color::getColor - invalid shade value" );
644 if( (0 <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT) )
645 {
646 double fFactor = static_cast< double >( transform.mnValue ) / MAX_PERCENT;
647 mnC1 = static_cast< sal_Int32 >( mnC1 * fFactor );
648 mnC2 = static_cast< sal_Int32 >( mnC2 * fFactor );
649 mnC3 = static_cast< sal_Int32 >( mnC3 * fFactor );
650 }
651 break;
652 case XML_tint:
653 // tint: 0% = white, 100% = original color
654 toCrgb();
655 OSL_ENSURE( (0 <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT), "Color::getColor - invalid tint value" );
656 if( (0 <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT) )
657 {
658 double fFactor = static_cast< double >( transform.mnValue ) / MAX_PERCENT;
659 mnC1 = static_cast< sal_Int32 >( MAX_PERCENT - (MAX_PERCENT - mnC1) * fFactor );
660 mnC2 = static_cast< sal_Int32 >( MAX_PERCENT - (MAX_PERCENT - mnC2) * fFactor );
661 mnC3 = static_cast< sal_Int32 >( MAX_PERCENT - (MAX_PERCENT - mnC3) * fFactor );
662 }
663 break;
664 case XLS_TOKEN( tint ):
665 // Excel tint: move luminance relative to current value
666 toHsl();
667 OSL_ENSURE( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT), "Color::getColor - invalid tint value" );
668 if( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue < 0) )
669 {
670 // negative: luminance towards 0% (black)
671 lclModValue( mnC3, transform.mnValue + MAX_PERCENT );
672 }
673 else if( (0 < transform.mnValue) && (transform.mnValue <= MAX_PERCENT) )
674 {
675 // positive: luminance towards 100% (white)
677 lclModValue( mnC3, MAX_PERCENT - transform.mnValue );
679 }
680 break;
681
682 case XML_gray:
683 // change color to gray, weighted RGB: 22% red, 72% green, 6% blue
684 toRgb();
685 mnC1 = mnC2 = mnC3 = (mnC1 * 22 + mnC2 * 72 + mnC3 * 6) / 100;
686 break;
687
688 case XML_comp:
689 // comp: rotate hue by 180 degrees, do not change lum/sat
690 toHsl();
691 mnC1 = (mnC1 + (180 * PER_DEGREE)) % MAX_DEGREE;
692 break;
693 case XML_inv:
694 // invert percentual RGB values
695 toCrgb();
699 break;
700
701 case XML_gamma:
702 // increase gamma of color
703 toCrgb();
704 mnC1 = lclGamma( mnC1, INC_GAMMA );
705 mnC2 = lclGamma( mnC2, INC_GAMMA );
706 mnC3 = lclGamma( mnC3, INC_GAMMA );
707 break;
708 case XML_invGamma:
709 // decrease gamma of color
710 toCrgb();
711 mnC1 = lclGamma( mnC1, DEC_GAMMA );
712 mnC2 = lclGamma( mnC2, DEC_GAMMA );
713 mnC3 = lclGamma( mnC3, DEC_GAMMA );
714 break;
715 }
716 }
717
718 // store resulting RGB value in mnC1
719 toRgb();
720 mnC1 = lclRgbComponentsToRgb( mnC1, mnC2, mnC3 );
721 }
722 else // if( meMode != COLOR_UNUSED )
723 {
724 mnC1 = sal_Int32(API_RGB_TRANSPARENT);
725 }
726
727 sal_Int32 nRet = mnC1;
728 // Restore the original values when the color depends on one of the input
729 // parameters (rGraphicHelper or nPhClr)
730 if( eTempMode >= COLOR_SCHEME && eTempMode <= COLOR_PH )
731 {
732 mnC1 = nTempC1;
733 mnC2 = nTempC2;
734 mnC3 = nTempC3;
735 meMode = eTempMode;
736 }
737 else
738 {
740 }
741 if( meMode == COLOR_FINAL )
742 maTransforms.clear();
743 return ::Color(ColorTransparency, nRet);
744}
745
747{
748 return mnAlpha < MAX_PERCENT;
749}
750
751sal_Int16 Color::getTransparency() const
752{
753 return sal_Int16(std::round( (1.0 * (MAX_PERCENT - mnAlpha)) / PER_PERCENT) );
754}
755
757{
758 auto eThemeType = schemeNameToThemeColorType(msSchemeName);
759 return sal_Int16(eThemeType);
760}
761
762// private --------------------------------------------------------------------
763
765{
766 meMode = (sal_Int32(nRgb) < 0) ? COLOR_UNUSED : COLOR_RGB;
767 lclRgbToRgbComponents( mnC1, mnC2, mnC3, nRgb );
768}
769
770void Color::toRgb() const
771{
772 switch( meMode )
773 {
774 case COLOR_RGB:
775 // nothing to do
776 break;
777 case COLOR_CRGB:
779 mnC1 = lclCrgbCompToRgbComp( lclGamma( mnC1, INC_GAMMA ) );
780 mnC2 = lclCrgbCompToRgbComp( lclGamma( mnC2, INC_GAMMA ) );
781 mnC3 = lclCrgbCompToRgbComp( lclGamma( mnC3, INC_GAMMA ) );
782 break;
783 case COLOR_HSL:
784 {
786 double fR = 0.0, fG = 0.0, fB = 0.0;
787 if( (mnC2 == 0) || (mnC3 == MAX_PERCENT) )
788 {
789 fR = fG = fB = static_cast< double >( mnC3 ) / MAX_PERCENT;
790 }
791 else if( mnC3 > 0 )
792 {
793 // base color from hue
794 double fHue = static_cast< double >( mnC1 ) / MAX_DEGREE * 6.0; // interval [0.0, 6.0)
795 if( fHue <= 1.0 ) { fR = 1.0; fG = fHue; } // red...yellow
796 else if( fHue <= 2.0 ) { fR = 2.0 - fHue; fG = 1.0; } // yellow...green
797 else if( fHue <= 3.0 ) { fG = 1.0; fB = fHue - 2.0; } // green...cyan
798 else if( fHue <= 4.0 ) { fG = 4.0 - fHue; fB = 1.0; } // cyan...blue
799 else if( fHue <= 5.0 ) { fR = fHue - 4.0; fB = 1.0; } // blue...magenta
800 else { fR = 1.0; fB = 6.0 - fHue; } // magenta...red
801
802 // apply saturation
803 double fSat = static_cast< double >( mnC2 ) / MAX_PERCENT;
804 fR = (fR - 0.5) * fSat + 0.5;
805 fG = (fG - 0.5) * fSat + 0.5;
806 fB = (fB - 0.5) * fSat + 0.5;
807
808 // apply luminance
809 double fLum = 2.0 * static_cast< double >( mnC3 ) / MAX_PERCENT - 1.0; // interval [-1.0, 1.0]
810 if( fLum < 0.0 )
811 {
812 double fShade = fLum + 1.0; // interval [0.0, 1.0] (black...full color)
813 fR *= fShade;
814 fG *= fShade;
815 fB *= fShade;
816 }
817 else if( fLum > 0.0 )
818 {
819 double fTint = 1.0 - fLum; // interval [0.0, 1.0] (white...full color)
820 fR = 1.0 - ((1.0 - fR) * fTint);
821 fG = 1.0 - ((1.0 - fG) * fTint);
822 fB = 1.0 - ((1.0 - fB) * fTint);
823 }
824 }
825 mnC1 = static_cast< sal_Int32 >( fR * 255.0 + 0.5 );
826 mnC2 = static_cast< sal_Int32 >( fG * 255.0 + 0.5 );
827 mnC3 = static_cast< sal_Int32 >( fB * 255.0 + 0.5 );
828 }
829 break;
830 default:
831 OSL_FAIL( "Color::toRgb - unexpected color mode" );
832 }
833}
834
835void Color::toCrgb() const
836{
837 switch( meMode )
838 {
839 case COLOR_HSL:
840 toRgb();
841 [[fallthrough]];
842 case COLOR_RGB:
844 mnC1 = lclGamma( lclRgbCompToCrgbComp( mnC1 ), DEC_GAMMA );
845 mnC2 = lclGamma( lclRgbCompToCrgbComp( mnC2 ), DEC_GAMMA );
846 mnC3 = lclGamma( lclRgbCompToCrgbComp( mnC3 ), DEC_GAMMA );
847 break;
848 case COLOR_CRGB:
849 // nothing to do
850 break;
851 default:
852 OSL_FAIL( "Color::toCrgb - unexpected color mode" );
853 }
854}
855
856void Color::toHsl() const
857{
858 switch( meMode )
859 {
860 case COLOR_CRGB:
861 toRgb();
862 [[fallthrough]];
863 case COLOR_RGB:
864 {
866 double fR = static_cast< double >( mnC1 ) / 255.0; // red [0.0, 1.0]
867 double fG = static_cast< double >( mnC2 ) / 255.0; // green [0.0, 1.0]
868 double fB = static_cast< double >( mnC3 ) / 255.0; // blue [0.0, 1.0]
869 double fMin = ::std::min( ::std::min( fR, fG ), fB );
870 double fMax = ::std::max( ::std::max( fR, fG ), fB );
871 double fD = fMax - fMin;
872
873 using ::rtl::math::approxEqual;
874
875 // hue: 0deg = red, 120deg = green, 240deg = blue
876 if( fD == 0.0 ) // black/gray/white
877 mnC1 = 0;
878 else if( approxEqual(fMax, fR, 64) ) // magenta...red...yellow
879 mnC1 = static_cast< sal_Int32 >( ((fG - fB) / fD * 60.0 + 360.0) * PER_DEGREE + 0.5 ) % MAX_DEGREE;
880 else if( approxEqual(fMax, fG, 64) ) // yellow...green...cyan
881 mnC1 = static_cast< sal_Int32 >( ((fB - fR) / fD * 60.0 + 120.0) * PER_DEGREE + 0.5 );
882 else // cyan...blue...magenta
883 mnC1 = static_cast< sal_Int32 >( ((fR - fG) / fD * 60.0 + 240.0) * PER_DEGREE + 0.5 );
884
885 // luminance: 0% = black, 50% = full color, 100% = white
886 mnC3 = static_cast< sal_Int32 >( (fMin + fMax) / 2.0 * MAX_PERCENT + 0.5 );
887
888 // saturation: 0% = gray, 100% = full color
889 if( (mnC3 == 0) || (mnC3 == MAX_PERCENT) ) // black/white
890 mnC2 = 0;
891 else if( mnC3 <= 50 * PER_PERCENT ) // dark...full color
892 mnC2 = static_cast< sal_Int32 >( fD / (fMin + fMax) * MAX_PERCENT + 0.5 );
893 else // full color...light
894 mnC2 = static_cast< sal_Int32 >( fD / (2.0 - fMax - fMin) * MAX_PERCENT + 0.5 );
895 }
896 break;
897 case COLOR_HSL:
898 // nothing to do
899 break;
900 default:
901 OSL_FAIL( "Color::toHsl - unexpected color mode" );
902 }
903}
904
905} // namespace oox
906
907/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
constexpr Color()
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
Returns the pointer to an existing element of the passed vector, or a null pointer,...
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
virtual ::Color getPaletteColor(sal_Int32 nPaletteIdx) const
Derived classes may implement to resolve a palette index to an RGB color.
virtual ::Color getSchemeColor(sal_Int32 nToken) const
Derived classes may implement to resolve a scheme color from the passed XML token identifier.
::Color getSystemColor(sal_Int32 nToken, ::Color nDefaultRgb=API_RGB_TRANSPARENT) const
Returns a system color specified by the passed XML token identifier.
void toCrgb() const
Converts the color components to CRGB values (gamma corrected percentage).
Definition: color.cxx:835
sal_Int16 getTintOrShade() const
Definition: color.cxx:525
sal_Int16 getLumMod() const
Definition: color.cxx:542
sal_Int16 getTransparency() const
Returns the transparency of the color (0 = opaque, 100 = full transparent).
Definition: color.cxx:751
void addTransformation(sal_Int32 nElement, sal_Int32 nValue=-1)
Inserts the passed color transformation.
Definition: color.cxx:370
void setPrstClr(sal_Int32 nToken)
Sets a predefined color from the a:prstClr element.
Definition: color.cxx:332
void setPaletteClr(sal_Int32 nPaletteIdx)
Sets a palette color index.
Definition: color.cxx:355
void setScrgbClr(sal_Int32 nR, sal_Int32 nG, sal_Int32 nB)
Sets the percentual RGB values from the a:scrgbClr element.
Definition: color.cxx:310
@ COLOR_SYSTEM
Color from application defined palette.
Definition: color.hxx:140
@ COLOR_RGB
Color is not used, or undefined.
Definition: color.hxx:135
@ COLOR_HSL
Relative RGB (r/g/b: 0...100000).
Definition: color.hxx:137
@ COLOR_FINAL
Placeholder color in theme style lists.
Definition: color.hxx:142
@ COLOR_CRGB
Absolute RGB (r/g/b: 0...255).
Definition: color.hxx:136
@ COLOR_PALETTE
Color from scheme.
Definition: color.hxx:139
@ COLOR_SCHEME
HSL (hue: 0...21600000, sat/lum: 0...100000).
Definition: color.hxx:138
@ COLOR_PH
Color from system palette.
Definition: color.hxx:141
ColorMode meMode
Definition: color.hxx:153
static OUString getColorTransformationName(sal_Int32 nElement)
Translates between color transformation tokens and their names.
Definition: color.cxx:412
void setResolvedRgb(::Color nRgb) const
Internal helper for getColor().
Definition: color.cxx:764
void toRgb() const
Converts the color components to RGB values.
Definition: color.cxx:770
void addExcelTintTransformation(double fTint)
Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint).
Definition: color.cxx:399
void setSchemeClr(sal_Int32 nToken)
Sets a scheme color from the a:schemeClr element.
Definition: color.cxx:348
void addChartTintTransformation(double fTint)
Inserts Chart specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint).
Definition: color.cxx:390
void clearTransformations()
Removes all color transformations.
Definition: color.cxx:405
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:156
void setUnused()
Sets the color to unused state.
Definition: color.cxx:293
void setHighlight(sal_Int32 nToken)
Sets a predefined color from the w:highlight element.
Definition: color.cxx:340
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:163
sal_Int32 mnAlpha
Blue, blue%, or luminance.
Definition: color.hxx:159
void setHslClr(sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum)
Sets the HSL values from the a:hslClr element.
Definition: color.cxx:321
sal_Int16 getLumOff() const
Definition: color.cxx:558
void clearTransparence()
Removes transparence from the color.
Definition: color.cxx:520
bool equals(const Color &rOther, const GraphicHelper &rGraphicHelper, ::Color nPhClr) const
Compares this color with rOther.
Definition: color.cxx:512
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:155
OUString msSchemeName
Alpha value (color opacity).
Definition: color.hxx:161
void setSysClr(sal_Int32 nToken, sal_Int32 nLastRgb)
Sets a system color from the a:sysClr element.
Definition: color.cxx:362
void toHsl() const
Converts the color components to HSL values.
Definition: color.cxx:856
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:157
bool hasTransparency() const
Returns true, if the color is transparent.
Definition: color.cxx:746
::Color getDmlPresetColor(sal_Int32 nToken, ::Color nDefaultRgb)
Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error.
Definition: color.cxx:266
sal_Int16 getSchemeColorIndex() const
Definition: color.cxx:756
static sal_Int32 getColorTransformationToken(std::u16string_view sName)
Translates between color transformation token names and the corresponding token.
Definition: color.cxx:449
sal_Int32 mnC3
Green, green%, saturation, or system default RGB.
Definition: color.hxx:158
::Color getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb)
Returns the RGB value for the passed VML color token, or nDefaultRgb on error.
Definition: color.cxx:284
::Color getVmlPresetColor(sal_Int32 nToken, ::Color nDefaultRgb)
Returns the RGB value for the passed VML color token, or nDefaultRgb on error.
Definition: color.cxx:275
::Color getColor(const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
Definition: color.cxx:574
void setSrgbClr(sal_Int32 nRgb)
Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element.
Definition: color.cxx:303
ColorVector maHighlightColors
Predefined colors in VML, indexed by XML token.
Definition: color.cxx:43
ColorVector maVmlColors
Predefined colors in DrawingML, indexed by XML token.
Definition: color.cxx:42
ColorVector maDmlColors
Definition: color.cxx:41
ColorTransparency
ColorMode meMode
OString sName
Definition: drawingml.cxx:4478
float u
sal_Int16 nValue
#define SAL_WARN(area, stream)
ThemeColorType
model::ThemeColorType schemeNameToThemeColorType(OUString const &rSchemeName)
Definition: color.cxx:219
const sal_Int32 MAX_DEGREE
const sal_Int32 MAX_PERCENT
const sal_Int32 PER_DEGREE
const sal_Int32 PER_PERCENT
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
XML_TOKEN_INVALID
DefTokenId nToken