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>
32
33namespace oox { class GraphicHelper; }
34
35namespace oox::drawingml {
36
37
39{
40public:
41 Color();
42
44 static ::Color getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
46 static ::Color getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
48 static ::Color getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb);
49
51 void setUnused();
53 void setSrgbClr( sal_Int32 nRgb );
54 void setSrgbClr( ::Color nRgb );
56 void setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB );
58 void setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum );
60 void setPrstClr( sal_Int32 nToken );
62 void setHighlight(sal_Int32 nToken);
64 void setSchemeClr( sal_Int32 nToken );
66 void setSchemeName( const OUString& sSchemeName ) { msSchemeName = sSchemeName; }
68 void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb );
70 void setPaletteClr( sal_Int32 nPaletteIdx );
71
73 void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 );
75 void addChartTintTransformation( double fTint );
77 void addExcelTintTransformation( double fTint );
79 void clearTransformations();
81 void clearTransparence();
82
84 void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; }
85
87 bool isUsed() const { return meMode != COLOR_UNUSED; }
89 bool isPlaceHolder() const { return meMode == COLOR_PH; }
92 ::Color getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr = API_RGB_TRANSPARENT ) const;
93
95 bool hasTransparency() const;
97 sal_Int16 getTransparency() const;
98
100 const OUString& getSchemeColorName() const { return msSchemeName; }
101 sal_Int16 getSchemeColorIndex() const;
102 sal_Int16 getTintOrShade() const;
103 sal_Int16 getLumMod() const;
104 sal_Int16 getLumOff() const;
105
107 const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
108
110 static OUString getColorTransformationName( sal_Int32 nElement );
112 static sal_Int32 getColorTransformationToken( std::u16string_view sName );
113
115 bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const;
116
117private:
119 void setResolvedRgb( ::Color nRgb ) const;
120
122 void toRgb() const;
124 void toCrgb() const;
126 void toHsl() const;
127
128private:
130 {
139 COLOR_FINAL
140 };
141
143 {
144 sal_Int32 mnToken;
145 sal_Int32 mnValue;
146
147 explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {}
148 };
149
151 mutable std::vector< Transformation >
153 mutable sal_Int32 mnC1;
154 mutable sal_Int32 mnC2;
155 mutable sal_Int32 mnC3;
156 sal_Int32 mnAlpha;
157
158 OUString msSchemeName;
159 css::uno::Sequence< css::beans::PropertyValue >
161};
162
163} // namespace oox::drawingml
164
165#endif
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
bool isPlaceHolder() const
Returns true, if the color is a placeholder color in theme style lists.
Definition: color.hxx:89
const OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:100
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
Definition: color.hxx:84
@ COLOR_SYSTEM
Color from application defined palette.
Definition: color.hxx:137
@ COLOR_RGB
Color is not used, or undefined.
Definition: color.hxx:132
@ COLOR_HSL
Relative RGB (r/g/b: 0...100000).
Definition: color.hxx:134
@ COLOR_CRGB
Absolute RGB (r/g/b: 0...255).
Definition: color.hxx:133
@ COLOR_PALETTE
Color from scheme.
Definition: color.hxx:136
@ COLOR_SCHEME
HSL (hue: 0...21600000, sat/lum: 0...100000).
Definition: color.hxx:135
@ COLOR_PH
Color from system palette.
Definition: color.hxx:138
ColorMode meMode
Definition: color.hxx:150
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:153
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:160
sal_Int32 mnAlpha
Blue, blue%, or luminance.
Definition: color.hxx:156
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:152
OUString msSchemeName
Alpha value (color opacity).
Definition: color.hxx:158
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:154
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:87
sal_Int32 mnC3
Green, green%, saturation, or system default RGB.
Definition: color.hxx:155
void setSchemeName(const OUString &sSchemeName)
Sets the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:66
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:107
ColorMode meMode
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
OString sName
Definition: drawingml.cxx:4066
sal_Int16 nValue
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:147