From b3e4727ae409af6414e8a12d894c6e6d67ce0524 Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Thu, 31 Jan 2008 15:32:30 +0000
Subject: [PATCH] - remove existing group to just keep the custom group
 'page_'+numpage. This fix permit to display many pages and not just the first
 with all fields on it like it was before this revision. The first group is
 renamed because the first element can't be removed - remove a code part wich
 was in the if and else block, and put it just after,   that permit to not
 have a duplicate code bloc

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18949 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ScribusUtils.py | 42 +++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/product/ERP5Form/ScribusUtils.py b/product/ERP5Form/ScribusUtils.py
index 200c9c7c14d..79f92677ff8 100644
--- a/product/ERP5Form/ScribusUtils.py
+++ b/product/ERP5Form/ScribusUtils.py
@@ -211,15 +211,27 @@ class ManageModule:
     else:
       # using special page positioning convention for
       # pdf-like rendering
-      del default_groups[0:]
       for page_iterator in range(global_properties['page']):
         page_number = 'page_%s' % str(page_iterator)
         default_groups.append(page_number)
+        
     # default_groups list completed, need to update the form_groups
-    # renaming form default group with list's first item
+    # rename the first group because it can't be removed
+    form.rename_group(form.group_list[0], default_groups[0])
+
+    # add other groups
+    if len(default_groups) > 1:
+      for group in default_groups[1:]:
+        form.add_group(group)
     form_view_id_object.rename_group('Default', default_groups[0])
+
+    # remove all other groups:
+    for existing_group in list(form.get_groups(include_empty=1)):
+      if existing_group not in default_groups:
+        form.remove_group(existing_group)
+
     # adding all other items
-    for group in default_groups[0:]:
+    for group in default_groups:
       form_view_id_object.add_group(group)
     # updating form settings
     # building dict containing (property, value)
@@ -810,25 +822,21 @@ class ManageCSS:
     if page_iterator == 0:
       # margin-top = 0 (first page)
       properties_css_page['margin-top'] = "0px"
-      properties_css_background['height'] = \
-        str(page_height) + 'px'
-      properties_css_background['width']= \
-        str (page_width) + 'px'
-      properties_page['actual_width'] = width_groups[page_iterator]
-      properties_page['actual_height'] = height_groups[page_iterator]
       #properties_css_background['margin-top'] = \
       #   str((y_pos -10))+ 'px'
       #properties_css_background['margin-left']= \
       #   str((x_pos- 5))+   'px' 
     else:
-      # margin-top = page height
-      properties_css_page['margin-top'] = "%spx" %(page_height + 20)
-      properties_page['actual_width'] = width_groups[page_iterator]
-      properties_page['actual_height'] = height_groups[page_iterator] 
-      properties_css_background['height'] = \
-        str(page_height) + 'px'
-      properties_css_background['width']= \
-        str (page_width) + 'px'
+      properties_css_page['margin-top'] = "%spx" %(40)
+
+    # set width and height on page block
+    properties_css_page['width'] = str (page_width) + 'px'
+    properties_css_page['height'] = str (page_height) + 'px'
+
+    properties_page['actual_width'] = width_groups[page_iterator]
+    properties_page['actual_height'] = height_groups[page_iterator] 
+    properties_css_background['height'] = str(page_height) + 'px'
+    properties_css_background['width'] = str (page_width) + 'px'
     # adding properties dict to global dicts
     properties_css_dict['head'][page_id] = properties_css_page
     properties_css_dict['head'][background_id] = properties_css_background
-- 
2.30.9