fpspreadsheet: Avoid writing duplicate conditional formatting styles to "styles.xml" of ods file.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7511 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-07-01 16:08:11 +00:00
parent 7f80fea142
commit efa8009d96
2 changed files with 24 additions and 15 deletions

View File

@@ -6022,24 +6022,33 @@ var
fmtIndex: Integer;
cf_rule: TsCFRule;
stylename: String;
L: TStrings;
begin
book := TsWorkbook(FWorkbook);
nCF := book.GetNumConditionalFormats;
for i := 0 to nCF-1 do
begin
CF := book.GetConditionalFormat(i);
for j := 0 to CF.RulesCount-1 do
L := TStringList.Create;
try
for i := 0 to nCF-1 do
begin
cf_Rule := CF.Rules[j];
if cf_Rule is TsCFCellRule then
CF := book.GetConditionalFormat(i);
for j := 0 to CF.RulesCount-1 do
begin
fmtIndex := TsCFCellRule(cf_Rule).FormatIndex;
fmt := book.GetCellFormat(TsCFCellRule(cf_Rule).FormatIndex);
stylename := Format('conditional_%d', [fmtIndex]);
WriteConditionalStyle(AStream, stylename, fmt);
cf_Rule := CF.Rules[j];
if cf_Rule is TsCFCellRule then
begin
fmtIndex := TsCFCellRule(cf_Rule).FormatIndex;
fmt := book.GetCellFormat(TsCFCellRule(cf_Rule).FormatIndex);
stylename := Format('conditional_%d', [fmtIndex]);
if L.IndexOf(styleName) = -1 then begin
WriteConditionalStyle(AStream, stylename, fmt);
L.Add(styleName);
end;
end;
end;
end;
finally
L.Free;
end;
end;