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 & getSchemeName () const
 Returns the scheme name from the a:schemeClr element for interoperability purposes. More...
 
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...
 

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...
 
css::uno::Sequence< css::beans::PropertyValue > maInteropTransformations
 Scheme name from the a:schemeClr element for interoperability purposes. More...
 

Detailed Description

Definition at line 38 of file color.hxx.

Member Enumeration Documentation

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 124 of file color.hxx.

Constructor & Destructor Documentation

Color::Color ( )

Definition at line 214 of file color.cxx.

References meMode.

Referenced by oox::drawingml::table::applyLineAttributes(), and setSrgbClr().

Member Function Documentation

void Color::addChartTintTransformation ( double  fTint)

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

Definition at line 346 of file color.cxx.

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

void Color::addExcelTintTransformation ( double  fTint)

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

Definition at line 355 of file color.cxx.

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

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

Inserts the passed color transformation.

Definition at line 327 of file color.cxx.

References getColorTransformationName(), maInteropTransformations, maTransforms, mnAlpha, and nToken.

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

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

Removes all color transformations.

Definition at line 361 of file color.cxx.

References clearTransparence(), maInteropTransformations, and maTransforms.

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

void Color::clearTransparence ( )

Removes transparence from the color.

Definition at line 476 of file color.cxx.

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

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

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

Compares this color with rOther.

Definition at line 468 of file color.cxx.

References getColor(), and getTransparency().

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

Returns the final RGB color value.

Parameters
nPhClrActual color for the phClr placeholder color used in theme style lists.

Definition at line 481 of file color.cxx.

References oox::API_RGB_TRANSPARENT, COLOR_CRGB, COLOR_FINAL, COLOR_HSL, COLOR_PALETTE, COLOR_PH, COLOR_RGB, COLOR_SCHEME, COLOR_SYSTEM, COLOR_UNUSED, ColorTransparency, oox::GraphicHelper::getPaletteColor(), oox::GraphicHelper::getSchemeColor(), oox::GraphicHelper::getSystemColor(), maTransforms, oox::drawingml::MAX_DEGREE, oox::drawingml::MAX_PERCENT, meMode, mnC1, mnC2, mnC3, oox::drawingml::PER_DEGREE, setResolvedRgb(), toCrgb(), toHsl(), and toRgb().

Referenced by oox::drawingml::table::applyBorder(), oox::drawingml::table::applyLineAttributes(), oox::drawingml::table::applyTableStylePart(), oox::drawingml::chart::TypeGroupConverter::convertMarker(), oox::drawingml::Shape::createAndInsert(), oox::ppt::SlidePersist::createBackground(), equals(), oox::drawingml::Generic3DProperties::getColorAttributes(), oox::shape::ShapeFilterBase::getSchemeColor(), oox::drawingml::TextParagraph::insertAt(), oox::drawingml::lcl_createPresetShape(), oox::ppt::AnimVariantContext::onEndElement(), oox::drawingml::LineProperties::pushToPropMap(), oox::drawingml::TextCharacterProperties::pushToPropMap(), oox::drawingml::FillProperties::pushToPropMap(), oox::vml::ShadowModel::pushToPropMap(), oox::drawingml::TextParagraphProperties::pushToPropSet(), oox::drawingml::table::TableCell::pushToXCell(), and oox::drawingml::clrSchemeColorContext::~clrSchemeColorContext().

OUString Color::getColorTransformationName ( sal_Int32  nElement)
static

Translates between color transformation tokens and their names.

Definition at line 368 of file color.cxx.

References SAL_WARN.

Referenced by addTransformation().

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

Translates between color transformation token names and the corresponding token.

Definition at line 405 of file color.cxx.

References SAL_WARN, u, and XML_TOKEN_INVALID.

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

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 223 of file color.cxx.

References oox::API_RGB_TRANSPARENT, oox::ContainerHelper::getVectorElement(), and maDmlColors.

Referenced by setPrstClr().

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 241 of file color.cxx.

References oox::API_RGB_TRANSPARENT, oox::ContainerHelper::getVectorElement(), and maHighlightColors.

Referenced by setHighlight().

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

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

Definition at line 100 of file color.hxx.

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

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 102 of file color.hxx.

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

sal_Int16 Color::getTransparency ( ) const
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 232 of file color.cxx.

References oox::API_RGB_TRANSPARENT, oox::ContainerHelper::getVectorElement(), and maVmlColors.

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

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

Definition at line 89 of file color.hxx.

References meMode.

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

bool oox::drawingml::Color::isUsed ( ) const
inline
void Color::setHighlight ( sal_Int32  nToken)

Sets a predefined color from the w:highlight element.

Definition at line 297 of file color.cxx.

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

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

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

Sets the HSL values from the a:hslClr element.

Definition at line 278 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().

void Color::setPaletteClr ( sal_Int32  nPaletteIdx)

Sets a palette color index.

Definition at line 312 of file color.cxx.

References COLOR_PALETTE, meMode, and mnC1.

void Color::setPrstClr ( sal_Int32  nToken)

Sets a predefined color from the a:prstClr element.

Definition at line 289 of file color.cxx.

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

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

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

Internal helper for getColor().

Definition at line 665 of file color.cxx.

References COLOR_RGB, COLOR_UNUSED, meMode, mnC1, mnC2, and mnC3.

Referenced by getColor().

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

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

Definition at line 66 of file color.hxx.

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

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 267 of file color.cxx.

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

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

void Color::setSrgbClr ( sal_Int32  nRgb)
void Color::setSrgbClr ( ::Color  nRgb)

Definition at line 255 of file color.cxx.

References setSrgbClr().

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

Sets a system color from the a:sysClr element.

Definition at line 319 of file color.cxx.

References COLOR_SYSTEM, meMode, mnC1, and mnC2.

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

void Color::setUnused ( )
void Color::toCrgb ( ) const
private

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

Definition at line 736 of file color.cxx.

References COLOR_CRGB, COLOR_HSL, COLOR_RGB, meMode, mnC1, mnC2, mnC3, and toRgb().

Referenced by getColor().

void Color::toHsl ( ) const
private

Converts the color components to HSL values.

Definition at line 757 of file color.cxx.

References COLOR_CRGB, COLOR_HSL, COLOR_RGB, oox::drawingml::MAX_DEGREE, oox::drawingml::MAX_PERCENT, meMode, mnC1, mnC2, mnC3, oox::drawingml::PER_DEGREE, oox::drawingml::PER_PERCENT, and toRgb().

Referenced by getColor().

void Color::toRgb ( ) const
private

Converts the color components to RGB values.

Definition at line 671 of file color.cxx.

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

Referenced by getColor(), toCrgb(), and toHsl().

Member Data Documentation

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

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

Definition at line 155 of file color.hxx.

Referenced by addTransformation(), and clearTransformations().

std::vector< Transformation > oox::drawingml::Color::maTransforms
mutableprivate
ColorMode oox::drawingml::Color::meMode
mutableprivate
sal_Int32 oox::drawingml::Color::mnAlpha
private

Blue, blue%, or luminance.

Definition at line 151 of file color.hxx.

Referenced by addTransformation(), clearTransparence(), getTransparency(), and hasTransparency().

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

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

Definition at line 149 of file color.hxx.

Referenced by getColor(), setHslClr(), setResolvedRgb(), setScrgbClr(), setSrgbClr(), setSysClr(), toCrgb(), toHsl(), and toRgb().

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

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

Definition at line 150 of file color.hxx.

Referenced by getColor(), setHslClr(), setResolvedRgb(), setScrgbClr(), setSrgbClr(), toCrgb(), toHsl(), and toRgb().

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

Alpha value (color opacity).

Definition at line 153 of file color.hxx.


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