fpspreadsheet: Use a StringHashTable for the SST needed when writing BIFF8 (significant speed-up of files with many strings, but still considerably slower than BIFF5 and BIFF2).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6447 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-05-31 16:22:41 +00:00
parent 40fabfc201
commit a6900014cf
3 changed files with 85 additions and 239 deletions

View File

@@ -179,6 +179,10 @@ function AnalyzeCompareStr(AString: String; out ACompareOp: TsCompareOperation):
procedure FixLineEndings(var AText: String; var ARichTextParams: TsRichTextParams);
function RandomString(ALen: Integer): String;
function SameRichTextParams(ARtp1, ARtp2: TsRichTextparams): Boolean;
function CombineTextAndRichTextParams(AText: String;
ARichText: TsRichTextParams): String;
procedure SplitTextAndRichTextParams(AValue: String;
out AText: String; out ARichText: TsRichTextParams);
function SplitStr(const AText: String; ADelimiter: Char): TStringArray;
function UnquoteStr(AString: String): String;
@@ -2195,6 +2199,57 @@ begin
Result := true;
end;
{@@ ----------------------------------------------------------------------------
Append the rich-text parameters to the bare text. Needed for StringHashList.
-------------------------------------------------------------------------------}
function CombineTextAndRichTextParams(AText: String;
ARichText: TsRichTextParams): String;
var
i: Integer;
begin
Result := AText;
if Length(ARichText) > 0 then begin
Result := Format('%s|@|%d,%d,%d', [
Result, ARichText[0].FirstIndex, ARichText[0].FontIndex, ARichText[0].HyperlinkIndex
]);
for i:=1 to High(ARichText) do
Result := Format('%s;%d,%d,%d', [
Result, ARichText[i].FirstIndex, ARichText[i].FontIndex, ARichText[i].HyperlinkIndex
]);
end;
end;
{@@ ----------------------------------------------------------------------------
Split text and rich-text parameters from the combined string needed for
StringHashList
-------------------------------------------------------------------------------}
procedure SplitTextAndRichTextParams(AValue: String; out AText: String;
out ARichText: TsRichTextParams);
const
SEPARATOR = '|@|';
var
p: Integer;
arr1, arr2: TStringArray;
i: Integer;
begin
p := pos(SEPARATOR, AValue);
if p = 0 then begin
AText := AValue;
SetLength(ARichText, 0);
end else
begin
AText := Copy(AValue, 1, p-1);
arr1 := SplitStr(Copy(AValue, p+Length(SEPARATOR), MaxInt), ';');
SetLength(ARichText, Length(arr1));
for i := 0 to Length(arr1)-1 do begin
arr2 := SplitStr(arr1[i], ',');
ARichText[i].FirstIndex := StrToInt(arr2[0]);
ARichText[i].FontIndex := StrToInt(arr2[1]);
ARichText[i].HyperlinkIndex := StrToInt(arr2[2]);
end;
end;
end;
{@@ ----------------------------------------------------------------------------
Splits a string at the specified delimiters into individual strings and passes
them in an array.