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& getSchemeName() const { return msSchemeName; }
102  const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
103 
105  static OUString getColorTransformationName( sal_Int32 nElement );
107  static sal_Int32 getColorTransformationToken( std::u16string_view sName );
108 
110  bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const;
111 
112 private:
114  void setResolvedRgb( ::Color nRgb ) const;
115 
117  void toRgb() const;
119  void toCrgb() const;
121  void toHsl() const;
122 
123 private:
125  {
134  COLOR_FINAL
135  };
136 
138  {
139  sal_Int32 mnToken;
140  sal_Int32 mnValue;
141 
142  explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {}
143  };
144 
145  mutable ColorMode meMode;
146  mutable std::vector< Transformation >
148  mutable sal_Int32 mnC1;
149  mutable sal_Int32 mnC2;
150  mutable sal_Int32 mnC3;
151  sal_Int32 mnAlpha;
152 
153  OUString msSchemeName;
154  css::uno::Sequence< css::beans::PropertyValue >
156 };
157 
158 } // namespace oox::drawingml
159 
160 #endif
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Relative RGB (r/g/b: 0...100000).
Definition: color.hxx:129
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
Absolute RGB (r/g/b: 0...255).
Definition: color.hxx:128
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:150
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:149
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:147
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:155
const OUString & getSchemeName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:100
Transformation(sal_Int32 nToken, sal_Int32 nValue)
Definition: color.hxx:142
HSL (hue: 0...21600000, sat/lum: 0...100000).
Definition: color.hxx:130
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:151
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:102
DefTokenId nToken
Color from application defined palette.
Definition: color.hxx:132
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:148
ColorMode meMode
Definition: color.hxx:145
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:153
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
Color is not used, or undefined.
Definition: color.hxx:127
Color from system palette.
Definition: color.hxx:133
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
Definition: color.hxx:84