You've already forked lazarus-ccr
fpspreadsheet: Fix handling of hyperlinks with spaces in the bookmark (sheet name).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8604 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -162,6 +162,25 @@ procedure TsWorksheet.WriteHyperlink(ACell: PCell; ATarget: String;
|
|||||||
Result := ATarget;
|
Result := ATarget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CheckTarget(ATarget: String): String;
|
||||||
|
var
|
||||||
|
p1, p2: Integer;
|
||||||
|
sheetName: String;
|
||||||
|
begin
|
||||||
|
Result := ATarget;
|
||||||
|
p1 := pos('#', ATarget);
|
||||||
|
p2 := pos('!', ATarget);
|
||||||
|
if (p1 > 0) and (p2 > p1) then
|
||||||
|
begin
|
||||||
|
sheetName := copy(ATarget, p1+1, p2-p1-1);
|
||||||
|
if (sheetName <> '') and (pos(' ', sheetName) > 0) and (sheetName[1] <> '''') then
|
||||||
|
begin
|
||||||
|
sheetName := '''' + sheetName + '''';
|
||||||
|
Result := copy(ATarget, 1, p1) + sheetName + copy(ATarget, p2, MaxInt);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
fmt: TsCellFormat;
|
fmt: TsCellFormat;
|
||||||
noCellText: Boolean = false;
|
noCellText: Boolean = false;
|
||||||
@ -186,7 +205,7 @@ begin
|
|||||||
(GetDisplayText(ReadHyperlink(ACell).Target) = ReadAsText(ACell));
|
(GetDisplayText(ReadHyperlink(ACell).Target) = ReadAsText(ACell));
|
||||||
|
|
||||||
// Attach the hyperlink to the cell
|
// Attach the hyperlink to the cell
|
||||||
FHyperlinks.AddHyperlink(ACell^.Row, ACell^.Col, ATarget, ATooltip);
|
FHyperlinks.AddHyperlink(ACell^.Row, ACell^.Col, CheckTarget(ATarget), ATooltip);
|
||||||
Include(ACell^.Flags, cfHyperlink);
|
Include(ACell^.Flags, cfHyperlink);
|
||||||
|
|
||||||
// If there is no other cell content use the target as cell label string.
|
// If there is no other cell content use the target as cell label string.
|
||||||
|
@ -960,7 +960,9 @@ begin
|
|||||||
Result := ParseCellString(AStr, ACellRow, ACellCol);
|
Result := ParseCellString(AStr, ACellRow, ACellCol);
|
||||||
ASheetName := '';
|
ASheetName := '';
|
||||||
end else begin
|
end else begin
|
||||||
ASheetName := UTF8Copy(AStr, 1, p-1);
|
ASheetName := Copy(AStr, 1, p-1);
|
||||||
|
if (ASheetName[1] = '''') and (ASheetName[Length(ASheetName)] = '''') then
|
||||||
|
ASheetName := Copy(ASheetName, 2, Length(ASheetName)-2);
|
||||||
Result := ParseCellString(Copy(AStr, p+1, Length(AStr)), ACellRow, ACellCol);
|
Result := ParseCellString(Copy(AStr, p+1, Length(AStr)), ACellRow, ACellCol);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user