mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 22:18:15 +02:00
fpvectorial: Fixes multiline table row, fixes crash in html with images, fixes style of table header
git-svn-id: trunk@49103 -
This commit is contained in:
parent
5748dddb92
commit
74776f4677
@ -1301,8 +1301,8 @@ type
|
||||
// List of common styles, for conveniently finding them
|
||||
StyleTextBody, StyleHeading1, StyleHeading2, StyleHeading3,
|
||||
StyleHeading4, StyleHeading5, StyleHeading6: TvStyle;
|
||||
StyleTextBodyCentralized, StyleHeading1Centralized,
|
||||
StyleHeading2Centralized, StyleHeading3Centralized: TvStyle;
|
||||
StyleTextBodyCentralized, StyleTextBodyBold: TvStyle; // text body modifications
|
||||
StyleHeading1Centralized, StyleHeading2Centralized, StyleHeading3Centralized: TvStyle; // heading modifications
|
||||
StyleBulletList, StyleNumberList : TvListStyle;
|
||||
StyleTextSpanBold, StyleTextSpanItalic, StyleTextSpanUnderline: TvStyle;
|
||||
{ Base methods }
|
||||
@ -1529,6 +1529,7 @@ type
|
||||
protected
|
||||
FFilename: string;
|
||||
class function GetTextContentsFromNode(ANode: TDOMNode): DOMString;
|
||||
class function RemoveLineEndingsAndTrim(AStr: string): string;
|
||||
public
|
||||
{ General reading methods }
|
||||
constructor Create; virtual;
|
||||
@ -4244,7 +4245,7 @@ var
|
||||
lTextWidth: Integer;
|
||||
{$endif}
|
||||
begin
|
||||
//lText := Value.Text; // for debugging
|
||||
lText := Value.Text + Format(' F=%d', [ADest.Font.Size]); // for debugging
|
||||
inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY, ADoDraw);
|
||||
|
||||
InitializeRenderInfo(ARenderInfo);
|
||||
@ -4285,6 +4286,7 @@ begin
|
||||
Render_NextText_X := CoordToCanvasX(X)+XAnchorAdjustment;
|
||||
if ADoDraw then
|
||||
ADest.TextOut(Render_NextText_X, Round(LowerDim.Y), lText);
|
||||
//lText := lText + Format(' F=%d', [ADest.Font.Size]); // for debugging
|
||||
|
||||
CalcEntityCanvasMinMaxXY(ARenderInfo, Render_NextText_X, Round(LowerDim.Y));
|
||||
lTextSize := ACanvas.TextExtent(lText);
|
||||
@ -8343,6 +8345,12 @@ begin
|
||||
StyleTextBodyCentralized.Alignment := vsaCenter;
|
||||
StyleTextBodyCentralized.SetElements := StyleTextBodyCentralized.SetElements + [spbfAlignment];
|
||||
|
||||
StyleTextBodyBold := AddStyle();
|
||||
StyleTextBodyBold.ApplyOver(StyleTextBody);
|
||||
StyleTextBodyBold.Name := 'Text Body Bold';
|
||||
StyleTextBodyBold.Font.Bold := True;
|
||||
StyleTextBodyBold.SetElements := StyleTextBodyCentralized.SetElements + [spbfFontBold];
|
||||
|
||||
StyleHeading1Centralized := AddStyle();
|
||||
StyleHeading1Centralized.ApplyOver(StyleHeading1);
|
||||
StyleHeading1Centralized.Name := 'Heading 1 Centered';
|
||||
@ -8530,6 +8538,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TvCustomVectorialReader.RemoveLineEndingsAndTrim(AStr: string): string;
|
||||
begin
|
||||
Result := Trim(AStr);
|
||||
Result := StringReplace(Result, #13, '', [rfReplaceAll]);
|
||||
Result := StringReplace(Result, #10, '', [rfReplaceAll]);
|
||||
end;
|
||||
|
||||
constructor TvCustomVectorialReader.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
|
@ -133,8 +133,7 @@ procedure TvHTMLVectorialReader.ReadParagraphFromNode(ADest: TvParagraph; ANode:
|
||||
AData: TvTextPageSequence; ADoc: TvVectorialDocument);
|
||||
var
|
||||
lText: TvText = nil;
|
||||
lTextSeparatedByBR: Boolean = False;
|
||||
lTextStr: string;
|
||||
lTextStr: string = '';
|
||||
lCurNode: TDOMNode;
|
||||
lNodeName, lNodeValue, lAttrName, lAttrValue: DOMString;
|
||||
lCurAttr: TDOMNode;
|
||||
@ -150,6 +149,19 @@ var
|
||||
lImageData: array of Byte;
|
||||
lImageDataStream: TMemoryStream;
|
||||
lImageReader: TFPCustomImageReader;
|
||||
|
||||
procedure TextMerging();
|
||||
begin
|
||||
if lTextStr <> '' then
|
||||
begin
|
||||
if lText = nil then
|
||||
lText := ADest.AddText(lTextStr)
|
||||
else
|
||||
lText.Value.Add(lTextStr);
|
||||
lTextStr := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
ADest.Style := ADoc.StyleTextBody;
|
||||
|
||||
@ -159,31 +171,18 @@ begin
|
||||
lNodeName := LowerCase(lCurNode.NodeName);
|
||||
lNodeValue := lCurNode.NodeValue;
|
||||
|
||||
if (lCurNode is TDOMText) and not lTextSeparatedByBR then
|
||||
if (lCurNode is TDOMText) then
|
||||
begin
|
||||
lTextStr := lNodeValue;
|
||||
lText := ADest.AddText(lTextStr);
|
||||
lCurNode := lCurNode.NextSibling;
|
||||
Continue;
|
||||
end
|
||||
// If after a text we get a <br /> or a TDOMText, merge them
|
||||
else if (lNodeName = 'br') and (lText <> nil) then
|
||||
begin
|
||||
lTextSeparatedByBR := True;
|
||||
lCurNode := lCurNode.NextSibling;
|
||||
Continue;
|
||||
end
|
||||
else if (lCurNode is TDOMText) and lTextSeparatedByBR then
|
||||
begin
|
||||
lTextStr := lNodeValue;
|
||||
lText.Value.Add(lTextStr);
|
||||
lTextStr += RemoveLineEndingsAndTrim(lNodeValue);
|
||||
lCurNode := lCurNode.NextSibling;
|
||||
Continue;
|
||||
end;
|
||||
|
||||
// text merging
|
||||
TextMerging();
|
||||
// reset text merging
|
||||
lText := nil;
|
||||
lTextSeparatedByBR := False;
|
||||
if lNodeName <> 'br' then
|
||||
lText := nil;
|
||||
|
||||
case lNodeName of
|
||||
// <image width="100" height="100" xlink:href="data:image/png;base64,UgAAA....QSK5CYII="/>
|
||||
@ -198,8 +197,9 @@ begin
|
||||
|
||||
for i := 0 to lCurNode.Attributes.Length - 1 do
|
||||
begin
|
||||
lAttrName := lCurNode.Attributes.Item[i].NodeName;
|
||||
lAttrValue := lCurNode.Attributes.Item[i].NodeValue;
|
||||
lCurAttr := lCurNode.Attributes.Item[i];
|
||||
lAttrName := lCurAttr.NodeName;
|
||||
lAttrValue := lCurAttr.NodeValue;
|
||||
|
||||
case lAttrName of
|
||||
'alt':
|
||||
@ -284,6 +284,8 @@ begin
|
||||
|
||||
lCurNode := lCurNode.NextSibling;
|
||||
end;
|
||||
|
||||
TextMerging();
|
||||
end;
|
||||
|
||||
function TvHTMLVectorialReader.ReadSVGFromNode(ANode: TDOMNode;
|
||||
@ -443,7 +445,7 @@ begin
|
||||
begin
|
||||
CurCell := CurRow.AddCell();
|
||||
CurCellPara := CurCell.AddParagraph();
|
||||
CurCellPara.Style := ADoc.StyleTextSpanBold;
|
||||
CurCellPara.Style := ADoc.StyleTextBodyBold;
|
||||
CurCellPara.AddText(GetTextContentFromNode(lCurNode));
|
||||
end;
|
||||
'td':
|
||||
|
@ -2647,9 +2647,7 @@ var
|
||||
else if lNodeName = 'textpath' then
|
||||
begin
|
||||
lTextStr := GetTextContentFromNode(lCurNode);
|
||||
lTextStr := StringReplace(lTextStr, #13#10, '', [rfReplaceAll]);
|
||||
lTextStr := StringReplace(lTextStr, #13, '', [rfReplaceAll]);
|
||||
lTextStr := StringReplace(lTextStr, #10, '', [rfReplaceAll]);
|
||||
lTextStr := RemoveLineEndingsAndTrim(lTextStr);
|
||||
lTextStr := Trim(lTextStr);
|
||||
|
||||
lCText := lParagraph.AddCurvedText(lTextStr);
|
||||
|
Loading…
Reference in New Issue
Block a user