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