LibreOffice Module sc (master) 1
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
XclExpPaletteImpl Class Reference
Collaboration diagram for XclExpPaletteImpl:
[legend]

Public Member Functions

 XclExpPaletteImpl (const XclDefaultPalette &rDefPal)
 
sal_uInt32 InsertColor (const Color &rColor, XclExpColorType eType, sal_uInt16 nAutoDefault=0)
 Inserts the color into the list and updates weighting. More...
 
void Finalize ()
 Reduces the color list to the maximum count of the current BIFF version. More...
 
sal_uInt16 GetColorIndex (sal_uInt32 nColorId) const
 Returns the Excel palette index of the color with passed color ID. More...
 
void GetMixedColors (sal_uInt16 &rnXclForeIx, sal_uInt16 &rnXclBackIx, sal_uInt8 &rnXclPattern, sal_uInt32 nForeColorId, sal_uInt32 nBackColorId) const
 Returns a foreground and background color for the two passed color IDs. More...
 
Color GetColor (sal_uInt16 nXclIndex) const
 Returns the RGB color for a (non-zero-based) Excel palette entry. More...
 
bool IsDefaultPalette () const
 Returns true, if all colors of the palette are equal to default palette colors. More...
 
void WriteBody (XclExpStream &rStrm)
 Writes the color list (contents of the palette record) to the passed stream. More...
 
void SaveXml (XclExpXmlStream &rStrm)
 

Static Public Member Functions

static sal_uInt32 GetColorIdFromIndex (sal_uInt16 nIndex)
 Returns the color ID representing a fixed Excel palette index (i.e. More...
 

Private Types

typedef std::vector< std::unique_ptr< XclListColor > > XclListColorList
 
typedef std::shared_ptr< XclListColorListXclListColorListRef
 

Private Member Functions

const ColorGetOriginalColor (sal_uInt32 nColorId) const
 Returns the original inserted color represented by the color ID nColorId. More...
 
XclListColor * SearchListEntry (const Color &rColor, sal_uInt32 &rnIndex)
 Searches for rColor, returns the ordered insertion index for rColor in rnIndex. More...
 
XclListColor * CreateListEntry (const Color &rColor, sal_uInt32 nIndex)
 Creates and inserts a new color list entry at the specified list position. More...
 
void RawReducePalette (sal_uInt32 nPass)
 Raw and fast reduction of the palette. More...
 
void ReduceLeastUsedColor ()
 Reduction of one color using advanced color merging based on color weighting. More...
 
sal_uInt32 GetLeastUsedListColor () const
 Finds the least used color and returns its current list index. More...
 
sal_uInt32 GetNearestListColor (const Color &rColor, sal_uInt32 nIgnore) const
 Returns the list index of the color nearest to rColor. More...
 
sal_uInt32 GetNearestListColor (sal_uInt32 nIndex) const
 Returns the list index of the color nearest to the color with list index nIndex. More...
 
sal_Int32 GetNearestPaletteColor (sal_uInt32 &rnIndex, const Color &rColor) const
 Returns in rnIndex the palette index of the color nearest to rColor. More...
 
sal_Int32 GetNearPaletteColors (sal_uInt32 &rnFirst, sal_uInt32 &rnSecond, const Color &rColor) const
 Returns in rnFirst and rnSecond the palette indexes of the two colors nearest to rColor. More...
 

Static Private Member Functions

static sal_uInt16 GetXclIndex (sal_uInt32 nIndex)
 Returns the Excel index of a 0-based color index. More...
 

Private Attributes

const XclDefaultPalettemrDefPal
 
XclListColorListRef mxColorList
 The default palette for the current BIFF version. More...
 
std::vector< XclColorIdData > maColorIdDataVec
 Working color list. More...
 
std::vector< XclPaletteColor > maPalette
 Data of all CIDs. More...
 
sal_uInt32 mnLastIdx
 Contains resulting colors to export. More...
 

Detailed Description

Definition at line 224 of file xestyle.cxx.

Member Typedef Documentation

◆ XclListColorList

typedef std::vector< std::unique_ptr<XclListColor> > XclExpPaletteImpl::XclListColorList
private

Definition at line 300 of file xestyle.cxx.

◆ XclListColorListRef

typedef std::shared_ptr< XclListColorList > XclExpPaletteImpl::XclListColorListRef
private

Definition at line 301 of file xestyle.cxx.

Constructor & Destructor Documentation

◆ XclExpPaletteImpl()

XclExpPaletteImpl::XclExpPaletteImpl ( const XclDefaultPalette rDefPal)
explicit

Member Function Documentation

◆ CreateListEntry()

XclListColor * XclExpPaletteImpl::CreateListEntry ( const Color rColor,
sal_uInt32  nIndex 
)
private

Creates and inserts a new color list entry at the specified list position.

Definition at line 553 of file xestyle.cxx.

References mxColorList, and nIndex.

Referenced by InsertColor(), and RawReducePalette().

◆ Finalize()

void XclExpPaletteImpl::Finalize ( )

Reduces the color list to the maximum count of the current BIFF version.

Definition at line 348 of file xestyle.cxx.

References EXC_PAL_MAXRAWSIZE, XclDefaultPalette::GetColorCount(), GetNearestPaletteColor(), maColorIdDataVec, maPalette, mrDefPal, mxColorList, nCount, nIndex, RawReducePalette(), ReduceLeastUsedColor(), and SAL_MAX_INT32.

◆ GetColor()

Color XclExpPaletteImpl::GetColor ( sal_uInt16  nXclIndex) const

Returns the RGB color for a (non-zero-based) Excel palette entry.

Returns
The color from current or default palette or COL_AUTO, if nothing else found.

Definition at line 460 of file xestyle.cxx.

References EXC_COLOR_USEROFFSET, XclDefaultPalette::GetDefColor(), maPalette, and mrDefPal.

◆ GetColorIdFromIndex()

sal_uInt32 XclExpPaletteImpl::GetColorIdFromIndex ( sal_uInt16  nIndex)
static

Returns the color ID representing a fixed Excel palette index (i.e.

for auto colors).

Definition at line 343 of file xestyle.cxx.

References EXC_PAL_INDEXBASE, and nIndex.

Referenced by XclExpPalette::GetColorIdFromIndex(), and InsertColor().

◆ GetColorIndex()

sal_uInt16 XclExpPaletteImpl::GetColorIndex ( sal_uInt32  nColorId) const

Returns the Excel palette index of the color with passed color ID.

Definition at line 402 of file xestyle.cxx.

References EXC_PAL_INDEXBASE, GetXclIndex(), maColorIdDataVec, and mnIndex.

Referenced by GetMixedColors().

◆ GetLeastUsedListColor()

sal_uInt32 XclExpPaletteImpl::GetLeastUsedListColor ( ) const
private

Finds the least used color and returns its current list index.

Definition at line 656 of file xestyle.cxx.

References mxColorList, nCount, and SAL_MAX_UINT32.

Referenced by ReduceLeastUsedColor().

◆ GetMixedColors()

void XclExpPaletteImpl::GetMixedColors ( sal_uInt16 &  rnXclForeIx,
sal_uInt16 &  rnXclBackIx,
sal_uInt8 rnXclPattern,
sal_uInt32  nForeColorId,
sal_uInt32  nBackColorId 
) const

Returns a foreground and background color for the two passed color IDs.

@descr If rnXclPattern contains a solid pattern, this function tries to find the two best fitting colors and a mix pattern (25%, 50% or 75%) for nForeColorId. This will result in a better approximation to the passed foreground color.

Definition at line 412 of file xestyle.cxx.

References EXC_PATT_25_PERC, EXC_PATT_50_PERC, EXC_PATT_75_PERC, EXC_PATT_SOLID, GetColorIndex(), GetNearPaletteColors(), GetOriginalColor(), GetXclIndex(), maColorIdDataVec, and maPalette.

◆ GetNearestListColor() [1/2]

sal_uInt32 XclExpPaletteImpl::GetNearestListColor ( const Color rColor,
sal_uInt32  nIgnore 
) const
private

Returns the list index of the color nearest to rColor.

Parameters
nIgnoreList index of a color which will be ignored.
Returns
The list index of the found color.

Definition at line 674 of file xestyle.cxx.

References mxColorList, nCount, and SAL_MAX_INT32.

Referenced by GetNearestListColor(), and ReduceLeastUsedColor().

◆ GetNearestListColor() [2/2]

sal_uInt32 XclExpPaletteImpl::GetNearestListColor ( sal_uInt32  nIndex) const
private

Returns the list index of the color nearest to the color with list index nIndex.

Definition at line 697 of file xestyle.cxx.

References GetNearestListColor(), mxColorList, and nIndex.

◆ GetNearestPaletteColor()

sal_Int32 XclExpPaletteImpl::GetNearestPaletteColor ( sal_uInt32 &  rnIndex,
const Color rColor 
) const
private

Returns in rnIndex the palette index of the color nearest to rColor.

Searches for default colors only (colors never replaced).

Returns
The distance from passed color to found color.

Definition at line 705 of file xestyle.cxx.

References maPalette, and SAL_MAX_INT32.

Referenced by Finalize().

◆ GetNearPaletteColors()

sal_Int32 XclExpPaletteImpl::GetNearPaletteColors ( sal_uInt32 &  rnFirst,
sal_uInt32 &  rnSecond,
const Color rColor 
) const
private

Returns in rnFirst and rnSecond the palette indexes of the two colors nearest to rColor.

Returns
The minimum distance from passed color to found colors.

Definition at line 728 of file xestyle.cxx.

References maPalette, and SAL_MAX_INT32.

Referenced by GetMixedColors().

◆ GetOriginalColor()

const Color & XclExpPaletteImpl::GetOriginalColor ( sal_uInt32  nColorId) const
private

Returns the original inserted color represented by the color ID nColorId.

Definition at line 500 of file xestyle.cxx.

References maColorIdDataVec, and maPalette.

Referenced by GetMixedColors().

◆ GetXclIndex()

static sal_uInt16 XclExpPaletteImpl::GetXclIndex ( sal_uInt32  nIndex)
inlinestaticprivate

Returns the Excel index of a 0-based color index.

Definition at line 262 of file xestyle.cxx.

References EXC_COLOR_USEROFFSET, and nIndex.

Referenced by GetColorIndex(), GetMixedColors(), IsDefaultPalette(), and XclExpPaletteImpl().

◆ InsertColor()

sal_uInt32 XclExpPaletteImpl::InsertColor ( const Color rColor,
XclExpColorType  eType,
sal_uInt16  nAutoDefault = 0 
)

Inserts the color into the list and updates weighting.

Parameters
nAutoDefaultThe Excel palette index for automatic color.
Returns
A unique ID for this color.

Definition at line 329 of file xestyle.cxx.

References COL_AUTO(), CreateListEntry(), eType, GetColorIdFromIndex(), and SearchListEntry().

Referenced by XclExpPaletteImpl().

◆ IsDefaultPalette()

bool XclExpPaletteImpl::IsDefaultPalette ( ) const

Returns true, if all colors of the palette are equal to default palette colors.

Definition at line 471 of file xestyle.cxx.

References XclDefaultPalette::GetDefColor(), GetXclIndex(), maPalette, and mrDefPal.

◆ RawReducePalette()

void XclExpPaletteImpl::RawReducePalette ( sal_uInt32  nPass)
private

Raw and fast reduction of the palette.

Definition at line 560 of file xestyle.cxx.

References CreateListEntry(), maColorIdDataVec, mxColorList, and SearchListEntry().

Referenced by Finalize().

◆ ReduceLeastUsedColor()

void XclExpPaletteImpl::ReduceLeastUsedColor ( )
private

Reduction of one color using advanced color merging based on color weighting.

Definition at line 625 of file xestyle.cxx.

References GetLeastUsedListColor(), GetNearestListColor(), maColorIdDataVec, and mxColorList.

Referenced by Finalize().

◆ SaveXml()

void XclExpPaletteImpl::SaveXml ( XclExpXmlStream rStrm)

Definition at line 486 of file xestyle.cxx.

References maPalette, rStrm, and XclXmlUtils::ToOString().

◆ SearchListEntry()

XclListColor * XclExpPaletteImpl::SearchListEntry ( const Color rColor,
sal_uInt32 &  rnIndex 
)
private

Searches for rColor, returns the ordered insertion index for rColor in rnIndex.

Definition at line 507 of file xestyle.cxx.

References mnLastIdx, mxColorList, and size.

Referenced by InsertColor(), and RawReducePalette().

◆ WriteBody()

void XclExpPaletteImpl::WriteBody ( XclExpStream rStrm)

Writes the color list (contents of the palette record) to the passed stream.

Definition at line 479 of file xestyle.cxx.

References maPalette, and rStrm.

Member Data Documentation

◆ maColorIdDataVec

std::vector< XclColorIdData > XclExpPaletteImpl::maColorIdDataVec
private

Working color list.

Definition at line 306 of file xestyle.cxx.

Referenced by Finalize(), GetColorIndex(), GetMixedColors(), GetOriginalColor(), RawReducePalette(), and ReduceLeastUsedColor().

◆ maPalette

std::vector< XclPaletteColor > XclExpPaletteImpl::maPalette
private

◆ mnLastIdx

sal_uInt32 XclExpPaletteImpl::mnLastIdx
private

Contains resulting colors to export.

Definition at line 309 of file xestyle.cxx.

Referenced by SearchListEntry().

◆ mrDefPal

const XclDefaultPalette& XclExpPaletteImpl::mrDefPal
private

Definition at line 303 of file xestyle.cxx.

Referenced by Finalize(), GetColor(), IsDefaultPalette(), and XclExpPaletteImpl().

◆ mxColorList

XclListColorListRef XclExpPaletteImpl::mxColorList
private

The default palette for the current BIFF version.

Definition at line 304 of file xestyle.cxx.

Referenced by CreateListEntry(), Finalize(), GetLeastUsedListColor(), GetNearestListColor(), RawReducePalette(), ReduceLeastUsedColor(), and SearchListEntry().


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