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.WriteNumber(row, 0, row);
|
||||||
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
||||||
Myworksheet.WriteVertAlignment(row, 1, vaTop);
|
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);
|
inc(row);
|
||||||
|
|
||||||
MyWorksheet.WriteNumber(row, 0, row);
|
MyWorksheet.WriteNumber(row, 0, row);
|
||||||
|
@ -76,7 +76,7 @@ begin
|
|||||||
MyWorksheet.WriteNumber(row, 0, row);
|
MyWorksheet.WriteNumber(row, 0, row);
|
||||||
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
MyWorksheet.WriteText(row, 1, 'This is a long text with line break:');
|
||||||
Myworksheet.WriteVertAlignment(row, 1, vaTop);
|
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);
|
inc(row);
|
||||||
|
|
||||||
MyWorksheet.WriteNumber(row, 0, row);
|
MyWorksheet.WriteNumber(row, 0, row);
|
||||||
|
@ -1625,6 +1625,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
// Standard text formatting
|
// Standard text formatting
|
||||||
ValidXMLText(txt);
|
ValidXMLText(txt);
|
||||||
|
txt := LineEndingToBR(txt);
|
||||||
if target <> '' then
|
if target <> '' then
|
||||||
txt := Format('<a href="%s">%s</a>', [target, txt]);
|
txt := Format('<a href="%s">%s</a>', [target, txt]);
|
||||||
if cellFnt.Position <> fpNormal then
|
if cellFnt.Position <> fpNormal then
|
||||||
|
@ -44,6 +44,7 @@ type
|
|||||||
function GetAttrValue(ANode : TDOMNode; AAttrName : string) : string;
|
function GetAttrValue(ANode : TDOMNode; AAttrName : string) : string;
|
||||||
function GetNodeValue(ANode: TDOMNode): String;
|
function GetNodeValue(ANode: TDOMNode): String;
|
||||||
|
|
||||||
|
function LineEndingToBR(const AText: String): String;
|
||||||
function UTF8TextToXMLText(AText: string; ProcessLineEndings: Boolean = false): string;
|
function UTF8TextToXMLText(AText: string; ProcessLineEndings: Boolean = false): string;
|
||||||
function ValidXMLText(var AText: string; ReplaceSpecialChars: Boolean = true;
|
function ValidXMLText(var AText: string; ReplaceSpecialChars: Boolean = true;
|
||||||
ProcessLineEndings: Boolean = false): Boolean;
|
ProcessLineEndings: Boolean = false): Boolean;
|
||||||
@ -107,6 +108,29 @@ begin
|
|||||||
Result := child.NodeValue;
|
Result := child.NodeValue;
|
||||||
end;
|
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,
|
Converts a string encoded in UTF8 to a string usable in XML. For this purpose,
|
||||||
some characters must be translated.
|
some characters must be translated.
|
||||||
|
@ -464,7 +464,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
lCell := FWorksheet.FindCell(i, j);
|
lCell := FWorksheet.FindCell(i, j);
|
||||||
lCurStr := FWorksheet.ReadAsText(lCell, fs);
|
lCurStr := FWorksheet.ReadAsText(lCell, fs);
|
||||||
// if lCurStr = '' then lCurStr := ' ';
|
|
||||||
|
|
||||||
// Check for invalid characters
|
// Check for invalid characters
|
||||||
if not ValidXMLText(lCurStr, false) then
|
if not ValidXMLText(lCurStr, false) then
|
||||||
@ -472,6 +471,8 @@ begin
|
|||||||
GetCellString(i, j)
|
GetCellString(i, j)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
lCurStr := LineEndingToBR(lCurStr);
|
||||||
|
|
||||||
lStyleStr := '';
|
lStyleStr := '';
|
||||||
lColSpanStr := '';
|
lColSpanStr := '';
|
||||||
lRowSpanStr := '';
|
lRowSpanStr := '';
|
||||||
@ -519,8 +520,6 @@ begin
|
|||||||
lStyleStr := Format('background-color:%s;color:%s;', [
|
lStyleStr := Format('background-color:%s;color:%s;', [
|
||||||
ColorToHTMLColorStr(lCurColor),
|
ColorToHTMLColorStr(lCurColor),
|
||||||
ColorToHTMLColorStr(lFont.Color)
|
ColorToHTMLColorStr(lFont.Color)
|
||||||
// FWorkbook.GetPaletteColorAsHTMLStr(lCurColor),
|
|
||||||
// FWorkbook.GetPaletteColorAsHTMLStr(lFont.Color)
|
|
||||||
]);
|
]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user