You've already forked lazarus-ccr
fpspreadsheet: Fix ooxml writer crashing when writing floating point numbers to various xml nodes using a decimal comma instead of a point (in non-English FormatSettings).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3740 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -61,6 +61,7 @@ type
|
||||
FFileFormat: TsSpreadsheetFormat;
|
||||
FPendingSelection: TsCellRangeArray;
|
||||
FPendingOperation: TsPendingOperation;
|
||||
FControlLockCount: Integer;
|
||||
FOptions: TsWorkbookOptions;
|
||||
FOnError: TsWorkbookSourceErrorEvent;
|
||||
|
||||
@ -103,6 +104,9 @@ type
|
||||
procedure SaveToSpreadsheetFile(AFileName: string; AFormat: TsSpreadsheetFormat;
|
||||
AOverwriteExisting: Boolean = true); overload;
|
||||
|
||||
procedure DisableControls;
|
||||
procedure EnableControls;
|
||||
|
||||
procedure SelectCell(ASheetRow, ASheetCol: Cardinal);
|
||||
procedure SelectWorksheet(AWorkSheet: TsWorksheet);
|
||||
|
||||
@ -471,6 +475,14 @@ begin
|
||||
NotifyListeners([lniWorkbook, lniWorksheet, lniSelection]);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Disables notification of listening controls
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.DisableControls;
|
||||
begin
|
||||
inc(FControlLockCount);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
An error has occured during loading of the workbook. Shows a message box by
|
||||
default. But a different behavior can be obtained by means of the OnError
|
||||
@ -488,6 +500,14 @@ begin
|
||||
MessageDlg(AErrorMsg, mtError, [mbOK], 0);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Enables notification of listening controls
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.EnableControls;
|
||||
begin
|
||||
dec(FControlLockCount);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Executes a "pending operation"
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -578,11 +598,16 @@ begin
|
||||
// Create a new empty workbook
|
||||
InternalCreateNewWorkbook;
|
||||
|
||||
// Read workbook from file and get worksheet
|
||||
if AAutoDetect then
|
||||
FWorkbook.ReadFromFile(AFileName)
|
||||
else
|
||||
FWorkbook.ReadFromFile(AFileName, AFormat);
|
||||
DisableControls;
|
||||
try
|
||||
// Read workbook from file and get worksheet
|
||||
if AAutoDetect then
|
||||
FWorkbook.ReadFromFile(AFileName)
|
||||
else
|
||||
FWorkbook.ReadFromFile(AFileName, AFormat);
|
||||
finally
|
||||
EnableControls;
|
||||
end;
|
||||
|
||||
SelectWorksheet(FWorkbook.GetWorkSheetByIndex(AWorksheetIndex));
|
||||
|
||||
@ -653,6 +678,9 @@ procedure TsWorkbookSource.NotifyListeners(AChangedItems: TsNotificationItems;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
//if FControlLockCount > 0 then
|
||||
// exit;
|
||||
|
||||
for i:=0 to FListeners.Count-1 do
|
||||
if TObject(FListeners[i]) is TsCellCombobox then
|
||||
TsCellCombobox(FListeners[i]).ListenerNotification(AChangedItems, AData)
|
||||
@ -861,6 +889,7 @@ end;
|
||||
procedure TsWorkbookSource.WorksheetAddedHandler(Sender: TObject;
|
||||
ASheet: TsWorksheet);
|
||||
begin
|
||||
Unused(Sender);
|
||||
NotifyListeners([lniWorkbook]);
|
||||
SelectWorksheet(ASheet);
|
||||
end;
|
||||
@ -875,7 +904,7 @@ end;
|
||||
procedure TsWorkbookSource.WorksheetChangedHandler(Sender: TObject;
|
||||
ASheet: TsWorksheet);
|
||||
begin
|
||||
Unused(ASheet);
|
||||
Unused(Sender, ASheet);
|
||||
NotifyListeners([lniWorkbook, lniWorksheet]);
|
||||
end;
|
||||
|
||||
|
@ -1739,7 +1739,7 @@ begin
|
||||
if col <> nil then
|
||||
AppendToStream(AStream, Format(
|
||||
'<col min="%d" max="%d" width="%g" customWidth="1" />',
|
||||
[c+1, c+1, col.Width])
|
||||
[c+1, c+1, col.Width], FPointSeparatorSettings)
|
||||
);
|
||||
end;
|
||||
|
||||
@ -1806,7 +1806,7 @@ begin
|
||||
// Font #4 is missing in fpspreadsheet due to BIFF compatibility. We write
|
||||
// an empty node to keep the numbers in sync with the stored font index.
|
||||
else begin
|
||||
s := Format('<sz val="%g" /><name val="%s" />', [font.Size, font.FontName]);
|
||||
s := Format('<sz val="%g" /><name val="%s" />', [font.Size, font.FontName], FPointSeparatorSettings);
|
||||
if (fssBold in font.Style) then
|
||||
s := s + '<b />';
|
||||
if (fssItalic in font.Style) then
|
||||
@ -1930,7 +1930,8 @@ begin
|
||||
row := AWorksheet.FindRow(r);
|
||||
if row <> nil then
|
||||
rh := Format(' ht="%g" customHeight="1"', [
|
||||
(row^.Height + ROW_HEIGHT_CORRECTION)*h0])
|
||||
(row^.Height + ROW_HEIGHT_CORRECTION)*h0],
|
||||
FPointSeparatorSettings)
|
||||
else
|
||||
rh := '';
|
||||
AppendToStream(AStream, Format(
|
||||
@ -1985,7 +1986,7 @@ begin
|
||||
row := AWorksheet.FindRow(r);
|
||||
if row <> nil then
|
||||
rh := Format(' ht="%g" customHeight="1"', [
|
||||
(row^.Height + ROW_HEIGHT_CORRECTION)*h0])
|
||||
(row^.Height + ROW_HEIGHT_CORRECTION)*h0], FPointSeparatorSettings)
|
||||
else
|
||||
rh := '';
|
||||
AppendToStream(AStream, Format(
|
||||
|
Reference in New Issue
Block a user