fpspreadsheet: CutToClipboard using system clipboard now

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4361 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-09-25 11:28:44 +00:00
parent 2ad5901d28
commit 69c34e5687
2 changed files with 32 additions and 34 deletions

View File

@ -446,6 +446,7 @@ type
// Selected cell and ranges // Selected cell and ranges
procedure SelectCell(ARow, ACol: Cardinal); procedure SelectCell(ARow, ACol: Cardinal);
procedure ClearSelection; procedure ClearSelection;
procedure DeleteSelection;
function GetSelection: TsCellRangeArray; function GetSelection: TsCellRangeArray;
function GetSelectionAsString: String; function GetSelectionAsString: String;
function GetSelectionCount: Integer; function GetSelectionCount: Integer;
@ -3579,6 +3580,25 @@ begin
SetLength(FSelection, 0); SetLength(FSelection, 0);
end; end;
{@@ ----------------------------------------------------------------------------
Deletes all selected cells (delete = make them empty)
-------------------------------------------------------------------------------}
procedure TsWorksheet.DeleteSelection;
var
i: Integer;
r, c: Cardinal;
cell: PCell;
begin
for i:=0 to High(FSelection) do
for r := FSelection[i].Row1 to FSelection[i].Row2 do
for c := FSelection[i].Col1 to FSelection[i].Col2 do
begin
cell := FindCell(r, c);
DeleteCell(cell);
end;
ClearSelection;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Returns the list of selected cell ranges Returns the list of selected cell ranges
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}

View File

@ -62,7 +62,6 @@ type
FFileFormat: TsSpreadsheetFormat; FFileFormat: TsSpreadsheetFormat;
FPendingSelection: TsCellRangeArray; FPendingSelection: TsCellRangeArray;
FPendingOperation: TsCopyOperation; FPendingOperation: TsCopyOperation;
FCutPending: Boolean;
FControlLockCount: Integer; FControlLockCount: Integer;
FOptions: TsWorkbookOptions; FOptions: TsWorkbookOptions;
FOnError: TsWorkbookSourceErrorEvent; FOnError: TsWorkbookSourceErrorEvent;
@ -122,8 +121,8 @@ type
const ASelection: TsCellRangeArray); const ASelection: TsCellRangeArray);
{ Clipboard } { Clipboard }
function CellClipboardEmpty: Boolean; // function CellClipboardEmpty: Boolean;
procedure ClearCellClipboard; // procedure ClearCellClipboard;
procedure CopyCellsToClipboard; procedure CopyCellsToClipboard;
procedure CutCellsToClipboard; procedure CutCellsToClipboard;
procedure PasteCellsFromClipboard(AItem: TsCopyOperation); procedure PasteCellsFromClipboard(AItem: TsCopyOperation);
@ -525,9 +524,6 @@ type
property MultipleRanges: Boolean read FMultipleRanges write FMultipleRanges; property MultipleRanges: Boolean read FMultipleRanges write FMultipleRanges;
end; end;
var
CellClipboard: TsCellList = nil;
destructor TsCellList.Destroy; destructor TsCellList.Destroy;
begin begin
Clear; Clear;
@ -1138,23 +1134,6 @@ begin
FPendingOperation := AOperation; FPendingOperation := AOperation;
end; end;
{@@ ----------------------------------------------------------------------------
Checks whether the internal "Clipboard" is empty or not.
-------------------------------------------------------------------------------}
function TsWorkbookSource.CellClipboardEmpty: Boolean;
begin
Result := CellClipboard.Count = 0;
end;
{@@ ----------------------------------------------------------------------------
Clears the interal "Clipboard". Note that this is not the system clipboard.
-------------------------------------------------------------------------------}
procedure TsWorkbookSource.ClearCellClipboard;
begin
CellClipboard.Clear;
CellClipboard.MultipleRanges := false;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Copies the selected cells of the worksheet to an internal list ("Clipboard"). Copies the selected cells of the worksheet to an internal list ("Clipboard").
Note that this is not the system clipboard in the current implementation. Note that this is not the system clipboard in the current implementation.
@ -1222,12 +1201,10 @@ begin
finally finally
Clipboard.Close; Clipboard.Close;
end; end;
(*
exit; exit;
FCutPending := false;
ClearCellClipboard; ClearCellClipboard;
for i:=0 to High(sel) do for i:=0 to High(sel) do
@ -1242,19 +1219,19 @@ begin
end; end;
CellClipboard.MultipleRanges := (Length(sel) > 1); CellClipboard.MultipleRanges := (Length(sel) > 1);
*)
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Copies the selected cells of the worksheet to an internal list ("Clipboard") Copies the selected cells of the worksheet to an internal list ("Clipboard")
and sets the marker "CutPending". This means that the source cells will be and deletes them afterwards.
cleared when PasteCellsFromClipboard is called.
Note that the clipboard is not the system clipboard in the current
implementation.
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsWorkbookSource.CutCellsToClipboard; procedure TsWorkbookSource.CutCellsToClipboard;
var
i: Integer;
begin begin
CopyCellsToClipboard; CopyCellsToClipboard;
FCutPending := true; FWorksheet.DeleteSelection;
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -1307,11 +1284,11 @@ begin
Clipboard.Close; Clipboard.Close;
end; end;
(*
exit; exit;
if CellClipboard.Count = 0 then if CellClipboard.Count = 0 then
exit; exit;
@ -1401,6 +1378,7 @@ begin
finally finally
EnableControls; EnableControls;
end; end;
*)
end; end;
(* (*
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -3198,7 +3176,7 @@ end;
initialization initialization
{$I fpspreadsheetctrls.lrs} {$I fpspreadsheetctrls.lrs}
CellClipboard := TsCellList.Create; // CellClipboard := TsCellList.Create;
ComboColors := TsPalette.Create; ComboColors := TsPalette.Create;
ComboColors.AddExcelColors; ComboColors.AddExcelColors;
@ -3214,7 +3192,7 @@ initialization
finalization finalization
CellClipboard.Free; // CellClipboard.Free;
if ComboColors <> nil then ComboColors.Free; if ComboColors <> nil then ComboColors.Free;