From 3c2bf5b3bdaff79567cb6c01d4902073c1f47d2d Mon Sep 17 00:00:00 2001 From: Baranovskiy Konstantin Date: Wed, 16 Jan 2019 15:16:25 +0200 Subject: [PATCH] Grid tricks: paste without grid expanding. CHANGED: On pasting multiple rows from a clipboard to the end of a grid, the grid is automatically expanding (appended needed number of rows). In general case the grid expanding on pasting is inappropriate. Rows must be added by tools like a button or a menu command etc. In some cases rows cannot be added at all. So we must paste only the part of the clipboard that fits between the cursor position and the end of the grid without a grid extending. --- common/grid_tricks.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/grid_tricks.cpp b/common/grid_tricks.cpp index 8ab8b82708..3a9433070b 100644 --- a/common/grid_tricks.cpp +++ b/common/grid_tricks.cpp @@ -397,22 +397,22 @@ void GRID_TRICKS::paste_text( const wxString& cb_text ) wxStringTokenizer rows( cb_text, ROW_SEP, wxTOKEN_RET_EMPTY ); - // if clipboard rows would extend past end of current table size... - if( int( rows.CountTokens() ) > tbl->GetNumberRows() - cur_row ) - { - int newRowsNeeded = rows.CountTokens() - ( tbl->GetNumberRows() - cur_row ); - - tbl->AppendRows( newRowsNeeded ); - } - for( int row = cur_row; rows.HasMoreTokens(); ++row ) { + // If table can't be expanded just paste the part of clipboard + // that may be placed. + if( row >= tbl->GetNumberRows() ) + break; + wxString rowTxt = rows.GetNextToken(); wxStringTokenizer cols( rowTxt, COL_SEP, wxTOKEN_RET_EMPTY ); for( int col = cur_col; cols.HasMoreTokens(); ++col ) { + if( col >= tbl->GetNumberCols() ) + break; + wxString cellTxt = cols.GetNextToken(); tbl->SetValue( row, col, cellTxt ); }