LibreOffice Module oox (master) 1
color.hxx
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
20#ifndef INCLUDED_OOX_DRAWINGML_COLOR_HXX
21#define INCLUDED_OOX_DRAWINGML_COLOR_HXX
22
23#include <vector>
24
25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/uno/Sequence.hxx>
27#include <oox/helper/helper.hxx>
28#include <oox/dllapi.h>
29#include <rtl/ustring.hxx>
30#include <sal/types.h>
31#include <tools/color.hxx>
34
35namespace oox { class GraphicHelper; }
36
37namespace oox::drawingml
38{
39
41model::ThemeColorType schemeNameToThemeColorType(OUString const& rSchemeName);
42
44{
45public:
46 Color();
47
49 static ::Color getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
51 static ::Color getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
53 static ::Color getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb);
54
56 void setUnused();
58 void setSrgbClr( sal_Int32 nRgb );
59 void setSrgbClr( ::Color nRgb );
61 void setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB );
63 void setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum );
65 void setPrstClr( sal_Int32 nToken );
67 void setHighlight(sal_Int32 nToken);
69 void setSchemeClr( sal_Int32 nToken );
71 void setSchemeName( const OUString& sSchemeName ) { msSchemeName = sSchemeName; }
73 void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb );
75 void setPaletteClr( sal_Int32 nPaletteIdx );
76
78 void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 );
80 void addChartTintTransformation( double fTint );
82 void addExcelTintTransformation( double fTint );
84 void clearTransformations();
86 void clearTransparence();
87
89 void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; }
90
92 bool isUsed() const { return meMode != COLOR_UNUSED; }
94 bool isPlaceHolder() const { return meMode == COLOR_PH; }
97 ::Color getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr = API_RGB_TRANSPARENT ) const;
98
100 bool hasTransparency() const;
102 sal_Int16 getTransparency() const;
103
105 const OUString& getSchemeColorName() const { return msSchemeName; }
106 sal_Int16 getSchemeColorIndex() const;
107 sal_Int16 getTintOrShade() const;
108 sal_Int16 getLumMod() const;
109 sal_Int16 getLumOff() const;
110
112 {
113 return meThemeColorType;
114 }
115
116 model::ComplexColor createComplexColor(const GraphicHelper& rGraphicHelper, sal_Int16 nPhClrTheme) const;
117
119 const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
120
122 static OUString getColorTransformationName( sal_Int32 nElement );
124 static sal_Int32 getColorTransformationToken( std::u16string_view sName );
125
127 bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const;
128
129 model::ComplexColor getComplexColor() const;
130
131private:
133 void setResolvedRgb( ::Color nRgb ) const;
134
136 void toRgb() const;
138 void toCrgb() const;
140 void toHsl() const;
141
142private:
144 {
153 COLOR_FINAL
154 };
155
157 {
158 sal_Int32 mnToken;
159 sal_Int32 mnValue;
160
161 explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {}
162 };
163
165 mutable std::vector< Transformation >
167 mutable sal_Int32 mnC1;
168 mutable sal_Int32 mnC2;
169 mutable sal_Int32 mnC3;
170 sal_Int32 mnAlpha;
171 OUString msSchemeName;
173 css::uno::Sequence< css::beans::PropertyValue >
175};
176
177} // namespace oox::drawingml
178
179#endif
180
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
model::ThemeColorType getThemeColorType() const
Definition: color.hxx:111
bool isPlaceHolder() const
Returns true, if the color is a placeholder color in theme style lists.
Definition: color.hxx:94
const OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:105
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
Definition: color.hxx:89
@ 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
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:167
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Definition: color.hxx:174
sal_Int32 mnAlpha
Blue, blue%, or luminance.
Definition: color.hxx:170
model::ThemeColorType meThemeColorType
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:172
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:166
OUString msSchemeName
Alpha value (color opacity).
Definition: color.hxx:171
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:168
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:92
sal_Int32 mnC3
Green, green%, saturation, or system default RGB.
Definition: color.hxx:169
void setSchemeName(const OUString &sSchemeName)
Sets the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:71
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:119
ColorMode meMode
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
OString sName
Definition: drawingml.cxx:4451
sal_Int16 nValue
ThemeColorType
model::ThemeColorType schemeNameToThemeColorType(OUString const &rSchemeName)
Definition: color.cxx:274
model::ThemeColorType schemeTokenToThemeColorType(sal_uInt32 nToken)
Definition: color.cxx:283
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
DefTokenId nToken
const double mnValue
Transformation(sal_Int32 nToken, sal_Int32 nValue)
Definition: color.hxx:161