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 
33 namespace oox { class GraphicHelper; }
34 
35 namespace oox::drawingml {
36 
37 
39 {
40 public:
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();
103  sal_Int16 getLumMod();
104  sal_Int16 getLumOff();
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 
117 private:
119  void setResolvedRgb( ::Color nRgb ) const;
120 
122  void toRgb() const;
124  void toCrgb() const;
126  void toHsl() const;
127 
128 private:
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 
150  mutable ColorMode meMode;
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: */
Relative RGB (r/g/b: 0...100000).
Definition: color.hxx:134
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
Absolute RGB (r/g/b: 0...255).
Definition: color.hxx:133
const OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:100
const char * sName
Definition: olehelper.cxx:92
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
sal_Int32 mnC3
Green, green%, saturation, or system default RGB.
Definition: color.hxx:155
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:154
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:152
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:160
Transformation(sal_Int32 nToken, sal_Int32 nValue)
Definition: color.hxx:147
HSL (hue: 0...21600000, sat/lum: 0...100000).
Definition: color.hxx:135
ColorMode meMode
void setSchemeName(const OUString &sSchemeName)
Sets the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:66
sal_Int32 mnAlpha
Blue, blue%, or luminance.
Definition: color.hxx:156
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:87
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:107
DefTokenId nToken
Color from application defined palette.
Definition: color.hxx:137
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:153
ColorMode meMode
Definition: color.hxx:150
bool isPlaceHolder() const
Returns true, if the color is a placeholder color in theme style lists.
Definition: color.hxx:89
OUString msSchemeName
Alpha value (color opacity).
Definition: color.hxx:158
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
Color is not used, or undefined.
Definition: color.hxx:132
Color from system palette.
Definition: color.hxx:138
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
Definition: color.hxx:84