You've already forked lazarus-ccr
fpspreadsheet: Fix crash of db_import_export demo in virtual mode.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5993 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -8,7 +8,7 @@ object Form1: TForm1
|
||||
ClientWidth = 521
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.7'
|
||||
LCLVersion = '1.9.0.0'
|
||||
object PageControl: TPageControl
|
||||
Left = 4
|
||||
Height = 302
|
||||
@ -274,7 +274,6 @@ object Form1: TForm1
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
ItemHeight = 0
|
||||
OnClick = FileListClick
|
||||
Options = [lboDrawFocusRect]
|
||||
TabOrder = 1
|
||||
end
|
||||
object Label3: TLabel
|
||||
|
@ -514,6 +514,7 @@ begin
|
||||
|
||||
FWorkbook := TsWorkbook.Create;
|
||||
try
|
||||
FWorkbook.FormatSettings.ShortDateFormat := 'dd.mm.yyyy "r."';
|
||||
worksheet := FWorkbook.AddWorksheet(tableName);
|
||||
|
||||
// Make header line frozen - but not in Excel2 where frozen panes do not yet work properly
|
||||
@ -614,7 +615,7 @@ begin
|
||||
cctNumber : if IsCurrencyFormat(nfp) then fieldType := ftCurrency
|
||||
else fieldType := ftFloat;
|
||||
cctDateTime : fieldType := ftDateTime;
|
||||
cctUTF8String : fieldType := ftString;
|
||||
else fieldType := ftString;
|
||||
end;
|
||||
FImportDataset.FieldDefs.Add(FImportedFieldNames[i], fieldType);
|
||||
end;
|
||||
@ -629,7 +630,7 @@ begin
|
||||
case FImportedRowCells[i].ContentType of
|
||||
cctNumber : FImportDataset.Fields[i].AsFloat := FImportedRowCells[i].NumberValue;
|
||||
cctDateTime : FImportDataset.Fields[i].AsDateTime := FImportedRowCells[i].DateTimeValue;
|
||||
cctUTF8String: FImportDataset.Fields[i].AsString := FImportedRowCells[i].UTF8StringValue;
|
||||
else FImportDataset.Fields[i].AsString := FImportedRowCells[i].UTF8StringValue;
|
||||
end;
|
||||
FImportDataset.Post;
|
||||
// Finally we dispose the buffered cells, we don't need them any more
|
||||
|
@ -1778,7 +1778,7 @@ begin
|
||||
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -1798,7 +1798,7 @@ var
|
||||
begin
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -1997,7 +1997,7 @@ var
|
||||
begin
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -2023,7 +2023,7 @@ var
|
||||
begin
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -2311,7 +2311,7 @@ begin
|
||||
// Create cell and apply format
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.GetCell(ARow, ACol); // Don't use AddCell here
|
||||
@ -2643,7 +2643,7 @@ begin
|
||||
// Initalize cell
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -2760,7 +2760,7 @@ var
|
||||
begin
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -3559,7 +3559,7 @@ var
|
||||
else
|
||||
begin
|
||||
// No cell in row --> appy format to dummy cell to get its format index
|
||||
InitCell(row, 0, cellRecord);
|
||||
InitCell(FWorksheet, row, 0, cellRecord);
|
||||
ApplyStyleToCell(@cellRecord, styleIndex);
|
||||
lRow^.FormatIndex := cellRecord.FormatIndex;
|
||||
end;
|
||||
@ -3618,7 +3618,7 @@ var
|
||||
if cell <> nil then
|
||||
colFmt[col] := cell^.FormatIndex
|
||||
else begin
|
||||
InitCell(row, col, cellRecord);
|
||||
InitCell(FWorksheet, row, col, cellRecord);
|
||||
ApplyStyleToCell(@cellRecord, styleIndex);
|
||||
colFmt[col] := cellRecord.FormatIndex;
|
||||
end;
|
||||
@ -7327,7 +7327,7 @@ begin
|
||||
colsRepeated := 1;
|
||||
|
||||
lCell.Row := r; // to silence a compiler hint...
|
||||
InitCell(r, c, lCell);
|
||||
InitCell(ASheet, r, c, lCell);
|
||||
value := varNull;
|
||||
styleCell := nil;
|
||||
|
||||
@ -7339,7 +7339,7 @@ begin
|
||||
cc := c + 1;
|
||||
while (cc <= lastCol) do
|
||||
begin
|
||||
InitCell(r, cc, lCell);
|
||||
InitCell(ASheet, r, cc, lCell);
|
||||
value := varNull;
|
||||
styleCell := nil;
|
||||
ASheet.OnWriteCellData(ASheet, r, cc, value, styleCell);
|
||||
|
@ -2274,7 +2274,7 @@ begin
|
||||
WriteComment(r, c, '');
|
||||
|
||||
// Erase all cell content
|
||||
InitCell(r, c, ACell^);
|
||||
InitCell(nil, r, c, ACell^);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -174,7 +174,7 @@ procedure SplitHyperlink(AValue: String; out ATarget, ABookmark: String);
|
||||
procedure FixHyperlinkPathDelims(var ATarget: String);
|
||||
|
||||
procedure InitCell(out ACell: TCell); overload;
|
||||
procedure InitCell(ARow, ACol: Cardinal; out ACell: TCell); overload;
|
||||
procedure InitCell(AWorksheet: Pointer; ARow, ACol: Cardinal; out ACell: TCell); overload;
|
||||
procedure InitCryptoInfo(out AValue: TsCryptoInfo);
|
||||
procedure InitFormatRecord(out AValue: TsCellFormat);
|
||||
procedure InitImageRecord(out AValue: TsImage; ARow, ACol: Cardinal;
|
||||
@ -2105,13 +2105,15 @@ end;
|
||||
Initalizes a new cell and presets the row and column fields of the cell record
|
||||
to the parameters passed to the procedure.
|
||||
|
||||
@param ARow Row index of the new cell
|
||||
@param ACol Column index of the new cell
|
||||
@param AWorksheet Pointer to the worksheet containing the cell
|
||||
@param ARow Row index of the new cell
|
||||
@param ACol Column index of the new cell
|
||||
@return New cell record with row and column fields preset to passed values.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure InitCell(ARow, ACol: Cardinal; out ACell: TCell);
|
||||
procedure InitCell(AWorksheet: Pointer; ARow, ACol: Cardinal; out ACell: TCell);
|
||||
begin
|
||||
InitCell(ACell);
|
||||
ACell.Worksheet := AWorksheet;
|
||||
ACell.Row := ARow;
|
||||
ACell.Col := ACol;
|
||||
end;
|
||||
|
@ -492,13 +492,13 @@ begin
|
||||
// Column width (to be considered in first row)
|
||||
if i = 0 then
|
||||
lColWidthStr := Format(' width="%.0fpt"', [
|
||||
FWorkbook.ConvertUnits(FWorksheet.GetColWidth(i), FWorkbook.Units, suPoints)
|
||||
FWorkbook.ConvertUnits(FWorksheet.GetColWidth(i, suChars), FWorkbook.Units, suPoints)
|
||||
]);
|
||||
|
||||
// Row height (to be considered in first column)
|
||||
if j = 0 then
|
||||
lRowHeightStr := Format(' height="%.0fpt"', [
|
||||
FWorkbook.ConvertUnits(FWorksheet.GetRowHeight(j), FWorkbook.Units, suPoints)
|
||||
FWorkbook.ConvertUnits(FWorksheet.GetRowHeight(j, suLines), FWorkbook.Units, suPoints)
|
||||
]);
|
||||
|
||||
// Font
|
||||
|
@ -328,7 +328,7 @@ var
|
||||
begin
|
||||
ReadRowColXF(AStream, ARow, ACol, XF);
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -358,7 +358,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(r, c, FVirtualCell);
|
||||
InitCell(FWorksheet, r, c, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(r, c);
|
||||
@ -687,7 +687,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -782,7 +782,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -817,7 +817,7 @@ begin
|
||||
|
||||
{Create cell}
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -856,7 +856,7 @@ begin
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
|
@ -657,7 +657,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -1095,7 +1095,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
|
@ -1051,7 +1051,7 @@ begin
|
||||
|
||||
{ Save the data }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell); // "virtual" cell
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell); // "virtual" cell
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol); // "real" cell
|
||||
@ -1293,7 +1293,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell); // "virtual" cell
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell); // "virtual" cell
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol); // "real" cell
|
||||
@ -1443,7 +1443,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
|
@ -1324,7 +1324,7 @@ begin
|
||||
XF := WordLEToN(rec.XFIndex);
|
||||
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -1359,7 +1359,7 @@ begin
|
||||
XF := WordLEToN(rec.XFIndex);
|
||||
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(r, c, FVirtualCell);
|
||||
InitCell(FWorksheet, r, c, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(r, c);
|
||||
@ -1661,7 +1661,7 @@ begin
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then // "Virtual" cell
|
||||
begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.GetCell(ARow, ACol); // "Real" cell
|
||||
@ -1788,7 +1788,7 @@ begin
|
||||
fc := WordLEtoN(AStream.ReadWord);
|
||||
pending := RecordSize - SizeOf(fc) - SizeOf(ARow);
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, 0, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, 0, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end;
|
||||
while pending > SizeOf(XF) do begin
|
||||
@ -1832,7 +1832,7 @@ begin
|
||||
fc := WordLEtoN(AStream.ReadWord);
|
||||
pending := RecordSize - SizeOf(fc) - SizeOf(ARow);
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, fc, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, fc, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end;
|
||||
while pending > SizeOf(XF) + SizeOf(RK) do begin
|
||||
@ -1894,7 +1894,7 @@ begin
|
||||
|
||||
{ Create cell }
|
||||
if FIsVirtualMode then begin // "virtual" cell
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol); // "real" cell
|
||||
@ -2185,7 +2185,7 @@ begin
|
||||
|
||||
{Create cell}
|
||||
if FIsVirtualMode then begin
|
||||
InitCell(ARow, ACol, FVirtualCell);
|
||||
InitCell(FWorksheet, ARow, ACol, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
@ -2855,7 +2855,7 @@ begin
|
||||
|
||||
{ Create cell - this is the "base" of the shared formula }
|
||||
if FIsVirtualMode then begin // "Virtual" cell
|
||||
InitCell(r1, c1, FVirtualCell);
|
||||
InitCell(FWorksheet, r1, c1, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.GetCell(r1, c1); // "Real" cell
|
||||
@ -4918,6 +4918,7 @@ begin
|
||||
begin
|
||||
lCell.Row := r; // to silence a compiler hint...
|
||||
InitCell(lCell);
|
||||
lCell.Worksheet := ASheet;
|
||||
value := varNull;
|
||||
styleCell := nil;
|
||||
ASheet.OnWriteCellData(ASheet, r, c, value, styleCell);
|
||||
|
@ -638,7 +638,7 @@ begin
|
||||
// create cell
|
||||
if FIsVirtualMode then
|
||||
begin
|
||||
InitCell(rowIndex, colIndex, FVirtualCell);
|
||||
InitCell(FWorksheet, rowIndex, colIndex, FVirtualCell);
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := AWorksheet.AddCell(rowIndex, colIndex);
|
||||
@ -706,7 +706,7 @@ begin
|
||||
begin
|
||||
sharedformulabase := TSharedFormulaData(FSharedFormulaBaseList[StrToInt(s)]);
|
||||
// ... and copy shared formula to destination cell
|
||||
InitCell(sharedformulabase.Row, sharedformulabase.Col, lCell);
|
||||
InitCell(FWorksheet, sharedformulabase.Row, sharedformulabase.Col, lCell);
|
||||
lCell.Formulavalue := sharedformulabase.Formula;
|
||||
lCell.Worksheet := sharedformulabase.Worksheet;
|
||||
FWorksheet.CopyFormula(@lCell, cell);
|
||||
|
@ -9,7 +9,7 @@ unit fpsexportreg;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LazarusPackageIntf, lresources, fpdataexporter;
|
||||
Classes, SysUtils, LazarusPackageIntf, lresources;
|
||||
|
||||
procedure Register;
|
||||
|
||||
|
@ -686,7 +686,7 @@ var
|
||||
cell: PCell;
|
||||
begin
|
||||
New(cell);
|
||||
InitCell(ARow, ACol, cell^);
|
||||
InitCell(nil, ARow, ACol, cell^);
|
||||
Result := inherited Add(cell);
|
||||
end;
|
||||
|
||||
|
@ -2131,7 +2131,6 @@ end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.DragDrop(Source: TObject; X, Y: Integer);
|
||||
var
|
||||
i, j: Integer;
|
||||
sel: TsCellRange;
|
||||
srccell, destcell: PCell;
|
||||
r: LongInt = 0;
|
||||
@ -2178,7 +2177,8 @@ procedure TsCustomWorksheetGrid.DragOver(ASource: TObject; X, Y: Integer;
|
||||
var
|
||||
destcell: PCell;
|
||||
sc, sr: Integer;
|
||||
gc, gr: Integer;
|
||||
gc: Integer = 0;
|
||||
gr: Integer = 0;
|
||||
dc, dr: Integer;
|
||||
sel: TsCellRange;
|
||||
dragMove: Boolean;
|
||||
@ -3014,7 +3014,6 @@ var
|
||||
r1,c1,r2,c2: Cardinal;
|
||||
delta: Integer;
|
||||
savedPenMode: TPenMode;
|
||||
penwidth: Integer;
|
||||
P: array[0..9] of TPoint;
|
||||
begin
|
||||
if Worksheet = nil then
|
||||
|
Reference in New Issue
Block a user