v1.0.0
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
type TSComponentsBase = class
|
||||
public
|
||||
function Create();
|
||||
function Init();virtual;
|
||||
function OpenFile(alias: string; file: string; password: string): tableArray;
|
||||
function Zip(): ZipFile;
|
||||
|
||||
protected
|
||||
function GetProp(_variable: tslobj; _name: string): tslobj;
|
||||
function GetPropArr(_variable: tslobj; _name: string; _index: integer): tslobj;
|
||||
function NewObject(_name: string): tslobj;virtual;
|
||||
|
||||
protected
|
||||
zipfile_: ZipFile;
|
||||
conf_: tableArray;
|
||||
|
||||
end;
|
||||
|
||||
function TSComponentsBase.Create();
|
||||
begin
|
||||
end;
|
||||
|
||||
function TSComponentsBase.OpenFile(alias: string; file: string; password: string): tableArray;
|
||||
begin
|
||||
self.Init();
|
||||
zipfile_ := new ZipFile();
|
||||
return zipfile_.Open(alias, file, password);
|
||||
end;
|
||||
|
||||
function TSComponentsBase.Zip(): ZipFile;
|
||||
begin
|
||||
return zipfile_;
|
||||
end
|
||||
|
||||
function TSComponentsBase.GetProp(_variable: tslobj; _name: string): tslobj;
|
||||
begin
|
||||
if ifnil(_variable) then
|
||||
begin
|
||||
name := conf_[_name][0];
|
||||
xml := zipfile_.Get(name);
|
||||
if ifObj(xml) then
|
||||
begin
|
||||
node := xml.FirstChild(conf_[_name][1]);
|
||||
if not ifObj(node) then raise (name $ " error.");
|
||||
_variable := self.NewObject(_name);
|
||||
_variable.InitNode(node);
|
||||
end
|
||||
end
|
||||
return _variable;
|
||||
end;
|
||||
|
||||
function TSComponentsBase.GetPropArr(_variable: tslobj; _name: string; _index: integer): tslobj;
|
||||
begin
|
||||
if not ifNumber(_index) then
|
||||
begin
|
||||
ind := 1;
|
||||
name := Format(conf_[_name][0], ind);
|
||||
xml := zipfile_.Get(name);
|
||||
while ifObj(xml) do
|
||||
begin
|
||||
node := xml.FirstChild(conf_[_name][1]);
|
||||
obj := self.NewObject(_name);
|
||||
obj.InitNode(node);
|
||||
_variable[length(_variable)] := obj;
|
||||
name := Format(conf_[_name][0], ++ind);
|
||||
xml := zipfile_.Get(name);
|
||||
end
|
||||
return _variable;
|
||||
end
|
||||
if ifnil(_variable[_index]) then
|
||||
begin
|
||||
obj := nil;
|
||||
self.SetProp(obj, _name, _index + 1);
|
||||
_variable[_index] := obj;
|
||||
end
|
||||
return _variable[_index];
|
||||
end;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
unit TSSafeUnitConverter;
|
||||
interface
|
||||
function TwipsToPoints(value): real;
|
||||
function EmusToPoints(value): real;
|
||||
function HalfPointToPoints(value): real;
|
||||
function PercentToNumber(value): real;
|
||||
|
||||
implementation
|
||||
|
||||
uses TSUnitConverter;
|
||||
|
||||
function TwipsToPoints(value): real;
|
||||
begin
|
||||
if ifNil(value) then return 0;
|
||||
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;
|
||||
|
||||
function EmusToPoints(value): real;
|
||||
begin
|
||||
if ifNil(value) then return 0;
|
||||
new_value := ifString(value) ? strToFloat(value) : value;
|
||||
return TSUnitConverter.EmusToPoints(new_value);
|
||||
end;
|
||||
|
||||
function PercentToNumber(value): real;
|
||||
begin
|
||||
if ifNil(value) then return 0;
|
||||
new_value := ifString(value) ? strToFloat(value) : value;
|
||||
return TSUnitConverter.PercentToNumber(new_value);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
unit TSUnitConverter;
|
||||
interface
|
||||
function TwipsToPoints(value: real): real;
|
||||
function EmusToPoints(value: real): real;
|
||||
function HalfPointToPoints(value: real): real;
|
||||
function PercentToNumber(value: real): real;
|
||||
|
||||
implementation
|
||||
|
||||
function TwipsToPoints(value: real): real;
|
||||
begin
|
||||
return value / 20;
|
||||
end;
|
||||
|
||||
function EmusToPoints(value: real): real;
|
||||
begin
|
||||
return value / 12700;
|
||||
end;
|
||||
|
||||
function HalfPointToPoints(value: real): real;
|
||||
begin
|
||||
return value / 2;
|
||||
end;
|
||||
|
||||
function PercentToNumber(value: real): real;
|
||||
begin
|
||||
return value / 100;
|
||||
end
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user