improvement: 单位转换的调整

This commit is contained in:
csh 2025-08-06 18:16:15 +08:00
parent 9062457251
commit 16452c8362
6 changed files with 1301 additions and 1019 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ uses SharedML, TSSafeUnitConverter;
type MathPrUnitDecorator = class(MathPr) type MathPrUnitDecorator = class(MathPr)
public public
function Create(_obj: MathPr); function create(_obj: MathPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -13,7 +13,7 @@ end;
type OMathParaUnitDecorator = class(OMathPara) type OMathParaUnitDecorator = class(OMathPara)
public public
function Create(_obj: OMathPara); function create(_obj: OMathPara);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -22,7 +22,7 @@ end;
type OMathParaPrUnitDecorator = class(OMathParaPr) type OMathParaPrUnitDecorator = class(OMathParaPr)
public public
function Create(_obj: OMathParaPr); function create(_obj: OMathParaPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -31,7 +31,7 @@ end;
type PureMValUnitDecorator = class(PureMVal) type PureMValUnitDecorator = class(PureMVal)
public public
function Create(_obj: PureMVal); function create(_obj: PureMVal);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -40,7 +40,7 @@ end;
type OMathUnitDecorator = class(OMath) type OMathUnitDecorator = class(OMath)
public public
function Create(_obj: OMath); function create(_obj: OMath);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -49,7 +49,7 @@ end;
type RUnitDecorator = class(R) type RUnitDecorator = class(R)
public public
function Create(_obj: R); function create(_obj: R);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -58,7 +58,7 @@ end;
type RPrUnitDecorator = class(RPr) type RPrUnitDecorator = class(RPr)
public public
function Create(_obj: RPr); function create(_obj: RPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -67,7 +67,7 @@ end;
type TUnitDecorator = class(T) type TUnitDecorator = class(T)
public public
function Create(_obj: T); function create(_obj: T);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -76,7 +76,7 @@ end;
type DUnitDecorator = class(D) type DUnitDecorator = class(D)
public public
function Create(_obj: D); function create(_obj: D);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -85,7 +85,7 @@ end;
type DPrUnitDecorator = class(DPr) type DPrUnitDecorator = class(DPr)
public public
function Create(_obj: DPr); function create(_obj: DPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -94,7 +94,7 @@ end;
type CtrlPrUnitDecorator = class(CtrlPr) type CtrlPrUnitDecorator = class(CtrlPr)
public public
function Create(_obj: CtrlPr); function create(_obj: CtrlPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -103,7 +103,7 @@ end;
type SSupUnitDecorator = class(SSup) type SSupUnitDecorator = class(SSup)
public public
function Create(_obj: SSup); function create(_obj: SSup);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -112,7 +112,7 @@ end;
type SSupPrUnitDecorator = class(SSupPr) type SSupPrUnitDecorator = class(SSupPr)
public public
function Create(_obj: SSupPr); function create(_obj: SSupPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -121,7 +121,7 @@ end;
type FUnitDecorator = class(F) type FUnitDecorator = class(F)
public public
function Create(_obj: F); function create(_obj: F);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -130,7 +130,7 @@ end;
type FPrUnitDecorator = class(FPr) type FPrUnitDecorator = class(FPr)
public public
function Create(_obj: FPr); function create(_obj: FPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -139,7 +139,7 @@ end;
type RadUnitDecorator = class(Rad) type RadUnitDecorator = class(Rad)
public public
function Create(_obj: Rad); function create(_obj: Rad);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -148,7 +148,7 @@ end;
type RadPrUnitDecorator = class(RadPr) type RadPrUnitDecorator = class(RadPr)
public public
function Create(_obj: RadPr); function create(_obj: RadPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -157,7 +157,7 @@ end;
type SSubUnitDecorator = class(SSub) type SSubUnitDecorator = class(SSub)
public public
function Create(_obj: SSub); function create(_obj: SSub);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -166,7 +166,7 @@ end;
type SSubPrUnitDecorator = class(SSubPr) type SSubPrUnitDecorator = class(SSubPr)
public public
function Create(_obj: SSubPr); function create(_obj: SSubPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -175,7 +175,7 @@ end;
type NaryUnitDecorator = class(Nary) type NaryUnitDecorator = class(Nary)
public public
function Create(_obj: Nary); function create(_obj: Nary);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -184,7 +184,7 @@ end;
type NaryPrUnitDecorator = class(NaryPr) type NaryPrUnitDecorator = class(NaryPr)
public public
function Create(_obj: NaryPr); function create(_obj: NaryPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -193,7 +193,7 @@ end;
type FuncUnitDecorator = class(Func) type FuncUnitDecorator = class(Func)
public public
function Create(_obj: Func); function create(_obj: Func);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -202,7 +202,7 @@ end;
type FNameUnitDecorator = class(FName) type FNameUnitDecorator = class(FName)
public public
function Create(_obj: FName); function create(_obj: FName);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -211,7 +211,7 @@ end;
type FuncPrUnitDecorator = class(FuncPr) type FuncPrUnitDecorator = class(FuncPr)
public public
function Create(_obj: FuncPr); function create(_obj: FuncPr);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -220,7 +220,7 @@ end;
type CorePropertiesUnitDecorator = class(CoreProperties) type CorePropertiesUnitDecorator = class(CoreProperties)
public public
function Create(_obj: CoreProperties); function create(_obj: CoreProperties);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -229,7 +229,7 @@ end;
type CreatedUnitDecorator = class(Created) type CreatedUnitDecorator = class(Created)
public public
function Create(_obj: Created); function create(_obj: Created);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -238,7 +238,7 @@ end;
type ModifiedUnitDecorator = class(Modified) type ModifiedUnitDecorator = class(Modified)
public public
function Create(_obj: Modified); function create(_obj: Modified);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -247,7 +247,7 @@ end;
type RelationshipsUnitDecorator = class(Relationships) type RelationshipsUnitDecorator = class(Relationships)
public public
function Create(_obj: Relationships); function create(_obj: Relationships);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -256,7 +256,7 @@ end;
type RelationshipUnitDecorator = class(Relationship) type RelationshipUnitDecorator = class(Relationship)
public public
function Create(_obj: Relationship); function create(_obj: Relationship);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -265,7 +265,7 @@ end;
type TypesUnitDecorator = class(Types) type TypesUnitDecorator = class(Types)
public public
function Create(_obj: Types); function create(_obj: Types);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -274,7 +274,7 @@ end;
type DefaultUnitDecorator = class(Default) type DefaultUnitDecorator = class(Default)
public public
function Create(_obj: Default); function create(_obj: Default);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -283,7 +283,7 @@ end;
type _OverrideUnitDecorator = class(_Override) type _OverrideUnitDecorator = class(_Override)
public public
function Create(_obj: _Override); function create(_obj: _Override);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -292,7 +292,7 @@ end;
type NumUnitDecorator = class(Num) type NumUnitDecorator = class(Num)
public public
function Create(_obj: Num); function create(_obj: Num);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -301,7 +301,7 @@ end;
type DegUnitDecorator = class(Deg) type DegUnitDecorator = class(Deg)
public public
function Create(_obj: Deg); function create(_obj: Deg);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -310,7 +310,7 @@ end;
type EUnitDecorator = class(E) type EUnitDecorator = class(E)
public public
function Create(_obj: E); function create(_obj: E);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -319,7 +319,7 @@ end;
type SupUnitDecorator = class(Sup) type SupUnitDecorator = class(Sup)
public public
function Create(_obj: Sup); function create(_obj: Sup);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -328,7 +328,7 @@ end;
type DenUnitDecorator = class(Den) type DenUnitDecorator = class(Den)
public public
function Create(_obj: Den); function create(_obj: Den);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -337,7 +337,7 @@ end;
type SubUnitDecorator = class(Sub) type SubUnitDecorator = class(Sub)
public public
function Create(_obj: Sub); function create(_obj: Sub);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -346,9 +346,9 @@ end;
implementation implementation
function MathPrUnitDecorator.Create(_obj: MathPr); function MathPrUnitDecorator.create(_obj: MathPr);
begin begin
class(MathPr).Create(); class(MathPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -387,9 +387,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function OMathParaUnitDecorator.Create(_obj: OMathPara); function OMathParaUnitDecorator.create(_obj: OMathPara);
begin begin
class(OMathPara).Create(); class(OMathPara).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -410,9 +410,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function OMathParaPrUnitDecorator.Create(_obj: OMathParaPr); function OMathParaPrUnitDecorator.create(_obj: OMathParaPr);
begin begin
class(OMathParaPr).Create(); class(OMathParaPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -431,9 +431,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function PureMValUnitDecorator.Create(_obj: PureMVal); function PureMValUnitDecorator.create(_obj: PureMVal);
begin begin
class(PureMVal).Create(); class(PureMVal).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -452,9 +452,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function OMathUnitDecorator.Create(_obj: OMath); function OMathUnitDecorator.create(_obj: OMath);
begin begin
class(OMath).Create(); class(OMath).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -495,9 +495,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RUnitDecorator.Create(_obj: R); function RUnitDecorator.create(_obj: R);
begin begin
class(R).Create(); class(R).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -522,9 +522,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RPrUnitDecorator.Create(_obj: RPr); function RPrUnitDecorator.create(_obj: RPr);
begin begin
class(RPr).Create(); class(RPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -543,9 +543,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function TUnitDecorator.Create(_obj: T); function TUnitDecorator.create(_obj: T);
begin begin
class(T).Create(); class(T).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -564,9 +564,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function DUnitDecorator.Create(_obj: D); function DUnitDecorator.create(_obj: D);
begin begin
class(D).Create(); class(D).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -587,9 +587,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function DPrUnitDecorator.Create(_obj: DPr); function DPrUnitDecorator.create(_obj: DPr);
begin begin
class(DPr).Create(); class(DPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -620,9 +620,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function CtrlPrUnitDecorator.Create(_obj: CtrlPr); function CtrlPrUnitDecorator.create(_obj: CtrlPr);
begin begin
class(CtrlPr).Create(); class(CtrlPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -643,9 +643,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SSupUnitDecorator.Create(_obj: SSup); function SSupUnitDecorator.create(_obj: SSup);
begin begin
class(SSup).Create(); class(SSup).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -668,9 +668,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SSupPrUnitDecorator.Create(_obj: SSupPr); function SSupPrUnitDecorator.create(_obj: SSupPr);
begin begin
class(SSupPr).Create(); class(SSupPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -689,9 +689,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FUnitDecorator.Create(_obj: F); function FUnitDecorator.create(_obj: F);
begin begin
class(F).Create(); class(F).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -714,9 +714,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FPrUnitDecorator.Create(_obj: FPr); function FPrUnitDecorator.create(_obj: FPr);
begin begin
class(FPr).Create(); class(FPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -737,9 +737,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RadUnitDecorator.Create(_obj: Rad); function RadUnitDecorator.create(_obj: Rad);
begin begin
class(Rad).Create(); class(Rad).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -762,9 +762,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RadPrUnitDecorator.Create(_obj: RadPr); function RadPrUnitDecorator.create(_obj: RadPr);
begin begin
class(RadPr).Create(); class(RadPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -785,9 +785,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SSubUnitDecorator.Create(_obj: SSub); function SSubUnitDecorator.create(_obj: SSub);
begin begin
class(SSub).Create(); class(SSub).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -810,9 +810,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SSubPrUnitDecorator.Create(_obj: SSubPr); function SSubPrUnitDecorator.create(_obj: SSubPr);
begin begin
class(SSubPr).Create(); class(SSubPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -831,9 +831,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function NaryUnitDecorator.Create(_obj: Nary); function NaryUnitDecorator.create(_obj: Nary);
begin begin
class(Nary).Create(); class(Nary).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -858,9 +858,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function NaryPrUnitDecorator.Create(_obj: NaryPr); function NaryPrUnitDecorator.create(_obj: NaryPr);
begin begin
class(NaryPr).Create(); class(NaryPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -889,9 +889,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FuncUnitDecorator.Create(_obj: Func); function FuncUnitDecorator.create(_obj: Func);
begin begin
class(Func).Create(); class(Func).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -914,9 +914,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FNameUnitDecorator.Create(_obj: FName); function FNameUnitDecorator.create(_obj: FName);
begin begin
class(FName).Create(); class(FName).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -936,9 +936,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FuncPrUnitDecorator.Create(_obj: FuncPr); function FuncPrUnitDecorator.create(_obj: FuncPr);
begin begin
class(FuncPr).Create(); class(FuncPr).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -957,9 +957,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function CorePropertiesUnitDecorator.Create(_obj: CoreProperties); function CorePropertiesUnitDecorator.create(_obj: CoreProperties);
begin begin
class(CoreProperties).Create(); class(CoreProperties).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -988,9 +988,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function CreatedUnitDecorator.Create(_obj: Created); function CreatedUnitDecorator.create(_obj: Created);
begin begin
class(Created).Create(); class(Created).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1009,9 +1009,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function ModifiedUnitDecorator.Create(_obj: Modified); function ModifiedUnitDecorator.create(_obj: Modified);
begin begin
class(Modified).Create(); class(Modified).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1030,9 +1030,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RelationshipsUnitDecorator.Create(_obj: Relationships); function RelationshipsUnitDecorator.create(_obj: Relationships);
begin begin
class(Relationships).Create(); class(Relationships).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1052,9 +1052,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function RelationshipUnitDecorator.Create(_obj: Relationship); function RelationshipUnitDecorator.create(_obj: Relationship);
begin begin
class(Relationship).Create(); class(Relationship).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1077,9 +1077,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function TypesUnitDecorator.Create(_obj: Types); function TypesUnitDecorator.create(_obj: Types);
begin begin
class(Types).Create(); class(Types).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1102,9 +1102,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function DefaultUnitDecorator.Create(_obj: Default); function DefaultUnitDecorator.create(_obj: Default);
begin begin
class(Default).Create(); class(Default).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1125,9 +1125,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function _OverrideUnitDecorator.Create(_obj: _Override); function _OverrideUnitDecorator.create(_obj: _Override);
begin begin
class(_Override).Create(); class(_Override).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1148,9 +1148,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function NumUnitDecorator.Create(_obj: Num); function NumUnitDecorator.create(_obj: Num);
begin begin
class(Num).Create(); class(Num).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1193,9 +1193,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function DegUnitDecorator.Create(_obj: Deg); function DegUnitDecorator.create(_obj: Deg);
begin begin
class(Deg).Create(); class(Deg).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1238,9 +1238,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function EUnitDecorator.Create(_obj: E); function EUnitDecorator.create(_obj: E);
begin begin
class(E).Create(); class(E).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1283,9 +1283,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SupUnitDecorator.Create(_obj: Sup); function SupUnitDecorator.create(_obj: Sup);
begin begin
class(Sup).Create(); class(Sup).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1328,9 +1328,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function DenUnitDecorator.Create(_obj: Den); function DenUnitDecorator.create(_obj: Den);
begin begin
class(Den).Create(); class(Den).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -1373,9 +1373,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function SubUnitDecorator.Create(_obj: Sub); function SubUnitDecorator.create(_obj: Sub);
begin begin
class(Sub).Create(); class(Sub).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;

View File

@ -4,7 +4,7 @@ uses VML, TSSafeUnitConverter;
type ShapetypeUnitDecorator = class(Shapetype) type ShapetypeUnitDecorator = class(Shapetype)
public public
function Create(_obj: Shapetype); function create(_obj: Shapetype);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -13,7 +13,7 @@ end;
type FormulasUnitDecorator = class(Formulas) type FormulasUnitDecorator = class(Formulas)
public public
function Create(_obj: Formulas); function create(_obj: Formulas);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -22,7 +22,7 @@ end;
type LockUnitDecorator = class(Lock) type LockUnitDecorator = class(Lock)
public public
function Create(_obj: Lock); function create(_obj: Lock);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -31,7 +31,7 @@ end;
type FUnitDecorator = class(F) type FUnitDecorator = class(F)
public public
function Create(_obj: F); function create(_obj: F);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -40,7 +40,7 @@ end;
type StrokeUnitDecorator = class(Stroke) type StrokeUnitDecorator = class(Stroke)
public public
function Create(_obj: Stroke); function create(_obj: Stroke);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -49,7 +49,7 @@ end;
type PathUnitDecorator = class(Path) type PathUnitDecorator = class(Path)
public public
function Create(_obj: Path); function create(_obj: Path);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -58,7 +58,7 @@ end;
type TextpathUnitDecorator = class(Textpath) type TextpathUnitDecorator = class(Textpath)
public public
function Create(_obj: Textpath); function create(_obj: Textpath);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -67,7 +67,7 @@ end;
type HandlesUnitDecorator = class(Handles) type HandlesUnitDecorator = class(Handles)
public public
function Create(_obj: Handles); function create(_obj: Handles);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -76,7 +76,7 @@ end;
type HUnitDecorator = class(H) type HUnitDecorator = class(H)
public public
function Create(_obj: H); function create(_obj: H);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -85,7 +85,7 @@ end;
type ShapeUnitDecorator = class(Shape) type ShapeUnitDecorator = class(Shape)
public public
function Create(_obj: Shape); function create(_obj: Shape);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -94,7 +94,7 @@ end;
type WrapUnitDecorator = class(Wrap) type WrapUnitDecorator = class(Wrap)
public public
function Create(_obj: Wrap); function create(_obj: Wrap);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -103,7 +103,7 @@ end;
type FillUnitDecorator = class(Fill) type FillUnitDecorator = class(Fill)
public public
function Create(_obj: Fill); function create(_obj: Fill);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -112,7 +112,7 @@ end;
type ImagedataUnitDecorator = class(Imagedata) type ImagedataUnitDecorator = class(Imagedata)
public public
function Create(_obj: Imagedata); function create(_obj: Imagedata);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -121,7 +121,7 @@ end;
type TextboxUnitDecorator = class(Textbox) type TextboxUnitDecorator = class(Textbox)
public public
function Create(_obj: Textbox); function create(_obj: Textbox);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -130,7 +130,7 @@ end;
type OLEObjectUnitDecorator = class(OLEObject) type OLEObjectUnitDecorator = class(OLEObject)
public public
function Create(_obj: OLEObject); function create(_obj: OLEObject);
function GetObject(); function GetObject();
function Convert(); function Convert();
private private
@ -139,9 +139,9 @@ end;
implementation implementation
function ShapetypeUnitDecorator.Create(_obj: Shapetype); function ShapetypeUnitDecorator.create(_obj: Shapetype);
begin begin
class(Shapetype).Create(); class(Shapetype).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -167,8 +167,8 @@ begin
{self.}Adj := object_.XmlAttrAdj.Value; {self.}Adj := object_.XmlAttrAdj.Value;
if not ifnil(object_.XmlAttrPreferrelative) then if not ifnil(object_.XmlAttrPreferrelative) then
{self.}Preferrelative := object_.XmlAttrPreferrelative.Value; {self.}Preferrelative := object_.XmlAttrPreferrelative.Value;
if not ifnil(object_.XmlAttrPath) then if not ifnil(object_.XmlAttrAttrPath) then
{self.}Path := object_.XmlAttrPath.Value; {self.}AttrPath := object_.XmlAttrAttrPath.Value;
if not ifnil(object_.XmlAttrFilled) then if not ifnil(object_.XmlAttrFilled) then
{self.}Filled := object_.XmlAttrFilled.Value; {self.}Filled := object_.XmlAttrFilled.Value;
if not ifnil(object_.XmlAttrStroked) then if not ifnil(object_.XmlAttrStroked) then
@ -188,9 +188,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FormulasUnitDecorator.Create(_obj: Formulas); function FormulasUnitDecorator.create(_obj: Formulas);
begin begin
class(Formulas).Create(); class(Formulas).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -206,13 +206,13 @@ begin
tslassigning := 1; tslassigning := 1;
elems := object_.Fs(); elems := object_.Fs();
for _,elem in elems do for _,elem in elems do
{self.}AppendChild(new ShapetypeUnitDecorator(elem)); {self.}AppendChild(new FUnitDecorator(elem));
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function LockUnitDecorator.Create(_obj: Lock); function LockUnitDecorator.create(_obj: Lock);
begin begin
class(Lock).Create(); class(Lock).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -230,12 +230,16 @@ begin
{self.}Ext := object_.XmlAttrExt.Value; {self.}Ext := object_.XmlAttrExt.Value;
if not ifnil(object_.XmlAttrAspectration) then if not ifnil(object_.XmlAttrAspectration) then
{self.}Aspectration := object_.XmlAttrAspectration.Value; {self.}Aspectration := object_.XmlAttrAspectration.Value;
if not ifnil(object_.XmlAttrText) then
{self.}Text := object_.XmlAttrText.Value;
if not ifnil(object_.XmlAttrShapetype) then
{self.}Shapetype := object_.XmlAttrShapetype.Value;
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FUnitDecorator.Create(_obj: F); function FUnitDecorator.create(_obj: F);
begin begin
class(F).Create(); class(F).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -254,9 +258,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function StrokeUnitDecorator.Create(_obj: Stroke); function StrokeUnitDecorator.create(_obj: Stroke);
begin begin
class(Stroke).Create(); class(Stroke).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -275,9 +279,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function PathUnitDecorator.Create(_obj: Path); function PathUnitDecorator.create(_obj: Path);
begin begin
class(Path).Create(); class(Path).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -306,9 +310,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function TextpathUnitDecorator.Create(_obj: Textpath); function TextpathUnitDecorator.create(_obj: Textpath);
begin begin
class(Textpath).Create(); class(Textpath).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -333,9 +337,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function HandlesUnitDecorator.Create(_obj: Handles); function HandlesUnitDecorator.create(_obj: Handles);
begin begin
class(Handles).Create(); class(Handles).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -354,9 +358,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function HUnitDecorator.Create(_obj: H); function HUnitDecorator.create(_obj: H);
begin begin
class(H).Create(); class(H).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -370,16 +374,16 @@ function HUnitDecorator.Convert();
begin begin
tslassigning_backup := tslassigning; tslassigning_backup := tslassigning;
tslassigning := 1; tslassigning := 1;
if not ifnil(object_.XmlAttrXrange) then
{self.}Xrange := object_.XmlAttrXrange.Value;
if not ifnil(object_.XmlAttrPosition) then if not ifnil(object_.XmlAttrPosition) then
{self.}Position := object_.XmlAttrPosition.Value; {self.}Position := object_.XmlAttrPosition.Value;
if not ifnil(object_.XmlAttrXrange) then
{self.}Xrange := object_.XmlAttrXrange.Value;
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function ShapeUnitDecorator.Create(_obj: Shape); function ShapeUnitDecorator.create(_obj: Shape);
begin begin
class(Shape).Create(); class(Shape).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -426,9 +430,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function WrapUnitDecorator.Create(_obj: Wrap); function WrapUnitDecorator.create(_obj: Wrap);
begin begin
class(Wrap).Create(); class(Wrap).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -449,9 +453,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function FillUnitDecorator.Create(_obj: Fill); function FillUnitDecorator.create(_obj: Fill);
begin begin
class(Fill).Create(); class(Fill).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -470,9 +474,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function ImagedataUnitDecorator.Create(_obj: Imagedata); function ImagedataUnitDecorator.create(_obj: Imagedata);
begin begin
class(Imagedata).Create(); class(Imagedata).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -493,9 +497,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function TextboxUnitDecorator.Create(_obj: Textbox); function TextboxUnitDecorator.create(_obj: Textbox);
begin begin
class(Textbox).Create(); class(Textbox).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;
@ -514,9 +518,9 @@ begin
tslassigning := tslassigning_backup; tslassigning := tslassigning_backup;
end; end;
function OLEObjectUnitDecorator.Create(_obj: OLEObject); function OLEObjectUnitDecorator.create(_obj: OLEObject);
begin begin
class(OLEObject).Create(); class(OLEObject).create();
object_ := _obj; object_ := _obj;
{self.}Convert(); {self.}Convert();
end; end;

View File

@ -1,70 +1,144 @@
unit TSSafeUnitConverter; unit TSSafeUnitConverter;
interface interface
function PointsToTwips(value): real; function CentimetersToPoints(value): real;
function TwipsToPoints(value): real;
function EmusToPoints(value): real; function EmusToPoints(value): real;
function HalfPointToPoints(value): real; function InchesToPoints(value): real;
function LinesToPoints(value): real;
function MillimetersToPoints(value): real;
function PicasToPoints(value): real;
function PixelsToPoints(value): real; // TODO 不实现与DPI有关
function TwipsToPoints(value): real;
// points -> other
function PointsToCentimeters(value): real;
function PointsToEmus(value): real;
function PointsToInches(value): real;
function PointsToLines(value): real;
function PointsToMillimeters(value);
function PointsToPicas(value);
function PointsToPixels(value); // TODO
function PointsToTwips(value): real;
// other
function HalfPointsToPoints(value): real;
function PointsToHalfPoints(value): real;
function EighthPointsToPoints(value): real;
function PercentToNumber(value): real; function PercentToNumber(value): real;
function NumberToPercent(value): real; function NumberToPercent(value): real;
function ToInt(value): integer; function ToInt(value): integer;
function EighthPointToPoints(value): real;
implementation implementation
uses TSUnitConverter; uses TSUnitConverter;
function PointsToTwips(value): real; function SafeConvert(value, convert_func): real;
begin begin
if ifNil(value) then return 0; if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value; new_value := ifString(value) ? strToFloatDef(value, 0) : value;
return TSUnitConverter.PointsToTwips(new_value); return ##convert_func(new_value);
end; end;
function TwipsToPoints(value): real; function CentimetersToPoints(value): real;
begin begin
if ifNil(value) then return 0; return SafeConvert(value, thisFunction(TSUnitConverter.CentimetersToPoints));
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.TwipsToPoints(new_value);
end;
function HalfPointToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.HalfPointToPoints(new_value);
end; end;
function EmusToPoints(value): real; function EmusToPoints(value): real;
begin begin
if ifNil(value) then return 0; return SafeConvert(value, thisFunction(TSUnitConverter.EmusToPoints));
new_value := ifString(value) ? strToFloat(value) : value; end;
return TSUnitConverter.EmusToPoints(new_value);
function InchesToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.InchesToPoints));
end;
function LinesToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.LinesToPoints));
end;
function MillimetersToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.MillimetersToPoints));
end;
function PicasToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PicasToPoints));
end;
function TwipsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.TwipsToPoints));
end;
// points -> other
function PointsToCentimeters(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToCentimeters));
end;
function PointsToEmus(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToEmus));
end;
function PointsToInches(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToInches));
end;
function PointsToLines(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToLines));
end;
function PointsToMillimeters(value);
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToMillimeters));
end;
function PointsToPicas(value);
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToPicas));
end;
function PointsToTwips(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToTwips));
end;
// other
function HalfPointsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.HalfPointsToPoints));
end;
function PointsToHalfPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToHalfPoints));
end;
function EighthPointsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.EighthPointsToPoints));
end; end;
function PercentToNumber(value): real; function PercentToNumber(value): real;
begin begin
if ifNil(value) then return 0; return SafeConvert(value, thisFunction(TSUnitConverter.PercentToNumber));
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.PercentToNumber(new_value);
end; end;
function NumberToPercent(value): real; function NumberToPercent(value): real;
begin begin
if ifNil(value) then return 0; return SafeConvert(value, thisFunction(TSUnitConverter.NumberToPercent));
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.NumberToPercent(new_value);
end; end;
function ToInt(value): integer; function ToInt(value): real;
begin begin
if ifNil(value) then return 0; if ifnumber(value) then return integer(value);
return strtoIntDef(value, 0); if ifstring(value) then return strToIntDef(value, 0);
end; return 0;
function EighthPointToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.EighthPointToPoints(new_value);
end; end;
end. end.

View File

@ -1,48 +1,130 @@
unit TSUnitConverter; unit TSUnitConverter;
interface interface
function PointsToTwips(value): real; // other -> points
function TwipsToPoints(value: real): real; function CentimetersToPoints(centimeters: real): real;
function EmusToPoints(value: real): real; function EmusToPoints(emus: real): real;
function HalfPointToPoints(value: real): real; function InchesToPoints(inches: real): real;
function EighthPointToPoints(value: real): real; function LinesToPoints(lines: real): real;
function PercentToNumber(value: real): real; function MillimetersToPoints(millimeters: real): real;
function NumberToPercent(value: real): real; function PicasToPoints(picas: real): real;
function PixelsToPoints(pixels: real; f_vertical: boolean = false): real; // TODO 不实现与DPI有关
function TwipsToPoints(twips: real): real;
// points -> other
function PointsToCentimeters(points: real): real;
function PointsToEmus(points: real): real;
function PointsToInches(points: real): real;
function PointsToLines(points: real): real;
function PointsToMillimeters(points: real);
function PointsToPicas(points: real);
function PointsToPixels(points: real); // TODO
function PointsToTwips(points): real;
// other
function HalfPointsToPoints(half_points: real): real;
function PointsToHalfPoints(points: real): real;
function EighthPointsToPoints(eighth_points: real): real;
function PercentToNumber(percent: real): real;
function NumberToPercent(number: real): real;
implementation implementation
function PointsToTwips(value): real; function CentimetersToPoints(centimeters: real): real;
begin begin
return value * 20; return centimeters * 28.346456692913385826771653543307;
end; end;
function TwipsToPoints(value: real): real; function EmusToPoints(emus: real): real;
begin begin
return value / 20; return emus / 12700;
end; end;
function EmusToPoints(value: real): real; function InchesToPoints(inches: real): real;
begin begin
return value / 12700; return inches * 72;
end; end;
function HalfPointToPoints(value: real): real; function LinesToPoints(lines: real): real;
begin begin
return value / 2; return lines * 12; // Assuming 1 line = 12 points
end; end;
function PercentToNumber(value: real): real; function MillimetersToPoints(millimeters: real): real;
begin begin
return value / 100; return millimeters * 2.8346456692913385826771653543307;
end; end;
function NumberToPercent(value: real): real; function PicasToPoints(picas: real): real;
begin begin
return value * 100; return picas * 12;
end; end;
function EighthPointToPoints(value: real): real; function TwipsToPoints(twips: real): real;
begin begin
return value / 8; return twips / 20;
end;
// Points -> others
function PointsToCentimeters(points: real): real;
begin
return points / 28.346456692913385826771653543307;
end;
function PointsToEmus(points: real): real;
begin
return points * 12700;
end;
function PointsToInches(points: real): real;
begin
return points / 72;
end;
function PointsToLines(points: real): real;
begin
return points / 12;
end;
function PointsToMillimeters(points: real);
begin
return points / 2.8346456692913385826771653543307;
end;
function PointsToTwips(points): real;
begin
return points * 20;
end;
function PointsToPicas(points: real);
begin
return points / 12;
end;
// other
function HalfPointsToPoints(half_points: real): real;
begin
return half_points / 2;
end;
function PointsToHalfPoints(points: real): real;
begin
return points * 2;
end;
function EighthPointsToPoints(eighth_points: real): real;
begin
return eighth_points / 8;
end;
function PercentToNumber(percent: real): real;
begin
return percent / 100;
end;
function NumberToPercent(number: real): real;
begin
return number * 100;
end; end;
end. end.