[evolution-patches] [gtkhtml] inserting nested cluevs fix




Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2099
diff -u -p -r1.2099 ChangeLog
--- ChangeLog	28 Feb 2005 15:36:25 -0000	1.2099
+++ ChangeLog	3 Mar 2005 16:31:20 -0000
@@ -1,3 +1,11 @@
+2005-03-03  Radek Doulik  <rodo novell com>
+
+	* test-suite.c (test_insert_nested_cluevs): added test for
+	inserting nested cluevs
+
+	* htmlobject.c (html_object_get_insert_level): make sure object
+	insert level isn't greater than cursor level
+
 2005-02-28  Radek Doulik  <rodo novell com>
 
 	* htmltext.c (html_text_direction_pango_to_html): new helper
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.592
diff -u -p -r1.592 gtkhtml.c
--- gtkhtml.c	28 Feb 2005 15:36:25 -0000	1.592
+++ gtkhtml.c	3 Mar 2005 16:31:28 -0000
@@ -5593,7 +5593,7 @@ gtk_html_insert_html_generic (GtkHTML *h
 		tmp->engine->clue = NULL;
 		html_engine_insert_object (html->engine, o,
 					   html_object_get_recursive_length (o),
-					   html_object_get_insert_level (o));
+					   html_object_get_insert_level (o, html->engine));
 	}
 	gtk_widget_destroy (window);
 	html_engine_thaw (html->engine);
Index: htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.108
diff -u -p -r1.108 htmlengine-edit-cut-and-paste.c
--- htmlengine-edit-cut-and-paste.c	28 Feb 2005 15:36:25 -0000	1.108
+++ htmlengine-edit-cut-and-paste.c	3 Mar 2005 16:31:31 -0000
@@ -1102,7 +1102,7 @@ html_engine_paste_object (HTMLEngine *e,
 {
 	html_undo_level_begin (e->undo, "Paste", "Paste");
 	html_engine_delete (e);
-	html_engine_insert_object (e, o, len, html_object_get_insert_level (o));
+	html_engine_insert_object (e, o, len, html_object_get_insert_level (o, e));
 	html_undo_level_end (e->undo);
 }
 
Index: htmlobject.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlobject.c,v
retrieving revision 1.186
diff -u -p -r1.186 htmlobject.c
--- htmlobject.c	3 Feb 2005 17:18:43 -0000	1.186
+++ htmlobject.c	3 Mar 2005 16:31:36 -0000
@@ -41,6 +41,7 @@
 #include "htmlobject.h"
 #include "htmlpainter.h"
 #include "htmltable.h"
+#include "htmltablecell.h"
 #include "htmltext.h"
 #include "htmlrule.h"
 #include "htmltype.h"
@@ -2062,19 +2063,27 @@ html_object_is_parent (HTMLObject *paren
 }
 
 gint
-html_object_get_insert_level (HTMLObject *o)
+html_object_get_insert_level (HTMLObject *o, HTMLEngine *e)
 {
 	switch (HTML_OBJECT_TYPE (o)) {
 	case HTML_TYPE_TABLECELL:
 	case HTML_TYPE_CLUEV: {
-		int level = 3;
+		int level = 3, cursor_level = 3;
 
-		while (o && HTML_IS_CLUEV (o) && HTML_CLUE (o)->head && HTML_IS_CLUEV (HTML_CLUE (o)->head)) {
+		while (o && (HTML_IS_CLUEV (o) || HTML_IS_TABLE_CELL (o))
+		       && HTML_CLUE (o)->head && (HTML_IS_CLUEV (HTML_CLUE (o)->head) || HTML_IS_TABLE_CELL (HTML_CLUE (o)->head))) {
 			level ++;
 			o = HTML_CLUE (o)->head;
 		}
 
-		return level;
+		if (e && e->cursor->object && e->cursor->object->parent && e->cursor->object->parent->parent && html_object_is_clue (e->cursor->object->parent->parent)) {
+			HTMLObject *clue = e->cursor->object->parent->parent;
+
+			while (clue && clue->parent && (HTML_IS_CLUEV (clue->parent) || HTML_IS_TABLE_CELL (clue->parent)))
+			       cursor_level ++;
+		}
+
+		return MIN (level, cursor_level);
 	}
 	case HTML_TYPE_CLUEFLOW:
 		return 2;
Index: htmlobject.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlobject.h,v
retrieving revision 1.133
diff -u -p -r1.133 htmlobject.h
--- htmlobject.h	31 Jan 2005 11:20:43 -0000	1.133
+++ htmlobject.h	3 Mar 2005 16:31:38 -0000
@@ -577,7 +577,8 @@ void      html_object_merge_down        
 						  HTMLEngine *e);
 gboolean  html_object_is_parent                  (HTMLObject *parent,
 						  HTMLObject *child);
-gint      html_object_get_insert_level           (HTMLObject *o);
+gint      html_object_get_insert_level           (HTMLObject *o,
+						  HTMLEngine *e);
 
 void      html_object_engine_translation   (HTMLObject *o,
 					    HTMLEngine *e,
Index: test-suite.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/test-suite.c,v
retrieving revision 1.10
diff -u -p -r1.10 test-suite.c
--- test-suite.c	21 Feb 2005 16:34:49 -0000	1.10
+++ test-suite.c	3 Mar 2005 16:31:39 -0000
@@ -36,6 +36,7 @@ static int test_quotes_in_div_block (Gtk
 static int test_quotes_in_table (GtkHTML *html);
 static int test_capitalize_upcase_lowcase_word (GtkHTML *html);
 static int test_delete_nested_cluevs_and_undo (GtkHTML *html);
+static int test_insert_nested_cluevs (GtkHTML *html);
 static int test_indentation_plain_text (GtkHTML *html);
 static int test_indentation_plain_text_rtl (GtkHTML *html);
 
@@ -53,6 +54,7 @@ static Test tests[] = {
 	{ "outer quotes inside table", test_quotes_in_table },
 	{ "capitalize, upcase/lowcase word", test_capitalize_upcase_lowcase_word },
 	{ "delete across nested cluev's and undo", test_delete_nested_cluevs_and_undo },
+	{ "insert nested cluev's", test_insert_nested_cluevs },
 	{ "indentation in plain text", test_indentation_plain_text },
 	{ "indentation in plain text (RTL)", test_indentation_plain_text_rtl },
 	{ NULL, NULL }
@@ -118,6 +120,15 @@ static int test_delete_nested_cluevs_and
 	if (html->engine->cursor->offset != 3
 	    || html->engine->cursor->position != 7)
 		return FALSE;
+
+	return TRUE;
+}
+
+static int test_insert_nested_cluevs (GtkHTML *html)
+{
+	load_editable (html, "text");
+
+	gtk_html_insert_html (html, "<div>text in div block</div>");
 
 	return TRUE;
 }


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