diff --git a/components/fpspreadsheet/fpspreadsheetctrls.pas b/components/fpspreadsheet/fpspreadsheetctrls.pas index a0b1d7c46..d2af24c72 100644 --- a/components/fpspreadsheet/fpspreadsheetctrls.pas +++ b/components/fpspreadsheet/fpspreadsheetctrls.pas @@ -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; diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index a7a6e6115..a5beca0ba 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -1739,7 +1739,7 @@ begin if col <> nil then AppendToStream(AStream, Format( '', - [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('', [font.Size, font.FontName]); + s := Format('', [font.Size, font.FontName], FPointSeparatorSettings); if (fssBold in font.Style) then s := s + ''; 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(