You've already forked lazarus-ccr
fpspreadsheet: First working ole file generation
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@652 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
<PackageName Value="laz_fpspreadsheet"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="19">
|
||||
<Units Count="21">
|
||||
<Unit0>
|
||||
<Filename Value="excel5demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -38,7 +38,7 @@
|
||||
<CursorPos X="16" Y="16"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="96"/>
|
||||
<UsageCount Value="112"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -46,69 +46,69 @@
|
||||
<UnitName Value="fpspreadsheet"/>
|
||||
<CursorPos X="32" Y="414"/>
|
||||
<TopLine Value="388"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="19"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\xlsbiff5.pas"/>
|
||||
<UnitName Value="xlsbiff5"/>
|
||||
<CursorPos X="16" Y="320"/>
|
||||
<TopLine Value="300"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="19"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\packages\base\winunits\activex.pp"/>
|
||||
<UnitName Value="ActiveX"/>
|
||||
<CursorPos X="27" Y="29"/>
|
||||
<TopLine Value="6"/>
|
||||
<UsageCount Value="4"/>
|
||||
<UsageCount Value="3"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\fpolestorage.pas"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="40"/>
|
||||
<UsageCount Value="39"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\rtl\inc\objpash.inc"/>
|
||||
<CursorPos X="21" Y="141"/>
|
||||
<TopLine Value="131"/>
|
||||
<UsageCount Value="4"/>
|
||||
<UsageCount Value="3"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\xlsbiff2.pas"/>
|
||||
<UnitName Value="xlsbiff2"/>
|
||||
<CursorPos X="20" Y="277"/>
|
||||
<TopLine Value="260"/>
|
||||
<UsageCount Value="13"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\rtl\objpas\classes\classesh.inc"/>
|
||||
<CursorPos X="22" Y="1602"/>
|
||||
<TopLine Value="1598"/>
|
||||
<UsageCount Value="6"/>
|
||||
<UsageCount Value="5"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\rtl\win32\buildrtl.pp"/>
|
||||
<UnitName Value="buildrtl"/>
|
||||
<CursorPos X="29" Y="5"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="4"/>
|
||||
<UsageCount Value="3"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\rtl\objpas\fgl.pp"/>
|
||||
<UnitName Value="fgl"/>
|
||||
<CursorPos X="15" Y="86"/>
|
||||
<TopLine Value="55"/>
|
||||
<UsageCount Value="13"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\..\..\..\lazarus\lcl\interfaces\win32\win32wsstdctrls.pp"/>
|
||||
<UnitName Value="Win32WSStdCtrls"/>
|
||||
<CursorPos X="11" Y="737"/>
|
||||
<TopLine Value="713"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="37"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<UsageCount Value="45"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
@ -116,29 +116,29 @@
|
||||
<UnitName Value="Win32WSControls"/>
|
||||
<CursorPos X="13" Y="206"/>
|
||||
<TopLine Value="199"/>
|
||||
<UsageCount Value="7"/>
|
||||
<UsageCount Value="6"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="..\..\..\..\..\lazarus\components\sqlite\registersqlite3.pas"/>
|
||||
<UnitName Value="registersqlite3"/>
|
||||
<CursorPos X="15" Y="5"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="6"/>
|
||||
<UsageCount Value="5"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\..\..\..\lazarus\ideintf\componenteditors.pas"/>
|
||||
<UnitName Value="ComponentEditors"/>
|
||||
<CursorPos X="54" Y="353"/>
|
||||
<TopLine Value="330"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="35"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<UsageCount Value="43"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="..\..\..\..\..\FPC220\source\rtl\objpas\classes\cregist.inc"/>
|
||||
<CursorPos X="17" Y="124"/>
|
||||
<TopLine Value="121"/>
|
||||
<UsageCount Value="6"/>
|
||||
<UsageCount Value="5"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
@ -146,7 +146,7 @@
|
||||
<CursorPos X="28" Y="62"/>
|
||||
<TopLine Value="59"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="41"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
@ -155,7 +155,7 @@
|
||||
<CursorPos X="1" Y="49"/>
|
||||
<TopLine Value="30"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="41"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
@ -164,139 +164,155 @@
|
||||
<CursorPos X="1" Y="69"/>
|
||||
<TopLine Value="57"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="41"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
<CursorPos X="1" Y="471"/>
|
||||
<TopLine Value="458"/>
|
||||
<CursorPos X="1" Y="316"/>
|
||||
<TopLine Value="308"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="33"/>
|
||||
<UsageCount Value="41"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\classesh.inc"/>
|
||||
<CursorPos X="17" Y="724"/>
|
||||
<TopLine Value="714"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
<Filename Value="..\..\..\..\..\lazarus26\fpc\2.2.2\source\rtl\objpas\classes\streams.inc"/>
|
||||
<CursorPos X="1" Y="159"/>
|
||||
<TopLine Value="151"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit20>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\..\..\..\lazarus\lcl\interfaces\win32\win32wsstdctrls.pp"/>
|
||||
<Caret Line="737" Column="11" TopLine="713"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="51" Column="25" TopLine="34"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\..\..\..\lazarus\ideintf\componenteditors.pas"/>
|
||||
<Caret Line="353" Column="54" TopLine="330"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="157" Column="21" TopLine="151"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="excel5demo.lpr"/>
|
||||
<Caret Line="49" Column="12" TopLine="30"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="155" Column="5" TopLine="136"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="365" Column="37" TopLine="354"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="65" Column="3" TopLine="58"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="38" Column="20" TopLine="21"/>
|
||||
<Caret Line="25" Column="11" TopLine="16"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="60" Column="54" TopLine="49"/>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="194" Column="15" TopLine="60"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="44" Column="24" TopLine="32"/>
|
||||
<Filename Value="..\..\fpsutils.pas"/>
|
||||
<Caret Line="45" Column="5" TopLine="26"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="51" Column="25" TopLine="34"/>
|
||||
<Caret Line="150" Column="5" TopLine="131"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="157" Column="21" TopLine="151"/>
|
||||
<Caret Line="191" Column="5" TopLine="172"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="155" Column="5" TopLine="136"/>
|
||||
<Caret Line="49" Column="15" TopLine="39"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="65" Column="3" TopLine="58"/>
|
||||
<Caret Line="331" Column="45" TopLine="326"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="25" Column="11" TopLine="16"/>
|
||||
<Caret Line="24" Column="27" TopLine="19"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="194" Column="15" TopLine="60"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="247" Column="1" TopLine="229"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\fpsutils.pas"/>
|
||||
<Caret Line="45" Column="5" TopLine="26"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="224" Column="5" TopLine="205"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="150" Column="5" TopLine="131"/>
|
||||
<Caret Line="231" Column="1" TopLine="219"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="191" Column="5" TopLine="172"/>
|
||||
<Caret Line="377" Column="5" TopLine="358"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="49" Column="15" TopLine="39"/>
|
||||
<Caret Line="225" Column="1" TopLine="211"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="331" Column="45" TopLine="326"/>
|
||||
<Caret Line="246" Column="12" TopLine="237"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="24" Column="27" TopLine="19"/>
|
||||
<Caret Line="79" Column="16" TopLine="78"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="247" Column="1" TopLine="229"/>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="87" Column="16" TopLine="77"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="224" Column="5" TopLine="205"/>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="218" Column="24" TopLine="207"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="231" Column="1" TopLine="219"/>
|
||||
<Caret Line="235" Column="30" TopLine="224"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="377" Column="5" TopLine="358"/>
|
||||
<Caret Line="80" Column="28" TopLine="68"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="225" Column="1" TopLine="211"/>
|
||||
<Caret Line="40" Column="5" TopLine="31"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="246" Column="12" TopLine="237"/>
|
||||
<Caret Line="472" Column="49" TopLine="461"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="79" Column="16" TopLine="78"/>
|
||||
<Caret Line="405" Column="5" TopLine="386"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="87" Column="16" TopLine="77"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="404" Column="14" TopLine="401"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\..\xlsbiff5.pas"/>
|
||||
<Caret Line="218" Column="24" TopLine="207"/>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="79" Column="42" TopLine="72"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="235" Column="30" TopLine="224"/>
|
||||
<Caret Line="78" Column="31" TopLine="67"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\..\fpolestorage.pas"/>
|
||||
<Caret Line="80" Column="28" TopLine="68"/>
|
||||
<Caret Line="314" Column="39" TopLine="296"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -37,7 +37,7 @@ unit fpolestorage;
|
||||
interface
|
||||
|
||||
{$ifdef Windows}
|
||||
{$define FPOLESTORAGE_USE_COM}
|
||||
{.$define FPOLESTORAGE_USE_COM}
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
@ -79,6 +79,7 @@ type
|
||||
EntryType, EntryColor: Byte; AIsStorage: Boolean;
|
||||
AStreamSize: Cardinal);
|
||||
procedure WriteShortSectorAllocationTable(AStream: TStream);
|
||||
procedure WriteUserStream(ADest, ASource: TStream);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -127,6 +128,8 @@ begin
|
||||
{ 8 16 Unique identifier (UID) of this file (not of interest in the following, may be all 0) }
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
|
||||
{ 24 2 Revision number of the file format (most used is 003EH) }
|
||||
AStream.WriteWord(WordToLE($003E));
|
||||
@ -272,7 +275,9 @@ begin
|
||||
storage, ➜7.1), –1 otherwise
|
||||
}
|
||||
|
||||
AStream.WriteWord(WordToLE(Length(AName) * 2));
|
||||
if AName = #0 then AStream.WriteWord($0000)
|
||||
else AStream.WriteWord(WordToLE(Length(AName) * 2));
|
||||
|
||||
AStream.WriteByte(EntryType);
|
||||
AStream.WriteByte(EntryColor);
|
||||
|
||||
@ -280,7 +285,7 @@ begin
|
||||
AStream.WriteDWord(DWordToLE($FFFFFFFF));
|
||||
|
||||
if AIsStorage then AStream.WriteDWord(DWordToLE($00000001))
|
||||
else AStream.WriteDWord(DWordToLE($FFFFFFFF));;
|
||||
else AStream.WriteDWord(DWordToLE($FFFFFFFF));
|
||||
|
||||
{00000450H 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
|
||||
@ -296,7 +301,17 @@ begin
|
||||
a valid time stamp, but fill up this space with zero bytes.
|
||||
}
|
||||
|
||||
for i := 1 to ($474 - $450) do AStream.WriteByte($00);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
|
||||
AStream.WriteDWord(0);
|
||||
AStream.WriteDWord(0);
|
||||
|
||||
{Root Storage #1
|
||||
00000470H XX XX XX XX 03 00 00 00 40 03 00 00 00 00 00 00
|
||||
@ -335,7 +350,7 @@ procedure TOLEStorage.WriteDirectoryStream(AStream: TStream);
|
||||
begin
|
||||
WriteDirectoryEntry(AStream, 'Root Entry'#0,
|
||||
INT_OLE_DIR_ENTRY_TYPE_ROOT_STORAGE, INT_OLE_DIR_COLOR_RED,
|
||||
True, $00000340);
|
||||
True, $00000340);
|
||||
|
||||
WriteDirectoryEntry(AStream, 'Book'#0,
|
||||
INT_OLE_DIR_ENTRY_TYPE_USER_STREAM, INT_OLE_DIR_COLOR_BLACK,
|
||||
@ -396,6 +411,18 @@ begin
|
||||
for i := 1 to ($A00 - $840) do AStream.WriteByte($FF);
|
||||
end;
|
||||
|
||||
procedure TOLEStorage.WriteUserStream(ADest, ASource: TStream);
|
||||
var
|
||||
i, PadSize: Integer;
|
||||
begin
|
||||
ADest.CopyFrom(ASource, 0);
|
||||
|
||||
// Pad the sector with zeroes
|
||||
PadSize := INT_OLE_SECTOR_SIZE - (ASource.Size mod INT_OLE_SECTOR_SIZE);
|
||||
|
||||
for i := 1 to PadSize do ADest.WriteByte($00);
|
||||
end;
|
||||
|
||||
constructor TOLEStorage.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
@ -461,15 +488,14 @@ begin
|
||||
// Record 0, the SAT
|
||||
WriteSectorAllocationTable(AFileStream);
|
||||
|
||||
// Records 1 and 2, the directory stream
|
||||
WriteDirectoryStream(AFileStream);
|
||||
// Record 1, the directory stream
|
||||
WriteDirectoryStream(AFileStream);
|
||||
|
||||
// Record 3, the Short SAT
|
||||
// Record 2, the Short SAT
|
||||
WriteShortSectorAllocationTable(AFileStream);
|
||||
|
||||
// Records 4 and on, the user data
|
||||
AFileStream.CopyFrom(FOLEDocument.Streams[0]);
|
||||
// Records 3 and on, the user data
|
||||
WriteUserStream(AFileStream, FOLEDocument.Streams[0]);
|
||||
finally
|
||||
AFileStream.Free;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user