fpspreadsheet: Allow writing duplicate filler palette entries like in the built-in Excel colors
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5867 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
6f8fba8ec8
commit
25da629e34
@ -1230,6 +1230,11 @@ begin
|
||||
SetLength(sheetPos, 0);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Populates the palette of the writer with the colors used by the workbook.
|
||||
BIFF8 begins with the 8 default colors which are duplicated. Then the user
|
||||
colors follow up to a max of total 64 entries.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF5Writer.PopulatePalette(AWorkbook: TsWorkbook);
|
||||
var
|
||||
i: Integer;
|
||||
@ -1240,7 +1245,9 @@ begin
|
||||
// Fill up Excel colors of the standard palette to avoid empty color
|
||||
// place holders in Excel's colordialog.
|
||||
for i := 16 to High(PALETTE_BIFF5) do
|
||||
FPalette.AddUniqueColor(PALETTE_BIFF5[i]);
|
||||
FPalette.AddColor(PALETTE_BIFF5[i]);
|
||||
// The BIFF5 palette contains duplicate colors -> don't use AddUniqueColor
|
||||
// FPalette.AddUniqueColor(PALETTE_BIFF5[i]);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -211,14 +211,14 @@ var
|
||||
$FF00FF, // $06: magenta
|
||||
$00FFFF, // $07: cyan
|
||||
|
||||
$000000, // $08: EGA black 1
|
||||
$FFFFFF, // $09: EGA white 2
|
||||
$FF0000, // $0A: EGA red 3
|
||||
$00FF00, // $0B: EGA green 4
|
||||
$0000FF, // $0C: EGA blue 5
|
||||
$FFFF00, // $0D: EGA yellow 6
|
||||
$FF00FF, // $0E: EGA magenta 7 pink
|
||||
$00FFFF, // $0F: EGA cyan 8 turqoise
|
||||
$000000, // $08: EGA black 1
|
||||
$FFFFFF, // $09: EGA white 2
|
||||
$FF0000, // $0A: EGA red 3
|
||||
$00FF00, // $0B: EGA green 4
|
||||
$0000FF, // $0C: EGA blue 5
|
||||
$FFFF00, // $0D: EGA yellow 6
|
||||
$FF00FF, // $0E: EGA magenta 7 pink
|
||||
$00FFFF, // $0F: EGA cyan 8 turqoise
|
||||
|
||||
$800000, // $10=16: EGA dark red 9
|
||||
$008000, // $11=17: EGA dark green 10
|
||||
@ -2226,6 +2226,11 @@ begin
|
||||
SetLength(sheetPos, 0);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Populates the palette of the writer with the colors used by the workbook.
|
||||
BIFF8 begins with the 8 default colors which are duplicated. Then the user
|
||||
colors follow up to a max of total 64 entries.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF8Writer.PopulatePalette(AWorkbook: TsWorkbook);
|
||||
var
|
||||
i: Integer;
|
||||
@ -2236,7 +2241,9 @@ begin
|
||||
// Fill up Excel colors of the standard palette to avoid empty color
|
||||
// place holders in Excel's colordialog.
|
||||
for i := 16 to High(PALETTE_BIFF8) do
|
||||
FPalette.AddUniqueColor(PALETTE_BIFF8[i]);
|
||||
FPalette.AddColor(PALETTE_BIFF8[i]);
|
||||
// The BIFF8 palette contains duplicate colors -> don't use AddUniqueColor
|
||||
// FPalette.AddUniqueColor(PALETTE_BIFF8[i]);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -3853,11 +3853,13 @@ end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Writes the PALETTE record for the color palette.
|
||||
Valid for BIFF3-BIFF8. BIFF2 has no palette in the file.
|
||||
Valid for BIFF3-BIFF8. BIFF2 has no palette in the file, i.e. WritePalette is
|
||||
not called.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFFWriter.WritePalette(AStream: TStream);
|
||||
const
|
||||
NUM_COLORS = 56;
|
||||
MAX_PALETTE = NUM_COLORS + 8 - 1;
|
||||
var
|
||||
i, n: Integer;
|
||||
rgb: TsColor;
|
||||
@ -3872,7 +3874,7 @@ begin
|
||||
n := FPalette.Count;
|
||||
|
||||
{ Skip the first 8 entries - they are hard-coded into Excel }
|
||||
for i := 8 to 8 + NUM_COLORS - 1 do
|
||||
for i := 8 to MAX_PALETTE do
|
||||
begin
|
||||
rgb := Math.IfThen(i < n, FPalette[i], $FFFFFF);
|
||||
AStream.WriteDWord(DWordToLE(rgb))
|
||||
|
Loading…
Reference in New Issue
Block a user