You've already forked lazarus-ccr
fpspreadsheet: Adds support for RGB colours
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2750 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -541,7 +541,7 @@ begin
|
|||||||
if (uffBackgroundColor in FFormattingStyles[i].UsedFormattingFields) then
|
if (uffBackgroundColor in FFormattingStyles[i].UsedFormattingFields) then
|
||||||
begin
|
begin
|
||||||
Result := Result + 'fo:background-color="#'
|
Result := Result + 'fo:background-color="#'
|
||||||
+ FPSColorToHexString(FFormattingStyles[i].BackgroundColor) +'" ';
|
+ FPSColorToHexString(FFormattingStyles[i].BackgroundColor, FFormattingStyles[i].RGBBackgroundColor) +'" ';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then
|
if (uffWordWrap in FFormattingStyles[i].UsedFormattingFields) then
|
||||||
|
@ -14,7 +14,7 @@ unit fpspreadsheet;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, AVL_Tree, avglvltree, lconvencoding;
|
Classes, SysUtils, fpimage, AVL_Tree, avglvltree, lconvencoding;
|
||||||
|
|
||||||
type
|
type
|
||||||
TsSpreadsheetFormat = (sfExcel2, sfExcel3, sfExcel4, sfExcel5, sfExcel8,
|
TsSpreadsheetFormat = (sfExcel2, sfExcel3, sfExcel4, sfExcel5, sfExcel8,
|
||||||
@ -146,7 +146,14 @@ type
|
|||||||
scGrey, // 808080H
|
scGrey, // 808080H
|
||||||
//
|
//
|
||||||
scGrey10pct,// E6E6E6H
|
scGrey10pct,// E6E6E6H
|
||||||
scGrey20pct // CCCCCCH
|
scGrey20pct,// CCCCCCH
|
||||||
|
scOrange, // ffa500
|
||||||
|
scDarkBrown,// a0522d
|
||||||
|
scBrown, // cd853f
|
||||||
|
scBeige, // f5f5dc
|
||||||
|
scWheat, // f5deb3
|
||||||
|
//
|
||||||
|
scRGBCOLOR // Defined via TFPColor
|
||||||
);
|
);
|
||||||
|
|
||||||
{@@ Cell structure for TsWorksheet
|
{@@ Cell structure for TsWorksheet
|
||||||
@ -173,6 +180,7 @@ type
|
|||||||
TextRotation: TsTextRotation;
|
TextRotation: TsTextRotation;
|
||||||
Border: TsCellBorders;
|
Border: TsCellBorders;
|
||||||
BackgroundColor: TsColor;
|
BackgroundColor: TsColor;
|
||||||
|
RGBBackgroundColor: TFPColor; // only valid if BackgroundColor=scRGBCOLOR
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PCell = ^TCell;
|
PCell = ^TCell;
|
||||||
@ -328,7 +336,7 @@ type
|
|||||||
procedure ListAllFormattingStylesCallback(ACell: PCell; AStream: TStream);
|
procedure ListAllFormattingStylesCallback(ACell: PCell; AStream: TStream);
|
||||||
procedure ListAllFormattingStyles(AData: TsWorkbook);
|
procedure ListAllFormattingStyles(AData: TsWorkbook);
|
||||||
function ExpandFormula(AFormula: TsFormula): TsExpandedFormula;
|
function ExpandFormula(AFormula: TsFormula): TsExpandedFormula;
|
||||||
function FPSColorToHexString(AColor: TsColor): string;
|
function FPSColorToHexString(AColor: TsColor; ARGBColor: TFPColor): string;
|
||||||
{ General writing methods }
|
{ General writing methods }
|
||||||
procedure WriteCellCallback(ACell: PCell; AStream: TStream);
|
procedure WriteCellCallback(ACell: PCell; AStream: TStream);
|
||||||
procedure WriteCellsToStream(AStream: TStream; ACells: TAVLTree);
|
procedure WriteCellsToStream(AStream: TStream; ACells: TAVLTree);
|
||||||
@ -1485,7 +1493,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TsCustomSpreadWriter.FPSColorToHexString(AColor: TsColor): string;
|
function TsCustomSpreadWriter.FPSColorToHexString(AColor: TsColor; ARGBColor: TFPColor): string;
|
||||||
begin
|
begin
|
||||||
case AColor of
|
case AColor of
|
||||||
scBlack: Result := '000000';
|
scBlack: Result := '000000';
|
||||||
@ -1507,6 +1515,13 @@ begin
|
|||||||
//
|
//
|
||||||
scGrey10pct:Result := 'E6E6E6';
|
scGrey10pct:Result := 'E6E6E6';
|
||||||
scGrey20pct:Result := 'CCCCCC';
|
scGrey20pct:Result := 'CCCCCC';
|
||||||
|
scOrange: Result := 'FFA500';
|
||||||
|
scDarkBrown:Result := 'a0522d';
|
||||||
|
scBrown: Result := 'cd853f';
|
||||||
|
scBeige: Result := 'f5f5dc';
|
||||||
|
scWheat: Result := 'f5deb3';
|
||||||
|
//
|
||||||
|
scRGBCOLOR: Result := Format('%x%x%x', [ARGBColor.Red div $100, ARGBColor.Green div $100, ARGBColor.Blue div $100]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -257,7 +257,9 @@ begin
|
|||||||
lFormatStr := LowerCase(Trim(lFormatStr));
|
lFormatStr := LowerCase(Trim(lFormatStr));
|
||||||
if lFormatStr = 'color:red' then lCurBackgroundColor := scRED
|
if lFormatStr = 'color:red' then lCurBackgroundColor := scRED
|
||||||
else if lFormatStr = 'color:green' then lCurBackgroundColor := scGREEN
|
else if lFormatStr = 'color:green' then lCurBackgroundColor := scGREEN
|
||||||
else if lFormatStr = 'color:orange' then lCurBackgroundColor := scYELLOW
|
else if lFormatStr = 'color:yellow' then lCurBackgroundColor := scYELLOW
|
||||||
|
//
|
||||||
|
else if lFormatStr = 'color:orange' then lCurBackgroundColor := scOrange
|
||||||
else lCurBackgroundColor := scWHITE;
|
else lCurBackgroundColor := scWHITE;
|
||||||
lUseBackgroundColor := True;
|
lUseBackgroundColor := True;
|
||||||
lFormatStr := '';
|
lFormatStr := '';
|
||||||
@ -369,12 +371,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
lCurColor := FWorksheet.ReadBackgroundColor(i, j);
|
lCurColor := FWorksheet.ReadBackgroundColor(i, j);
|
||||||
case lCurColor of
|
case lCurColor of
|
||||||
scBlack: lColorStr := 'black';
|
scBlack: lColorStr := 'style="background-color:black;color:white;"';
|
||||||
scWhite: lColorStr := 'white';
|
scWhite: lColorStr := 'style="background-color:white;color:black;"';
|
||||||
scRed: lColorStr := 'red';
|
scRed: lColorStr := 'style="background-color:red;color:white;"';
|
||||||
scGREEN: lColorStr := 'green';
|
scGREEN: lColorStr := 'style="background-color:green;color:white;"';
|
||||||
scBLUE: lColorStr := 'blue';
|
scBLUE: lColorStr := 'style="background-color:blue;color:white;"';
|
||||||
scYELLOW: lColorStr := 'yellow';
|
scYELLOW: lColorStr := 'style="background-color:yellow;color:black;"';
|
||||||
{scMAGENTA, // FF00FFH
|
{scMAGENTA, // FF00FFH
|
||||||
scCYAN, // 00FFFFH
|
scCYAN, // 00FFFFH
|
||||||
scDarkRed, // 800000H
|
scDarkRed, // 800000H
|
||||||
@ -388,8 +390,9 @@ begin
|
|||||||
//
|
//
|
||||||
scGrey10pct,// E6E6E6H
|
scGrey10pct,// E6E6E6H
|
||||||
scGrey20pct // CCCCCCH }
|
scGrey20pct // CCCCCCH }
|
||||||
|
scOrange: lColorStr := 'style="background-color:orange;color:white;"';
|
||||||
end;
|
end;
|
||||||
lCurStr := 'style="background-color:'+lColorStr+';color:white;" |' + lCurStr
|
lCurStr := lColorStr + ' |' + lCurStr;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if uffBold in lCurUsedFormatting then lCurStr := '!' + lCurStr
|
if uffBold in lCurUsedFormatting then lCurStr := '!' + lCurStr
|
||||||
|
Reference in New Issue
Block a user