[gnumeric] Fix selection after filter-in-place



commit 3009c48f72e6fd8adc0d45b3aa260e2128158827
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue May 4 20:22:01 2010 -0600

    Fix selection after filter-in-place
    
    2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* filter.c (advanced_filter): force the selection to be
    	  corrected

 src/tools/ChangeLog |    5 +++++
 src/tools/filter.c  |   15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 290a793..264aea8 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,5 +1,10 @@
 2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* filter.c (advanced_filter): force the selection to be
+	  corrected
+	
+2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* filter.c (filter): use ri->in_advanced_filter rather
 	  than ri->in_filter
 	(cb_show_all): set ri->in_advanced_filter to false
diff --git a/src/tools/filter.c b/src/tools/filter.c
index d2b6987..46bd27d 100644
--- a/src/tools/filter.c
+++ b/src/tools/filter.c
@@ -33,6 +33,7 @@
 #include <cell.h>
 #include <ranges.h>
 #include <value.h>
+#include <selection.h>
 
 #include "filter.h"
 #include "analysis-tools.h"
@@ -106,6 +107,9 @@ advanced_filter (WorkbookControl        *wbc,
 {
         GSList  *crit, *rows;
 	GnmEvalPos ep;
+	GnmRange r, s;
+	SheetView *sv;
+	Sheet *sheet = criteria->v_range.cell.a.sheet;
 
 	/* I don't like this -- minimal fix for now.  509427.  */
 	if (criteria->type != VALUE_CELLRANGE)
@@ -118,7 +122,7 @@ advanced_filter (WorkbookControl        *wbc,
 	if (crit == NULL)
 		return analysis_tools_invalid_field;
 
-	rows = find_rows_that_match (database->v_range.cell.a.sheet,
+	rows = find_rows_that_match (sheet,
 				     database->v_range.cell.a.col,
 				     database->v_range.cell.a.row + 1,
 				     database->v_range.cell.b.col,
@@ -132,13 +136,20 @@ advanced_filter (WorkbookControl        *wbc,
 
 	dao_prepare_output (wbc, dao, _("Filtered"));
 
-	filter (dao, database->v_range.cell.a.sheet, rows,
+	filter (dao, sheet, rows,
 		database->v_range.cell.a.col,
 		database->v_range.cell.b.col, database->v_range.cell.a.row,
 		database->v_range.cell.b.row);
 
 	go_slist_free_custom (rows, (GFreeFunc)g_free);
 
+	sv = sheet_get_view (sheet, wb_control_view (wbc));
+	s = r = *(selection_first_range (sv, NULL, NULL));
+	r.end.row = r.start.row;
+	sv_selection_reset (sv);
+	sv_selection_add_range (sv, &r);
+	sv_selection_add_range (sv, &s);
+	
 	wb_control_menu_state_update (wbc, MS_FILTER_STATE_CHANGED);
 
 	return analysis_tools_noerr;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]