lazarus-ccr/components/fpspreadsheet/fpsutils.pas
sekelsenmat 0b32db4780 fpspreasheet: Adds forgotten files
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@655 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2009-01-09 08:39:40 +00:00

53 lines
1015 B
ObjectPascal

unit fpsutils;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
function WordToLE(AValue: Word): Word;
function DWordToLE(AValue: Cardinal): Cardinal;
function IntegerToLE(AValue: Integer): Integer;
implementation
{
Endianess helper functions
Excel files are all written with Little Endian byte order,
so it's necessary to swap the data to be able to build a
correct file on big endian systems.
}
function WordToLE(AValue: Word): Word;
begin
{$IFDEF BIG_ENDIAN}
Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
{$ELSE}
Result := AValue;
{$ENDIF}
end;
function DWordToLE(AValue: Cardinal): Cardinal;
begin
{$IFDEF BIG_ENDIAN}
// ?? Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
{$ELSE}
Result := AValue;
{$ENDIF}
end;
function IntegerToLE(AValue: Integer): Integer;
begin
{$IFDEF BIG_ENDIAN}
// ?? Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
{$ELSE}
Result := AValue;
{$ENDIF}
end;
end.