LibreOffice Module oox (master) 1
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
oox::drawingml::Color Class Reference

#include <color.hxx>

Inheritance diagram for oox::drawingml::Color:
[legend]

Classes

struct  Transformation
 

Public Member Functions

 Color ()
 
void setUnused ()
 Sets the color to unused state. More...
 
void setSrgbClr (sal_Int32 nRgb)
 Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element. More...
 
void setSrgbClr (::Color nRgb)
 
void setScrgbClr (sal_Int32 nR, sal_Int32 nG, sal_Int32 nB)
 Sets the percentual RGB values from the a:scrgbClr element. More...
 
void setHslClr (sal_Int32 nHue, sal_Int32 nSat, sal_Int32 nLum)
 Sets the HSL values from the a:hslClr element. More...
 
void setPrstClr (sal_Int32 nToken)
 Sets a predefined color from the a:prstClr element. More...
 
void setHighlight (sal_Int32 nToken)
 Sets a predefined color from the w:highlight element. More...
 
void setSchemeClr (sal_Int32 nToken)
 Sets a scheme color from the a:schemeClr element. More...
 
void setSchemeName (const OUString &sSchemeName)
 Sets the scheme name from the a:schemeClr element for interoperability purposes. More...
 
void setSysClr (sal_Int32 nToken, sal_Int32 nLastRgb)
 Sets a system color from the a:sysClr element. More...
 
void setPaletteClr (sal_Int32 nPaletteIdx)
 Sets a palette color index. More...
 
void addTransformation (sal_Int32 nElement, sal_Int32 nValue=-1)
 Inserts the passed color transformation. More...
 
void addChartTintTransformation (double fTint)
 Inserts Chart specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). More...
 
void addExcelTintTransformation (double fTint)
 Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). More...
 
void clearTransformations ()
 Removes all color transformations. More...
 
void clearTransparence ()
 Removes transparence from the color. More...
 
void assignIfUsed (const Color &rColor)
 Overwrites this color with the passed color, if it is used. More...
 
bool isUsed () const
 Returns true, if the color is initialized. More...
 
bool isPlaceHolder () const
 Returns true, if the color is a placeholder color in theme style lists. More...
 
::Color getColor (const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
 Returns the final RGB color value. More...
 
bool hasTransparency () const
 Returns true, if the color is transparent. More...
 
sal_Int16 getTransparency () const
 Returns the transparency of the color (0 = opaque, 100 = full transparent). More...
 
const OUString & getSchemeColorName () const
 Returns the scheme name from the a:schemeClr element for interoperability purposes. More...
 
sal_Int16 getSchemeColorIndex () const
 
sal_Int16 getTintOrShade () const
 
sal_Int16 getLumMod () const
 
sal_Int16 getLumOff () const
 
model::ThemeColorType getThemeColorType () const
 
model::ComplexColor createComplexColor (const GraphicHelper &rGraphicHelper, sal_Int16 nPhClrTheme) const
 
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations () const
 Returns the unaltered list of transformations for interoperability purposes. More...
 
bool equals (const Color &rOther, const GraphicHelper &rGraphicHelper, ::Color nPhClr) const
 Compares this color with rOther. More...
 
model::ComplexColor getComplexColor () const
 

Static Public Member Functions

::Color getDmlPresetColor (sal_Int32 nToken, ::Color nDefaultRgb)
 Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error. More...
 
::Color getVmlPresetColor (sal_Int32 nToken, ::Color nDefaultRgb)
 Returns the RGB value for the passed VML color token, or nDefaultRgb on error. More...
 
::Color getHighlightColor (sal_Int32 nToken, ::Color nDefaultRgb)
 Returns the RGB value for the passed VML color token, or nDefaultRgb on error. More...
 
static OUString getColorTransformationName (sal_Int32 nElement)
 Translates between color transformation tokens and their names. More...
 
static sal_Int32 getColorTransformationToken (std::u16string_view sName)
 Translates between color transformation token names and the corresponding token. More...
 

Private Types

enum  ColorMode {
  COLOR_UNUSED ,
  COLOR_RGB ,
  COLOR_CRGB ,
  COLOR_HSL ,
  COLOR_SCHEME ,
  COLOR_PALETTE ,
  COLOR_SYSTEM ,
  COLOR_PH ,
  COLOR_FINAL
}
 

Private Member Functions

void setResolvedRgb (::Color nRgb) const
 Internal helper for getColor(). More...
 
void toRgb () const
 Converts the color components to RGB values. More...
 
void toCrgb () const
 Converts the color components to CRGB values (gamma corrected percentage). More...
 
void toHsl () const
 Converts the color components to HSL values. More...
 

Private Attributes

ColorMode meMode
 
std::vector< TransformationmaTransforms
 Current color mode. More...
 
sal_Int32 mnC1
 Color transformations. More...
 
sal_Int32 mnC2
 Red, red%, hue, scheme token, palette index, system token, or final RGB. More...
 
sal_Int32 mnC3
 Green, green%, saturation, or system default RGB. More...
 
sal_Int32 mnAlpha
 Blue, blue%, or luminance. More...
 
OUString msSchemeName
 Alpha value (color opacity). More...
 
model::ThemeColorType meThemeColorType
 Scheme name from the a:schemeClr element for interoperability purposes. More...
 
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
 

Detailed Description

Definition at line 43 of file color.hxx.

Member Enumeration Documentation

◆ ColorMode

Enumerator
COLOR_UNUSED 
COLOR_RGB 

Color is not used, or undefined.

COLOR_CRGB 

Absolute RGB (r/g/b: 0...255).

COLOR_HSL 

Relative RGB (r/g/b: 0...100000).

COLOR_SCHEME 

HSL (hue: 0...21600000, sat/lum: 0...100000).

COLOR_PALETTE 

Color from scheme.

COLOR_SYSTEM 

Color from application defined palette.

COLOR_PH 

Color from system palette.

COLOR_FINAL 

Placeholder color in theme style lists.

Finalized RGB color.

Definition at line 143 of file color.hxx.

Constructor & Destructor Documentation

◆ Color()

Color::Color ( )

Definition at line 292 of file color.cxx.

References meMode, and Unknown.

Referenced by oox::drawingml::table::applyLineAttributes().

Member Function Documentation

◆ addChartTintTransformation()

void Color::addChartTintTransformation ( double  fTint)

Inserts Chart specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint).

Definition at line 428 of file color.cxx.

References maTransforms, oox::drawingml::MAX_PERCENT, and nValue.

◆ addExcelTintTransformation()

void Color::addExcelTintTransformation ( double  fTint)

Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint).

Definition at line 437 of file color.cxx.

References maTransforms, and nValue.

◆ addTransformation()

void Color::addTransformation ( sal_Int32  nElement,
sal_Int32  nValue = -1 
)

◆ assignIfUsed()

void oox::drawingml::Color::assignIfUsed ( const Color rColor)
inline

◆ clearTransformations()

void Color::clearTransformations ( )

Removes all color transformations.

Definition at line 451 of file color.cxx.

References clearTransparence(), maInteropTransformations, and maTransforms.

Referenced by oox::drawingml::Shape::createAndInsert(), and oox::drawingml::table::TableCell::pushToXCell().

◆ clearTransparence()

void Color::clearTransparence ( )

Removes transparence from the color.

Definition at line 566 of file color.cxx.

References oox::drawingml::MAX_PERCENT, and mnAlpha.

Referenced by clearTransformations(), and oox::drawingml::ColorChangeContext::~ColorChangeContext().

◆ createComplexColor()

model::ComplexColor Color::createComplexColor ( const GraphicHelper rGraphicHelper,
sal_Int16  nPhClrTheme 
) const

◆ equals()

bool Color::equals ( const Color rOther,
const GraphicHelper rGraphicHelper,
::Color  nPhClr 
) const

Compares this color with rOther.

Definition at line 558 of file color.cxx.

References getColor(), and getTransparency().

◆ getColor()

Color Color::getColor ( const GraphicHelper rGraphicHelper,
::Color  nPhClr = API_RGB_TRANSPARENT 
) const

◆ getColorTransformationName()

OUString Color::getColorTransformationName ( sal_Int32  nElement)
static

Translates between color transformation tokens and their names.

Definition at line 458 of file color.cxx.

References SAL_WARN.

Referenced by addTransformation().

◆ getColorTransformationToken()

sal_Int32 Color::getColorTransformationToken ( std::u16string_view  sName)
static

Translates between color transformation token names and the corresponding token.

Definition at line 495 of file color.cxx.

References SAL_WARN, sName, u, and XML_TOKEN_INVALID.

Referenced by oox::drawingml::DrawingML::WriteColorTransformations().

◆ getComplexColor()

model::ComplexColor Color::getComplexColor ( ) const

◆ getDmlPresetColor()

Color Color::getDmlPresetColor ( sal_Int32  nToken,
::Color  nDefaultRgb 
)
static

Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error.

Definition at line 302 of file color.cxx.

References nToken.

Referenced by oox::drawingml::ColorValueContext::onStartElement(), and setPrstClr().

◆ getHighlightColor()

Color Color::getHighlightColor ( sal_Int32  nToken,
::Color  nDefaultRgb 
)
static

Returns the RGB value for the passed VML color token, or nDefaultRgb on error.

Definition at line 320 of file color.cxx.

References nToken.

Referenced by setHighlight().

◆ getLumMod()

sal_Int16 Color::getLumMod ( ) const

Definition at line 588 of file color.cxx.

References maTransforms.

Referenced by getComplexColor(), and oox::drawingml::LineProperties::pushToPropMap().

◆ getLumOff()

sal_Int16 Color::getLumOff ( ) const

Definition at line 604 of file color.cxx.

References maTransforms.

Referenced by getComplexColor(), and oox::drawingml::LineProperties::pushToPropMap().

◆ getSchemeColorIndex()

sal_Int16 Color::getSchemeColorIndex ( ) const

◆ getSchemeColorName()

const OUString & oox::drawingml::Color::getSchemeColorName ( ) const
inline

Returns the scheme name from the a:schemeClr element for interoperability purposes.

Definition at line 105 of file color.hxx.

Referenced by oox::drawingml::Shape::createAndInsert(), and oox::drawingml::Generic3DProperties::getColorAttributes().

◆ getThemeColorType()

model::ThemeColorType oox::drawingml::Color::getThemeColorType ( ) const
inline

Definition at line 111 of file color.hxx.

◆ getTintOrShade()

sal_Int16 Color::getTintOrShade ( ) const

Definition at line 571 of file color.cxx.

References maTransforms.

Referenced by getComplexColor(), and oox::drawingml::LineProperties::pushToPropMap().

◆ getTransformations()

const css::uno::Sequence< css::beans::PropertyValue > & oox::drawingml::Color::getTransformations ( ) const
inline

Returns the unaltered list of transformations for interoperability purposes.

Definition at line 119 of file color.hxx.

Referenced by oox::drawingml::Shape::createAndInsert(), and oox::drawingml::Generic3DProperties::getColorAttributes().

◆ getTransparency()

sal_Int16 Color::getTransparency ( ) const

◆ getVmlPresetColor()

Color Color::getVmlPresetColor ( sal_Int32  nToken,
::Color  nDefaultRgb 
)
static

Returns the RGB value for the passed VML color token, or nDefaultRgb on error.

Definition at line 311 of file color.cxx.

References nToken.

◆ hasTransparency()

bool Color::hasTransparency ( ) const

◆ isPlaceHolder()

bool oox::drawingml::Color::isPlaceHolder ( ) const
inline

Returns true, if the color is a placeholder color in theme style lists.

Definition at line 94 of file color.hxx.

References meMode.

Referenced by oox::drawingml::Shape::createAndInsert().

◆ isUsed()

bool oox::drawingml::Color::isUsed ( ) const
inline

◆ setHighlight()

void Color::setHighlight ( sal_Int32  nToken)

Sets a predefined color from the w:highlight element.

Definition at line 376 of file color.cxx.

References oox::API_RGB_TRANSPARENT, getHighlightColor(), nToken, and setSrgbClr().

Referenced by oox::AttributeList::getHighlightColor().

◆ setHslClr()

void Color::setHslClr ( sal_Int32  nHue,
sal_Int32  nSat,
sal_Int32  nLum 
)

Sets the HSL values from the a:hslClr element.

Definition at line 357 of file color.cxx.

References COLOR_HSL, oox::drawingml::MAX_DEGREE, oox::drawingml::MAX_PERCENT, meMode, mnC1, mnC2, and mnC3.

Referenced by oox::drawingml::ColorValueContext::onStartElement().

◆ setPaletteClr()

void Color::setPaletteClr ( sal_Int32  nPaletteIdx)

Sets a palette color index.

Definition at line 393 of file color.cxx.

References COLOR_PALETTE, meMode, and mnC1.

◆ setPrstClr()

void Color::setPrstClr ( sal_Int32  nToken)

Sets a predefined color from the a:prstClr element.

Definition at line 368 of file color.cxx.

References oox::API_RGB_TRANSPARENT, getDmlPresetColor(), nToken, and setSrgbClr().

Referenced by oox::drawingml::ColorValueContext::onStartElement().

◆ setResolvedRgb()

void Color::setResolvedRgb ( ::Color  nRgb) const
private

Internal helper for getColor().

Definition at line 864 of file color.cxx.

References meMode.

◆ setSchemeClr()

void Color::setSchemeClr ( sal_Int32  nToken)

◆ setSchemeName()

void oox::drawingml::Color::setSchemeName ( const OUString &  sSchemeName)
inline

Sets the scheme name from the a:schemeClr element for interoperability purposes.

Definition at line 71 of file color.hxx.

Referenced by oox::drawingml::ColorValueContext::onStartElement().

◆ setScrgbClr()

void Color::setScrgbClr ( sal_Int32  nR,
sal_Int32  nG,
sal_Int32  nB 
)

Sets the percentual RGB values from the a:scrgbClr element.

Definition at line 346 of file color.cxx.

References COLOR_CRGB, oox::drawingml::MAX_PERCENT, meMode, mnC1, mnC2, and mnC3.

Referenced by oox::drawingml::ColorValueContext::onStartElement().

◆ setSrgbClr() [1/2]

void Color::setSrgbClr ( ::Color  nRgb)

Definition at line 334 of file color.cxx.

References setSrgbClr().

◆ setSrgbClr() [2/2]

void Color::setSrgbClr ( sal_Int32  nRgb)

◆ setSysClr()

void Color::setSysClr ( sal_Int32  nToken,
sal_Int32  nLastRgb 
)

Sets a system color from the a:sysClr element.

Definition at line 400 of file color.cxx.

References COLOR_SYSTEM, meMode, mnC1, mnC2, and nToken.

Referenced by oox::drawingml::ColorValueContext::onStartElement().

◆ setUnused()

void Color::setUnused ( )

◆ toCrgb()

void Color::toCrgb ( ) const
private

Converts the color components to CRGB values (gamma corrected percentage).

Definition at line 935 of file color.cxx.

References meMode.

◆ toHsl()

void Color::toHsl ( ) const
private

Converts the color components to HSL values.

Definition at line 956 of file color.cxx.

References oox::drawingml::MAX_DEGREE, oox::drawingml::MAX_PERCENT, meMode, oox::drawingml::PER_DEGREE, and oox::drawingml::PER_PERCENT.

◆ toRgb()

void Color::toRgb ( ) const
private

Converts the color components to RGB values.

Definition at line 870 of file color.cxx.

References oox::drawingml::MAX_DEGREE, oox::drawingml::MAX_PERCENT, and meMode.

Member Data Documentation

◆ maInteropTransformations

css::uno::Sequence< css::beans::PropertyValue > oox::drawingml::Color::maInteropTransformations
private

Definition at line 174 of file color.hxx.

Referenced by addTransformation(), and clearTransformations().

◆ maTransforms

std::vector< Transformation > oox::drawingml::Color::maTransforms
mutableprivate

◆ meMode

ColorMode oox::drawingml::Color::meMode
mutableprivate

◆ meThemeColorType

model::ThemeColorType oox::drawingml::Color::meThemeColorType
private

Scheme name from the a:schemeClr element for interoperability purposes.

Definition at line 172 of file color.hxx.

Referenced by setSchemeClr().

◆ mnAlpha

sal_Int32 oox::drawingml::Color::mnAlpha
private

Blue, blue%, or luminance.

Definition at line 170 of file color.hxx.

Referenced by addTransformation(), and clearTransparence().

◆ mnC1

sal_Int32 oox::drawingml::Color::mnC1
mutableprivate

Color transformations.

Definition at line 167 of file color.hxx.

Referenced by setHslClr(), setPaletteClr(), setSchemeClr(), setScrgbClr(), setSrgbClr(), and setSysClr().

◆ mnC2

sal_Int32 oox::drawingml::Color::mnC2
mutableprivate

Red, red%, hue, scheme token, palette index, system token, or final RGB.

Definition at line 168 of file color.hxx.

Referenced by setHslClr(), setScrgbClr(), setSrgbClr(), and setSysClr().

◆ mnC3

sal_Int32 oox::drawingml::Color::mnC3
mutableprivate

Green, green%, saturation, or system default RGB.

Definition at line 169 of file color.hxx.

Referenced by setHslClr(), setScrgbClr(), and setSrgbClr().

◆ msSchemeName

OUString oox::drawingml::Color::msSchemeName
private

Alpha value (color opacity).

Definition at line 171 of file color.hxx.


The documentation for this class was generated from the following files: