26 from datetime
import datetime, date
27 from xml.etree.ElementTree
import Element, SubElement, tostring
46 import LeenoSheetUtils
47 import LeenoToolbars
as Toolbars
52 import LeenoDialogs
as DLG
53 import PersistUtils
as PU
55 import LeenoBasicBridge
66 from com.sun.star.beans
import PropertyValue
68 from com.sun.star.sheet.CellFlags
import \
69 VALUE, DATETIME, STRING, ANNOTATION, FORMULA, HARDATTR, OBJECTS, EDITATTR, FORMATTED
71 from com.sun.star.beans.PropertyAttribute
import \
72 MAYBEVOID, REMOVEABLE, MAYBEDEFAULT
82 '''Richiama funzioni definite in Basic'''
85 sm = xCompCont.ServiceManager
86 mspf = sm.createInstance(
"com.sun.star.script.provider.MasterScriptProviderFactory")
87 scriptPro = mspf.createScriptProvider(
"")
88 Xscript = scriptPro.getScript(
89 "vnd.sun.star.script:UltimusFree2." +
91 "?language=Basic&location=application")
92 Result = Xscript.invoke(args,
None,
None)
99 Visualizza il menù di configurazione
102 if not oDoc.getSheets().hasByName(
'S1'):
106 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
107 oDlg_config = dp.createDialog(
108 "vnd.sun.star.script:UltimusFree2.Dlg_config?language=Basic&location=application"
112 oSheets = list(oDoc.getSheets().getElementNames())
114 for nome
in (
'M1',
'S1',
'S2',
'S5',
'Elenco Prezzi',
'COMPUTO'):
117 oSheet = oDoc.getSheets().getByName(nome)
118 if not oSheet.IsVisible:
119 oDlg_config.getControl(
'CheckBox2').State = 0
122 oDlg_config.getControl(
'CheckBox2').State = 1
124 if oDoc.getSheets().getByName(
"copyright_LeenO").IsVisible:
125 oDlg_config.getControl(
'CheckBox2').State = 1
126 if cfg.read(
'Generale',
'pesca_auto') ==
'1':
127 oDlg_config.getControl(
'CheckBox1').State = 1
128 if cfg.read(
'Generale',
'toolbar_contestuali') ==
'1':
129 oDlg_config.getControl(
'CheckBox6').State = 1
131 oSheet = oDoc.getSheets().getByName(
'S5')
133 if not oSheet.getCellRangeByName(
'C9').IsMerged:
134 oDlg_config.getControl(
'CheckBox5').State = 1
136 oDlg_config.getControl(
'CheckBox5').State = 0
140 sString = oDlg_config.getControl(
'TextField1')
141 sString.Text = cfg.read(
'Generale',
'altezza_celle')
146 sString = oDlg_config.getControl(
"ComboBox2")
147 if cfg.read(
'Generale',
'movedirection') ==
'1':
148 sString.Text =
'A DESTRA'
149 elif cfg.read(
'Generale',
'movedirection') ==
'0':
150 sString.Text =
'IN BASSO'
151 oSheet = oDoc.getSheets().getByName(
'S1')
154 oLayout = oDoc.CurrentController.getFrame().LayoutManager
155 if not oLayout.isElementVisible(
'private:resource/toolbar/standardbar'):
156 oDlg_config.getControl(
'CheckBox3').State = 1
158 sString = oDlg_config.getControl(
'TextField14')
159 sString.Text = oSheet.getCellRangeByName(
161 sString = oDlg_config.getControl(
'TextField4')
162 sString.Text = oSheet.getCellRangeByName(
164 if oDoc.NamedRanges.hasByName(
"_Lib_1"):
165 sString.setEnable(
False)
166 sString = oDlg_config.getControl(
'TextField12')
167 sString.Text = oSheet.getCellRangeByName(
169 if oDoc.NamedRanges.hasByName(
"_Lib_1"):
170 sString.setEnable(
False)
172 if cfg.read(
'Generale',
'torna_a_ep') ==
'1':
173 oDlg_config.getControl(
'CheckBox8').State = 1
175 sString = oDlg_config.getControl(
'ComboBox4')
176 sString.Text = cfg.read(
'Generale',
'copie_backup')
177 if int(cfg.read(
'Generale',
'copie_backup')) != 0:
178 sString = oDlg_config.getControl(
'ComboBox5')
179 sString.Text = cfg.read(
'Generale',
'pausa_backup')
187 oDlg_config.execute()
189 if oDlg_config.getControl(
'CheckBox2').State != test:
190 if oDlg_config.getControl(
'CheckBox2').State == 1:
195 if oDlg_config.getControl(
'CheckBox3').State == 1:
196 Toolbars.Switch(
False)
198 Toolbars.Switch(
True)
203 oGSheetSettings = ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.sheet.GlobalSheetSettings", ctx)
204 if oDlg_config.getControl(
'ComboBox2').getText() ==
'IN BASSO':
205 cfg.write(
'Generale',
'movedirection',
'0')
206 oGSheetSettings.MoveDirection = 0
208 cfg.write(
'Generale',
'movedirection',
'1')
209 oGSheetSettings.MoveDirection = 1
210 cfg.write(
'Generale',
'altezza_celle', oDlg_config.getControl(
'TextField1').getText())
212 cfg.write(
'Generale',
'pesca_auto', str(oDlg_config.getControl(
'CheckBox1').State))
213 cfg.write(
'Generale',
'descrizione_in_una_colonna', str(oDlg_config.getControl(
'CheckBox5').State))
214 cfg.write(
'Generale',
'toolbar_contestuali', str(oDlg_config.getControl(
'CheckBox6').State))
216 if oDlg_config.getControl(
'CheckBox5').State == 1:
221 cfg.write(
'Generale',
'torna_a_ep', str(oDlg_config.getControl(
'CheckBox8').State))
225 if oDlg_config.getControl(
'TextField14').getText() !=
'10000':
226 cfg.write(
'Generale',
'vedi_voce_breve', oDlg_config.getControl(
'TextField14').getText())
227 oSheet.getCellRangeByName(
'S1.H334').Value = float(oDlg_config.getControl(
'TextField14').getText())
229 if oDlg_config.getControl(
'TextField4').getText() !=
'10000':
230 cfg.write(
'Contabilita',
'cont_inizio_voci_abbreviate', oDlg_config.getControl(
'TextField4').getText())
231 oSheet.getCellRangeByName(
'S1.H335').Value = float(oDlg_config.getControl(
'TextField4').getText())
233 if oDlg_config.getControl(
'TextField12').getText() !=
'10000':
234 cfg.write(
'Contabilita',
'cont_fine_voci_abbreviate', oDlg_config.getControl(
'TextField12').getText())
235 oSheet.getCellRangeByName(
'S1.H336').Value = float(oDlg_config.getControl(
'TextField12').getText())
238 cfg.write(
'Generale',
'copie_backup', oDlg_config.getControl(
'ComboBox4').getText())
239 cfg.write(
'Generale',
'pausa_backup', oDlg_config.getControl(
'ComboBox5').getText())
246 '''Restituisce il percorso di installazione di LeenO.oxt'''
248 pir = ctx.getValueByName(
249 '/singletons/com.sun.star.deployment.PackageInformationProvider')
250 expath = pir.getPackageLocation(
'org.giuseppe-vizziello.leeno')
257 '''arg { integer } : 1 mostra il dialogo di salvataggio file'''
259 opz = PropertyValue()
260 opz.Name =
'AsTemplate'
262 document = desktop.loadComponentFromURL(
263 LeenO_path() +
'/template/leeno/Computo_LeenO.ots',
"_blank", 0,
269 Prima di procedere è meglio dare un nome al file.
270 Lavorando su un file senza nome potresti avere dei malfunzionamenti.
283 opz = PropertyValue()
284 opz.Name =
'AsTemplate'
286 document = desktop.loadComponentFromURL(
287 LeenO_path() +
'/template/offmisc/UsoBollo.ott',
"_blank", 0,
296 '''Crea un nuovo computo vuoto.'''
304 '''Crea un nuovo documento in formato uso bollo.'''
312 Invia le voci di Elenco Prezzi verso uno degli altri elaborati.
313 Richiede comunque la scelta del DP
317 oSheet = oDoc.CurrentController.ActiveSheet
322 cod = oSheet.getCellByPosition(0, el).String
324 dest = oSheet.getCellRangeByName(
'C2').String
326 if dest ==
'VARIANTE':
328 elif dest ==
'CONTABILITA':
331 elif dest ==
'COMPUTO':
335 Text=
'''Per procedere devi prima scegliere,
336 dalla cella "C2", l'elaborato a cui
337 inviare le voci di prezzo selezionate.
339 Se l'elaborato è già esistente,
340 assicurati di aver scelto anche
341 la posizione di destinazione.''')
344 oSheet = oDoc.getSheets().getByName(dest)
346 if oSheet.Name ==
'CONTABILITA':
357 Invia le voci di computo, elenco prezzi e analisi, con costi elementari,
358 dal documento corrente al Documento Principale.
361 oSheet = oDoc.CurrentController.ActiveSheet
366 fpartenza = uno.fileUrlToSystemPath(oDoc.getURL())
368 if nSheet ==
'Elenco Prezzi':
373 Text=
"Questo file coincide con il Documento Principale (DP).")
377 Text=
"E' necessario impostare il Documento Principale (DP).")
382 def getAnalisi(oSheet):
384 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
385 except AttributeError:
386 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
390 for el
in oRangeAddress:
391 el_y.append((el.StartRow, el.EndRow))
393 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
396 for el
in range(y[0], y[1] + 1):
400 if oSheet.getCellByPosition(1, y).Type.value ==
'FORMULA':
401 analisi.append(oSheet.getCellByPosition(0, y).String)
402 return (analisi, lista)
408 if oSheet.getCellByPosition(0, lrow).CellStyle
in stili_analisi:
409 for el
in reversed(range(0, lrow)):
410 if oSheet.getCellByPosition(0,
411 el).CellStyle ==
'Analisi_Sfondo':
415 if oSheet.getCellByPosition(
416 0, el).CellStyle ==
'An-sfondo-basso Att End':
419 celle = oSheet.getCellRangeByPosition(0, SR, 250, ER)
423 if oSheet.Name ==
'Elenco Prezzi':
424 if oSheet.getCellByPosition(
428 Text=
'La posizione di PARTENZA non è corretta.')
431 analisi = getAnalisi(oSheet)[0]
432 lrow = getAnalisi(oSheet)[1][0]
434 lista = getAnalisi(oSheet)[1]
437 voci = oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges")
439 rangen = oSheet.getCellRangeByPosition(0, y, 100, y).RangeAddress
440 selezione.append(rangen)
441 voci.addRangeAddresses(selezione,
True)
447 oSheet = oDoc.getSheets().getByName(
'Analisi di Prezzo')
449 ranges = oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges")
450 selezione_analisi = list()
454 SR = sStRange.RangeAddress.StartRow
455 ER = sStRange.RangeAddress.EndRow
456 coppia.append((SR, ER))
457 selezione_analisi.append(sStRange.RangeAddress)
460 for y
in range(el[0], el[1]):
461 if oSheet.getCellByPosition(0, y).CellStyle ==
'An-lavoraz-Cod-sx' and \
462 oSheet.getCellByPosition(0, y).Type.value !=
'EMPTY':
463 costi.append(oSheet.getCellByPosition(0, y).String)
466 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
471 rangen = oSheet.getCellRangeByPosition(0, y, 100,
473 selezione.append(rangen)
474 voci.addRangeAddresses(selezione,
True)
475 oDoc.CurrentController.select(voci)
477 oDoc.CurrentController.select(
479 "com.sun.star.sheet.SheetCellRanges"))
482 dccSheet = ddcDoc.CurrentController.ActiveSheet
485 if nome
in (
'Elenco Prezzi'):
486 ddcDoc.CurrentController.setActiveSheet(dccSheet)
490 if nome
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
491 dccSheet = ddcDoc.getSheets().getByName(
'Elenco Prezzi')
492 dccSheet.IsVisible =
True
493 ddcDoc.CurrentController.setActiveSheet(dccSheet)
500 dccSheet = ddcDoc.getSheets().getByName(nome)
507 if dccSheet.getCellByPosition(0, lrow).CellStyle
in (
'comp Int_colonna'):
510 _gotoCella(1, lrow + 2)
513 if dccSheet.getCellByPosition(
514 0, lrow).CellStyle
in (stili_cat + stili_computo + (
'comp Int_colonna', )):
522 ddcDoc.CurrentController.setFirstVisibleColumn(0)
527 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
530 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
531 except AttributeError:
532 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
534 SR = oRangeAddress.StartRow
536 except AttributeError:
538 Text=
'''La selezione delle voci dal COMPUTO
539 di partenza deve essere contigua.''')
544 ER = oRangeAddress.EndRow
546 oDoc.CurrentController.select(oSheet.getCellRangeByPosition(0, SR, 100, ER))
548 oSheet.getCellRangeByPosition(45, SR, 45, ER).CellBackColor = 15757935
551 for el
in range(SR, ER + 1):
552 if oSheet.getCellByPosition(0, el).CellStyle
in (
'Comp Start Attributo'):
555 if nSheetDCC
in (
'Analisi di Prezzo'):
558 Text=
'Il foglio di destinazione non è corretto.')
559 oDoc.CurrentController.select(
561 "com.sun.star.sheet.SheetCellRanges"))
563 if nSheetDCC
in (
'COMPUTO',
'VARIANTE'):
568 dccSheet = ddcDoc.getSheets().getByName(nSheet)
570 if dccSheet.getCellByPosition(0, lrow).CellStyle
in (
'comp Int_colonna', ):
572 elif dccSheet.getCellByPosition(0, lrow).CellStyle
not in stili_computo + stili_cat:
575 Text=
'La posizione di destinazione non è corretta.')
577 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
584 last = lrow + ER - SR + 1
592 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
594 ranges = oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges")
597 rangen = oSheet.getCellRangeByPosition(0, y, 100,
599 selezione.append(rangen)
601 ranges.addRangeAddresses(selezione,
True)
602 oDoc.CurrentController.select(ranges)
607 dccSheet = ddcDoc.getSheets().getByName(
'Elenco Prezzi')
612 if nSheetDCC
in (
'Elenco Prezzi'):
615 Text=
"Non è possibile inviare voci da un COMPUTO all'Elenco Prezzi.")
617 oDoc.CurrentController.select(
619 "com.sun.star.sheet.SheetCellRanges"))
629 ranges = oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges")
630 ranges.addRangeAddresses(selezione_analisi,
True)
631 oDoc.CurrentController.select(ranges)
644 oDoc.CurrentController.select(
645 oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
651 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
654 if nSheetDCC
in (
'COMPUTO',
'VARIANTE'):
656 _gotoCella(2, lrow + 1)
657 oSheet = oDoc.getSheets().getByName(nSheetDCC)
666 lrow { int } : id della riga
667 cod { string } : codice del prezzo
668 Se cod è assente, restituisce il codice della voce,
669 altrimenti glielo assegna.
672 oSheet = oDoc.CurrentController.ActiveSheet
674 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
676 elif oSheet.Name
in (
'Analisi di Prezzo'):
679 return oSheet.getCellByPosition(1, sopra + 1).String
681 oSheet.getCellByPosition(1, sopra + 1).String = cod
701 sUrl { string } : nome del file
702 porta il focus su di un determinato documento
704 sUrl = uno.systemPathToFileUrl(sUrl)
705 if sys.platform ==
'linux' or sys.platform ==
'darwin':
707 sUrl,
"_default", 0, list())
708 target.getCurrentController().Frame.ContainerWindow.toFront()
709 target.getCurrentController().Frame.activate()
710 elif sys.platform ==
'win32':
712 oFocus = uno.createUnoStruct(
'com.sun.star.awt.FocusEvent')
713 target = desktop.loadComponentFromURL(sUrl,
"_default", 0, list())
714 target.getCurrentController().getFrame().focusGained(oFocus)
723 sUrl { string } : nome del file
724 porta il focus su di un determinato documento
727 fpartenza = uno.fileUrlToSystemPath(oDoc.getURL())
732 return sUltimus_sheet
740 restituisce la data di oggi
742 return '/'.join(reversed(str(datetime.now()).split(
' ')[0].split(
'-')))
750 fa una copia della directory del codice nel repository locale ed apre una shell per la commit
755 if oDoc.getSheets().getByName(
'S1').getCellByPosition(
756 7, 338).String ==
'':
759 src_oxt = oDoc.getSheets().getByName(
'S1').getCellByPosition(
765 if sys.platform ==
'linux' or sys.platform ==
'darwin':
766 dest =
'/media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt'
767 if not os.path.exists(dest):
770 "HOME") +
'/' + src_oxt +
'/leeno/src/Ultimus.oxt/'
772 os.makedirs(os.getenv(
"HOME") +
'/' + src_oxt +
'/leeno/bin/')
773 os.makedirs(os.getenv(
"HOME") +
'/' + src_oxt +
'/_SRC/OXT')
774 except FileExistsError:
777 comandi =
'cd ' + dest +
' && mate-terminal && gitk &'
779 comandi =
'cd /media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt && mate-terminal && gitk &'
781 subprocess.Popen(comandi, shell=
True, stdout=subprocess.PIPE)
782 elif sys.platform ==
'win32':
783 if not os.path.exists(
'w:/_dwg/ULTIMUSFREE/_SRC/leeno/src/'):
786 os.getenv(
"HOMEPATH") +
'\\' + src_oxt +
787 '\\leeno\\src\\Ultimus.oxt\\')
788 except FileExistsError:
790 dest = os.getenv(
"HOMEDRIVE") + os.getenv(
791 "HOMEPATH") +
'\\' + src_oxt +
'\\leeno\\src\\Ultimus.oxt\\'
793 dest =
'w:\\_dwg\\ULTIMUSFREE\\_SRC\\leeno\\src\\Ultimus.oxt'
795 'w: && cd w:/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt && "C:/Program Files/Git/git-bash.exe"',
797 stdout=subprocess.PIPE)
806 Avvia la modifica di pyleeno.py con geany
812 '''Avvia la modifica di pyleeno.py con geany o eric6'''
815 Toolbars.On(
"private:resource/toolbar/addon_ULTIMUS_3.OfficeToolBar_DEV", 1)
817 if oDoc.getSheets().getByName(
'S1').getCellByPosition(
818 7, 338).String ==
'':
821 src_oxt = oDoc.getSheets().getByName(
'S1').getCellByPosition(
826 if sys.platform ==
'linux' or sys.platform ==
'darwin':
828 dest =
'/media/giuserpe/PRIVATO/LeenO/_SRC/leeno/src/Ultimus.oxt/python/pythonpath'
829 if not os.path.exists(dest):
832 "HOME") +
'/' + src_oxt +
'/leeno/src/Ultimus.oxt/'
834 os.makedirs(os.getenv(
"HOME") +
'/' + src_oxt +
'/leeno/bin/')
835 os.makedirs(os.getenv(
"HOME") +
'/' + src_oxt +
'/_SRC/OXT')
836 except FileExistsError:
839 subprocess.Popen(
'caja '+
843 stdout=subprocess.PIPE)
844 subprocess.Popen(
'geany ' + dest +
'/pyleeno.py',
847 stdout=subprocess.PIPE)
848 elif sys.platform ==
'win32':
849 if not os.path.exists(
'w:/_dwg/ULTIMUSFREE/_SRC/leeno/src/'):
852 os.getenv(
"HOMEPATH") +
'\\' + src_oxt +
853 '\\leeno\\src\\Ultimus.oxt\\')
854 except FileExistsError:
856 dest = os.getenv(
"HOMEDRIVE") + os.getenv(
857 "HOMEPATH") +
'\\' + src_oxt +
'\\leeno\\src\\Ultimus.oxt\\'
859 dest =
'w:\\_dwg\\ULTIMUSFREE\\_SRC\\leeno\\src\\Ultimus.oxt'
865 subprocess.Popen(
'"C:/Program Files/Geany/bin/geany.exe" ' +
867 '/python/pythonpath/pyleeno.py',
869 stdout=subprocess.PIPE)
895 n { int } : livello della categoria
902 oSheet = oDoc.CurrentController.ActiveSheet
909 if oSheet.getCellByPosition(0,row).CellStyle
in stili_computo + stili_contab:
911 elif oSheet.getCellByPosition(0, row).CellStyle
in noVoce:
917 sTesto =
'Inserisci il titolo per la Supercategoria'
919 sTesto =
'Inserisci il titolo per la Categoria'
921 sTesto =
'Inserisci il titolo per la Sottocategoria'
923 if sString
is None or sString ==
'':
935 oDoc.enableAutomaticCalculation(
True)
936 oDoc.CurrentController.setFirstVisibleColumn(0)
937 oDoc.CurrentController.setFirstVisibleRow(lrow - 5)
977 oSheet = oDoc.CurrentController.ActiveSheet
984 oDoc.enableAutomaticCalculation(
False)
989 oDoc.enableAutomaticCalculation(
True)
993 '''ricalcola i subtotali di categorie e subcategorie'''
995 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
998 if oSheet.getCellByPosition(0, n).CellStyle ==
'Livello-0-scritta':
1000 if oSheet.getCellByPosition(0, n).CellStyle ==
'Livello-1-scritta':
1002 if oSheet.getCellByPosition(0, n).CellStyle ==
'livello2 valuta':
1007 oSheet.getCellByPosition(
1008 17, 1).Formula =
'=SUBTOTAL(9;R4:R' + str(lrow + 1) +
')'
1009 oSheet.getCellByPosition(
1010 17, lrow).Formula =
'=SUBTOTAL(9;R4:R' + str(lrow + 1) +
')'
1011 oSheet.getCellByPosition(
1012 18, 1).Formula =
'=SUBTOTAL(9;S4:S' + str(lrow + 1) +
')'
1013 oSheet.getCellByPosition(
1014 18, lrow).Formula =
'=SUBTOTAL(9;S4:S' + str(lrow + 1) +
')'
1016 oSheet.getCellByPosition(
1017 28, lrow).Formula =
'=SUBTOTAL(9;AC4:AC' + str(lrow + 1) +
')'
1018 oSheet.getCellByPosition(
1019 28, 1).Formula =
'=SUBTOTAL(9;AC4:AC' + str(lrow + 1) +
')'
1021 oSheet.getCellByPosition(
1022 30, lrow).Formula =
'=SUBTOTAL(9;AE4:AE' + str(lrow + 1) +
')'
1023 oSheet.getCellByPosition(
1024 30, 1).Formula =
'=SUBTOTAL(9;AE4:AE' + str(lrow + 1) +
')'
1025 oSheet.getCellByPosition(
1026 36, lrow).Formula =
'=SUBTOTAL(9;AK4:AK' + str(lrow + 1) +
')'
1027 oSheet.getCellByPosition(
1028 36, 1).Formula =
'=SUBTOTAL(9;AK4:AK' + str(lrow + 1) +
')'
1036 lrow { double } : id della riga di inserimento
1037 inserisce i dati nella riga di SuperCategoria
1040 oSheet = oDoc.CurrentController.ActiveSheet
1041 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
1046 for n
in range(lrow + 1, lrowE):
1047 if oSheet.getCellByPosition(
1049 n).CellStyle
in (
'Livello-0-scritta mini val',
'Comp TOTALI'):
1054 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
1055 oSheet.getCellByPosition(
1057 ).Formula =
'=SUBTOTAL(9;S' + str(lrow + 1) +
':S' + str(nextCap) +
')'
1058 oSheet.getCellByPosition(
1059 24, lrow).Formula =
'=S' + str(lrow + 1) +
'/S' + str(lrowE)
1060 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1061 lrow + 1) +
':AC' + str(nextCap) +
')'
1062 oSheet.getCellByPosition(
1063 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/S' + str(lrow + 1)
1064 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1065 lrow + 1) +
':AE' + str(nextCap) +
')'
1066 oSheet.getCellByPosition(18,
1067 lrow).CellStyle =
'Livello-0-scritta mini val'
1068 oSheet.getCellByPosition(24,
1069 lrow).CellStyle =
'Livello-0-scritta mini %'
1070 oSheet.getCellByPosition(29,
1071 lrow).CellStyle =
'Livello-0-scritta mini %'
1072 oSheet.getCellByPosition(30,
1073 lrow).CellStyle =
'Livello-0-scritta mini val'
1074 if oSheet.Name
in (
'CONTABILITA'):
1075 oSheet.getCellByPosition(15, lrow).Formula =
'=SUBTOTAL(9;P' + str(
1076 lrow + 1) +
':P' + str(nextCap) +
')'
1077 oSheet.getCellByPosition(
1078 16, lrow).Formula =
'=P' + str(lrow + 1) +
'/P' + str(
1080 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1081 lrow + 1) +
':AC' + str(nextCap) +
')'
1082 oSheet.getCellByPosition(
1083 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/P' + str(lrow + 1)
1084 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1085 lrow + 1) +
':AE' + str(nextCap) +
')'
1086 oSheet.getCellByPosition(15,
1087 lrow).CellStyle =
'Livello-0-scritta mini val'
1088 oSheet.getCellByPosition(16,
1089 lrow).CellStyle =
'Livello-0-scritta mini %'
1090 oSheet.getCellByPosition(29,
1091 lrow).CellStyle =
'Livello-0-scritta mini %'
1092 oSheet.getCellByPosition(28,
1093 lrow).CellStyle =
'Livello-0-scritta mini val'
1094 oSheet.getCellByPosition(30,
1095 lrow).CellStyle =
'Livello-0-scritta mini val'
1104 lrow { double } : id della riga di inserimento
1105 inserisce i dati nella riga di subcategoria
1108 oSheet = oDoc.CurrentController.ActiveSheet
1109 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
1114 for n
in range(lrow + 1, lrowE):
1115 if oSheet.getCellByPosition(
1117 n).CellStyle
in (
'livello2 scritta mini',
1118 'Livello-0-scritta mini val',
1119 'Livello-1-scritta mini val',
'Comp TOTALI'):
1122 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
1123 oSheet.getCellByPosition(
1125 ).Formula =
'=SUBTOTAL(9;S' + str(lrow + 1) +
':S' + str(nextCap) +
')'
1126 oSheet.getCellByPosition(
1127 24, lrow).Formula =
'=S' + str(lrow + 1) +
'/S' + str(lrowE)
1128 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1129 lrow + 1) +
':AC' + str(nextCap) +
')'
1130 oSheet.getCellByPosition(
1131 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/S' + str(lrow + 1)
1132 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1133 lrow + 1) +
':AE' + str(nextCap) +
')'
1134 oSheet.getCellByPosition(18, lrow).CellStyle =
'livello2 scritta mini'
1135 oSheet.getCellByPosition(24, lrow).CellStyle =
'livello2 valuta mini %'
1136 oSheet.getCellByPosition(28, lrow).CellStyle =
'livello2 scritta mini'
1137 oSheet.getCellByPosition(29, lrow).CellStyle =
'livello2 valuta mini %'
1138 oSheet.getCellByPosition(30, lrow).CellStyle =
'livello2 valuta mini'
1139 if oSheet.Name
in (
'CONTABILITA'):
1140 oSheet.getCellByPosition(15, lrow).Formula =
'=SUBTOTAL(9;P' + str(
1141 lrow + 1) +
':P' + str(nextCap) +
')'
1142 oSheet.getCellByPosition(
1143 16, lrow).Formula =
'=P' + str(lrow + 1) +
'/P' + str(
1145 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1146 lrow + 1) +
':AC' + str(nextCap) +
')'
1147 oSheet.getCellByPosition(
1148 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/P' + str(lrow + 1)
1149 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1150 lrow + 1) +
':AE' + str(nextCap) +
')'
1151 oSheet.getCellByPosition(15, lrow).CellStyle =
'livello2 scritta mini'
1152 oSheet.getCellByPosition(16, lrow).CellStyle =
'livello2 valuta mini %'
1153 oSheet.getCellByPosition(29, lrow).CellStyle =
'livello2 valuta mini %'
1154 oSheet.getCellByPosition(28, lrow).CellStyle =
'livello2 scritta mini'
1155 oSheet.getCellByPosition(30, lrow).CellStyle =
'livello2 scritta mini'
1163 lrow { double } : id della riga di inserimento
1164 inserisce i dati nella riga di categoria
1167 oSheet = oDoc.CurrentController.ActiveSheet
1168 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
1173 for n
in range(lrow + 1, lrowE):
1174 if oSheet.getCellByPosition(
1176 n).CellStyle
in (
'Livello-1-scritta mini val',
1177 'Livello-0-scritta mini val',
'Comp TOTALI'):
1181 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
1182 oSheet.getCellByPosition(18, lrow).Formula =
'=SUBTOTAL(9;S' + str(
1183 lrow + 1) +
':S' + str(nextCap) +
')'
1184 oSheet.getCellByPosition(
1185 24, lrow).Formula =
'=S' + str(lrow + 1) +
'/S' + str(lrowE)
1186 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1187 lrow + 1) +
':AC' + str(nextCap) +
')'
1188 oSheet.getCellByPosition(
1189 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/S' + str(lrow + 1)
1190 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1191 lrow + 1) +
':AE' + str(nextCap) +
')'
1192 oSheet.getCellByPosition(18,
1193 lrow).CellStyle =
'Livello-1-scritta mini val'
1194 oSheet.getCellByPosition(24,
1195 lrow).CellStyle =
'Livello-1-scritta mini %'
1196 oSheet.getCellByPosition(29,
1197 lrow).CellStyle =
'Livello-1-scritta mini %'
1198 oSheet.getCellByPosition(30,
1199 lrow).CellStyle =
'Livello-1-scritta mini val'
1200 if oSheet.Name
in (
'CONTABILITA'):
1201 oSheet.getCellByPosition(15, lrow).Formula =
'=SUBTOTAL(9;P' + str(
1202 lrow + 1) +
':P' + str(nextCap) +
')'
1203 oSheet.getCellByPosition(
1204 16, lrow).Formula =
'=P' + str(lrow + 1) +
'/P' + str(
1206 oSheet.getCellByPosition(28, lrow).Formula =
'=SUBTOTAL(9;AC' + str(
1207 lrow + 1) +
':AC' + str(nextCap) +
')'
1208 oSheet.getCellByPosition(
1209 29, lrow).Formula =
'=AE' + str(lrow + 1) +
'/P' + str(lrow + 1)
1210 oSheet.getCellByPosition(30, lrow).Formula =
'=SUBTOTAL(9;AE' + str(
1211 lrow + 1) +
':AE' + str(nextCap) +
')'
1212 oSheet.getCellByPosition(15,
1213 lrow).CellStyle =
'Livello-1-scritta mini val'
1214 oSheet.getCellByPosition(16,
1215 lrow).CellStyle =
'Livello-1-scritta mini %'
1216 oSheet.getCellByPosition(29,
1217 lrow).CellStyle =
'Livello-1-scritta mini %'
1218 oSheet.getCellByPosition(28,
1219 lrow).CellStyle =
'Livello-1-scritta mini val'
1220 oSheet.getCellByPosition(30,
1221 lrow).CellStyle =
'Livello-1-scritta mini val'
1229 lrow { double } : id della riga di inserimento
1230 sincronizza categoria e sottocategorie
1232 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
1240 for lrow
in range(0, lastRow):
1242 if oSheet.getCellByPosition(2, lrow).CellStyle ==
'livello2_':
1243 if oSheet.getCellByPosition(2, lrow).String
not in listasbcat:
1244 listasbcat.append((oSheet.getCellByPosition(2, lrow).String))
1246 oSheet.getCellByPosition(31, lrow).Value = idspcat
1250 oSheet.getCellByPosition(32, lrow).Value = idcat
1253 idsbcat = listasbcat.index(oSheet.getCellByPosition(2, lrow).String) + 1
1254 oSheet.getCellByPosition(33, lrow).Value = idsbcat
1255 oSheet.getCellByPosition(
1256 1, lrow).Formula =
'=AF' + str(lrow + 1) +
'&"."&AG' + str(
1257 lrow + 1) +
'&"."&AH' + str(lrow + 1)
1260 elif oSheet.getCellByPosition(2, lrow).CellStyle ==
'Livello-1-scritta mini':
1261 if oSheet.getCellByPosition(2, lrow).String
not in listacat:
1262 listacat.append((oSheet.getCellByPosition(2, lrow).String))
1267 oSheet.getCellByPosition(31, lrow).Value = idspcat
1270 idcat = listacat.index(oSheet.getCellByPosition(2,
1272 oSheet.getCellByPosition(32, lrow).Value = idcat
1273 oSheet.getCellByPosition(
1274 1, lrow).Formula =
'=AF' + str(lrow +
1275 1) +
'&"."&AG' + str(lrow + 1)
1278 elif oSheet.getCellByPosition(
1280 lrow).CellStyle ==
'Livello-0-scritta mini':
1281 if oSheet.getCellByPosition(2, lrow).String
not in listaspcat:
1282 listaspcat.append((oSheet.getCellByPosition(2, lrow).String))
1284 idcat = idsbcat =
None
1286 idspcat = listaspcat.index(
1287 oSheet.getCellByPosition(2, lrow).String) + 1
1288 oSheet.getCellByPosition(31, lrow).Value = idspcat
1289 oSheet.getCellByPosition(1, lrow).Formula =
'=AF' + str(lrow + 1)
1292 elif oSheet.getCellByPosition(
1293 33, lrow).CellStyle ==
'compTagRiservato':
1295 oSheet.getCellByPosition(33, lrow).Value = idsbcat
1297 oSheet.getCellByPosition(33, lrow).Value = 0
1299 oSheet.getCellByPosition(32, lrow).Value = idcat
1301 oSheet.getCellByPosition(32, lrow).Value = 0
1303 oSheet.getCellByPosition(31, lrow).Value = idspcat
1305 oSheet.getCellByPosition(31, lrow).Value = 0
1313 '''Mostra tutti i foglio fogli'''
1315 lista_fogli = oDoc.Sheets.ElementNames
1316 for el
in lista_fogli:
1317 oDoc.getSheets().getByName(el).IsVisible =
True
1325 Mostra tutti i foglio fogli
1331 '''Mostra tutti i foglio fogli'''
1333 lista_fogli = oDoc.Sheets.ElementNames
1334 for el
in lista_fogli:
1335 oDoc.getSheets().getByName(el).IsVisible =
True
1336 for nome
in (
'cP_',
'cT_',
'M1',
'S1',
'S2',
'S5',
'QUADRO ECONOMICO',
1337 '_LeenO',
'Scorciatoie'):
1339 oDoc.getSheets().getByName(el).IsVisible =
False
1346 '''Mostra tutti i foglio fogli'''
1348 lista_fogli = oDoc.Sheets.ElementNames
1350 for el
in lista_fogli:
1351 oDoc.getSheets().getByName(el).IsVisible =
True
1352 for nome
in (
'cP_',
'M1',
'S1',
'S2',
'S5',
'QUADRO ECONOMICO',
1353 '_LeenO',
'Scorciatoie'):
1355 oDoc.getSheets().getByName(el).IsVisible =
False
1362 '''Mostra tutti i foglio fogli'''
1364 lista_fogli = oDoc.Sheets.ElementNames
1366 for el
in lista_fogli:
1367 oDoc.getSheets().getByName(el).IsVisible =
True
1368 for nome
in (
'cT_',
'M1',
'S1',
'S2',
'S5',
'QUADRO ECONOMICO',
1369 '_LeenO',
'Scorciatoie'):
1371 oDoc.getSheets().getByName(el).IsVisible =
False
1379 nSheet { string } : nome sheet
1380 tag { string } : stringa di tag
1381 duplica copia sheet corrente di fianco a destra
1385 oSheet = oDoc.getSheets().getByName(nSheet)
1386 idSheet = oSheet.RangeAddress.Sheet + 1
1387 if oDoc.getSheets().hasByName(nSheet +
'_' + tag):
1388 DLG.MsgBox(
'La tabella di nome ' + nSheet +
'_' + tag +
'è già presente.',
'ATTENZIONE! Impossibile procedere.')
1391 oDoc.Sheets.copyByName(nSheet, nSheet +
'_' + tag, idSheet)
1392 oSheet = oDoc.getSheets().getByName(nSheet +
'_' + tag)
1393 oDoc.CurrentController.setActiveSheet(oSheet)
1402 nSheet { string } : nome Sheet
1403 ncol { integer } : colonna di tag
1404 sString { string } : stringa di tag
1405 crea una nuova sheet contenente le sole voci filtrate
1409 oSheet = oDoc.CurrentController.ActiveSheet
1413 sopra = sStRange.RangeAddress.StartRow
1414 sotto = sStRange.RangeAddress.EndRow
1419 if sString != oSheet.getCellByPosition(nCol, test).String:
1420 oSheet.getRows().removeByIndex(sopra, sotto - sopra + 1)
1425 if(oSheet.getCellByPosition(18, lrow).CellStyle ==
'Livello-1-scritta mini val' and
1426 oSheet.getCellByPosition(18, lrow).Value == 0
or
1427 oSheet.getCellByPosition(18, lrow).CellStyle ==
'livello2 scritta mini' and
1428 oSheet.getCellByPosition(18, lrow).Value == 0):
1430 oSheet.getRows().removeByIndex(lrow, 1)
1434 oSheet.getCellRangeByPosition(0, 0, 42, 0).clearContents(
1436 oDoc.CurrentController.select(oSheet.getCellByPosition(0, 3))
1437 oDoc.CurrentController.select(
1438 oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
1562 nSheet { string } : nome Sheet
1563 attiva e seleziona una sheet
1566 oSheet = oDoc.Sheets.getByName(nSheet)
1569 oSheet.IsVisible =
True
1570 oDoc.CurrentController.setActiveSheet(oSheet)
1578 def _primaCella(IDcol=0, IDrow=0):
1580 IDcol { integer } : id colonna
1581 IDrow { integer } : id riga
1582 settaggio prima cella visibile(IDcol, IDrow)
1586 oDoc.CurrentController.setFirstVisibleColumn(IDcol)
1587 oDoc.CurrentController.setFirstVisibleRow(IDrow)
1596 ncol { integer } : id colonna
1597 ordina i dati secondo la colonna con id ncol
1603 oFrame = desktop.getCurrentFrame()
1604 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1605 'com.sun.star.frame.DispatchHelper', ctx)
1607 oProp0 = PropertyValue()
1608 oProp0.Name =
'ByRows'
1610 oProp1 = PropertyValue()
1611 oProp1.Name =
'HasHeader'
1612 oProp1.Value =
False
1613 oProp2 = PropertyValue()
1614 oProp2.Name =
'CaseSensitive'
1615 oProp2.Value =
False
1616 oProp3 = PropertyValue()
1617 oProp3.Name =
'NaturalSort'
1618 oProp3.Value =
False
1619 oProp4 = PropertyValue()
1620 oProp4.Name =
'IncludeAttribs'
1622 oProp5 = PropertyValue()
1623 oProp5.Name =
'UserDefIndex'
1625 oProp6 = PropertyValue()
1626 oProp6.Name =
'Col1'
1628 oProp7 = PropertyValue()
1629 oProp7.Name =
'Ascending1'
1631 oProp.append(oProp0)
1632 oProp.append(oProp1)
1633 oProp.append(oProp2)
1634 oProp.append(oProp3)
1635 oProp.append(oProp4)
1636 oProp.append(oProp5)
1637 oProp.append(oProp6)
1638 oProp.append(oProp7)
1639 properties = tuple(oProp)
1640 dispatchHelper.executeDispatch(oFrame,
'.uno:DataSort',
'', 0, properties)
1647 Sprotegge e riordina tutti fogli del documento.
1654 Sprotegge e riordina tutti fogli del documento.
1657 oSheets = oDoc.Sheets.ElementNames
1658 for nome
in oSheets:
1659 oSheet = oDoc.getSheets().getByName(nome)
1660 oSheet.unprotect(
'')
1662 oDoc.Sheets.moveByName(
"Elenco Prezzi", 0)
1663 if oDoc.Sheets.hasByName(
"Analisi di Prezzo"):
1664 oDoc.Sheets.moveByName(
"Analisi di Prezzo", 1)
1665 oDoc.Sheets.moveByName(
"COMPUTO", 2)
1666 if oDoc.Sheets.hasByName(
"VARIANTE"):
1667 oDoc.Sheets.moveByName(
"VARIANTE", 3)
1668 if oDoc.Sheets.hasByName(
"CONTABILITA"):
1669 oDoc.Sheets.moveByName(
"CONTABILITA", 4)
1670 if oDoc.Sheets.hasByName(
"M1"):
1671 oDoc.Sheets.moveByName(
"M1", 5)
1672 oDoc.Sheets.moveByName(
"S1", 6)
1673 oDoc.Sheets.moveByName(
"S2", 7)
1675 if oDoc.Sheets.hasByName(
"S5"):
1676 oDoc.Sheets.moveByName(
"S5", 10)
1677 if oDoc.Sheets.hasByName(
"copyright_LeenO"):
1678 oDoc.Sheets.moveByName(
"copyright_LeenO", oDoc.Sheets.Count)
1686 colore { integer } : id colore
1687 attribuisce al foglio corrente un colore a scelta
1690 oSheet = oDoc.CurrentController.ActiveSheet
1694 oFrame = desktop.getCurrentFrame()
1695 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1696 'com.sun.star.frame.DispatchHelper', ctx)
1697 oProp = PropertyValue()
1698 properties = (oProp, )
1699 dispatchHelper.executeDispatch(oFrame,
'.uno:PrintPreview',
'', arg, properties)
1707 colore { integer } : id colore
1708 attribuisce al foglio corrente un colore a scelta
1714 oFrame = desktop.getCurrentFrame()
1715 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1716 'com.sun.star.frame.DispatchHelper', ctx)
1717 oProp = PropertyValue()
1718 oProp.Name =
'TabBgColor'
1719 oProp.Value = colore
1720 properties = (oProp, )
1721 dispatchHelper.executeDispatch(oFrame,
'.uno:SetTabBgColor',
'', 0,
1730 Forza la formattazione della cella
1736 oFrame = desktop.getCurrentFrame()
1737 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1738 'com.sun.star.frame.DispatchHelper', ctx)
1739 oProp = PropertyValue()
1742 properties = (oProp, )
1743 dispatchHelper.executeDispatch(oFrame,
'.uno:' + stile,
'', 0, properties)
1751 x { boolean } : True = ON, False = OFF
1753 Mastra/nasconde tutte le tabelle ad esclusione di COMPUTO ed Elenco Prezzi
1756 oSheets = list(oDoc.getSheets().getElementNames())
1758 for nome
in (
'Elenco Prezzi',
'COMPUTO'):
1759 oSheets.remove(nome)
1762 for nome
in oSheets:
1763 oSheet = oDoc.getSheets().getByName(nome)
1764 oSheet.IsVisible = x
1765 for nome
in (
'COMPUTO',
'VARIANTE',
'Elenco Prezzi',
'CONTABILITA',
1766 'Analisi di Prezzo'):
1768 oSheet = oDoc.getSheets().getByName(nome)
1769 oSheet.IsVisible =
True
1783 nomefile { string } : nome del file di destinazione
1784 Se presente l'argomento nomefile, salva il file corrente in nomefile.
1790 oFrame = desktop.getCurrentFrame()
1791 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.DispatchHelper', ctx)
1794 if nomefile
is not None:
1795 nomefile = uno.systemPathToFileUrl(nomefile)
1796 oProp0 = PropertyValue()
1798 oProp0.Value = nomefile
1799 oProp.append(oProp0)
1801 oProp1 = PropertyValue()
1802 oProp1.Name =
"FilterName"
1803 oProp1.Value =
"calc8"
1804 oProp.append(oProp1)
1806 properties = tuple(oProp)
1808 dispatchHelper.executeDispatch(oFrame,
".uno:SaveAs",
"", 0, properties)
1814 def _gotoCella(IDcol=0, IDrow=0):
1816 IDcol { integer } : id colonna
1817 IDrow { integer } : id riga
1819 muove il cursore nelle cella(IDcol, IDrow)
1822 oSheet = oDoc.CurrentController.ActiveSheet
1824 oDoc.CurrentController.select(oSheet.getCellByPosition(IDcol, IDrow))
1825 oDoc.CurrentController.select(
1826 oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
1835 Legge il numero di versione di LibreOffice.
1840 "com.sun.star.configuration.ConfigurationProvider")
1841 arg = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
1842 arg.Name =
"nodepath"
1843 arg.Value =
'/org.openoffice.Setup/Product'
1844 return aConfigProvider.createInstanceWithArguments(
1845 "com.sun.star.configuration.ConfigurationAccess",
1846 (arg, )).ooSetupVersionAboutBox
1854 oSheet = oDoc.CurrentController.ActiveSheet
1859 Cambia il numero di caratteri visualizzati per la descrizione voce in COMPUTO,
1860 CONTABILITA E VARIANTE.
1864 oSheet = oDoc.CurrentController.ActiveSheet
1869 if not oDoc.getSheets().hasByName(
'S1'):
1871 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
1872 oSheet = oDoc.getSheets().getByName(
'S1')
1873 if oSheet.getCellRangeByName(
'S1.H337').Value < 10000:
1874 cfg.write(
'Computo',
'inizio_voci_abbreviate', oSheet.getCellRangeByName(
'S1.H337').String)
1875 oSheet.getCellRangeByName(
'S1.H337').Value = 10000
1877 oSheet.getCellRangeByName(
'S1.H337').Value = int(
1878 cfg.read(
'Computo',
'inizio_voci_abbreviate'))
1879 if oSheet.getCellRangeByName(
'S1.H338').Value < 10000:
1880 cfg.write(
'Computo',
'fine_voci_abbreviate', oSheet.getCellRangeByName(
'S1.H338').String)
1881 oSheet.getCellRangeByName(
'S1.H338').Value = 10000
1883 oSheet.getCellRangeByName(
'S1.H338').Value = int(cfg.read(
'Computo',
'fine_voci_abbreviate'))
1885 elif oSheet.Name ==
'CONTABILITA':
1886 oSheet = oDoc.getSheets().getByName(
'S1')
1887 if oDoc.NamedRanges.hasByName(
"_Lib_1"):
1889 Text=
'''Risulta già registrato un SAL, quindi
1890 NON E' POSSIBILE PROCEDERE.''')
1896 if oSheet.getCellRangeByName(
'S1.H335').Value < 10000:
1897 cfg.write(
'Contabilita',
'cont_inizio_voci_abbreviate', oSheet.getCellRangeByName(
'S1.H335').String)
1898 oSheet.getCellRangeByName(
'S1.H335').Value = 10000
1900 oSheet.getCellRangeByName(
'S1.H335').Value = int(cfg.read(
'Contabilita',
'cont_inizio_voci_abbreviate'))
1901 if oSheet.getCellRangeByName(
'S1.H336').Value < 10000:
1902 cfg.write(
'Contabilita',
'cont_fine_voci_abbreviate', oSheet.getCellRangeByName(
'S1.H336').String)
1903 oSheet.getCellRangeByName(
'S1.H336').Value = 10000
1905 oSheet.getCellRangeByName(
'S1.H336').Value = int(cfg.read(
'Contabilita',
'cont_fine_voci_abbreviate'))
1914 Aggiunge suffisso al Codice Articolo
1918 testo, t=
'Inserisci il suffisso per il Codice Articolo (es: "BAS22/1_").')
1919 if suffisso
in (
None,
'',
' '):
1922 oSheet = oDoc.CurrentController.ActiveSheet
1926 progress =
Dialogs.Progress(Title=
'Operazione in corso...', Text=
"Progressione")
1928 progress.setLimits(n, lrow)
1930 progress.setValue(0)
1931 for y
in range(0, lrow):
1932 if oSheet.getCellByPosition(0, y).CellStyle ==
"EP-aS" and \
1933 oSheet.getCellByPosition(0, y).String !=
"000":
1934 oSheet.getCellByPosition(0, y).String = suffisso + oSheet.getCellByPosition(0, y).String
1935 progress.setValue(y)
1944 Cancella le voci di prezzo non utilizzate.
1950 Text=
'''Questo comando ripulisce l'Elenco Prezzi
1951 dalle voci non utilizzate in nessuno degli altri elaborati.
1953 LA PROCEDURA POTREBBE RICHIEDERE DEL TEMPO.
1955 Vuoi procedere comunque?''') == 0:
1958 oDoc.enableAutomaticCalculation(
False)
1959 oSheet = oDoc.CurrentController.ActiveSheet
1961 oRange = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
1962 SR = oRange.StartRow + 1
1963 ER = oRange.EndRow + 1
1964 lista_prezzi = list()
1965 for n
in range(SR, ER):
1966 lista_prezzi.append(oSheet.getCellByPosition(0, n).String)
1969 progress =
Dialogs.Progress(Title=
'Ricerca delle voci da eliminare in corso...', Text=
"Lettura dati")
1971 progress.setLimits(n, len(lista_prezzi))
1973 progress.setValue(1)
1974 for tab
in (
'COMPUTO',
'Analisi di Prezzo',
'VARIANTE',
'CONTABILITA'):
1976 oSheet = oDoc.getSheets().getByName(tab)
1977 if tab ==
'Analisi di Prezzo':
1981 for el
in lista_prezzi:
1983 progress.setValue(n)
1988 progress.setLimits(0, 5)
1989 progress.setValue(2)
1990 da_cancellare = set(lista_prezzi).difference(set(lista))
1991 oSheet = oDoc.CurrentController.ActiveSheet
1992 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
1993 iSheet = oSheet.RangeAddress.Sheet
1994 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
1995 oCellRangeAddr.Sheet = iSheet
1996 progress.setValue(3)
1997 oDoc.CurrentController.select(oSheet.getCellRangeByPosition(0, SR, 0, ER))
2001 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
2002 progress.setValue(4)
2011 for n
in reversed(range(SR, ER)):
2012 if oSheet.getCellByPosition(0, n).String
in da_cancellare:
2013 oSheet.Rows.removeByIndex(n, 1)
2014 if(oSheet.getCellByPosition(0, n).String ==
'' and
2015 oSheet.getCellByPosition(1, n).String ==
'' and
2016 oSheet.getCellByPosition(4, n).String ==
''):
2017 oSheet.Rows.removeByIndex(n, 1)
2019 progress.setValue(5)
2020 oDoc.enableAutomaticCalculation(
True)
2024 Dialogs.Info(Title =
'Ricerca conclusa', Text=
'Eliminate ' + str(len(da_cancellare)) +
" voci dall'elenco prezzi.")
2032 Ottimizza l'altezza delle celle di Elenco Prezzi o visualizza solo
2033 tre righe della descrizione.
2036 oSheet = oDoc.CurrentController.ActiveSheet
2038 oRange = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2039 SR = oRange.StartRow + 1
2042 if not oSheet.getCellByPosition(1, 3).Rows.OptimalHeight:
2045 hriga = oSheet.getCellRangeByName(
2046 'B4').CharHeight * 65 * 2 + 100
2047 oSheet.getCellRangeByPosition(0, SR, 0, ER).Rows.Height = hriga
2055 Gestisce i dialoghi del menù viste nelle tabelle di Analisi di Prezzo,
2056 Elenco Prezzi, COMPUTO, VARIANTE, CONTABILITA'
2057 Genera i raffronti tra COMPUTO e VARIANTE e CONTABILITA'
2061 oSheet = oDoc.CurrentController.ActiveSheet
2063 dp = psm.createInstance(
'com.sun.star.awt.DialogProvider')
2065 if oSheet.Name
in (
'VARIANTE',
'COMPUTO'):
2066 oDialog1 = dp.createDialog(
2067 'vnd.sun.star.script:UltimusFree2.DialogViste_A?language=Basic&location=application'
2070 oDialog1.getControl(
'Dettaglio').State = cfg.read(
'Generale',
'dettaglio')
2071 if oSheet.getColumns().getByIndex(5).Columns.IsVisible:
2072 oDialog1.getControl(
'CBMis').State = 1
2073 if oSheet.getColumns().getByIndex(17).Columns.IsVisible:
2074 oDialog1.getControl(
'CBSic').State = 1
2075 if oSheet.getColumns().getByIndex(28).Columns.IsVisible:
2076 oDialog1.getControl(
'CBMat').State = 1
2077 if oSheet.getColumns().getByIndex(29).Columns.IsVisible:
2078 oDialog1.getControl(
'CBMdo').State = 1
2079 if oSheet.getColumns().getByIndex(31).Columns.IsVisible:
2080 oDialog1.getControl(
'CBCat').State = 1
2081 if oSheet.getColumns().getByIndex(38).Columns.IsVisible:
2082 oDialog1.getControl(
'CBFig').State = 1
2084 sString = oDialog1.getControl(
'TextField10')
2085 sString.Text = oDoc.getSheets().getByName(
'S1').getCellRangeByName(
2087 sString = oDialog1.getControl(
'TextField11')
2088 sString.Text = oDoc.getSheets().getByName(
'S1').getCellRangeByName(
2094 if oDialog1.getControl(
'TextField10').getText() !=
'10000':
2095 cfg.write(
'Computo',
'inizio_voci_abbreviate', oDialog1.getControl(
'TextField10').getText())
2096 oDoc.getSheets().getByName(
'S1').getCellRangeByName(
'H337').Value = float(oDialog1.getControl(
'TextField10').getText())
2098 if oDialog1.getControl(
'TextField11').getText() !=
'10000':
2099 cfg.write(
'Computo',
'fine_voci_abbreviate', oDialog1.getControl(
'TextField11').getText())
2100 oDoc.getSheets().getByName(
'S1').getCellRangeByName(
'H338').Value = float(oDialog1.getControl(
'TextField11').getText())
2105 if oDialog1.getControl(
'OBTerra').State:
2107 oDialog1.getControl(
'CBSic').State = 0
2108 oDialog1.getControl(
'CBMdo').State = 0
2109 oDialog1.getControl(
'CBMat').State = 0
2110 oDialog1.getControl(
'CBCat').State = 0
2111 oDialog1.getControl(
'CBFig').State = 0
2112 oDialog1.getControl(
'CBMis').State = 1
2114 if oDialog1.getControl(
"CBMis").State == 0:
2115 oSheet.getColumns().getByIndex(5).Columns.IsVisible =
False
2116 oSheet.getColumns().getByIndex(6).Columns.IsVisible =
False
2117 oSheet.getColumns().getByIndex(7).Columns.IsVisible =
False
2118 oSheet.getColumns().getByIndex(8).Columns.IsVisible =
False
2120 oSheet.getColumns().getByIndex(5).Columns.IsVisible =
True
2121 oSheet.getColumns().getByIndex(6).Columns.IsVisible =
True
2122 oSheet.getColumns().getByIndex(7).Columns.IsVisible =
True
2123 oSheet.getColumns().getByIndex(8).Columns.IsVisible =
True
2125 if oDialog1.getControl(
'CBMdo').State:
2126 oSheet.getColumns().getByIndex(29).Columns.IsVisible =
True
2127 oSheet.getColumns().getByIndex(30).Columns.IsVisible =
True
2128 oSheet.getColumns().getByIndex(5).Columns.IsVisible =
False
2129 oSheet.getColumns().getByIndex(6).Columns.IsVisible =
False
2130 oSheet.getColumns().getByIndex(7).Columns.IsVisible =
False
2131 oSheet.getColumns().getByIndex(8).Columns.IsVisible =
False
2133 oSheet.clearOutline()
2136 oSheet.getColumns().getByIndex(29).Columns.IsVisible =
False
2137 oSheet.getColumns().getByIndex(30).Columns.IsVisible =
False
2139 if oDialog1.getControl(
'CBMat').State == 0:
2140 oSheet.getColumns().getByIndex(28).Columns.IsVisible =
False
2143 oSheet.getColumns().getByIndex(28).Columns.IsVisible =
True
2145 if oDialog1.getControl(
'CBCat').State == 0:
2146 oSheet.getColumns().getByIndex(31).Columns.IsVisible =
False
2147 oSheet.getColumns().getByIndex(32).Columns.IsVisible =
False
2148 oSheet.getColumns().getByIndex(33).Columns.IsVisible =
False
2150 oSheet.getColumns().getByIndex(31).Columns.IsVisible =
True
2151 oSheet.getColumns().getByIndex(32).Columns.IsVisible =
True
2152 oSheet.getColumns().getByIndex(33).Columns.IsVisible =
True
2154 if oDialog1.getControl(
"CBSic").State == 0:
2155 oSheet.getColumns().getByIndex(17).Columns.IsVisible =
False
2157 oSheet.getColumns().getByIndex(17).Columns.IsVisible =
True
2159 if oDialog1.getControl(
"CBFig").State == 0:
2160 oSheet.getColumns().getByIndex(38).Columns.IsVisible =
False
2162 oSheet.getColumns().getByIndex(38).Columns.IsVisible =
True
2164 if oDialog1.getControl(
'Dettaglio').State == 0:
2165 cfg.write(
'Generale',
'dettaglio',
'0')
2168 cfg.write(
'Generale',
'dettaglio',
'1')
2171 elif oSheet.Name
in (
'Elenco Prezzi'):
2172 oCellRangeAddr = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2173 oDialog1 = dp.createDialog(
2174 "vnd.sun.star.script:UltimusFree2.DialogViste_EP?language=Basic&location=application"
2178 if oSheet.getColumns().getByIndex(3).Columns.IsVisible:
2179 oDialog1.getControl(
'CBSic').State = 1
2180 if oSheet.getColumns().getByIndex(5).Columns.IsVisible:
2181 oDialog1.getControl(
'CBMdo').State = 1
2182 if not oSheet.getCellByPosition(1, 3).Rows.OptimalHeight:
2183 oDialog1.getControl(
'CBDesc').State = 1
2184 if oSheet.getColumns().getByIndex(7).Columns.IsVisible:
2185 oDialog1.getControl(
'CBOrig').State = 1
2186 if oDialog1.execute() == 1:
2187 if oDialog1.getControl(
"CBSic").State == 0:
2188 oSheet.getColumns().getByIndex(3).Columns.IsVisible =
False
2190 oSheet.getColumns().getByIndex(3).Columns.IsVisible =
True
2192 if oDialog1.getControl(
"CBMdo").State == 0:
2193 oSheet.getColumns().getByIndex(5).Columns.IsVisible =
False
2194 oSheet.getColumns().getByIndex(6).Columns.IsVisible =
False
2196 oSheet.getColumns().getByIndex(5).Columns.IsVisible =
True
2197 oSheet.getColumns().getByIndex(6).Columns.IsVisible =
True
2199 if oDialog1.getControl(
"CBDesc").State == 1:
2200 oSheet.getColumns().getByIndex(3).Columns.IsVisible =
False
2201 oSheet.getCellByPosition(1, 3).Rows.OptimalHeight
2205 if oDialog1.getControl(
"CBOrig").State == 0:
2206 oSheet.getColumns().getByIndex(7).Columns.IsVisible =
False
2208 oSheet.getColumns().getByIndex(7).Columns.IsVisible =
True
2210 if oDialog1.getControl(
"CBSom").State == 1:
2213 oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2214 SR = oRangeAddress.StartRow + 1
2215 ER = oRangeAddress.EndRow
2217 oSheet.getCellRangeByPosition(11, 0, 26,
2218 0).Columns.IsVisible =
True
2219 oSheet.getCellRangeByPosition(23, SR, 25,
2220 ER).CellStyle =
'EP statistiche'
2221 oSheet.getCellRangeByPosition(26, SR, 26,
2222 ER).CellStyle =
'EP-mezzo %'
2223 oSheet.getCellRangeByName(
'AA2').CellStyle =
'EP-mezzo %'
2225 oSheet.getCellByPosition(11, 0).String =
'COMPUTO'
2226 oSheet.getCellByPosition(15, 0).String =
'VARIANTE'
2227 oSheet.getCellByPosition(19, 0).String =
"CONTABILITA"
2228 if oDialog1.getControl(
"ComVar").State:
2230 oRangeAddress.StartColumn = 19
2231 oRangeAddress.EndColumn = 22
2233 oSheet.getCellByPosition(23, 0).String =
'COMPUTO - VARIANTE'
2236 '=IF(Q' + str(n) +
'-M' + str(n) +
'=0;"--";Q' +
2237 str(n) +
'-M' + str(n) +
')',
'=IF(R' + str(n) +
'-N' +
2238 str(n) +
'>0;R' + str(n) +
'-N' + str(n) +
';"")',
2239 '=IF(R' + str(n) +
'-N' + str(n) +
'<0;N' + str(n) +
2240 '-R' + str(n) +
';"")',
'=IFERROR(IFS(AND(N' + str(n) +
2241 '>R' + str(n) +
';R' + str(n) +
'=0);-1;AND(N' +
2242 str(n) +
'<R' + str(n) +
';N' + str(n) +
'=0);1;N' +
2243 str(n) +
'=R' + str(n) +
';"--";N' + str(n) +
'>R' +
2244 str(n) +
';-(N' + str(n) +
'-R' + str(n) +
')/N' +
2245 str(n) +
';N' + str(n) +
'<R' + str(n) +
';-(N' +
2246 str(n) +
'-R' + str(n) +
')/N' + str(n) +
');"--")'
2249 oSheet.getCellByPosition(
2251 ).Formula =
'=IFERROR(IFS(AND(N2>R2;R2=0);-1;AND(N2<R2;N2=0);1;N2=R2;"--";N2>R2;-(N2-R2)/N2;N2<R2;-(N2-R2)/N2);"--")'
2252 oSheet.getCellByPosition(
2254 ).Formula =
'=IFERROR(IFS(AND(N' + str(n) +
'>R' + str(
2255 n) +
';R' + str(n) +
'=0);-1;AND(N' + str(n) +
'<R' + str(
2256 n) +
';N' + str(n) +
'=0);1;N' + str(n) +
'=R' + str(
2257 n) +
';"--";N' + str(n) +
'>R' + str(
2258 n) +
';-(N' + str(n) +
'-R' + str(
2259 n) +
')/N' + str(n) +
';N' + str(
2260 n) +
'<R' + str(n) +
';-(N' + str(
2261 n) +
'-R' + str(n) +
')/N' + str(
2263 oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2265 formule = tuple(formule)
2266 oRange.setFormulaArray(formule)
2268 if oRangeAddress.StartColumn != 0:
2269 oCellRangeAddr.StartColumn = 18
2270 oCellRangeAddr.EndColumn = 21
2271 oSheet.group(oCellRangeAddr, 0)
2272 oSheet.getCellRangeByPosition(18, 0, 21,
2273 0).Columns.IsVisible =
False
2275 oCellRangeAddr.StartColumn = 15
2276 oCellRangeAddr.EndColumn = 15
2277 oSheet.group(oCellRangeAddr, 0)
2278 oSheet.getCellRangeByPosition(15, 0, 15,
2279 0).Columns.IsVisible =
False
2282 if oDialog1.getControl(
"ComCon").State:
2284 oRangeAddress.StartColumn = 15
2285 oRangeAddress.EndColumn = 18
2287 oSheet.getCellByPosition(23,
2288 0).String =
'COMPUTO - CONTABILITÀ'
2291 '=IF(U' + str(n) +
'-M' + str(n) +
'=0;"--";U' +
2292 str(n) +
'-M' + str(n) +
')',
'=IF(V' + str(n) +
'-N' +
2293 str(n) +
'>0;V' + str(n) +
'-N' + str(n) +
';"")',
2294 '=IF(V' + str(n) +
'-N' + str(n) +
'<0;N' + str(n) +
2295 '-V' + str(n) +
';"")',
'=IFERROR(IFS(AND(N' + str(n) +
2296 '>V' + str(n) +
';V' + str(n) +
'=0);-1;AND(N' +
2297 str(n) +
'<V' + str(n) +
';N' + str(n) +
'=0);1;N' +
2298 str(n) +
'=V' + str(n) +
';"--";N' + str(n) +
'>V' +
2299 str(n) +
';-(N' + str(n) +
'-V' + str(n) +
')/N' +
2300 str(n) +
';N' + str(n) +
'<V' + str(n) +
';-(N' +
2301 str(n) +
'-V' + str(n) +
')/N' + str(n) +
');"--")'
2305 oSheet.getCellByPosition(
2307 ).Formula =
'=IFERROR(IFS(AND(N2>V2;V2=0);-1;AND(N2<V2;N2=0);1;N2=V2;"--";N2>V2;-(N2-V2)/N2;N2<V2;-(N2-V2)/N2);"--")'
2308 oSheet.getCellByPosition(
2310 ).Formula =
'=IFERROR(IFS(AND(N' + str(n) +
'>V' + str(
2311 n) +
';V' + str(n) +
'=0);-1;AND(N' + str(n) +
'<V' + str(
2312 n) +
';N' + str(n) +
'=0);1;N' + str(n) +
'=V' + str(
2313 n) +
';"--";N' + str(n) +
'>V' + str(
2314 n) +
';-(N' + str(n) +
'-V' + str(
2315 n) +
')/N' + str(n) +
';N' + str(
2316 n) +
'<V' + str(n) +
';-(N' + str(
2317 n) +
'-V' + str(n) +
')/N' + str(
2319 oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2321 formule = tuple(formule)
2322 oRange.setFormulaArray(formule)
2324 if oRangeAddress.StartColumn != 0:
2327 if oSheet.getCellByPosition(
2329 el).Value >= 0.2
or oSheet.getCellByPosition(
2330 26, el).String ==
'20,00%':
2331 oSheet.getCellRangeByPosition(
2332 0, el, 25, el).CellBackColor = 16777062
2335 "Nascondo eventuali voci non ancora contabilizzate?"
2339 if oSheet.getCellByPosition(20, el).Value == 0:
2340 oCellRangeAddr.StartRow = el
2341 oCellRangeAddr.EndRow = el
2342 oSheet.group(oCellRangeAddr, 1)
2343 oSheet.getCellRangeByPosition(
2344 0, el, 1, el).Rows.IsVisible =
False
2346 oCellRangeAddr.StartColumn = 5
2347 oCellRangeAddr.EndColumn = 11
2348 oSheet.group(oCellRangeAddr, 0)
2349 oSheet.getCellRangeByPosition(5, 0, 11,
2350 0).Columns.IsVisible =
False
2351 oCellRangeAddr.StartColumn = 15
2352 oCellRangeAddr.EndColumn = 19
2353 oSheet.group(oCellRangeAddr, 0)
2354 oSheet.getCellRangeByPosition(15, 0, 19,
2355 0).Columns.IsVisible =
False
2358 if oDialog1.getControl(
2362 oRangeAddress.StartColumn = 11
2363 oRangeAddress.EndColumn = 14
2365 oSheet.getCellByPosition(23,
2366 0).String =
'VARIANTE - CONTABILITÀ'
2369 '=IF(U' + str(n) +
'-Q' + str(n) +
'=0;"--";U' +
2370 str(n) +
'-Q' + str(n) +
')',
'=IF(V' + str(n) +
'-R' +
2371 str(n) +
'>0;V' + str(n) +
'-R' + str(n) +
';"")',
2372 '=IF(V' + str(n) +
'-R' + str(n) +
'<0;R' + str(n) +
2373 '-V' + str(n) +
';"")',
'=IFERROR(IFS(AND(R' + str(n) +
2374 '>V' + str(n) +
';V' + str(n) +
'=0);-1;AND(R' +
2375 str(n) +
'<V' + str(n) +
';R' + str(n) +
'=0);1;R' +
2376 str(n) +
'=V' + str(n) +
';"--";R' + str(n) +
'>V' +
2377 str(n) +
';-(R' + str(n) +
'-V' + str(n) +
')/R' +
2378 str(n) +
';R' + str(n) +
'<V' + str(n) +
';-(R' +
2379 str(n) +
'-V' + str(n) +
')/R' + str(n) +
');"--")'
2383 oSheet.getCellByPosition(
2385 ).Formula =
'=IFERROR(IFS(AND(R2>V2;V2=0);-1;AND(R2<V2;R2=0);1;R2=V2;"--";R2>V2;-(R2-V2)/R2;R2<V2;-(R2-V2)/R2);"--")'
2386 oSheet.getCellByPosition(
2388 ).Formula =
'=IFERROR(IFS(AND(R' + str(n) +
'>V' + str(
2389 n) +
';V' + str(n) +
'=0);-1;AND(R' + str(n) +
'<V' + str(
2390 n) +
';R' + str(n) +
'=0);1;R' + str(n) +
'=V' + str(
2391 n) +
';"--";R' + str(n) +
'>V' + str(
2392 n) +
';-(R' + str(n) +
'-V' + str(
2393 n) +
')/R' + str(n) +
';R' + str(
2394 n) +
'<V' + str(n) +
';-(R' + str(
2395 n) +
'-V' + str(n) +
')/R' + str(
2397 oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2399 formule = tuple(formule)
2400 oRange.setFormulaArray(formule)
2402 for el
in (11, 15, 19, 26):
2403 oSheet.getCellRangeByPosition(
2405 for el
in (12, 16, 20, 23):
2406 oSheet.getCellRangeByPosition(
2409 for el
in (13, 17, 21, 24, 25):
2410 oSheet.getCellRangeByPosition(
2413 oCellRangeAddr.StartColumn = 3
2414 oCellRangeAddr.EndColumn = 3
2415 oSheet.group(oCellRangeAddr, 0)
2416 oSheet.getCellRangeByPosition(3, 0, 3, 0).Columns.IsVisible =
False
2417 oCellRangeAddr.StartColumn = 5
2418 oCellRangeAddr.EndColumn = 11
2419 oSheet.group(oCellRangeAddr, 0)
2420 oSheet.getCellRangeByPosition(5, 0, 11,
2421 0).Columns.IsVisible =
False
2423 oDoc.CurrentController.select(oSheet.getCellRangeByName(
'AA2'))
2426 oDoc.CurrentController.select(
2427 oSheet.getCellRangeByPosition(26, 3, 26, ER))
2430 if(oDialog1.getControl(
"ComVar").State
or
2431 oDialog1.getControl(
"ComCon").State
or
2432 oDialog1.getControl(
"VarCon").State):
2433 if DLG.DlgSiNo(
"Nascondo eventuali righe con scostamento nullo?") == 2:
2434 errori = (
'#DIV/0!',
'--')
2436 oSheet.group(oRangeAddress, 0)
2437 oSheet.getCellRangeByPosition(oRangeAddress.StartColumn, 0,
2438 oRangeAddress.EndColumn,
2439 1).Columns.IsVisible =
False
2443 elif oSheet.Name
in (
'Analisi di Prezzo'):
2444 oDialog1 = dp.createDialog(
2445 "vnd.sun.star.script:UltimusFree2.DialogViste_AN?language=Basic&location=application"
2448 if not oSheet.getCellByPosition(1, 2).Rows.OptimalHeight:
2449 oDialog1.getControl(
"CBDesc").State = 1
2451 oS1 = oDoc.getSheets().getByName(
'S1')
2452 sString = oDialog1.getControl(
'TextField5')
2453 sString.Text = oS1.getCellRangeByName(
2454 'S1.H319').Value * 100
2455 sString = oDialog1.getControl(
'TextField6')
2456 sString.Text = oS1.getCellRangeByName(
2457 'S1.H320').Value * 100
2458 sString = oDialog1.getControl(
'TextField7')
2459 sString.Text = oS1.getCellRangeByName(
2460 'S1.H321').Value * 100
2463 if oS1.getCellRangeByName(
'S1.H323').Value == 1:
2464 oDialog1.getControl(
'CheckBox4').State = 1
2465 sString = oDialog1.getControl(
'TextField8')
2466 sString.Text = oS1.getCellRangeByName(
'S1.H324').Value * 100
2467 sString = oDialog1.getControl(
'TextField9')
2468 sString.Text = oS1.getCellRangeByName(
2469 'S1.H326').Value * 100
2473 if(oSheet.getCellByPosition(1, 2).Rows.OptimalHeight
and
2474 oDialog1.getControl(
"CBDesc").State == 1):
2479 oS1.getCellRangeByName(
'S1.H319').Value = float(
2480 oDialog1.getControl(
'TextField5').getText().replace(
2482 oS1.getCellRangeByName(
'S1.H320').Value = float(
2483 oDialog1.getControl(
'TextField6').getText().replace(
2485 oS1.getCellRangeByName(
'S1.H321').Value = float(
2486 oDialog1.getControl(
'TextField7').getText().replace(
2488 oS1.getCellRangeByName(
'S1.H323').Value = oDialog1.getControl(
2490 oS1.getCellRangeByName(
'S1.H324').Value = float(
2491 oDialog1.getControl(
'TextField8').getText().replace(
2493 oS1.getCellRangeByName(
'S1.H326').Value = float(
2494 oDialog1.getControl(
'TextField9').getText().replace(
2498 if oS1.getCellRangeByName(
'S1.H323').Value == 1:
2499 oDialog1.getControl(
'CheckBox4').State = 1
2500 sString = oDialog1.getControl(
'TextField8')
2501 sString.Text = oS1.getCellRangeByName(
'S1.H324').Value * 100
2502 sString = oDialog1.getControl(
'TextField9')
2503 sString.Text = oS1.getCellRangeByName(
2504 'S1.H326').Value * 100
2506 elif oSheet.Name
in (
'CONTABILITA',
'Registro',
'SAL'):
2507 oDialog1 = dp.createDialog(
2508 "vnd.sun.star.script:UltimusFree2.Dialogviste_N?language=Basic&location=application"
2510 if oSheet.getColumns().getByIndex(19).Columns.IsVisible:
2511 oDialog1.getControl(
'vista_pre').State = 1
2513 oDialog1.getControl(
'vista_sem').State = 1
2514 sString = oDialog1.getControl(
'TextField3')
2515 sString.Text = oDoc.getSheets().getByName(
'S1').getCellRangeByName(
2517 sString = oDialog1.getControl(
'TextField2')
2518 sString.Text = oDoc.getSheets().getByName(
'S1').getCellRangeByName(
2524 sString = oDialog1.getControl(
'TextField13')
2525 if cfg.read(
'Contabilita',
'idxsal') ==
'&273.Dlg_config.TextField13.Text':
2528 sString.Text = cfg.read(
'Contabilita',
'idxsal')
2529 if sString.Text ==
'':
2531 sString = oDialog1.getControl(
'ComboBox3')
2532 sString.Text = cfg.read(
'Contabilita',
'ricicla_da')
2535 oDialog1.getControl(
'Dettaglio').State = cfg.read(
'Generale',
'dettaglio')
2538 if oDialog1.getControl(
'vista_pre').State:
2540 if oDialog1.getControl(
'vista_sem').State:
2545 if oDialog1.getControl(
'TextField3').getText() !=
'10000':
2546 cfg.write(
'Contabilita',
'cont_inizio_voci_abbreviate', oDialog1.getControl(
'TextField3').getText())
2547 oDoc.getSheets().getByName(
'S1').getCellRangeByName(
'H335').Value = float(oDialog1.getControl(
'TextField3').getText())
2549 if oDialog1.getControl(
'TextField2').getText() !=
'10000':
2550 cfg.write(
'Contabilita',
'cont_fine_voci_abbreviate', oDialog1.getControl(
'TextField2').getText())
2551 oDoc.getSheets().getByName(
'S1').getCellRangeByName(
'H336').Value = float(oDialog1.getControl(
'TextField2').getText())
2553 cfg.write(
'Contabilita',
'idxsal', oDialog1.getControl(
'TextField13').getText())
2554 if oDialog1.getControl(
'ComboBox3').getText()
in (
'COMPUTO',
'&305.Dlg_config.ComboBox3.Text'):
2555 cfg.write(
'Contabilita',
'ricicla_da',
'COMPUTO')
2557 cfg.write(
'Contabilita',
'ricicla_da',
'VARIANTE')
2559 if oDialog1.getControl(
'Dettaglio').State == 0:
2560 cfg.write(
'Generale',
'dettaglio',
'0')
2563 cfg.write(
'Generale',
'dettaglio',
'1')
2577 Genera il foglio di VARIANTE a partire dal COMPUTO
2578 @@@ MODIFICA IN CORSO CON 'LeenoVariante.generaVariante'
2582 if not oDoc.getSheets().hasByName(
'VARIANTE'):
2583 if oDoc.NamedRanges.hasByName(
"AA"):
2584 oDoc.NamedRanges.removeByName(
"AA")
2585 oDoc.NamedRanges.removeByName(
"BB")
2586 oDoc.Sheets.copyByName(
'COMPUTO',
'VARIANTE', 4)
2587 oSheet = oDoc.getSheets().getByName(
'COMPUTO')
2592 oSheet = oDoc.getSheets().getByName(
'VARIANTE')
2595 oSheet.getCellByPosition(2, 0).String =
"VARIANTE"
2596 oSheet.getCellByPosition(2, 0).CellStyle =
"comp Int_colonna"
2597 oSheet.getCellRangeByName(
"C1").CellBackColor = 16777062
2598 oSheet.getCellRangeByPosition(0, 2, 42, 2).CellBackColor = 16777062
2600 """Vuoi svuotare la VARIANTE appena generata?
2602 Se decidi di continuare, cancellerai tutte le voci di
2603 misurazione già presenti in questo elaborato.
2604 Cancello le voci di misurazione?
2605 """,
'ATTENZIONE!') == 2:
2607 oSheet.Rows.removeByIndex(3, lrow)
2610 oSheet = oDoc.getSheets().getByName(
'VARIANTE')
2624 Genera i sommari in Elenco Prezzi
2629 oDoc.enableAutomaticCalculation(
False)
2630 oSheet = oDoc.getSheets().getByName(
'COMPUTO')
2636 if oDoc.getSheets().hasByName(
'VARIANTE'):
2637 oSheet = oDoc.getSheets().getByName(
'VARIANTE')
2643 if oDoc.getSheets().hasByName(
'CONTABILITA'):
2644 oSheet = oDoc.getSheets().getByName(
'CONTABILITA')
2647 oDoc.getSheets().getByName(
'CONTABILITA')).EndRow
2653 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
2656 progress =
Dialogs.Progress(Title=
'Generazione dei sommari in corso...', Text=
"Lettura dati")
2658 progress.setValue(0)
2662 progress.setValue(n)
2664 '=N' + str(n) +
'/$N$2',
'=SUMIF(AA;A' + str(n) +
';BB)',
2665 '=SUMIF(AA;A' + str(n) +
';cEuro)',
'',
'',
'',
'',
'',
'',
'',
''
2667 if oDoc.getSheets().hasByName(
'VARIANTE'):
2669 '=N' + str(n) +
'/$N$2',
'=SUMIF(AA;A' + str(n) +
';BB)',
2670 '=SUMIF(AA;A' + str(n) +
';cEuro)',
'',
2671 '=R' + str(n) +
'/$R$2',
'=SUMIF(varAA;A' + str(n) +
';varBB)',
2672 '=SUMIF(varAA;A' + str(n) +
';varEuro)',
'',
'',
'',
''
2674 if oDoc.getSheets().hasByName(
'CONTABILITA'):
2676 '=N' + str(n) +
'/$N$2',
'=SUMIF(AA;A' + str(n) +
';BB)',
2677 '=SUMIF(AA;A' + str(n) +
';cEuro)',
'',
2678 '=R' + str(n) +
'/$R$2',
2679 '=SUMIF(varAA;A' + str(n) +
';varBB)',
2680 '=SUMIF(varAA;A' + str(n) +
';varEuro)',
'',
2681 '=V' + str(n) +
'/$V$2',
'=SUMIF(GG;A' + str(n) +
';G1G1)',
2682 '=SUMIF(GG;A' + str(n) +
';conEuro)'
2684 elif oDoc.getSheets().hasByName(
'CONTABILITA'):
2686 '=N' + str(n) +
'/$N$2',
'=SUMIF(AA;A' + str(n) +
';BB)',
2687 '=SUMIF(AA;A' + str(n) +
';cEuro)',
'',
'',
'',
'',
'',
2688 '=V' + str(n) +
'/$V$2',
'=SUMIF(GG;A' + str(n) +
';G1G1)',
2689 '=SUMIF(GG;A' + str(n) +
';conEuro)'
2691 formule.append(stringa)
2693 formule = tuple(formule)
2694 oRange.setFormulaArray(formule)
2696 oDoc.enableAutomaticCalculation(
True)
2705 Riordina l'Elenco Prezzi secondo l'ordine alfabetico dei codici di prezzo
2708 oDoc.enableAutomaticCalculation(
False)
2710 oDoc.enableAutomaticCalculation(
True)
2715 Riordina l'Elenco Prezzi secondo l'ordine alfabetico dei codici di prezzo
2718 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
2724 oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2725 SR = oRangeAddress.StartRow + 1
2727 EC = oRangeAddress.EndColumn
2728 SR = oRangeAddress.StartRow + 1
2729 ER = oRangeAddress.EndRow -1
2733 oRange = oSheet.getCellRangeByPosition(SC, SR, EC, ER)
2748 Cancella eventuali voci che si ripetono in Elenco Prezzi
2751 if oDoc.getSheets().hasByName(
'Analisi di Prezzo'):
2752 lista_tariffe_analisi = list()
2753 oSheet = oDoc.getSheets().getByName(
'Analisi di Prezzo')
2755 if oSheet.getCellByPosition(0, n).CellStyle ==
'An-1_sigla':
2756 lista_tariffe_analisi.append(
2757 oSheet.getCellByPosition(0, n).String)
2758 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
2764 lista_tariffe_analisi
2765 for i
in reversed(range(SR, ER)):
2766 if oSheet.getCellByPosition(0, i).String
in lista_tariffe_analisi:
2767 oSheet.getRows().removeByIndex(i, 1)
2770 oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2771 SR = oRangeAddress.StartRow + 1
2772 ER = oRangeAddress.EndRow - 1
2775 oRange = oSheet.getCellRangeByPosition(0, SR, 7, ER)
2776 lista_come_array = tuple(set(oRange.getDataArray()))
2779 oSheet.getRows().removeByIndex(SR, ER - SR + 1)
2781 oSheet.getRows().insertByIndex(SR, len(set(lista_come_array)))
2782 for el
in set(lista_come_array):
2783 lista_tar.append(el[0])
2784 colonne_lista = len(lista_come_array[0]
2788 oRange = oSheet.getCellRangeByPosition(
2791 colonne_lista + 0 - 1,
2792 righe_lista + 3 - 1)
2793 oRange.setDataArray(lista_come_array)
2794 oSheet.getCellRangeByPosition(0, 3, 0,
2795 righe_lista + 3 - 1).CellStyle =
"EP-aS"
2796 oSheet.getCellRangeByPosition(1, 3, 1,
2797 righe_lista + 3 - 1).CellStyle =
"EP-a"
2798 oSheet.getCellRangeByPosition(2, 3, 7,
2799 righe_lista + 3 - 1).CellStyle =
"EP-mezzo"
2800 oSheet.getCellRangeByPosition(5, 3, 5,
2801 righe_lista + 3 - 1).CellStyle =
"EP-mezzo %"
2802 oSheet.getCellRangeByPosition(8, 3, 9,
2803 righe_lista + 3 - 1).CellStyle =
"EP-sfondo"
2805 oSheet.getCellRangeByPosition(11, 3, 11,
2806 righe_lista + 3 - 1).CellStyle =
'EP-mezzo %'
2807 oSheet.getCellRangeByPosition(12, 3, 12, righe_lista + 3 -
2808 1).CellStyle =
'EP statistiche_q'
2809 oSheet.getCellRangeByPosition(13, 3, 13, righe_lista + 3 -
2810 1).CellStyle =
'EP statistiche_Contab_q'
2813 if oDoc.getSheets().hasByName(
'Analisi di Prezzo'):
2816 oDoc.enableAutomaticCalculation(
True)
2821 if len(set(lista_tar)) != len(set(lista_come_array)):
2823 Text=
'''Ci sono ancora 2 o più voci che hanno
2824 lo stesso Codice Articolo pur essendo diverse.''')
2834 esporta il documento in formato XPWE
2836 elaborato { string } : nome del foglio da esportare
2837 out_file { string } : nome base del file
2839 il nome file risulterà out_file-elaborato.xpwe
2843 progress =
Dialogs.Progress(Title=
'Esportazione di ' + elaborato +
' in corso...', Text=
"Lettura dati")
2844 progress.setLimits(0, 7)
2845 progress.setValue(0)
2850 if cfg.read(
'Generale',
'dettaglio') ==
'1':
2853 top = Element(
'PweDocumento')
2855 CopyRight = SubElement(top,
'CopyRight')
2856 CopyRight.text =
'Copyright ACCA software S.p.A.'
2857 TipoDocumento = SubElement(top,
'TipoDocumento')
2858 TipoDocumento.text =
'1'
2859 TipoFormato = SubElement(top,
'TipoFormato')
2860 TipoFormato.text =
'XMLPwe'
2861 Versione = SubElement(top,
'Versione')
2863 SourceVersione = SubElement(top,
'SourceVersione')
2871 SourceVersione.text = release
2872 SourceNome = SubElement(top,
'SourceNome')
2873 SourceNome.text =
'LeenO.org'
2874 FileNameDocumento = SubElement(top,
'FileNameDocumento')
2876 PweDatiGenerali = SubElement(top,
'PweDatiGenerali')
2877 PweMisurazioni = SubElement(top,
'PweMisurazioni')
2878 PweDGProgetto = SubElement(PweDatiGenerali,
'PweDGProgetto')
2879 PweDGDatiGenerali = SubElement(PweDGProgetto,
'PweDGDatiGenerali')
2880 PercPrezzi = SubElement(PweDGDatiGenerali,
'PercPrezzi')
2881 PercPrezzi.text =
'0'
2883 Comune = SubElement(PweDGDatiGenerali,
'Comune')
2884 Provincia = SubElement(PweDGDatiGenerali,
'Provincia')
2885 Oggetto = SubElement(PweDGDatiGenerali,
'Oggetto')
2886 Committente = SubElement(PweDGDatiGenerali,
'Committente')
2887 Impresa = SubElement(PweDGDatiGenerali,
'Impresa')
2888 ParteOpera = SubElement(PweDGDatiGenerali,
'ParteOpera')
2890 oSheet = oDoc.getSheets().getByName(
'S2')
2891 Comune.text = oSheet.getCellByPosition(2, 3).String
2893 Oggetto.text = oSheet.getCellByPosition(2, 2).String
2894 Committente.text = oSheet.getCellByPosition(2, 5).String
2895 Impresa.text = oSheet.getCellByPosition(2, 16).String
2896 ParteOpera.text =
''
2898 PweDGCapitoliCategorie = SubElement(PweDatiGenerali,
2899 'PweDGCapitoliCategorie')
2901 oSheet = oDoc.getSheets().getByName(elaborato)
2905 PweDGSuperCategorie = SubElement(PweDGCapitoliCategorie,
2906 'PweDGSuperCategorie')
2907 progress.setValue(1)
2908 for n
in range(0, lastRow):
2909 if oSheet.getCellByPosition(1, n).CellStyle ==
'Livello-0-scritta':
2910 desc = oSheet.getCellByPosition(2, n).String
2911 if desc
not in listaspcat:
2912 listaspcat.append(desc)
2913 idID = str(listaspcat.index(desc) + 1)
2916 DGSuperCategorieItem = SubElement(PweDGSuperCategorie,
2917 'DGSuperCategorieItem')
2918 DesSintetica = SubElement(DGSuperCategorieItem,
'DesSintetica')
2920 DesEstesa = SubElement(DGSuperCategorieItem,
'DesEstesa')
2921 DataInit = SubElement(DGSuperCategorieItem,
'DataInit')
2922 Durata = SubElement(DGSuperCategorieItem,
'Durata')
2924 Percentuale = SubElement(DGSuperCategorieItem,
'Percentuale')
2927 DGSuperCategorieItem.set(
'ID', idID)
2928 DesSintetica.text = desc
2929 DataInit.text =
oggi()
2931 Percentuale.text =
'0'
2935 PweDGCategorie = SubElement(PweDGCapitoliCategorie,
'PweDGCategorie')
2936 progress.setValue(2)
2937 for n
in range(0, lastRow):
2938 if oSheet.getCellByPosition(2,
2939 n).CellStyle ==
'Livello-1-scritta mini':
2940 desc = oSheet.getCellByPosition(2, n).String
2941 if desc
not in listaCat:
2942 listaCat.append(desc)
2943 idID = str(listaCat.index(desc) + 1)
2946 DGCategorieItem = SubElement(PweDGCategorie,
'DGCategorieItem')
2947 DesSintetica = SubElement(DGCategorieItem,
'DesSintetica')
2949 DesEstesa = SubElement(DGCategorieItem,
'DesEstesa')
2950 DataInit = SubElement(DGCategorieItem,
'DataInit')
2951 Durata = SubElement(DGCategorieItem,
'Durata')
2953 Percentuale = SubElement(DGCategorieItem,
'Percentuale')
2956 DGCategorieItem.set(
'ID', idID)
2957 DesSintetica.text = desc
2958 DataInit.text =
oggi()
2960 Percentuale.text =
'0'
2964 PweDGSubCategorie = SubElement(PweDGCapitoliCategorie,
'PweDGSubCategorie')
2965 progress.setValue(3)
2966 for n
in range(0, lastRow):
2967 if oSheet.getCellByPosition(2, n).CellStyle ==
'livello2_':
2968 desc = oSheet.getCellByPosition(2, n).String
2969 if desc
not in listasbCat:
2970 listasbCat.append(desc)
2971 idID = str(listasbCat.index(desc) + 1)
2974 DGSubCategorieItem = SubElement(PweDGSubCategorie,
2975 'DGSubCategorieItem')
2976 DesSintetica = SubElement(DGSubCategorieItem,
'DesSintetica')
2978 DesEstesa = SubElement(DGSubCategorieItem,
'DesEstesa')
2979 DataInit = SubElement(DGSubCategorieItem,
'DataInit')
2980 Durata = SubElement(DGSubCategorieItem,
'Durata')
2982 Percentuale = SubElement(DGSubCategorieItem,
'Percentuale')
2985 DGSubCategorieItem.set(
'ID', idID)
2986 DesSintetica.text = desc
2987 DataInit.text =
oggi()
2989 Percentuale.text =
'0'
2992 PweDGModuli = SubElement(PweDatiGenerali,
'PweDGModuli')
2993 PweDGAnalisi = SubElement(PweDGModuli,
'PweDGAnalisi')
2994 SpeseUtili = SubElement(PweDGAnalisi,
'SpeseUtili')
2995 SpeseGenerali = SubElement(PweDGAnalisi,
'SpeseGenerali')
2996 UtiliImpresa = SubElement(PweDGAnalisi,
'UtiliImpresa')
2997 OneriAccessoriSc = SubElement(PweDGAnalisi,
'OneriAccessoriSc')
3000 oSheet = oDoc.getSheets().getByName(
'S1')
3001 if oSheet.getCellByPosition(
3003 SpeseUtili.text =
'1'
3005 SpeseUtili.text =
'-1'
3007 UtiliImpresa.text = oSheet.getCellByPosition(7, 320).String[:-1].replace(
3009 OneriAccessoriSc.text = oSheet.getCellByPosition(7,
3010 318).String[:-1].replace(
3012 SpeseGenerali.text = oSheet.getCellByPosition(7, 319).String[:-1].replace(
3023 PweDGConfigurazione = SubElement(PweDatiGenerali,
'PweDGConfigurazione')
3024 PweDGConfigNumeri = SubElement(PweDGConfigurazione,
'PweDGConfigNumeri')
3025 Divisa = SubElement(PweDGConfigNumeri,
'Divisa')
3026 Divisa.text =
'euro'
3027 ConversioniIN = SubElement(PweDGConfigNumeri,
'ConversioniIN')
3028 ConversioniIN.text =
'lire'
3029 FattoreConversione = SubElement(PweDGConfigNumeri,
'FattoreConversione')
3030 FattoreConversione.text =
'1936.27'
3031 Cambio = SubElement(PweDGConfigNumeri,
'Cambio')
3033 PartiUguali = SubElement(PweDGConfigNumeri,
'PartiUguali')
3034 PartiUguali.text =
'9.' + PU +
'|0'
3035 Lunghezza = SubElement(PweDGConfigNumeri,
'Lunghezza')
3036 Lunghezza.text =
'9.' + LUN +
'|0'
3037 Larghezza = SubElement(PweDGConfigNumeri,
'Larghezza')
3038 Larghezza.text =
'9.' + LAR +
'|0'
3039 HPeso = SubElement(PweDGConfigNumeri,
'HPeso')
3040 HPeso.text =
'9.' + PES +
'|0'
3041 Quantita = SubElement(PweDGConfigNumeri,
'Quantita')
3042 Quantita.text =
'10.' + QUA +
'|1'
3043 Prezzi = SubElement(PweDGConfigNumeri,
'Prezzi')
3044 Prezzi.text =
'10.' + PR +
'|1'
3045 PrezziTotale = SubElement(PweDGConfigNumeri,
'PrezziTotale')
3046 PrezziTotale.text =
'14.' + TOT +
'|1'
3047 ConvPrezzi = SubElement(PweDGConfigNumeri,
'ConvPrezzi')
3048 ConvPrezzi.text =
'11.0|1'
3049 ConvPrezziTotale = SubElement(PweDGConfigNumeri,
'ConvPrezziTotale')
3050 ConvPrezziTotale.text =
'15.0|1'
3051 IncidenzaPercentuale = SubElement(PweDGConfigNumeri,
3052 'IncidenzaPercentuale')
3053 IncidenzaPercentuale.text =
'7.3|0'
3054 Aliquote = SubElement(PweDGConfigNumeri,
'Aliquote')
3055 Aliquote.text =
'7.3|0'
3058 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
3059 PweElencoPrezzi = SubElement(PweMisurazioni,
'PweElencoPrezzi')
3062 progress.setValue(4)
3070 if oSheet.getCellByPosition(0, n).CellBackColor == 16777072
and \
3071 oSheet.getCellByPosition(0, n).String !=
'000':
3072 cod = oSheet.getCellByPosition(0, n).String
3073 desc = oSheet.getCellByPosition(1, n).String
3074 if desc
not in listaspcap:
3075 listaspcap.append(desc)
3076 IDSpCap = str(listaspcap.index(desc) + 1)
3078 PweDGSuperCapitoli = SubElement(PweDGCapitoliCategorie,
'PweDGSuperCapitoli')
3079 DGSuperCapitoliItem = SubElement(PweDGSuperCapitoli,
3080 'DGSuperCapitoliItem')
3081 DesSintetica = SubElement(DGSuperCapitoliItem,
'DesSintetica')
3083 DesEstesa = SubElement(DGSuperCapitoliItem,
'DesEstesa')
3084 DataInit = SubElement(DGSuperCapitoliItem,
'DataInit')
3085 Durata = SubElement(DGSuperCapitoliItem,
'Durata')
3087 Percentuale = SubElement(DGSuperCapitoliItem,
'Percentuale')
3088 Codice = SubElement(DGSuperCapitoliItem,
'Codice')
3090 DGSuperCapitoliItem.set(
'ID', IDSpCap)
3091 DesSintetica.text = desc
3095 Percentuale.text =
'0'
3098 if oSheet.getCellByPosition(0, n).CellBackColor == 16777120:
3099 cod = oSheet.getCellByPosition(0, n).String
3100 desc = oSheet.getCellByPosition(1, n).String
3101 if desc
not in listacap:
3102 listacap.append(desc)
3103 IDCap = str(listacap.index(desc) + 1)
3105 PweDGCapitoli = SubElement(PweDGCapitoliCategorie,
'PweDGCapitoli')
3106 DGCapitoliItem = SubElement(PweDGCapitoli,
3108 DesSintetica = SubElement(DGCapitoliItem,
'DesSintetica')
3110 DesEstesa = SubElement(DGCapitoliItem,
'DesEstesa')
3111 DataInit = SubElement(DGCapitoliItem,
'DataInit')
3112 Durata = SubElement(DGCapitoliItem,
'Durata')
3114 Percentuale = SubElement(DGCapitoliItem,
'Percentuale')
3115 Codice = SubElement(DGCapitoliItem,
'Codice')
3117 DGCapitoliItem.set(
'ID', IDCap)
3118 DesSintetica.text = desc
3122 Percentuale.text =
'0'
3125 if oSheet.getCellByPosition(0, n).CellBackColor == 16777168:
3126 cod = oSheet.getCellByPosition(0, n).String
3127 desc = oSheet.getCellByPosition(1, n).String
3128 if desc
not in listasbcap:
3129 listasbcap.append(desc)
3130 IDSbCap = str(listasbcap.index(desc) + 1)
3132 PweDGSubCapitoli = SubElement(PweDGCapitoliCategorie,
'PweDGSubCapitoli')
3133 DGSubCapitoliItem = SubElement(PweDGSubCapitoli,
3134 'DGSubCapitoliItem')
3135 DesSintetica = SubElement(DGSubCapitoliItem,
'DesSintetica')
3137 DesEstesa = SubElement(DGSubCapitoliItem,
'DesEstesa')
3138 DataInit = SubElement(DGSubCapitoliItem,
'DataInit')
3139 Durata = SubElement(DGSubCapitoliItem,
'Durata')
3141 Percentuale = SubElement(DGSubCapitoliItem,
'Percentuale')
3142 Codice = SubElement(DGSubCapitoliItem,
'Codice')
3144 DGSubCapitoliItem.set(
'ID', IDSbCap)
3145 DesSintetica.text = desc
3149 Percentuale.text =
'0'
3153 if(oSheet.getCellByPosition(1, n).Type.value ==
'FORMULA' and
3154 oSheet.getCellByPosition(2, n).Type.value ==
'FORMULA'):
3155 lista_AP.append(oSheet.getCellByPosition(0, n).String)
3156 elif(oSheet.getCellByPosition(1, n).Type.value ==
'TEXT' and
3157 oSheet.getCellByPosition(2, n).Type.value ==
'TEXT'):
3158 EPItem = SubElement(PweElencoPrezzi,
'EPItem')
3159 EPItem.set(
'ID', str(n))
3160 TipoEP = SubElement(EPItem,
'TipoEP')
3162 Tariffa = SubElement(EPItem,
'Tariffa')
3164 Tariffa.text = oSheet.getCellByPosition(0, n).String
3165 diz_ep[oSheet.getCellByPosition(0, n).String] = id_tar
3166 Articolo = SubElement(EPItem,
'Articolo')
3168 DesRidotta = SubElement(EPItem,
'DesRidotta')
3169 DesEstesa = SubElement(EPItem,
'DesEstesa')
3170 DesEstesa.text = oSheet.getCellByPosition(1, n).String
3171 if len(DesEstesa.text) > 120:
3172 DesRidotta.text = DesEstesa.text[:
3173 60] +
' ... ' + DesEstesa.text[
3176 DesRidotta.text = DesEstesa.text
3177 DesBreve = SubElement(EPItem,
'DesBreve')
3178 if len(DesEstesa.text) > 60:
3179 DesBreve.text = DesEstesa.text[:30] +
' ... ' + DesEstesa.text[
3182 DesBreve.text = DesEstesa.text
3183 UnMisura = SubElement(EPItem,
'UnMisura')
3184 UnMisura.text = oSheet.getCellByPosition(2, n).String
3185 Prezzo1 = SubElement(EPItem,
'Prezzo1')
3186 Prezzo1.text = str(oSheet.getCellByPosition(4, n).Value)
3187 Prezzo2 = SubElement(EPItem,
'Prezzo2')
3189 Prezzo3 = SubElement(EPItem,
'Prezzo3')
3191 Prezzo4 = SubElement(EPItem,
'Prezzo4')
3193 Prezzo5 = SubElement(EPItem,
'Prezzo5')
3197 SubElement(EPItem,
'IDSpCap').text = IDSpCap
3199 SubElement(EPItem,
'IDSpCap').text =
'0'
3201 SubElement(EPItem,
'IDCap').text = IDCap
3203 SubElement(EPItem,
'IDCap').text =
'0'
3205 SubElement(EPItem,
'IDSbCap').text = IDSbCap
3207 SubElement(EPItem,
'IDSbCap').text =
'0'
3209 Flags = SubElement(EPItem,
'Flags')
3210 if oSheet.getCellByPosition(8, n).String ==
'(AP)':
3211 Flags.text =
'131072'
3214 Data = SubElement(EPItem,
'Data')
3215 Data.text =
'30/12/1899'
3216 AdrInternet = SubElement(EPItem,
'AdrInternet')
3217 AdrInternet.text =
''
3218 PweEPAnalisi = SubElement(EPItem,
'PweEPAnalisi')
3220 IncSIC = SubElement(EPItem,
'IncSIC')
3221 if oSheet.getCellByPosition(3, n).Value == 0.0:
3224 IncSIC.text = str(oSheet.getCellByPosition(3, n).Value * 100)
3226 IncMDO = SubElement(EPItem,
'IncMDO')
3227 if oSheet.getCellByPosition(5, n).Value == 0.0:
3230 IncMDO.text = str(oSheet.getCellByPosition(5, n).Value * 100)
3232 IncMAT = SubElement(EPItem,
'IncMAT')
3233 if oSheet.getCellByPosition(6, n).Value == 0.0:
3236 IncMAT.text = str(oSheet.getCellByPosition(6, n).Value * 100)
3238 IncATTR = SubElement(EPItem,
'IncATTR')
3239 if oSheet.getCellByPosition(7, n).Value == 0.0:
3242 IncATTR.text = str(oSheet.getCellByPosition(7, n).Value * 100)
3245 progress.setValue(5)
3246 if len(lista_AP) != 0:
3247 oSheet = oDoc.getSheets().getByName(
'Analisi di Prezzo')
3252 EPItem = SubElement(PweElencoPrezzi,
'EPItem')
3253 EPItem.set(
'ID', str(k))
3254 TipoEP = SubElement(EPItem,
'TipoEP')
3256 Tariffa = SubElement(EPItem,
'Tariffa')
3258 Tariffa.text = oSheet.getCellByPosition(0, m).String
3259 diz_ep[oSheet.getCellByPosition(0, m).String] = id_tar
3260 Articolo = SubElement(EPItem,
'Articolo')
3262 DesRidotta = SubElement(EPItem,
'DesRidotta')
3263 DesEstesa = SubElement(EPItem,
'DesEstesa')
3264 DesEstesa.text = oSheet.getCellByPosition(1, m).String
3265 if len(DesEstesa.text) > 120:
3266 DesRidotta.text = DesEstesa.text[:
3267 60] +
' ... ' + DesEstesa.text[
3270 DesRidotta.text = DesEstesa.text
3271 DesBreve = SubElement(EPItem,
'DesBreve')
3272 if len(DesEstesa.text) > 60:
3273 DesBreve.text = DesEstesa.text[:
3274 30] +
' ... ' + DesEstesa.text[
3277 DesBreve.text = DesEstesa.text
3278 UnMisura = SubElement(EPItem,
'UnMisura')
3279 UnMisura.text = oSheet.getCellByPosition(2, m).String
3280 Prezzo1 = SubElement(EPItem,
'Prezzo1')
3281 Prezzo1.text = str(oSheet.getCellByPosition(6, m).Value)
3282 Prezzo2 = SubElement(EPItem,
'Prezzo2')
3284 Prezzo3 = SubElement(EPItem,
'Prezzo3')
3286 Prezzo4 = SubElement(EPItem,
'Prezzo4')
3288 Prezzo5 = SubElement(EPItem,
'Prezzo5')
3290 IDSpCap = SubElement(EPItem,
'IDSpCap')
3292 IDCap = SubElement(EPItem,
'IDCap')
3294 IDSbCap = SubElement(EPItem,
'IDSbCap')
3296 Flags = SubElement(EPItem,
'Flags')
3297 Flags.text =
'131072'
3298 Data = SubElement(EPItem,
'Data')
3299 Data.text =
'30/12/1899'
3300 AdrInternet = SubElement(EPItem,
'AdrInternet')
3301 AdrInternet.text =
''
3302 PweEPAnalisi = SubElement(EPItem,
'PweEPAnalisi')
3303 PweEPAR = SubElement(PweEPAnalisi,
'PweEPAR')
3305 for x
in range(m, m + 100):
3306 if oSheet.getCellByPosition(
3307 0, x).CellStyle ==
'An-lavoraz-desc':
3308 EPARItem = SubElement(PweEPAR,
'EPARItem')
3309 EPARItem.set(
'ID', str(nEPARItem))
3311 Tipo = SubElement(EPARItem,
'Tipo')
3313 IDEP = SubElement(EPARItem,
'IDEP')
3314 IDEP.text = diz_ep.get(
3315 oSheet.getCellByPosition(0, x).String)
3316 if IDEP.text
is None:
3318 Descrizione = SubElement(EPARItem,
'Descrizione')
3319 if '=IF(' in oSheet.getCellByPosition(1, x).String:
3320 Descrizione.text =
''
3322 Descrizione.text = oSheet.getCellByPosition(
3324 Misura = SubElement(EPARItem,
'Misura')
3326 Qt = SubElement(EPARItem,
'Qt')
3328 Prezzo = SubElement(EPARItem,
'Prezzo')
3330 FieldCTL = SubElement(EPARItem,
'FieldCTL')
3332 if(oSheet.getCellByPosition(0, x).CellStyle ==
'An-lavoraz-Cod-sx' and
3333 oSheet.getCellByPosition(1, x).String !=
''):
3334 EPARItem = SubElement(PweEPAR,
'EPARItem')
3335 EPARItem.set(
'ID', str(nEPARItem))
3337 Tipo = SubElement(EPARItem,
'Tipo')
3339 IDEP = SubElement(EPARItem,
'IDEP')
3340 IDEP.text = diz_ep.get(
3341 oSheet.getCellByPosition(0, x).String)
3342 if IDEP.text
is None:
3344 Descrizione = SubElement(EPARItem,
'Descrizione')
3345 if '=IF(' in oSheet.getCellByPosition(1, x).String:
3346 Descrizione.text =
''
3348 Descrizione.text = oSheet.getCellByPosition(
3350 Misura = SubElement(EPARItem,
'Misura')
3351 Misura.text = oSheet.getCellByPosition(2, x).String
3352 Qt = SubElement(EPARItem,
'Qt')
3353 Qt.text = oSheet.getCellByPosition(3,
3356 Prezzo = SubElement(EPARItem,
'Prezzo')
3358 oSheet.getCellByPosition(4, x).Value).replace(
3360 FieldCTL = SubElement(EPARItem,
'FieldCTL')
3362 elif oSheet.getCellByPosition(
3363 0, x).CellStyle ==
'An-sfondo-basso Att End':
3366 IncSIC = SubElement(EPItem,
'IncSIC')
3367 if oSheet.getCellByPosition(10, n).Value == 0.0:
3370 IncSIC.text = str(oSheet.getCellByPosition(10, n).Value)
3372 IncMDO = SubElement(EPItem,
'IncMDO')
3373 if oSheet.getCellByPosition(8, n).Value == 0.0:
3377 oSheet.getCellByPosition(5, n).Value * 100)
3382 if elaborato ==
'Elenco_Prezzi':
3386 oSheet = oDoc.getSheets().getByName(elaborato)
3387 PweVociComputo = SubElement(PweMisurazioni,
'PweVociComputo')
3388 oDoc.CurrentController.setActiveSheet(oSheet)
3391 progress.setValue(6)
3394 progress.setValue(n)
3395 if oSheet.getCellByPosition(0,
3396 n).CellStyle
in (
'Comp Start Attributo',
3397 'Comp Start Attributo_R'):
3399 sStRange.RangeAddress
3400 sopra = sStRange.RangeAddress.StartRow
3401 sotto = sStRange.RangeAddress.EndRow
3402 if elaborato ==
'CONTABILITA':
3404 VCItem = SubElement(PweVociComputo,
'VCItem')
3405 VCItem.set(
'ID', str(nVCItem))
3408 IDEP = SubElement(VCItem,
'IDEP')
3409 IDEP.text = diz_ep.get(
3410 oSheet.getCellByPosition(1, sopra + 1).String)
3412 Quantita = SubElement(VCItem,
'Quantita')
3413 Quantita.text = oSheet.getCellByPosition(9, sotto).String
3415 DataMis = SubElement(VCItem,
'DataMis')
3416 if elaborato ==
'CONTABILITA':
3417 DataMis.text = oSheet.getCellByPosition(1, sopra + 2).String
3419 DataMis.text =
oggi()
3420 vFlags = SubElement(VCItem,
'Flags')
3423 IDSpCat = SubElement(VCItem,
'IDSpCat')
3424 IDSpCat.text = str(oSheet.getCellByPosition(31, sotto).String)
3425 if elaborato ==
'CONTABILITA':
3426 IDSpCat.text = str(oSheet.getCellByPosition(31, sotto + 1).String)
3427 if IDSpCat.text ==
'':
3430 IDCat = SubElement(VCItem,
'IDCat')
3431 IDCat.text = str(oSheet.getCellByPosition(32, sotto).String)
3432 if elaborato ==
'CONTABILITA':
3433 IDCat.text = str(oSheet.getCellByPosition(32, sotto + 1).String)
3434 if IDCat.text ==
'':
3437 IDSbCat = SubElement(VCItem,
'IDSbCat')
3438 IDSbCat.text = str(oSheet.getCellByPosition(33, sotto).String)
3439 if elaborato ==
'CONTABILITA':
3440 IDSbCat.text = str(oSheet.getCellByPosition(33, sotto + 1).String)
3441 if IDSbCat.text ==
'':
3444 PweVCMisure = SubElement(VCItem,
'PweVCMisure')
3446 for m
in range(sopra + 2, sotto):
3447 RGItem = SubElement(PweVCMisure,
'RGItem')
3448 RGItem.set(
'ID', str(x))
3451 IDVV = SubElement(RGItem,
'IDVV')
3454 Descrizione = SubElement(RGItem,
'Descrizione')
3455 Descrizione.text = oSheet.getCellByPosition(2, m).String
3457 PartiUguali = SubElement(RGItem,
'PartiUguali')
3458 PartiUguali.text =
valuta_cella(oSheet.getCellByPosition(5, m))
3460 Lunghezza = SubElement(RGItem,
'Lunghezza')
3461 Lunghezza.text =
valuta_cella(oSheet.getCellByPosition(6, m))
3463 Larghezza = SubElement(RGItem,
'Larghezza')
3464 Larghezza.text =
valuta_cella(oSheet.getCellByPosition(7, m))
3466 HPeso = SubElement(RGItem,
'HPeso')
3467 HPeso.text =
valuta_cella(oSheet.getCellByPosition(8, m))
3469 Quantita = SubElement(RGItem,
'Quantita')
3470 Quantita.text = str(oSheet.getCellByPosition(9, m).Value)
3473 if oSheet.getCellByPosition(4, m).Value < 0:
3475 if elaborato ==
'CONTABILITA':
3476 if oSheet.getCellByPosition(11, m).Value != 0:
3477 Quantita.text =
'-' + str(oSheet.getCellByPosition(11, m).Value)
3479 Flags = SubElement(RGItem,
'Flags')
3480 if '*** VOCE AZZERATA ***' in Descrizione.text:
3481 PartiUguali.text = str(
3485 elif '-' in Quantita.text
or oSheet.getCellByPosition(
3488 elif "Parziale [" in oSheet.getCellByPosition(8, m).String:
3491 elif 'PARTITA IN CONTO PROVVISORIO' in Descrizione.text:
3496 if 'DETRAE LA PARTITA IN CONTO PROVVISORIO' in Descrizione.text:
3498 if '- vedi voce n.' in Descrizione.text:
3501 Descrizione.text.split(
'- vedi voce n.')[1].split(
3503 Flags.text =
'32768'
3504 Descrizione.text =
''
3506 if oSheet.getCellByPosition(4, m).Value < 0
and \
3507 oSheet.getCellByPosition(11, m).Value != 0:
3508 Flags.text =
'32768'
3509 if oSheet.getCellByPosition(4, m).Value > 0
and \
3510 oSheet.getCellByPosition(11, m).Value != 0:
3511 Flags.text =
'32769'
3512 if oSheet.getCellByPosition(4, m).Value > 0
and \
3513 oSheet.getCellByPosition(10, m).Value != 0:
3514 Flags.text =
'32768'
3521 if cfg.read(
'Generale',
'dettaglio') ==
'1':
3524 if out_file.split(
'.')[-1].upper() !=
'XPWE':
3525 out_file = out_file +
'-' + elaborato +
'.xpwe'
3526 FileNameDocumento.text = out_file
3527 except AttributeError:
3529 riga = str(tostring(top, encoding=
"unicode"))
3534 of = codecs.open(out_file,
'w',
'utf-8')
3540 Text=
''' Esportazione non eseguita!
3541 Verifica che il file di destinazione non sia già in uso!''')
3552 Inserisce(in COMPUTO o VARIANTE) un riepilogo delle categorie
3553 ed i dati necessari alle firme
3557 oSheet = oDoc.CurrentController.ActiveSheet
3558 oSheet_S2 = oDoc.getSheets().getByName(
'S2')
3560 datafirme = oSheet_S2.getCellRangeByName(
'$S2.C4').String
3565 datafirme = datafirme +
", "
3566 if oSheet.Name ==
"CONTABILITA":
3569 oSheet.getRows().insertByIndex(lrowF, 11)
3570 riga_corrente = lrowF + 1
3574 oSheet.getCellByPosition(2 , riga_corrente).Formula = (
3575 '=CONCATENATE("' + datafirme +
'";TEXT(NOW();"GG/mm/aaaa"))')
3576 oSheet.getCellByPosition(2 , riga_corrente + 2).Formula = (
3577 "L'Impresa esecutrice\n(" + oSheet_S2.getCellByPosition(
3578 2, 16).String +
")")
3579 oSheet.getCellByPosition(2 , riga_corrente + 6).Formula = (
3580 "Il Direttore dei Lavori\n(" + oSheet_S2.getCellByPosition(
3581 2, 15).String +
")")
3584 oRange = oSheet.getCellRangeByPosition (2, riga_corrente, 40, riga_corrente)
3585 aSaveData = oRange.getDataArray()
3586 oRange.setDataArray(aSaveData)
3587 if oSheet.Name
in (
"Registro",
"SAL"):
3591 oSheet.getRows().insertByIndex(lrowF, 13)
3592 riga_corrente = lrowF + 1
3593 oSheet.getCellByPosition(1 , riga_corrente).Formula =
'=CONCATENATE("' + datafirme +
'";TEXT(NOW();"GG/mm/aaaa"))'
3595 oRange = oSheet.getCellRangeByPosition (1, riga_corrente, 40, riga_corrente)
3596 aSaveData = oRange.getDataArray()
3597 oRange.setDataArray(aSaveData)
3599 oSheet.getCellByPosition(1, riga_corrente + 2).Formula = (
3600 "L'Impresa esecutrice\n(" + oSheet_S2.getCellRangeByName(
3601 '$S2.C17').String +
")")
3603 oSheet.getCellByPosition(1, riga_corrente + 6).Formula = (
3604 "Il Direttore dei Lavori\n(" + oSheet_S2.getCellRangeByName(
3605 '$S2.C16').String +
")")
3606 oSheet.getCellRangeByPosition (0, riga_corrente + 2, 5,riga_corrente + 6).Rows.OptimalHeight =
True
3607 if oSheet.Name ==
"SAL":
3610 for i
in reversed(range(2, 50)):
3611 if oDoc.NamedRanges.hasByName(
"_Lib_" + str(i)):
3614 oSheet.getCellByPosition(1, riga_corrente + 10).Formula = (
3615 '=CONCATENATE("In data ";TEXT(NOW();"DD/MM/YYYY");" è stato emesso il CERTIFICATO DI PAGAMENTO n.' + str(nSal) +
' per un importo di €")')
3618 oRange = oSheet.getCellRangeByPosition (1, riga_corrente + 10, 40, riga_corrente + 10)
3620 aSaveData = oRange.getDataArray()
3621 oRange.setDataArray(aSaveData)
3623 oSheet.getCellByPosition(1 , riga_corrente + 12).Formula = (
3624 "Il Direttore dei Lavori\n(" + oSheet_S2.getCellRangeByName(
3625 '$S2.C16').String +
")")
3626 if oSheet.Name
in (
'Analisi di Prezzo',
'Elenco Prezzi'):
3629 oDoc.CurrentController.setFirstVisibleRow(lrowF - 1)
3632 if oSheet.getCellByPosition(0, i).CellStyle ==
"Riga_rossa_Chiudi":
3635 if lrowE > lrowF + 1:
3636 oSheet.getRows().removeByIndex(lrowF, lrowE - lrowF)
3637 riga_corrente = lrowF + 1
3638 oSheet.getRows().insertByIndex(lrowF, 15)
3639 oSheet.getCellRangeByPosition(0, lrowF, 100, lrowF + 15 -
3640 1).CellStyle =
"Ultimus_centro"
3641 oSheet.getCellRangeByPosition(0, lrowF + 15 - 1, 100, lrowF + 15 -
3642 1).CellStyle =
"Comp-Bianche in mezzo Descr_R"
3644 iSheet = oSheet.RangeAddress.Sheet
3645 oCellRangeAddr = uno.createUnoStruct(
3646 'com.sun.star.table.CellRangeAddress')
3647 oCellRangeAddr.Sheet = iSheet
3648 oCellRangeAddr.StartColumn = 0
3649 oCellRangeAddr.EndColumn = 0
3650 oCellRangeAddr.StartRow = lrowF
3651 oCellRangeAddr.EndRow = lrowF + 15 - 1
3652 oSheet.group(oCellRangeAddr, 1)
3655 oSheet.getCellByPosition(
3657 3).Formula =
'=CONCATENATE("Data, ";TEXT(NOW();"GG/MM/AAAA"))'
3660 oRange = oSheet.getCellByPosition(1, riga_corrente + 3)
3662 aSaveData = oRange.getDataArray()
3663 oRange.setDataArray(aSaveData)
3664 oSheet.getCellRangeByPosition(1, riga_corrente + 3, 1,
3665 riga_corrente + 3).CellStyle =
'ULTIMUS'
3666 oSheet.getCellByPosition(1,
3667 riga_corrente + 5).Formula =
'Il Progettista'
3668 oSheet.getCellByPosition(
3669 1, riga_corrente + 6
3670 ).Formula =
'=CONCATENATE($S2.$C$13)'
3672 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CompuM_NoP'):
3675 oDoc.CurrentController.setFirstVisibleRow(lrowF - 2)
3678 if oSheet.getCellByPosition(0, i).CellStyle ==
"Riga_rossa_Chiudi":
3681 if lrowE > lrowF + 1:
3682 oSheet.getRows().removeByIndex(lrowF, lrowE - lrowF)
3683 riga_corrente = lrowF + 2
3684 if oDoc.getSheets().hasByName(
'S2'):
3698 oSheet.getRows().insertByIndex(lrowF, 17)
3699 oSheet.getCellRangeByPosition(0, lrowF, ss,
3700 lrowF + 17 - 1).CellStyle =
'ULTIMUS'
3702 iSheet = oSheet.RangeAddress.Sheet
3703 oCellRangeAddr = uno.createUnoStruct(
3704 'com.sun.star.table.CellRangeAddress')
3705 oCellRangeAddr.Sheet = iSheet
3706 oCellRangeAddr.StartColumn = 0
3707 oCellRangeAddr.EndColumn = 0
3708 oCellRangeAddr.StartRow = lrowF
3709 oCellRangeAddr.EndRow = lrowF + 17 - 1
3710 oSheet.group(oCellRangeAddr, 1)
3713 oSheet.getCellByPosition(
3714 2, riga_corrente).String =
'Riepilogo strutturale delle Categorie'
3715 oSheet.getCellByPosition(ii, riga_corrente).String =
'Incidenze %'
3716 oSheet.getCellByPosition(vv, riga_corrente).String =
'Importi €'
3717 oSheet.getCellByPosition(ac,
3718 riga_corrente).String =
'Materiali\ne Noli €'
3719 oSheet.getCellByPosition(ad, riga_corrente).String =
'Incidenza\nMDO %'
3720 oSheet.getCellByPosition(ae, riga_corrente).String =
'Importo\nMDO €'
3721 inizio_gruppo = riga_corrente
3725 progress =
Dialogs.Progress(Title=
'Esecuzione in corso...', Text=
"Composizione del riepilogo strutturale.")
3728 progress.setValue(i)
3730 for i
in range(0, lrowF):
3731 progress.setValue(i)
3733 if oSheet.getCellByPosition(1, i).CellStyle ==
'Livello-0-scritta':
3734 oSheet.getRows().insertByIndex(riga_corrente, 1)
3735 oSheet.getCellRangeByPosition(
3736 0, riga_corrente, 30,
3737 riga_corrente).CellStyle =
'ULTIMUS_1'
3738 oSheet.getCellByPosition(
3739 1, riga_corrente).Formula =
'=B' + str(i + 1)
3740 oSheet.getCellByPosition(
3741 1, riga_corrente).CellStyle =
'Ultimus_destra_1'
3742 oSheet.getCellByPosition(
3743 2, riga_corrente).Formula =
'=C' + str(i + 1)
3744 oSheet.getCellByPosition(
3745 ii, riga_corrente).Formula =
'=' + col + str(
3746 riga_corrente + 1) +
'/' + col + str(lrowF) +
'*100'
3747 oSheet.getCellByPosition(
3748 ii, riga_corrente).CellStyle =
'Ultimus %_1'
3749 oSheet.getCellByPosition(
3750 vv, riga_corrente).Formula =
'=' + col + str(i + 1)
3751 oSheet.getCellRangeByPosition(
3752 vv, riga_corrente, ae,
3753 riga_corrente).CellStyle =
'Ultimus_totali_1'
3754 oSheet.getCellByPosition(
3755 ac, riga_corrente).Formula =
'=AC' + str(i + 1)
3756 oSheet.getCellByPosition(
3757 ad, riga_corrente).Formula =
'=AD' + str(i + 1) +
'*100'
3758 oSheet.getCellByPosition(
3759 ad, riga_corrente).CellStyle =
'Ultimus %_1'
3760 oSheet.getCellByPosition(
3761 ae, riga_corrente).Formula =
'=AE' + str(i + 1)
3763 elif oSheet.getCellByPosition(1,
3764 i).CellStyle ==
'Livello-1-scritta':
3765 oSheet.getRows().insertByIndex(riga_corrente, 1)
3766 oSheet.getCellRangeByPosition(
3767 0, riga_corrente, 30,
3768 riga_corrente).CellStyle =
'ULTIMUS_2'
3769 oSheet.getCellByPosition(
3770 1, riga_corrente).Formula =
'=B' + str(i + 1)
3771 oSheet.getCellByPosition(
3772 1, riga_corrente).CellStyle =
'Ultimus_destra'
3773 oSheet.getCellByPosition(
3774 2, riga_corrente).Formula =
'=C' + str(i + 1)
3775 oSheet.getCellByPosition(
3776 ii, riga_corrente).Formula =
'=' + col + str(
3777 riga_corrente + 1) +
'/' + col + str(lrowF) +
'*100'
3778 oSheet.getCellByPosition(ii,
3779 riga_corrente).CellStyle =
'Ultimus %'
3780 oSheet.getCellByPosition(
3781 vv, riga_corrente).Formula =
'=' + col + str(i + 1)
3782 oSheet.getCellByPosition(
3783 vv, riga_corrente).CellStyle =
'Ultimus_bordo'
3784 oSheet.getCellByPosition(
3785 ac, riga_corrente).Formula =
'=AC' + str(i + 1)
3786 oSheet.getCellByPosition(
3787 ad, riga_corrente).Formula =
'=AD' + str(i + 1) +
'*100'
3788 oSheet.getCellByPosition(ad,
3789 riga_corrente).CellStyle =
'Ultimus %'
3790 oSheet.getCellByPosition(
3791 ae, riga_corrente).Formula =
'=AE' + str(i + 1)
3793 elif oSheet.getCellByPosition(1, i).CellStyle ==
'livello2 valuta':
3794 oSheet.getRows().insertByIndex(riga_corrente, 1)
3795 oSheet.getCellRangeByPosition(
3796 0, riga_corrente, 30,
3797 riga_corrente).CellStyle =
'ULTIMUS_3'
3798 oSheet.getCellByPosition(
3799 1, riga_corrente).Formula =
'=B' + str(i + 1)
3800 oSheet.getCellByPosition(
3801 1, riga_corrente).CellStyle =
'Ultimus_destra_3'
3802 oSheet.getCellByPosition(
3803 2, riga_corrente).Formula =
'=C' + str(i + 1)
3804 oSheet.getCellByPosition(
3805 ii, riga_corrente).Formula =
'=' + col + str(
3806 riga_corrente + 1) +
'/' + col + str(lrowF) +
'*100'
3807 oSheet.getCellByPosition(
3808 ii, riga_corrente).CellStyle =
'Ultimus %_3'
3809 oSheet.getCellByPosition(
3810 vv, riga_corrente).Formula =
'=' + col + str(i + 1)
3811 oSheet.getCellByPosition(vv,
3812 riga_corrente).CellStyle =
'ULTIMUS_3'
3813 oSheet.getCellByPosition(
3814 ac, riga_corrente).Formula =
'=AC' + str(i + 1)
3815 oSheet.getCellByPosition(
3816 ad, riga_corrente).Formula =
'=AD' + str(i + 1) +
'*100'
3817 oSheet.getCellByPosition(
3818 ad, riga_corrente).CellStyle =
'Ultimus %_3'
3819 oSheet.getCellByPosition(
3820 ae, riga_corrente).Formula =
'=AE' + str(i + 1)
3823 oSheet.getCellRangeByPosition(
3824 2, inizio_gruppo, ae, inizio_gruppo).CellStyle =
"Ultimus_centro"
3825 oSheet.getCellByPosition(ii, riga_corrente).Value = 100
3826 oSheet.getCellByPosition(2, riga_corrente).CellStyle =
'Ultimus_destra'
3827 oSheet.getCellByPosition(ii, riga_corrente).CellStyle =
'Ultimus %_1'
3828 oSheet.getCellByPosition(
3829 vv, riga_corrente).Formula =
'=' + col + str(lrowF)
3830 oSheet.getCellByPosition(
3831 vv, riga_corrente).CellStyle =
'Ultimus_Bordo_sotto'
3832 oSheet.getCellByPosition(ac,
3833 riga_corrente).Formula =
'=AC' + str(lrowF)
3834 oSheet.getCellByPosition(
3835 ac, riga_corrente).CellStyle =
'Ultimus_Bordo_sotto'
3836 oSheet.getCellByPosition(ae,
3837 riga_corrente).Formula =
'=AE' + str(lrowF)
3838 oSheet.getCellByPosition(
3839 ae, riga_corrente).CellStyle =
'Ultimus_Bordo_sotto'
3840 oSheet.getCellByPosition(
3841 ad, riga_corrente).Formula =
'=AD' + str(lrowF) +
'*100'
3842 oSheet.getCellByPosition(
3843 2, riga_corrente).String =
' T O T A L E €'
3844 oSheet.getCellByPosition(2, riga_corrente).CellStyle =
'ULTIMUS_1'
3847 oSheet.getCellByPosition(
3849 3).Formula =
'=CONCATENATE("Data, ";TEXT(NOW();"GG/MM/AAAA"))'
3851 oRange = oSheet.getCellByPosition(2, riga_corrente + 3)
3854 aSaveData = oRange.getDataArray()
3855 oRange.setDataArray(aSaveData)
3857 oSheet.getCellByPosition(2,
3858 riga_corrente + 5).Formula =
'Il Progettista'
3859 oSheet.getCellByPosition(
3860 2, riga_corrente + 6
3861 ).Formula =
'=CONCATENATE($S2.$C$13)'
3862 oSheet.getCellRangeByPosition(2, riga_corrente + 5, 2, riga_corrente +
3863 6).CellStyle =
'Ultimus_centro'
3866 oDoc.CurrentController.select(oSheet.getCellByPosition(0, lrowF))
3869 oFrame = desktop.getCurrentFrame()
3870 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
3871 'com.sun.star.frame.DispatchHelper', ctx)
3872 dispatchHelper.executeDispatch(oFrame,
".uno:InsertRowBreak",
"", 0, list())
3873 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
3883 cancella le voci in Elenco Prezzi che derivano da analisi
3886 oSheet = oDoc.CurrentController.ActiveSheet
3887 oSheet = oDoc.Sheets.getByName(
'Analisi di Prezzo')
3890 if oSheet.getCellByPosition(0, i).CellStyle ==
'An-1_sigla':
3892 lista_an.append(oSheet.getCellByPosition(0, i).String)
3893 oSheet = oDoc.Sheets.getByName(
'Elenco Prezzi')
3895 if oSheet.getCellByPosition(0, i).String
in lista_an:
3896 oSheet.getRows().removeByIndex(i, 1)
3905 oSheet = oDoc.CurrentController.ActiveSheet
3906 if oSheet.Name !=
'Analisi di Prezzo':
3908 oDoc.enableAutomaticCalculation(
False)
3910 riga = sStRange.RangeAddress.StartRow + 2
3912 codice = oSheet.getCellByPosition(0, riga).String
3914 oSheet = oDoc.Sheets.getByName(
'Elenco Prezzi')
3915 oDoc.CurrentController.setActiveSheet(oSheet)
3917 oSheet.getRows().insertByIndex(3, 1)
3919 oSheet.getCellByPosition(0, 3).CellStyle =
'EP-aS'
3920 oSheet.getCellByPosition(1, 3).CellStyle =
'EP-a'
3921 oSheet.getCellRangeByPosition(2, 3, 8, 3).CellStyle =
'EP-mezzo'
3922 oSheet.getCellByPosition(5, 3).CellStyle =
'EP-mezzo %'
3923 oSheet.getCellByPosition(9, 3).CellStyle =
'EP-sfondo'
3924 oSheet.getCellByPosition(10, 3).CellStyle =
'Default'
3925 oSheet.getCellByPosition(11, 3).CellStyle =
'EP-mezzo %'
3926 oSheet.getCellByPosition(12, 3).CellStyle =
'EP statistiche_q'
3927 oSheet.getCellByPosition(13, 3).CellStyle =
'EP statistiche_Contab_q'
3929 oSheet.getCellByPosition(0, 3).String = codice
3931 oSheet.getCellByPosition(
3932 1, 3).Formula =
"=$'Analisi di Prezzo'.B" + str(riga + 1)
3933 oSheet.getCellByPosition(
3934 2, 3).Formula =
"=$'Analisi di Prezzo'.C" + str(riga + 1)
3935 oSheet.getCellByPosition(
3936 3, 3).Formula =
"=$'Analisi di Prezzo'.K" + str(riga + 1)
3937 oSheet.getCellByPosition(
3938 4, 3).Formula =
"=$'Analisi di Prezzo'.G" + str(riga + 1)
3939 oSheet.getCellByPosition(
3940 5, 3).Formula =
"=$'Analisi di Prezzo'.I" + str(riga + 1)
3941 oSheet.getCellByPosition(
3942 6, 3).Formula =
"=$'Analisi di Prezzo'.J" + str(riga + 1)
3943 oSheet.getCellByPosition(
3944 7, 3).Formula =
"=$'Analisi di Prezzo'.A" + str(riga + 1)
3945 oSheet.getCellByPosition(8, 3).String =
"(AP)"
3946 oSheet.getCellByPosition(11, 3).Formula =
"=N4/$N$2"
3947 oSheet.getCellByPosition(12, 3).Formula =
"=SUMIF(AA;A4;BB)"
3948 oSheet.getCellByPosition(13, 3).Formula =
"=SUMIF(AA;A4;cEuro)"
3949 oDoc.enableAutomaticCalculation(
True)
3953 oDoc.enableAutomaticCalculation(
True)
3959 Invia le analisi all'Elenco Prezzi.
3965 lista_analisi = list()
3966 oSheet = oDoc.getSheets().getByName(
'Analisi di prezzo')
3972 if oSheet.getCellByPosition(
3974 ).CellStyle ==
'An-1_sigla' and oSheet.getCellByPosition(
3976 ).String !=
'<<<Scrivi la descrizione della nuova voce da analizzare ':
3978 oSheet.getCellByPosition(0, n).String,
3979 "=$'Analisi di Prezzo'.B" + str(n + 1),
3980 "=$'Analisi di Prezzo'.C" + str(n + 1),
3981 "=$'Analisi di Prezzo'.K" + str(n + 1),
3982 "=$'Analisi di Prezzo'.G" + str(n + 1),
3983 "=$'Analisi di Prezzo'.I" + str(n + 1),
3986 "=$'Analisi di Prezzo'.A" + str(n + 1),
3990 "=N" + str(idx) +
"/$N$2",
3991 "=SUMIF(AA;A" + str(idx) +
";BB)",
3992 "=SUMIF(AA;A" + str(idx) +
";cEuro)",
3994 lista_analisi.append(voce)
3996 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
3997 if len(lista_analisi) != 0:
3998 oSheet.getRows().insertByIndex(3, len(lista_analisi))
4001 oRange = oSheet.getCellRangeByPosition(0, 3, 13,
4002 3 + len(lista_analisi) - 1)
4003 lista_come_array = tuple(lista_analisi)
4004 oRange.setDataArray(
4007 for y
in range(3, 3 + len(lista_analisi)):
4009 1, len(lista_analisi[0])
4011 oSheet.getCellByPosition(x, y).Formula = oSheet.getCellByPosition(
4013 oSheet.getCellRangeByPosition(0, 3, 0, 3 + len(lista_analisi) -
4014 1).CellStyle =
'EP-aS'
4015 oSheet.getCellRangeByPosition(1, 3, 1, 3 + len(lista_analisi) -
4016 1).CellStyle =
'EP-a'
4017 oSheet.getCellRangeByPosition(2, 3, 8, 3 + len(lista_analisi) -
4018 1).CellStyle =
'EP-mezzo'
4019 oSheet.getCellRangeByPosition(5, 3, 5, 3 + len(lista_analisi) -
4020 1).CellStyle =
'EP-mezzo %'
4021 oSheet.getCellRangeByPosition(9, 3, 9, 3 + len(lista_analisi) -
4022 1).CellStyle =
'EP-sfondo'
4023 oSheet.getCellRangeByPosition(10, 3, 10, 3 + len(lista_analisi) -
4024 1).CellStyle =
'Default'
4025 oSheet.getCellRangeByPosition(11, 3, 11, 3 + len(lista_analisi) -
4026 1).CellStyle =
'EP-mezzo %'
4027 oSheet.getCellRangeByPosition(12, 3, 12, 3 + len(lista_analisi) -
4028 1).CellStyle =
'EP statistiche_q'
4029 oSheet.getCellRangeByPosition(13, 3, 13, 3 + len(lista_analisi) -
4030 1).CellStyle =
'EP statistiche_Contab_q'
4040 @@@ MODIFICA IN CORSO CON 'LeenoAnalysis.circoscriveAnalisi'
4041 lrow { int } : riga di riferimento per
4042 la selezione dell'intera voce
4043 Circoscrive una voce di analisi
4044 partendo dalla posizione corrente del cursore
4047 oSheet = oDoc.CurrentController.ActiveSheet
4049 if oSheet.getCellByPosition(0, lrow).CellStyle
in stili_analisi:
4050 for el
in reversed(range(0, lrow)):
4052 if oSheet.getCellByPosition(0, el).CellStyle ==
'Analisi_Sfondo':
4056 if oSheet.getCellByPosition(
4057 0, el).CellStyle ==
'An-sfondo-basso Att End':
4060 celle = oSheet.getCellRangeByPosition(0, SR, 250, ER)
4067 '''Trasforma IDcolonna in Nome'''
4070 oColumns = oSheet.getColumns()
4071 oColumn = oColumns.getByIndex(cColumnNumb).Name
4077 '''Trasforma il nome colonna in IDcolonna'''
4080 oColumns = oSheet.getColumns()
4081 oColumn = oColumns.getByName(cColumnName)
4082 oRangeAddress = oColumn.getRangeAddress()
4083 nColumn = oRangeAddress.StartColumn
4090 Azzera la quantità di una voce e ne raggruppa le relative righe
4096 oSheet = oDoc.CurrentController.ActiveSheet
4097 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
4099 sRow = oDoc.getCurrentSelection().getRangeAddresses(
4101 eRow = oDoc.getCurrentSelection().getRangeAddresses()[0].EndRow
4104 sRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
4105 eRow = oDoc.getCurrentSelection().getRangeAddress().EndRow
4107 sStRange.RangeAddress
4108 sRow = sStRange.RangeAddress.StartRow
4111 sStRange.RangeAddress
4114 inizio = sStRange.RangeAddress.StartRow
4115 eRow = sStRange.RangeAddress.EndRow + 1
4119 for x
in range(sRow, eRow):
4120 if oSheet.getCellByPosition(
4121 0, x).CellStyle ==
'Comp End Attributo':
4123 elif oSheet.getCellByPosition(
4124 0, x).CellStyle ==
'Comp End Attributo_R':
4127 for lrow
in reversed(fini):
4131 sStRange.RangeAddress
4132 inizio = sStRange.RangeAddress.StartRow
4133 fine = sStRange.RangeAddress.EndRow
4134 if oSheet.Name ==
'CONTABILITA':
4136 _gotoCella(2, fine - 1)
4137 if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, fine - 1).String:
4139 if oSheet.Name ==
'CONTABILITA':
4140 oSheet.getCellRangeByPosition(
4141 0, inizio, 250, fine + 1).clearContents(HARDATTR)
4143 oSheet.getCellRangeByPosition(
4144 0, inizio, 250, fine).clearContents(HARDATTR)
4146 oSheet.getRows().removeByIndex(fine - 1, 1)
4148 _gotoCella(2, fine - 1)
4152 oSheet.getCellByPosition(2, fine).String =
'*** VOCE AZZERATA ***'
4153 if oSheet.Name ==
'CONTABILITA':
4154 oSheet.getCellByPosition(
4155 5, fine).Formula =
'=SUBTOTAL(9;J' + str(
4156 inizio + 1) +
':J' + str(
4157 fine) +
')-SUBTOTAL(9;L' + str(
4158 inizio + 1) +
':L' + str(fine) +
')'
4160 oSheet.getCellByPosition(
4161 5, fine).Formula =
'=SUBTOTAL(9;J' + str(
4162 inizio + 1) +
':J' + str(fine) +
')'
4165 oDoc.CurrentController.select(sStRange)
4169 oFrame = desktop.getCurrentFrame()
4170 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
4171 'com.sun.star.frame.DispatchHelper', ctx)
4172 oProp = PropertyValue()
4173 oProp.Name =
'BackgroundColor'
4174 oProp.Value = 15066597
4175 properties = (oProp, )
4176 dispatchHelper.executeDispatch(oFrame,
'.uno:BackgroundColor',
'', 0, properties)
4193 Elimina le voci in cui compare la dicitura '*** VOCE AZZERATA ***'
4194 in COMPUTO o in VARIANTE, senza chiedere conferma
4197 oSheet = oDoc.CurrentController.ActiveSheet
4199 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
4202 progress =
Dialogs.Progress(Title=
'Esecuzione in corso...', Text=
"Cancellazione voci azzerate")
4205 progress.setValue(n)
4207 for lrow
in reversed(range(0, ER)):
4209 progress.setValue(n)
4212 if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, lrow).String:
4225 Raggruppa le righe che compongono una singola voce.
4228 oSheet = oDoc.CurrentController.ActiveSheet
4230 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4232 sStRange.RangeAddress
4234 iSheet = oSheet.RangeAddress.Sheet
4235 oCellRangeAddr = uno.createUnoStruct(
4236 'com.sun.star.table.CellRangeAddress')
4237 oCellRangeAddr.Sheet = iSheet
4238 oCellRangeAddr.StartColumn = sStRange.RangeAddress.StartColumn
4239 oCellRangeAddr.EndColumn = sStRange.RangeAddress.EndColumn
4240 oCellRangeAddr.StartRow = sStRange.RangeAddress.StartRow
4241 oCellRangeAddr.EndRow = sStRange.RangeAddress.EndRow
4243 oSheet.group(oCellRangeAddr, 1)
4245 oSheet.ungroup(oCellRangeAddr, 1)
4251 Nasconde le voci in cui compare la dicitura '*** VOCE AZZERATA ***'
4252 in COMPUTO o in VARIANTE.
4255 oSheet = oDoc.CurrentController.ActiveSheet
4257 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4259 for lrow
in reversed(range(0, ER)):
4260 if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, lrow).String:
4269 Seleziona voci intere
4272 oSheet = oDoc.CurrentController.ActiveSheet
4278 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4279 except AttributeError:
4280 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4281 if oSheet.Name
in (
'Elenco Prezzi'):
4287 for el
in oRangeAddress:
4288 el_y.append((el.StartRow, el.EndRow))
4290 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4292 for el
in range(y[0], y[1] + 1):
4296 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'Analisi di Prezzo'):
4298 if lrow
is not None:
4299 SR = oRangeAddress.StartRow
4303 except AttributeError:
4306 Text=
'''La selezione deve essere contigua.''')
4308 if lrow
is not None:
4309 ER = oRangeAddress.EndRow
4333 if oSheet.Name ==
'CONTABILITA':
4335 if partenza[2] ==
'#reg':
4343 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4344 except AttributeError:
4345 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4347 if lrow
is not None:
4348 SR = oRangeAddress.StartRow
4352 except AttributeError:
4355 Text=
'''La selezione deve essere contigua.''')
4357 if lrow
is not None:
4358 ER = oRangeAddress.EndRow
4369 @@@ MODIFICA IN CORSO CON 'LeenoSheetUtils.selezionaVoce'
4370 Restituisce inizio e fine riga di una voce in COMPUTO, VARIANTE,
4371 CONTABILITA o Analisi di Prezzo
4372 lrow { long } : numero riga
4375 oSheet = oDoc.CurrentController.ActiveSheet
4376 if lrow
is None or lrow == 0:
4378 if oSheet.Name
in (
'Elenco Prezzi'):
4381 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4383 elif oSheet.Name ==
'Analisi di Prezzo':
4386 if oSheet.Name ==
'CONTABILITA':
4388 if partenza[2] ==
'#reg':
4400 sStRange.RangeAddress
4401 SR = sStRange.RangeAddress.StartRow
4402 ER = sStRange.RangeAddress.EndRow
4422 Elimina le righe selezionate anche se non contigue.
4425 oDoc.enableAutomaticCalculation(
False)
4426 oSheet = oDoc.CurrentController.ActiveSheet
4428 if oSheet.Name ==
'Elenco Prezzi':
4429 Dialogs.Info(Title =
'Info', Text=
"""Per eliminare una o più voci dall'Elenco Prezzi
4430 devi selezionarle ed utilizzare il comando 'Elimina righe' di Calc.""")
4433 if oSheet.Name
not in (
'COMPUTO',
'CONTABILITA',
'VARIANTE',
'Analisi di Prezzo'):
4437 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4438 except AttributeError:
4439 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4444 for el
in oRangeAddress:
4445 el_y.append((el.StartRow, el.EndRow))
4447 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4449 for el
in range(y[0], y[1] + 1):
4451 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
4453 for y
in reversed(lista_y):
4454 if oSheet.getCellByPosition(2, y).CellStyle
not in (
'An-lavoraz-generica',
4455 'An-lavoraz-Cod-sx',
4458 'comp sotto centro',
4460 'Livello-0-scritta mini',
4461 'Livello-1-scritta mini',
4463 'Somma positivi e negativi [' in oSheet.getCellByPosition(8, y).String
or \
4464 'SOMMANO' in oSheet.getCellByPosition(8, y).String:
4467 if oSheet.getCellByPosition(2, y).CellStyle
in (
'comp sotto centro'):
4469 if oSheet.getCellByPosition(1, y).CellStyle ==
'Data_bianca':
4470 oCellAddress = oSheet.getCellByPosition(1, y+1).getCellAddress()
4471 oCellRangeAddr.Sheet = oSheet.RangeAddress.Sheet
4472 oCellRangeAddr.StartColumn = 1
4473 oCellRangeAddr.StartRow = y
4474 oCellRangeAddr.EndColumn = 1
4475 oCellRangeAddr.EndRow = y
4476 oSheet.copyRange(oCellAddress, oCellRangeAddr)
4477 stile = oSheet.getCellByPosition(2, y).CellStyle
4478 oSheet.getRows().removeByIndex(y, 1)
4479 if stile
in (
'Livello-0-scritta mini',
'Livello-1-scritta mini',
'livello2_'):
4483 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
4484 oDoc.enableAutomaticCalculation(
True)
4489 Inserisce una nuova riga di misurazione nel computo
4492 oSheet = oDoc.CurrentController.ActiveSheet
4494 stile = oSheet.getCellByPosition(1, lrow).CellStyle
4496 'comp Art-EP',
'comp Art-EP_R',
'Comp-Bianche in mezzo'
4499 oSheet.getRows().insertByIndex(lrow, 1)
4501 oSheet.getCellRangeByPosition(
4506 ).CellStyle =
'comp 1-a'
4507 oSheet.getCellByPosition(0, lrow).CellStyle =
'comp 10 s'
4508 oSheet.getCellByPosition(1, lrow).CellStyle =
'Comp-Bianche in mezzo'
4509 oSheet.getCellByPosition(2, lrow).CellStyle =
'comp 1-a'
4510 oSheet.getCellRangeByPosition(
4511 3, lrow, 4, lrow).CellStyle =
'Comp-Bianche in mezzo bordate_R'
4512 oSheet.getCellByPosition(5, lrow).CellStyle =
'comp 1-a PU'
4513 oSheet.getCellByPosition(6, lrow).CellStyle =
'comp 1-a LUNG'
4514 oSheet.getCellByPosition(7, lrow).CellStyle =
'comp 1-a LARG'
4515 oSheet.getCellByPosition(8, lrow).CellStyle =
'comp 1-a peso'
4516 oSheet.getCellByPosition(9, lrow).CellStyle =
'Blu'
4518 oSheet.getCellByPosition(
4519 9, lrow).Formula =
'=IF(PRODUCT(E' + str(lrow + 1) +
':I' + str(
4520 lrow + 1) +
')=0;"";PRODUCT(E' + str(lrow +
4521 1) +
':I' + str(lrow +
4530 Inserisce una nuova riga di misurazione in contabilità
4534 oSheet = oDoc.CurrentController.ActiveSheet
4535 oSheetto = oDoc.getSheets().getByName(
'S5')
4536 oRangeAddress = oSheetto.getCellRangeByPosition(0, 24, 42, 24).getRangeAddress()
4538 stile = oSheet.getCellByPosition(1, lrow).CellStyle
4539 if oSheet.getCellByPosition(1,
4540 lrow + 1).CellStyle ==
'comp sotto Bianche_R':
4542 if stile
in (
'comp Art-EP_R',
'Data_bianca',
'Comp-Bianche in mezzo_R'):
4546 oCellAddress = oSheet.getCellByPosition(0, lrow).getCellAddress()
4547 oSheet.getRows().insertByIndex(lrow, 1)
4548 oSheet.copyRange(oCellAddress, oRangeAddress)
4549 if stile
in (
'comp Art-EP_R'):
4550 oRangeAddress = oSheet.getCellByPosition(1, lrow +
4551 1).getRangeAddress()
4552 oCellAddress = oSheet.getCellByPosition(1, lrow).getCellAddress()
4553 oSheet.copyRange(oCellAddress, oRangeAddress)
4554 oSheet.getCellByPosition(1, lrow + 1).String =
""
4555 oSheet.getCellByPosition(1, lrow + 1
4556 ).CellStyle =
'Comp-Bianche in mezzo_R'
4558 oSheet.getCellByPosition(1, lrow).CellStyle =
'Comp-Bianche in mezzo_R'
4565 @@@ MODIFICA IN CORSO CON 'LeenoAnalysis.copiaRigaAnalisi'
4566 Inserisce una nuova riga di misurazione in analisi di prezzo
4569 oSheet = oDoc.CurrentController.ActiveSheet
4570 stile = oSheet.getCellByPosition(0, lrow).CellStyle
4571 if stile
in (
'An-lavoraz-desc',
'An-lavoraz-Cod-sx'):
4573 oSheet.getRows().insertByIndex(lrow, 1)
4575 oSheet.getCellByPosition(0, lrow).CellStyle =
'An-lavoraz-Cod-sx'
4576 oSheet.getCellRangeByPosition(1, lrow, 5,
4577 lrow).CellStyle =
'An-lavoraz-generica'
4578 oSheet.getCellByPosition(3, lrow).CellStyle =
'An-lavoraz-input'
4579 oSheet.getCellByPosition(6, lrow).CellStyle =
'An-senza'
4580 oSheet.getCellByPosition(7, lrow).CellStyle =
'An-senza-DX'
4583 oSheet.getCellByPosition(1, lrow).Formula =
'=IF(A' + str(
4584 lrow + 1) +
'="";"";CONCATENATE(" ";VLOOKUP(A' + str(
4585 lrow + 1) +
';elenco_prezzi;2;FALSE());' '))'
4586 oSheet.getCellByPosition(
4588 lrow).Formula =
'=IF(A' + str(lrow + 1) +
'="";"";VLOOKUP(A' + str(
4589 lrow + 1) +
';elenco_prezzi;3;FALSE()))'
4590 oSheet.getCellByPosition(3, lrow).Value = 0
4591 oSheet.getCellByPosition(
4593 lrow).Formula =
'=IF(A' + str(lrow + 1) +
'="";0;VLOOKUP(A' + str(
4594 lrow + 1) +
';elenco_prezzi;5;FALSE()))'
4595 oSheet.getCellByPosition(
4596 5, lrow).Formula =
'=D' + str(lrow + 1) +
'*E' + str(lrow + 1)
4597 oSheet.getCellByPosition(
4599 ).Formula =
'=IF(A' + str(lrow + 1) +
'="";"";IF(VLOOKUP(A' + str(
4600 lrow + 1) +
';elenco_prezzi;6;FALSE())="";"";(VLOOKUP(A' + str(
4601 lrow + 1) +
';elenco_prezzi;6;FALSE()))))'
4602 oSheet.getCellByPosition(9, lrow).Formula =
'=IF(I' + str(
4603 lrow + 1) +
'="";"";I' + str(lrow + 1) +
'*F' + str(lrow + 1) +
')'
4606 if oSheet.getCellByPosition(
4607 1, lrow - 1).CellStyle ==
'An-lavoraz-dx-senza-bordi':
4608 oRangeAddress = oSheet.getCellByPosition(0, lrow +
4609 1).getRangeAddress()
4610 oCellAddress = oSheet.getCellByPosition(0, lrow).getCellAddress()
4611 oSheet.copyRange(oCellAddress, oRangeAddress)
4612 oSheet.getCellByPosition(0, lrow).String =
'Cod. Art.?'
4627 Aggiunge riga di misurazione
4631 oSheet = oDoc.CurrentController.ActiveSheet
4633 nome_sheet = oSheet.Name
4634 if nome_sheet
in (
'COMPUTO',
'VARIANTE'):
4635 if cfg.read(
'Generale',
'dettaglio') ==
'1':
4638 elif nome_sheet ==
'CONTABILITA':
4639 if cfg.read(
'Generale',
'dettaglio') ==
'1':
4642 elif nome_sheet ==
'Analisi di Prezzo':
4650 Conserva, nella variabile globale 'partenza', il nome del foglio [0] e l'id
4651 della riga di codice prezzo componente [1], il flag '#reg' solo per la contabilità.
4652 partenza = (nome_foglio, id_rcodice, flag_contabilità)
4655 oSheet = oDoc.CurrentController.ActiveSheet
4665 @@@ MODIFICA IN CORSO CON 'LeenoContab.sbloccaContabilita'
4666 Controlla che non ci siano atti contabili registrati e dà il consenso a procedere.
4670 oSheet = oDoc.CurrentController.ActiveSheet
4671 if oSheet.Name
in (
'CONTABILITA'):
4678 if partenza[2] ==
'':
4680 if partenza[2] ==
'#reg':
4683 Text=
"""Lavorando in questo punto del foglio,
4684 comprometterai la validità degli atti contabili già emessi.
4688 SCEGLIENDO SI' SARAI COSTRETTO A RIGENERARLI!""") == 0:
4700 Evidenzia il codice di elenco prezzi della voce corrente.
4707 Evidenzia il codice di elenco prezzi della voce corrente.
4710 oSheet = oDoc.CurrentController.ActiveSheet
4712 if oSheet.Name
in (
'COMPUTO',
'CONTABILITA',
'VARIANTE',
'Registro',
4713 'Analisi di Prezzo',
'SAL'):
4714 if oSheet.Name ==
'Analisi di Prezzo':
4715 if oSheet.getCellByPosition(
4716 0, lrow).CellStyle
in (
'An-lavoraz-Cod-sx',
'An-1_sigla'):
4717 codice_da_cercare = oSheet.getCellByPosition(0, lrow).String
4720 elif oSheet.Name
in (
'Registro',
'SAL'):
4721 codice_da_cercare =oSheet.getCellByPosition(0, lrow).String.split(
'\n')[1]
4724 sopra = sStRange.RangeAddress.StartRow
4725 codice_da_cercare = oSheet.getCellByPosition(1, sopra + 1).String
4726 oSheet = oDoc.getSheets().getByName(
"Elenco Prezzi")
4727 oSheet.IsVisible =
True
4729 elif oSheet.Name
in (
'Elenco Prezzi'):
4730 if oSheet.getCellByPosition(1, lrow).Type.value ==
'FORMULA':
4731 codice_da_cercare = oSheet.getCellByPosition(0, lrow).String
4734 oSheet = oDoc.getSheets().getByName(
"Analisi di Prezzo")
4735 oSheet.IsVisible =
True
4738 if codice_da_cercare ==
"Cod. Art.?":
4740 if codice_da_cercare !=
'':
4743 oDoc.CurrentController.select(
4744 oSheet.getCellRangeByPosition(oCell[0], oCell[1], 30, oCell[1]))
4761 Permette di scegliere il codice per la voce di COMPUTO o VARIANTE o CONTABILITA dall'Elenco Prezzi.
4762 Capisce quando la voce nel libretto delle misure è già registrata o nel documento ci sono già atti contabili emessi.
4766 oSheet = oDoc.CurrentController.ActiveSheet
4774 if oSheet.getCellByPosition(0, lrow).CellStyle
not in stili_computo + stili_contab + stili_analisi + stili_elenco:
4776 if oSheet.Name
in (
'Analisi di Prezzo'):
4782 if oSheet.Name
in (
'CONTABILITA'):
4785 if partenza[2] ==
'#reg':
4794 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4795 if oDoc.NamedRanges.hasByName(
"_Lib_1"):
4798 "Risulta già registrato un SAL. VUOI PROCEDERE COMUQUE?",
4799 'ATTENZIONE!') == 3:
4802 Text=
"Risulta già registrato un SAL."
4803 "Vuoi procedere comunque?") == 0:
4808 if oSheet.getCellByPosition(1, partenza[1]).String !=
'Cod. Art.?':
4812 if oSheet.Name
in (
'Elenco Prezzi'):
4815 codice = oSheet.getCellByPosition(0, lrow).String
4817 oSheet = oDoc.CurrentController.ActiveSheet
4818 if partenza[0] ==
'Analisi di Prezzo':
4819 oSheet.getCellByPosition(0, partenza[1]).String = codice
4820 _gotoCella(3, partenza[1])
4822 oSheet.getCellByPosition(1, partenza[1]).String = codice
4823 _gotoCella(2, partenza[1] + 1)
4831 In CONTABILITA consente l'inserimento di nuove voci di misurazione
4832 partendo da voci già inserite in COMPUTO o VARIANTE.
4837 oSheet = oDoc.CurrentController.ActiveSheet
4838 if oSheet.Name ==
'CONTABILITA':
4842 if partenza[2] ==
'#reg':
4856 if oSheet.getCellByPosition(0, lrow).CellStyle
not in stili_contab + (
4857 'comp Int_colonna_R_prima', ):
4862 GotoSheet(cfg.read(
'Contabilita',
'ricicla_da'))
4865 Text=
' Stai cercando di riciclare le misure dal foglio ' + \
4866 cfg.read(
'Contabilita',
'ricicla_da'))
4868 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4871 sopra = sStRange.RangeAddress.StartRow + 2
4872 sotto = sStRange.RangeAddress.EndRow - 1
4874 oSrc = oSheet.getCellRangeByPosition(2, sopra, 8,
4875 sotto).getRangeAddress()
4876 oSheet.getCellByPosition(2, sopra - 1).CellBackColor = 13500076
4878 if partenza
is None:
4880 oDest = oDoc.getSheets().getByName(
'CONTABILITA')
4881 oCellAddress = oDest.getCellByPosition(2, partenza[1] + 1).getCellAddress()
4885 oDest.getRows().insertByIndex(partenza[1] + 2, sotto - sopra)
4886 oDest.getCellRangeByPosition(1, partenza[1] + 2, 1, partenza[1] +
4887 sotto - sopra +1).CellStyle =
'Comp-Bianche in mezzo_R'
4889 oDest.copyRange(oCellAddress, oSrc)
4890 oDest.getCellByPosition(1, partenza[1]).String = oSheet.getCellByPosition(1, sopra - 1).String
4891 oDest.getCellByPosition(2, partenza[1]).CellBackColor = 13500076
4894 _gotoCella(2, partenza[1] + 1)
4904 Inverte il segno delle formule di quantità nei righi di misurazione selezionati.
4907 oSheet = oDoc.CurrentController.ActiveSheet
4912 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4913 except AttributeError:
4914 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4921 for el
in oRangeAddress:
4922 el_y.append((el.StartRow, el.EndRow))
4924 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4930 for el
in range(y[0], y[1] + 1):
4934 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
4936 if 'comp 1-a' in oSheet.getCellByPosition(2, lrow).CellStyle:
4937 if 'ROSSO' in oSheet.getCellByPosition(2, lrow).CellStyle:
4939 oSheet.getCellByPosition(9, lrow).Formula = (
4940 '=IF(PRODUCT(E' + str(lrow + 1) +
':I' +
4941 str(lrow + 1) +
')=0;"";PRODUCT(E' +
4942 str(lrow + 1) +
':I' +
4943 str(lrow + 1) +
'))')
4945 for x
in range(2, 10):
4946 oSheet.getCellByPosition(x, lrow).CellStyle = (
4947 oSheet.getCellByPosition(x, lrow).CellStyle.split(
' ROSSO')[0])
4950 oSheet.getCellByPosition(9, lrow).Formula = (
4951 '=IF(PRODUCT(E' + str(lrow + 1) +
':I' +
4952 str(lrow + 1) +
')=0;"";-PRODUCT(E' +
4953 str(lrow + 1) +
':I' + str(lrow + 1) +
'))')
4955 for x
in range(2, 10):
4956 oSheet.getCellByPosition(x, lrow).CellStyle = (
4957 oSheet.getCellByPosition(x, lrow).CellStyle +
' ROSSO')
4959 elif oSheet.Name
in (
'CONTABILITA'):
4961 if 'comp 1-a' in oSheet.getCellByPosition(2, lrow).CellStyle:
4962 formula1 = oSheet.getCellByPosition(9, lrow).Formula
4963 formula2 = oSheet.getCellByPosition(11, lrow).Formula
4964 oSheet.getCellByPosition(11, lrow).Formula = formula1
4965 oSheet.getCellByPosition(9, lrow).Formula = formula2
4966 if oSheet.getCellByPosition(11, lrow).Value > 0:
4967 for x
in range(2, 12):
4968 oSheet.getCellByPosition(x, lrow).CellStyle = (
4969 oSheet.getCellByPosition(x, lrow).CellStyle +
' ROSSO')
4971 for x
in range(2, 12):
4972 oSheet.getCellByPosition(
4973 x, lrow).CellStyle = (
4974 oSheet.getCellByPosition(x, lrow).CellStyle.split(
' ROSSO')[0])
4980 Estrae qualsiasi valore da una cella, restituendo una stringa, indipendentemente dal tipo originario.
4981 oCell { object } : cella da validare
4983 if oCell.Type.value ==
'FORMULA':
4984 if re.search(
'[a-zA-Z]', oCell.Formula):
4985 valore = str(oCell.Value)
4987 valore = oCell.Formula.split(
'=')[-1]
4988 elif oCell.Type.value ==
'VALUE':
4989 valore = str(oCell.Value)
4990 elif oCell.Type.value ==
'TEXT':
4991 valore = str(oCell.String)
4992 elif oCell.Type.value ==
'EMPTY':
5002 Indica il dettaglio delle misure nel rigo di descrizione quando
5003 incontra delle formule nei valori immessi.
5004 bit { integer } : 1 inserisce i dettagli
5005 0 cancella i dettagli
5009 oSheet = oDoc.CurrentController.ActiveSheet
5011 if ' ►' in oSheet.getCellByPosition(2, lrow).String:
5012 oSheet.getCellByPosition(2, lrow).String = oSheet.getCellByPosition(
5013 2, lrow).String.split(
' ►')[0]
5014 if oSheet.getCellByPosition(2, lrow).CellStyle
in (
5016 )
and "*** VOCE AZZERATA ***" not in oSheet.getCellByPosition(2,
5018 for el
in range(5, 9):
5019 if oSheet.getCellByPosition(el, lrow).Type.value ==
'FORMULA':
5026 for el
in range(5, 9):
5027 if oSheet.getCellByPosition(el, lrow).Type.value ==
'FORMULA':
5028 if '$' not in oSheet.getCellByPosition(el, lrow).Formula:
5031 oSheet.getCellByPosition(
5032 el, lrow).Formula.split(
'=')[1].replace(
5035 stringa = stringa +
'(' + oSheet.getCellByPosition(
5036 el, lrow).Formula.split(
'=')[-1] +
')*'
5038 stringa = stringa +
'(' + oSheet.getCellByPosition(
5039 el, lrow).String.split(
'=')[-1] +
')*'
5042 stringa = stringa +
'*' + str(
5043 oSheet.getCellByPosition(el, lrow).String) +
'*'
5044 while '**' in stringa:
5045 stringa = stringa.replace(
'**',
'*')
5046 if stringa[0] ==
'*':
5047 stringa = stringa[1:-1]
5049 stringa = stringa[0:-1]
5050 stringa =
' ►' + stringa
5051 if oSheet.getCellByPosition(2, lrow).Type.value !=
'FORMULA':
5052 oSheet.getCellByPosition(
5053 2, lrow).String = oSheet.getCellByPosition(
5054 2, lrow).String + stringa.replace(
'.',
',')
5061 Indica il dettaglio delle misure nel rigo di descrizione quando
5062 incontra delle formule nei valori immessi.
5063 bit { integer } : 1 inserisce i dettagli
5064 0 cancella i dettagli
5069 oSheet = oDoc.CurrentController.ActiveSheet
5074 progress =
Dialogs.Progress(Title=
'Rigenerazione in corso...', Text=
"Lettura dati")
5076 progress.setValue(0)
5080 for lrow
in range(0, ER):
5081 progress.setValue(lrow)
5082 if oSheet.getCellByPosition(2, lrow).CellStyle
in (
5084 )
and "*** VOCE AZZERATA ***" not in oSheet.getCellByPosition(
5086 for el
in range(5, 9):
5087 if oSheet.getCellByPosition(el, lrow).Type.value ==
'FORMULA':
5093 for el
in range(5, 9):
5094 if oSheet.getCellByPosition(
5095 el, lrow).Type.value ==
'FORMULA':
5096 if '$' not in oSheet.getCellByPosition(
5100 oSheet.getCellByPosition(
5101 el, lrow).Formula.split(
'=')
5102 [1].replace(
'^',
'**'))
5104 stringa = stringa +
'(' + oSheet.getCellByPosition(
5105 el, lrow).Formula.split(
'=')[-1] +
')*'
5107 stringa = stringa +
'(' + oSheet.getCellByPosition(
5108 el, lrow).String.split(
'=')[-1] +
')*'
5111 stringa = stringa +
'*' + str(
5112 oSheet.getCellByPosition(el,
5114 while '**' in stringa:
5115 stringa = stringa.replace(
'**',
'*')
5116 if stringa[0] ==
'*':
5117 stringa = stringa[1:-1]
5119 stringa = stringa[0:-1]
5120 stringa =
' ►' + stringa
5121 if oSheet.getCellByPosition(2,
5122 lrow).Type.value !=
'FORMULA':
5123 oSheet.getCellByPosition(
5124 2, lrow).String = oSheet.getCellByPosition(
5125 2, lrow).String + stringa.replace(
'.',
',')
5127 for lrow
in range(0, ER):
5130 if ' ►' in oSheet.getCellByPosition(2, lrow).String:
5131 oSheet.getCellByPosition(
5132 2, lrow).String = oSheet.getCellByPosition(
5133 2, lrow).String.split(
' ►')[0]
5143 oSheet = oDoc.CurrentController.ActiveSheet
5146 oSheet.getCellRangeByName(
'L1').String =
'Ricicla da:'
5147 oSheet.getCellRangeByName(
'L1').CellStyle =
'Reg_prog'
5148 oCell = oSheet.getCellRangeByName(
'N1')
5149 if oCell.String
not in (
"COMPUTO",
"VARIANTE",
'Scegli origine'):
5150 oCell.CellStyle =
'Menu_sfondo _input_grasBig'
5152 '"COMPUTO";"VARIANTE"',
5153 titoloInput=
'Scegli...',
5154 msgInput=
'COMPUTO o VARIANTE',
5156 oCell.String =
'Scegli...'
5159 def valida_cella(oCell, lista_val, titoloInput='', msgInput='', err=False):
5161 Validità lista valori
5162 Imposta un elenco di valori a cascata, da cui scegliere.
5163 oCell { object } : cella da validare
5164 lista_val { string } : lista dei valori in questa forma: '"UNO";"DUE";"TRE"'
5165 titoloInput { string } : titolo del suggerimento che compare passando il cursore sulla cella
5166 msgInput { string } : suggerimento che compare passando il cursore sulla cella
5167 err { boolean } : permette di abilitare il messaggio di errore per input non validi
5172 oTabVal = oCell.getPropertyValue(
"Validation")
5173 oTabVal.setPropertyValue(
'ConditionOperator', 1)
5175 oTabVal.setPropertyValue(
"ShowInputMessage",
True)
5176 oTabVal.setPropertyValue(
"InputTitle", titoloInput)
5177 oTabVal.setPropertyValue(
"InputMessage", msgInput)
5178 oTabVal.setPropertyValue(
"ErrorMessage",
5179 "ERRORE: Questo valore non è consentito.")
5180 oTabVal.setPropertyValue(
"ShowErrorMessage", err)
5181 oTabVal.ErrorAlertStyle = uno.Enum(
5182 "com.sun.star.sheet.ValidationAlertStyle",
"STOP")
5183 oTabVal.Type = uno.Enum(
"com.sun.star.sheet.ValidationType",
"LIST")
5184 oTabVal.Operator = uno.Enum(
"com.sun.star.sheet.ConditionOperator",
5186 oTabVal.setFormula1(lista_val)
5187 oCell.setPropertyValue(
"Validation", oTabVal)
5192 oCell = oDoc.CurrentSelection
5193 oSheet = oDoc.CurrentController.ActiveSheet
5195 i = oCell.RangeAddress.StartRow
5196 n = oCell.Rows.Count
5197 oSheet.getRows().removeByIndex(i, n)
5203 Esegue un comando di menù.
5204 cmd { string } : nome del comando di menù
5207 'DeletePrintArea' = Cancella l'area di stampa
5208 'ShowDependents' = Mostra le celle dipendenti
5209 'ClearArrowDependents' = elimina frecce celle dipendenti
5210 'Undo' = Annulla ultimo comando
5211 'CalculateHard' = Ricalcolo incondizionato
5215 oFrame = desktop.getCurrentFrame()
5216 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
5217 'com.sun.star.frame.DispatchHelper', ctx)
5218 dispatchHelper.executeDispatch(oFrame,
".uno:" + cmd,
"", 0,
5229 Elimina righe o colonne.
5230 arg { string } : 'R' per righe
5237 oFrame = desktop.getCurrentFrame()
5238 oProp = PropertyValue()
5239 oProp.Name =
'Flags'
5241 properties = (oProp, )
5243 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
5244 'com.sun.star.frame.DispatchHelper', ctx)
5245 dispatchHelper.executeDispatch(oFrame,
".uno:DeleteCell",
"", 0, properties)
5254 oFrame = desktop.getCurrentFrame()
5256 oProp0 = PropertyValue()
5257 oProp0.Name =
'Flags'
5259 oProp1 = PropertyValue()
5260 oProp1.Name =
'FormulaCommand'
5262 oProp2 = PropertyValue()
5263 oProp2.Name =
'SkipEmptyCells'
5264 oProp2.Value =
False
5265 oProp3 = PropertyValue()
5266 oProp3.Name =
'Transpose'
5267 oProp3.Value =
False
5268 oProp4 = PropertyValue()
5269 oProp4.Name =
'AsLink'
5270 oProp4.Value =
False
5271 oProp.append(oProp0)
5272 oProp.append(oProp1)
5273 oProp.append(oProp2)
5274 oProp.append(oProp3)
5275 oProp.append(oProp4)
5278 oProp5 = PropertyValue()
5279 oProp5.Name =
'MoveMode'
5281 oProp.append(oProp5)
5282 properties = tuple(oProp)
5284 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.DispatchHelper', ctx)
5285 dispatchHelper.executeDispatch(oFrame,
'.uno:InsertContents',
'', 0, properties)
5286 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
5292 Incolla solo il formato cella
5297 oFrame = desktop.getCurrentFrame()
5299 oProp0 = PropertyValue()
5300 oProp0.Name =
'Flags'
5302 oProp1 = PropertyValue()
5303 oProp1.Name =
'FormulaCommand'
5305 oProp2 = PropertyValue()
5306 oProp2.Name =
'SkipEmptyCells'
5307 oProp2.Value =
False
5308 oProp3 = PropertyValue()
5309 oProp3.Name =
'Transpose'
5310 oProp3.Value =
False
5311 oProp4 = PropertyValue()
5312 oProp4.Name =
'AsLink'
5313 oProp4.Value =
False
5314 oProp.append(oProp0)
5315 oProp.append(oProp1)
5316 oProp.append(oProp2)
5317 oProp.append(oProp3)
5318 oProp.append(oProp4)
5319 properties = tuple(oProp)
5320 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.DispatchHelper', ctx)
5321 dispatchHelper.executeDispatch(oFrame,
'.uno:InsertContents',
'', 0, properties)
5322 oDoc.CurrentController.select(oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
5328 A partire dalla selezione di un range di celle in cui alcune righe e/o
5329 colonne sono nascoste, mette in clipboard solo il contenuto delle celle
5331 Liberamente ispirato a "Copy only visible cells" http://bit.ly/2j3bfq2
5334 oSheet = oDoc.CurrentController.ActiveSheet
5336 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
5337 except AttributeError:
5338 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
5340 SC = oRangeAddress.StartColumn
5341 EC = oRangeAddress.EndColumn
5342 SR = oRangeAddress.StartRow
5343 ER = oRangeAddress.EndRow
5351 for nRow
in range(SR, ER + 1):
5352 if not oSheet.getCellByPosition(SR, nRow).Rows.IsVisible:
5356 for nCol
in range(SC, EC + 1):
5357 if not oSheet.getCellByPosition(nCol, nRow).Columns.IsVisible:
5361 if not oDoc.getSheets().hasByName(
'tmp_clip'):
5362 sheet = oDoc.createInstance(
"com.sun.star.sheet.Spreadsheet")
5363 tmp = oDoc.Sheets.insertByName(
'tmp_clip', sheet)
5364 tmp = oDoc.getSheets().getByName(
'tmp_clip')
5366 oCellAddress = tmp.getCellByPosition(0, 0).getCellAddress()
5367 tmp.copyRange(oCellAddress, oRangeAddress)
5369 for i
in reversed(righe):
5370 tmp.getRows().removeByIndex(i, 1)
5371 for i
in reversed(colonne):
5372 tmp.getColumns().removeByIndex(i, 1)
5374 oRange = tmp.getCellRangeByPosition(0, 0, EC - SC - len(colonne),
5375 ER - SR - len(righe))
5376 oDoc.CurrentController.select(oRange)
5380 oFrame = desktop.getCurrentFrame()
5381 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.DispatchHelper', ctx)
5382 dispatchHelper.executeDispatch(oFrame,
".uno:Copy",
"", 0, list())
5383 oDoc.Sheets.removeByName(
'tmp_clip')
5384 oDoc.CurrentController.setActiveSheet(oSheet)
5385 oDoc.CurrentController.select(oSheet.getCellRangeByPosition(SC, SR, EC, ER))
5391 Restituisce la tupla (IDcolonna, IDriga, NameSheet) della posizione corrente
5394 oSheet = oDoc.CurrentController.ActiveSheet
5396 if oDoc.getCurrentSelection().getRangeAddresses()[0]:
5397 nRow = oDoc.getCurrentSelection().getRangeAddresses()[0].StartRow
5398 nCol = oDoc.getCurrentSelection().getRangeAddresses(
5400 except AttributeError:
5401 nRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
5402 nCol = oDoc.getCurrentSelection().getRangeAddress().StartColumn
5403 return (nCol, nRow, oSheet.Name)
5411 Comando di menu per numera_voci()
5418 @@@ MODIFICA IN CORSO CON 'LeenoSheetUtils.numeraVoci'
5419 bit { integer } : 1 rinumera tutto
5420 0 rinumera dalla voce corrente in giù
5423 oSheet = oDoc.CurrentController.ActiveSheet
5429 for x
in reversed(range(0, lrow)):
5431 oSheet.getCellByPosition(1, x).CellStyle
in (
'comp Art-EP',
'comp Art-EP_R')
and
5432 oSheet.getCellByPosition(1, x).CellBackColor != 15066597):
5433 n = oSheet.getCellByPosition(0, x).Value + 1
5435 for row
in range(lrow, lastRow):
5436 if oSheet.getCellByPosition(1, row).CellBackColor == 15066597:
5437 oSheet.getCellByPosition(0, row).String =
''
5438 elif oSheet.getCellByPosition(1,row).CellStyle
in (
'comp Art-EP',
'comp Art-EP_R'):
5439 oSheet.getCellByPosition(0, row).Value = n
5442 for row
in range(0, lastRow):
5448 if oSheet.getCellByPosition(1, row).CellStyle
in (
'comp Art-EP',
'comp Art-EP_R'):
5449 oSheet.getCellByPosition(0, row).Value = n
5459 '''Crea la Lista Lavorazioni e Forniture dall'Elenco Prezzi,
5460 per la formulazione dell'offerta'''
5465 oSheet = oDoc.CurrentController.ActiveSheet
5467 oDoc.Sheets.copyByName(oSheet.Name,
'Elenco Prezzi', 5)
5470 nSheet = oDoc.getSheets().getByIndex(5).Name
5472 oSheet = oDoc.CurrentController.ActiveSheet
5473 oSheet.Name =
'Richiesta offerta'
5475 oSheet = oDoc.CurrentController.ActiveSheet
5477 oRange = oSheet.getCellRangeByPosition(12, 3, 12, fine)
5478 aSaveData = oRange.getDataArray()
5479 oRange = oSheet.getCellRangeByPosition(3, 3, 3, fine)
5480 oRange.CellStyle =
'EP statistiche_q'
5481 oRange.setDataArray(aSaveData)
5482 oSheet.getCellByPosition(3, 2).String =
'Quantità\na Computo'
5483 oSheet.getCellByPosition(5, 2).String =
'Prezzo Unitario\nin lettere'
5484 oSheet.getCellByPosition(6, 2).String =
'Importo'
5485 oSheet.Columns.removeByIndex(7, 100)
5486 oSheet.getColumns().getByName(
"D").IsVisible =
True
5487 oSheet.getColumns().getByName(
"F").IsVisible =
True
5488 oSheet.getColumns().getByName(
"G").IsVisible =
True
5489 oSheet.getColumns().getByName(
"A").Columns.Width = 1600
5490 oSheet.getColumns().getByName(
"B").Columns.Width = 8000
5491 oSheet.getColumns().getByName(
"C").Columns.Width = 1200
5492 oSheet.getColumns().getByName(
"D").Columns.Width = 1600
5493 oSheet.getColumns().getByName(
"E").Columns.Width = 1500
5494 oSheet.getColumns().getByName(
"F").Columns.Width = 4000
5495 oSheet.getColumns().getByName(
"G").Columns.Width = 1800
5496 oDoc.CurrentController.freezeAtPosition(0, 1)
5501 '=IF(E' + str(x + 1) +
'<>"";D' + str(x + 1) +
'*E' + str(x + 1) +
5504 oSheet.getCellRangeByPosition(6, 3, 6,
5505 len(formule) + 2).CellBackColor = 15757935
5506 oRange = oSheet.getCellRangeByPosition(6, 3, 6, len(formule) + 2)
5507 formule = tuple(formule)
5508 oRange.setFormulaArray(formule)
5510 oSheet.getCellRangeByPosition(
5512 fine).clearContents(VALUE + DATETIME + STRING + ANNOTATION + FORMULA +
5513 HARDATTR + OBJECTS + EDITATTR + FORMATTED)
5515 oSheet.getCellRangeByPosition(4, 3, 4, fine + 1).clearContents(
5516 VALUE + FORMULA + STRING)
5517 oSheet.getCellRangeByPosition(0, fine - 1, 100, fine +
5518 1).clearContents(VALUE + FORMULA + STRING)
5519 oSheet.Columns.insertByIndex(0, 1)
5521 oSrc = oSheet.getCellRangeByPosition(1, 0, 1, fine).RangeAddress
5522 oDest = oSheet.getCellByPosition(0, 0).CellAddress
5523 oSheet.copyRange(oDest, oSrc)
5524 oSheet.getCellByPosition(0, 2).String =
"N."
5525 for x
in range(3, fine - 1):
5526 oSheet.getCellByPosition(0, x).Value = x - 2
5527 oSheet.getCellRangeByPosition(0, 1, 0, fine).CellStyle =
"EP-aS"
5529 for x
in range(3, fine - 1):
5530 if oSheet.getCellByPosition(y, x).Type.value ==
'FORMULA':
5531 oSheet.getCellByPosition(y,
5532 x).String = oSheet.getCellByPosition(
5534 for x
in range(3, fine - 1):
5535 if oSheet.getCellByPosition(5, x).Type.value ==
'FORMULA':
5536 oSheet.getCellByPosition(5, x).Value = oSheet.getCellByPosition(
5538 oSheet.getColumns().getByName(
"A").Columns.Width = 650
5540 oSheet.getCellByPosition(
5541 7, fine).Formula =
"=SUBTOTAL(9;H2:H" + str(fine + 1) +
")"
5542 oSheet.getCellByPosition(2, fine).String =
"TOTALE COMPUTO"
5543 oSheet.getCellRangeByPosition(0, fine, 7, fine).CellStyle =
"Comp TOTALI"
5544 oSheet.Rows.removeByIndex(fine - 1, 1)
5545 oSheet.Rows.removeByIndex(0, 2)
5546 oSheet.getCellByPosition(2,
5547 fine + 3).String =
"(diconsi euro - in lettere)"
5548 oSheet.getCellRangeByPosition(2, fine + 3, 6,
5549 fine + 3).CellStyle =
"List-intest_med_c"
5550 oSheet.getCellByPosition(2, fine +
5551 5).String =
"Pari a Ribasso del ___________%"
5552 oSheet.getCellByPosition(2, fine + 8).String =
"(ribasso in lettere)"
5553 oSheet.getCellRangeByPosition(2, fine + 8, 6,
5554 fine + 8).CellStyle =
"List-intest_med_c"
5556 oSheet.getCellByPosition(
5558 fine + 10).Formula =
'=CONCATENATE("Data, ";TEXT(NOW();"GG/MM/AAAA"))'
5559 oSheet.getCellRangeByPosition(2, fine + 10, 2,
5560 fine + 10).CellStyle =
"Ultimus"
5561 oSheet.getCellByPosition(2, fine + 12).String =
"L'OFFERENTE"
5562 oSheet.getCellByPosition(2, fine + 12).CellStyle =
'centro_grassetto'
5563 oSheet.getCellByPosition(2, fine + 13).String =
'(timbro e firma)'
5564 oSheet.getCellByPosition(2, fine + 13).CellStyle =
'centro_corsivo'
5567 oRange = oSheet.getCellRangeByPosition(2, fine + 10, 2, fine + 10)
5569 aSaveData = oRange.getDataArray()
5570 oRange.setDataArray(aSaveData)
5571 oSheet.getCellRangeByPosition(
5576 oSheet.PageStyle =
'PageStyle_COMPUTO_A4'
5577 pagestyle = oDoc.StyleFamilies.getByName(
'PageStyles').getByName(
5578 'PageStyle_COMPUTO_A4')
5579 pagestyle.HeaderIsOn =
True
5582 pagestyle.HeaderIsOn =
True
5583 oHContent = pagestyle.RightPageHeaderContent
5585 if len(filename) > 50:
5586 filename = filename[:20] +
' ... ' + filename[-20:]
5587 oHContent.LeftText.String = filename
5588 oHContent.CenterText.String =
''
5589 oHContent.RightText.String =
''.join(
''.join(
''.join(
5590 str(datetime.now()).split(
'.')[0].split(
' ')).split(
'-')).split(
':'))
5592 pagestyle.RightPageHeaderContent = oHContent
5600 Inserisce una nuova riga voce in Elenco Prezzi
5603 oDoc.enableAutomaticCalculation(
False)
5605 oSheet = oDoc.CurrentController.ActiveSheet
5607 oSheet.getRows().insertByIndex(3, 1)
5609 oSheet.getCellByPosition(0, 3).CellStyle =
"EP-aS"
5610 oSheet.getCellByPosition(1, 3).CellStyle =
"EP-a"
5611 oSheet.getCellRangeByPosition(2, 3, 7, 3).CellStyle =
"EP-mezzo"
5612 oSheet.getCellRangeByPosition(8, 3, 9, 3).CellStyle =
"EP-sfondo"
5613 for el
in (5, 11, 15, 19, 26):
5614 oSheet.getCellByPosition(el, 3).CellStyle =
"EP-mezzo %"
5616 for el
in (12, 16, 20, 21):
5617 oSheet.getCellByPosition(el, 3).CellStyle =
'EP statistiche_q'
5619 for el
in (13, 17, 23, 24, 25):
5620 oSheet.getCellByPosition(el, 3).CellStyle =
'EP statistiche'
5622 oSheet.getCellRangeByPosition(0, 3, 26, 3).clearContents(HARDATTR)
5623 oSheet.getCellByPosition(11,
5624 3).Formula =
'=IF(ISERROR(N4/$N$2);"--";N4/$N$2)'
5626 oSheet.getCellByPosition(12, 3).Formula =
'=SUMIF(AA;A4;BB)'
5627 oSheet.getCellByPosition(13, 3).Formula =
'=SUMIF(AA;A4;cEuro)'
5630 oRangeAddress = oSheet.getCellRangeByPosition(15, 4, 26,
5631 4).getRangeAddress()
5632 oCellAddress = oSheet.getCellByPosition(15, 3).getCellAddress()
5633 oSheet.copyRange(oCellAddress, oRangeAddress)
5634 oCell = oSheet.getCellByPosition(2, 3)
5637 '"cad";"corpo";"dm";"dm²";"dm³";"kg";"lt";"m";"m²";"m³";"q";"t";""',
5638 titoloInput=
'Scegli...',
5639 msgInput=
'Unità di misura')
5640 oDoc.enableAutomaticCalculation(
True)
5646 Ripristina/ricalcola le formule di descrizione e somma di una voce.
5647 in COMPUTO, VARIANTE e CONTABILITA
5650 oSheet = oDoc.CurrentController.ActiveSheet
5655 sopra = sStRange.RangeAddress.StartRow
5656 sotto = sStRange.RangeAddress.EndRow
5664 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
5666 oSheet.getCellByPosition(
5668 ).CellStyle =
'comp Art-EP_R'
5669 oSheet.getCellByPosition(
5671 ).Formula =
'=IF(LEN(VLOOKUP(B' + str(
5673 ) +
';elenco_prezzi;2;FALSE()))<($S1.$H$337+$S1.$H$338);VLOOKUP(B' + str(
5675 ) +
';elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B' + str(
5677 ) +
';elenco_prezzi;2;FALSE());$S1.$H$337);" [...] ";RIGHT(VLOOKUP(B' + str(
5678 sopra + 2) +
';elenco_prezzi;2;FALSE());$S1.$H$338)))'
5679 oSheet.getCellByPosition(
5680 8, sotto).Formula =
'=CONCATENATE("SOMMANO [";VLOOKUP(B' + str(
5681 sopra + 2) +
';elenco_prezzi;3;FALSE());"]")'
5682 oSheet.getCellByPosition(
5684 sotto).Formula =
'=SUBTOTAL(9;J' + str(sopra +
5685 2) +
':J' + str(sotto +
5687 oSheet.getCellByPosition(11, sotto).Formula =
'=VLOOKUP(B' + str(
5688 sopra + 2) +
';elenco_prezzi;5;FALSE())'
5689 oSheet.getCellByPosition(13, sotto).Formula =
'=J' + str(sotto + 1)
5690 oSheet.getCellByPosition(
5692 sotto).Formula =
'=AB' + str(sotto + 1) +
'*J' + str(sotto + 1)
5694 oSheet.getCellByPosition(
5695 18, sotto).Formula =
'=IF(VLOOKUP(B' + str(
5696 sopra + 2) +
';elenco_prezzi;3;FALSE())="%";J' + str(
5697 sotto + 1) +
'*L' + str(sotto + 1) +
'/100;J' + str(
5698 sotto + 1) +
'*L' + str(sotto + 1) +
')'
5699 oSheet.getCellByPosition(27, sotto).Formula =
'=VLOOKUP(B' + str(
5700 sopra + 2) +
';elenco_prezzi;4;FALSE())'
5701 oSheet.getCellByPosition(
5703 sotto).Formula =
'=S' + str(sotto + 1) +
'-AE' + str(sotto + 1)
5704 oSheet.getCellByPosition(29, sotto).Formula =
'=VLOOKUP(B' + str(
5705 sopra + 2) +
';elenco_prezzi;6;FALSE())'
5706 oSheet.getCellByPosition(
5708 ).Formula =
'=IF(AD' + str(sotto + 1) +
'<>""; PRODUCT(AD' + str(
5709 sotto + 1) +
'*S' + str(sotto + 1) +
'))'
5710 oSheet.getCellByPosition(35, sotto).Formula =
'=B' + str(sopra + 2)
5711 oSheet.getCellByPosition(
5713 ).Formula =
'=IF(ISERROR(S' + str(sotto + 1) +
');"";IF(S' + str(
5714 sotto + 1) +
'<>"";S' + str(sotto + 1) +
';""))'
5717 for n
in range (sopra + 2, sotto):
5722 if oSheet.getCellByPosition(2, n).CellStyle ==
'comp 1-a' or \
5723 oSheet.getCellByPosition(2, n).CellStyle ==
'comp 1-a ROSSO' and \
5724 "'" in oSheet.getCellByPosition(2, n).Formula:
5725 ff = oSheet.getCellByPosition(2, n).Formula.split(
"'")
5727 oSheet.getCellByPosition(2, n).Formula = ff[0] + ff[-1][1:]
5730 for x
in range (5, 8):
5731 if 'ROSSO' in oSheet.getCellByPosition(x, n).CellStyle:
5735 formula = ([
'=IF(PRODUCT(E' + str(n + 1) +
':I' +
5736 str(n + 1) +
')=0;"";-PRODUCT(E' + str(n + 1) +
5737 ':I' + str(n + 1) +
'))'])
5739 formula = ([
'=IF(PRODUCT(E' + str(n + 1) +
':I' +
5740 str(n + 1) +
')=0;"";PRODUCT(E' + str(n + 1) +
5741 ':I' + str(n + 1) +
'))'])
5742 if oSheet.getCellByPosition(4, n).Value < 0:
5743 formula = ([
'=IF(PRODUCT(E' + str(n + 1) +
':I' +
5744 str(n + 1) +
')=0;"";PRODUCT(E' + str(n + 1) +
5745 ':I' + str(n + 1) +
'))'])
5746 formule.append(formula)
5748 oRange = oSheet.getCellRangeByPosition(9, sopra + 2, 9, sotto - 1)
5749 formule = tuple(formule)
5752 oRange.setFormulaArray(formule)
5754 if oSheet.Name
in (
'CONTABILITA'):
5756 oSheet.getCellByPosition(
5758 ).Formula =
'=IF(LEN(VLOOKUP(B' + str(
5760 ) +
';elenco_prezzi;2;FALSE()))<($S1.$H$335+$S1.$H$336);VLOOKUP(B' + str(
5762 ) +
';elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B' + str(
5764 ) +
';elenco_prezzi;2;FALSE());$S1.$H$335);" [...] ";RIGHT(VLOOKUP(B' + str(
5765 sopra + 2) +
';elenco_prezzi;2;FALSE());$S1.$H$336)))'
5766 oSheet.getCellByPosition(
5768 ).Formula =
'=CONCATENATE("Somma positivi e negativi [";VLOOKUP(B' + str(
5769 sopra + 2) +
';elenco_prezzi;3;FALSE());"]")'
5770 oSheet.getCellByPosition(
5771 8, sotto).Formula =
'=CONCATENATE("SOMMANO [";VLOOKUP(B' + str(
5772 sopra + 2) +
';elenco_prezzi;3;FALSE());"]")'
5773 oSheet.getCellByPosition(
5775 1).Formula =
'=IF(SUBTOTAL(9;J' + str(sopra + 2) +
':J' + str(
5776 sotto) +
')<0;"";SUBTOTAL(9;J' + str(
5777 sopra + 2) +
':J' + str(sotto) +
'))'
5778 oSheet.getCellByPosition(
5780 1).Formula =
'=IF(SUBTOTAL(9;L' + str(sopra + 2) +
':L' + str(
5781 sotto) +
')<0;"";SUBTOTAL(9;L' + str(
5782 sopra + 2) +
':L' + str(sotto) +
'))'
5783 oSheet.getCellByPosition(
5784 9, sotto).Formula =
'=J' + str(sotto) +
'-L' + str(sotto)
5785 oSheet.getCellByPosition(13, sotto).Formula =
'=VLOOKUP(B' + str(
5786 sopra + 2) +
';elenco_prezzi;5;FALSE())'
5787 oSheet.getCellByPosition(
5788 15, sotto).Formula =
'=IF(VLOOKUP(B' + str(
5789 sopra + 2) +
';elenco_prezzi;3;FALSE())="%";J' + str(
5790 sotto + 1) +
'*N' + str(sotto + 1) +
'/100;J' + str(
5791 sotto + 1) +
'*N' + str(sotto + 1) +
')'
5792 oSheet.getCellByPosition(
5794 sotto).Formula =
'=J' + str(sotto + 1) +
'*AB' + str(sotto + 1)
5795 oSheet.getCellByPosition(27, sotto).Formula =
'=VLOOKUP(B' + str(
5796 sopra + 2) +
';elenco_prezzi;4;FALSE())'
5797 oSheet.getCellByPosition(
5799 sotto).Formula =
'=P' + str(sotto + 1) +
'-AE' + str(sotto + 1)
5800 oSheet.getCellByPosition(29, sotto).Formula =
'=VLOOKUP(B' + str(
5801 sopra + 2) +
';elenco_prezzi;6;FALSE())'
5802 oSheet.getCellByPosition(
5804 ).Formula =
'=IF(AD' + str(sotto + 1) +
'<>""; PRODUCT(AD' + str(
5805 sotto + 1) +
'*P' + str(sotto + 1) +
'))'
5806 oSheet.getCellRangeByName(
'A2').Formula =
'=P2'
5807 oSheet.getCellByPosition(9, sotto -
5808 1).CellStyle =
'Comp-Variante num sotto'
5810 for n
in range (sopra + 2, sotto - 1):
5815 if oSheet.getCellByPosition(2, n).CellStyle ==
'comp 1-a' or \
5816 oSheet.getCellByPosition(2, n).CellStyle ==
'comp 1-a ROSSO' and \
5817 "'" in oSheet.getCellByPosition(2, n).Formula:
5818 ff = oSheet.getCellByPosition(2, n).Formula.split(
"'")
5820 oSheet.getCellByPosition(2, n).Formula = ff[0] + ff[-1][1:]
5823 for x
in range (5, 8):
5824 if 'ROSSO' in oSheet.getCellByPosition(x, n).CellStyle:
5828 formule.append ([
'=IF(PRODUCT(E' + str(n + 1) +
':I' +
5829 str(n + 1) +
')>=0;"";PRODUCT(E' +
5830 str(n + 1) +
':I' + str(n + 1) +
')*-1)',
'',
5831 '=IF(PRODUCT(E' + str(n+1) +
':I' +
5832 str(n+1) +
')<=0;"";PRODUCT(E' + str(
5833 n + 1) +
':I' + str(n+1) +
'))'])
5835 formule.append ([
'=IF(PRODUCT(E' + str(n + 1) +
':I' +
5836 str(n + 1) +
')<=0;"";PRODUCT(E' +
5837 str(n + 1) +
':I' + str(n + 1) +
'))',
'',
5838 '=IF(PRODUCT(E' + str(n+1) +
':I' +
5839 str(n+1) +
')>=0;"";PRODUCT(E' + str(
5840 n + 1) +
':I' + str(n+1) +
')*-1)'])
5842 oRange = oSheet.getCellRangeByPosition(9, sopra + 2, 11, sotto - 2)
5843 formule = tuple(formule)
5844 oRange.setFormulaArray(formule)
5852 Ripristina le formule in tutto il foglio
5862 oSheet = oDoc.CurrentController.ActiveSheet
5868 progress =
Dialogs.Progress(Title=
'Rigenerazione di ' + nome +
' in corso...', Text=
"Lettura dati")
5870 progress.setValue(0)
5872 if nome
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
5874 oSheet = oDoc.Sheets.getByName(nome)
5876 oDoc.CurrentController.select(oSheet.getCellByPosition(0, row))
5879 progress.setValue(row)
5897 Ripristina stili di cella per una singola voce.
5898 in COMPUTO, VARIANTE e CONTABILITA
5902 oSheet = oDoc.CurrentController.ActiveSheet
5907 sopra = sStRange.RangeAddress.StartRow
5908 sotto = sStRange.RangeAddress.EndRow
5909 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
5910 for x
in range(sopra + 1, sotto - 1):
5911 if 'comp 1-a' in oSheet.getCellByPosition(2, x).CellStyle:
5912 oSheet.getCellByPosition(9, x).CellStyle =
'Blu'
5913 if oSheet.getCellByPosition(9, x).Value < 0:
5914 oSheet.getCellByPosition(2, x).CellStyle =
'comp 1-a ROSSO'
5915 oSheet.getCellByPosition(5,
5916 x).CellStyle =
'comp 1-a PU ROSSO'
5917 oSheet.getCellByPosition(
5918 6, x).CellStyle =
'comp 1-a LUNG ROSSO'
5919 oSheet.getCellByPosition(
5920 7, x).CellStyle =
'comp 1-a LARG ROSSO'
5921 oSheet.getCellByPosition(
5922 8, x).CellStyle =
'comp 1-a peso ROSSO'
5924 oSheet.getCellByPosition(2, x).CellStyle =
'comp 1-a'
5925 oSheet.getCellByPosition(5, x).CellStyle =
'comp 1-a PU'
5926 oSheet.getCellByPosition(6, x).CellStyle =
'comp 1-a LUNG'
5927 oSheet.getCellByPosition(7, x).CellStyle =
'comp 1-a LARG'
5928 oSheet.getCellByPosition(8, x).CellStyle =
'comp 1-a peso'
5930 if oSheet.Name
in (
'CONTABILITA'):
5931 oSheet.getCellByPosition(9, sopra + 1).CellStyle =
'vuote2'
5932 oSheet.getCellByPosition(11, sopra +
5933 1).CellStyle =
'Comp-Bianche in mezzo_R'
5934 oSheet.getCellByPosition(9, sotto -
5935 1).CellStyle =
'Comp-Variante num sotto'
5936 oSheet.getCellByPosition(9,
5937 sotto).CellStyle =
'Comp-Variante num sotto'
5938 oSheet.getCellByPosition(13, sotto).CellStyle =
'comp sotto Unitario'
5939 oSheet.getCellByPosition(15,
5940 sotto).CellStyle =
'comp sotto Euro Originale'
5941 oSheet.getCellByPosition(17,
5942 sotto).CellStyle =
'comp sotto Euro Originale'
5943 oSheet.getCellByPosition(11, sotto -
5944 1).CellStyle =
'Comp-Variante num sotto ROSSO'
5945 oSheet.getCellByPosition(11, sotto).CellStyle =
'comp sotto centro_R'
5946 oSheet.getCellByPosition(28, sotto).CellStyle =
'Comp-sotto euri'
5947 for x
in range(sopra + 1, sotto):
5949 if 'comp 1-a' in oSheet.getCellByPosition(2, x).CellStyle:
5950 oSheet.getCellByPosition(9, x).CellStyle =
'Blu'
5951 elif oSheet.getCellByPosition(
5952 2, x).CellStyle ==
'comp sotto centro':
5953 oSheet.getCellByPosition(
5954 9, x).CellStyle =
'Comp-Variante num sotto'
5956 for x
in range(sopra + 2, sotto - 1):
5958 for y
in range(2, 8):
5959 if oSheet.getCellByPosition(y, x).String !=
'':
5962 for y
in range (2, 8):
5964 if 'ROSSO' in oSheet.getCellByPosition(y, x).CellStyle:
5967 if str(test) + str(rosso) ==
'10':
5968 oSheet.getCellByPosition(9, x).Formula =
'=IF(PRODUCT(E' + str(
5969 x + 1) +
':I' + str(x + 1) +
')=0;"";PRODUCT(E' + str(
5970 x + 1) +
':I' + str(x + 1) +
'))'
5971 oSheet.getCellByPosition(2, x).CellStyle =
'comp 1-a'
5972 oSheet.getCellByPosition(5, x).CellStyle =
'comp 1-a PU'
5973 oSheet.getCellByPosition(6, x).CellStyle =
'comp 1-a LUNG'
5974 oSheet.getCellByPosition(7, x).CellStyle =
'comp 1-a LARG'
5975 oSheet.getCellByPosition(8, x).CellStyle =
'comp 1-a peso'
5976 oSheet.getCellByPosition(11, x).String =
''
5977 if str(test) + str(rosso) ==
'11':
5978 oSheet.getCellByPosition(
5979 11, x).Formula =
'=IF(PRODUCT(E' + str(x + 1) +
':I' + str(
5980 x + 1) +
')=0;"";PRODUCT(E' + str(x + 1) +
':I' + str(
5982 oSheet.getCellByPosition(2, x).CellStyle =
'comp 1-a ROSSO'
5983 oSheet.getCellByPosition(5, x).CellStyle =
'comp 1-a PU ROSSO'
5984 oSheet.getCellByPosition(6,
5985 x).CellStyle =
'comp 1-a LUNG ROSSO'
5986 oSheet.getCellByPosition(7,
5987 x).CellStyle =
'comp 1-a LARG ROSSO'
5988 oSheet.getCellByPosition(8,
5989 x).CellStyle =
'comp 1-a peso ROSSO'
5990 oSheet.getCellByPosition(9, x).String =
''
5996 arg { boolean }: Se False rigenera solo voce corrente
5997 Rigenera i parziali di tutte le voci
6001 oSheet = oDoc.CurrentController.ActiveSheet
6003 if oSheet.Name
not in (
'COMPUTO',
'CONTABILITA',
'VARIANTE'):
6018 progress =
Dialogs.Progress(Title=
'Rigenerazione in corso...', Text=
"Parziali")
6019 progress.setLimits(0, sotto - sopra)
6021 progress.setValue(n)
6025 for i
in range(sopra, sotto):
6027 progress.setValue(n)
6028 if 'Parziale [' in oSheet.getCellByPosition(8, i).Formula:
6039 Contestualizza in ogni tabella l'inserimento delle voci.
6044 oSheet = oDoc.CurrentController.ActiveSheet
6047 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
6049 elif oSheet.Name ==
'Analisi di Prezzo':
6051 elif oSheet.Name ==
'CONTABILITA':
6054 elif oSheet.Name ==
'Elenco Prezzi':
6062 @@@ MODIFICA IN CORSO CON 'LeenoContab.insertVoceContabilita
6063 Inserisce una nuova voce in CONTABILITA.
6067 oSheet = oDoc.Sheets.getByName(
'CONTABILITA')
6074 if oSheet.getCellByPosition(0, lrow + 1).CellStyle ==
'uuuuu':
6082 if partenza[2] ==
'#reg':
6092 stile = oSheet.getCellByPosition(0, lrow).CellStyle
6097 if stile ==
'Ultimus_centro_bordi_lati':
6100 if oSheet.getCellByPosition(23, i).Value != 0:
6101 nSal = int(oSheet.getCellByPosition(23, i).Value)
6104 while oSheet.getCellByPosition(0, lrow).CellStyle == stile:
6106 if oSheet.getCellByPosition(0, lrow).CellStyle ==
'uuuuu':
6110 elif stile ==
'Comp TOTALI':
6112 if stile
in stili_cat:
6114 elif stile
in (stili_contab):
6116 nSal = int(oSheet.getCellByPosition(23, sStRange.RangeAddress.StartRow + 1).Value)
6121 oSheetto = oDoc.getSheets().getByName(
'S5')
6122 oRangeAddress = oSheetto.getCellRangeByPosition(0, 22, 48, 26).getRangeAddress()
6123 oCellAddress = oSheet.getCellByPosition(0, lrow).getCellAddress()
6124 oSheet.getRows().insertByIndex(lrow, 5)
6125 oSheet.copyRange(oCellAddress, oRangeAddress)
6127 _gotoCella(1, lrow + 1)
6137 sopra = sStRange.RangeAddress.StartRow
6139 for n
in reversed(range(0, sopra)):
6140 if oSheet.getCellByPosition(
6141 1, n).CellStyle ==
'Ultimus_centro_bordi_lati':
6143 if oSheet.getCellByPosition(1, n).CellStyle ==
'Data_bianca':
6144 data = oSheet.getCellByPosition(1, n).Value
6147 oSheet.getCellByPosition(1, sopra +
6148 2).Value = date.today().toordinal() - 693594
6150 oSheet.getCellByPosition(1, sopra + 2).Value = data
6160 iSheet = oSheet.RangeAddress.Sheet
6161 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
6162 oCellRangeAddr.Sheet = iSheet
6163 oCellRangeAddr.StartColumn = 0
6164 oCellRangeAddr.EndColumn = 0
6165 oCellRangeAddr.StartRow = lrow + 2
6166 oCellRangeAddr.EndRow = lrow + 2
6167 oSheet.group(oCellRangeAddr, 1)
6170 if oDoc.NamedRanges.hasByName(
'_Lib_' + str(nSal)):
6171 if lrow - 1 == oSheet.getCellRangeByName(
6172 '_Lib_' + str(nSal)).getRangeAddress().EndRow:
6175 oSheet.getCellByPosition(23, sopra + 1).Value = nSal
6176 oSheet.getCellByPosition(23, sopra + 1).CellStyle =
'Sal'
6178 oSheet.getCellByPosition(35, sopra + 4).Formula =
'=B' + str(sopra + 2)
6179 oSheet.getCellByPosition(
6181 4).Formula =
'=IF(ISERROR(P' + str(sopra + 5) +
');"";IF(P' + str(
6182 sopra + 5) +
'<>"";P' + str(sopra + 5) +
';""))'
6183 oSheet.getCellByPosition(36, sopra + 4).CellStyle =
"comp -controolo"
6185 oSheet.getCellByPosition(1, sopra + 1).String = cod
6187 if cfg.read(
'Generale',
'pesca_auto') ==
'1':
6198 Riscrive le intestazioni di colonna e le formule dei totali in Elenco Prezzi.
6204 oSheet = oDoc.Sheets.getByName(
'Elenco Prezzi')
6210 oCellRangeAddr = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
6212 ER = oCellRangeAddr.EndRow
6214 EC = oCellRangeAddr.EndColumn
6215 oSheet.getCellRangeByPosition(11, 3, EC, ER -
6216 1).clearContents(STRING + VALUE + FORMULA)
6218 oDoc.CurrentController.freezeAtPosition(0, 3)
6219 oSheet.getCellRangeByPosition(0, 0, 100, 0).CellStyle =
"Default"
6222 oSheet.getCellRangeByName(
'L1').String =
'COMPUTO'
6223 oSheet.getCellRangeByName(
'P1').String =
'VARIANTE'
6224 oSheet.getCellRangeByName(
'T1').String =
'CONTABILITA'
6225 oSheet.getCellRangeByName(
'B2').String =
'QUESTA RIGA NON VIENE STAMPATA'
6226 oSheet.getCellRangeByName(
6227 "'Elenco Prezzi'.A2:AA2").CellStyle =
"comp In testa"
6228 oSheet.getCellRangeByName(
"'Elenco Prezzi'.AA2").CellStyle =
'EP-mezzo %'
6230 oSheet.getCellRangeByName(
"'Elenco Prezzi'.A3:AA3").CellStyle =
"EP-a -Top"
6231 oSheet.getCellRangeByName(
'A3').String =
'Codice\nArticolo'
6232 oSheet.getCellRangeByName(
6233 'B3').String =
'DESCRIZIONE DEI LAVORI\nE DELLE SOMMINISTRAZIONI'
6234 oSheet.getCellRangeByName(
'C3').String =
'Unità\ndi misura'
6235 oSheet.getCellRangeByName(
'D3').String =
'Sicurezza\ninclusa'
6236 oSheet.getCellRangeByName(
'E3').String =
'Prezzo\nunitario'
6237 oSheet.getCellRangeByName(
'F3').String =
'Incidenza\nMdO'
6238 oSheet.getCellRangeByName(
'G3').String =
'Importo\nMdO'
6239 oSheet.getCellRangeByName(
'H3').String =
'Codice di origine'
6240 oSheet.getCellRangeByName(
'L3').String =
'Inc. % \nComputo'
6241 oSheet.getCellRangeByName(
'M3').String =
'Quantità\nComputo'
6242 oSheet.getCellRangeByName(
'N3').String =
'Importi\nComputo'
6243 oSheet.getCellRangeByName(
'L3:N3').CellBackColor = 16762855
6244 oSheet.getCellRangeByName(
'P3').String =
'Inc. % \nVariante'
6245 oSheet.getCellRangeByName(
'Q3').String =
'Quantità\nVariante'
6246 oSheet.getCellRangeByName(
'R3').String =
'Importi\nVariante'
6247 oSheet.getCellRangeByName(
'P3:R3').CellBackColor = 16777062
6248 oSheet.getCellRangeByName(
'T3').String =
'Inc. % \nContabilità'
6249 oSheet.getCellRangeByName(
'U3').String =
'Quantità\nContabilità'
6250 oSheet.getCellRangeByName(
'V3').String =
'Importi\nContabilità'
6251 oSheet.getCellRangeByName(
'T3:V3').CellBackColor = 16757935
6252 oSheet.getCellRangeByName(
'X3').String =
'Quantità\nvariaz.'
6253 oSheet.getCellRangeByName(
'Y3').String =
'IMPORTI\nin più'
6254 oSheet.getCellRangeByName(
'Z3').String =
'IMPORTI\nin meno'
6255 oSheet.getCellRangeByName(
'AA3').String =
'VAR. %'
6256 oSheet.getCellRangeByName(
'I1:J1').Columns.IsVisible =
False
6259 oSheet.getCellRangeByName(
'N2').Formula =
'=SUBTOTAL(9;N:N)'
6260 oSheet.getCellRangeByName(
'R2').Formula =
'=SUBTOTAL(9;R:R)'
6261 oSheet.getCellRangeByName(
'V2').Formula =
'=SUBTOTAL(9;V:V)'
6262 oSheet.getCellRangeByName(
'Y2').Formula =
'=SUBTOTAL(9;Y:Y)'
6263 oSheet.getCellRangeByName(
'Z2').Formula =
'=SUBTOTAL(9;Z:Z)'
6266 oSheet.getCellByPosition(12, y).String =
'TOTALE'
6267 oSheet.getCellByPosition(13, y).Formula =
'=SUBTOTAL(9;N3:N' + str(y) +
')'
6269 oSheet.getCellByPosition(16, y).String =
'TOTALE'
6270 oSheet.getCellByPosition(17, y).Formula =
'=SUBTOTAL(9;R3:R' + str(y) +
')'
6272 oSheet.getCellByPosition(20, y).String =
'TOTALE'
6273 oSheet.getCellByPosition(21, y).Formula =
'=SUBTOTAL(9;V3:V' + str(y) +
')'
6275 oSheet.getCellByPosition(23, y).String =
'TOTALE'
6276 oSheet.getCellByPosition(24, y).Formula =
'=SUBTOTAL(9;Y3:Y' + str(y) +
')'
6277 oSheet.getCellByPosition(25, y).Formula =
'=SUBTOTAL(9;Z3:Z' + str(y) +
')'
6278 oSheet.getCellRangeByPosition(10, y, 26,
6279 y).CellStyle =
'EP statistiche_Contab'
6284 oSheet.getCellRangeByName(
'K2:K' + str(y)).CellStyle =
'Default'
6285 oSheet.getCellRangeByName(
'O2:O' + str(y)).CellStyle =
'Default'
6286 oSheet.getCellRangeByName(
'S2:S' + str(y)).CellStyle =
'Default'
6287 oSheet.getCellRangeByName(
'W2:W' + str(y)).CellStyle =
'Default'
6288 oSheet.getCellRangeByPosition(3, 3, 250, y + 10).clearContents(HARDATTR)
6299 Riscrive le intestazioni di colonna e le formule dei totali in COMPUTO.
6302 oSheet = oDoc.Sheets.getByName(
'COMPUTO')
6303 oDoc.CurrentController.setActiveSheet(oSheet)
6304 oDoc.CurrentController.freezeAtPosition(0, 3)
6314 lRowE = oRow.CellAddress.Row
6320 Flags = STRING + VALUE + FORMULA
6321 oSheet.getCellRangeByPosition(0, 0, 100, 2).clearContents(Flags)
6322 oSheet.getCellRangeByPosition(12, 0, 16, lRowE).clearContents(Flags)
6323 oSheet.getCellRangeByPosition(22, 0, 23, lRowE).clearContents(Flags)
6324 oSheet.getCellRangeByPosition(0, 0, 100, 0).CellStyle =
"Default"
6325 oSheet.getCellRangeByPosition(0, 0, 100, 0).clearContents(HARDATTR)
6326 oSheet.getCellRangeByPosition(44, 0, 100, lRowE + 10).CellStyle =
"Default"
6331 oSheet.getCellByPosition(2, 1).String =
'QUESTA RIGA NON VIENE STAMPATA'
6332 oSheet.getCellByPosition(
6333 17, 1).Formula =
'=SUBTOTAL(9;R3:R' + str(lRowE + 1) +
')'
6334 oSheet.getCellByPosition(
6336 1).Formula =
'=SUBTOTAL(9;S3:S' + str(lRowE + 1) +
')'
6337 oSheet.getCellByPosition(0, 1).Formula =
'=AK2'
6339 oSheet.getCellByPosition(
6341 1).Formula =
'=SUBTOTAL(9;AC3:AC' + str(lRowE +
6344 oSheet.getCellByPosition(29,
6345 1).Formula =
'=AE2/S2'
6346 oSheet.getCellByPosition(29, 1).CellStyle =
"Comp TOTALI %"
6347 oSheet.getCellByPosition(
6349 1).Formula =
'=SUBTOTAL(9;AE3:AE' + str(lRowE +
6351 oSheet.getCellByPosition(36, 1).Formula =
'=SUBTOTAL(9;AK3:AK' + str(
6354 oSheet.getCellRangeByPosition(0, 1, 43, 1).CellStyle =
"comp In testa"
6355 oSheet.getCellRangeByPosition(0, 0, 43, 2).merge(
False)
6356 oSheet.getCellRangeByPosition(0, 1, 1, 1).merge(
True)
6359 oSheet.getCellByPosition(0, 2).String =
'N.'
6360 oSheet.getCellByPosition(1, 2).String =
'Articolo\nData'
6361 oSheet.getCellByPosition(
6362 2, 2).String =
'DESIGNAZIONE DEI LAVORI\nE DELLE SOMMINISTRAZIONI'
6363 oSheet.getCellByPosition(5, 2).String =
'P.U.\nCoeff.'
6364 oSheet.getCellByPosition(6, 2).String =
'Lung.'
6365 oSheet.getCellByPosition(7, 2).String =
'Larg.'
6366 oSheet.getCellByPosition(8, 2).String =
'Alt.\nPeso'
6367 oSheet.getCellByPosition(9, 2).String =
'Quantità'
6368 oSheet.getCellByPosition(11, 2).String =
'Prezzo\nunitario'
6369 oSheet.getCellByPosition(
6371 ).String =
'Serve per avere le quantità\nrealizzate "pulite" e sommabili'
6372 oSheet.getCellByPosition(17, 2).String =
'di cui\nsicurezza'
6373 oSheet.getCellByPosition(18, 2).String =
'Importo €'
6374 oSheet.getCellByPosition(
6376 ).String =
'Incidenza\nsul totale'
6377 oSheet.getCellByPosition(27, 2).String =
'Sicurezza\nunitaria'
6378 oSheet.getCellByPosition(28, 2).String =
'Materiali\ne Noli €'
6379 oSheet.getCellByPosition(29, 2).String =
'Incidenza\nMdO %'
6380 oSheet.getCellByPosition(30, 2).String =
'Importo\nMdO'
6381 oSheet.getCellByPosition(31, 2).String =
'Super Cat'
6382 oSheet.getCellByPosition(32, 2).String =
'Cat'
6383 oSheet.getCellByPosition(33, 2).String =
'Sub Cat'
6384 oSheet.getCellByPosition(34, 2).String =
'tag B'
6385 oSheet.getCellByPosition(35, 2).String =
'tag C'
6386 oSheet.getCellByPosition(36, 2).String =
'importo totale\nsenza errori'
6387 oSheet.getCellByPosition(38, 2).String =
'Figure e\nannotazioni'
6388 oSheet.getCellByPosition(
6389 43, 2).String =
'riservato per annotare\nil numero della voce'
6390 oSheet.getCellRangeByPosition(0, 2, 43, 2).CellStyle =
'comp Int_colonna'
6391 oSheet.getCellByPosition(13, 2).CellStyle =
'COnt_noP'
6392 oSheet.getCellByPosition(19, 2).CellStyle =
'COnt_noP'
6393 oSheet.getCellByPosition(36, 2).CellStyle =
'COnt_noP'
6394 oSheet.getCellByPosition(43, 2).CellStyle =
'COnt_noP'
6398 oSheet.getCellByPosition(2, lRowE).String =
"TOTALI COMPUTO"
6399 oSheet.getCellByPosition(
6401 lRowE).Formula =
"=SUBTOTAL(9;R3:R" + str(lRowE +
6403 oSheet.getCellByPosition(
6404 18, lRowE).Formula =
"=SUBTOTAL(9;S3:S" + str(lRowE +
6406 oSheet.getCellByPosition(29, lRowE).Formula =
"=AE" + str(
6407 lRowE + 1) +
"/S" + str(lRowE + 1) +
""
6408 oSheet.getCellByPosition(30, lRowE).Formula =
"=SUBTOTAL(9;AE3:AE" + str(
6410 oSheet.getCellByPosition(36, lRowE).Formula =
"=SUBTOTAL(9;AK3:AK" + str(
6412 oSheet.getCellRangeByPosition(0, lRowE, 36,
6413 lRowE).CellStyle =
"Comp TOTALI"
6414 oSheet.getCellByPosition(24, lRowE).CellStyle =
"Comp TOTALI %"
6415 oSheet.getCellByPosition(29, lRowE).CellStyle =
"Comp TOTALI %"
6419 oSheet = oDoc.Sheets.getByName(
'S1')
6420 oSheet.getCellByPosition(9, 190).Formula =
"=$COMPUTO.$S$2"
6421 oSheet = oDoc.Sheets.getByName(
'M1')
6422 oSheet.getCellByPosition(3, 0).Formula =
"=$COMPUTO.$S$2"
6423 oSheet = oDoc.Sheets.getByName(
'S2')
6424 oSheet.getCellByPosition(4, 0).Formula =
"=$COMPUTO.$S$2"
6432 @@@ MODIFICA IN CORSO CON 'LeenoAnalysis.inizializzaAnalisi'
6433 Se non presente, crea il foglio 'Analisi di Prezzo' ed inserisce la prima scheda
6438 if not oDoc.getSheets().hasByName(
'Analisi di Prezzo'):
6439 oDoc.getSheets().insertNewByName(
'Analisi di Prezzo', 1)
6440 oSheet = oDoc.Sheets.getByName(
'Analisi di Prezzo')
6441 oSheet.getCellRangeByPosition(0, 0, 15, 0).CellStyle =
'Analisi_Sfondo'
6442 oSheet.getCellByPosition(0, 1).Value = 0
6443 oSheet = oDoc.Sheets.getByName(
'Analisi di Prezzo')
6444 oDoc.CurrentController.setActiveSheet(oSheet)
6446 oRangeAddress = oDoc.NamedRanges.blocco_analisi.ReferredCells.RangeAddress
6447 oCellAddress = oSheet.getCellByPosition(
6450 oDoc.CurrentController.select(oSheet.getCellByPosition(0, 2))
6451 oDoc.CurrentController.select(
6452 oDoc.createInstance(
6453 "com.sun.star.sheet.SheetCellRanges"))
6457 oSheet = oDoc.Sheets.getByName(
'Analisi di Prezzo')
6458 oDoc.CurrentController.setActiveSheet(oSheet)
6464 if oSheet.getCellByPosition(
6465 0, n).CellStyle ==
'An-sfondo-basso Att End':
6467 oRangeAddress = oDoc.NamedRanges.blocco_analisi.ReferredCells.RangeAddress
6468 oSheet.getRows().insertByIndex(n + 2, 26)
6469 oCellAddress = oSheet.getCellByPosition(0, n + 2).getCellAddress()
6470 oDoc.CurrentController.select(oSheet.getCellByPosition(0, n + 2 + 1))
6471 oDoc.CurrentController.select(
6472 oDoc.createInstance(
6473 "com.sun.star.sheet.SheetCellRanges"))
6474 oSheet.copyRange(oCellAddress, oRangeAddress)
6485 Inserisce la riga rossa di chiusura degli elaborati
6486 Questa riga è un riferimento per varie operazioni
6489 oSheet = oDoc.CurrentController.ActiveSheet
6495 Mette in vista struttura secondo il colore
6496 level { integer } : specifica il livello di categoria
6500 oSheet = oDoc.CurrentController.ActiveSheet
6501 iSheet = oSheet.RangeAddress.Sheet
6502 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
6503 oCellRangeAddr.Sheet = iSheet
6504 hriga = oSheet.getCellRangeByName(
'B4').CharHeight * 65
6515 if oSheet.getCellByPosition(0, y).String ==
'':
6516 oSheet.getCellByPosition(0, y).CellBackColor = col4
6517 elif len(oSheet.getCellByPosition(0, y).String.split(
'.')) == 3:
6518 oSheet.getCellByPosition(0, y).CellBackColor = col3
6519 elif len(oSheet.getCellByPosition(0, y).String.split(
'.')) == 2:
6520 oSheet.getCellByPosition(0, y).CellBackColor = col2
6521 elif len(oSheet.getCellByPosition(0, y).String.split(
'.')) == 1:
6522 oSheet.getCellByPosition(0, y).CellBackColor = col1
6525 myrange = (col1, col0)
6528 myrange = (col1, col2, col0)
6531 myrange = (col1, col2, col3, col0)
6534 myrange = (col1, col2, col3, col4, col0)
6537 oCellRangeAddr.StartColumn = n
6538 oCellRangeAddr.EndColumn = n
6539 oSheet.group(oCellRangeAddr, 0)
6540 oSheet.getCellRangeByPosition(n, 0, n, 0).Columns.IsVisible =
False
6543 progress =
Dialogs.Progress(Title=
'Rigenerazione in corso...', Text=
"Lettura dati")
6544 progress.setLimits(0, test)
6545 progress.setValue(0)
6549 for n
in range(0, test):
6551 progress.setValue(x)
6552 if oSheet.getCellByPosition(0, n).CellBackColor == colore:
6553 oSheet.getCellByPosition(0, n).Rows.Height = hriga
6555 for n
in range(sopra + 1, test):
6556 if oSheet.getCellByPosition(0, n).CellBackColor
in myrange:
6558 lista.append((sopra, sotto))
6561 oCellRangeAddr.StartRow = el[0]
6562 oCellRangeAddr.EndRow = el[1]
6563 oSheet.group(oCellRangeAddr, 1)
6564 oSheet.getCellRangeByPosition(0, el[0], 0,
6565 el[1]).Rows.IsVisible =
False
6574 Dà una tonalità di colore, diverso dal colore dello stile cella, alle righe
6575 che non hanno il prezzo, come i titoli di capitolo e sottocapitolo.
6580 Text=
'''Adesso puoi dare ai titoli di capitolo e sottocapitolo
6581 una tonalità di colore che ne facilita la leggibilità, ma
6582 il risultato finale dipende dalla struttura dei codici di voce.
6584 L'OPERAZIONE POTREBBE RICHIEDERE DEL TEMPO E
6585 LibreOffice POTREBBE SEMBRARE BLOCCATO!
6587 Vuoi procedere comunque?''') == 0:
6591 oSheet = oDoc.CurrentController.ActiveSheet
6592 oSheet.clearOutline()
6631 oSheet = oDoc.CurrentController.ActiveSheet
6643 for el
in range(inizio, fine):
6644 if len(oSheet.getCellByPosition(2, el).String.split(
'.')) == 1:
6645 oSheet.getCellByPosition(2, el).CellBackColor = col1
6646 if len(oSheet.getCellByPosition(2, el).String.split(
'.')) == 2:
6647 oSheet.getCellByPosition(2, el).CellBackColor = col2
6648 if len(oSheet.getCellByPosition(2, el).String.split(
'.')) == 3:
6649 oSheet.getCellByPosition(2, el).CellBackColor = col3
6656 Importa tutti gli stili da un documento di riferimento. Se non è
6657 selezionato, il file di riferimento è il template di leenO.
6662 Text=
'''Questa operazione sovrascriverà gli stili
6663 del documento attivo, se già presenti!
6665 Se non scegli un file di riferimento, saranno
6666 importati gli stili di default di LeenO.
6668 Vuoi continuare?''') == 0:
6671 if filename
is None:
6673 filename =
LeenO_path() +
'/template/leeno/Computo_LeenO.ots'
6675 filename = uno.systemPathToFileUrl(filename)
6677 nome = oDoc.CurrentController.ActiveSheet.Name
6678 oDoc.getStyleFamilies().loadStylesFromURL(filename, list())
6679 for el
in oDoc.Sheets.ElementNames:
6680 oDoc.CurrentController.setActiveSheet(oDoc.getSheets().getByName(el))
6681 oSheet = oDoc.getSheets().getByName(el)
6690 Inserisce una riga con l'indicazione della somma parziale.
6694 oSheet = oDoc.CurrentController.ActiveSheet
6696 if oSheet.getCellByPosition(1, lrow-1).CellStyle
in (
'comp Art-EP_R')
or \
6699 if oSheet.Name
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
6708 lrow { double } : id della riga di inserimento
6711 sopra = sStRange.RangeAddress.StartRow
6713 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
6714 if(oSheet.getCellByPosition(2, lrow).String ==
'' and
6715 oSheet.getCellByPosition(9, lrow).String ==
''):
6717 if(oSheet.getCellByPosition(0, lrow).CellStyle ==
'comp 10 s' and
6718 oSheet.getCellByPosition(1, lrow).CellStyle ==
'Comp-Bianche in mezzo' and
6719 oSheet.getCellByPosition(2, lrow).CellStyle ==
'comp 1-a' or
6720 oSheet.getCellByPosition(0, lrow).CellStyle ==
'Comp End Attributo'):
6721 oSheet.getRows().insertByIndex(lrow, 1)
6723 oSheet.getCellByPosition(1, lrow).CellStyle =
'Comp-Bianche in mezzo'
6724 oSheet.getCellRangeByPosition(2, lrow, 7,
6725 lrow).CellStyle =
'comp sotto centro'
6726 oSheet.getCellByPosition(8, lrow).CellStyle =
'comp sotto BiancheS'
6727 oSheet.getCellByPosition(9, lrow).CellStyle =
'Comp-Variante num sotto'
6728 oSheet.getCellByPosition(
6729 8, lrow).Formula =
'''=CONCATENATE("Parziale [";VLOOKUP(B''' + str(
6730 sopra + 2) +
''';elenco_prezzi;3;FALSE());"]")'''
6731 for i
in reversed(range(0, lrow)):
6732 if oSheet.getCellByPosition(9, i - 1).CellStyle
in (
'vuote2',
'Comp-Variante num sotto'):
6735 oSheet.getCellByPosition(9, lrow).Formula =
"=SUBTOTAL(9;J" + str(i) +
":J" + str(lrow + 1) +
")"
6737 if oSheet.Name
in (
'CONTABILITA'):
6738 if(oSheet.getCellByPosition(2, lrow).String ==
'' and
6739 oSheet.getCellByPosition(9, lrow).String ==
'' and
6740 oSheet.getCellByPosition(11, lrow).String ==
''):
6743 elif(oSheet.getCellByPosition(0, lrow).CellStyle ==
"comp 10 s_R" and
6744 oSheet.getCellByPosition(1, lrow).CellStyle ==
"Comp-Bianche in mezzo_R" and
6745 oSheet.getCellByPosition(2, lrow).CellStyle ==
"comp 1-a" or
6746 'Somma positivi e negativi [' in oSheet.getCellByPosition(8, lrow).String):
6747 oSheet.getRows().insertByIndex(lrow, 1)
6748 elif(oSheet.getCellByPosition(0, lrow).CellStyle ==
"Comp End Attributo_R" or
6749 oSheet.getCellByPosition(1, lrow).CellStyle ==
"Data_bianca" or
6750 oSheet.getCellByPosition(1, lrow).CellStyle ==
"comp Art-EP_R"):
6753 oSheet.getCellByPosition(2, lrow).CellStyle =
"comp sotto centro"
6754 oSheet.getCellRangeByPosition(5, lrow, 7,
6755 lrow).CellStyle =
"comp sotto centro"
6756 oSheet.getCellByPosition(8, lrow).CellStyle =
"comp sotto BiancheS"
6757 oSheet.getCellByPosition(9, lrow).CellStyle =
"Comp-Variante num sotto"
6758 oSheet.getCellByPosition(
6759 8, lrow).Formula =
'=CONCATENATE("Parziale [";VLOOKUP(B' + str(
6760 sopra + 2) +
';elenco_prezzi;3;FALSE());"]")'
6764 if oSheet.getCellByPosition(
6766 i - 1).CellStyle
in (
'vuote2',
'Comp-Variante num sotto'):
6770 oSheet.getCellByPosition(
6771 9, lrow).Formula =
'=SUBTOTAL(9;J' + str(da) +
':J' + str(
6772 lrow + 1) +
')-SUBTOTAL(9;L' + str(da) +
':L' + str(lrow +
6779 (riga d'inserimento, riga di riferimento)
6783 idv = sStRange.RangeAddress.StartRow + 1
6784 sotto = sStRange.RangeAddress.EndRow
6785 art =
'B$' + str(idv + 1)
6786 idvoce =
'A$' + str(idv + 1)
6787 des =
'C$' + str(idv + 1)
6788 quantity =
'J$' + str(sotto + 1)
6789 val = oSheet.getCellByPosition(9, sotto).String
6790 um =
'VLOOKUP(' + art +
';elenco_prezzi;3;FALSE())'
6795 sformula = (
'=CONCATENATE("";"- vedi voce n.";TEXT(' +
6796 idvoce +
';"@");" - art. ";' +
6800 ';$S1.$H$334);"... [";' +
6802 quantity +
';"0,00");"]";)')
6803 oSheet.getCellByPosition(2, lrow).Formula = sformula
6805 oSheet.Annotations.insertNew(oSheet.getCellByPosition(2, lrow).CellAddress,
6806 'Se non usi questo rigo di misura per il "Vedi voce precedente", eliminalo ed aggiungine uno nuovo.')
6807 oSheet.getCellByPosition(4, lrow).Formula =
'=' + quantity
6819 for x
in range(2, 12):
6820 oSheet.getCellByPosition(x, lrow).CellStyle = (
6821 oSheet.getCellByPosition(x, lrow).CellStyle +
' ROSSO')
6827 Inserisce un riferimento a voce precedente sulla riga corrente.
6830 oSheet = oDoc.CurrentController.ActiveSheet
6832 if oSheet.getCellByPosition(2, lrow).String
not in (
'#N/A',
'#RIF!'):
6833 if oSheet.getCellByPosition(2, lrow).Type.value !=
'EMPTY':
6834 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
6836 elif oSheet.Name
in (
'CONTABILITA'):
6839 if oSheet.getCellByPosition(2, lrow).CellStyle ==
'comp 1-a':
6841 "Seleziona voce di riferimento o indica n. d'ordine")
6842 if oSheet.Name
not in to:
6845 to = int(to.split(
'$')[-1]) - 1
6856 Allunga una stringa fino a n.
6857 el { string } : stringa di partenza
6858 n { int } : numero di caratteri da aggiungere
6859 pos { int } : 0 = prefisso; 1 = suffisso
6875 valore { integer } : id formato
6876 attribuisce alla selezione di celle un formato numerico a scelta
6877 valore = 36 (dd/mm/yyyy)
6882 oFrame = desktop.getCurrentFrame()
6883 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
6884 'com.sun.star.frame.DispatchHelper', ctx)
6885 oProp = PropertyValue()
6886 oProp.Name =
'NumberFormatValue'
6887 oProp.Value = valore
6888 properties = (oProp, )
6889 dispatchHelper.executeDispatch(oFrame,
'.uno:NumberFormatValue',
'', 0,
6894 Converte in numeri le stringhe o viceversa.
6897 oSheet = oDoc.CurrentController.ActiveSheet
6899 sRow = oDoc.getCurrentSelection().getRangeAddresses()[0].StartRow
6900 sCol = oDoc.getCurrentSelection().getRangeAddresses()[0].StartColumn
6901 eRow = oDoc.getCurrentSelection().getRangeAddresses()[0].EndRow
6902 eCol = oDoc.getCurrentSelection().getRangeAddresses()[0].EndColumn
6903 except AttributeError:
6904 sRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
6905 sCol = oDoc.getCurrentSelection().getRangeAddress().StartColumn
6906 eRow = oDoc.getCurrentSelection().getRangeAddress().EndRow
6907 eCol = oDoc.getCurrentSelection().getRangeAddress().EndColumn
6908 if '/' in oSheet.getCellByPosition(sCol, sRow).String:
6910 for y
in range(sCol, eCol + 1):
6911 for x
in range(sRow, eRow + 1):
6913 if oSheet.getCellByPosition(y, x).Type.value ==
'TEXT':
6914 if '/' in oSheet.getCellByPosition(y, x).String:
6915 oSheet.getCellByPosition(y, x).Formula =
'=DATEVALUE("' + oSheet.getCellByPosition(y, x).String +
'")'
6916 oSheet.getCellByPosition(y, x).Value = oSheet.getCellByPosition(y, x).Value
6918 oSheet.getCellByPosition(y, x).Value = float(
6919 oSheet.getCellByPosition(y,
6920 x).String.replace(
',',
'.'))
6922 oSheet.getCellByPosition(
6923 y, x).String = oSheet.getCellByPosition(y, x).String
6934 Scrive la variabile globale che individua il Documento Principale (DCC)
6935 che è il file a cui giungono le voci di prezzo inviate da altri file
6938 if not oDoc.getSheets().hasByName(
'M1'):
6944 if len(oDoc.getURL()) == 0:
6946 Text=
'''Prima di procedere, devi salvare il lavoro!
6947 Provvedi subito a dare un nome al file.''')
6964 n { integer } : posizione cella
6965 a { string } : primo parametro da sostituire
6966 b { string } : secondo parametro da sostituire
6968 v = dict(n=n, a=a, b=b)
6970 18:
'=SUBTOTAL(9;S%(a)s:S%(b)s)',
6971 24:
'=S%(a)s/S%(b)s',
6972 29:
'=AE%(a)s/S%(b)s',
6973 30:
'=SUBTOTAL(9;AE%(a)s:AE%(b)s)'
6975 return formulas[n] % v
6980 level { integer } : livello(1 o 2)
6981 pos { integer } : posizione cella
6985 18:
'livello2 scritta mini',
6986 24:
'livello2 valuta mini %',
6987 29:
'livello2 valuta mini %',
6988 30:
'livello2 valuta mini'
6991 18:
'Livello-1-scritta mini val',
6992 24:
'Livello-1-scritta mini %',
6993 29:
'Livello-1-scritta mini %',
6994 30:
'Livello-1-scritta mini val'
6997 return styles[level][pos]
7001 """ Inserisce i dati nella riga
7002 sub { boolean } : specifica se sotto-categoria
7006 'livello2 scritta mini',
7007 'Livello-1-scritta minival',
7013 'Livello-1-scritta mini val',
7019 oSheet = oDoc.CurrentController.ActiveSheet
7020 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE'):
7024 for n
in range(lrow + 1, lrowE):
7025 if oSheet.getCellByPosition(18, n).CellStyle
in myrange:
7050 oSheet.getCellByPosition(n, lrow).Formula =
get_Formula(n, a, b)
7051 oSheet.getCellByPosition(18, lrow).CellStyle =
getCellStyle(level, n)
7061 Applica un filtro di visualizzazione sulla base del codice di voce selezionata.
7062 Lanciando il comando da Elenco Prezzi, il comportamento è regolato dal valore presente nella cella 'C2'
7069 Applica un filtro di visualizzazione sulla base del codice di voce selezionata.
7070 Lanciando il comando da Elenco Prezzi, il comportamento è regolato dal valore presente nella cella 'C2'
7076 oSheet = oDoc.CurrentController.ActiveSheet
7081 if oSheet.Name ==
"Elenco Prezzi":
7082 oCell = oSheet.getCellRangeByName(
'C2')
7083 voce = oDoc.Sheets.getByName(
'Elenco Prezzi').getCellByPosition(
7090 if oCell.String ==
'<DIALOGO>' or oCell.String ==
'':
7092 elaborato = DLG.ScegliElaborato(
'Ricerca di ' + voce)
7097 elaborato = oSheet.getCellByPosition(2, 1).String
7102 oSheet = oDoc.Sheets.getByName(elaborato)
7105 oSheet.clearOutline()
7107 if oSheet.getCellByPosition(0, lrow).CellStyle
in (stili_computo + stili_contab):
7108 iSheet = oSheet.RangeAddress.Sheet
7109 oCellRangeAddr = uno.createUnoStruct(
7110 'com.sun.star.table.CellRangeAddress')
7111 oCellRangeAddr.Sheet = iSheet
7113 sopra = sStRange.RangeAddress.StartRow
7115 voce = oSheet.getCellByPosition(1, sopra + 1).String
7119 Text=
'''Devi prima selezionare una voce di misurazione.''')
7123 progress =
Dialogs.Progress(Title=
'Applicazione filtro in corso...', Text=
"Lettura dati")
7124 progress.setLimits(0, fine)
7125 progress.setValue(0)
7131 for n
in range(0, fine):
7132 progress.setValue(n)
7133 if oSheet.getCellByPosition(0,
7134 n).CellStyle
in (
'Comp Start Attributo',
7135 'Comp Start Attributo_R'):
7137 sopra = sStRange.RangeAddress.StartRow
7138 sotto = sStRange.RangeAddress.EndRow
7139 if oSheet.getCellByPosition(1, sopra + 1).String != voce:
7140 lista_pt.append((sopra, sotto))
7148 progress.setValue(fine)
7150 oCellRangeAddr.StartRow = el[0]
7151 oCellRangeAddr.EndRow = el[1]
7152 oSheet.group(oCellRangeAddr, 1)
7153 oSheet.getCellRangeByPosition(0, el[0], 0,
7154 el[1]).Rows.IsVisible =
False
7171 oSheet = oDoc.CurrentController.ActiveSheet
7173 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
7175 elif oSheet.Name ==
'Elenco Prezzi':
7177 elif oSheet.Name ==
'Analisi di Prezzo':
7179 elif oSheet.Name
in (
'CONTABILITA',
'Registro',
'SAL'):
7188 oSheet = oDoc.CurrentController.ActiveSheet
7189 oSheet.clearOutline()
7191 progress =
Dialogs.Progress(Title=
'Creazione vista struttura in corso...', Text=
"Lettura dati")
7192 progress.setLimits(0, 5)
7193 progress.setValue(0)
7196 progress.setValue(1)
7198 progress.setValue(2)
7200 progress.setValue(3)
7202 progress.setValue(4)
7204 progress.setValue(5)
7213 oSheet = oDoc.CurrentController.ActiveSheet
7214 oSheet.clearOutline()
7220 Cancella la vista in struttura
7227 Cancella la vista in struttura
7232 oSheet = oDoc.CurrentController.ActiveSheet
7233 oSheet.clearOutline()
7234 oDoc.CurrentController.setFirstVisibleColumn(0)
7235 oDoc.CurrentController.setFirstVisibleRow(lrow - 4)
7236 _gotoCella( x, lrow)
7240 ''' mette in vista struttura secondo categorie
7241 level { integer } : specifica il livello di categoria
7242 ### COMPUTO/VARIANTE ###
7246 3 = intera voce di misurazione
7248 4 = simile all'elenco prezzi
7251 oSheet = oDoc.CurrentController.ActiveSheet
7252 iSheet = oSheet.RangeAddress.Sheet
7253 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
7254 oCellRangeAddr.Sheet = iSheet
7257 stile =
'Livello-0-scritta'
7259 'Livello-0-scritta',
7265 stile =
'Livello-1-scritta'
7267 'Livello-1-scritta',
7268 'Livello-0-scritta',
7274 stile =
'livello2 valuta'
7277 'Livello-1-scritta',
7278 'Livello-0-scritta',
7284 stile =
'Comp Start Attributo'
7286 'Comp End Attributo',
7293 stile =
'An-1_sigla'
7308 for n
in range(0, test):
7309 if oSheet.getCellByPosition(0, n).CellStyle == stile:
7311 for n
in range(sopra + 1, test):
7312 if oSheet.getCellByPosition(0, n).CellStyle
in myrange:
7314 lista_cat.append((sopra, sotto))
7316 for el
in lista_cat:
7317 oCellRangeAddr.StartRow = el[0]
7318 oCellRangeAddr.EndRow = el[1]
7319 oSheet.group(oCellRangeAddr, 1)
7320 oSheet.getCellRangeByPosition(0, el[0], 0, el[1]).Rows.IsVisible =
False
7329 apri.execute(
LeenO_path() +
'/MANUALE_LeenO.pdf',
"", 0)
7338 Toolbars.Switch(
True)
7342 Toolbars.On(
'private:resource/toolbar/addon_ULTIMUS_3.OfficeToolBar_DEV', 0)
7343 for el
in (
'COMPUTO',
'VARIANTE',
'Elenco Prezzi',
'CONTABILITA',
7344 'Analisi di Prezzo'):
7346 oSheet = oDoc.Sheets.getByName(el)
7347 oSheet.getCellRangeByName(
"A1:AT1").clearContents(EDITATTR +
7350 oSheet.getCellRangeByName(
"A1").String =
''
7357 '''Avvia processi automatici ad intervalli definiti di tempo'''
7359 threading.Thread.__init__(self)
7363 minuti = 60 * int(cfg.read(
'Generale',
'pausa_backup'))
7373 if int(cfg.read(
'Generale',
'copie_backup')) != 0:
7388 questa è richiamata da creaComputo()
7400 oGSheetSettings = ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.sheet.GlobalSheetSettings", ctx)
7402 oGSheetSettings.UsePrinterMetrics =
True
7406 node.CreateBackup =
True
7407 node.commitChanges()
7408 uso = int(cfg.read(
'Generale',
'conta_usi')) + 1
7410 if uso == 10
or (uso % 50) == 0:
7412 cfg.write(
'Generale',
'conta_usi', str(uso))
7413 if cfg.read(
'Generale',
'movedirection') ==
'0':
7414 oGSheetSettings.MoveDirection = 0
7416 oGSheetSettings.MoveDirection = 1
7421 oDoc.Wildcards =
False
7424 oDoc.RegularExpressions =
False
7425 oDoc.CalcAsShown =
True
7427 oSheet = oDoc.CurrentController.ActiveSheet
7428 for nome
in (
'VARIANTE',
'CONTABILITA',
'COMPUTO'):
7453 Settaggio base di configurazione colonne in COMPUTO e VARIANTE
7458 oSheet = oDoc.CurrentController.ActiveSheet
7461 ncol = oSheet.getColumns().getCount()
7462 iSheet = oSheet.RangeAddress.Sheet
7463 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
7464 oCellRangeAddr.Sheet = iSheet
7465 if oSheet.Name
in (
'COMPUTO',
'VARIANTE'):
7467 elif oSheet.Name ==
'CONTABILITA':
7469 oCellRangeAddr.StartColumn = col
7470 oCellRangeAddr.EndColumn = ncol
7471 oSheet.ungroup(oCellRangeAddr, 0)
7472 oSheet.group(oCellRangeAddr, 0)
7474 oSheet.getCellRangeByPosition(col, 0, ncol -1, 0).Columns.IsVisible =
False
7484 Apre un nuovo foglio e vi inserisce tutti gli stili di cella
7485 con relativo esempio
7488 sty = oDoc.StyleFamilies.getByName(
"CellStyles").getElementNames()
7489 if oDoc.Sheets.hasByName(
"stili"):
7490 oSheet = oDoc.Sheets.getByName(
"stili")
7492 sheet = oDoc.createInstance(
"com.sun.star.sheet.Spreadsheet")
7493 unione = oDoc.Sheets.insertByName(
'stili', sheet)
7494 oSheet = oDoc.Sheets.getByName(
"stili")
7497 progress =
Dialogs.Progress(Title=
'Stili cella', Text=
"Scrittura in corso...")
7498 progress.setLimits(0, len(sty))
7503 oSheet.getCellByPosition( 0, i).String = el
7504 oSheet.getCellByPosition( 1, i).CellStyle = el
7505 oSheet.getCellByPosition( 3, i).CellStyle = el
7506 oSheet.getCellByPosition( 1, i).Value = 2000.00
7507 oSheet.getCellByPosition( 3, i).String =
"LeenO"
7509 progress.setValue(i)
7518 stili = oDoc.StyleFamilies.getByName(
'CellStyles').getElementNames()
7520 if not oDoc.StyleFamilies.getByName(
'CellStyles').getByName(el).isInUse():
7521 oDoc.StyleFamilies.getByName(
'CellStyles').removeByName(el)
7527 Inserisce tutti i dati e gli stili per preparare il lavoro.
7528 lanciata in autoexec()
7533 oDoc.getSheets().getByName(
'copyright_LeenO').getCellRangeByName(
7534 'A3').String =
'# © 2001-2013 Bartolomeo Aimar - © 2014-' + str(
7535 datetime.now().year) +
' Giuseppe Vizziello'
7537 oUDP = oDoc.getDocumentProperties().getUserDefinedProperties()
7538 oSheet = oDoc.getSheets().getByName(
'S1')
7540 oSheet.getCellRangeByName(
'G219').String =
'Copyright 2014-' + str(datetime.now().year)
7543 rvc = version_code.read().split(
'-')[0]
7544 if isinstance(rvc, str):
7545 oSheet.getCellRangeByName(
'H194').String = rvc
7547 oSheet.getCellRangeByName(
'H194').Value = rvc
7551 oSheet.getCellRangeByName(
'H291').Value = oUDP.Versione
7552 oSheet.getCellRangeByName(
'I291').String = oUDP.Versione_LeenO.split(
'.')[0]
7553 oSheet.getCellRangeByName(
'J291').String = oUDP.Versione_LeenO.split(
'.')[1]
7555 oSheet.getCellRangeByName(
'H295').String = oUDP.Versione_LeenO.split(
'.')[0]
7556 oSheet.getCellRangeByName(
'I295').String = oUDP.Versione_LeenO.split(
'.')[1]
7557 oSheet.getCellRangeByName(
'J295').String = oUDP.Versione_LeenO.split(
'.')[2]
7564 if oDoc.getSheets().hasByName(
'CONTABILITA'):
7565 oSheet.getCellRangeByName(
'H328').Value = 1
7567 oSheet.getCellRangeByName(
'H328').Value = 0
7570 oCell = oDoc.getSheets().getByName(
'Elenco Prezzi').getCellRangeByName(
'C2')
7572 '"<DIALOGO>";"COMPUTO";"VARIANTE";"CONTABILITA"',
7573 titoloInput=
'Scegli...',
7574 msgInput=
'Applica Filtra Codice a...',
7576 oCell.String =
"<DIALOGO>"
7577 oCell.CellStyle =
'EP-aS'
7578 oCell = oDoc.getSheets().getByName(
'Elenco Prezzi').getCellRangeByName(
'C1')
7579 oCell.String =
"Applica Filtro a:"
7580 oCell.CellStyle =
'EP-aS'
7582 oCell = oDoc.getSheets().getByName(
'cP_Cop').getCellRangeByName(
'B19')
7585 '"ANALISI DI PREZZO";"ELENCO PREZZI";"ELENCO PREZZI E COSTI ELEMENTARI";\
7586 "COMPUTO METRICO";"PERIZIA DI VARIANTE";"LIBRETTO DELLE MISURE";"REGISTRO DI CONTABILITÀ";\
7587 "S.A.L. A TUTTO IL"',
7588 titoloInput=
'Scegli...',
7589 msgInput=
'Titolo della copertina...',
7600 Mantengo la compatibilità con le vecchie versioni del template:
7601 - dal 200 parte di autoexec è in python
7602 - dal 203(LeenO 3.14.0 ha templ 202) introdotta la Super Categoria con nuovi stili di cella;
7603 sostituita la colonna "Tag A" con "Tag Super Cat"
7604 - dal 207 introdotta la colonna dei materiali in computo e contabilità
7605 - dal 209 cambia il nome di proprietà del file in "Versione_LeenO"
7606 - dal 211 cambiano le formule del prezzo unitario e dell'importo in Computo e Contabilità
7607 - dal 212 vengono cancellate le celle che indicano il DCC nel foglio M1
7608 - dal 213 sposta il VediVoce nella colonna E
7609 - dal 214 assegna un'approssimazione diversa per ognuno dei valori di misurazione
7610 - dal 215 adegua del formule degli importi ai prezzi in %
7611 - dal 216 aggiorna le formule in CONTABILITA
7612 - dal 217 aggiorna le formule in COMPUTO
7616 oDoc.enableAutomaticCalculation(
False)
7619 ver_tmpl = oDoc.getDocumentProperties().getUserDefinedProperties().Versione
7625 if ver_tmpl < adegua_a:
7627 Text=
'''Vuoi procedere con l'adeguamento di questo file
7628 alla versione di LeenO installata?''') == 0:
7630 Text=
'''Non avendo effettuato l'adeguamento del file alla versione
7631 di LeenO installata, potresti avere dei malfunzionamenti!''')
7635 if oDoc.getSheets().hasByName(
'S4'):
7636 oDoc.Sheets.removeByName(
'S4')
7639 Text=
"Lettura dati")
7640 progress.setLimits(0, 10)
7641 progress.setValue(0)
7646 progress.setValue(1)
7647 for el
in (
'comp 1-a PU',
'comp 1-a LUNG',
'comp 1-a LARG',
7648 'comp 1-a peso',
'comp 1-a',
'Blu',
7649 'Comp-Variante num sotto'):
7650 oStileCella = oDoc.createInstance(
"com.sun.star.style.CellStyle")
7651 if not oDoc.StyleFamilies.getByName(
'CellStyles').hasByName(el):
7652 oDoc.StyleFamilies.getByName(
'CellStyles').insertByName(
7654 oStileCella.ParentStyle =
'comp 1-a'
7655 progress.setValue(2)
7656 for el
in (
'comp 1-a PU',
'comp 1-a LUNG',
'comp 1-a LARG',
7657 'comp 1-a peso',
'comp 1-a',
'Blu',
7658 'Comp-Variante num sotto'):
7659 oStileCella = oDoc.createInstance(
"com.sun.star.style.CellStyle")
7660 if not oDoc.StyleFamilies.getByName(
"CellStyles").hasByName(el +
' ROSSO'):
7661 oDoc.StyleFamilies.getByName(
'CellStyles').insertByName(
7662 el +
' ROSSO', oStileCella)
7663 oStileCella.ParentStyle =
'comp 1-a'
7664 oDoc.StyleFamilies.getByName(
"CellStyles").getByName(
7665 el +
' ROSSO').CharColor = 16711680
7672 progress.setValue(3)
7673 oSheet = oDoc.getSheets().getByName(
'S1')
7674 oSheet.getCellRangeByName(
'S1.H291').Value = \
7675 oDoc.getDocumentProperties().getUserDefinedProperties().Versione = adegua_a
7676 for el
in oDoc.Sheets.ElementNames:
7677 oDoc.getSheets().getByName(el).IsVisible =
True
7678 oDoc.CurrentController.setActiveSheet(oDoc.getSheets().getByName(el))
7679 oDoc.getSheets().getByName(el).IsVisible =
False
7681 flags = VALUE + DATETIME + STRING + ANNOTATION + FORMULA + OBJECTS + EDITATTR
7682 progress.setValue(4)
7684 oSheet = oDoc.getSheets().getByName(
'M1')
7685 oSheet.getCellRangeByName(
'B23:E30').clearContents(flags)
7686 oSheet.getCellRangeByName(
'B23:E30').CellStyle =
'M1 scritte noP'
7690 oSheet = oDoc.getSheets().getByName(
'S1')
7691 oSheet.getCellRangeByName(
7693 ).String =
'[Computo e Variante] Vedi Voce: PRIMI caratteri della voce'
7694 oSheet.getCellRangeByName(
'H334').Value = 50
7695 oSheet.getCellRangeByName(
7697 ).String =
"Quanti caratteri della descrizione vuoi visualizzare usando il Vedi Voce?"
7698 oSheet.getCellRangeByName(
7700 ).String =
'[Contabilità] Descrizioni abbreviate: PRIMI caratteri della voce'
7701 oSheet.getCellRangeByName(
'H335').Value = 100
7702 oSheet.getCellRangeByName(
7704 ).String =
"Quanti caratteri vuoi visualizzare partendo dall'INIZIO della descrizione?"
7705 oSheet.getCellRangeByName(
7707 ).String =
'Descrizioni abbreviate: primi caratteri della voce'
7708 oSheet.getCellRangeByName(
'H336').Value = 120
7709 oSheet.getCellRangeByName(
7711 ).String =
"[Contabilità] Descrizioni abbreviate: ULTIMI caratteri della voce"
7712 oSheet.getCellRangeByName(
7714 ).String =
'Descrizioni abbreviate: primi caratteri della voce'
7715 oSheet.getCellRangeByName(
'H337').Value = 100
7716 oSheet.getCellRangeByName(
7718 ).String =
"Quanti caratteri vuoi visualizzare partendo dall'INIZIO della descrizione?"
7719 oSheet.getCellRangeByName(
7721 ).String =
'Descrizioni abbreviate: ultimi caratteri della voce'
7722 oSheet.getCellRangeByName(
'H338').Value = 120
7723 oSheet.getCellRangeByName(
7725 ).String =
"Quanti caratteri vuoi visualizzare partendo dalla FINE della descrizione?"
7726 oSheet.getCellRangeByName(
'L25').String =
''
7727 oSheet.getCellRangeByName(
'G297:G338').CellStyle =
'Setvar b'
7728 oSheet.getCellRangeByName(
'H297:H338').CellStyle =
'Setvar C'
7729 oSheet.getCellRangeByName(
'I297:I338').CellStyle =
'Setvar D'
7730 oSheet.getCellRangeByName(
'H319:H326').CellStyle =
'Setvar C_3'
7731 oSheet.getCellRangeByName(
'H311').CellStyle =
'Setvar C_3'
7732 oSheet.getCellRangeByName(
'H323').CellStyle =
'Setvar C'
7733 oDoc.StyleFamilies.getByName(
"CellStyles").getByName(
7737 oUDP = oDoc.getDocumentProperties().getUserDefinedProperties()
7738 if oUDP.getPropertySetInfo().hasPropertyByName(
"Versione LeenO"):
7739 oUDP.removeProperty(
'Versione LeenO')
7740 if oUDP.getPropertySetInfo().hasPropertyByName(
"Versione_LeenO"):
7741 oUDP.removeProperty(
'Versione_LeenO')
7742 oUDP.addProperty(
'Versione_LeenO',
7743 MAYBEVOID + REMOVEABLE + MAYBEDEFAULT,
7746 progress.setValue(5)
7747 for el
in (
'COMPUTO',
'VARIANTE'):
7748 if oDoc.getSheets().hasByName(el):
7750 oSheet = oDoc.getSheets().getByName(el)
7753 oSheet.getCellRangeByPosition(3, 0, 4,
7754 fine).clearContents(HARDATTR)
7755 for n
in range(0, fine):
7756 if '=CONCATENATE("' in oSheet.getCellByPosition(
7757 2, n).Formula
and oSheet.getCellByPosition(
7758 4, n).Type.value ==
'EMPTY':
7759 oSheet.getCellByPosition(
7760 4, n).Formula = oSheet.getCellByPosition(5,
7762 oSheet.getCellByPosition(5, n).String =
''
7763 oSheet.getCellByPosition(
7765 ).Formula =
'=IF(PRODUCT(E' + str(n + 1) +
':I' + str(
7766 n + 1) +
')=0;"";PRODUCT(E' + str(
7767 n + 1) +
':I' + str(n + 1) +
'))'
7769 oSheet.getCellByPosition(31, 2).String =
'Super Cat'
7770 oSheet.getCellByPosition(32, 2).String =
'Cat'
7771 oSheet.getCellByPosition(33, 2).String =
'Sub Cat'
7772 oSheet.getCellByPosition(28, 2).String =
'Materiali\ne Noli €'
7775 oDoc.CurrentController.select(
7776 oSheet.getCellByPosition(0, lrow))
7783 for y
in range(0, test):
7787 if(oSheet.getCellByPosition(2, y).Type.value ==
'FORMULA' and
7788 oSheet.getCellByPosition(2, y).CellStyle ==
'comp 1-a' and
7789 oSheet.getCellByPosition(5, y).Type.value ==
'FORMULA'):
7792 oSheet.getCellByPosition(
7793 5, y).Formula.split(
'=J$')[-1]) - 1
7796 oSheet.getCellByPosition(
7797 5, y).Formula.split(
'=J')[-1]) - 1
7798 if oSheet.getCellByPosition(9, y).Value < 0:
7801 oSheet.getCellByPosition(5, y).String =
''
7808 if '=J' in oSheet.getCellByPosition(5, y).Formula:
7809 if '$' in oSheet.getCellByPosition(5, y).Formula:
7810 n = oSheet.getCellByPosition(
7811 5, y).Formula.split(
'$')[1]
7813 n = oSheet.getCellByPosition(
7814 5, y).Formula.split(
'J')[1]
7815 oSheet.getCellByPosition(5, y).Formula =
'=J$' + n
7818 progress.setValue(6)
7820 oSheet = oDoc.getSheets().getByName(
'S5')
7821 oSheet.getCellRangeByPosition(
7824 FORMATTED + HARDATTR)
7825 oSheet.getCellRangeByName(
'C10').Formula = \
7826 '=IF(LEN(VLOOKUP(B10;elenco_prezzi;2;FALSE()))<($S1.$H$337+$S1.$H$338);\
7827 VLOOKUP(B10;elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B10;\
7828 elenco_prezzi;2;FALSE());$S1.$H$337);" [...] ";RIGHT(VLOOKUP(B10;\
7829 elenco_prezzi;2;FALSE());$S1.$H$338)))'
7830 oSheet.getCellRangeByName(
'C24').Formula = \
7831 '=IF(LEN(VLOOKUP(B24;elenco_prezzi;2;FALSE()))<($S1.$H$335+$S1.$H$336);VLOOKUP(B24;\
7832 elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B24;elenco_prezzi;\
7833 2;FALSE());$S1.$H$335);" [...] ";RIGHT(VLOOKUP(B24;elenco_prezzi;2;\
7834 FALSE());$S1.$H$336)))'
7835 oSheet.getCellRangeByName(
'I24').CellStyle =
'Comp-Bianche in mezzo_R'
7836 oSheet.getCellRangeByName(
'S12').Formula =
'=IF(VLOOKUP(B10;elenco_prezzi;3;FALSE())="%";J12*L12/100;J12*L12)'
7837 oSheet.getCellRangeByName(
'P27').Formula =
'=IF(VLOOKUP(B24;elenco_prezzi;3;FALSE())="%";J27*N27/100;J27*N27)'
7839 oSheet.getCellRangeByName(
'AC12').Formula =
'=S12-AE12'
7840 oSheet.getCellRangeByName(
'AC12').CellStyle =
'Comp-sotto euri'
7841 oSheet.getCellRangeByName(
'AC27').Formula =
'=P27-AE27'
7842 oSheet.getCellRangeByName(
'AC27').CellStyle =
'Comp-sotto euri'
7844 oSheet.getCellRangeByName(
'J11').Formula =
'=IF(PRODUCT(E11:I11)=0;"";PRODUCT(E11:I11))'
7845 oSheet.getCellRangeByName(
'J25').CellStyle =
'Blu'
7846 oSheet.getCellRangeByName(
'J25').Formula =
'=IF(PRODUCT(E25:I25)<=0;"";PRODUCT(E25:I25))'
7848 oSheet.getCellRangeByName(
'L25').CellStyle =
'Blu ROSSO'
7849 oSheet.getCellRangeByName(
'L25').Formula =
'=IF(PRODUCT(E25:I25)>=0;"";PRODUCT(E25:I25)*-1)'
7851 oSheet.getCellRangeByName(
'J26').Formula =
'=IF(SUBTOTAL(9;J24:J26)<0;"";SUBTOTAL(9;J24:J26))'
7852 oSheet.getCellRangeByName(
'L26').Formula =
'=IF(SUBTOTAL(9;L24:L26)<0;"";SUBTOTAL(9;L24:L26))'
7853 oSheet.getCellRangeByName(
'L26').CellStyle =
'Comp-Variante num sotto ROSSO'
7856 progress.setValue(7)
7857 if oDoc.getSheets().hasByName(
'CONTABILITA'):
7859 oSheet = oDoc.getSheets().getByName(
'CONTABILITA')
7862 oSheet.getCellRangeByPosition(3, 0, 4,
7863 fine).clearContents(HARDATTR)
7864 for n
in range(0, fine):
7865 if '=CONCATENATE("' in oSheet.getCellByPosition(
7866 2, n).Formula
and oSheet.getCellByPosition(
7867 4, n).Type.value ==
'EMPTY':
7868 oSheet.getCellByPosition(
7869 4, n).Formula = oSheet.getCellByPosition(5, n).Formula
7870 oSheet.getCellByPosition(5, n).String =
''
7871 oSheet.getCellByPosition(
7873 n).Formula =
'=IF(PRODUCT(E' + str(n + 1) +
':I' + str(
7874 n + 1) +
')=0;"";PRODUCT(E' + str(
7875 n + 1) +
':I' + str(n + 1) +
'))'
7878 oSheet.getCellByPosition(
7879 28, n + 1).Formula =
'=SUBTOTAL(9;AC3:AC' + str(n + 2)
7883 oDoc.CurrentController.select(oSheet.getCellByPosition(0, lrow))
7887 for el
in oDoc.Sheets.ElementNames:
7888 oDoc.CurrentController.setActiveSheet(
7889 oDoc.getSheets().getByName(el))
7890 oSheet = oDoc.getSheets().getByName(el)
7893 progress.setValue(8)
7898 for el
in (
'COMPUTO',
'VARIANTE',
'CONTABILITA'):
7900 oSheet = oDoc.getSheets().getByName(el)
7907 Dialogs.Info(Title =
'Avviso', Text=
'Adeguamento del file completato con successo.')
7915 Visualizza il menù export/import XPWE
7918 if not oDoc.getSheets().hasByName(
'S2'):
7921 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
7922 Dialog_XPWE = dp.createDialog(
7923 "vnd.sun.star.script:UltimusFree2.Dialog_XPWE?language=Basic&location=application"
7925 oSheet = oDoc.CurrentController.ActiveSheet
7927 for el
in (
"COMPUTO",
"VARIANTE",
"CONTABILITA",
"Elenco Prezzi"):
7929 importo = oDoc.getSheets().getByName(el).getCellRangeByName(
7932 Dialog_XPWE.getControl(el).Label =
'Computo: €: ' + importo
7933 if el ==
'VARIANTE':
7934 Dialog_XPWE.getControl(el).Label =
'Variante: €: ' + importo
7935 if el ==
'CONTABILITA':
7936 Dialog_XPWE.getControl(el).Label =
'Contabilità: €: ' + importo
7937 Dialog_XPWE.getControl(el).Enable =
True
7939 Dialog_XPWE.getControl(el).Enable =
False
7940 Dialog_XPWE.Title =
'Esportazione XPWE'
7942 Dialog_XPWE.getControl(oSheet.Name).State =
True
7945 Dialog_XPWE.getControl(
7947 ).Text =
'C:\\tmp\\prova.txt'
7955 if Dialog_XPWE.execute() == 1:
7956 for el
in (
"COMPUTO",
"VARIANTE",
"CONTABILITA",
"Elenco Prezzi"):
7957 if Dialog_XPWE.getControl(el).State == 1:
7965 testo = testo +
'● ' + out_file +
'-' + el +
'.xpwe\n\n'
7968 Text=
'Esportazione in formato XPWE eseguita con successo su:\n' + testo)
7977 oDialog1.endExecute()
7989 Indica qual è il Documento Principale
8000 if sUltimus == uno.fileUrlToSystemPath(oDoc.getURL()):
8009 oSheet = oDoc.CurrentController.ActiveSheet
8010 except AttributeError:
8016 'Elenco Prezzi':
'A1',
8017 'CONTABILITA':
'F1',
8018 'Analisi di Prezzo':
'A1'
8022 oSheet = oDoc.Sheets.getByName(el)
8024 oSheet.getCellRangeByName(
"A1:AT1").clearContents(EDITATTR + FORMATTED + HARDATTR)
8033 Genera il PDF del file ODS partendo dalle aree di stampa impostate.
8034 oDoc { object } : documento da esportare.
8035 sFile { string } : nome del file di destinazione.
8039 oFrame = desktop.getCurrentFrame()
8041 oProp0 = PropertyValue()
8043 oProp0.Value = sFile
8044 oProp1 = PropertyValue()
8045 oProp1.Name =
"FilterName"
8046 oProp1.Value =
"calc_pdf_Export"
8047 oProp2 = PropertyValue()
8048 oProp2.Name =
"FilterData"
8050 oProp.append(oProp0)
8051 oProp.append(oProp1)
8052 oProp.append(oProp2)
8053 properties = tuple(oProp)
8054 dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
'com.sun.star.frame.DispatchHelper', ctx)
8055 dispatchHelper.executeDispatch(oFrame,
'.uno:ExportToPDF',
'', 0, properties)
8063 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
8064 oDlgPDF = dp.createDialog(
8065 "vnd.sun.star.script:UltimusFree2.DlgPDF?language=Basic&location=application"
8067 sUrl =
LeenO_path() +
'/python/pythonpath/Icons-Big/preview.png'
8068 oDlgPDF.getModel().ImageControl1.ImageURL = sUrl
8070 oSheet = oDoc.getSheets().getByName(
'S2')
8072 progetto = oSheet.getCellRangeByName(
'$S2.C3').String
8073 localit = oSheet.getCellRangeByName(
'$S2.C4').String
8074 data_prg = oSheet.getCellRangeByName(
'$S2.C5').String
8075 committente = oSheet.getCellRangeByName(
'$S2.C6').String
8076 sponsor = oSheet.getCellRangeByName(
'$S2.C7').String
8077 rup = oSheet.getCellRangeByName(
'$S2.C12').String
8078 progettista = oSheet.getCellRangeByName(
'$S2.C13').String
8079 dl = oSheet.getCellRangeByName(
'$S2.C16').String
8081 'progetto' :
'[PROGETTO]',
8082 'localit' :
'[LOCALITÀ]',
8083 'data_prg' :
'[DATA_PROGETTO]',
8084 'committente' :
'[COMMITTENTE-STAZIONE APPALTANTE]',
8085 'sponsor' :
'[FINANZIATORE]',
8086 'rup' :
'[RESPONSABILE_PROCEDIMENTO]',
8087 'progettista' :
'[PROGETTISTA]',
8088 'dl' :
'[DIRETTORE_LAVORI]',
8093 lista = list(formulas.values())
8096 oDlgPDF.getControl(
"ComboBox1").addItems(lista, 1)
8103 Visualizza il menù principale dialog_fil
8107 oDoc.unlockControllers()
8109 oSheet = oDoc.CurrentController.ActiveSheet
8110 if not oDoc.getSheets().hasByName(
'S2'):
8112 if(len(oDoc.getURL()) == 0
and
8118 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
8119 oDlgMain = dp.createDialog(
8120 "vnd.sun.star.script:UltimusFree2.DlgMain?language=Basic&location=application"
8124 oDlgMain.Title =
'Menù Principale (Ctrl+0)'
8127 oDlgMain.getModel().ImageControl1.ImageURL = sUrl
8129 sString = oDlgMain.getControl(
"CommandButton13")
8132 sString.setEnable(
False)
8134 sString.setEnable(
True)
8138 sString = oDlgMain.getControl(
"Label12")
8139 sString.Text = version_code.read()
8140 sString = oDlgMain.getControl(
"Label_DDC")
8143 sString = oDlgMain.getControl(
"Label1")
8149 sString = oDlgMain.getControl(
"Label2")
8151 oSheet = oDoc.Sheets.getByName(
'S1')
8154 sString.Text = oDoc.getDocumentProperties().getUserDefinedProperties(
8157 sString = oDlgMain.getControl(
"TextField1")
8159 sString.Text = oDoc.Sheets.getByName(
'S2').getCellRangeByName(
'C3').String
8161 oSheet = oDoc.Sheets.getByName(
'COMPUTO')
8162 sString = oDlgMain.getControl(
"Label8")
8163 sString.Text =
"€ {:,.2f}".format(
8164 oSheet.getCellByPosition(18, 1).Value)
8168 oSheet = oDoc.Sheets.getByName(
'VARIANTE')
8169 sString = oDlgMain.getControl(
"Label5")
8170 sString.Text =
"€ {:,.2f}".format(
8171 oSheet.getCellByPosition(18, 1).Value)
8175 oSheet = oDoc.Sheets.getByName(
'CONTABILITA')
8176 sString = oDlgMain.getControl(
"Label9")
8177 sString.Text =
"€ {:,.2f}".format(
8178 oSheet.getCellByPosition(15, 1).Value)
8183 oDlgMain.getControl(
'CheckBox1').State = int(
8184 cfg.read(
'Generale',
'dialogo'))
8188 sString = oDlgMain.getControl(
"Label_DDC").Text
8189 if oDlgMain.getControl(
'CheckBox1').State == 1:
8190 cfg.write(
'Generale',
'dialogo',
'1')
8194 cfg.write(
'Generale',
'dialogo',
'0')
8196 oDoc.Sheets.getByName(
'S2').getCellRangeByName(
8197 'C3').String = oDlgMain.getControl(
"TextField1").Text
8202 'Elenco Prezzi':
'A1',
8203 'CONTABILITA':
'F1',
8204 'Analisi di Prezzo':
'A1'
8208 oSheet = oDoc.Sheets.getByName(el)
8210 oSheet.getCellRangeByName(
8211 "A1:AT1").CellBackColor = 16773632
8212 oSheet.getCellRangeByName(
8213 d[el]).String =
'DP: Questo documento'
8215 oSheet.getCellRangeByName(
8216 "A1:AT1").clearContents(HARDATTR)
8217 oSheet.getCellRangeByName(
8228 sCella { string } : stringa di default nella casella di testo
8229 t { string } : titolo del dialogo
8230 Visualizza un dialogo di richiesta testo
8234 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
8235 oDialog1 = dp.createDialog(
8236 "vnd.sun.star.script:UltimusFree2.DlgTesto?language=Basic&location=application"
8238 oDialog1Model = oDialog1.Model
8240 oDialog1Model.Title = t
8242 sString = oDialog1.getControl(
"TextField1")
8243 sString.Text = sCella
8245 if oDialog1.execute() == 0:
8253 lErrori { tuple } : nome dell'errore es.: '#DIV/0!'
8254 icol { integer } : indice di colonna della riga da nascondere
8255 Visualizza o nascondi una toolbar
8259 oSheet = oDoc.CurrentController.ActiveSheet
8263 iSheet = oSheet.RangeAddress.Sheet
8264 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
8265 oCellRangeAddr.Sheet = iSheet
8266 for i
in range(n, test):
8268 if oSheet.getCellByPosition(icol, i).String == el:
8269 oCellRangeAddr.StartRow = i
8270 oCellRangeAddr.EndRow = i
8271 oSheet.group(oCellRangeAddr, 1)
8272 oSheet.getCellByPosition(0, i).Rows.IsVisible =
False
8278 Fa il backup del file di lavoro all'apertura.
8282 orig = oDoc.getURL()
8283 dest =
'.'.join(os.path.basename(orig).split(
'.')[0:-1]) +
'.bak.ods'
8284 dir_bak = os.path.dirname(oDoc.getURL()) +
'/leeno-bk/'
8286 dir_bak = uno.fileUrlToSystemPath(dir_bak)
8292 if not os.path.exists(dir_bak):
8293 os.makedirs(dir_bak)
8294 orig = uno.fileUrlToSystemPath(orig)
8295 dest = uno.fileUrlToSystemPath(dest)
8296 if os.path.exists(dir_bak + dest):
8297 shutil.copyfile(dir_bak + dest, dir_bak + dest +
'.old')
8298 shutil.copyfile(orig, dir_bak + dest)
8304 Esegue un numero definito di backup durante il lavoro.
8306 tempo =
''.join(
''.join(
''.join(
8307 str(datetime.now()).split(
'.')[0].split(
' ')).split(
'-')).split(
8310 orig = oDoc.getURL()
8312 os.path.basename(orig).split(
'.')[0:-1]) +
'-' + tempo +
'.ods'
8313 dir_bak = os.path.dirname(oDoc.getURL()) +
'/leeno-bk/'
8314 filename =
'.'.join(os.path.basename(orig).split(
'.')[0:-1]) +
'-'
8317 if not os.path.exists(uno.fileUrlToSystemPath(dir_bak)):
8318 os.makedirs(uno.fileUrlToSystemPath(dir_bak))
8319 orig = uno.fileUrlToSystemPath(orig)
8320 dest = uno.fileUrlToSystemPath(dest)
8321 oDoc.storeToURL(dir_bak + dest, list())
8322 lista = os.listdir(uno.fileUrlToSystemPath(dir_bak))
8324 nb = int(cfg.read(
'Generale',
'copie_backup'))
8325 for el
in reversed(lista):
8328 os.remove(uno.fileUrlToSystemPath(dir_bak) + el)
8336 """ Gestisce il nome del file OXT in leeno_version_code"""
8339 """ Class initialiser """
8345 code_file = uno.fileUrlToSystemPath(
LeenO_path() + os.altsep +
8346 'leeno_version_code')
8348 code_file = uno.fileUrlToSystemPath(
LeenO_path() + os.sep +
8349 'leeno_version_code')
8350 f = open(code_file,
'r')
8356 code_file = uno.fileUrlToSystemPath(
LeenO_path() + os.altsep +
8357 'leeno_version_code')
8359 code_file = uno.fileUrlToSystemPath(
LeenO_path() + os.sep +
8360 'leeno_version_code')
8361 f = open(code_file,
'r')
8362 Ldev = str (int(f.readline().split(
'LeenO-')[1].split(
'-')[0].split(
'.')[-1]) + 1)
8363 tempo =
''.join(
''.join(
''.join(str(datetime.now()).split(
'.')[0].split(
' ')).split(
'-')).split(
':'))
8364 of = open(code_file,
'w')
8371 Ldev +
'-TESTING-' +
8379 Aggiorna il valore di versione del file description.xml
8382 desc_file = uno.fileUrlToSystemPath(
LeenO_path() + os.altsep +
8385 desc_file = uno.fileUrlToSystemPath(
LeenO_path() + os.sep +
8387 f = open(desc_file,
'r')
8388 oxt_name = version_code.read()
8391 for el
in f.readlines():
8392 if '<version value=' in el:
8394 el = el.split(
'''"''')[0] +
'''"'''+ oxt_name[6:100] +
'''"'''+ el.split(
'''"''')[2]
8397 str_join =
''.join(new)
8399 of = open(desc_file,
'w')
8408 '''Mostra / nasconde griglia'''
8410 oDoc.CurrentController.ShowGrid =
not oDoc.CurrentController.ShowGrid
8415 Produce il pacchetto installabile
8422 bar { integer } : toolbar 0=spenta 1=accesa
8423 Pacchettizza l'estensione in duplice copia: LeenO.oxt e LeenO-x.xx.x.xxx-TESTING-yyyymmdd.oxt
8424 in una directory precisa (da parametrizzare...)
8429 if oDoc.getSheets().getByName(
'S1').getCellByPosition(
8430 7, 338).String ==
'':
8433 src_oxt = oDoc.getSheets().getByName(
'S1').getCellByPosition(
8437 oxt_name = version_code.write()
8442 oxt_path = uno.fileUrlToSystemPath(
LeenO_path())
8443 if sys.platform ==
'linux' or sys.platform ==
'darwin':
8444 dest =
'/media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt'
8445 if not os.path.exists(dest):
8448 "HOME") +
'/' + src_oxt +
'/leeno/src/Ultimus.oxt/'
8450 os.makedirs(os.getenv(
"HOME") +
'/' + src_oxt +
'/_SRC/OXT')
8451 except FileExistsError:
8453 nomeZip2 = os.getenv(
8454 "HOME") +
'/' + src_oxt +
'/_SRC/OXT/' + oxt_name +
'.oxt'
8455 subprocess.Popen(
'caja ' + os.getenv(
"HOME") +
'/' + src_oxt +
8458 stdout=subprocess.PIPE)
8461 nomeZip2 =
'/media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/OXT/' + oxt_name +
'.oxt'
8463 'caja /media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/OXT/',
8465 stdout=subprocess.PIPE)
8466 elif sys.platform ==
'win32':
8467 if not os.path.exists(
'w:/_dwg/ULTIMUSFREE/_SRC/OXT/'):
8469 os.makedirs(os.getenv(
"HOMEPATH") +
'/' + src_oxt +
'/')
8470 except FileExistsError:
8472 nomeZip2 = os.getenv(
8473 "HOMEPATH") +
'/' + src_oxt +
'/OXT/' + oxt_name +
'.oxt'
8474 subprocess.Popen(
'explorer.exe ' + os.getenv(
"HOMEPATH") +
'\\' +
8475 src_oxt +
'\\OXT\\',
8477 stdout=subprocess.PIPE)
8479 nomeZip2 =
'w:/_dwg/ULTIMUSFREE/_SRC/OXT/' + oxt_name +
'.oxt'
8480 subprocess.Popen(
'explorer.exe w:\\_dwg\\ULTIMUSFREE\\_SRC\\OXT\\',
8482 stdout=subprocess.PIPE)
8483 shutil.make_archive(nomeZip2,
'zip', oxt_path)
8484 shutil.move(nomeZip2 +
'.zip', nomeZip2)
8495 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
8496 oDialog1 = dp.createDialog(
8497 "vnd.sun.star.script:UltimusFree2.DlgDonazioni?language=Basic&location=application"
8501 oDialog1.getModel().ImageControl1.ImageURL = sUrl
8511 apri.execute(
"https://leeno.org/donazioni/",
"", 0)
8519 threading.Thread.__init__(self)
8538 threading.Thread.__init__(self)
8543 oSheet = oDoc.CurrentController.ActiveSheet
8546 progress =
Dialogs.Progress(Title=
'Esportazione di ' + oSheet.Name +
' in corso...', Text=
"Lettura dati")
8548 progress.setValue(0)
8550 if oSheet.Name
not in (
'COMPUTO',
'VARIANTE'):
8552 descrizione =
InputBox(t=
'inserisci una descrizione per la nuova riga')
8556 progress.setValue(i)
8557 if oSheet.getCellByPosition(2, i).CellStyle ==
'comp 1-a':
8559 qui = sStRange.RangeAddress.StartRow + 1
8561 i = sotto = sStRange.RangeAddress.EndRow + 3
8562 oDoc.CurrentController.select(oSheet.getCellByPosition(2, qui))
8564 oSheet.getCellByPosition(2, qui + 1).String = descrizione
8572 inserisce, all'inizio di ogni voce di computo o variante,
8573 una nuova riga con una descrizione a scelta
8581 Copia il valore della prima cella superiore utile.
8584 oCell = oDoc.CurrentSelection
8585 oSheet = oDoc.CurrentController.ActiveSheet
8590 while oSheet.getCellByPosition(x, y).Type.value ==
'EMPTY':
8594 oDoc.CurrentController.select(oSheet.getCellByPosition(x, y))
8596 oDoc.CurrentController.select(oCell)
8598 oDoc.CurrentController.select(
8599 oDoc.createInstance(
"com.sun.star.sheet.SheetCellRanges"))
8605 taglia il contenuto della selezione
8606 senza cancellare la formattazione delle celle
8609 oSheet = oDoc.CurrentController.ActiveSheet
8613 sRow = oDoc.getCurrentSelection().getRangeAddresses()[0].StartRow
8614 sCol = oDoc.getCurrentSelection().getRangeAddresses()[0].StartColumn
8615 eRow = oDoc.getCurrentSelection().getRangeAddresses()[0].EndRow
8616 eCol = oDoc.getCurrentSelection().getRangeAddresses()[0].EndColumn
8617 except AttributeError:
8618 sRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
8619 sCol = oDoc.getCurrentSelection().getRangeAddress().StartColumn
8620 eRow = oDoc.getCurrentSelection().getRangeAddress().EndRow
8621 eCol = oDoc.getCurrentSelection().getRangeAddress().EndColumn
8623 flags = VALUE + DATETIME + STRING + ANNOTATION + FORMULA + OBJECTS + EDITATTR
8624 oSheet.getCellRangeByPosition(sCol, sRow, eCol, eRow).clearContents(flags)
8630 Colora le colonne del sabato e della domenica, oltre le festività,
8631 nel file ../PRIVATO/LeenO/extra/calendario.ods che potrei implementare
8632 in LeenO per la gestione delle ore in economia o del diagramma di Gantt.
8635 oSheet = oDoc.getSheets().getByName(
'elenco festività')
8636 oRangeAddress = oDoc.NamedRanges.feste.ReferredCells.RangeAddress
8637 SR = oRangeAddress.StartRow
8638 ER = oRangeAddress.EndRow
8640 for x
in range(SR, ER):
8641 if oSheet.getCellByPosition(0, x).Value != 0:
8642 lFeste.append(oSheet.getCellByPosition(0, x).String)
8643 oSheet = oDoc.getSheets().getByName(
'CALENDARIO')
8646 for x
in range(0, test):
8647 if oSheet.getCellByPosition(
8648 x, 3).String ==
's' or oSheet.getCellByPosition(
8649 x, 3).String ==
'd':
8651 for x
in range(0, test):
8652 if oSheet.getCellByPosition(x, 1).String
in lFeste:
8658 oSheet.getCellByPosition(x, y).CellStyle =
'ok'
8660 oSheet.getCellByPosition(x, y).CellStyle =
'tabella'
8672 oSheet = oDoc.CurrentController.ActiveSheet
8675 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
8676 except AttributeError:
8677 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
8682 for el
in oRangeAddress:
8683 el_y.append((el.StartRow, el.EndRow))
8685 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
8687 for el
in reversed(range(y[0], y[1] + 1)):
8690 oDoc.CurrentController.select(oSheet.getCellByPosition(lcol, y))
8691 if oDoc.getCurrentSelection().Type.value ==
'TEXT':
8692 testo = oDoc.getCurrentSelection().String.replace(
8693 '\t',
' ').replace(
'è',
'è').replace(
8694 '°',
'°').replace(
'Ã',
'à').replace(
8697 testo = testo.replace(
' ',
' ')
8698 while '\n\n' in testo:
8699 testo = testo.replace(
'\n\n',
'\n')
8700 oDoc.getCurrentSelection().String = testo.strip().strip().strip()
8707 Consente di estendere su più colonne o ridurre ad una colonna lo spazio
8708 occupato dalla descrizione di voce in COMPUTO, VARIANTE e CONTABILITA.
8711 oSheet = oDoc.CurrentController.ActiveSheet
8712 oSheet = oDoc.getSheets().getByName(
'S5')
8713 oSheet.getCellRangeByName(
'C9:I9').merge(flag)
8714 oSheet.getCellRangeByName(
'C10:I10').merge(flag)
8715 oSheet = oDoc.getSheets().getByName(
'COMPUTO')
8717 if oSheet.getCellByPosition(
8718 2, y).CellStyle
in (
'Comp-Bianche sopraS',
8719 'Comp-Bianche in mezzo Descr'):
8720 oSheet.getCellRangeByPosition(2, y, 8, y).merge(flag)
8721 if oDoc.getSheets().hasByName(
'VARIANTE'):
8722 oSheet = oDoc.getSheets().getByName(
'VARIANTE')
8724 if oSheet.getCellByPosition(
8725 2, y).CellStyle
in (
'Comp-Bianche sopraS',
8726 'Comp-Bianche in mezzo Descr'):
8727 oSheet.getCellRangeByPosition(2, y, 8, y).merge(flag)
8728 if oDoc.getSheets().hasByName(
'CONTABILITA'):
8729 if oDoc.NamedRanges.hasByName(
"_Lib_1"):
8731 Text=
"Risulta già registrato un SAL. NON E' POSSIBILE PROCEDERE.")
8736 oSheet = oDoc.getSheets().getByName(
'S5')
8737 oSheet.getCellRangeByName(
'C23').merge(flag)
8738 oSheet.getCellRangeByName(
'C24').merge(flag)
8739 oSheet = oDoc.getSheets().getByName(
'CONTABILITA')
8741 if oSheet.getCellByPosition(
8742 2, y).CellStyle
in (
'Comp-Bianche sopra_R',
8743 'Comp-Bianche in mezzo Descr_R'):
8744 oSheet.getCellRangeByPosition(2, y, 8, y).merge(flag)
8746 oSheet = oDoc.getSheets().getByName(
'S5')
8747 oSheet.getCellRangeByName(
'C23:I23').merge(flag)
8748 oSheet.getCellRangeByName(
'C24:I24').merge(flag)
8755 Comando di menu per numera_colonna()
8760 '''Inserisce l'indice di colonna nelle prime 100 colonne del rigo selezionato
8761 Associato a Ctrl+Shift+C'''
8763 oSheet = oDoc.CurrentController.ActiveSheet
8765 for x
in range(0, 50):
8766 if oSheet.getCellByPosition(x, lrow).Type.value ==
'EMPTY':
8767 larg = oSheet.getCellByPosition(x, lrow).Columns.Width
8769 oSheet.getCellByPosition(x, lrow).Formula =
'=CELL("col")-1'
8770 oSheet.getCellByPosition(x, lrow).HoriJustify =
'CENTER'
8771 elif oSheet.getCellByPosition(x, lrow).Formula ==
'=CELL("col")-1':
8772 oSheet.getCellByPosition(x, lrow).String =
''
8773 oSheet.getCellByPosition(x, lrow).HoriJustify =
'STANDARD'
8779 Sostituisce stringhe di testi nel foglio corrente
8782 oSheet = oDoc.CurrentController.ActiveSheet
8783 ReplaceDescriptor = oSheet.createReplaceDescriptor()
8784 ReplaceDescriptor.SearchString = cerca
8785 ReplaceDescriptor.ReplaceString = sostituisce
8786 oSheet.replaceAll(ReplaceDescriptor)
8791 '''Verifica l'esistenza di un processo di sistema'''
8792 ps = subprocess.Popen(
"ps -A", shell=
True, stdout=subprocess.PIPE)
8794 if arg
in (str(ps.stdout.read())):
8801 '''Dà accesso alla configurazione utente di LibreOffice'''
8803 "com.sun.star.configuration.ConfigurationProvider")
8804 arg = uno.createUnoStruct(
'com.sun.star.beans.PropertyValue')
8805 arg.Name =
"nodepath"
8806 arg.Value = sKeyName
8808 GetRegistryKeyContent = oConfigProvider.createInstanceWithArguments(
8809 "com.sun.star.configuration.ConfigurationUpdateAccess", (arg, ))
8811 GetRegistryKeyContent = oConfigProvider.createInstanceWithArguments(
8812 "com.sun.star.configuration.ConfigurationAccess", (arg, ))
8813 return GetRegistryKeyContent
8821 Cancella area di stampa di tutti i fogli ad esclusione di quello
8822 corrente del foglio cP_Cop
8826 nome = oDoc.CurrentController.ActiveSheet.Name
8827 lista_fogli = oDoc.Sheets.ElementNames
8828 for el
in lista_fogli:
8829 if el
not in (nome,
'cP_Cop'):
8830 oSheet = oDoc.getSheets().getByName(el)
8831 oSheet.setPrintAreas(())
8839 ''' Imposta area di stampa il relazione all'elaborato da produrre'''
8841 oSheet = oDoc.CurrentController.ActiveSheet
8842 oSheet.removeAllManualPageBreaks()
8845 iSheet = oSheet.RangeAddress.Sheet
8846 oTitles = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
8847 oTitles.Sheet = iSheet
8849 if oSheet.Name
in (
"VARIANTE",
"COMPUTO",
"COMPUTO_print",
'Elenco Prezzi',
'CONTABILITA',
'Registro',
'SAL'):
8851 oSheet.getCellByPosition(0, 2).Rows.Height = 800
8855 oTitles.StartRow = 2
8857 oSheet.setTitleRows(oTitles)
8858 oSheet.setPrintTitleRows(
True)
8859 if oSheet.Name ==
'Elenco Prezzi':
8862 if oSheet.Name ==
'CONTABILITA':
8864 if oDoc.NamedRanges.hasByName(
'_Lib_1'):
8866 if oSheet.Name
in (
'Analisi di Prezzo'):
8870 oSheet.setPrintTitleRows(
False)
8872 oStampa = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
8873 oStampa.Sheet = iSheet
8874 oStampa.StartColumn = 0
8875 oStampa.StartRow = SR
8876 oStampa.EndColumn = EC
8878 oSheet.setPrintAreas((oStampa,))
8887 Configura intestazioni e pie' di pagina degli stili di stampa
8888 e propone un'anteprima di stampa
8891 if not oDoc.getSheets().hasByName(
'M1'):
8897 Text=
'''Vuoi attribuire il colore bianco allo sfondo delle celle?
8898 Le formattazioni dirette impostate durante il lavoro andranno perse.
8900 Per ripristinare i colori, tipici dei fogli di LeenO, basterà selezionare
8901 le celle ed usare "CTRL+M".
8903 Procedo cambiando i colori?''') == 1:
8906 oSheet = oDoc.CurrentController.ActiveSheet
8907 oSheet.removeAllManualPageBreaks()
8911 oggetto = oDoc.getSheets().getByName(
'S2').getCellRangeByName(
"C3").String +
'\n\n'
8912 committente =
"\nCommittente: " + oDoc.getSheets().getByName(
'S2').getCellRangeByName(
"C6").String
8913 luogo =
'\n' + oSheet.Name
8914 if oSheet.Name ==
'COMPUTO' and oSheet.getColumns().getByName(
"AD").Columns.Width > 10:
8915 luogo = luogo +
' - Incidenza MdO'
8962 'cP_Cop':
'Page_Style_COPERTINE',
8963 'COMPUTO':
'PageStyle_COMPUTO_A4',
8964 'VARIANTE':
'PageStyle_COMPUTO_A4',
8965 'Elenco Prezzi':
'PageStyle_Elenco Prezzi',
8967 'Analisi di Prezzo':
'PageStyle_COMPUTO_A4',
8968 'CONTABILITA':
'Page_Style_Libretto_Misure2',
8969 'Registro':
'PageStyle_REGISTRO_A4',
8970 'SAL':
'PageStyle_REGISTRO_A4',
8974 oStyleFam = oDoc.StyleFamilies
8975 oTablePageStyles = oStyleFam.getByName(
"PageStyles")
8976 oPgStyle = oDoc.createInstance(
"com.sun.star.style.PageStyle")
8977 for el
in stili.keys():
8979 oDoc.getSheets().getByName(el).PageStyle = stili[el]
8987 if cfg.read(
'Generale',
'dettaglio') ==
'1':
8992 for n
in range(0, oDoc.StyleFamilies.getByName(
'PageStyles').Count):
8993 oAktPage = oDoc.StyleFamilies.getByName(
'PageStyles').getByIndex(n)
8995 oAktPage.HeaderIsOn =
True
8996 oAktPage.FooterIsOn =
True
8998 oAktPage.TopMargin = 1500
8999 oAktPage.BottomMargin = 800
9000 oAktPage.LeftMargin = 1500
9001 oAktPage.RightMargin = 1000
9003 oAktPage.FooterLeftMargin = 0
9004 oAktPage.FooterRightMargin = 0
9005 oAktPage.HeaderLeftMargin = 0
9006 oAktPage.HeaderRightMargin = 0
9008 oAktPage.HeaderBodyDistance = 0
9009 oAktPage.FooterBodyDistance = 0
9011 if oAktPage.DisplayName ==
'Page_Style_COPERTINE':
9012 oAktPage.HeaderIsOn =
False
9013 oAktPage.FooterIsOn =
False
9015 oAktPage.PageScale = 0
9016 oAktPage.CenterHorizontally =
True
9017 oAktPage.ScaleToPagesX = 1
9018 oAktPage.ScaleToPagesY = 0
9019 if oAktPage.DisplayName
in (
'PageStyle_Analisi di Prezzo',
9020 'PageStyle_COMPUTO_A4',
9021 'PageStyle_Elenco Prezzi'):
9022 htxt = 8.0 / 100 * oAktPage.PageScale
9023 if oSheet.Name ==
'Analisi di Prezzo':
9024 htxt = 9.0 / 100 * oAktPage.PageScale
9027 bordo = oAktPage.TopBorder
9029 bordo.OuterLineWidth = 0
9030 oAktPage.TopBorder = bordo
9032 bordo = oAktPage.BottomBorder
9034 bordo.OuterLineWidth = 0
9035 oAktPage.BottomBorder = bordo
9037 bordo = oAktPage.RightBorder
9039 bordo.OuterLineWidth = 0
9040 oAktPage.RightBorder = bordo
9042 bordo = oAktPage.LeftBorder
9044 bordo.OuterLineWidth = 0
9045 oAktPage.LeftBorder = bordo
9047 oAktPage.PageScale = 0
9048 oAktPage.ScaleToPagesX = 1
9049 oAktPage.ScaleToPagesY = 0
9052 oHeader = oAktPage.RightPageHeaderContent
9054 oHLText = oHeader.LeftText.Text.String = committente
9055 oHRText = oHeader.LeftText.Text.Text.CharFontName =
'Liberation Sans Narrow'
9056 oHRText = oHeader.LeftText.Text.Text.CharHeight = htxt
9058 oHLText = oHeader.CenterText.Text.String = oggetto
9059 oHRText = oHeader.CenterText.Text.Text.CharFontName =
'Liberation Sans Narrow'
9060 oHRText = oHeader.CenterText.Text.Text.CharHeight = htxt
9062 oHRText = oHeader.RightText.Text.String = luogo
9063 oHRText = oHeader.RightText.Text.Text.CharFontName =
'Liberation Sans Narrow'
9064 oHRText = oHeader.RightText.Text.Text.CharHeight = htxt
9066 oAktPage.RightPageHeaderContent = oHeader
9068 oFooter = oAktPage.RightPageFooterContent
9069 oHLText = oFooter.CenterText.Text.String =
''
9070 nomefile = oDoc.getURL().replace(
'%20',
' ')
9071 oHLText = oFooter.LeftText.Text.String =
"\nrealizzato con LeenO\n" + os.path.basename(nomefile)
9072 oHLText = oFooter.LeftText.Text.Text.CharFontName =
'Liberation Sans Narrow'
9073 oHLText = oFooter.LeftText.Text.Text.CharHeight = htxt * 0.70
9074 oHLText = oFooter.RightText.Text.Text.CharFontName =
'Liberation Sans Narrow'
9075 oHLText = oFooter.RightText.Text.Text.CharHeight = htxt
9077 oAktPage.RightPageFooterContent = oFooter
9079 if oAktPage.DisplayName ==
'Page_Style_Libretto_Misure2':
9081 oHeader = oAktPage.RightPageHeaderContent
9084 oAktPage.RightPageHeaderContent = oHeader
9086 oFooter = oAktPage.RightPageFooterContent
9090 oAktPage.RightPageFooterContent = oFooter
9092 if oAktPage.DisplayName ==
'PageStyle_REGISTRO_A4':
9094 oHeader = oAktPage.RightPageHeaderContent
9097 oAktPage.RightPageHeaderContent = oHeader
9099 oFooter = oAktPage.RightPageFooterContent
9103 oAktPage.RightPageFooterContent = oFooter
9105 if oDoc.CurrentController.ActiveSheet.Name
in (
'COMPUTO',
'VARIANTE',
9109 if oDoc.CurrentController.ActiveSheet.Name
in (
'Analisi di Prezzo'):
9131 oSheet = oDoc.CurrentController.ActiveSheet
9139 oDoc.CurrentController.freezeAtPosition(0, 3)
9140 elif oSheet.Name
in (
'CONTABILITA'):
9141 oDoc.CurrentController.freezeAtPosition(0, 3)
9142 elif oSheet.Name
in (
'Analisi di Prezzo'):
9143 oDoc.CurrentController.freezeAtPosition(0, 2)
9144 elif oSheet.Name
in (
'Registro',
'SAL'):
9145 oDoc.CurrentController.freezeAtPosition(0, 1)
9154 Consente la visualizzazione selettiva delle voci di COMPUTO che fanno
9155 capo alla stessa voce di Elenco Prezzi.
9160 '''Trova i codici di prezzo ricorrenti nel COMPUTO'''
9162 oSheet = oDoc.CurrentController.ActiveSheet
9166 for n
in range(3, last):
9167 if oSheet.getCellByPosition(1, n).CellStyle ==
'comp Art-EP_R':
9168 lista.append(oSheet.getCellByPosition(1, n).String)
9169 unici = (set(lista))
9172 iSheet = oSheet.RangeAddress.Sheet
9173 oCellRangeAddr = uno.createUnoStruct(
9174 'com.sun.star.table.CellRangeAddress')
9175 oCellRangeAddr.Sheet = iSheet
9177 for n
in range(0, last):
9178 if oSheet.getCellByPosition(1, n).CellStyle ==
'comp Art-EP_R':
9179 if oSheet.getCellByPosition(1, n).String
not in lista:
9181 oCellRangeAddr.StartRow = oRange.StartRow
9182 oCellRangeAddr.EndRow = oRange.EndRow
9183 oSheet.group(oCellRangeAddr, 1)
9184 lista = list(set(lista))
9191 lista_ricorrenze = ricorrenze()
9193 if len(lista_ricorrenze) == 0:
9196 Text=
"Non ci sono voci di prezzo ricorrenti.")
9199 dp = psm.createInstance(
"com.sun.star.awt.DialogProvider")
9200 oDlg = dp.createDialog(
9201 "vnd.sun.star.script:UltimusFree2.DlgLista?language=Basic&location=application"
9205 oDlg.Title =
'Seleziona il codice e dai OK...'
9206 oDlg.getControl(
'ListBox1').addItems(lista_ricorrenze, 0)
9207 if oDlg.execute() == 0:
9220 Raggruppa le righe in modo da rendere evidenti i nuovi prezzi
9224 oSheet = oDoc.CurrentController.ActiveSheet
9225 oDoc.enableAutomaticCalculation(
False)
9228 oCellRangeAddr = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
9230 if oSheet.getCellByPosition(
9232 el).Value == 0
and oSheet.getCellByPosition(20, el).Value > 0:
9235 oCellRangeAddr.StartRow = el
9236 oCellRangeAddr.EndRow = el
9237 oSheet.group(oCellRangeAddr, 1)
9238 oSheet.getCellRangeByPosition(0, el, 1, el).Rows.IsVisible =
False
9240 oDoc.enableAutomaticCalculation(
True)
9250 oSheet = oDoc.getSheets().getByName(
'Elenco Prezzi')
9255 progress =
Dialogs.Progress(Title=
'Ricerca delle voci da eliminare in corso...', Text=
"Lettura dati")
9256 progress.setLimits(0, fine)
9257 progress.setValue(0)
9260 oSheet.getCellByPosition(30, 3).Formula =
'=IF(A4=A3;1;0)'
9261 oDoc.CurrentController.select(oSheet.getCellByPosition(30, 3))
9263 oDoc.CurrentController.select(
9264 oSheet.getCellRangeByPosition(30, 3, 30, fine))
9267 for i
in reversed(range(0, fine)):
9268 progress.setValue(i)
9269 if oSheet.getCellByPosition(30, i).Value == 1:
9271 oSheet.getRows().removeByIndex(i, 1)
9272 oSheet.getCellRangeByPosition(30, 3, 30, fine).clearContents(FORMULA)
9280 Sostituisce hiperlink alla stringa nella colonna B, se questa è un
9281 indirizzo di file o cartella
9284 oSheet = oDoc.CurrentController.ActiveSheet
9287 if oSheet.getCellByPosition(1, el).String[1] ==
':':
9288 stringa =
'=HYPERLINK("' + oSheet.getCellByPosition(
9289 1, el).String +
'";">>>")'
9290 oSheet.getCellByPosition(1, el).Formula = stringa
9298 Raggruppa e nasconde tutte le voci di misura in cui non compare
9303 oSheet = oDoc.CurrentController.ActiveSheet
9305 iSheet = oSheet.RangeAddress.Sheet
9306 oCellRangeAddr = uno.createUnoStruct(
'com.sun.star.table.CellRangeAddress')
9307 oCellRangeAddr.Sheet = iSheet
9310 if 'comp 1-a' in oDoc.getCurrentSelection().CellStyle
or \
9311 'Descr' in oDoc.getCurrentSelection().CellStyle:
9312 testo = oDoc.getCurrentSelection().String
9316 testo, t=
'Inserisci la descrizione da cercare o OK per conferma.')
9317 if descrizione
in (
None,
'',
' '):
9319 oSheet.getCellRangeByPosition(2, 0, 2, 1048575).clearContents(HARDATTR)
9323 oSheet.getCellRangeByPosition(2, 0, 2, 1048575).clearContents(HARDATTR)
9326 progress =
Dialogs.Progress(Title=
'Applicazione filtro in corso...', Text=
"Lettura dati")
9327 progress.setLimits(0, fine)
9328 progress.setValue(0)
9334 Dialogs.Exclamation (Title =
'ATTENZIONE!',
9335 Text=
"Testo non trovato.")
9340 progress.setValue(y)
9341 oSheet.getCellByPosition(2, y).CellBackColor = 15757935
9347 progress.setValue(y)
9351 if oSheet.Name ==
'CONTABILITA':
9352 lista_y.append(fine - 2)
9354 lista_y.append(fine - 3)
9356 while len(lista_y[i:]) > 1:
9357 SR = lista_y[i:][0] + 1
9360 oCellRangeAddr.StartRow = SR
9361 oCellRangeAddr.EndRow = ER - 1
9362 oSheet.group(oCellRangeAddr, 1)
9363 oSheet.getCellRangeByPosition(0, SR, 0,
9364 ER - 1).Rows.IsVisible =
False
9366 _gotoCella(2, lRow[0])
9388 DLG.MsgBox(traceback.format_exc())
9393 Mostra la somme dei valori di una selezione su singola colonna. Utile quando la
9394 finestra di Calc non mostra la statusbar.
9397 oSheet = oDoc.CurrentController.ActiveSheet
9400 oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
9401 except AttributeError:
9402 oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
9407 for el
in oRangeAddress:
9408 el_y.append((el.StartRow, el.EndRow))
9410 el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
9412 for el
in range(y[0], y[1] + 1):
9416 somma.append(oSheet.getCellByPosition(lcol, y).Value)
9425 oSheet = oDoc.CurrentController.ActiveSheet
9429 lst = str(testo).split(
'-')
9431 testo = lst[2] +
'/' + lst[1] +
'/' + lst[0]
9432 oSheet.getCellByPosition(x, y).String = testo
9447 oSheet = oDoc.CurrentController.ActiveSheet
9448 oSheets = list(oDoc.getSheets().getElementNames())
9451 return Dialogs.Dialog(Title=
'Esportazione PDFPDFPDFPDFPDF', Horz=
False, CanClose=
True, Items=[
9473 Dialogs.ListBox(List=oSheets, FixedHeight=hItems * 1, FixedWidth=nWidth * 6),
9493 Dialogs.Button(Label=
'Ok', MinWidth=Dialogs.MINBTNWIDTH, Icon=
'Icons-24x24/ok.png', RetVal=1),
9495 Dialogs.Button(Label=
'Annulla', MinWidth=Dialogs.MINBTNWIDTH, Icon=
'Icons-24x24/cancel.png', RetVal=-1),
9505 tempo =
''.join(
''.join(
''.join(
9506 str(datetime.now()).split(
'.')[0].split(
' ')).split(
'-')).split(
9509 orig = oDoc.getURL()
9510 dest = orig.split(
'.')[0] +
'-' + tempo +
'.pdf'