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.
This commit is contained in:
Baranovskiy Konstantin 2019-01-16 15:16:25 +02:00 committed by Wayne Stambaugh
parent 62bf4614ad
commit 3c2bf5b3bd
1 changed files with 8 additions and 8 deletions

View File

@ -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 );
}