fpspreadsheet: Use fmShareDenyNone when opening files for reading (see Mantis 0026826).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3636 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2014-10-07 14:02:11 +00:00
parent f9e295540f
commit c3f65eac18
6 changed files with 46 additions and 38 deletions

View File

@ -95,7 +95,7 @@ begin
VLAbsolutePath:='/'+AStreamName; //Virtual layer always use absolute paths. VLAbsolutePath:='/'+AStreamName; //Virtual layer always use absolute paths.
try try
RealFile:=nil; RealFile:=nil;
RealFile:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyWrite); RealFile:=TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone);
try try
fsOLE:=nil; fsOLE:=nil;
fsOLE:=TVirtualLayer_OLE.Create(RealFile); fsOLE:=TVirtualLayer_OLE.Create(RealFile);

View File

@ -7342,9 +7342,9 @@ var
InputFile: TStream; InputFile: TStream;
begin begin
if (boBufStream in Workbook.Options) then if (boBufStream in Workbook.Options) then
InputFile := TBufStream.Create(AFileName, fmOpenRead) InputFile := TBufStream.Create(AFileName, fmOpenRead + fmShareDenyNone)
else else
InputFile := TFileStream.Create(AFileName, fmOpenRead); InputFile := TFileStream.Create(AFileName, fmOpenRead + fmShareDenyNone);
try try
ReadFromStream(InputFile, AData); ReadFromStream(InputFile, AData);
finally finally

View File

@ -1586,7 +1586,7 @@ Begin
if Assigned(FOnOpenInputStream) then if Assigned(FOnOpenInputStream) then
FOnOpenInputStream(Self, FZipStream); FOnOpenInputStream(Self, FZipStream);
if FZipStream = nil then if FZipStream = nil then
FZipStream:=TFileStream.Create(FFileName,fmOpenRead); FZipStream:=TFileStream.Create(FFileName,fmOpenRead + fmShareDenyNone);
End; End;

View File

@ -178,22 +178,22 @@ object MainForm: TMainForm
OnSelection = HexGridSelection OnSelection = HexGridSelection
ColWidths = ( ColWidths = (
28 28
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
21 20
26 20
) )
Cells = ( Cells = (
16 16
@ -263,22 +263,22 @@ object MainForm: TMainForm
OnClick = GridClick OnClick = GridClick
OnSelection = AlphaGridSelection OnSelection = AlphaGridSelection
ColWidths = ( ColWidths = (
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
17 15
18 27
) )
Cells = ( Cells = (
16 16

View File

@ -818,6 +818,7 @@ procedure TMainForm.LoadFile(const AFileName: String; AFormat: TsSpreadsheetForm
var var
OLEDocument: TOLEDocument; OLEDocument: TOLEDocument;
streamname: UTF8String; streamname: UTF8String;
filestream: TFileStream;
begin begin
if MemStream <> nil then if MemStream <> nil then
FreeAndNil(MemStream); FreeAndNil(MemStream);
@ -828,7 +829,14 @@ begin
MemStream := TMemoryStream.Create; MemStream := TMemoryStream.Create;
if AFormat = sfExcel2 then begin if AFormat = sfExcel2 then begin
MemStream.LoadFromFile(UTF8ToSys(AFileName)); fileStream := TFileStream.Create(UTF8ToSys(AFileName), fmOpenRead + fmShareDenyNone);
try
MemStream.CopyFrom(fileStream, fileStream.Size);
MemStream.Position := 0;
// MemStream.LoadFromFile(UTF8ToSys(AFileName));
finally
filestream.Free;
end;
end else begin end else begin
OLEStorage := TOLEStorage.Create; OLEStorage := TOLEStorage.Create;

View File

@ -1666,7 +1666,7 @@ begin
// Write adapted copy of shared formula to stream. // Write adapted copy of shared formula to stream.
WriteRPNTokenArray(AStream, ACell, formula, false, RPNLength); WriteRPNTokenArray(AStream, ACell, formula, false, RPNLength);
// false --> "do not convert cess addresses to relative offsets", because // false --> "do not convert cell addresses to relative offsets", because
// biff2 does not support shared formulas! // biff2 does not support shared formulas!
// Clean up // Clean up