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 219 of file xestyle.cxx.

Member Typedef Documentation

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

Definition at line 295 of file xestyle.cxx.

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

Definition at line 296 of file xestyle.cxx.

Constructor & Destructor Documentation

XclExpPaletteImpl::XclExpPaletteImpl ( const XclDefaultPalette rDefPal)
explicit

Member Function Documentation

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 548 of file xestyle.cxx.

References mxColorList.

Referenced by InsertColor(), and RawReducePalette().

void XclExpPaletteImpl::Finalize ( )

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

Definition at line 343 of file xestyle.cxx.

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

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 455 of file xestyle.cxx.

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

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 338 of file xestyle.cxx.

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

sal_uInt16 XclExpPaletteImpl::GetColorIndex ( sal_uInt32  nColorId) const

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

Definition at line 397 of file xestyle.cxx.

References GetXclIndex(), maColorIdDataVec, and mnIndex.

Referenced by GetMixedColors().

sal_uInt32 XclExpPaletteImpl::GetLeastUsedListColor ( ) const
private

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

Definition at line 651 of file xestyle.cxx.

References mxColorList, nCount, and SAL_MAX_UINT32.

Referenced by ReduceLeastUsedColor().

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.

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 407 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.

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 669 of file xestyle.cxx.

References mxColorList, nCount, and SAL_MAX_INT32.

Referenced by GetNearestListColor(), and ReduceLeastUsedColor().

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 692 of file xestyle.cxx.

References GetNearestListColor(), and mxColorList.

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 700 of file xestyle.cxx.

References maPalette, and SAL_MAX_INT32.

Referenced by Finalize().

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 723 of file xestyle.cxx.

References maPalette, and SAL_MAX_INT32.

Referenced by GetMixedColors().

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

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

Definition at line 495 of file xestyle.cxx.

References maColor, maColorIdDataVec, and maPalette.

Referenced by GetMixedColors().

static sal_uInt16 XclExpPaletteImpl::GetXclIndex ( sal_uInt32  nIndex)
inlinestaticprivate

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

Definition at line 257 of file xestyle.cxx.

References EXC_COLOR_USEROFFSET.

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

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 324 of file xestyle.cxx.

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

Referenced by XclExpPaletteImpl().

bool XclExpPaletteImpl::IsDefaultPalette ( ) const

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

Definition at line 466 of file xestyle.cxx.

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

void XclExpPaletteImpl::RawReducePalette ( sal_uInt32  nPass)
private

Raw and fast reduction of the palette.

Definition at line 555 of file xestyle.cxx.

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

Referenced by Finalize().

void XclExpPaletteImpl::ReduceLeastUsedColor ( )
private

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

Definition at line 620 of file xestyle.cxx.

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

Referenced by Finalize().

void XclExpPaletteImpl::SaveXml ( XclExpXmlStream rStrm)
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 502 of file xestyle.cxx.

References mnLastIdx, mxColorList, and size.

Referenced by InsertColor(), and RawReducePalette().

void XclExpPaletteImpl::WriteBody ( XclExpStream rStrm)

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

Definition at line 474 of file xestyle.cxx.

References maPalette.

Member Data Documentation

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

Working color list.

Definition at line 301 of file xestyle.cxx.

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

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

Contains resulting colors to export.

Definition at line 304 of file xestyle.cxx.

Referenced by SearchListEntry().

const XclDefaultPalette& XclExpPaletteImpl::mrDefPal
private

Definition at line 298 of file xestyle.cxx.

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

XclListColorListRef XclExpPaletteImpl::mxColorList
private

The default palette for the current BIFF version.

Definition at line 299 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: