You've already forked lazarus-ccr
fpsprreadsheet: Fix usage of LineEndings in the html and wikitable writers.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4580 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -77,7 +77,7 @@ begin
|
||||
MyWorksheet.WriteNumber(row, 0, row);
|
||||
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
||||
Myworksheet.WriteVertAlignment(row, 1, vaTop);
|
||||
MyWorksheet.WriteText(row, 2, 'A very, very, very, very long text,<br /> indeed');
|
||||
MyWorksheet.WriteText(row, 2, 'A very, very, very, very long text,'#13#10'indeed');
|
||||
inc(row);
|
||||
|
||||
MyWorksheet.WriteNumber(row, 0, row);
|
||||
|
@ -76,7 +76,7 @@ begin
|
||||
MyWorksheet.WriteNumber(row, 0, row);
|
||||
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
||||
Myworksheet.WriteVertAlignment(row, 1, vaTop);
|
||||
MyWorksheet.WriteText(row, 2, 'A very, very, very, very long text,<br /> indeed');
|
||||
MyWorksheet.WriteText(row, 2, 'A very, very, very, very long text,' + LineEnding + 'indeed');
|
||||
inc(row);
|
||||
|
||||
MyWorksheet.WriteNumber(row, 0, row);
|
||||
|
@ -1625,6 +1625,7 @@ begin
|
||||
begin
|
||||
// Standard text formatting
|
||||
ValidXMLText(txt);
|
||||
txt := LineEndingToBR(txt);
|
||||
if target <> '' then
|
||||
txt := Format('<a href="%s">%s</a>', [target, txt]);
|
||||
if cellFnt.Position <> fpNormal then
|
||||
|
@ -44,6 +44,7 @@ type
|
||||
function GetAttrValue(ANode : TDOMNode; AAttrName : string) : string;
|
||||
function GetNodeValue(ANode: TDOMNode): String;
|
||||
|
||||
function LineEndingToBR(const AText: String): String;
|
||||
function UTF8TextToXMLText(AText: string; ProcessLineEndings: Boolean = false): string;
|
||||
function ValidXMLText(var AText: string; ReplaceSpecialChars: Boolean = true;
|
||||
ProcessLineEndings: Boolean = false): Boolean;
|
||||
@ -107,6 +108,29 @@ begin
|
||||
Result := child.NodeValue;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces LineEnding character(s) by '<br />';
|
||||
-------------------------------------------------------------------------------}
|
||||
function LineEndingToBR(const AText: String): String;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := '';
|
||||
i := 1;
|
||||
while (i <= Length(AText)) do
|
||||
begin
|
||||
case AText[i] of
|
||||
#13: begin
|
||||
Result := Result + '<br />';
|
||||
if (i < Length(AText)) and (AText[i+1] = #10) then inc(i);
|
||||
end;
|
||||
#10: Result := Result + '<br />';
|
||||
else Result := Result + AText[i];
|
||||
end;
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Converts a string encoded in UTF8 to a string usable in XML. For this purpose,
|
||||
some characters must be translated.
|
||||
|
@ -464,7 +464,6 @@ begin
|
||||
begin
|
||||
lCell := FWorksheet.FindCell(i, j);
|
||||
lCurStr := FWorksheet.ReadAsText(lCell, fs);
|
||||
// if lCurStr = '' then lCurStr := ' ';
|
||||
|
||||
// Check for invalid characters
|
||||
if not ValidXMLText(lCurStr, false) then
|
||||
@ -472,6 +471,8 @@ begin
|
||||
GetCellString(i, j)
|
||||
]);
|
||||
|
||||
lCurStr := LineEndingToBR(lCurStr);
|
||||
|
||||
lStyleStr := '';
|
||||
lColSpanStr := '';
|
||||
lRowSpanStr := '';
|
||||
@ -519,8 +520,6 @@ begin
|
||||
lStyleStr := Format('background-color:%s;color:%s;', [
|
||||
ColorToHTMLColorStr(lCurColor),
|
||||
ColorToHTMLColorStr(lFont.Color)
|
||||
// FWorkbook.GetPaletteColorAsHTMLStr(lCurColor),
|
||||
// FWorkbook.GetPaletteColorAsHTMLStr(lFont.Color)
|
||||
]);
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user