OfficeXml/utils/TSUnitConverter.tsf

132 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit TSUnitConverter;
interface
// other -> points
function CentimetersToPoints(centimeters: real): real;
function EmusToPoints(emus: real): real;
function InchesToPoints(inches: real): real;
function LinesToPoints(lines: real): real;
function MillimetersToPoints(millimeters: 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
function CentimetersToPoints(centimeters: real): real;
begin
return centimeters * 28.346456692913385826771653543307;
end;
function EmusToPoints(emus: real): real;
begin
return emus / 12700;
end;
function InchesToPoints(inches: real): real;
begin
return inches * 72;
end;
function LinesToPoints(lines: real): real;
begin
return lines * 12; // Assuming 1 line = 12 points
end;
function MillimetersToPoints(millimeters: real): real;
begin
return millimeters * 2.8346456692913385826771653543307;
end;
function PicasToPoints(picas: real): real;
begin
return picas * 12;
end;
function TwipsToPoints(twips: real): real;
begin
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.