You've already forked lazarus-ccr
fpspreadsheet: Read image hyperlinks for ODS (old format). Display image hyperlinks in TsSpreadsheetInspector.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6673 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4050,14 +4050,45 @@ end;
|
|||||||
'</draw:frame>', [
|
'</draw:frame>', [
|
||||||
}
|
}
|
||||||
procedure TsSpreadOpenDocReader.ReadShapes(ATableNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadShapes(ATableNode: TDOMNode);
|
||||||
|
|
||||||
|
procedure ReadFrame(ANode: TDOMNode; AHLink: String);
|
||||||
|
var
|
||||||
|
r, c: Cardinal;
|
||||||
|
x, y, w, h: Double;
|
||||||
|
dr, dc, sx, sy: Double;
|
||||||
|
childNode: TDOMNode;
|
||||||
|
idx: Integer;
|
||||||
|
href: String;
|
||||||
|
img: PsImage;
|
||||||
|
begin
|
||||||
|
x := PtsToMM(HTMLLengthStrToPts(GetAttrValue(ANode, 'svg:x')));
|
||||||
|
y := PtsToMM(HTMLLengthStrToPts(GetAttrValue(ANode, 'svg:y')));
|
||||||
|
w := PtsToMM(HTMLLengthStrToPts(GetAttrValue(ANode, 'svg:width')));
|
||||||
|
h := PtsToMM(HTMLLengthStrToPts(GetAttrValue(ANode, 'svg:height')));
|
||||||
|
childNode := ANode.FirstChild;
|
||||||
|
while Assigned(childNode) do
|
||||||
|
begin
|
||||||
|
href := GetAttrValue(childNode, 'xlink:href');
|
||||||
|
if href <> '' then
|
||||||
|
begin
|
||||||
|
idx := TsWorkbook(FWorkbook).FindEmbeddedObj(ExtractFileName(href));
|
||||||
|
with FWorksheet as TsWorksheet do begin
|
||||||
|
CalcImageCell(idx, x, y, w, h, r, c, dr, dc, sx, sy);
|
||||||
|
idx := WriteImage(r, c, idx, dc, dr, sx, sy); // order of dc and dr is correct!
|
||||||
|
if AHLink <> '' then begin
|
||||||
|
img := GetPointerToImage(idx);
|
||||||
|
img^.HyperlinkTarget := AHLink;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
childNode := ANode.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
shapesNode, shapeNode, childShapeNode: TDOMNode;
|
shapesNode, shapeNode, childNode: TDOMNode;
|
||||||
nodeName: String;
|
nodeName: String;
|
||||||
r, c: Cardinal;
|
hlink: String;
|
||||||
w, h, x, y: Double;
|
|
||||||
dr, dc, sx, sy: Double;
|
|
||||||
idx: Integer;
|
|
||||||
href: String;
|
|
||||||
begin
|
begin
|
||||||
shapesNode := ATableNode.FirstChild;
|
shapesNode := ATableNode.FirstChild;
|
||||||
while Assigned(shapesNode) do
|
while Assigned(shapesNode) do
|
||||||
@ -4070,24 +4101,19 @@ begin
|
|||||||
begin
|
begin
|
||||||
nodeName := shapeNode.NodeName;
|
nodeName := shapeNode.NodeName;
|
||||||
if nodeName = 'draw:frame' then
|
if nodeName = 'draw:frame' then
|
||||||
begin
|
ReadFrame(shapeNode, '')
|
||||||
x := PtsToMM(HTMLLengthStrToPts(GetAttrValue(shapeNode, 'svg:x')));
|
else
|
||||||
y := PtsToMM(HTMLLengthStrToPts(GetAttrValue(shapeNode, 'svg:y')));
|
if nodeName = 'draw:a' then begin
|
||||||
w := PtsToMM(HTMLLengthStrToPts(GetAttrValue(shapeNode, 'svg:width')));
|
hlink := GetAttrValue(shapeNode, 'xlink:href');
|
||||||
h := PtsToMM(HTMLLengthStrToPts(GetAttrValue(shapeNode, 'svg:height')));
|
if Lowercase(GetAttrValue(shapeNode, 'xlink:type')) = 'simple' then
|
||||||
childShapeNode := shapeNode.FirstChild;
|
|
||||||
while Assigned(childShapeNode) do
|
|
||||||
begin
|
begin
|
||||||
href := GetAttrValue(childShapeNode, 'xlink:href');
|
childNode := shapeNode.FirstChild;
|
||||||
if href <> '' then
|
while assigned(childNode) do begin
|
||||||
begin
|
nodeName := childNode.NodeName;
|
||||||
idx := TsWorkbook(FWorkbook).FindEmbeddedObj(ExtractFileName(href));
|
if nodeName = 'draw:frame' then
|
||||||
with FWorksheet as TsWorksheet do begin
|
ReadFrame(childNode, hlink);
|
||||||
CalcImageCell(idx, x, y, w, h, r, c, dr, dc, sx, sy);
|
childNode := childNode.NextSibling;
|
||||||
WriteImage(r, c, idx, dc, dr, sx, sy); // order of dc and dr is correct!
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
childShapeNode := childShapeNode.NextSibling;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
shapeNode := shapeNode.NextSibling;
|
shapeNode := shapeNode.NextSibling;
|
||||||
|
@ -4126,6 +4126,8 @@ begin
|
|||||||
AStrings.Add(Format(' OffsetY=%.2f mm', [img.OffsetY]));
|
AStrings.Add(Format(' OffsetY=%.2f mm', [img.OffsetY]));
|
||||||
AStrings.Add(Format(' ScaleX=%.2f', [img.ScaleX]));
|
AStrings.Add(Format(' ScaleX=%.2f', [img.ScaleX]));
|
||||||
AStrings.Add(Format(' ScaleY=%.2f', [img.ScaleY]));
|
AStrings.Add(Format(' ScaleY=%.2f', [img.ScaleY]));
|
||||||
|
AStrings.Add(Format(' HyperlinkTarget=%s', [img.HyperlinkTarget]));
|
||||||
|
AStrings.Add(Format(' HyperlinkTooltip=%s', [img.HyperlinkToolTip]));
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
AStrings.Add('(+) Images=(dblclick for more...)');
|
AStrings.Add('(+) Images=(dblclick for more...)');
|
||||||
|
Reference in New Issue
Block a user