mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-05 22:19:27 +01:00
fpvectorial: Fixes parsing pi named element from xml in mathml
git-svn-id: trunk@46937 -
This commit is contained in:
parent
599eb6c7ed
commit
8c6bb2e752
@ -12,7 +12,7 @@ AUTHORS: Felipe Monteiro de Carvalho
|
|||||||
unit fpvectorial;
|
unit fpvectorial;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef fpc}
|
||||||
{$mode delphi}
|
{$mode objfpc}{$h+}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$define USE_LCL_CANVAS}
|
{$define USE_LCL_CANVAS}
|
||||||
@ -1410,6 +1410,8 @@ type
|
|||||||
{ TvCustomVectorialReader }
|
{ TvCustomVectorialReader }
|
||||||
|
|
||||||
TvCustomVectorialReader = class
|
TvCustomVectorialReader = class
|
||||||
|
protected
|
||||||
|
class function GetTextContentsFromNode(ANode: TDOMNode): DOMString;
|
||||||
public
|
public
|
||||||
{ General reading methods }
|
{ General reading methods }
|
||||||
constructor Create; virtual;
|
constructor Create; virtual;
|
||||||
@ -1931,7 +1933,7 @@ begin
|
|||||||
// Page style
|
// Page style
|
||||||
sseMarginTop, sseMarginBottom, sseMarginLeft, sseMarginRight
|
sseMarginTop, sseMarginBottom, sseMarginLeft, sseMarginRight
|
||||||
);
|
);
|
||||||
{ Font.Size, Font.Name, Font.Orientation,
|
Font.Size, Font.Name, Font.Orientation,
|
||||||
BoolToStr(Font.Underline),
|
BoolToStr(Font.Underline),
|
||||||
BoolToStr(Font.StrikeThrough),
|
BoolToStr(Font.StrikeThrough),
|
||||||
GetEnumName(TypeInfo(TvTextAnchor), integer(TextAnchor))}
|
GetEnumName(TypeInfo(TvTextAnchor), integer(TextAnchor))}
|
||||||
@ -2043,7 +2045,7 @@ begin
|
|||||||
|
|
||||||
// SolveNumerically
|
// SolveNumerically
|
||||||
|
|
||||||
lT1 := SolveNumericallyAngle(AlignedEllipseCenterEquationT1, 0.0001, 20);
|
lT1 := SolveNumericallyAngle(@AlignedEllipseCenterEquationT1, 0.0001, 20);
|
||||||
|
|
||||||
CX1 := E1.X - RX*cos(lt1);
|
CX1 := E1.X - RX*cos(lt1);
|
||||||
CY1 := E1.Y - RY*sin(lt1);
|
CY1 := E1.Y - RY*sin(lt1);
|
||||||
@ -3020,7 +3022,7 @@ var
|
|||||||
CurveLength: Integer;
|
CurveLength: Integer;
|
||||||
t: Double;
|
t: Double;
|
||||||
// For polygons
|
// For polygons
|
||||||
Points: array of TPoint;
|
lPoints: array of TPoint;
|
||||||
// for elliptical arcs
|
// for elliptical arcs
|
||||||
BoxLeft, BoxTop, BoxRight, BoxBottom: Double;
|
BoxLeft, BoxTop, BoxRight, BoxBottom: Double;
|
||||||
EllipseRect: TRect;
|
EllipseRect: TRect;
|
||||||
@ -3056,8 +3058,8 @@ begin
|
|||||||
DeleteObject(ClipRegion);
|
DeleteObject(ClipRegion);
|
||||||
// debug info
|
// debug info
|
||||||
{$ifdef DEBUG_CANVAS_CLIP_REGION}
|
{$ifdef DEBUG_CANVAS_CLIP_REGION}
|
||||||
ConvertPathToPoints(CurPath.ClipPath, ADestX, ADestY, AMulX, AMulY, Points);
|
ConvertPathToPoints(CurPath.ClipPath, ADestX, ADestY, AMulX, AMulY, lPoints);
|
||||||
ACanvas.Polygon(Points);
|
ACanvas.Polygon(lPoints);
|
||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -3133,18 +3135,18 @@ begin
|
|||||||
CoordY3 := CoordToCanvasY(Cur2DBSegment.Y3);
|
CoordY3 := CoordToCanvasY(Cur2DBSegment.Y3);
|
||||||
CoordX4 := CoordToCanvasX(Cur2DBSegment.X);
|
CoordX4 := CoordToCanvasX(Cur2DBSegment.X);
|
||||||
CoordY4 := CoordToCanvasY(Cur2DBSegment.Y);
|
CoordY4 := CoordToCanvasY(Cur2DBSegment.Y);
|
||||||
SetLength(Points, 0);
|
SetLength(lPoints, 0);
|
||||||
AddBezierToPoints(
|
AddBezierToPoints(
|
||||||
Make2DPoint(CoordX, CoordY),
|
Make2DPoint(CoordX, CoordY),
|
||||||
Make2DPoint(CoordX2, CoordY2),
|
Make2DPoint(CoordX2, CoordY2),
|
||||||
Make2DPoint(CoordX3, CoordY3),
|
Make2DPoint(CoordX3, CoordY3),
|
||||||
Make2DPoint(CoordX4, CoordY4),
|
Make2DPoint(CoordX4, CoordY4),
|
||||||
Points
|
lPoints
|
||||||
);
|
);
|
||||||
|
|
||||||
ADest.Brush.Style := Brush.Style;
|
ADest.Brush.Style := Brush.Style;
|
||||||
if Length(Points) >= 3 then
|
if Length(lPoints) >= 3 then
|
||||||
ADest.Polygon(Points);
|
ADest.Polygon(lPoints);
|
||||||
|
|
||||||
PosX := Cur2DSegment.X;
|
PosX := Cur2DSegment.X;
|
||||||
PosY := Cur2DSegment.Y;
|
PosY := Cur2DSegment.Y;
|
||||||
@ -3184,7 +3186,7 @@ begin
|
|||||||
CoordX3 := CoordToCanvasX(Cur2DArcSegment.XRotation);
|
CoordX3 := CoordToCanvasX(Cur2DArcSegment.XRotation);
|
||||||
CoordX4 := CoordToCanvasX(Cur2DArcSegment.X);
|
CoordX4 := CoordToCanvasX(Cur2DArcSegment.X);
|
||||||
CoordY4 := CoordToCanvasY(Cur2DArcSegment.Y);
|
CoordY4 := CoordToCanvasY(Cur2DArcSegment.Y);
|
||||||
SetLength(Points, 0);
|
SetLength(lPoints, 0);
|
||||||
|
|
||||||
Cur2DArcSegment.CalculateEllipseBoundingBox(nil, BoxLeft, BoxTop, BoxRight, BoxBottom);
|
Cur2DArcSegment.CalculateEllipseBoundingBox(nil, BoxLeft, BoxTop, BoxRight, BoxBottom);
|
||||||
|
|
||||||
@ -4773,14 +4775,14 @@ end;
|
|||||||
function TvFormula.GetFirstElement: TvFormulaElement;
|
function TvFormula.GetFirstElement: TvFormulaElement;
|
||||||
begin
|
begin
|
||||||
if FElements.Count = 0 then Exit(nil);
|
if FElements.Count = 0 then Exit(nil);
|
||||||
Result := FElements.Items[0];
|
Result := TvFormulaElement(FElements.Items[0]);
|
||||||
FCurIndex := 1;
|
FCurIndex := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TvFormula.GetNextElement: TvFormulaElement;
|
function TvFormula.GetNextElement: TvFormulaElement;
|
||||||
begin
|
begin
|
||||||
if FElements.Count <= FCurIndex then Exit(nil);
|
if FElements.Count <= FCurIndex then Exit(nil);
|
||||||
Result := FElements.Items[FCurIndex];
|
Result := TvFormulaElement(FElements.Items[FCurIndex]);
|
||||||
Inc(FCurIndex);
|
Inc(FCurIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4861,7 +4863,7 @@ begin
|
|||||||
try
|
try
|
||||||
for i := 0 to AInfix.Count-1 do
|
for i := 0 to AInfix.Count-1 do
|
||||||
begin
|
begin
|
||||||
CurItem := AInfix.Items[i];
|
CurItem := TvFormulaElement(AInfix.Items[i]);
|
||||||
case CurItem.Kind of
|
case CurItem.Kind of
|
||||||
fekVariable:
|
fekVariable:
|
||||||
begin
|
begin
|
||||||
@ -5026,7 +5028,7 @@ end;
|
|||||||
procedure TvFormula.Clear;
|
procedure TvFormula.Clear;
|
||||||
begin
|
begin
|
||||||
inherited Clear;
|
inherited Clear;
|
||||||
FElements.ForEachCall(CallbackDeleteElement, nil);
|
FElements.ForEachCall(@CallbackDeleteElement, nil);
|
||||||
FElements.Clear;
|
FElements.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5185,14 +5187,14 @@ end;
|
|||||||
function TvEntityWithSubEntities.GetFirstEntity: TvEntity;
|
function TvEntityWithSubEntities.GetFirstEntity: TvEntity;
|
||||||
begin
|
begin
|
||||||
if FElements.Count = 0 then Exit(nil);
|
if FElements.Count = 0 then Exit(nil);
|
||||||
Result := FElements.Items[0];
|
Result := TvEntity(FElements.Items[0]);
|
||||||
FCurIndex := 1;
|
FCurIndex := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TvEntityWithSubEntities.GetNextEntity: TvEntity;
|
function TvEntityWithSubEntities.GetNextEntity: TvEntity;
|
||||||
begin
|
begin
|
||||||
if FElements.Count <= FCurIndex then Exit(nil);
|
if FElements.Count <= FCurIndex then Exit(nil);
|
||||||
Result := FElements.Items[FCurIndex];
|
Result := TvEntity(FElements.Items[FCurIndex]);
|
||||||
Inc(FCurIndex);
|
Inc(FCurIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5225,7 +5227,7 @@ function TvEntityWithSubEntities.DeleteEntity(AIndex: Cardinal): Boolean;
|
|||||||
var
|
var
|
||||||
lEntity: TvEntity;
|
lEntity: TvEntity;
|
||||||
begin
|
begin
|
||||||
lEntity := FElements.Items[AIndex];
|
lEntity := TvEntity(FElements.Items[AIndex]);
|
||||||
FElements.Remove(lEntity);
|
FElements.Remove(lEntity);
|
||||||
lEntity.Free;
|
lEntity.Free;
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -5257,7 +5259,7 @@ end;
|
|||||||
procedure TvEntityWithSubEntities.Clear;
|
procedure TvEntityWithSubEntities.Clear;
|
||||||
begin
|
begin
|
||||||
inherited Clear;
|
inherited Clear;
|
||||||
FElements.ForEachCall(CallbackDeleteElement, nil);
|
FElements.ForEachCall(@CallbackDeleteElement, nil);
|
||||||
FElements.Clear;
|
FElements.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5909,7 +5911,7 @@ end;
|
|||||||
|
|
||||||
procedure TvVectorialPage.Clear;
|
procedure TvVectorialPage.Clear;
|
||||||
begin
|
begin
|
||||||
FEntities.ForEachCall(CallbackDeleteEntity, nil);
|
FEntities.ForEachCall(@CallbackDeleteEntity, nil);
|
||||||
FEntities.Clear();
|
FEntities.Clear();
|
||||||
ClearTmpPath();
|
ClearTmpPath();
|
||||||
ClearLayerSelection();
|
ClearLayerSelection();
|
||||||
@ -7317,6 +7319,34 @@ end;
|
|||||||
|
|
||||||
{ TvCustomVectorialReader }
|
{ TvCustomVectorialReader }
|
||||||
|
|
||||||
|
class function TvCustomVectorialReader.GetTextContentsFromNode(ANode: TDOMNode): DOMString;
|
||||||
|
var
|
||||||
|
lNodeTextTmp: DOMString;
|
||||||
|
lContentNode: TDOMNode;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
|
||||||
|
for lContentNode in ANode.GetEnumeratorAllChildren() do
|
||||||
|
begin
|
||||||
|
if lContentNode is TDOMText then
|
||||||
|
lNodeTextTmp := TDOMText(lContentNode).TextContent
|
||||||
|
else if lContentNode is TDOMEntityReference then
|
||||||
|
begin
|
||||||
|
lNodeTextTmp := UTF8LowerCase(lContentNode.NodeName);
|
||||||
|
case lNodeTextTmp of
|
||||||
|
'pi': lNodeTextTmp := 'π';
|
||||||
|
'invisibletimes': lNodeTextTmp := '';
|
||||||
|
else
|
||||||
|
lNodeTextTmp := '';//lContentNode.NodeName;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
lNodeTextTmp := lContentNode.NodeName;
|
||||||
|
|
||||||
|
Result := Result + lNodeTextTmp;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TvCustomVectorialReader.Create;
|
constructor TvCustomVectorialReader.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, math,
|
Classes, SysUtils, math,
|
||||||
laz2_xmlread, laz2_dom,
|
laz2_xmlread, laz2_dom,
|
||||||
fpvectorial, fpvutils;
|
fpvectorial, fpvutils, lazutf8;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TvMathMLVectorialReader }
|
{ TvMathMLVectorialReader }
|
||||||
@ -68,8 +68,8 @@ var
|
|||||||
lNodeTextLen: Integer;
|
lNodeTextLen: Integer;
|
||||||
begin
|
begin
|
||||||
lNodeName := ANode.NodeName;
|
lNodeName := ANode.NodeName;
|
||||||
if ANode.FirstChild <> nil then
|
lNodeText := GetTextContentsFromNode(ANode);
|
||||||
lNodeText := ANode.FirstChild.NodeValue;
|
|
||||||
// mi - variables
|
// mi - variables
|
||||||
// Examples:
|
// Examples:
|
||||||
// <mi>x</mi>
|
// <mi>x</mi>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user