kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #39047
[PATCH 4/7] 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 8ab8b8270..3a9433070 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 );
}
--
2.20.1
References