fpspreadsheet: Fix cell offset when pasting in from clipboard. Patch by DonAlfredo, https://forum.lazarus.freepascal.org/index.php/topic,47965.0.html

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7214 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2020-01-01 23:43:41 +00:00
parent 397d9de5de
commit 93ebcc497e

View File

@ -10383,6 +10383,7 @@ var
clipbook: TsWorkbook; clipbook: TsWorkbook;
clipsheet: TsWorksheet; clipsheet: TsWorksheet;
sel: TsCellRange; sel: TsCellRange;
range: TsCellRangeArray;
r, c: Cardinal; r, c: Cardinal;
srccell, destcell: PCell; srccell, destcell: PCell;
begin begin
@ -10412,8 +10413,9 @@ begin
end; end;
end; end;
// Select the same cells as in the source workbook. // Select the same cells as in the source workbook.
clipsheet.SetSelection(ActiveWorksheet.GetSelection); range := ActiveWorksheet.GetSelection;
clipsheet.SelectCell(ActiveWorksheet.ActiveCellRow, ActiveWorksheet.ActiveCellCol); clipsheet.SetSelection(range);
clipsheet.SelectCell(range[0].Row1, range[0].Col1);
// Write this workbook to a stream. Set the parameter spClipboard to // Write this workbook to a stream. Set the parameter spClipboard to
// indicate that this should be the special clipboard version of the stream. // indicate that this should be the special clipboard version of the stream.
@ -10488,8 +10490,8 @@ begin
and (ActiveWorksheet.GetSelection[0].Row1 = ActiveWorksheet.GetSelection[0].Row2) and (ActiveWorksheet.GetSelection[0].Row1 = ActiveWorksheet.GetSelection[0].Row2)
then begin then begin
// Find offset of active cell to left/top cell in clipboard sheet // Find offset of active cell to left/top cell in clipboard sheet
dr := LongInt(ActiveWorksheet.ActiveCellRow) - clipsheet.GetFirstRowIndex(true); dr := LongInt(ActiveWorksheet.ActiveCellRow) - clipsheet.ActiveCellRow;
dc := LongInt(ActiveWorksheet.ActiveCellCol) - clipsheet.GetFirstColIndex(true); dc := LongInt(ActiveWorksheet.ActiveCellCol) - clipsheet.ActiveCellCol;
// Copy cells from clipboard sheet to active worksheet // Copy cells from clipboard sheet to active worksheet
// Shift them such that top/left of clipboard sheet is at active cell // Shift them such that top/left of clipboard sheet is at active cell
for srcCell in clipsheet.Cells do for srcCell in clipsheet.Cells do
@ -10523,8 +10525,8 @@ begin
c := clipsheet.ActiveCellCol; c := clipsheet.ActiveCellCol;
end else end else
begin begin
r := sel.Row2; r := LongInt(sel.Row2);
c := sel.Col2; c := LongInt(sel.Col2);
end; end;
if (r <> -1) and (c <> -1) then if (r <> -1) and (c <> -1) then
ActiveWorksheet.SelectCell(r + dr, c + dc); ActiveWorksheet.SelectCell(r + dr, c + dc);