[glom] pdate the DTD for portal navigation and save space in XML.



commit 09add90b7e2fc83d64388117c54ab67524c0a79c
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jun 4 16:52:45 2009 +0200

    pdate the DTD for portal navigation and save space in XML.
    
    * glom/glom_document.dtd: Update for the portal navigation changes,
    as promised in bug #574360
    * glom/libglom/document/document.cc: save_before_layout_group():
    Do not even create the portal_navigation_relationship node if it is the
    default (automatic), to save space in the XML file.
---
 ChangeLog                         |   10 ++++++++++
 glom/glom_document.dtd            |   16 +++++++++++++++-
 glom/libglom/document/document.cc |   20 +++++++++++++-------
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 178d3b8..0d43eea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-06-04  Murray Cumming  <murrayc murrayc-x61>
 
+	Update the DTD for portal navigation and save space in XML.
+
+	* glom/glom_document.dtd: Update for the portal navigation changes, 
+	as promised in bug #574360
+	* glom/libglom/document/document.cc: save_before_layout_group(): 
+	Do not even create the portal_navigation_relationship node if it is the 
+	default ("automatic"), to save space in the XML file.
+
+2009-06-04  Murray Cumming  <murrayc murrayc-x61>
+
 	Clean up the code to load/save portal navigation options.
 
 	* glom/libglom/document/document.cc: load_after_layout_group(): 
diff --git a/glom/glom_document.dtd b/glom/glom_document.dtd
index e2032b3..746d805 100644
--- a/glom/glom_document.dtd
+++ b/glom/glom_document.dtd
@@ -341,7 +341,7 @@ TODO: Test this by trying to validate some real documents against this DTD.
 <!-- A data_layout_portal is the essential information, a short and quick list of values
   that are probably of interest to others (e.g. contact information, name, etc). -->
 
-    <!ELEMENT data_layout_portal ANY >
+    <!ELEMENT data_layout_portal (portal_navigation_relationship)* >
     <!ATTLIST data_layout_portal
         name CDATA #REQUIRED
         relationship CDATA #REQUIRED
@@ -349,6 +349,20 @@ TODO: Test this by trying to validate some real documents against this DTD.
         hide CDATA #IMPLIED
         columns_count CDATA #IMPLIED >
 
+<!-- portal_navigation_relationship determines what happens when the user 
+     activates a row in a related records portal.
+     portal_navigation_relationship: "automatic", "specific" or "none".
+     relationship: If portal_navigation_relationship is "specific" then this is 
+     the relationship to which to navigate.
+     related_relationship: If portal_navigation_relationship is "specific" then 
+     this may be a related (to relationship) relationship to which to navigate. -->
+
+    <!ELEMENT portal_navigation_relationship ANY >
+    <!ATTLIST portal_navigation_relationship
+        navigation_type CDATA #REQUIRED
+        relationship CDATA #REQUIRED
+        related_relationship CDATA #REQUIRED >
+
 <!-- reports and data reports make short sheets of important information that
   distill a larger database. data_report(s) is the old interface; use reports if you are
   writing a new XML document. -->
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index c9dda05..57298a9 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -3043,15 +3043,13 @@ void Document::save_before_layout_group(xmlpp::Element* node, const sharedptr<co
               save_before_layout_item_usesrelationship(child, portal);
 
               //Portal navigation details:
-              xmlpp::Element* child_navigation_relationship = child->add_child(GLOM_NODE_DATA_LAYOUT_PORTAL_NAVIGATIONRELATIONSHIP);
-
-              Glib::ustring navigation_type_string = GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_AUTOMATIC; //Default.
+              Glib::ustring navigation_type_string;
               sharedptr<const UsesRelationship> relationship_navigation_specific;
 
               switch(portal->get_navigation_type())
               {
                 case LayoutItem_Portal::NAVIGATION_AUTOMATIC:
-                  navigation_type_string = GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_AUTOMATIC;
+                  //We leave this blank to use the default.
                   break;
                 case LayoutItem_Portal::NAVIGATION_NONE:
                   navigation_type_string = GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE_NONE;
@@ -3063,9 +3061,17 @@ void Document::save_before_layout_group(xmlpp::Element* node, const sharedptr<co
                   break;
               }
    
-              save_before_layout_item_usesrelationship(child_navigation_relationship, relationship_navigation_specific);
-              set_node_attribute_value(child_navigation_relationship, 
-                GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE, navigation_type_string);
+              //Empty means the default ("automatic")
+              //In that case we don't even write the node, to keep the XML small:   
+              if(!navigation_type_string.empty())
+              {
+                xmlpp::Element* child_navigation_relationship = child->add_child(GLOM_NODE_DATA_LAYOUT_PORTAL_NAVIGATIONRELATIONSHIP);
+
+                save_before_layout_item_usesrelationship(child_navigation_relationship, relationship_navigation_specific);
+                set_node_attribute_value(child_navigation_relationship, 
+                  GLOM_ATTRIBUTE_PORTAL_NAVIGATION_TYPE, navigation_type_string);
+              }              
+
 
               //Print Layout specific stuff:
               set_node_attribute_value_as_decimal(child, GLOM_ATTRIBUTE_PORTAL_PRINT_LAYOUT_ROW_HEIGHT, portal->get_print_layout_row_height());



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