You've already forked lazarus-ccr
fpspreadsheet: Fix TsWorksheet.CopyCell ignoring comments, hyperlinks and merged cells. Fix incorrect handling of trailing zeros of hyperlink strings when reading biff8.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3974 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -205,9 +205,9 @@ type
|
|||||||
procedure UpdateCaches;
|
procedure UpdateCaches;
|
||||||
|
|
||||||
{ Reading of values }
|
{ Reading of values }
|
||||||
function ReadAsUTF8Text(ARow, ACol: Cardinal): string; overload; //ansistring; overload;
|
function ReadAsUTF8Text(ARow, ACol: Cardinal): string; overload;
|
||||||
function ReadAsUTF8Text(ACell: PCell): string; overload; //ansistring; overload;
|
function ReadAsUTF8Text(ACell: PCell): string; overload;
|
||||||
function ReadAsUTF8Text(ACell: PCell; AFormatSettings: TFormatSettings): string; overload; //ansistring; overload;
|
function ReadAsUTF8Text(ACell: PCell; AFormatSettings: TFormatSettings): string; overload;
|
||||||
function ReadAsNumber(ARow, ACol: Cardinal): Double; overload;
|
function ReadAsNumber(ARow, ACol: Cardinal): Double; overload;
|
||||||
function ReadAsNumber(ACell: PCell): Double; overload;
|
function ReadAsNumber(ACell: PCell): Double; overload;
|
||||||
function ReadAsDateTime(ARow, ACol: Cardinal; out AResult: TDateTime): Boolean; overload;
|
function ReadAsDateTime(ARow, ACol: Cardinal; out AResult: TDateTime): Boolean; overload;
|
||||||
@@ -1882,6 +1882,8 @@ end;
|
|||||||
procedure TsWorksheet.CopyCell(AFromCell, AToCell: PCell);
|
procedure TsWorksheet.CopyCell(AFromCell, AToCell: PCell);
|
||||||
var
|
var
|
||||||
toRow, toCol: Cardinal;
|
toRow, toCol: Cardinal;
|
||||||
|
row1, col1, row2, col2: Cardinal;
|
||||||
|
hyperlink: PsHyperlink;
|
||||||
begin
|
begin
|
||||||
if (AFromCell = nil) or (AToCell = nil) then
|
if (AFromCell = nil) or (AToCell = nil) then
|
||||||
exit;
|
exit;
|
||||||
@@ -1901,6 +1903,22 @@ begin
|
|||||||
// This also fires the OnChange event.
|
// This also fires the OnChange event.
|
||||||
CopyFormula(AFromCell, AToCell);
|
CopyFormula(AFromCell, AToCell);
|
||||||
|
|
||||||
|
// Merged?
|
||||||
|
if IsMergeBase(AFromCell) then
|
||||||
|
begin
|
||||||
|
FindMergedRange(AFromCell, row1, col1, row2, col2);
|
||||||
|
MergeCells(toRow, toCol, toRow + row2 - row1, toCol + col2 - col1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Copy comment
|
||||||
|
if HasComment(AFromCell) then
|
||||||
|
WriteComment(AToCell, ReadComment(AFromCell));
|
||||||
|
|
||||||
|
// Copy hyperlink
|
||||||
|
hyperlink := FindHyperlink(AFromCell);
|
||||||
|
if hyperlink <> nil then
|
||||||
|
WriteHyperlink(AToCell, hyperlink^.Target, hyperlink^.Tooltip);
|
||||||
|
|
||||||
// Notify visual controls of possibly changed row heights.
|
// Notify visual controls of possibly changed row heights.
|
||||||
ChangedFont(AToCell^.Row, AToCell^.Col);
|
ChangedFont(AToCell^.Row, AToCell^.Col);
|
||||||
end;
|
end;
|
||||||
|
@@ -1468,7 +1468,6 @@ begin
|
|||||||
{ Target frame: external link (URI or local file) }
|
{ Target frame: external link (URI or local file) }
|
||||||
link := '';
|
link := '';
|
||||||
if flags and MASK_HLINK_LINK <> 0 then
|
if flags and MASK_HLINK_LINK <> 0 then
|
||||||
// if flags and (MASK_HLINK_LINK or MASK_HLINK_ABSOLUTE) = (MASK_HLINK_LINK or MASK_HLINK_ABSOLUTE) then
|
|
||||||
begin
|
begin
|
||||||
AStream.ReadBuffer(guid, SizeOf(guid));
|
AStream.ReadBuffer(guid, SizeOf(guid));
|
||||||
|
|
||||||
@@ -1480,6 +1479,7 @@ begin
|
|||||||
// Character array of URL (16-bit-characters, with trailing zero word)
|
// Character array of URL (16-bit-characters, with trailing zero word)
|
||||||
SetLength(wideStr, len);
|
SetLength(wideStr, len);
|
||||||
AStream.ReadBuffer(wideStr[1], len*SizeOf(wideChar));
|
AStream.ReadBuffer(wideStr[1], len*SizeOf(wideChar));
|
||||||
|
SetLength(wideStr, len-1); // Remove trailing zero word
|
||||||
link := UTF8Encode(wideStr);
|
link := UTF8Encode(wideStr);
|
||||||
end else
|
end else
|
||||||
// Check for local file
|
// Check for local file
|
||||||
@@ -1490,9 +1490,10 @@ begin
|
|||||||
len := DWordLEToN(AStream.ReadDWord);
|
len := DWordLEToN(AStream.ReadDWord);
|
||||||
// Character array of the shortened file path and name in 8.3-DOS-format.
|
// Character array of the shortened file path and name in 8.3-DOS-format.
|
||||||
// This field can be filled with a long file name too.
|
// This field can be filled with a long file name too.
|
||||||
// No Unicode string header, always 8-bit characters, zeroterminated.
|
// No unicode string header, always 8-bit characters, zero-terminated.
|
||||||
SetLength(ansiStr, len);
|
SetLength(ansiStr, len);
|
||||||
AStream.ReadBuffer(ansiStr[1], len*SizeOf(ansiChar));
|
AStream.ReadBuffer(ansiStr[1], len*SizeOf(ansiChar));
|
||||||
|
SetLength(ansistr, len-1); // Remove trailing zero
|
||||||
linkDos := AnsiToUTF8(ansiStr);
|
linkDos := AnsiToUTF8(ansiStr);
|
||||||
while dirUpCount > 0 do
|
while dirUpCount > 0 do
|
||||||
begin
|
begin
|
||||||
@@ -1535,6 +1536,7 @@ begin
|
|||||||
// no Unicode string header, always 16-bit characters, zero-terminated
|
// no Unicode string header, always 16-bit characters, zero-terminated
|
||||||
SetLength(wideStr, len);
|
SetLength(wideStr, len);
|
||||||
AStream.ReadBuffer(wideStr[1], len*SizeOf(wideChar));
|
AStream.ReadBuffer(wideStr[1], len*SizeOf(wideChar));
|
||||||
|
SetLength(wideStr, len-1); // Remove trailing zero word
|
||||||
mark := UTF8Encode(wideStr);
|
mark := UTF8Encode(wideStr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1576,6 +1578,7 @@ begin
|
|||||||
numbytes := RecordSize - 5*SizeOf(word);
|
numbytes := RecordSize - 5*SizeOf(word);
|
||||||
SetLength(wideStr, numbytes div 2);
|
SetLength(wideStr, numbytes div 2);
|
||||||
AStream.ReadBuffer(wideStr[1], numbytes);
|
AStream.ReadBuffer(wideStr[1], numbytes);
|
||||||
|
SetLength(wideStr, Length(wideStr)-1); // Remove trailing zero word
|
||||||
txt := UTF8Encode(wideStr);
|
txt := UTF8Encode(wideStr);
|
||||||
|
|
||||||
{ Add tooltip to hyperlinks }
|
{ Add tooltip to hyperlinks }
|
||||||
|
Reference in New Issue
Block a user