Commit 73896c25 authored by Mame Coumba Sall's avatar Mame Coumba Sall

Various patches by mame to support width and height.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14510 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1d978441
def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
portal_skins_folder=None, object_portal_type=None, object_title=None, module_id=None,
module_title=None, selection_index=None, selection_name=None, import_scribus_file=None,
import_pdf_file=None, option_html=None, import_image_1=None, import_image_2=None,
import_pdf_file=None, option_html=None,desired_height=None, desired_width=None, import_image_1=None, import_image_2=None,
import_image_3=None, **kw) :
""" Creates a module, portal_type and ERP5Form from a scribus and
PDFForm file"""
......@@ -27,21 +27,21 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
ManageCSS = ManageCSS()
generator = LocalGenerator()
# DECLARING VARIABLES
def_lineNumberInList = 20
def_colorRequired = 'rgb(192,192,255)'
def_colorRequiredError = 'rgb(128,128,255)'
def_color = '#F6FFFF'
def_colorError = 'rgb(255,64,64)'
def_lineNumberInList = 20 # JPS-XXX - hardcoded
def_colorRequired = 'rgb(192,192,255)' # JPS-XXX - hardcoded
def_colorRequiredError = 'rgb(128,128,255)' # JPS-XXX - hardcoded
def_color = '#F6FFFF' # JPS-XXX - hardcoded
def_colorError = 'rgb(255,64,64)' # JPS-XXX - hardcoded
# recovering objects
portal = context.getPortalObject()
portal_types = portal.portal_types
object_portal_type_id = object_portal_type
desired_height= desired_height
desired_width= desired_width
resolution= 300 # JPS-XXX - hardcoded
option_html = option_html
# DECLARING NAMES
# declaring names for ERP5 objects, such as Form, DTML Document, etc.
......@@ -49,7 +49,6 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
object_names = ManageModule.setObjectNames(object_portal_type_id,
object_title)
# CREATING NEW PORTAL TYPE FOR THE MODULE
# Manage the creation of a ne portal_type for the module
# (module is not saved for the moment, but properties can be
......@@ -96,6 +95,7 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
global_properties = ScribusParser.initFieldDict()
# PARSER VARIABLES DECLARATION
# the following variable will recover the final CSS
# file's content object (string) before saving it
......@@ -105,14 +105,11 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
properties_css_dict = {}
# init page number
page_number_int = 0
scale_factor=0
# import scribus file
# take the input ScribusFile and read the content
xml_string = ScribusParser.getContentFile(import_scribus_file)
if xml_string == None:
LOG("ScribusParser",1,"Scribus file is empty !")
print "no field was defined in the Scribus file"
pass
else:
......@@ -121,7 +118,6 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
# get string from ScribusFile content
output_string = str(xml_string)
print " createmodule > ScribusParser.getXmlObjectPropertiesDict"
# building a tree from the output string elaborated from the
# original Scribus file.
......@@ -141,10 +137,13 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
# to extract all the usefull properties and organize elements. Then check
# attributes to get properties values.
# This represents the main process of the script.
widget_properties = ScribusParser.getPropertiesConversionDict(text_field_list)
(widget_properties) = ScribusParser.getPropertiesConversionDict(text_field_list)
print " createmodule < ScribusParser.getPropertiesConversionDict\n"
# testing if final rendering is PDF-like
if option_html ==1 :
print " createmodule > generating background"
......@@ -153,35 +152,30 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
# format (JPG) and add them to the skin folder as Image objects.
# used only with option_html == 1
# recover image_size
image_size = ManageFiles.setBackgroundPictures(import_pdf_file,
object_names,
skin_folder)
page_height, page_width = image_size
image_size=ManageFiles.setBackgroundPictures(import_pdf_file,object_names,skin_folder,desired_height,desired_width,resolution)
page_height,page_width,original_page_height,original_page_width = image_size
print " height = " + str(page_height)
print " width = " + str(page_width)
print " createmodule < background generated\n"
# add field from OrderedWidgetProperties in ERP5 Module created
# radiofield_widget_properties = {}
position = {}
# personal_properties_list is used to create PropertySheet
personal_properties_list = []
# recovering number of pages
global_properties['page'] = len(widget_properties)
# CSS FILE INIT
# init the CSS dict by creating sub-dicts to store various information
# i.e : 'head', 'standard' ,'error', etc.
# these sub-dicts are stored in the properties_css_dict
properties_css_dict = ManageCSS.setInit()
# BEGINING DATA INTERPRETATION
LOG("ScribusParser",0,"begining interpretation of data")
print " createmodule > begining data interpretation"
#iterating pages
#print " %s" % int(global_properties['page'])
......@@ -190,22 +184,22 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
page_content = widget_properties[page_number]
page_id = "page_" + page_number
if option_html == 1:
# CSS PAGE DEFINITION (PAGE AND BACKGROUND IMAGE)
# get CSS class properties relative to the actual page
# (background picture position, picture size, etc.)
# and add them to the css dict
properties_css_dict = ManageCSS.setPageProperties(
width_groups,height_groups = ManageFiles.getPageattributes(
global_properties,
import_pdf_file)
properties_css_dict,properties_page,actual_width,actual_height = ManageCSS.setPageProperties(
properties_css_dict,
page_iterator,
page_id,
page_height)
page_height,
page_width,
original_page_width,
original_page_height,width_groups,height_groups)
# RESUME DATA INTERPRETATION
# iterating pageobjects in page
......@@ -226,11 +220,16 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
page_height,
page_iterator,
page_gap,
keep_page)
keep_page,
0,
0,
properties_page,actual_width,actual_height)
# recover useful page_object attributes from scribus dict
# to be able to create and update correctly the fields
# composing the form
ScribusParser.getFieldAttributes(page_content[index],
option_html,
page_id,
......@@ -270,13 +269,15 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
# create fields corresponding to the page_objects
# recovered from the scribus file
ManageModule.setFieldsInObjectForm(skin_folder,
object_names,
default_groups,
global_properties,
option_html
)
print " createmodue < fields created in ERP5 Form\n"
print " createmodule < fields created in ERP5 Form\n"
......@@ -296,6 +297,7 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
# PROPERTYSHEET AND DOCUMENT CREATION
print " createmodule > PropertySheet and Document creation"
# recover personal properties and save them in a PropertySheet
# then create the Document related to the object
......@@ -346,4 +348,4 @@ def ERP5Site_createModuleScribus(self, form_id=None, module_portal_type=None,
)
# redirect
portal.REQUEST.RESPONSE.redirect( redirect_url )
portal.REQUEST.RESPONSE.redirect(redirect_url )
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment