You've already forked lazarus-ccr
fpspreadsheet: Fix ooxml reader crashing for files having no shared strings table.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3379 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -93,16 +93,13 @@
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="laz_fpspreadsheet"/>
|
||||
<PackageName Value="laz_fpspreadsheet_visual"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="laz_fpspreadsheet_visual"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
|
@@ -4,7 +4,7 @@ program spready;
|
||||
|
||||
uses
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, mainform, laz_fpspreadsheet_visual, laz_fpspreadsheet;
|
||||
Forms, mainform, laz_fpspreadsheet_visual;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
This package is all you need if you don't want graphical components (like grids and charts)."/>
|
||||
<License Value="LGPL with static linking exception. This is the same license as is used in the LCL (Lazarus Component Library)."/>
|
||||
<Version Major="1" Minor="2"/>
|
||||
<Files Count="22">
|
||||
<Files Count="23">
|
||||
<Item1>
|
||||
<Filename Value="fpolestorage.pas"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
@@ -114,6 +114,10 @@ This package is all you need if you don't want graphical components (like grids
|
||||
<Filename Value="fpsfunc.pas"/>
|
||||
<UnitName Value="fpsfunc"/>
|
||||
</Item22>
|
||||
<Item23>
|
||||
<Filename Value="fpsxmlcommon.pas"/>
|
||||
<UnitName Value="fpsxmlcommon"/>
|
||||
</Item23>
|
||||
</Files>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
|
@@ -11,7 +11,7 @@ uses
|
||||
xlsbiff5, xlsbiff8, xlsxooxml, fpsutils, fpsStreams, fpszipper,
|
||||
uvirtuallayer_types, uvirtuallayer, uvirtuallayer_ole,
|
||||
uvirtuallayer_ole_helpers, uvirtuallayer_ole_types, uvirtuallayer_stream,
|
||||
fpolebasic, xlscommon, wikitable, fpsNumFormatParser, fpsfunc;
|
||||
fpolebasic, xlscommon, wikitable, fpsNumFormatParser, fpsfunc, fpsxmlcommon;
|
||||
|
||||
implementation
|
||||
|
||||
|
@@ -448,6 +448,7 @@ var
|
||||
FileList : TStringList;
|
||||
SheetList: TStringList;
|
||||
i: Integer;
|
||||
fn: String;
|
||||
|
||||
BodyNode, SpreadSheetNode, TableNode: TDOMNode;
|
||||
StylesNode: TDOMNode;
|
||||
@@ -478,10 +479,12 @@ begin
|
||||
SheetList := TStringList.Create;
|
||||
try
|
||||
// process the sharedStrings.xml file
|
||||
ReadXMLFile(Doc, FilePath + OOXML_PATH_XL_STRINGS);
|
||||
DeleteFile(FilePath + OOXML_PATH_XL_STRINGS);
|
||||
ReadSharedStrings(Doc.DocumentElement.FindNode('si'));
|
||||
FreeAndNil(Doc);
|
||||
if FileExists(FilePath + OOXML_PATH_XL_STRINGS) then begin
|
||||
ReadXMLFile(Doc, FilePath + OOXML_PATH_XL_STRINGS);
|
||||
DeleteFile(FilePath + OOXML_PATH_XL_STRINGS);
|
||||
ReadSharedStrings(Doc.DocumentElement.FindNode('si'));
|
||||
FreeAndNil(Doc);
|
||||
end;
|
||||
|
||||
// process the styles.xml file
|
||||
ReadXMLFile(Doc, FilePath + OOXML_PATH_XL_STYLES);
|
||||
@@ -507,7 +510,9 @@ begin
|
||||
// unzip sheet file
|
||||
FileList := TStringList.Create;
|
||||
try
|
||||
FileList.Add(OOXML_PATH_XL_WORKSHEETS + SheetList[i] + '.xml');
|
||||
// The file name is always "sheet<n>.xml", irrespective of the sheet's name!
|
||||
fn := OOXML_PATH_XL_WORKSHEETS + 'sheet' + IntToStr(i+1) + '.xml';
|
||||
FileList.Add(fn);
|
||||
UnZip := TUnZipper.Create;
|
||||
try
|
||||
UnZip.OutputPath := FilePath;
|
||||
@@ -519,8 +524,8 @@ begin
|
||||
FreeAndNil(FileList);
|
||||
end;
|
||||
|
||||
ReadXMLFile(Doc, FilePath + OOXML_PATH_XL_WORKSHEETS + SheetList[i] + '.xml');
|
||||
DeleteFile(FilePath + OOXML_PATH_XL_WORKSHEETS + SheetList[i] + '.xml');
|
||||
ReadXMLFile(Doc, FilePath + fn);
|
||||
DeleteFile(FilePath + fn);
|
||||
|
||||
FWorksheet := AData.AddWorksheet(SheetList[i]);
|
||||
|
||||
|
Reference in New Issue
Block a user