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>
33
34namespace oox { class GraphicHelper; }
35
36namespace oox::drawingml
37{
38
39model::ThemeColorType schemeNameToThemeColorType(OUString const& rSchemeName);
40
42{
43public:
44 Color();
45
47 static ::Color getDmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
49 static ::Color getVmlPresetColor( sal_Int32 nToken, ::Color nDefaultRgb );
51 static ::Color getHighlightColor(sal_Int32 nToken, ::Color nDefaultRgb);
52
54 void setUnused();
56 void setSrgbClr( sal_Int32 nRgb );
57 void setSrgbClr( ::Color nRgb );
59 void setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB );
61 void setHslClr( sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum );
63 void setPrstClr( sal_Int32 nToken );
65 void setHighlight(sal_Int32 nToken);
67 void setSchemeClr( sal_Int32 nToken );
69 void setSchemeName( const OUString& sSchemeName ) { msSchemeName = sSchemeName; }
71 void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb );
73 void setPaletteClr( sal_Int32 nPaletteIdx );
74
76 void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 );
78 void addChartTintTransformation( double fTint );
80 void addExcelTintTransformation( double fTint );
82 void clearTransformations();
84 void clearTransparence();
85
87 void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; }
88
90 bool isUsed() const { return meMode != COLOR_UNUSED; }
92 bool isPlaceHolder() const { return meMode == COLOR_PH; }
95 ::Color getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr = API_RGB_TRANSPARENT ) const;
96
98 bool hasTransparency() const;
100 sal_Int16 getTransparency() const;
101
103 const OUString& getSchemeColorName() const { return msSchemeName; }
104 sal_Int16 getSchemeColorIndex() const;
105 sal_Int16 getTintOrShade() const;
106 sal_Int16 getLumMod() const;
107 sal_Int16 getLumOff() const;
108
110 const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
111
113 static OUString getColorTransformationName( sal_Int32 nElement );
115 static sal_Int32 getColorTransformationToken( std::u16string_view sName );
116
118 bool equals(const Color& rOther, const GraphicHelper& rGraphicHelper, ::Color nPhClr) const;
119
120private:
122 void setResolvedRgb( ::Color nRgb ) const;
123
125 void toRgb() const;
127 void toCrgb() const;
129 void toHsl() const;
130
131private:
133 {
142 COLOR_FINAL
143 };
144
146 {
147 sal_Int32 mnToken;
148 sal_Int32 mnValue;
149
150 explicit Transformation( sal_Int32 nToken, sal_Int32 nValue ) : mnToken( nToken ), mnValue( nValue ) {}
151 };
152
154 mutable std::vector< Transformation >
156 mutable sal_Int32 mnC1;
157 mutable sal_Int32 mnC2;
158 mutable sal_Int32 mnC3;
159 sal_Int32 mnAlpha;
160
161 OUString msSchemeName;
162 css::uno::Sequence< css::beans::PropertyValue >
164};
165
166} // namespace oox::drawingml
167
168#endif
169
170/* 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:92
const OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:103
void assignIfUsed(const Color &rColor)
Overwrites this color with the passed color, if it is used.
Definition: color.hxx:87
@ COLOR_SYSTEM
Color from application defined palette.
Definition: color.hxx:140
@ COLOR_RGB
Color is not used, or undefined.
Definition: color.hxx:135
@ COLOR_HSL
Relative RGB (r/g/b: 0...100000).
Definition: color.hxx:137
@ COLOR_CRGB
Absolute RGB (r/g/b: 0...255).
Definition: color.hxx:136
@ COLOR_PALETTE
Color from scheme.
Definition: color.hxx:139
@ COLOR_SCHEME
HSL (hue: 0...21600000, sat/lum: 0...100000).
Definition: color.hxx:138
@ COLOR_PH
Color from system palette.
Definition: color.hxx:141
ColorMode meMode
Definition: color.hxx:153
sal_Int32 mnC1
Color transformations.
Definition: color.hxx:156
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
Scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:163
sal_Int32 mnAlpha
Blue, blue%, or luminance.
Definition: color.hxx:159
std::vector< Transformation > maTransforms
Current color mode.
Definition: color.hxx:155
OUString msSchemeName
Alpha value (color opacity).
Definition: color.hxx:161
sal_Int32 mnC2
Red, red%, hue, scheme token, palette index, system token, or final RGB.
Definition: color.hxx:157
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:90
sal_Int32 mnC3
Green, green%, saturation, or system default RGB.
Definition: color.hxx:158
void setSchemeName(const OUString &sSchemeName)
Sets the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:69
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:110
ColorMode meMode
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
OString sName
Definition: drawingml.cxx:4478
sal_Int16 nValue
ThemeColorType
model::ThemeColorType schemeNameToThemeColorType(OUString const &rSchemeName)
Definition: color.cxx:219
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:150