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