fpvectorial: Adds skeleton for MathML support

git-svn-id: trunk@36798 -
This commit is contained in:
sekelsenmat 2012-04-15 18:00:43 +00:00
parent 400e093b67
commit b7d551eece
5 changed files with 105 additions and 3 deletions

1
.gitattributes vendored
View File

@ -1020,6 +1020,7 @@ components/fpvectorial/fpvectorialpkg.pas svneol=native#text/plain
components/fpvectorial/fpvtocanvas.pas svneol=native#text/plain
components/fpvectorial/fpvutils.pas svneol=native#text/plain
components/fpvectorial/lasvectorialreader.pas svneol=native#text/plain
components/fpvectorial/mathmlvectorialreader.pas svneol=native#text/plain
components/fpvectorial/pdfvectorialreader.pas svneol=native#text/plain
components/fpvectorial/pdfvrlexico.pas svneol=native#text/plain
components/fpvectorial/pdfvrsemantico.pas svneol=native#text/plain

View File

@ -41,7 +41,9 @@ type
vfPostScript, vfEncapsulatedPostScript,
{ GCode formats }
vfGCodeAvisoCNCPrototipoV5, vfGCodeAvisoCNCPrototipoV6,
{ Other formats }
{ Formula formats }
vfMathML,
{ Raster Image formats }
vfRAW
);

View File

@ -12,7 +12,7 @@
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="14">
<Files Count="15">
<Item1>
<Filename Value="svgvectorialwriter.pas"/>
<UnitName Value="svgvectorialwriter"/>
@ -69,6 +69,10 @@
<Filename Value="rawvectorialreadwrite.pas"/>
<UnitName Value="rawvectorialreadwrite"/>
</Item14>
<Item15>
<Filename Value="mathmlvectorialreader.pas"/>
<UnitName Value="mathmlvectorialreader"/>
</Item15>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">

View File

@ -10,7 +10,8 @@ uses
svgvectorialwriter, fpvtocanvas, fpvectorial, fpvectbuildunit,
dxfvectorialreader, cdrvectorialreader, avisozlib, avisocncgcodewriter,
avisocncgcodereader, svgvectorialreader, epsvectorialreader, fpvutils,
lasvectorialreader, rawvectorialreadwrite, LazarusPackageIntf;
lasvectorialreader, rawvectorialreadwrite, mathmlvectorialreader,
LazarusPackageIntf;
implementation

View File

@ -0,0 +1,94 @@
{
Reads a MathML Document
License: The same modified LGPL as the Free Pascal RTL
See the file COPYING.modifiedLGPL for more details
AUTHORS: Felipe Monteiro de Carvalho
}
unit mathmlvectorialreader;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, math,
xmlread, dom,
fpvectorial, fpvutils;
type
{ TvMathMLVectorialReader }
TvMathMLVectorialReader = class(TvCustomVectorialReader)
private
FPointSeparator, FCommaSeparator: TFormatSettings;
function StringToFloat(AStr: string): Single;
public
{ General reading methods }
constructor Create; override;
Destructor Destroy; override;
procedure ReadFromStream(AStream: TStream; AData: TvVectorialDocument); override;
end;
implementation
{ TvMathMLVectorialReader }
function TvMathMLVectorialReader.StringToFloat(AStr: string): Single;
begin
Result := StrToInt(AStr);
end;
constructor TvMathMLVectorialReader.Create;
begin
inherited Create;
FPointSeparator := DefaultFormatSettings;
FPointSeparator.DecimalSeparator := '.';
FPointSeparator.ThousandSeparator := '#';// disable the thousand separator
end;
destructor TvMathMLVectorialReader.Destroy;
begin
inherited Destroy;
end;
procedure TvMathMLVectorialReader.ReadFromStream(AStream: TStream;
AData: TvVectorialDocument);
var
Doc: TXMLDocument;
lFirstLayer, lCurNode: TDOMNode;
lPage: TvVectorialPage;
begin
try
// Read in xml file from the stream
ReadXMLFile(Doc, AStream);
{// Read the properties of the <svg> tag
AData.Width := StringWithUnitToFloat(Doc.DocumentElement.GetAttribute('width'));
AData.Height := StringWithUnitToFloat(Doc.DocumentElement.GetAttribute('height'));}
// Now process the elements inside the first layer
lFirstLayer := Doc.DocumentElement.FirstChild;
lCurNode := lFirstLayer.FirstChild;
lPage := AData.AddPage();
lPage.Width := AData.Width;
lPage.Height := AData.Height;
while Assigned(lCurNode) do
begin
//ReadFormulaFromNode(lCurNode, lPage, AData);
lCurNode := lCurNode.NextSibling;
end;
finally
// finally, free the document
Doc.Free;
end;
end;
initialization
RegisterVectorialReader(TvMathMLVectorialReader, vfMathML);
end.