fpspreadsheet: Add element array with conditional format indexes to TCell record. Needed by ODS writer and for visual controls.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7502 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-06-28 21:37:30 +00:00
parent 72986ddc75
commit ea76276469
3 changed files with 66 additions and 1 deletions

View File

@@ -84,6 +84,8 @@ type
end;
TsConditionalFormatList = class(TFPObjectList)
private
FWorksheet: TsBasicWorksheet;
protected
function AddRule(ARange: TsCellRange; ARule: TsCFRule): Integer;
public
@@ -95,12 +97,16 @@ type
AParam1, AParam2: Variant; ACellFormatIndex: Integer): Integer; overload;
procedure AddColorRangeRule(ARange: TsCellRange);
procedure AddDataBarRule(ARange: TsCellRange);
procedure Delete(AIndex: Integer);
function Find(ARange: TsCellRange): Integer;
end;
implementation
uses
fpSpreadsheet;
procedure TsCFCellRule.Assign(ASource: TsCFRule);
begin
if ASource is TsCFCellRule then
@@ -265,6 +271,34 @@ begin
end;
{@@ ----------------------------------------------------------------------------
Deletes the conditional format at the given index from the list.
Iterates also through all cell in the range of the CF and removess the
format index from the cell's ConditionalFormatIndex array.
-------------------------------------------------------------------------------}
procedure TsConditionalFormatList.Delete(AIndex: Integer);
var
CF: TsConditionalFormat;
r, c: Cardinal;
i: Integer;
cell: PCell;
begin
CF := TsConditionalFormat(Items[AIndex]);
for r := CF.CellRange.Row1 to CF.CellRange.Row2 do
for c := CF.CellRange.Col1 to CF.CellRange.Col2 do
begin
cell := TsWorksheet(FWorksheet).FindCell(r, c);
if Assigned(cell) and (Length(cell^.ConditionalFormatIndex) > 0) then begin
for i := AIndex+1 to High(cell^.ConditionalFormatIndex) do
cell^.ConditionalFormatIndex[i-1] := cell^.ConditionalFormatIndex[i];
SetLength(cell^.ConditionalFormatIndex, Length(cell^.ConditionalFormatIndex)-1);
end;
end;
inherited Delete(AIndex);
end;
{@@ ----------------------------------------------------------------------------
The conditional format list must be unique regarding cell ranges.
This function searches all format item whether a given cell ranges is