fpspreadsheet: Add hyperlink to image. Supported by ODS writer, so far.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6671 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
3de5275499
commit
48d37a6351
@ -7271,6 +7271,9 @@ var
|
|||||||
r1,c1,r2,c2: Cardinal;
|
r1,c1,r2,c2: Cardinal;
|
||||||
roffs1,coffs1, roffs2, coffs2: Double;
|
roffs1,coffs1, roffs2, coffs2: Double;
|
||||||
x, y, w, h: Double;
|
x, y, w, h: Double;
|
||||||
|
xml: String;
|
||||||
|
target, bookmark: String;
|
||||||
|
u: TURI;
|
||||||
begin
|
begin
|
||||||
if (ASheet as TsWorksheet).GetImageCount = 0 then
|
if (ASheet as TsWorksheet).GetImageCount = 0 then
|
||||||
exit;
|
exit;
|
||||||
@ -7290,7 +7293,7 @@ begin
|
|||||||
roffs1, coffs1, roffs2, coffs2, // mm
|
roffs1, coffs1, roffs2, coffs2, // mm
|
||||||
x, y, w, h); // mm
|
x, y, w, h); // mm
|
||||||
|
|
||||||
AppendToStream(AStream, Format(
|
xml := Format(
|
||||||
'<draw:frame draw:z-index="%d" draw:name="Image %d" '+
|
'<draw:frame draw:z-index="%d" draw:name="Image %d" '+
|
||||||
'draw:style-name="gr1" draw:text-style-name="P1" '+
|
'draw:style-name="gr1" draw:text-style-name="P1" '+
|
||||||
'svg:width="%.2fmm" svg:height="%.2fmm" '+
|
'svg:width="%.2fmm" svg:height="%.2fmm" '+
|
||||||
@ -7303,7 +7306,27 @@ begin
|
|||||||
w, h,
|
w, h,
|
||||||
x, y,
|
x, y,
|
||||||
img.Index+1, GetImageTypeExt(imgType)
|
img.Index+1, GetImageTypeExt(imgType)
|
||||||
], FPointSeparatorSettings));
|
], FPointSeparatorSettings);
|
||||||
|
|
||||||
|
if img.HyperlinkTarget <> '' then begin
|
||||||
|
SplitHyperlink(img.HyperlinkTarget, target, bookmark);
|
||||||
|
if (target <> '') and (pos('file:', target) = 0) then
|
||||||
|
begin
|
||||||
|
u := ParseURI(target);
|
||||||
|
if u.Protocol = '' then
|
||||||
|
target := '../' + target;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// ods absolutely wants "/" path delimiters in the file uri!
|
||||||
|
FixHyperlinkPathdelims(target);
|
||||||
|
|
||||||
|
if (bookmark <> '') then
|
||||||
|
target := target + '#' + bookmark;
|
||||||
|
|
||||||
|
xml := Format('<draw:a xlink:type="simple" xlink:href="%s">%s</draw:a>', [target, xml]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
AppendToStream(AStream, xml);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
|
@ -555,6 +555,8 @@ type
|
|||||||
function WriteImage(ARow, ACol: Cardinal; AImageIndex: Integer;
|
function WriteImage(ARow, ACol: Cardinal; AImageIndex: Integer;
|
||||||
AOffsetX: Double = 0.0; AOffsetY: Double = 0.0; AScaleX: Double = 1.0;
|
AOffsetX: Double = 0.0; AOffsetY: Double = 0.0; AScaleX: Double = 1.0;
|
||||||
AScaleY: Double = 1.0): Integer; overload;
|
AScaleY: Double = 1.0): Integer; overload;
|
||||||
|
procedure AddHyperlinkToImage(AImageIndex: Integer; ATarget: String;
|
||||||
|
AToolTip: String = '');
|
||||||
|
|
||||||
{ Protection }
|
{ Protection }
|
||||||
procedure Protect(AEnable: Boolean);
|
procedure Protect(AEnable: Boolean);
|
||||||
@ -4017,6 +4019,20 @@ begin
|
|||||||
Result := FImages.Add(img);
|
Result := FImages.Add(img);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ Assigns a hyperlink to an image. The image is specified by its index in the
|
||||||
|
internal image list}
|
||||||
|
procedure TsWorksheet.AddHyperlinkToImage(AImageIndex: Integer; ATarget: String;
|
||||||
|
AToolTip: String = '');
|
||||||
|
var
|
||||||
|
img: PsImage;
|
||||||
|
begin
|
||||||
|
img := GetPointerToImage(AImageIndex);
|
||||||
|
if Assigned(img) then begin
|
||||||
|
img^.HyperlinkTarget := ATarget;
|
||||||
|
img^.HyperlinkToolTip := AToolTip;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Removes an image from the internal image list.
|
Removes an image from the internal image list.
|
||||||
The image is identified by its index.
|
The image is identified by its index.
|
||||||
@ -4027,7 +4043,11 @@ var
|
|||||||
img: PsImage;
|
img: PsImage;
|
||||||
begin
|
begin
|
||||||
img := PsImage(FImages[AIndex]);
|
img := PsImage(FImages[AIndex]);
|
||||||
if (img <> nil) and (img^.Bitmap <> nil) then img^.Bitmap.Free;
|
if (img <> nil) then begin
|
||||||
|
if (img^.Bitmap <> nil) then img^.Bitmap.Free;
|
||||||
|
img^.HyperlinkTarget := '';
|
||||||
|
img^.HyperlinkToolTip := '';
|
||||||
|
end;
|
||||||
Dispose(img);
|
Dispose(img);
|
||||||
FImages.Delete(AIndex);
|
FImages.Delete(AIndex);
|
||||||
end;
|
end;
|
||||||
|
@ -823,6 +823,8 @@ type
|
|||||||
OffsetX, OffsetY: Double; // mm, relative to anchor
|
OffsetX, OffsetY: Double; // mm, relative to anchor
|
||||||
ScaleX, ScaleY: Double; // scaling factor of image
|
ScaleX, ScaleY: Double; // scaling factor of image
|
||||||
Bitmap: TObject; // used for bitmap for display in grid
|
Bitmap: TObject; // used for bitmap for display in grid
|
||||||
|
HyperlinkTarget: String; // Hyperlink assigned to the image
|
||||||
|
HyperlinkToolTip: String; // Tooltip for hyperlink of the image
|
||||||
end;
|
end;
|
||||||
PsImage = ^TsImage;
|
PsImage = ^TsImage;
|
||||||
|
|
||||||
|
@ -2495,6 +2495,8 @@ begin
|
|||||||
AValue.ScaleY := AScaleY;
|
AValue.ScaleY := AScaleY;
|
||||||
AValue.Bitmap := nil; // to be initialized by viewing application
|
AValue.Bitmap := nil; // to be initialized by viewing application
|
||||||
AValue.Index := -1;
|
AValue.Index := -1;
|
||||||
|
AValue.HyperlinkTarget := '';
|
||||||
|
AValue.HyperlinkToolTip := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user