9 _EXPORTSETTINGSITEMS = (
23 if data
is None or len(data) == 0:
24 data = cfg.readBlock(
'ImpostazioniExport',
True)
31 cfg.writeBlock(
'ImpostazioniExport', es,
True)
36 prepare cover page, if there's one
37 copy to nDoc document and fill it's data
38 return true if we've got a cover, false otherwise
39 docSubst is a dictionary with additional variable replacements
40 mostly used for [PAGINE], [OGGETTO] and [NUMERO_DOCUMENTO]
41 which are document dependent data
45 fileCopertine = data.get(
'fileCopertine')
46 copertina = data.get(
'copertina')
47 if fileCopertine
is None or copertina
is None:
49 if fileCopertine ==
'' or copertina ==
'':
55 if not copertina
in cDoc.Sheets:
61 sheet = cDoc.Sheets[copertina]
62 pageStyle = sheet.PageStyle
63 if pageStyle
is not None and pageStyle !=
'':
64 print(
"PAGE HAS STYLE")
65 pageStyles = cDoc.StyleFamilies.getByName(
'PageStyles')
66 style = pageStyles.getByName(pageStyle)
70 pos = nDoc.Sheets.Count
71 nDoc.Sheets.importSheet(cDoc, copertina, pos)
74 nDoc.Sheets[pos].PageStyle = sheet.PageStyle
75 if len(sheet.PrintAreas) > 0:
76 print(
"PAGE HAS PRINT AREA")
77 nDoc.Sheets[pos].PrintAreas = sheet.PrintAreas
81 for key, val
in docSubst.items():
99 for key, val
in docSubst.items():
103 for psKey
in (
'intSx',
'intCenter',
'intDx',
'ppSx',
'ppCenter',
'ppDx'):
104 if psKey
in printSettings:
105 psVal = printSettings[psKey]
106 for replKey, replVal
in replDict.items():
109 if replKey
in (
'[PAGINA]',
'[PAGINE]'):
112 while replKey
in psVal:
113 psVal = psVal.replace(replKey, replVal)
126 return Dialogs.Dialog(Title=
'Esportazione documenti PDF', Horz=
False, CanClose=
True, Items=[
136 Dialogs.Edit(Id=
'npElencoPrezzi', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
138 Dialogs.Edit(Id=
'npComputoMetrico', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
140 Dialogs.Edit(Id=
'npCostiManodopera', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
142 Dialogs.Edit(Id=
'npQuadroEconomico', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
148 Dialogs.CheckBox(Id=
"cbElencoPrezzi", Label=
"Elenco prezzi", FixedHeight=hItems),
150 Dialogs.CheckBox(Id=
"cbComputoMetrico", Label=
"Computo metrico", FixedHeight=hItems),
152 Dialogs.CheckBox(Id=
"cbCostiManodopera", Label=
"Costi manodopera", FixedHeight=hItems),
154 Dialogs.CheckBox(Id=
"cbQuadroEconomico", Label=
"Quadro economico", FixedHeight=hItems),
166 Dialogs.Button(Label=
'Ok', MinWidth=Dialogs.MINBTNWIDTH, Icon=
'Icons-24x24/ok.png', RetVal=1),
168 Dialogs.Button(Label=
'Annulla', MinWidth=Dialogs.MINBTNWIDTH, Icon=
'Icons-24x24/cancel.png', RetVal=-1),
177 ep = oDoc.Sheets.getByName(
'Elenco Prezzi')
182 if nDoc !=
'' and nDoc
is not None:
183 baseName = nDoc +
'-'
184 destPath = os.path.join(destFolder, baseName +
'ElencoPrezzi.pdf')
185 print(f
"Export to '{destPath}' file")
188 '[OGGETTO]':
'Elenco Prezzi',
189 '[NUMERO_DOCUMENTO]': str(nTavola),
192 nPages = len(ep.RowPageBreaks) - 1
195 docSubst[
'[PAGINE]'] = nPages
202 ep = oDoc.Sheets.getByName(
'COMPUTO')
207 if nDoc !=
'' and nDoc
is not None:
208 baseName = nDoc +
'-'
209 destPath = os.path.join(destFolder, baseName +
'ComputoMetrico.pdf')
213 '[OGGETTO]':
'Computo Metrico',
214 '[NUMERO_DOCUMENTO]': str(nTavola),
218 nPages = len(ep.RowPageBreaks) - 1
220 docSubst[
'[PAGINE]'] = nPages
236 es = dlg.getData(_EXPORTSETTINGSITEMS)
240 destFolder = dlg[
'pathEdit'].getPath()
248 if dlg[
'cbElencoPrezzi'].getState():
252 if dlg[
'cbComputoMetrico'].getState():