Small RDF patch

Ben Martin <[email protected]> Mon, 24 Mar 2014 22:09:12 +1000
Newsgroups gmane.editors.abiword.devel
Message-ID <1395662952.1827.32.camel@sam>

--=-4xhsFeAFNMaoU81+h5Vg
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Hi,
  I notice that current svn master doesn't allow semantic items to be
created. Tracking this down it turns out that some method sigs have
changed and a template class still had the older sigs. The attached
patch allows one to insert a "Contact" semantic item with the editor
coming up to allow one to customize it. The context menu again also
allows editing semantic items. I put a quick shortout at the top of
addRelevantIDsForPosition() if there is *no* RDF so that there is as
little potential slow down in that case as possible.

  While I may be able to still commit using dev credentials I thought it
best to run by the list instead since I've been inactive on abiword for
a while.


--=-4xhsFeAFNMaoU81+h5Vg
Content-Disposition: attachment; filename="abiword-2014march-rdf.patch"
Content-Type: text/x-patch; name="abiword-2014march-rdf.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Index: src/text/ptbl/xp/pd_DocumentRDF.cpp
===================================================================
--- src/text/ptbl/xp/pd_DocumentRDF.cpp	(revision 34094)
+++ src/text/ptbl/xp/pd_DocumentRDF.cpp	(working copy)
@@ -3845,6 +3845,12 @@
                                         std::pair< PT_DocPosition, PT_DocPosition > range )
 {
     //
+    // If we know we have nothing, then we might as well just return nothing
+    //
+    if( !haveSemItems() )
+        return ret;
+    
+    //
     // A sneaky optimization, for the first position we might have to
     // search backward to the start of the document to see opening
     // blocks and text:meta elements which might have RDF attached.
Index: src/text/ptbl/xp/pd_DocumentRDF.h
===================================================================
--- src/text/ptbl/xp/pd_DocumentRDF.h	(revision 34094)
+++ src/text/ptbl/xp/pd_DocumentRDF.h	(working copy)
@@ -1023,6 +1023,10 @@
 
 
     void addRDFForID( const std::string& xmlid, PD_DocumentRDFMutationHandle& m );
+    /**
+     * 
+     * This is a very fast call if there is no RDF in use.
+     */
     std::set< std::string >& addRelevantIDsForPosition( std::set< std::string >& ret,
                                                         PT_DocPosition pos );
     std::set< std::string >& addRelevantIDsForRange( std::set< std::string >& ret,
Index: src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.cpp
===================================================================
--- src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.cpp	(revision 34094)
+++ src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.cpp	(working copy)
@@ -110,6 +110,7 @@
 
 void GDestroyNotify_GObjectSemItem(gpointer data)
 {
+    UT_DEBUGMSG(("GDestroyNotify_GObjectSemItem data:%p\n", data ));
     ap_GObjectSemItem* obj = (ap_GObjectSemItem*)data;
     delete obj;
 }
@@ -124,7 +125,7 @@
 void OnSemItemEdited ( GtkDialog* d, gint /*response_id*/, 
 					   gpointer /*user_data*/)
 {
-    UT_DEBUGMSG(("OnSemItemEdited()\n"));
+    UT_DEBUGMSG(("OnSemItemEdited() d:%p\n",d));
     PD_RDFSemanticItemHandle h = getHandle( d );
     h->updateFromEditorData();
     gtk_widget_destroy( GTK_WIDGET(d) );
@@ -134,6 +135,7 @@
 
 void GDestroyNotify_GObjectSemItem_List(gpointer data)
 {
+    UT_DEBUGMSG(("GDestroyNotify_GObjectSemItem_List data:%p\n", data ));
     ap_GObjectSemItem_List* obj = (ap_GObjectSemItem_List*)data;
     delete obj;
 }
Index: src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.h
===================================================================
--- src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.h	(revision 34094)
+++ src/wp/ap/gtk/ap_RDFSemanticItemGTKInjected.h	(working copy)
@@ -77,7 +77,8 @@
     {
     }
 
-    void showEditorWindow( PD_RDFSemanticItemHandle c )
+//    void showEditorWindow( PD_RDFSemanticItemHandle c )
+    void showEditorWindow( const PD_RDFSemanticItemHandle& c )
     {
         UT_DEBUGMSG(("showEditorWindow(INJECTED) name:%s linksubj:%s\n",
                      c->name().c_str(), c->linkingSubject().toString().c_str() ));
@@ -92,17 +93,17 @@
                                 G_OBJECT_SEMITEM,
                                 new ap_GObjectSemItem( c ),
                                 GDestroyNotify_GObjectSemItem );
-        /* g_object_set_data_full( G_OBJECT(d), */
-        /*                         G_OBJECT_SEMITEM, */
-        /*                         new struct G_OBJECT_SEMITEM( c ), */
-        /*                         GDestroyNotify_G_OBJECT_SEMITEM ); */
+        g_object_set_data_full( G_OBJECT(d),
+                                G_OBJECT_SEMITEM,
+                                new ap_GObjectSemItem( c ),
+                                GDestroyNotify_GObjectSemItem );
         gtk_widget_reparent( w, GTK_WIDGET( gtk_dialog_get_content_area( GTK_DIALOG (d))));
 
         g_signal_connect (G_OBJECT(d), "response",  G_CALLBACK(OnSemItemEdited), c.get() );
         gtk_widget_show_all (d);
     }
 
-    void showEditorWindow( PD_RDFSemanticItems cl )
+    void showEditorWindow( const PD_RDFSemanticItems& cl )
     {
         UT_DEBUGMSG(("showEditorWindow() list... sz:%ld\n", cl.size() ));
 
@@ -115,7 +116,7 @@
         GtkNotebook* notebook = GTK_NOTEBOOK(gtk_notebook_new());
         gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area( GTK_DIALOG (d))),
                            GTK_WIDGET(notebook) );
-        for( PD_RDFSemanticItems::iterator ci = cl.begin(); ci != cl.end(); ++ci )
+        for( PD_RDFSemanticItems::const_iterator ci = cl.begin(); ci != cl.end(); ++ci )
         {
             PD_RDFSemanticItemHandle c = *ci;
             GtkWidget* w = GTK_WIDGET(c->createEditor());
Index: src/wp/ap/xp/ap_Menu_Functions.cpp
===================================================================
--- src/wp/ap/xp/ap_Menu_Functions.cpp	(revision 34094)
+++ src/wp/ap/xp/ap_Menu_Functions.cpp	(working copy)
@@ -672,8 +672,8 @@
 	UT_return_val_if_fail( rdf, EV_MIS_Gray );
 
 	/* The editors aren't working yet. Remove if they do work. */
-	if (id == AP_MENU_ID_RDFANCHOR_EDITSEMITEM) 
-		return EV_MIS_Gray;
+//	if (id == AP_MENU_ID_RDFANCHOR_EDITSEMITEM) 
+//		return EV_MIS_Gray;
 
 #ifndef WITH_EVOLUTION_DATA_SERVER
 	if (id == AP_MENU_ID_RDFANCHOR_EXPORTSEMITEM) 
@@ -681,10 +681,8 @@
 #endif
     
 	EV_Menu_ItemState s = EV_MIS_ZERO ;
-    return s;
 
-    
-    PD_RDFContacts contacts = rdf->getContacts();
+//    PD_RDFContacts contacts = rdf->getContacts();
 
     std::set< std::string > xmlids;
     rdf->addRelevantIDsForPosition( xmlids, pView->getPoint() );

--=-4xhsFeAFNMaoU81+h5Vg--