OfficeXml/utils/TSSafeUnitConverter.tsf

57 lines
1.6 KiB
Plaintext

unit TSSafeUnitConverter;
interface
function TwipsToPoints(value): real;
function EmusToPoints(value): real;
function HalfPointToPoints(value): real;
function PercentToNumber(value): real;
function ToInt(value): integer;
function EighthPointToPoints(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;
function ToInt(value): integer;
begin
if ifNil(value) then return 0;
return tryStrtoInt(value, r) ? r : 0;
end;
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.