text
stringlengths
0
234
xl : in out Excel_Out_Stream;
r,
c : Positive;
num : Unsigned_16)
is
pragma Inline(Write_as_16_bit_unsigned);
begin
Jump_to_and_store_max(xl, r, c);
-- 5.60 INTEGER
WriteBiff(xl, 16#0002#,
Intel_16(Unsigned_16(r-1)) &
Intel_16(Unsigned_16(c-1)) &
Cell_attributes(xl) &
Intel_16(num)
);
Jump_to(xl, r, c+1); -- Store and check new position
end Write_as_16_bit_unsigned;
-- Internal. This is BIFF3+. BIFF format choice unchecked here.
--
procedure Write_as_30_bit_signed (
xl : in out Excel_Out_Stream;
r,
c : Positive;
num : Integer_32)
is
pragma Inline(Write_as_30_bit_signed);
RK_val: Unsigned_32;
RK_code: constant:= 2; -- Code for signed integer. See 2.5.5 RK Values
begin
if num >= 0 then
RK_val:= Unsigned_32(num) * 4 + RK_code;
else
RK_val:= (-Unsigned_32(-num)) * 4 + RK_code;
end if;
Jump_to_and_store_max(xl, r, c);
-- 5.87 RK
WriteBiff(xl, 16#027E#,
Intel_16(Unsigned_16(r-1)) &
Intel_16(Unsigned_16(c-1)) &
Intel_16(Unsigned_16(xl.xf_in_use)) &
Intel_32(RK_val)
);
Jump_to(xl, r, c+1); -- Store and check new position
end Write_as_30_bit_signed;
--
-- Profile with floating-point number
--
procedure Write (
xl : in out Excel_Out_Stream;
r,
c : Positive;
num : Long_Float
)
is
max_16_u: constant:= 2.0 ** 16 - 1.0;
min_30_s: constant:= -(2.0 ** 29);
max_30_s: constant:= 2.0 ** 29 - 1.0;
begin
case xl.format is
when BIFF2 =>
if num >= 0.0 and then
num <= max_16_u and then
Almost_zero(num - Long_Float'Floor(num))
then
Write_as_16_bit_unsigned(xl, r, c, Unsigned_16(Long_Float'Floor(num)));
else
Write_as_double(xl, r, c, num);
end if;
when BIFF3 | BIFF4 =>
if num >= min_30_s and then
num <= max_30_s and then
Almost_zero(num - Long_Float'Floor(num))
then
Write_as_30_bit_signed(xl, r, c, Integer_32(Long_Float'Floor(num)));
else
Write_as_double(xl, r, c, num);
end if;
end case;
end Write;
--
-- Profile with integer number
--
procedure Write (
xl : in out Excel_Out_Stream;
r,
c : Positive;
num : Integer)
is
begin
-- We use an integer representation (and small storage) if possible;
-- we need to use a floating-point in all other cases
case xl.format is
when BIFF2 =>
if num in 0..2**16-1 then
Write_as_16_bit_unsigned(xl, r, c, Unsigned_16(num));
else
Write_as_double(xl, r, c, Long_Float(num));