LeenO computo metrico con LibreOffice  3.22.0
Il software libero per la gestione di computi metrici e contabilità lavori.
pyleeno.py
Vai alla documentazione di questo file.
1 #!/usr/bin/env python3
2 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3 
13 
14 # MsgBox('''Per segnalare questo problema,
15 # contatta il canale Telegram
16 # https://t.me/leeno_computometrico''', 'ERRORE!')
17 
18 # documentazione ufficiale: https://api.libreoffice.org/
19 # import pydevd
20 
21  # funzioni per misurare la velocità delle macro
22  # ~datarif = datetime.now()
23  # ~DLG.chi('eseguita in ' + str((datetime.now() - datarif).total_seconds()) + ' secondi!')
24 
25 
26 from datetime import datetime, date
27 from xml.etree.ElementTree import Element, SubElement, tostring
28 
29 # import distutils.dir_util
30 
31 import codecs
32 import subprocess
33 # import psutil
34 import re
35 import traceback
36 import threading
37 import time
38 
39 import os
40 import shutil
41 import sys
42 import uno
43 
44 import SheetUtils
45 import LeenoUtils
46 import LeenoSheetUtils
47 import LeenoToolbars as Toolbars
48 import LeenoFormat
49 import LeenoComputo
50 import LeenoContab
51 import LeenoAnalysis
52 import LeenoDialogs as DLG
53 import PersistUtils as PU
54 import LeenoEvents
55 import LeenoBasicBridge
56 
57 import LeenoConfig
59 
60 import Dialogs
61 
62 # cos'e' il namespace:
63 # http://www.html.it/articoli/il-misterioso-mondo-dei-namespaces-1/
64 
65 # from com.sun.star.lang import Locale
66 from com.sun.star.beans import PropertyValue
67 # from com.sun.star.table.CellContentType import TEXT, EMPTY, VALUE, FORMULA
68 from com.sun.star.sheet.CellFlags import \
69  VALUE, DATETIME, STRING, ANNOTATION, FORMULA, HARDATTR, OBJECTS, EDITATTR, FORMATTED
70 
71 from com.sun.star.beans.PropertyAttribute import \
72  MAYBEVOID, REMOVEABLE, MAYBEDEFAULT
73 
74 
76 
77 
80 
81 def basic_LeenO(funcname, *args):
82  '''Richiama funzioni definite in Basic'''
83 
84  xCompCont = LeenoUtils.getComponentContext()
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." +
90  funcname +
91  "?language=Basic&location=application")
92  Result = Xscript.invoke(args, None, None)
93  return Result[0]
94 
95 
96 # leeno.conf
98  '''
99  Visualizza il menù di configurazione
100  '''
101  oDoc = LeenoUtils.getDocument()
102  if not oDoc.getSheets().hasByName('S1'):
103  Toolbars.AllOff()
104  return
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"
109  )
110  # oDialog1Model = oDlg_config.Model
111 
112  oSheets = list(oDoc.getSheets().getElementNames())
113  # ~for nome in ('M1', 'S1', 'S2', 'S4', 'S5', 'Elenco Prezzi', 'COMPUTO'):
114  for nome in ('M1', 'S1', 'S2', 'S5', 'Elenco Prezzi', 'COMPUTO'):
115  oSheets.remove(nome)
116  for nome in oSheets:
117  oSheet = oDoc.getSheets().getByName(nome)
118  if not oSheet.IsVisible:
119  oDlg_config.getControl('CheckBox2').State = 0
120  test = 0
121  break
122  oDlg_config.getControl('CheckBox2').State = 1
123  test = 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 # pesca codice automatico
128  if cfg.read('Generale', 'toolbar_contestuali') == '1':
129  oDlg_config.getControl('CheckBox6').State = 1
130 
131  oSheet = oDoc.getSheets().getByName('S5')
132  # descrizione_in_una_colonna
133  if not oSheet.getCellRangeByName('C9').IsMerged:
134  oDlg_config.getControl('CheckBox5').State = 1
135  else:
136  oDlg_config.getControl('CheckBox5').State = 0
137 
138  # if conf.read(path_conf, 'Generale', 'descrizione_in_una_colonna') == '1': oDlg_config.getControl('CheckBox5').State = 1
139 
140  sString = oDlg_config.getControl('TextField1')
141  sString.Text = cfg.read('Generale', 'altezza_celle')
142 
143  # sString = oDlg_config.getControl("ComboBox1")
144  # sString.Text = conf.read(path_conf, 'Generale', 'visualizza') #visualizza all'avvio
145 
146  sString = oDlg_config.getControl("ComboBox2") # spostamento ad INVIO
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')
152 
153  # fullscreen
154  oLayout = oDoc.CurrentController.getFrame().LayoutManager
155  if not oLayout.isElementVisible('private:resource/toolbar/standardbar'):
156  oDlg_config.getControl('CheckBox3').State = 1
157 
158  sString = oDlg_config.getControl('TextField14')
159  sString.Text = oSheet.getCellRangeByName(
160  'S1.H334').String # vedi_voce_breve
161  sString = oDlg_config.getControl('TextField4')
162  sString.Text = oSheet.getCellRangeByName(
163  'S1.H335').String # cont_inizio_voci_abbreviate
164  if oDoc.NamedRanges.hasByName("_Lib_1"):
165  sString.setEnable(False)
166  sString = oDlg_config.getControl('TextField12')
167  sString.Text = oSheet.getCellRangeByName(
168  'S1.H336').String # cont_fine_voci_abbreviate
169  if oDoc.NamedRanges.hasByName("_Lib_1"):
170  sString.setEnable(False)
171 
172  if cfg.read('Generale', 'torna_a_ep') == '1':
173  oDlg_config.getControl('CheckBox8').State = 1
174 
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')
180  # ~else:
181  # ~oDlg_config.getControl('ComboBox5').setEnable(False)
182  # ~oDlg_config.execute()
183  # ~DLG.chi(oDlg_config.getControl('ComboBox5'))
184 
185 
186  # MOSTRA IL DIALOGO
187  oDlg_config.execute()
188 
189  if oDlg_config.getControl('CheckBox2').State != test:
190  if oDlg_config.getControl('CheckBox2').State == 1:
191  show_sheets(True)
192  else:
193  show_sheets(False)
194 
195  if oDlg_config.getControl('CheckBox3').State == 1:
196  Toolbars.Switch(False)
197  else:
198  Toolbars.Switch(True)
199 
200  # conf.write(path_conf, 'Generale', 'visualizza', oDlg_config.getControl('ComboBox1').getText())
201 
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
207  else:
208  cfg.write('Generale', 'movedirection', '1')
209  oGSheetSettings.MoveDirection = 1
210  cfg.write('Generale', 'altezza_celle', oDlg_config.getControl('TextField1').getText())
211 
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))
215  Toolbars.Vedi()
216  if oDlg_config.getControl('CheckBox5').State == 1:
218  else:
220  # torna su prezzario
221  cfg.write('Generale', 'torna_a_ep', str(oDlg_config.getControl('CheckBox8').State))
222 
223  # il salvataggio anche su leeno.conf serve alla funzione voce_breve()
224 
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())
228 
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())
232 
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())
237 
238  cfg.write('Generale', 'copie_backup', oDlg_config.getControl('ComboBox4').getText())
239  cfg.write('Generale', 'pausa_backup', oDlg_config.getControl('ComboBox5').getText())
240  autorun()
241 
242 
243 
244 
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')
251  return expath
252 
253 
254 
255 
256 def creaComputo(arg=1):
257  '''arg { integer } : 1 mostra il dialogo di salvataggio file'''
258  desktop = LeenoUtils.getDesktop()
259  opz = PropertyValue()
260  opz.Name = 'AsTemplate'
261  opz.Value = True
262  document = desktop.loadComponentFromURL(
263  LeenO_path() + '/template/leeno/Computo_LeenO.ots', "_blank", 0,
264  (opz, ))
265  autoexec()
266  if arg == 1:
267  Dialogs.Exclamation(Title = 'ATTENZIONE!',
268  Text='''
269 Prima di procedere è meglio dare un nome al file.
270 Lavorando su un file senza nome potresti avere dei malfunzionamenti.
271 ''')
272  # ~DLG.MsgBox(
273  # ~"Prima di procedere è consigliabile salvare il lavoro.\n"
274  # ~"Provvedi subito a dare un nome al file di computo...",
275  # ~"Dai un nome al file...")
276  salva_come()
277  DlgMain()
278  return document
279 
280 
282  desktop = LeenoUtils.getDesktop()
283  opz = PropertyValue()
284  opz.Name = 'AsTemplate'
285  opz.Value = True
286  document = desktop.loadComponentFromURL(
287  LeenO_path() + '/template/offmisc/UsoBollo.ott', "_blank", 0,
288  (opz, ))
289  return document
290 
291 
292 
293 
294 
296  '''Crea un nuovo computo vuoto.'''
297  creaComputo()
298 
299 
300 
301 
302 
304  '''Crea un nuovo documento in formato uso bollo.'''
305  creaUsobollo()
306 
307 
308 
309 
311  '''
312  Invia le voci di Elenco Prezzi verso uno degli altri elaborati.
313  Richiede comunque la scelta del DP
314  '''
316  oDoc = LeenoUtils.getDocument()
317  oSheet = oDoc.CurrentController.ActiveSheet
318 
319  elenco = seleziona()
320  codici = []
321  for el in elenco:
322  cod = oSheet.getCellByPosition(0, el).String
323  codici.append(cod)
324  dest = oSheet.getCellRangeByName('C2').String
325 
326  if dest == 'VARIANTE':
328  elif dest == 'CONTABILITA':
330  # ~ins_voce_contab()
331  elif dest == 'COMPUTO':
332  GotoSheet(dest)
333  else:
334  Dialogs.Exclamation(Title='AVVISO!',
335  Text='''Per procedere devi prima scegliere,
336 dalla cella "C2", l'elaborato a cui
337 inviare le voci di prezzo selezionate.
338 
339 Se l'elaborato è già esistente,
340 assicurati di aver scelto anche
341 la posizione di destinazione.''')
342  _gotoCella(2, 1)
343  return
344  oSheet = oDoc.getSheets().getByName(dest)
345  for el in codici:
346  if oSheet.Name == 'CONTABILITA':
347  GotoSheet(dest)
348  ins_voce_contab(cod=el)
349  else:
351  lrow = SheetUtils.getLastUsedRow(oSheet)
353  return
354 
356  '''
357  Invia le voci di computo, elenco prezzi e analisi, con costi elementari,
358  dal documento corrente al Documento Principale.
359  '''
360  oDoc = LeenoUtils.getDocument()
361  oSheet = oDoc.CurrentController.ActiveSheet
362  stili_computo = LeenoUtils.getGlobalVar('stili_computo')
363  stili_cat = LeenoUtils.getGlobalVar('stili_cat')
364 
365  nSheet = oSheet.Name
366  fpartenza = uno.fileUrlToSystemPath(oDoc.getURL())
367  if fpartenza == LeenoUtils.getGlobalVar('sUltimus'):
368  if nSheet == 'Elenco Prezzi':
370  return
371  else:
372  Dialogs.Exclamation(Title='ATTENZIONE!',
373  Text="Questo file coincide con il Documento Principale (DP).")
374  return
375  elif LeenoUtils.getGlobalVar('sUltimus') == '':
376  Dialogs.Exclamation(Title='ATTENZIONE!',
377  Text="E' necessario impostare il Documento Principale (DP).")
378  return
379  nSheetDCC = getDCCSheet()
380  lrow = LeggiPosizioneCorrente()[1]
381 
382  def getAnalisi(oSheet):
383  try:
384  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
385  except AttributeError:
386  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
387  el_y = list()
388  try:
389  len(oRangeAddress)
390  for el in oRangeAddress:
391  el_y.append((el.StartRow, el.EndRow))
392  except TypeError:
393  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
394  lista = list()
395  for y in el_y:
396  for el in range(y[0], y[1] + 1):
397  lista.append(el)
398  analisi = list()
399  for y in lista:
400  if oSheet.getCellByPosition(1, y).Type.value == 'FORMULA':
401  analisi.append(oSheet.getCellByPosition(0, y).String)
402  return (analisi, lista)
403 
404  def Circoscrive_Analisi(lrow):
405  # oDoc = LeenoUtils.getDocument()
406  # oSheet = oDoc.CurrentController.ActiveSheet
407  stili_analisi = LeenoUtils.getGlobalVar('stili_analisi')
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':
412  SR = el
413  break
414  for el in range(lrow, SheetUtils.getUsedArea(oSheet).EndRow):
415  if oSheet.getCellByPosition(
416  0, el).CellStyle == 'An-sfondo-basso Att End':
417  ER = el
418  break
419  celle = oSheet.getCellRangeByPosition(0, SR, 250, ER)
420  return celle
421 
422  # partenza
423  if oSheet.Name == 'Elenco Prezzi':
424  if oSheet.getCellByPosition(
425  0,
426  LeggiPosizioneCorrente()[1]).CellStyle not in ('EP-Cs', 'EP-aS'):
427  Dialogs.Exclamation(Title = 'ATTENZIONE!',
428  Text='La posizione di PARTENZA non è corretta.')
429  # ~DLG.MsgBox('La posizione di PARTENZA non è corretta.', 'ATTENZIONE!')
430  return
431  analisi = getAnalisi(oSheet)[0]
432  lrow = getAnalisi(oSheet)[1][0]
433  LeenoUtils.setGlobalVar('cod', oSheet.getCellByPosition(0, lrow).String)
434  lista = getAnalisi(oSheet)[1]
435 
436  selezione = list()
437  voci = oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")
438  for y in lista:
439  rangen = oSheet.getCellRangeByPosition(0, y, 100, y).RangeAddress
440  selezione.append(rangen)
441  voci.addRangeAddresses(selezione, True)
442 
443  coppia = list()
444 
445  if analisi:
446  GotoSheet('Analisi di Prezzo')
447  oSheet = oDoc.getSheets().getByName('Analisi di Prezzo')
448 
449  ranges = oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")
450  selezione_analisi = list()
451  for el in analisi:
452  y = SheetUtils.uFindStringCol(el, 0, oSheet)
453  sStRange = Circoscrive_Analisi(y)
454  SR = sStRange.RangeAddress.StartRow
455  ER = sStRange.RangeAddress.EndRow
456  coppia.append((SR, ER))
457  selezione_analisi.append(sStRange.RangeAddress)
458  costi = list()
459  for el in coppia:
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)
464  if len(costi) > 0:
465  GotoSheet('Elenco Prezzi')
466  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
467  el_y = list()
468  for el in costi:
469  el_y.append(SheetUtils.uFindStringCol(el, 0, oSheet))
470  for y in el_y:
471  rangen = oSheet.getCellRangeByPosition(0, y, 100,
472  y).RangeAddress
473  selezione.append(rangen)
474  voci.addRangeAddresses(selezione, True)
475  oDoc.CurrentController.select(voci)
476  comando('Copy')
477  oDoc.CurrentController.select(
478  oDoc.createInstance(
479  "com.sun.star.sheet.SheetCellRanges")) # unselect
480  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
481  ddcDoc = LeenoUtils.getDocument()
482  dccSheet = ddcDoc.CurrentController.ActiveSheet
483  nome = dccSheet.Name
484 
485  if nome in ('Elenco Prezzi'):
486  ddcDoc.CurrentController.setActiveSheet(dccSheet)
487  _gotoCella(0, 3)
488  paste_clip(insCells=1)
489  # EliminaVociDoppieElencoPrezzi()
490  if nome in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
491  dccSheet = ddcDoc.getSheets().getByName('Elenco Prezzi')
492  dccSheet.IsVisible = True
493  ddcDoc.CurrentController.setActiveSheet(dccSheet)
494  _gotoCella(0, 3)
495  paste_clip(insCells=1)
496  # EliminaVociDoppieElencoPrezzi()
497  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
498  ddcDoc = LeenoUtils.getDocument()
499  GotoSheet(nome)
500  dccSheet = ddcDoc.getSheets().getByName(nome)
501  lrow = LeggiPosizioneCorrente()[1]
502 
503  # ~if dccSheet.getCellByPosition(0, lrow).CellStyle in stili_cat:
504  # ~DLG.chi(dccSheet.getCellByPosition(0, lrow).CellStyle)
505  # ~lrow += 1
506 
507  if dccSheet.getCellByPosition(0, lrow).CellStyle in ('comp Int_colonna'):
508  LeenoComputo.insertVoceComputoGrezza(dccSheet, lrow + 1)
509  # @@ PROVVISORIO !!!
510  _gotoCella(1, lrow + 2)
511  numera_voci(1)
512  lrow = LeggiPosizioneCorrente()[1]
513  if dccSheet.getCellByPosition(
514  0, lrow).CellStyle in (stili_cat + stili_computo + ('comp Int_colonna', )):
515  if codice_voce(lrow) in ('', 'Cod. Art.?'):
517  else:
519  GotoSheet(nome)
521  if LeggiPosizioneCorrente()[1] > 20:
522  ddcDoc.CurrentController.setFirstVisibleColumn(0)
523  ddcDoc.CurrentController.setFirstVisibleRow(LeggiPosizioneCorrente()[1] - 5)
524  else:
525  return
526  # partenza
527  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
529  try:
530  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
531  except AttributeError:
532  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
533  try:
534  SR = oRangeAddress.StartRow
535  SR = LeenoComputo.circoscriveVoceComputo(oSheet, SR).RangeAddress.StartRow
536  except AttributeError:
537  Dialogs.Exclamation(Title = 'ATTENZIONE!',
538  Text='''La selezione delle voci dal COMPUTO
539 di partenza deve essere contigua.''')
540  # ~DLG.MsgBox(
541  # ~'La selezione delle voci dal COMPUTO di partenza\ndeve essere contigua.',
542  # ~'ATTENZIONE!')
543  return
544  ER = oRangeAddress.EndRow
545  ER = LeenoComputo.circoscriveVoceComputo(oSheet, ER).RangeAddress.EndRow
546  oDoc.CurrentController.select(oSheet.getCellRangeByPosition(0, SR, 100, ER))
547 
548  oSheet.getCellRangeByPosition(45, SR, 45, ER).CellBackColor = 15757935
549 
550  lista = list()
551  for el in range(SR, ER + 1):
552  if oSheet.getCellByPosition(0, el).CellStyle in ('Comp Start Attributo'):
553  lista.append(codice_voce(el))
554  # seleziona()
555  if nSheetDCC in ('Analisi di Prezzo'):
556  # ~DLG.MsgBox('Il foglio di destinazione non è corretto.', 'ATTENZIONE!')
557  Dialogs.Exclamation(Title = 'ATTENZIONE!',
558  Text='Il foglio di destinazione non è corretto.')
559  oDoc.CurrentController.select(
560  oDoc.createInstance(
561  "com.sun.star.sheet.SheetCellRanges")) # unselect
562  return
563  if nSheetDCC in ('COMPUTO', 'VARIANTE'):
564  comando('Copy')
565  # arrivo
566  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
567  ddcDoc = LeenoUtils.getDocument()
568  dccSheet = ddcDoc.getSheets().getByName(nSheet)
569  lrow = LeggiPosizioneCorrente()[1]
570  if dccSheet.getCellByPosition(0, lrow).CellStyle in ('comp Int_colonna', ):
571  lrow = LeggiPosizioneCorrente()[1] + 1
572  elif dccSheet.getCellByPosition(0, lrow).CellStyle not in stili_computo + stili_cat:
573  # ~DLG.MsgBox('La posizione di destinazione non è corretta.', 'ATTENZIONE!')
574  Dialogs.Exclamation(Title = 'ATTENZIONE!',
575  Text='La posizione di destinazione non è corretta.')
576  # unselect
577  oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges"))
578  return
579  else:
580  lrow = LeenoSheetUtils.prossimaVoce(dccSheet, LeggiPosizioneCorrente()[1], 1)
581  _gotoCella(0, lrow)
582  paste_clip(insCells=1)
583  numera_voci(1)
584  last = lrow + ER - SR + 1
585  while lrow < last:
586  rigenera_voce(lrow)
587  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 1)
588  # torno su partenza per prendere i prezzi
589  _gotoDoc(fpartenza)
590  oDoc = LeenoUtils.getDocument()
591  GotoSheet('Elenco Prezzi')
592  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
593  selezione = list()
594  ranges = oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")
595  for el in lista:
596  y = SheetUtils.uFindStringCol(el, 0, oSheet)
597  rangen = oSheet.getCellRangeByPosition(0, y, 100,
598  y).RangeAddress
599  selezione.append(rangen)
600 
601  ranges.addRangeAddresses(selezione, True)
602  oDoc.CurrentController.select(ranges)
603  comando('Copy')
604  #
605  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
606  ddcDoc = LeenoUtils.getDocument()
607  dccSheet = ddcDoc.getSheets().getByName('Elenco Prezzi')
608  GotoSheet('Elenco Prezzi')
609  _gotoCella(0, 3)
610  paste_clip(insCells=1)
611  # EliminaVociDoppieElencoPrezzi()
612  if nSheetDCC in ('Elenco Prezzi'):
613  # ~DLG.MsgBox("Non è possibile inviare voci da un COMPUTO all'Elenco Prezzi.")
614  Dialogs.Exclamation(Title = 'ATTENZIONE!',
615  Text="Non è possibile inviare voci da un COMPUTO all'Elenco Prezzi.")
616  return
617  oDoc.CurrentController.select(
618  oDoc.createInstance(
619  "com.sun.star.sheet.SheetCellRanges")) # unselect
620 
621  try:
622  len(analisi)
623 
624  selezione = list()
625  lista = list()
626  _gotoDoc(fpartenza)
627  oDoc = LeenoUtils.getDocument()
628  GotoSheet('Analisi di Prezzo')
629  ranges = oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")
630  ranges.addRangeAddresses(selezione_analisi, True)
631  oDoc.CurrentController.select(ranges)
632 
633  comando('Copy')
634 
635  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
636  ddcDoc = LeenoUtils.getDocument()
638  _gotoCella(0, 0)
639  paste_clip(insCells=1)
641  except Exception:
642  pass
643 
644  oDoc.CurrentController.select(
645  oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) # unselect
646  _gotoDoc(fpartenza)
647  GotoSheet(nSheet)
648  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
649  # ~if DLG.DlgSiNo("Ricerco ed elimino le voci di prezzo duplicate?") == 2:
650  # ~EliminaVociDoppieElencoPrezzi()
651  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
652  # ~LeenoSheetUtils.adattaAltezzaRiga(oSheet)
653  GotoSheet(nSheetDCC)
654  if nSheetDCC in ('COMPUTO', 'VARIANTE'):
655  lrow = LeggiPosizioneCorrente()[1]
656  _gotoCella(2, lrow + 1)
657  oSheet = oDoc.getSheets().getByName(nSheetDCC)
659 
660 
661 
662 
663 
664 def codice_voce(lrow, cod=None):
665  '''
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.
670  '''
671  oDoc = LeenoUtils.getDocument()
672  oSheet = oDoc.CurrentController.ActiveSheet
673  # lrow = LeggiPosizioneCorrente()[1]
674  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
675  sopra = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
676  elif oSheet.Name in ('Analisi di Prezzo'):
677  sopra = Circoscrive_Analisi(lrow).RangeAddress.StartRow + 1
678  if cod is None:
679  return oSheet.getCellByPosition(1, sopra + 1).String
680  else:
681  oSheet.getCellByPosition(1, sopra + 1).String = cod
682 
683 
684 # def getVoce(cod=None):
685 # oDoc = LeenoUtils.getDocument()
686 # oSheet = oDoc.CurrentController.ActiveSheet
687 # lrow = LeggiPosizioneCorrente()[1]
688 # sopra = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
689 # return oSheet.getCellByPosition(1, sopra+1).String
690 # def setVoce(cod):
691 # oDoc = LeenoUtils.getDocument()
692 # oSheet = oDoc.CurrentController.ActiveSheet
693 # lrow = LeggiPosizioneCorrente()[1]
694 # sopra = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
695 # oSheet.getCellByPosition(1, sopra+1).String = cod
696 
697 
698 
699 def _gotoDoc(sUrl):
700  '''
701  sUrl { string } : nome del file
702  porta il focus su di un determinato documento
703  '''
704  sUrl = uno.systemPathToFileUrl(sUrl)
705  if sys.platform == 'linux' or sys.platform == 'darwin':
706  target = LeenoUtils.getDesktop().loadComponentFromURL(
707  sUrl, "_default", 0, list())
708  target.getCurrentController().Frame.ContainerWindow.toFront()
709  target.getCurrentController().Frame.activate()
710  elif sys.platform == 'win32':
711  desktop = LeenoUtils.getDesktop()
712  oFocus = uno.createUnoStruct('com.sun.star.awt.FocusEvent')
713  target = desktop.loadComponentFromURL(sUrl, "_default", 0, list())
714  target.getCurrentController().getFrame().focusGained(oFocus)
715  return target
716 
717 
718 
719 
720 
722  '''
723  sUrl { string } : nome del file
724  porta il focus su di un determinato documento
725  '''
726  oDoc = LeenoUtils.getDocument()
727  fpartenza = uno.fileUrlToSystemPath(oDoc.getURL())
728  _gotoDoc(LeenoUtils.getGlobalVar('sUltimus'))
729  sUltimus_sheet = LeenoUtils.getDocument().CurrentController.ActiveSheet.Name
730  _gotoDoc(fpartenza)
731  LeenoUtils.setGlobalVar('sUltimus_sheet', sUltimus_sheet)
732  return sUltimus_sheet
733 
734 
735 
736 
737 
738 def oggi():
739  '''
740  restituisce la data di oggi
741  '''
742  return '/'.join(reversed(str(datetime.now()).split(' ')[0].split('-')))
743 
744 
745 
746 
747 
749  '''
750  fa una copia della directory del codice nel repository locale ed apre una shell per la commit
751  '''
752  oDoc = LeenoUtils.getDocument()
753 
754  try:
755  if oDoc.getSheets().getByName('S1').getCellByPosition(
756  7, 338).String == '':
757  src_oxt = '_LeenO'
758  else:
759  src_oxt = oDoc.getSheets().getByName('S1').getCellByPosition(
760  7, 338).String
761  except Exception:
762  pass
763 
764  make_pack(bar=1)
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):
768  try:
769  dest = os.getenv(
770  "HOME") + '/' + src_oxt + '/leeno/src/Ultimus.oxt/'
771  os.makedirs(dest)
772  os.makedirs(os.getenv("HOME") + '/' + src_oxt + '/leeno/bin/')
773  os.makedirs(os.getenv("HOME") + '/' + src_oxt + '/_SRC/OXT')
774  except FileExistsError:
775  pass
776 
777  comandi = 'cd ' + dest + ' && mate-terminal && gitk &'
778  else:
779  comandi = 'cd /media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt && mate-terminal && gitk &'
780  if not processo('wish'):
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/'):
784  try:
785  os.makedirs(
786  os.getenv("HOMEPATH") + '\\' + src_oxt +
787  '\\leeno\\src\\Ultimus.oxt\\')
788  except FileExistsError:
789  pass
790  dest = os.getenv("HOMEDRIVE") + os.getenv(
791  "HOMEPATH") + '\\' + src_oxt + '\\leeno\\src\\Ultimus.oxt\\'
792  else:
793  dest = 'w:\\_dwg\\ULTIMUSFREE\\_SRC\\leeno\\src\\Ultimus.oxt'
794  subprocess.Popen(
795  'w: && cd w:/_dwg/ULTIMUSFREE/_SRC/leeno/src/Ultimus.oxt && "C:/Program Files/Git/git-bash.exe"',
796  shell=True,
797  stdout=subprocess.PIPE)
798  return
799 
800 
801 
802 
803 
805  '''
806  Avvia la modifica di pyleeno.py con geany
807  '''
808  avvia_IDE()
809 
810 
811 def avvia_IDE():
812  '''Avvia la modifica di pyleeno.py con geany o eric6'''
813  basic_LeenO('file_gest.avvia_IDE')
814  oDoc = LeenoUtils.getDocument()
815  Toolbars.On("private:resource/toolbar/addon_ULTIMUS_3.OfficeToolBar_DEV", 1)
816  try:
817  if oDoc.getSheets().getByName('S1').getCellByPosition(
818  7, 338).String == '':
819  src_oxt = '_LeenO'
820  else:
821  src_oxt = oDoc.getSheets().getByName('S1').getCellByPosition(
822  7, 338).String
823  except Exception:
824  pass
825 
826  if sys.platform == 'linux' or sys.platform == 'darwin':
827 
828  dest = '/media/giuserpe/PRIVATO/LeenO/_SRC/leeno/src/Ultimus.oxt/python/pythonpath'
829  if not os.path.exists(dest):
830  try:
831  dest = os.getenv(
832  "HOME") + '/' + src_oxt + '/leeno/src/Ultimus.oxt/'
833  os.makedirs(dest)
834  os.makedirs(os.getenv("HOME") + '/' + src_oxt + '/leeno/bin/')
835  os.makedirs(os.getenv("HOME") + '/' + src_oxt + '/_SRC/OXT')
836  except FileExistsError:
837  pass
838 
839  subprocess.Popen('caja '+
840  # ~dest,
841  uno.fileUrlToSystemPath(LeenO_path()),
842  shell=True,
843  stdout=subprocess.PIPE)
844  subprocess.Popen('geany ' + dest + '/pyleeno.py',
845  # ~ subprocess.Popen('eric ' + dest + '/pyleeno.py',
846  shell=True,
847  stdout=subprocess.PIPE)
848  elif sys.platform == 'win32':
849  if not os.path.exists('w:/_dwg/ULTIMUSFREE/_SRC/leeno/src/'):
850  try:
851  os.makedirs(
852  os.getenv("HOMEPATH") + '\\' + src_oxt +
853  '\\leeno\\src\\Ultimus.oxt\\')
854  except FileExistsError:
855  pass
856  dest = os.getenv("HOMEDRIVE") + os.getenv(
857  "HOMEPATH") + '\\' + src_oxt + '\\leeno\\src\\Ultimus.oxt\\'
858  else:
859  dest = 'w:\\_dwg\\ULTIMUSFREE\\_SRC\\leeno\\src\\Ultimus.oxt'
860  # ~subprocess.Popen('explorer.exe ' +
861  # dest,
862  # ~uno.fileUrlToSystemPath(LeenO_path()),
863  # ~shell=True,
864  # ~stdout=subprocess.PIPE)
865  subprocess.Popen('"C:/Program Files/Geany/bin/geany.exe" ' +
866  dest +
867  '/python/pythonpath/pyleeno.py',
868  shell=True,
869  stdout=subprocess.PIPE)
870  return
871 
872 
873 
874 
875 
877  '''
878  @@ DA DOCUMENTARE
879  '''
881 
882 
884  '''
885  @@ DA DOCUMENTARE
886  '''
887  Ins_Categorie(2)
888 
889 
890 
891 
892 
894  '''
895  n { int } : livello della categoria
896  0 = SuperCategoria
897  1 = Categoria
898  2 = SubCategoria
899  '''
900  oDoc = LeenoUtils.getDocument()
902  oSheet = oDoc.CurrentController.ActiveSheet
903 
904  stili_computo = LeenoUtils.getGlobalVar('stili_computo')
905  stili_contab = LeenoUtils.getGlobalVar('stili_contab')
906  noVoce = LeenoUtils.getGlobalVar('noVoce')
907 
908  row = LeggiPosizioneCorrente()[1]
909  if oSheet.getCellByPosition(0,row).CellStyle in stili_computo + stili_contab:
910  lrow = LeenoSheetUtils.prossimaVoce(oSheet, row, 1)
911  elif oSheet.getCellByPosition(0, row).CellStyle in noVoce:
912  lrow = row + 1
913  else:
914  return
915  sTesto = ''
916  if n == 0:
917  sTesto = 'Inserisci il titolo per la Supercategoria'
918  elif n == 1:
919  sTesto = 'Inserisci il titolo per la Categoria'
920  elif n == 2:
921  sTesto = 'Inserisci il titolo per la Sottocategoria'
922  sString = InputBox('', sTesto)
923  if sString is None or sString == '':
924  return
925 
926  if n == 0:
927  LeenoSheetUtils.inserSuperCapitolo(oSheet, lrow, sString)
928  elif n == 1:
929  LeenoSheetUtils.inserCapitolo(oSheet, lrow, sString)
930  elif n == 2:
931  LeenoSheetUtils.inserSottoCapitolo(oSheet, lrow, sString)
932 
933  _gotoCella(2, lrow)
935  oDoc.enableAutomaticCalculation(True)
936  oDoc.CurrentController.setFirstVisibleColumn(0)
937  oDoc.CurrentController.setFirstVisibleRow(lrow - 5)
939 
940 
941 
942 
943 
945  '''
946  @@ DA DOCUMENTARE
947  '''
949 
950 
952  '''
953  @@ DA DOCUMENTARE
954  '''
955  Ins_Categorie(0)
956 
957 
958 
960  '''
961  @@ DA DOCUMENTARE
962  '''
964 
965 
967  '''
968  @@ DA DOCUMENTARE
969  '''
970  Ins_Categorie(1)
971 
972 
973 
974 
976  oDoc = LeenoUtils.getDocument()
977  oSheet = oDoc.CurrentController.ActiveSheet
979 
980 
982  # sistemo gli idcat voce per voce
983  oDoc = LeenoUtils.getDocument()
984  oDoc.enableAutomaticCalculation(False)
986 
987  # ricalcola i totali di categorie e subcategorie
988  Tutti_Subtotali(oSheet)
989  oDoc.enableAutomaticCalculation(True)
990 
991 
992 def Tutti_Subtotali(oSheet):
993  '''ricalcola i subtotali di categorie e subcategorie'''
994 
995  if oSheet.Name not in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
996  return
997  for n in range(0, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1):
998  if oSheet.getCellByPosition(0, n).CellStyle == 'Livello-0-scritta':
999  SubSum_SuperCap(n)
1000  if oSheet.getCellByPosition(0, n).CellStyle == 'Livello-1-scritta':
1001  SubSum_Cap(n)
1002  if oSheet.getCellByPosition(0, n).CellStyle == 'livello2 valuta':
1003  SubSum_SottoCap(n)
1004 
1005  # TOTALI GENERALI
1006  lrow = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
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) + ')'
1015 
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) + ')'
1020 
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) + ')'
1029 
1030 
1031 
1032 
1033 
1035  '''
1036  lrow { double } : id della riga di inserimento
1037  inserisce i dati nella riga di SuperCategoria
1038  '''
1039  oDoc = LeenoUtils.getDocument()
1040  oSheet = oDoc.CurrentController.ActiveSheet
1041  if oSheet.Name not in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
1042  return
1043  # lrow = LeggiPosizioneCorrente()[1]
1044  lrowE = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
1045  nextCap = lrowE
1046  for n in range(lrow + 1, lrowE):
1047  if oSheet.getCellByPosition(
1048  18,
1049  n).CellStyle in ('Livello-0-scritta mini val', 'Comp TOTALI'):
1050  # MsgBox(oSheet.getCellByPosition(18, n).CellStyle,'')
1051  nextCap = n + 1
1052  break
1053  # oDoc.enableAutomaticCalculation(False)
1054  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
1055  oSheet.getCellByPosition(
1056  18, lrow
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) + ')' # IMPORTO
1077  oSheet.getCellByPosition(
1078  16, lrow).Formula = '=P' + str(lrow + 1) + '/P' + str(
1079  lrowE) # incidenza sul totale
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'
1096  # oDoc.enableAutomaticCalculation(True)
1097 
1098 
1099 
1100 
1101 
1103  '''
1104  lrow { double } : id della riga di inserimento
1105  inserisce i dati nella riga di subcategoria
1106  '''
1107  oDoc = LeenoUtils.getDocument()
1108  oSheet = oDoc.CurrentController.ActiveSheet
1109  if oSheet.Name not in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
1110  return
1111  # lrow = 0#LeggiPosizioneCorrente()[1]
1112  lrowE = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
1113  nextCap = lrowE
1114  for n in range(lrow + 1, lrowE):
1115  if oSheet.getCellByPosition(
1116  18,
1117  n).CellStyle in ('livello2 scritta mini',
1118  'Livello-0-scritta mini val',
1119  'Livello-1-scritta mini val', 'Comp TOTALI'):
1120  nextCap = n + 1
1121  break
1122  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
1123  oSheet.getCellByPosition(
1124  18, lrow
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) + ')' # IMPORTO
1142  oSheet.getCellByPosition(
1143  16, lrow).Formula = '=P' + str(lrow + 1) + '/P' + str(
1144  lrowE) # incidenza sul totale
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'
1156 
1157 
1158 
1159 
1160 
1161 def SubSum_Cap(lrow):
1162  '''
1163  lrow { double } : id della riga di inserimento
1164  inserisce i dati nella riga di categoria
1165  '''
1166  oDoc = LeenoUtils.getDocument()
1167  oSheet = oDoc.CurrentController.ActiveSheet
1168  if oSheet.Name not in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
1169  return
1170  # lrow = LeggiPosizioneCorrente()[1]
1171  lrowE = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
1172  nextCap = lrowE
1173  for n in range(lrow + 1, lrowE):
1174  if oSheet.getCellByPosition(
1175  18,
1176  n).CellStyle in ('Livello-1-scritta mini val',
1177  'Livello-0-scritta mini val', 'Comp TOTALI'):
1178  # MsgBox(oSheet.getCellByPosition(18, n).CellStyle,'')
1179  nextCap = n + 1
1180  break
1181  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
1182  oSheet.getCellByPosition(18, lrow).Formula = '=SUBTOTAL(9;S' + str(
1183  lrow + 1) + ':S' + str(nextCap) + ')' # IMPORTO
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) + ')' # IMPORTO
1203  oSheet.getCellByPosition(
1204  16, lrow).Formula = '=P' + str(lrow + 1) + '/P' + str(
1205  lrowE) # incidenza sul totale
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'
1222 
1223 
1224 
1225 
1226 
1228  '''
1229  lrow { double } : id della riga di inserimento
1230  sincronizza categoria e sottocategorie
1231  '''
1232  if oSheet.Name not in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
1233  return
1234 # lrow = LeggiPosizioneCorrente()[1]
1235  lastRow = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
1236 
1237  listasbcat = list()
1238  listacat = list()
1239  listaspcat = list()
1240  for lrow in range(0, lastRow):
1241  # SUB CATEGORIA
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))
1245  try:
1246  oSheet.getCellByPosition(31, lrow).Value = idspcat
1247  except Exception:
1248  pass
1249  try:
1250  oSheet.getCellByPosition(32, lrow).Value = idcat
1251  except Exception:
1252  pass
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)
1258 
1259  # CATEGORIA
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))
1263 
1264  idsbcat = None
1265 
1266  try:
1267  oSheet.getCellByPosition(31, lrow).Value = idspcat
1268  except Exception:
1269  pass
1270  idcat = listacat.index(oSheet.getCellByPosition(2,
1271  lrow).String) + 1
1272  oSheet.getCellByPosition(32, lrow).Value = idcat
1273  oSheet.getCellByPosition(
1274  1, lrow).Formula = '=AF' + str(lrow +
1275  1) + '&"."&AG' + str(lrow + 1)
1276 
1277  # SUPER CATEGORIA
1278  elif oSheet.getCellByPosition(
1279  2,
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))
1283 
1284  idcat = idsbcat = None
1285 
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)
1290 
1291  # CATEGORIA
1292  elif oSheet.getCellByPosition(
1293  33, lrow).CellStyle == 'compTagRiservato':
1294  try:
1295  oSheet.getCellByPosition(33, lrow).Value = idsbcat
1296  except Exception:
1297  oSheet.getCellByPosition(33, lrow).Value = 0
1298  try:
1299  oSheet.getCellByPosition(32, lrow).Value = idcat
1300  except Exception:
1301  oSheet.getCellByPosition(32, lrow).Value = 0
1302  try:
1303  oSheet.getCellByPosition(31, lrow).Value = idspcat
1304  except Exception:
1305  oSheet.getCellByPosition(31, lrow).Value = 0
1306 
1307 
1310 
1311 
1313  '''Mostra tutti i foglio fogli'''
1314  oDoc = LeenoUtils.getDocument()
1315  lista_fogli = oDoc.Sheets.ElementNames
1316  for el in lista_fogli:
1317  oDoc.getSheets().getByName(el).IsVisible = True
1318 
1319 
1320 
1321 
1322 
1324  '''
1325  Mostra tutti i foglio fogli
1326  '''
1328 
1329 
1331  '''Mostra tutti i foglio fogli'''
1332  oDoc = LeenoUtils.getDocument()
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'):
1338  if nome in el:
1339  oDoc.getSheets().getByName(el).IsVisible = False
1340 
1341 
1342 
1343 
1344 
1346  '''Mostra tutti i foglio fogli'''
1347  oDoc = LeenoUtils.getDocument()
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'):
1354  if nome in el:
1355  oDoc.getSheets().getByName(el).IsVisible = False
1356 
1357 
1358 
1359 
1360 
1362  '''Mostra tutti i foglio fogli'''
1363  oDoc = LeenoUtils.getDocument()
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'):
1370  if nome in el:
1371  oDoc.getSheets().getByName(el).IsVisible = False
1372 
1373 
1374 
1375 
1376 
1377 def copia_sheet(nSheet, tag):
1378  '''
1379  nSheet { string } : nome sheet
1380  tag { string } : stringa di tag
1381  duplica copia sheet corrente di fianco a destra
1382  '''
1383  oDoc = LeenoUtils.getDocument()
1384  # nSheet = 'COMPUTO'
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.')
1389  return
1390  else:
1391  oDoc.Sheets.copyByName(nSheet, nSheet + '_' + tag, idSheet)
1392  oSheet = oDoc.getSheets().getByName(nSheet + '_' + tag)
1393  oDoc.CurrentController.setActiveSheet(oSheet)
1394  # oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) #'unselect
1395 
1396 
1397 
1398 
1399 
1400 def Filtra_computo(nSheet, nCol, sString):
1401  '''
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
1406  '''
1407  oDoc = LeenoUtils.getDocument()
1408  copia_sheet(nSheet, sString)
1409  oSheet = oDoc.CurrentController.ActiveSheet
1410  for lrow in reversed(range(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))):
1411  try:
1412  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
1413  sopra = sStRange.RangeAddress.StartRow
1414  sotto = sStRange.RangeAddress.EndRow
1415  if nCol == 1:
1416  test = sopra + 1
1417  else:
1418  test = sotto
1419  if sString != oSheet.getCellByPosition(nCol, test).String:
1420  oSheet.getRows().removeByIndex(sopra, sotto - sopra + 1)
1421  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 0)
1422  except Exception:
1423  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 0)
1424  for lrow in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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):
1429 
1430  oSheet.getRows().removeByIndex(lrow, 1)
1431  return
1432  # iCellAttr =(oDoc.createInstance("com.sun.star.sheet.CellFlags.OBJECTS"))
1433  flags = OBJECTS
1434  oSheet.getCellRangeByPosition(0, 0, 42, 0).clearContents(
1435  flags) # cancello gli oggetti
1436  oDoc.CurrentController.select(oSheet.getCellByPosition(0, 3))
1437  oDoc.CurrentController.select(
1438  oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) # unselect
1439 
1440 
1441 
1442 
1443 
1444 # ~def Filtra_Computo_Cap():
1445  # ~oDoc = LeenoUtils.getDocument()
1446  # ~oSheet = oDoc.CurrentController.ActiveSheet
1447  # ~nSheet = oSheet.getCellByPosition(7, 8).String
1448  # ~sString = oSheet.getCellByPosition(7, 10).String
1449  # ~Filtra_computo(nSheet, 31, sString)
1450 
1451 
1452 
1453 
1454 
1455 # ~def Filtra_Computo_SottCap():
1456  # ~oDoc = LeenoUtils.getDocument()
1457  # ~oSheet = oDoc.CurrentController.ActiveSheet
1458  # ~nSheet = oSheet.getCellByPosition(7, 8).String
1459  # ~sString = oSheet.getCellByPosition(7, 12).String
1460  # ~Filtra_computo(nSheet, 32, sString)
1461 
1462 
1463 
1464 
1465 
1466 # ~def Filtra_Computo_A():
1467  # ~oDoc = LeenoUtils.getDocument()
1468  # ~oSheet = oDoc.CurrentController.ActiveSheet
1469  # ~nSheet = oSheet.getCellByPosition(7, 8).String
1470  # ~sString = oSheet.getCellByPosition(7, 14).String
1471  # ~Filtra_computo(nSheet, 33, sString)
1472 
1473 
1474 
1475 
1476 
1477 # ~def Filtra_Computo_B():
1478  # ~oDoc = LeenoUtils.getDocument()
1479  # ~oSheet = oDoc.CurrentController.ActiveSheet
1480  # ~nSheet = oSheet.getCellByPosition(7, 8).String
1481  # ~sString = oSheet.getCellByPosition(7, 16).String
1482  # ~Filtra_computo(nSheet, 34, sString)
1483 
1484 
1485 
1486 
1487 
1488 # ~def Filtra_Computo_C(): # filtra in base al codice di prezzo
1489  # ~oDoc = LeenoUtils.getDocument()
1490  # ~oSheet = oDoc.CurrentController.ActiveSheet
1491  # ~nSheet = oSheet.getCellByPosition(7, 8).String
1492  # ~sString = oSheet.getCellByPosition(7, 20).String
1493  # ~Filtra_computo(nSheet, 1, sString)
1494 
1495 
1496 
1497 
1498 
1499 def vai_a_M1():
1500  chiudi_dialoghi()
1501  GotoSheet('M1', 85)
1502  _primaCella(0, 0)
1503 
1504 
1505 
1506 
1507 
1508 def vai_a_S2():
1509  chiudi_dialoghi()
1510  GotoSheet('S2')
1511  _primaCella(0, 0)
1512 
1513 
1514 
1515 
1516 
1517 def vai_a_S1():
1518  chiudi_dialoghi()
1519  GotoSheet('S1')
1520  _primaCella(0, 190)
1521 
1522 
1523 
1524 
1525 
1526 def vai_a_ElencoPrezzi(event=None):
1527  chiudi_dialoghi()
1528  GotoSheet('Elenco Prezzi')
1529 
1530 
1531 
1532 
1533 
1535  chiudi_dialoghi()
1536  GotoSheet('COMPUTO')
1537 
1538 
1539 
1540 
1541 
1543  chiudi_dialoghi()
1544  GotoSheet('S1', 85)
1545  _primaCella(6, 289)
1546 
1547 
1548 
1549 
1550 
1552  chiudi_dialoghi()
1553  GotoSheet('Scorciatoie')
1554  _primaCella(0, 0)
1555 
1556 
1557 
1558 
1559 
1560 def GotoSheet(nSheet, fattore=100):
1561  '''
1562  nSheet { string } : nome Sheet
1563  attiva e seleziona una sheet
1564  '''
1565  oDoc = LeenoUtils.getDocument()
1566  oSheet = oDoc.Sheets.getByName(nSheet)
1567  # oDoc.getCurrentSelection().getCellAddress().Sheet
1568 
1569  oSheet.IsVisible = True
1570  oDoc.CurrentController.setActiveSheet(oSheet)
1571  # oDoc.CurrentController.ZoomValue = fattore
1572  # oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) #'unselect
1573 
1574 
1575 
1576 
1577 
1578 def _primaCella(IDcol=0, IDrow=0):
1579  '''
1580  IDcol { integer } : id colonna
1581  IDrow { integer } : id riga
1582  settaggio prima cella visibile(IDcol, IDrow)
1583  '''
1584  oDoc = LeenoUtils.getDocument()
1585  # oSheet = oDoc.CurrentController.ActiveSheet
1586  oDoc.CurrentController.setFirstVisibleColumn(IDcol)
1587  oDoc.CurrentController.setFirstVisibleRow(IDrow)
1588  return
1589 
1590 
1591 
1592 
1593 
1594 def ordina_col(ncol):
1595  '''
1596  ncol { integer } : id colonna
1597  ordina i dati secondo la colonna con id ncol
1598  '''
1599  # oDoc = LeenoUtils.getDocument()
1600  # oSheet = oDoc.CurrentController.ActiveSheet
1602  desktop = LeenoUtils.getDesktop()
1603  oFrame = desktop.getCurrentFrame()
1604  dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1605  'com.sun.star.frame.DispatchHelper', ctx)
1606  oProp = []
1607  oProp0 = PropertyValue()
1608  oProp0.Name = 'ByRows'
1609  oProp0.Value = True
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'
1621  oProp4.Value = True
1622  oProp5 = PropertyValue()
1623  oProp5.Name = 'UserDefIndex'
1624  oProp5.Value = 0
1625  oProp6 = PropertyValue()
1626  oProp6.Name = 'Col1'
1627  oProp6.Value = ncol
1628  oProp7 = PropertyValue()
1629  oProp7.Name = 'Ascending1'
1630  oProp7.Value = True
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)
1641 
1642 
1643 
1644 
1646  '''
1647  Sprotegge e riordina tutti fogli del documento.
1648  '''
1650 
1651 
1653  '''
1654  Sprotegge e riordina tutti fogli del documento.
1655  '''
1656  oDoc = LeenoUtils.getDocument()
1657  oSheets = oDoc.Sheets.ElementNames
1658  for nome in oSheets:
1659  oSheet = oDoc.getSheets().getByName(nome)
1660  oSheet.unprotect('')
1661  # riordino le sheet
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)
1674  # ~oDoc.Sheets.moveByName("S4", 9)
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)
1679 
1680 
1681 
1682 
1683 
1684 def setPreview(arg=0):
1685  '''
1686  colore { integer } : id colore
1687  attribuisce al foglio corrente un colore a scelta
1688  '''
1689  oDoc = LeenoUtils.getDocument()
1690  oSheet = oDoc.CurrentController.ActiveSheet # se questa dà errore, il preview è già attivo
1691  # ~LeenoSheetUtils.adattaAltezzaRiga(oSheet)
1693  desktop = LeenoUtils.getDesktop()
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)
1700 
1701 
1702 
1703 
1704 
1705 def setTabColor(colore):
1706  '''
1707  colore { integer } : id colore
1708  attribuisce al foglio corrente un colore a scelta
1709  '''
1710  # oDoc = LeenoUtils.getDocument()
1711  # oSheet = oDoc.CurrentController.ActiveSheet
1713  desktop = LeenoUtils.getDesktop()
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,
1722  properties)
1723 
1724 
1725 
1726 
1727 
1728 def txt_Format(stile):
1729  '''
1730  Forza la formattazione della cella
1731  '''
1732  # oDoc = LeenoUtils.getDocument()
1733  # oSheet = oDoc.CurrentController.ActiveSheet
1735  desktop = LeenoUtils.getDesktop()
1736  oFrame = desktop.getCurrentFrame()
1737  dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
1738  'com.sun.star.frame.DispatchHelper', ctx)
1739  oProp = PropertyValue()
1740  oProp.Name = stile
1741  oProp.Value = True
1742  properties = (oProp, )
1743  dispatchHelper.executeDispatch(oFrame, '.uno:' + stile, '', 0, properties)
1744 
1745 
1746 
1747 
1748 
1749 def show_sheets(x=True):
1750  '''
1751  x { boolean } : True = ON, False = OFF
1752 
1753  Mastra/nasconde tutte le tabelle ad esclusione di COMPUTO ed Elenco Prezzi
1754  '''
1755  oDoc = LeenoUtils.getDocument()
1756  oSheets = list(oDoc.getSheets().getElementNames())
1757  # for nome in ('M1', 'S1', 'S2', 'S5', 'Elenco Prezzi', 'COMPUTO'):
1758  for nome in ('Elenco Prezzi', 'COMPUTO'):
1759  oSheets.remove(nome)
1760  # oSheets.remove('Elenco Prezzi')
1761  # oSheets.remove('COMPUTO')
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'):
1767  try:
1768  oSheet = oDoc.getSheets().getByName(nome)
1769  oSheet.IsVisible = True
1770  except Exception:
1771  pass
1772 
1773 
1775  show_sheets(False)
1776 
1777 
1778 
1779 
1780 
1781 def salva_come(nomefile=None):
1782  '''
1783  nomefile { string } : nome del file di destinazione
1784  Se presente l'argomento nomefile, salva il file corrente in nomefile.
1785  '''
1786  # oDoc = LeenoUtils.getDocument()
1787  # oSheet = oDoc.CurrentController.ActiveSheet
1789  desktop = LeenoUtils.getDesktop()
1790  oFrame = desktop.getCurrentFrame()
1791  dispatchHelper = ctx.ServiceManager.createInstanceWithContext('com.sun.star.frame.DispatchHelper', ctx)
1792 
1793  oProp = []
1794  if nomefile is not None:
1795  nomefile = uno.systemPathToFileUrl(nomefile)
1796  oProp0 = PropertyValue()
1797  oProp0.Name = "URL"
1798  oProp0.Value = nomefile
1799  oProp.append(oProp0)
1800 
1801  oProp1 = PropertyValue()
1802  oProp1.Name = "FilterName"
1803  oProp1.Value = "calc8"
1804  oProp.append(oProp1)
1805 
1806  properties = tuple(oProp)
1807 
1808  dispatchHelper.executeDispatch(oFrame, ".uno:SaveAs", "", 0, properties)
1809 
1810 
1811 
1812 
1813 
1814 def _gotoCella(IDcol=0, IDrow=0):
1815  '''
1816  IDcol { integer } : id colonna
1817  IDrow { integer } : id riga
1818 
1819  muove il cursore nelle cella(IDcol, IDrow)
1820  '''
1821  oDoc = LeenoUtils.getDocument()
1822  oSheet = oDoc.CurrentController.ActiveSheet
1823 
1824  oDoc.CurrentController.select(oSheet.getCellByPosition(IDcol, IDrow))
1825  oDoc.CurrentController.select(
1826  oDoc.createInstance("com.sun.star.sheet.SheetCellRanges"))
1827  return
1828 
1829 
1830 
1831 
1832 
1834  '''
1835  Legge il numero di versione di LibreOffice.
1836  '''
1837  # sAccess = LeenoUtils.createUnoService(
1838  # "com.sun.star.configuration.ConfigurationAccess")
1839  aConfigProvider = LeenoUtils.createUnoService(
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
1847 
1848 
1851 
1853  oDoc = LeenoUtils.getDocument()
1854  oSheet = oDoc.CurrentController.ActiveSheet
1856 
1858  '''
1859  Cambia il numero di caratteri visualizzati per la descrizione voce in COMPUTO,
1860  CONTABILITA E VARIANTE.
1861  '''
1862  chiudi_dialoghi()
1863  oDoc = LeenoUtils.getDocument()
1864  oSheet = oDoc.CurrentController.ActiveSheet
1865  # ~oSheet.getCellRangeByPosition(
1866  # ~0, 0,
1867  # ~SheetUtils.getUsedArea(oSheet).EndColumn,
1868  # ~SheetUtils.getUsedArea(oSheet).EndRow).Rows.OptimalHeight = True
1869  if not oDoc.getSheets().hasByName('S1'):
1870  return
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
1876  else:
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
1882  else:
1883  oSheet.getCellRangeByName('S1.H338').Value = int(cfg.read('Computo', 'fine_voci_abbreviate'))
1884 
1885  elif oSheet.Name == 'CONTABILITA':
1886  oSheet = oDoc.getSheets().getByName('S1')
1887  if oDoc.NamedRanges.hasByName("_Lib_1"):
1888  Dialogs.Exclamation(Title = 'ATTENZIONE!',
1889  Text='''Risulta già registrato un SAL, quindi
1890  NON E' POSSIBILE PROCEDERE.''')
1891  # ~DLG.MsgBox(
1892  # ~"Risulta già registrato un SAL. NON E' POSSIBILE PROCEDERE.",
1893  # ~'ATTENZIONE!')
1894  return
1895  else:
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
1899  else:
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
1904  else:
1905  oSheet.getCellRangeByName('S1.H336').Value = int(cfg.read('Contabilita', 'cont_fine_voci_abbreviate'))
1907 
1908 
1909 
1910 
1911 
1913  '''
1914  Aggiunge suffisso al Codice Articolo
1915  '''
1916  testo = ''
1917  suffisso = InputBox(
1918  testo, t='Inserisci il suffisso per il Codice Articolo (es: "BAS22/1_").')
1919  if suffisso in (None, '', ' '):
1920  return
1921  oDoc = LeenoUtils.getDocument()
1922  oSheet = oDoc.CurrentController.ActiveSheet
1923  lrow = SheetUtils.getLastUsedRow(oSheet)
1924 
1925  # attiva la progressbar
1926  progress = Dialogs.Progress(Title='Operazione in corso...', Text="Progressione")
1927  n = 0
1928  progress.setLimits(n, lrow)
1929  progress.show()
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)
1936  progress.hide()
1937 
1938 
1939 
1940 
1941 
1943  '''
1944  Cancella le voci di prezzo non utilizzate.
1945  '''
1947  chiudi_dialoghi()
1948 
1949  if Dialogs.YesNoDialog(Title='AVVISO!',
1950  Text='''Questo comando ripulisce l'Elenco Prezzi
1951 dalle voci non utilizzate in nessuno degli altri elaborati.
1952 
1953 LA PROCEDURA POTREBBE RICHIEDERE DEL TEMPO.
1954 
1955 Vuoi procedere comunque?''') == 0:
1956  return
1957  oDoc = LeenoUtils.getDocument()
1958  oDoc.enableAutomaticCalculation(False)
1959  oSheet = oDoc.CurrentController.ActiveSheet
1960 
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)
1967  lista = list()
1968  # attiva la progressbar
1969  progress = Dialogs.Progress(Title='Ricerca delle voci da eliminare in corso...', Text="Lettura dati")
1970  n = 0
1971  progress.setLimits(n, len(lista_prezzi))
1972  progress.show()
1973  progress.setValue(1)
1974  for tab in ('COMPUTO', 'Analisi di Prezzo', 'VARIANTE', 'CONTABILITA'):
1975  try:
1976  oSheet = oDoc.getSheets().getByName(tab)
1977  if tab == 'Analisi di Prezzo':
1978  col = 0
1979  else:
1980  col = 1
1981  for el in lista_prezzi:
1982  n += 1
1983  progress.setValue(n)
1984  if SheetUtils.uFindStringCol(el, col, oSheet):
1985  lista.append(el)
1986  except Exception:
1987  pass
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))
1998  struttura_off()
1999  struttura_off()
2000  struttura_off()
2001  oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) #'unselect
2002  progress.setValue(4)
2003 
2004  # ~for el in da_cancellare:
2005  # ~oCellRangeAddr.StartRow = el
2006  # ~oCellRangeAddr.EndRow = el
2007  # ~oSheet.group(oCellRangeAddr, 1)
2008  # ~oSheet.getCellRangeByPosition(0, el, 0,
2009  # ~el).Rows.IsVisible = False
2010 
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)
2018 
2019  progress.setValue(5)
2020  oDoc.enableAutomaticCalculation(True)
2021  progress.hide()
2022  _gotoCella(0, 3)
2024  Dialogs.Info(Title = 'Ricerca conclusa', Text='Eliminate ' + str(len(da_cancellare)) + " voci dall'elenco prezzi.")
2025 
2026 
2027 
2028 
2029 
2031  '''
2032  Ottimizza l'altezza delle celle di Elenco Prezzi o visualizza solo
2033  tre righe della descrizione.
2034  '''
2035  oDoc = LeenoUtils.getDocument()
2036  oSheet = oDoc.CurrentController.ActiveSheet
2037 
2038  oRange = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2039  SR = oRange.StartRow + 1
2040  ER = oRange.EndRow
2041 
2042  if not oSheet.getCellByPosition(1, 3).Rows.OptimalHeight:
2044  else:
2045  hriga = oSheet.getCellRangeByName(
2046  'B4').CharHeight * 65 * 2 + 100 # visualizza tre righe
2047  oSheet.getCellRangeByPosition(0, SR, 0, ER).Rows.Height = hriga
2048 
2049 
2050 
2051 
2052 
2054  '''
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'
2058  '''
2059  oDoc = LeenoUtils.getDocument()
2061  oSheet = oDoc.CurrentController.ActiveSheet
2062  psm = LeenoUtils.getComponentContext().ServiceManager
2063  dp = psm.createInstance('com.sun.star.awt.DialogProvider')
2064  global oDialog1
2065  if oSheet.Name in ('VARIANTE', 'COMPUTO'):
2066  oDialog1 = dp.createDialog(
2067  'vnd.sun.star.script:UltimusFree2.DialogViste_A?language=Basic&location=application'
2068  )
2069  # oDialog1Model = oDialog1.Model
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
2083 
2084  sString = oDialog1.getControl('TextField10')
2085  sString.Text = oDoc.getSheets().getByName('S1').getCellRangeByName(
2086  'H337').Value # inizio_voci_abbreviate
2087  sString = oDialog1.getControl('TextField11')
2088  sString.Text = oDoc.getSheets().getByName('S1').getCellRangeByName(
2089  'H338').Value # fine_voci_abbreviate
2090 
2091  oDialog1.execute()
2092 
2093  # il salvataggio anche su leeno.conf serve alla funzione voce_breve()
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())
2097 
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())
2101  # oDialog1.getControl('CBMdo').State = False
2102  # if oSheet.getColumns().getByIndex(29).Columns.IsVisible:
2103  # oDialog1.getControl('CBMdo').State = True
2104 
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
2113 
2114  if oDialog1.getControl("CBMis").State == 0: # misure
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
2119  else:
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
2124 
2125  if oDialog1.getControl('CBMdo').State: # manodopera
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
2132  # LeenoSheetUtils.adattaAltezzaRiga(oSheet)
2133  oSheet.clearOutline()
2134  struct(3)
2135  else:
2136  oSheet.getColumns().getByIndex(29).Columns.IsVisible = False
2137  oSheet.getColumns().getByIndex(30).Columns.IsVisible = False
2138 
2139  if oDialog1.getControl('CBMat').State == 0: # materiali
2140  oSheet.getColumns().getByIndex(28).Columns.IsVisible = False
2141 
2142  else:
2143  oSheet.getColumns().getByIndex(28).Columns.IsVisible = True
2144 
2145  if oDialog1.getControl('CBCat').State == 0: # categorie
2146  oSheet.getColumns().getByIndex(31).Columns.IsVisible = False
2147  oSheet.getColumns().getByIndex(32).Columns.IsVisible = False
2148  oSheet.getColumns().getByIndex(33).Columns.IsVisible = False
2149  else:
2150  oSheet.getColumns().getByIndex(31).Columns.IsVisible = True
2151  oSheet.getColumns().getByIndex(32).Columns.IsVisible = True
2152  oSheet.getColumns().getByIndex(33).Columns.IsVisible = True
2153 
2154  if oDialog1.getControl("CBSic").State == 0: # sicurezza
2155  oSheet.getColumns().getByIndex(17).Columns.IsVisible = False
2156  else:
2157  oSheet.getColumns().getByIndex(17).Columns.IsVisible = True
2158 
2159  if oDialog1.getControl("CBFig").State == 0: # figure
2160  oSheet.getColumns().getByIndex(38).Columns.IsVisible = False
2161  else:
2162  oSheet.getColumns().getByIndex(38).Columns.IsVisible = True
2163 
2164  if oDialog1.getControl('Dettaglio').State == 0: #
2165  cfg.write('Generale', 'dettaglio', '0')
2166  dettaglio_misure(0)
2167  else:
2168  cfg.write('Generale', 'dettaglio', '1')
2169  dettaglio_misure(0)
2170  dettaglio_misure(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"
2175  )
2176  # oDialog1Model = oDialog1.Model
2177 
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: # sicurezza
2188  oSheet.getColumns().getByIndex(3).Columns.IsVisible = False
2189  else:
2190  oSheet.getColumns().getByIndex(3).Columns.IsVisible = True
2191 
2192  if oDialog1.getControl("CBMdo").State == 0: # manodopera
2193  oSheet.getColumns().getByIndex(5).Columns.IsVisible = False
2194  oSheet.getColumns().getByIndex(6).Columns.IsVisible = False
2195  else:
2196  oSheet.getColumns().getByIndex(5).Columns.IsVisible = True
2197  oSheet.getColumns().getByIndex(6).Columns.IsVisible = True
2198 
2199  if oDialog1.getControl("CBDesc").State == 1: # descrizione
2200  oSheet.getColumns().getByIndex(3).Columns.IsVisible = False
2201  oSheet.getCellByPosition(1, 3).Rows.OptimalHeight
2202  voce_breve_ep()
2203  # elif oDialog1.getControl("CBDesc").State == 0: LeenoSheetUtils.adattaAltezzaRiga(oSheet)
2204 
2205  if oDialog1.getControl("CBOrig").State == 0: # origine
2206  oSheet.getColumns().getByIndex(7).Columns.IsVisible = False
2207  else:
2208  oSheet.getColumns().getByIndex(7).Columns.IsVisible = True
2209 
2210  if oDialog1.getControl("CBSom").State == 1:
2211  genera_sommario()
2212 
2213  oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2214  SR = oRangeAddress.StartRow + 1
2215  ER = oRangeAddress.EndRow # -1
2216 
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 %'
2224  formule = list()
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: # Computo - Variante
2229  genera_sommario()
2230  oRangeAddress.StartColumn = 19
2231  oRangeAddress.EndColumn = 22
2232 
2233  oSheet.getCellByPosition(23, 0).String = 'COMPUTO - VARIANTE'
2234  for n in range(4, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2):
2235  formule.append([
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) + ');"--")'
2247  ])
2248  n += 1
2249  oSheet.getCellByPosition(
2250  26, 1
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(
2253  26, ER
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(
2262  n) + ');"--")'
2263  oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2265  formule = tuple(formule)
2266  oRange.setFormulaArray(formule)
2267 
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
2274 
2275  oCellRangeAddr.StartColumn = 15
2276  oCellRangeAddr.EndColumn = 15
2277  oSheet.group(oCellRangeAddr, 0)
2278  oSheet.getCellRangeByPosition(15, 0, 15,
2279  0).Columns.IsVisible = False
2280 
2281 
2282  if oDialog1.getControl("ComCon").State: # Computo - Contabilità
2283  genera_sommario()
2284  oRangeAddress.StartColumn = 15
2285  oRangeAddress.EndColumn = 18
2286 
2287  oSheet.getCellByPosition(23,
2288  0).String = 'COMPUTO - CONTABILITÀ'
2289  for n in range(4, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2):
2290  formule.append([
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) + ');"--")'
2302  ])
2303  n += 1
2304  # for el in(1, ER+1):
2305  oSheet.getCellByPosition(
2306  26, 1
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(
2309  26, ER
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(
2318  n) + ');"--")'
2319  oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2321  formule = tuple(formule)
2322  oRange.setFormulaArray(formule)
2323 
2324  if oRangeAddress.StartColumn != 0:
2325  # evidenzia le quantità eccedenti il VI/I
2326  for el in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
2327  if oSheet.getCellByPosition(
2328  26,
2329  el).Value >= 0.2 or oSheet.getCellByPosition(
2330  26, el).String == '20,00%':
2331  oSheet.getCellRangeByPosition(
2332  0, el, 25, el).CellBackColor = 16777062
2333  # oCellRangeAddr=oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2334  if DLG.DlgSiNo(
2335  "Nascondo eventuali voci non ancora contabilizzate?"
2336  ) == 2:
2337  struttura_off()
2338  for el in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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
2345 
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
2356 
2357 
2358  if oDialog1.getControl(
2359  "VarCon").State: # Variante - Contabilità
2360  genera_sommario()
2361 
2362  oRangeAddress.StartColumn = 11
2363  oRangeAddress.EndColumn = 14
2364 
2365  oSheet.getCellByPosition(23,
2366  0).String = 'VARIANTE - CONTABILITÀ'
2367  for n in range(4, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2):
2368  formule.append([
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) + ');"--")'
2380  ])
2381  n += 1
2382  # for el in(1, ER+1):
2383  oSheet.getCellByPosition(
2384  26, 1
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(
2387  26, ER
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(
2396  n) + ');"--")'
2397  oRange = oSheet.getCellRangeByPosition(23, 3, 26,
2399  formule = tuple(formule)
2400  oRange.setFormulaArray(formule)
2401  # operazioni comuni
2402  for el in (11, 15, 19, 26):
2403  oSheet.getCellRangeByPosition(
2404  el, 3, el, LeenoSheetUtils.cercaUltimaVoce(oSheet)).CellStyle = 'EP-mezzo %'
2405  for el in (12, 16, 20, 23):
2406  oSheet.getCellRangeByPosition(
2407  el, 3, el,
2408  LeenoSheetUtils.cercaUltimaVoce(oSheet)).CellStyle = 'EP statistiche_q'
2409  for el in (13, 17, 21, 24, 25):
2410  oSheet.getCellRangeByPosition(
2411  el, 3, el,
2412  LeenoSheetUtils.cercaUltimaVoce(oSheet)).CellStyle = 'EP statistiche'
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
2422 
2423  oDoc.CurrentController.select(oSheet.getCellRangeByName('AA2'))
2424  # oDoc.CurrentController.select(oDoc.getSheets().getByName('S5').getCellRangeByName('B30'))
2425  comando('Copy')
2426  oDoc.CurrentController.select(
2427  oSheet.getCellRangeByPosition(26, 3, 26, ER))
2428  paste_format()
2429 
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!', '--')
2435  hide_error(errori, 26)
2436  oSheet.group(oRangeAddress, 0)
2437  oSheet.getCellRangeByPosition(oRangeAddress.StartColumn, 0,
2438  oRangeAddress.EndColumn,
2439  1).Columns.IsVisible = False
2440  _primaCella()
2441  else:
2442  return
2443  elif oSheet.Name in ('Analisi di Prezzo'):
2444  oDialog1 = dp.createDialog(
2445  "vnd.sun.star.script:UltimusFree2.DialogViste_AN?language=Basic&location=application"
2446  )
2447  # oDialog1Model = oDialog1.Model
2448  if not oSheet.getCellByPosition(1, 2).Rows.OptimalHeight:
2449  oDialog1.getControl("CBDesc").State = 1 # descrizione breve
2450 
2451  oS1 = oDoc.getSheets().getByName('S1')
2452  sString = oDialog1.getControl('TextField5')
2453  sString.Text = oS1.getCellRangeByName(
2454  'S1.H319').Value * 100 # sicurezza
2455  sString = oDialog1.getControl('TextField6')
2456  sString.Text = oS1.getCellRangeByName(
2457  'S1.H320').Value * 100 # spese_generali
2458  sString = oDialog1.getControl('TextField7')
2459  sString.Text = oS1.getCellRangeByName(
2460  'S1.H321').Value * 100 # utile_impresa
2461 
2462  # accorpa_spese_utili
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 # sconto
2467  sString = oDialog1.getControl('TextField9')
2468  sString.Text = oS1.getCellRangeByName(
2469  'S1.H326').Value * 100 # maggiorazione
2470 
2471  oDialog1.execute() # mostra il dialogo
2472 
2473  if(oSheet.getCellByPosition(1, 2).Rows.OptimalHeight and
2474  oDialog1.getControl("CBDesc").State == 1): # descrizione breve
2475  basic_LeenO('Strutture.Tronca_Altezza_Analisi')
2476  # elif oDialog1.getControl("CBDesc").State == 0: LeenoSheetUtils.adattaAltezzaRiga(oSheet)
2477 
2478  # sString.Text =oSheet.getCellRangeByName('S1.H321').Value * 100 #utile_impresa
2479  oS1.getCellRangeByName('S1.H319').Value = float(
2480  oDialog1.getControl('TextField5').getText().replace(
2481  ',', '.')) / 100 # sicurezza
2482  oS1.getCellRangeByName('S1.H320').Value = float(
2483  oDialog1.getControl('TextField6').getText().replace(
2484  ',', '.')) / 100 # spese generali
2485  oS1.getCellRangeByName('S1.H321').Value = float(
2486  oDialog1.getControl('TextField7').getText().replace(
2487  ',', '.')) / 100 # utile_impresa
2488  oS1.getCellRangeByName('S1.H323').Value = oDialog1.getControl(
2489  'CheckBox4').State
2490  oS1.getCellRangeByName('S1.H324').Value = float(
2491  oDialog1.getControl('TextField8').getText().replace(
2492  ',', '.')) / 100 # sconto
2493  oS1.getCellRangeByName('S1.H326').Value = float(
2494  oDialog1.getControl('TextField9').getText().replace(
2495  ',', '.')) / 100 # maggiorazione
2496 
2497  # accorpa_spese_utili
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 # sconto
2502  sString = oDialog1.getControl('TextField9')
2503  sString.Text = oS1.getCellRangeByName(
2504  'S1.H326').Value * 100 # maggiorazione
2505 
2506  elif oSheet.Name in ('CONTABILITA', 'Registro', 'SAL'):
2507  oDialog1 = dp.createDialog(
2508  "vnd.sun.star.script:UltimusFree2.Dialogviste_N?language=Basic&location=application"
2509  )
2510  if oSheet.getColumns().getByIndex(19).Columns.IsVisible:
2511  oDialog1.getControl('vista_pre').State = 1
2512  else:
2513  oDialog1.getControl('vista_sem').State = 1
2514  sString = oDialog1.getControl('TextField3')
2515  sString.Text = oDoc.getSheets().getByName('S1').getCellRangeByName(
2516  'H335').Value # cont_inizio_voci_abbreviate
2517  sString = oDialog1.getControl('TextField2')
2518  sString.Text = oDoc.getSheets().getByName('S1').getCellRangeByName(
2519  'H336').Value # cont_fine_voci_abbreviate
2520 
2521  # Contabilità abilita
2522  # ~if oSheet.getCellRangeByName('S1.H328').Value == 1:
2523  # ~oDialog1.getControl('CheckBox7').State = 1
2524  sString = oDialog1.getControl('TextField13')
2525  if cfg.read('Contabilita', 'idxsal') == '&273.Dlg_config.TextField13.Text':
2526  sString.Text = '20'
2527  else:
2528  sString.Text = cfg.read('Contabilita', 'idxsal')
2529  if sString.Text == '':
2530  sString.Text = '20'
2531  sString = oDialog1.getControl('ComboBox3')
2532  sString.Text = cfg.read('Contabilita', 'ricicla_da')
2533 
2534  # oDialog1Model = oDialog1.Model
2535  oDialog1.getControl('Dettaglio').State = cfg.read('Generale', 'dettaglio')
2536  oDialog1.execute()
2537 
2538  if oDialog1.getControl('vista_pre').State:
2540  if oDialog1.getControl('vista_sem').State:
2541  LeenoSheetUtils.setVisibilitaColonne(oSheet, 'TTTFFTTTTTFTFTFTFFFFFFFFFFFFFFFFFFFFF')
2542  # ~vista_terra_terra()
2543 
2544  # il salvataggio anche su leeno.conf serve alla funzione voce_breve()
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())
2548 
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())
2552 
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')
2556  else:
2557  cfg.write('Contabilita', 'ricicla_da', 'VARIANTE')
2558 
2559  if oDialog1.getControl('Dettaglio').State == 0:
2560  cfg.write('Generale', 'dettaglio', '0')
2561  dettaglio_misure(0)
2562  else:
2563  cfg.write('Generale', 'dettaglio', '1')
2564  dettaglio_misure(0)
2565  dettaglio_misure(1)
2566  # LeenoSheetUtils.adattaAltezzaRiga(oSheet)
2568  # ~oDoc.enableAutomaticCalculation(True)
2569  # MsgBox('Operazione eseguita con successo!','')
2570 
2571 
2572 
2573 
2574 
2576  '''
2577  Genera il foglio di VARIANTE a partire dal COMPUTO
2578  @@@ MODIFICA IN CORSO CON 'LeenoVariante.generaVariante'
2579  '''
2580  chiudi_dialoghi()
2581  oDoc = LeenoUtils.getDocument()
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')
2588  lrow = SheetUtils.getUsedArea(oSheet).EndRow
2589  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$AJ$3:$AJ$' + str(lrow), 'AA')
2590  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$N$3:$N$' + str(lrow), "BB")
2591  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$AK$3:$AK$' + str(lrow), "cEuro")
2592  oSheet = oDoc.getSheets().getByName('VARIANTE')
2593  GotoSheet('VARIANTE')
2594  setTabColor(16777062)
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
2599  if DLG.DlgSiNo(
2600  """Vuoi svuotare la VARIANTE appena generata?
2601 
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:
2606  lrow = SheetUtils.uFindStringCol('TOTALI COMPUTO', 2, oSheet) - 3
2607  oSheet.Rows.removeByIndex(3, lrow)
2608  _gotoCella(0, 2)
2610  oSheet = oDoc.getSheets().getByName('VARIANTE')
2612  # else:
2613  GotoSheet('VARIANTE')
2617 
2618 
2619 
2620 
2621 
2623  '''
2624  Genera i sommari in Elenco Prezzi
2625  '''
2626  struttura_off()
2627 
2628  oDoc = LeenoUtils.getDocument()
2629  oDoc.enableAutomaticCalculation(False)
2630  oSheet = oDoc.getSheets().getByName('COMPUTO')
2631  lrow = SheetUtils.getUsedArea(oSheet).EndRow
2632  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$AJ$3:$AJ$' + str(lrow), 'AA')
2633  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$N$3:$N$' + str(lrow), "BB")
2634  SheetUtils.NominaArea(oDoc, 'COMPUTO', '$AK$3:$AK$' + str(lrow), "cEuro")
2635 
2636  if oDoc.getSheets().hasByName('VARIANTE'):
2637  oSheet = oDoc.getSheets().getByName('VARIANTE')
2638  lrow = SheetUtils.getUsedArea(oSheet).EndRow
2639  SheetUtils.NominaArea(oDoc, 'VARIANTE', '$AJ$3:$AJ$' + str(lrow), 'varAA')
2640  SheetUtils.NominaArea(oDoc, 'VARIANTE', '$N$3:$N$' + str(lrow), "varBB")
2641  SheetUtils.NominaArea(oDoc, 'VARIANTE', '$AK$3:$AK$' + str(lrow), "varEuro")
2642 
2643  if oDoc.getSheets().hasByName('CONTABILITA'):
2644  oSheet = oDoc.getSheets().getByName('CONTABILITA')
2645  lrow = SheetUtils.getUsedArea(oSheet).EndRow
2646  lrow = SheetUtils.getUsedArea(
2647  oDoc.getSheets().getByName('CONTABILITA')).EndRow
2648  SheetUtils.NominaArea(oDoc, 'CONTABILITA', '$AJ$3:$AJ$' + str(lrow), 'GG')
2649  SheetUtils.NominaArea(oDoc, 'CONTABILITA', '$S$3:$S$' + str(lrow), "G1G1")
2650  SheetUtils.NominaArea(oDoc, 'CONTABILITA', '$AK$3:$AK$' + str(lrow), "conEuro")
2651 
2652  formule = list()
2653  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
2654 
2655  # attiva la progressbar
2656  progress = Dialogs.Progress(Title='Generazione dei sommari in corso...', Text="Lettura dati")
2657  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2)
2658  progress.setValue(0)
2659  progress.show()
2660 
2661  for n in range(4, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2):
2662  progress.setValue(n)
2663  stringa = ([
2664  '=N' + str(n) + '/$N$2', '=SUMIF(AA;A' + str(n) + ';BB)',
2665  '=SUMIF(AA;A' + str(n) + ';cEuro)', '', '', '', '', '', '', '', ''
2666  ])
2667  if oDoc.getSheets().hasByName('VARIANTE'):
2668  stringa = ([
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)', '', '', '', ''
2673  ])
2674  if oDoc.getSheets().hasByName('CONTABILITA'):
2675  stringa = ([
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)'
2683  ])
2684  elif oDoc.getSheets().hasByName('CONTABILITA'):
2685  stringa = ([
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)'
2690  ])
2691  formule.append(stringa)
2692  oRange = oSheet.getCellRangeByPosition(11, 3, 21, LeenoSheetUtils.cercaUltimaVoce(oSheet))
2693  formule = tuple(formule)
2694  oRange.setFormulaArray(formule)
2695 
2696  oDoc.enableAutomaticCalculation(True)
2698  progress.hide()
2699 
2700 
2701 
2702 
2704  '''
2705  Riordina l'Elenco Prezzi secondo l'ordine alfabetico dei codici di prezzo
2706  '''
2707  oDoc = LeenoUtils.getDocument()
2708  oDoc.enableAutomaticCalculation(False)
2709  riordina_ElencoPrezzi(oDoc)
2710  oDoc.enableAutomaticCalculation(True)
2711 
2712 
2714  '''
2715  Riordina l'Elenco Prezzi secondo l'ordine alfabetico dei codici di prezzo
2716  '''
2717  #chiudi_dialoghi()
2718  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
2719  if SheetUtils.uFindStringCol('Fine elenco', 0, oSheet) is None:
2721  test = str(SheetUtils.uFindStringCol('Fine elenco', 0, oSheet) +1)
2722  SheetUtils.NominaArea(oDoc, 'Elenco Prezzi', "$A$3:$AF$" + test, 'elenco_prezzi')
2723  SheetUtils.NominaArea(oDoc, 'Elenco Prezzi', "$A$3:$A$" + test, 'Lista')
2724  oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2725  SR = oRangeAddress.StartRow + 1
2726  SC = 0 #oRangeAddress.StartColumn
2727  EC = oRangeAddress.EndColumn
2728  SR = oRangeAddress.StartRow + 1
2729  ER = oRangeAddress.EndRow -1
2730  if SR == ER:
2731  return
2732 
2733  oRange = oSheet.getCellRangeByPosition(SC, SR, EC, ER)
2734  SheetUtils.simpleSortColumn(oRange, 0, True)
2735 
2736 
2737 
2738 
2739 
2741  # ~EliminaVociDoppieElencoPrezzi()
2743 
2744 
2746  oDoc = LeenoUtils.getDocument()
2747  '''
2748  Cancella eventuali voci che si ripetono in Elenco Prezzi
2749  '''
2751  if oDoc.getSheets().hasByName('Analisi di Prezzo'):
2752  lista_tariffe_analisi = list()
2753  oSheet = oDoc.getSheets().getByName('Analisi di Prezzo')
2754  for n in range(0, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1):
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')
2759 
2760  SR = 0
2761  ER = SheetUtils.getUsedArea(oSheet).EndRow
2762 
2763  try:
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)
2768  except Exception:
2769  pass
2770  oRangeAddress = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
2771  SR = oRangeAddress.StartRow + 1
2772  ER = oRangeAddress.EndRow - 1
2773  if ER < SR:
2774  return
2775  oRange = oSheet.getCellRangeByPosition(0, SR, 7, ER)
2776  lista_come_array = tuple(set(oRange.getDataArray()))
2777  # ~chi ([len(lista_come_array),(lista_come_array)])
2778  # ~return
2779  oSheet.getRows().removeByIndex(SR, ER - SR + 1)
2780  lista_tar = list()
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]
2785  ) # numero di colonne necessarie per ospitare i dati
2786  righe_lista = len(
2787  lista_come_array) # numero di righe necessarie per ospitare i dati
2788  oRange = oSheet.getCellRangeByPosition(
2789  0,
2790  3,
2791  colonne_lista + 0 - 1, # l'indice parte da 0
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"
2804 
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'
2811  # ~oDoc.CurrentController.select(
2812  # ~oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) # unselect
2813  if oDoc.getSheets().hasByName('Analisi di Prezzo'):
2815 
2816  oDoc.enableAutomaticCalculation(True)
2818  riordina_ElencoPrezzi(oDoc)
2820 
2821  if len(set(lista_tar)) != len(set(lista_come_array)):
2822  Dialogs.Exclamation(Title = 'ATTENZIONE!',
2823  Text='''Ci sono ancora 2 o più voci che hanno
2824 lo stesso Codice Articolo pur essendo diverse.''')
2825  # ~DLG.MsgBox(
2826  # ~'Ci sono ancora 2 o più voci che hanno lo stesso Codice Articolo pur essendo diverse.',
2827  # ~'C o n t r o l l a!')
2828 
2829 
2830 
2832 def XPWE_out(elaborato, out_file):
2833  '''
2834  esporta il documento in formato XPWE
2835 
2836  elaborato { string } : nome del foglio da esportare
2837  out_file { string } : nome base del file
2838 
2839  il nome file risulterà out_file-elaborato.xpwe
2840  '''
2842  # attiva la progressbar
2843  progress = Dialogs.Progress(Title='Esportazione di ' + elaborato + ' in corso...', Text="Lettura dati")
2844  progress.setLimits(0, 7)
2845  progress.setValue(0)
2846  progress.show()
2847 
2848  oDoc = LeenoUtils.getDocument()
2849  # ~oDoc.enableAutomaticCalculation(False)
2850  if cfg.read('Generale', 'dettaglio') == '1':
2851  dettaglio_misure(0)
2852  numera_voci(1)
2853  top = Element('PweDocumento')
2854  # intestazioni
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')
2862  Versione.text = ''
2863  SourceVersione = SubElement(top, 'SourceVersione')
2864 
2865  release = (
2866  str(LeenoUtils.getGlobalVar('Lmajor')) + '.' +
2867  str(LeenoUtils.getGlobalVar('Lminor')) + '.' +
2868  LeenoUtils.getGlobalVar('Lsubv')
2869  )
2870 
2871  SourceVersione.text = release
2872  SourceNome = SubElement(top, 'SourceNome')
2873  SourceNome.text = 'LeenO.org'
2874  FileNameDocumento = SubElement(top, 'FileNameDocumento')
2875  # dati generali
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'
2882 
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')
2889  # leggo i dati generali
2890  oSheet = oDoc.getSheets().getByName('S2')
2891  Comune.text = oSheet.getCellByPosition(2, 3).String
2892  Provincia.text = ''
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 = ''
2897  # Capitoli e Categorie
2898  PweDGCapitoliCategorie = SubElement(PweDatiGenerali,
2899  'PweDGCapitoliCategorie')
2900  # SuperCategorie
2901  oSheet = oDoc.getSheets().getByName(elaborato)
2902  lastRow = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
2903  # evito di esportare in SuperCategorie perché inutile, almeno per ora
2904  listaspcat = list()
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)
2914 
2915  # PweDGSuperCategorie = SubElement(PweDGCapitoliCategorie,'PweDGSuperCategorie')
2916  DGSuperCategorieItem = SubElement(PweDGSuperCategorie,
2917  'DGSuperCategorieItem')
2918  DesSintetica = SubElement(DGSuperCategorieItem, 'DesSintetica')
2919 
2920  DesEstesa = SubElement(DGSuperCategorieItem, 'DesEstesa')
2921  DataInit = SubElement(DGSuperCategorieItem, 'DataInit')
2922  Durata = SubElement(DGSuperCategorieItem, 'Durata')
2923  # CodFase = SubElement(DGSuperCategorieItem, 'CodFase')
2924  Percentuale = SubElement(DGSuperCategorieItem, 'Percentuale')
2925  # Codice = SubElement(DGSuperCategorieItem, 'Codice')
2926 
2927  DGSuperCategorieItem.set('ID', idID)
2928  DesSintetica.text = desc
2929  DataInit.text = oggi()
2930  Durata.text = '0'
2931  Percentuale.text = '0'
2932 
2933 # Categorie
2934  listaCat = list()
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)
2944 
2945  # PweDGCategorie = SubElement(PweDGCapitoliCategorie,'PweDGCategorie')
2946  DGCategorieItem = SubElement(PweDGCategorie, 'DGCategorieItem')
2947  DesSintetica = SubElement(DGCategorieItem, 'DesSintetica')
2948 
2949  DesEstesa = SubElement(DGCategorieItem, 'DesEstesa')
2950  DataInit = SubElement(DGCategorieItem, 'DataInit')
2951  Durata = SubElement(DGCategorieItem, 'Durata')
2952  # CodFase = SubElement(DGCategorieItem, 'CodFase')
2953  Percentuale = SubElement(DGCategorieItem, 'Percentuale')
2954  # Codice = SubElement(DGCategorieItem, 'Codice')
2955 
2956  DGCategorieItem.set('ID', idID)
2957  DesSintetica.text = desc
2958  DataInit.text = oggi()
2959  Durata.text = '0'
2960  Percentuale.text = '0'
2961 
2962 # SubCategorie
2963  listasbCat = list()
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)
2972 
2973  # PweDGSubCategorie = SubElement(PweDGCapitoliCategorie,'PweDGSubCategorie')
2974  DGSubCategorieItem = SubElement(PweDGSubCategorie,
2975  'DGSubCategorieItem')
2976  DesSintetica = SubElement(DGSubCategorieItem, 'DesSintetica')
2977 
2978  DesEstesa = SubElement(DGSubCategorieItem, 'DesEstesa')
2979  DataInit = SubElement(DGSubCategorieItem, 'DataInit')
2980  Durata = SubElement(DGSubCategorieItem, 'Durata')
2981  # CodFase = SubElement(DGSubCategorieItem, 'CodFase')
2982  Percentuale = SubElement(DGSubCategorieItem, 'Percentuale')
2983  # Codice = SubElement(DGSubCategorieItem, 'Codice')
2984 
2985  DGSubCategorieItem.set('ID', idID)
2986  DesSintetica.text = desc
2987  DataInit.text = oggi()
2988  Durata.text = '0'
2989  Percentuale.text = '0'
2990 
2991 # Moduli
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')
2998  # ConfQuantita = SubElement(PweDGAnalisi, 'ConfQuantita')
2999 
3000  oSheet = oDoc.getSheets().getByName('S1')
3001  if oSheet.getCellByPosition(
3002  7, 322).Value == 0: # se 0: Spese e Utili Accorpati
3003  SpeseUtili.text = '1'
3004  else:
3005  SpeseUtili.text = '-1'
3006 
3007  UtiliImpresa.text = oSheet.getCellByPosition(7, 320).String[:-1].replace(
3008  ',', '.')
3009  OneriAccessoriSc.text = oSheet.getCellByPosition(7,
3010  318).String[:-1].replace(
3011  ',', '.')
3012  SpeseGenerali.text = oSheet.getCellByPosition(7, 319).String[:-1].replace(
3013  ',', '.')
3014 
3015  # Configurazioni
3016  PU = str(len(LeenoFormat.getFormatString('comp 1-a PU').split(',')[-1]))
3017  LUN = str(len(LeenoFormat.getFormatString('comp 1-a LUNG').split(',')[-1]))
3018  LAR = str(len(LeenoFormat.getFormatString('comp 1-a LARG').split(',')[-1]))
3019  PES = str(len(LeenoFormat.getFormatString('comp 1-a peso').split(',')[-1]))
3020  QUA = str(len(LeenoFormat.getFormatString('Blu').split(',')[-1]))
3021  PR = str(len(LeenoFormat.getFormatString('comp sotto Unitario').split(',')[-1]))
3022  TOT = str(len(LeenoFormat.getFormatString('An-1v-dx').split(',')[-1]))
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')
3032  Cambio.text = '1'
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'
3056 
3057 # Elenco Prezzi
3058  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
3059  PweElencoPrezzi = SubElement(PweMisurazioni, 'PweElencoPrezzi')
3060  diz_ep = dict()
3061  lista_AP = list()
3062  progress.setValue(4)
3063  listaspcap = list()
3064  listacap = list()
3065  listasbcap = list()
3066  # giallo(16777072,16777120,16777168)
3067  for n in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
3068 
3069  # SuperCapitoli
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)
3077 
3078  PweDGSuperCapitoli = SubElement(PweDGCapitoliCategorie,'PweDGSuperCapitoli')
3079  DGSuperCapitoliItem = SubElement(PweDGSuperCapitoli,
3080  'DGSuperCapitoliItem')
3081  DesSintetica = SubElement(DGSuperCapitoliItem, 'DesSintetica')
3082 
3083  DesEstesa = SubElement(DGSuperCapitoliItem, 'DesEstesa')
3084  DataInit = SubElement(DGSuperCapitoliItem, 'DataInit')
3085  Durata = SubElement(DGSuperCapitoliItem, 'Durata')
3086  # CodFase = SubElement(DGSuperCapitoliItem, 'CodFase')
3087  Percentuale = SubElement(DGSuperCapitoliItem, 'Percentuale')
3088  Codice = SubElement(DGSuperCapitoliItem, 'Codice')
3089 
3090  DGSuperCapitoliItem.set('ID', IDSpCap)
3091  DesSintetica.text = desc
3092  Codice.text = cod
3093  DataInit.text = '' #oggi()
3094  Durata.text = '0'
3095  Percentuale.text = '0'
3096 
3097  # Capitoli
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)
3104 
3105  PweDGCapitoli = SubElement(PweDGCapitoliCategorie,'PweDGCapitoli')
3106  DGCapitoliItem = SubElement(PweDGCapitoli,
3107  'DGCapitoliItem')
3108  DesSintetica = SubElement(DGCapitoliItem, 'DesSintetica')
3109 
3110  DesEstesa = SubElement(DGCapitoliItem, 'DesEstesa')
3111  DataInit = SubElement(DGCapitoliItem, 'DataInit')
3112  Durata = SubElement(DGCapitoliItem, 'Durata')
3113  # CodFase = SubElement(DGCapitoliItem, 'CodFase')
3114  Percentuale = SubElement(DGCapitoliItem, 'Percentuale')
3115  Codice = SubElement(DGCapitoliItem, 'Codice')
3116 
3117  DGCapitoliItem.set('ID', IDCap)
3118  DesSintetica.text = desc
3119  Codice.text = cod
3120  DataInit.text = '' #oggi()
3121  Durata.text = '0'
3122  Percentuale.text = '0'
3123 
3124  # SubCapitoli
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)
3131 
3132  PweDGSubCapitoli = SubElement(PweDGCapitoliCategorie,'PweDGSubCapitoli')
3133  DGSubCapitoliItem = SubElement(PweDGSubCapitoli,
3134  'DGSubCapitoliItem')
3135  DesSintetica = SubElement(DGSubCapitoliItem, 'DesSintetica')
3136 
3137  DesEstesa = SubElement(DGSubCapitoliItem, 'DesEstesa')
3138  DataInit = SubElement(DGSubCapitoliItem, 'DataInit')
3139  Durata = SubElement(DGSubCapitoliItem, 'Durata')
3140  # CodFase = SubElement(DGSubCapitoliItem, 'CodFase')
3141  Percentuale = SubElement(DGSubCapitoliItem, 'Percentuale')
3142  Codice = SubElement(DGSubCapitoliItem, 'Codice')
3143 
3144  DGSubCapitoliItem.set('ID', IDSbCap)
3145  DesSintetica.text = desc
3146  Codice.text = cod
3147  DataInit.text = '' #oggi()
3148  Durata.text = '0'
3149  Percentuale.text = '0'
3150 
3151 
3152  #voci di prezzo
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')
3161  TipoEP.text = '0'
3162  Tariffa = SubElement(EPItem, 'Tariffa')
3163  id_tar = str(n)
3164  Tariffa.text = oSheet.getCellByPosition(0, n).String
3165  diz_ep[oSheet.getCellByPosition(0, n).String] = id_tar
3166  Articolo = SubElement(EPItem, 'Articolo')
3167  Articolo.text = ''
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[
3174  -60:]
3175  else:
3176  DesRidotta.text = DesEstesa.text
3177  DesBreve = SubElement(EPItem, 'DesBreve')
3178  if len(DesEstesa.text) > 60:
3179  DesBreve.text = DesEstesa.text[:30] + ' ... ' + DesEstesa.text[
3180  -30:]
3181  else:
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')
3188  Prezzo2.text = '0'
3189  Prezzo3 = SubElement(EPItem, 'Prezzo3')
3190  Prezzo3.text = '0'
3191  Prezzo4 = SubElement(EPItem, 'Prezzo4')
3192  Prezzo4.text = '0'
3193  Prezzo5 = SubElement(EPItem, 'Prezzo5')
3194  Prezzo5.text = '0'
3195 
3196  try:
3197  SubElement(EPItem, 'IDSpCap').text = IDSpCap
3198  except:
3199  SubElement(EPItem, 'IDSpCap').text = '0'
3200  try:
3201  SubElement(EPItem, 'IDCap').text = IDCap
3202  except:
3203  SubElement(EPItem, 'IDCap').text = '0'
3204  try:
3205  SubElement(EPItem, 'IDSbCap').text = IDSbCap
3206  except:
3207  SubElement(EPItem, 'IDSbCap').text = '0'
3208 
3209  Flags = SubElement(EPItem, 'Flags')
3210  if oSheet.getCellByPosition(8, n).String == '(AP)':
3211  Flags.text = '131072'
3212  else:
3213  Flags.text = '0'
3214  Data = SubElement(EPItem, 'Data')
3215  Data.text = '30/12/1899'
3216  AdrInternet = SubElement(EPItem, 'AdrInternet')
3217  AdrInternet.text = ''
3218  PweEPAnalisi = SubElement(EPItem, 'PweEPAnalisi')
3219 
3220  IncSIC = SubElement(EPItem, 'IncSIC')
3221  if oSheet.getCellByPosition(3, n).Value == 0.0:
3222  IncSIC.text = ''
3223  else:
3224  IncSIC.text = str(oSheet.getCellByPosition(3, n).Value * 100)
3225 
3226  IncMDO = SubElement(EPItem, 'IncMDO')
3227  if oSheet.getCellByPosition(5, n).Value == 0.0:
3228  IncMDO.text = ''
3229  else:
3230  IncMDO.text = str(oSheet.getCellByPosition(5, n).Value * 100)
3231 
3232  IncMAT = SubElement(EPItem, 'IncMAT')
3233  if oSheet.getCellByPosition(6, n).Value == 0.0:
3234  IncMAT.text = ''
3235  else:
3236  IncMAT.text = str(oSheet.getCellByPosition(6, n).Value * 100)
3237 
3238  IncATTR = SubElement(EPItem, 'IncATTR')
3239  if oSheet.getCellByPosition(7, n).Value == 0.0:
3240  IncATTR.text = ''
3241  else:
3242  IncATTR.text = str(oSheet.getCellByPosition(7, n).Value * 100)
3243 
3244  # Analisi di prezzo
3245  progress.setValue(5)
3246  if len(lista_AP) != 0:
3247  oSheet = oDoc.getSheets().getByName('Analisi di Prezzo')
3248  k = n + 1
3249  for el in lista_AP:
3250  try:
3251  m = SheetUtils.uFindStringCol(el, 0, oSheet)
3252  EPItem = SubElement(PweElencoPrezzi, 'EPItem')
3253  EPItem.set('ID', str(k))
3254  TipoEP = SubElement(EPItem, 'TipoEP')
3255  TipoEP.text = '0'
3256  Tariffa = SubElement(EPItem, 'Tariffa')
3257  id_tar = str(k)
3258  Tariffa.text = oSheet.getCellByPosition(0, m).String
3259  diz_ep[oSheet.getCellByPosition(0, m).String] = id_tar
3260  Articolo = SubElement(EPItem, 'Articolo')
3261  Articolo.text = ''
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[
3268  -60:]
3269  else:
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[
3275  -30:]
3276  else:
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')
3283  Prezzo2.text = '0'
3284  Prezzo3 = SubElement(EPItem, 'Prezzo3')
3285  Prezzo3.text = '0'
3286  Prezzo4 = SubElement(EPItem, 'Prezzo4')
3287  Prezzo4.text = '0'
3288  Prezzo5 = SubElement(EPItem, 'Prezzo5')
3289  Prezzo5.text = '0'
3290  IDSpCap = SubElement(EPItem, 'IDSpCap')
3291  IDSpCap.text = '0'
3292  IDCap = SubElement(EPItem, 'IDCap')
3293  IDCap.text = '0'
3294  IDSbCap = SubElement(EPItem, 'IDSbCap')
3295  IDSbCap.text = '0'
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')
3304  nEPARItem = 2
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))
3310  nEPARItem += 1
3311  Tipo = SubElement(EPARItem, 'Tipo')
3312  Tipo.text = '0'
3313  IDEP = SubElement(EPARItem, 'IDEP')
3314  IDEP.text = diz_ep.get(
3315  oSheet.getCellByPosition(0, x).String)
3316  if IDEP.text is None:
3317  IDEP.text = '-2'
3318  Descrizione = SubElement(EPARItem, 'Descrizione')
3319  if '=IF(' in oSheet.getCellByPosition(1, x).String:
3320  Descrizione.text = ''
3321  else:
3322  Descrizione.text = oSheet.getCellByPosition(
3323  1, x).String
3324  Misura = SubElement(EPARItem, 'Misura')
3325  Misura.text = ''
3326  Qt = SubElement(EPARItem, 'Qt')
3327  Qt.text = ''
3328  Prezzo = SubElement(EPARItem, 'Prezzo')
3329  Prezzo.text = ''
3330  FieldCTL = SubElement(EPARItem, 'FieldCTL')
3331  FieldCTL.text = '0'
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))
3336  nEPARItem += 1
3337  Tipo = SubElement(EPARItem, 'Tipo')
3338  Tipo.text = '1'
3339  IDEP = SubElement(EPARItem, 'IDEP')
3340  IDEP.text = diz_ep.get(
3341  oSheet.getCellByPosition(0, x).String)
3342  if IDEP.text is None:
3343  IDEP.text = '-2'
3344  Descrizione = SubElement(EPARItem, 'Descrizione')
3345  if '=IF(' in oSheet.getCellByPosition(1, x).String:
3346  Descrizione.text = ''
3347  else:
3348  Descrizione.text = oSheet.getCellByPosition(
3349  1, x).String
3350  Misura = SubElement(EPARItem, 'Misura')
3351  Misura.text = oSheet.getCellByPosition(2, x).String
3352  Qt = SubElement(EPARItem, 'Qt')
3353  Qt.text = oSheet.getCellByPosition(3,
3354  x).String.replace(
3355  ',', '.')
3356  Prezzo = SubElement(EPARItem, 'Prezzo')
3357  Prezzo.text = str(
3358  oSheet.getCellByPosition(4, x).Value).replace(
3359  ',', '.')
3360  FieldCTL = SubElement(EPARItem, 'FieldCTL')
3361  FieldCTL.text = '0'
3362  elif oSheet.getCellByPosition(
3363  0, x).CellStyle == 'An-sfondo-basso Att End':
3364  break
3365 
3366  IncSIC = SubElement(EPItem, 'IncSIC')
3367  if oSheet.getCellByPosition(10, n).Value == 0.0:
3368  IncSIC.text = ''
3369  else:
3370  IncSIC.text = str(oSheet.getCellByPosition(10, n).Value)
3371 
3372  IncMDO = SubElement(EPItem, 'IncMDO')
3373  if oSheet.getCellByPosition(8, n).Value == 0.0:
3374  IncMDO.text = ''
3375  else:
3376  IncMDO.text = str(
3377  oSheet.getCellByPosition(5, n).Value * 100)
3378  k += 1
3379  except Exception:
3380  pass
3381 
3382  if elaborato == 'Elenco_Prezzi':
3383  pass
3384  else:
3385  # COMPUTO/VARIANTE/CONTABILITA
3386  oSheet = oDoc.getSheets().getByName(elaborato)
3387  PweVociComputo = SubElement(PweMisurazioni, 'PweVociComputo')
3388  oDoc.CurrentController.setActiveSheet(oSheet)
3389  Rinumera_TUTTI_Capitoli2(oSheet)
3390  nVCItem = 2
3391  progress.setValue(6)
3392  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))
3393  for n in range(0, LeenoSheetUtils.cercaUltimaVoce(oSheet)):
3394  progress.setValue(n)
3395  if oSheet.getCellByPosition(0,
3396  n).CellStyle in ('Comp Start Attributo',
3397  'Comp Start Attributo_R'):
3398  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, n)
3399  sStRange.RangeAddress
3400  sopra = sStRange.RangeAddress.StartRow
3401  sotto = sStRange.RangeAddress.EndRow
3402  if elaborato == 'CONTABILITA':
3403  sotto -= 1
3404  VCItem = SubElement(PweVociComputo, 'VCItem')
3405  VCItem.set('ID', str(nVCItem))
3406  nVCItem += 1
3407 
3408  IDEP = SubElement(VCItem, 'IDEP')
3409  IDEP.text = diz_ep.get(
3410  oSheet.getCellByPosition(1, sopra + 1).String)
3411 
3412  Quantita = SubElement(VCItem, 'Quantita')
3413  Quantita.text = oSheet.getCellByPosition(9, sotto).String
3414 
3415  DataMis = SubElement(VCItem, 'DataMis')
3416  if elaborato == 'CONTABILITA':
3417  DataMis.text = oSheet.getCellByPosition(1, sopra + 2).String
3418  else:
3419  DataMis.text = oggi() # 26/12/1952'#'28/09/2013'###
3420  vFlags = SubElement(VCItem, 'Flags')
3421  vFlags.text = '0'
3422 
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 == '':
3428  IDSpCat.text = '0'
3429  # #########################
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 == '':
3435  IDCat.text = '0'
3436  # #########################
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 == '':
3442  IDSbCat.text = '0'
3443  # #########################
3444  PweVCMisure = SubElement(VCItem, 'PweVCMisure')
3445  x = 2
3446  for m in range(sopra + 2, sotto):
3447  RGItem = SubElement(PweVCMisure, 'RGItem')
3448  RGItem.set('ID', str(x))
3449  x += 1
3450  # #########################
3451  IDVV = SubElement(RGItem, 'IDVV')
3452  IDVV.text = '-2'
3453 
3454  Descrizione = SubElement(RGItem, 'Descrizione')
3455  Descrizione.text = oSheet.getCellByPosition(2, m).String
3456  # #########################
3457  PartiUguali = SubElement(RGItem, 'PartiUguali')
3458  PartiUguali.text = valuta_cella(oSheet.getCellByPosition(5, m))
3459  # #########################
3460  Lunghezza = SubElement(RGItem, 'Lunghezza')
3461  Lunghezza.text = valuta_cella(oSheet.getCellByPosition(6, m))
3462  # #########################
3463  Larghezza = SubElement(RGItem, 'Larghezza')
3464  Larghezza.text = valuta_cella(oSheet.getCellByPosition(7, m))
3465  # #########################
3466  HPeso = SubElement(RGItem, 'HPeso')
3467  HPeso.text = valuta_cella(oSheet.getCellByPosition(8, m))
3468  # #########################
3469  Quantita = SubElement(RGItem, 'Quantita')
3470  Quantita.text = str(oSheet.getCellByPosition(9, m).Value)
3471  # se negativa in CONTABILITA:
3472  # quando vedi_voce guarda ad un valore negativo
3473  if oSheet.getCellByPosition(4, m).Value < 0:
3474  test = True
3475  if elaborato == 'CONTABILITA':
3476  if oSheet.getCellByPosition(11, m).Value != 0:
3477  Quantita.text = '-' + str(oSheet.getCellByPosition(11, m).Value)
3478  # #########################
3479  Flags = SubElement(RGItem, 'Flags')
3480  if '*** VOCE AZZERATA ***' in Descrizione.text:
3481  PartiUguali.text = str(
3482  abs(float(valuta_cella(oSheet.getCellByPosition(5,
3483  m)))))
3484  Flags.text = '1'
3485  elif '-' in Quantita.text or oSheet.getCellByPosition(
3486  11, m).Value != 0:
3487  Flags.text = '1'
3488  elif "Parziale [" in oSheet.getCellByPosition(8, m).String:
3489  Flags.text = '2'
3490  HPeso.text = ''
3491  elif 'PARTITA IN CONTO PROVVISORIO' in Descrizione.text:
3492  Flags.text = '16'
3493  else:
3494  Flags.text = '0'
3495  # #########################
3496  if 'DETRAE LA PARTITA IN CONTO PROVVISORIO' in Descrizione.text:
3497  Flags.text = '32'
3498  if '- vedi voce n.' in Descrizione.text:
3499  IDVV.text = str(
3500  int(
3501  Descrizione.text.split('- vedi voce n.')[1].split(
3502  ' ')[0]) + 1)
3503  Flags.text = '32768'
3504  Descrizione.text = ''
3505  # PartiUguali.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'
3515  n = sotto + 1
3516  # #########################
3517  # ~out_file = Dialogs.FileSelect('Salva con nome...', '*.xpwe', 1)
3518  # ~out_file = uno.fileUrlToSystemPath(oDoc.getURL())
3519  # ~DLG.mri (uno.fileUrlToSystemPath(oDoc.getURL()))
3520  # ~chi(out_file)
3521  if cfg.read('Generale', 'dettaglio') == '1':
3522  dettaglio_misure(1)
3523  try:
3524  if out_file.split('.')[-1].upper() != 'XPWE':
3525  out_file = out_file + '-' + elaborato + '.xpwe'
3526  FileNameDocumento.text = out_file
3527  except AttributeError:
3528  return
3529  riga = str(tostring(top, encoding="unicode"))
3530  # if len(lista_AP) != 0:
3531  # riga = riga.replace('<PweDatiGenerali>','<Fgs>131072</Fgs><PweDatiGenerali>')
3532  progress.hide()
3533  try:
3534  of = codecs.open(out_file, 'w', 'utf-8')
3535  of.write(riga)
3536  of.close()
3537  # ~MsgBox('Esportazione in formato XPWE eseguita con successo\nsul file ' + out_file + '!','Avviso.')
3538  except Exception:
3539  Dialogs.Exclamation(Title = 'E R R O R E !',
3540  Text=''' Esportazione non eseguita!
3541 Verifica che il file di destinazione non sia già in uso!''')
3542  # ~DLG.MsgBox(
3543  # ~'Esportazione non eseguita!\n\nVerifica che il file di destinazione non sia già in uso!',
3544  # ~'E R R O R E !')
3545 
3547 
3548 
3549 
3550 def MENU_firme_in_calce(lrowF=None):
3551  '''
3552  Inserisce(in COMPUTO o VARIANTE) un riepilogo delle categorie
3553  ed i dati necessari alle firme
3554  '''
3556  oDoc = LeenoUtils.getDocument()
3557  oSheet = oDoc.CurrentController.ActiveSheet
3558  oSheet_S2 = oDoc.getSheets().getByName('S2')
3559 
3560  datafirme = oSheet_S2.getCellRangeByName('$S2.C4').String
3561 
3562  if datafirme == "":
3563  datafirme="Data,"
3564  else:
3565  datafirme = datafirme + ", "
3566  if oSheet.Name == "CONTABILITA":
3567  if lrowF == None:
3568  lrowF = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
3569  oSheet.getRows().insertByIndex(lrowF, 11)
3570  riga_corrente = lrowF + 1
3571 
3572  # INSERISCI LA DATA E IL PROGETTISTA
3573  # ~DLG.chi(datafirme)
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 + ")")
3582  comando('CalculateHard')
3583 # ~rem CONSOLIDA LA DATA
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"):
3588  if lrowF == None:
3589  lrowF = SheetUtils.getLastUsedRow(oSheet)
3590 
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"))'
3594  comando('CalculateHard')
3595  oRange = oSheet.getCellRangeByPosition (1, riga_corrente, 40, riga_corrente)
3596  aSaveData = oRange.getDataArray()
3597  oRange.setDataArray(aSaveData)
3598 
3599  oSheet.getCellByPosition(1, riga_corrente + 2).Formula = (
3600  "L'Impresa esecutrice\n(" + oSheet_S2.getCellRangeByName(
3601  '$S2.C17').String + ")")
3602 
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":
3608  return
3609  nSal = 1
3610  for i in reversed(range(2, 50)):
3611  if oDoc.NamedRanges.hasByName("_Lib_" + str(i)):
3612  nSal = i
3613  break
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 €")')
3616  comando('CalculateHard')
3617 
3618  oRange = oSheet.getCellRangeByPosition (1, riga_corrente + 10, 40, riga_corrente + 10)
3619 
3620  aSaveData = oRange.getDataArray()
3621  oRange.setDataArray(aSaveData)
3622 
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'):
3627  if lrowF == None:
3628  lrowF = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
3629  oDoc.CurrentController.setFirstVisibleRow(lrowF - 1)
3630  lrowE = SheetUtils.getUsedArea(oSheet).EndRow
3631  for i in range(lrowF, SheetUtils.getUsedArea(oSheet).EndRow + 1):
3632  if oSheet.getCellByPosition(0, i).CellStyle == "Riga_rossa_Chiudi":
3633  lrowE = i
3634  break
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"
3643  # raggruppo i righi di mirura
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)
3653 
3654  # INSERISCI LA DATA E IL PROGETTISTA
3655  oSheet.getCellByPosition(
3656  1, riga_corrente +
3657  3).Formula = '=CONCATENATE("Data, ";TEXT(NOW();"GG/MM/AAAA"))'
3658  comando('CalculateHard')
3659  # consolido il risultato
3660  oRange = oSheet.getCellByPosition(1, riga_corrente + 3)
3661  # flags = (oDoc.createInstance('com.sun.star.sheet.CellFlags.FORMULA'))
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)' # senza concatenate, se la cella di origine è vuota il risultato è '0,00'
3671 
3672  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CompuM_NoP'):
3673  if lrowF == None:
3674  lrowF = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
3675  oDoc.CurrentController.setFirstVisibleRow(lrowF - 2)
3676  lrowE = SheetUtils.getUsedArea(oSheet).EndRow
3677  for i in range(lrowF, SheetUtils.getUsedArea(oSheet).EndRow + 1):
3678  if oSheet.getCellByPosition(0, i).CellStyle == "Riga_rossa_Chiudi":
3679  lrowE = i
3680  break
3681  if lrowE > lrowF + 1:
3682  oSheet.getRows().removeByIndex(lrowF, lrowE - lrowF)
3683  riga_corrente = lrowF + 2
3684  if oDoc.getSheets().hasByName('S2'):
3685  ii = 11
3686  vv = 18
3687  ac = 28
3688  ad = 29
3689  ae = 30
3690  ss = 41
3691  col = 'S'
3692 
3693  else:
3694  ii = 8
3695  vv = 9
3696  ss = 9
3697  col = 'J'
3698  oSheet.getRows().insertByIndex(lrowF, 17)
3699  oSheet.getCellRangeByPosition(0, lrowF, ss,
3700  lrowF + 17 - 1).CellStyle = 'ULTIMUS'
3701  # raggruppo i righi di mirura
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)
3711 
3712  # INSERIMENTO TITOLO
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
3722  riga_corrente += 1
3723 
3724  # attiva la progressbar
3725  progress = Dialogs.Progress(Title='Esecuzione in corso...', Text="Composizione del riepilogo strutturale.")
3726  i = 0
3727  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))
3728  progress.setValue(i)
3729  progress.show()
3730  for i in range(0, lrowF):
3731  progress.setValue(i)
3732 
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)
3762  riga_corrente += 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)
3792  riga_corrente += 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)
3821  riga_corrente += 1
3822  progress.hide()
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'
3845  # fine_gruppo = riga_corrente
3846  # DATA
3847  oSheet.getCellByPosition(
3848  2, riga_corrente +
3849  3).Formula = '=CONCATENATE("Data, ";TEXT(NOW();"GG/MM/AAAA"))'
3850  # consolido il risultato
3851  oRange = oSheet.getCellByPosition(2, riga_corrente + 3)
3852  # flags = (oDoc.createInstance('com.sun.star.sheet.CellFlags.FORMULA'))
3853  comando('CalculateHard')
3854  aSaveData = oRange.getDataArray()
3855  oRange.setDataArray(aSaveData)
3856 
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)' # senza concatenate, se la cella di origine è vuota il risultato è '0,00'
3862  oSheet.getCellRangeByPosition(2, riga_corrente + 5, 2, riga_corrente +
3863  6).CellStyle = 'Ultimus_centro'
3864 
3865  # inserisco il salto pagina in cima al riepilogo
3866  oDoc.CurrentController.select(oSheet.getCellByPosition(0, lrowF))
3868  desktop = LeenoUtils.getDesktop()
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"))
3874 
3875  # oSheet.getCellByPosition(lrowF,0).Rows.IsManualPageBreak = True
3877 
3878 
3879 
3880 
3882  '''
3883  cancella le voci in Elenco Prezzi che derivano da analisi
3884  '''
3885  oDoc = LeenoUtils.getDocument()
3886  oSheet = oDoc.CurrentController.ActiveSheet
3887  oSheet = oDoc.Sheets.getByName('Analisi di Prezzo')
3888  lista_an = list()
3889  for i in range(0, SheetUtils.getUsedArea(oSheet).EndRow):
3890  if oSheet.getCellByPosition(0, i).CellStyle == 'An-1_sigla':
3891  # codice = oSheet.getCellByPosition(0, i).String
3892  lista_an.append(oSheet.getCellByPosition(0, i).String)
3893  oSheet = oDoc.Sheets.getByName('Elenco Prezzi')
3894  for i in reversed(range(0, SheetUtils.getUsedArea(oSheet).EndRow)):
3895  if oSheet.getCellByPosition(0, i).String in lista_an:
3896  oSheet.getRows().removeByIndex(i, 1)
3897 
3898 
3900  '''
3901  @@ DA DOCUMENTARE
3902  '''
3903  oDoc = LeenoUtils.getDocument()
3904  try:
3905  oSheet = oDoc.CurrentController.ActiveSheet
3906  if oSheet.Name != 'Analisi di Prezzo':
3907  return
3908  oDoc.enableAutomaticCalculation(False) # blocco il calcolo automatico
3910  riga = sStRange.RangeAddress.StartRow + 2
3911 
3912  codice = oSheet.getCellByPosition(0, riga).String
3913 
3914  oSheet = oDoc.Sheets.getByName('Elenco Prezzi')
3915  oDoc.CurrentController.setActiveSheet(oSheet)
3916 
3917  oSheet.getRows().insertByIndex(3, 1)
3918 
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'
3928 
3929  oSheet.getCellByPosition(0, 3).String = codice
3930 
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) # sblocco il calcolo automatico
3950  _gotoCella(1, 3)
3951  except Exception:
3952  pass
3953  oDoc.enableAutomaticCalculation(True)
3954 
3955 
3956 
3958  '''
3959  Invia le analisi all'Elenco Prezzi.
3960  '''
3961  chiudi_dialoghi()
3962 
3963  oDoc = LeenoUtils.getDocument()
3964  # ~oDoc.enableAutomaticCalculation(False)
3965  lista_analisi = list()
3966  oSheet = oDoc.getSheets().getByName('Analisi di prezzo')
3967  SheetUtils.NominaArea(oDoc, 'Analisi di Prezzo',
3968  '$A$3:$K$' + str(SheetUtils.getUsedArea(oSheet).EndRow), 'analisi')
3969  voce = list()
3970  idx = 4
3971  for n in range(0, LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1):
3972  if oSheet.getCellByPosition(
3973  0, n
3974  ).CellStyle == 'An-1_sigla' and oSheet.getCellByPosition(
3975  1, n
3976  ).String != '<<<Scrivi la descrizione della nuova voce da analizzare ':
3977  voce = (
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),
3984  # ~"=$'Analisi di Prezzo'.J" + str(n + 1),
3985  "",
3986  "=$'Analisi di Prezzo'.A" + str(n + 1),
3987  "(AP)",
3988  '',
3989  '',
3990  "=N" + str(idx) + "/$N$2",
3991  "=SUMIF(AA;A" + str(idx) + ";BB)",
3992  "=SUMIF(AA;A" + str(idx) + ";cEuro)",
3993  )
3994  lista_analisi.append(voce)
3995  idx += 1
3996  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
3997  if len(lista_analisi) != 0:
3998  oSheet.getRows().insertByIndex(3, len(lista_analisi))
3999  else:
4000  return
4001  oRange = oSheet.getCellRangeByPosition(0, 3, 13,
4002  3 + len(lista_analisi) - 1)
4003  lista_come_array = tuple(lista_analisi)
4004  oRange.setDataArray(
4005  lista_come_array
4006  ) # setFormulaArray() sarebbe meglio, ma mi fa storie sul codice articolo
4007  for y in range(3, 3 + len(lista_analisi)):
4008  for x in range(
4009  1, len(lista_analisi[0])
4010  ): # evito il codice articolo, altrimenti me lo converte in numero
4011  oSheet.getCellByPosition(x, y).Formula = oSheet.getCellByPosition(
4012  x, y).String
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'
4031 
4032  # ~oDoc.enableAutomaticCalculation(True)
4033  GotoSheet('Elenco Prezzi')
4034  # MsgBox('Trasferite ' + str(len(lista_analisi)) + ' analisi di prezzo in Elenco Prezzi.', 'Avviso')
4035 
4036 
4037 
4039  '''
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
4045  '''
4046  oDoc = LeenoUtils.getDocument()
4047  oSheet = oDoc.CurrentController.ActiveSheet
4048  stili_analisi = LeenoUtils.getGlobalVar('stili_analisi')
4049  if oSheet.getCellByPosition(0, lrow).CellStyle in stili_analisi:
4050  for el in reversed(range(0, lrow)):
4051  # chi(oSheet.getCellByPosition(0, el).CellStyle)
4052  if oSheet.getCellByPosition(0, el).CellStyle == 'Analisi_Sfondo':
4053  SR = el
4054  break
4055  for el in range(lrow, SheetUtils.getUsedArea(oSheet).EndRow):
4056  if oSheet.getCellByPosition(
4057  0, el).CellStyle == 'An-sfondo-basso Att End':
4058  ER = el
4059  break
4060  celle = oSheet.getCellRangeByPosition(0, SR, 250, ER)
4061  return celle
4062 
4063 
4064 
4065 
4066 def ColumnNumberToName(oSheet, cColumnNumb):
4067  '''Trasforma IDcolonna in Nome'''
4068  # oDoc = LeenoUtils.getDocument()
4069  # oSheet = oDoc.CurrentController.ActiveSheet
4070  oColumns = oSheet.getColumns()
4071  oColumn = oColumns.getByIndex(cColumnNumb).Name
4072  return oColumn
4073 
4074 
4075 
4076 def ColumnNameToNumber(oSheet, cColumnName):
4077  '''Trasforma il nome colonna in IDcolonna'''
4078  # oDoc = LeenoUtils.getDocument()
4079  # oSheet = oDoc.CurrentController.ActiveSheet
4080  oColumns = oSheet.getColumns()
4081  oColumn = oColumns.getByName(cColumnName)
4082  oRangeAddress = oColumn.getRangeAddress()
4083  nColumn = oRangeAddress.StartColumn
4084  return nColumn
4085 
4086 
4087 
4089  '''
4090  Azzera la quantità di una voce e ne raggruppa le relative righe
4091  '''
4092  oDoc = LeenoUtils.getDocument()
4094 
4095  try:
4096  oSheet = oDoc.CurrentController.ActiveSheet
4097  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
4098  try:
4099  sRow = oDoc.getCurrentSelection().getRangeAddresses(
4100  )[0].StartRow
4101  eRow = oDoc.getCurrentSelection().getRangeAddresses()[0].EndRow
4102 
4103  except Exception:
4104  sRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
4105  eRow = oDoc.getCurrentSelection().getRangeAddress().EndRow
4106  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, sRow)
4107  sStRange.RangeAddress
4108  sRow = sStRange.RangeAddress.StartRow
4109  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, eRow)
4110  try:
4111  sStRange.RangeAddress
4112  except Exception:
4113  return
4114  inizio = sStRange.RangeAddress.StartRow
4115  eRow = sStRange.RangeAddress.EndRow + 1
4116 
4117  lrow = sRow
4118  fini = list()
4119  for x in range(sRow, eRow):
4120  if oSheet.getCellByPosition(
4121  0, x).CellStyle == 'Comp End Attributo':
4122  fini.append(x)
4123  elif oSheet.getCellByPosition(
4124  0, x).CellStyle == 'Comp End Attributo_R':
4125  fini.append(x - 2)
4126  idx = 0
4127  for lrow in reversed(fini):
4128  lrow += idx
4129  try:
4130  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
4131  sStRange.RangeAddress
4132  inizio = sStRange.RangeAddress.StartRow
4133  fine = sStRange.RangeAddress.EndRow
4134  if oSheet.Name == 'CONTABILITA':
4135  fine -= 1
4136  _gotoCella(2, fine - 1)
4137  if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, fine - 1).String:
4138  # elimino il colore di sfondo
4139  if oSheet.Name == 'CONTABILITA':
4140  oSheet.getCellRangeByPosition(
4141  0, inizio, 250, fine + 1).clearContents(HARDATTR)
4142  else:
4143  oSheet.getCellRangeByPosition(
4144  0, inizio, 250, fine).clearContents(HARDATTR)
4145  raggruppa_righe_voce(lrow, 0)
4146  oSheet.getRows().removeByIndex(fine - 1, 1)
4147  fine -= 1
4148  _gotoCella(2, fine - 1)
4149  idx -= 1
4150  else:
4151  Copia_riga_Ent()
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) + ')'
4159  else:
4160  oSheet.getCellByPosition(
4161  5, fine).Formula = '=SUBTOTAL(9;J' + str(
4162  inizio + 1) + ':J' + str(fine) + ')'
4163  inverti_segno()
4164  # cambio il colore di sfondo
4165  oDoc.CurrentController.select(sStRange)
4166  raggruppa_righe_voce(lrow, 1)
4168  desktop = LeenoUtils.getDesktop()
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)
4177  _gotoCella(2, fine)
4178 
4179  lrow = LeggiPosizioneCorrente()[1]
4180  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 1)
4181  except Exception:
4182  pass
4183  # ~numera_voci(1)
4184  except Exception:
4185  pass
4186  _gotoCella(0, fine)
4188 
4189 
4190 
4192  '''
4193  Elimina le voci in cui compare la dicitura '*** VOCE AZZERATA ***'
4194  in COMPUTO o in VARIANTE, senza chiedere conferma
4195  '''
4196  oDoc = LeenoUtils.getDocument()
4197  oSheet = oDoc.CurrentController.ActiveSheet
4198  try:
4199  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
4200  ER = SheetUtils.getUsedArea(oSheet).EndRow
4201  # attiva la progressbar
4202  progress = Dialogs.Progress(Title='Esecuzione in corso...', Text="Cancellazione voci azzerate")
4203  n = 0
4204  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))
4205  progress.setValue(n)
4206  progress.show()
4207  for lrow in reversed(range(0, ER)):
4208  n += 1
4209  progress.setValue(n)
4210  # ~if oSheet.getCellByPosition(
4211  # ~2, lrow).String == '*** VOCE AZZERATA ***':
4212  if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, lrow).String:
4213  # ~elimina_voce(lrow=lrow, msg=0)
4214  LeenoSheetUtils.eliminaVoce(oSheet, lrow)
4215 
4216  numera_voci(1)
4217  progress.hide()
4218  except Exception:
4219  return
4220 
4221 
4222 
4223 def raggruppa_righe_voce(lrow, flag=1):
4224  '''
4225  Raggruppa le righe che compongono una singola voce.
4226  '''
4227  oDoc = LeenoUtils.getDocument()
4228  oSheet = oDoc.CurrentController.ActiveSheet
4229  # lrow = LeggiPosizioneCorrente()[1]
4230  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4231  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
4232  sStRange.RangeAddress
4233 
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
4242  if flag == 1:
4243  oSheet.group(oCellRangeAddr, 1)
4244  else:
4245  oSheet.ungroup(oCellRangeAddr, 1)
4246 
4247 
4248 
4250  '''
4251  Nasconde le voci in cui compare la dicitura '*** VOCE AZZERATA ***'
4252  in COMPUTO o in VARIANTE.
4253  '''
4254  oDoc = LeenoUtils.getDocument()
4255  oSheet = oDoc.CurrentController.ActiveSheet
4256  try:
4257  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4258  ER = SheetUtils.getUsedArea(oSheet).EndRow
4259  for lrow in reversed(range(0, ER)):
4260  if '*** VOCE AZZERATA ***' in oSheet.getCellByPosition(2, lrow).String:
4261  raggruppa_righe_voce(lrow, 1)
4262  except Exception:
4263  return
4264 
4265 
4266 
4267 def seleziona(lrow=None):
4268  '''
4269  Seleziona voci intere
4270  '''
4271  oDoc = LeenoUtils.getDocument()
4272  oSheet = oDoc.CurrentController.ActiveSheet
4273 
4274  if lrow == None:
4275  lrow = LeggiPosizioneCorrente()[1]
4276 
4277  try:
4278  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4279  except AttributeError:
4280  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4281  if oSheet.Name in ('Elenco Prezzi'):
4282 
4283  el_y = []
4284  lista_y = []
4285  try:
4286  len(oRangeAddress)
4287  for el in oRangeAddress:
4288  el_y.append((el.StartRow, el.EndRow))
4289  except TypeError:
4290  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4291  for y in el_y:
4292  for el in range(y[0], y[1] + 1):
4293  lista_y.append(el)
4294 
4295 
4296  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'Analisi di Prezzo'):
4297  try:
4298  if lrow is not None:
4299  SR = oRangeAddress.StartRow
4300  SR = LeenoComputo.circoscriveVoceComputo(oSheet, SR).RangeAddress.StartRow
4301  else:
4302  SR = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
4303  except AttributeError:
4304  # ~DLG.MsgBox('La selezione deve essere contigua.', 'ATTENZIONE!')
4305  Dialogs.Exclamation(Title = 'ATTENZIONE!',
4306  Text='''La selezione deve essere contigua.''')
4307  return 0
4308  if lrow is not None:
4309  ER = oRangeAddress.EndRow
4310  ER = LeenoComputo.circoscriveVoceComputo(oSheet, ER).RangeAddress.EndRow
4311  else:
4312  ER = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.EndRow
4313  lista_y = [SR, ER]
4314  # ~if oSheet.Name == 'Analisi di Prezzo':
4315  # ~try:
4316  # ~oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4317  # ~except AttributeError:
4318  # ~oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4319  # ~try:
4320  # ~if lrow is not None:
4321  # ~SR = oRangeAddress.StartRow
4322  # ~SR = LeenoComputo.circoscriveVoceComputo(oSheet, SR).RangeAddress.StartRow
4323  # ~else:
4324  # ~SR = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
4325  # ~except AttributeError:
4326  # ~DLG.MsgBox('La selezione deve essere contigua.', 'ATTENZIONE!')
4327  # ~return 0
4328  # ~if lrow is not None:
4329  # ~ER = oRangeAddress.EndRow
4330  # ~ER = LeenoComputo.circoscriveVoceComputo(oSheet, ER).RangeAddress.EndRow
4331  # ~else:
4332  # ~ER = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.EndRow
4333  if oSheet.Name == 'CONTABILITA':
4334  partenza = cerca_partenza()
4335  if partenza[2] == '#reg':
4336  sblocca_cont()
4337  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
4338  return
4339  pass
4340  else:
4341  pass
4342  try:
4343  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4344  except AttributeError:
4345  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4346  try:
4347  if lrow is not None:
4348  SR = oRangeAddress.StartRow
4349  SR = LeenoComputo.circoscriveVoceComputo(oSheet, SR).RangeAddress.StartRow
4350  else:
4351  SR = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
4352  except AttributeError:
4353  # ~DLG.MsgBox('La selezione deve essere contigua.', 'ATTENZIONE!')
4354  Dialogs.Exclamation(Title = 'ATTENZIONE!',
4355  Text='''La selezione deve essere contigua.''')
4356  return 0
4357  if lrow is not None:
4358  ER = oRangeAddress.EndRow
4359  ER = LeenoComputo.circoscriveVoceComputo(oSheet, ER).RangeAddress.EndRow
4360  else:
4361  ER = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.EndRow
4362  lista_y = [SR, ER]
4363  return lista_y
4364 
4365 
4366 
4367 def seleziona_voce(lrow=None):
4368  '''
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
4373  '''
4374  oDoc = LeenoUtils.getDocument()
4375  oSheet = oDoc.CurrentController.ActiveSheet
4376  if lrow is None or lrow == 0:
4377  lrow = LeggiPosizioneCorrente()[1]
4378  if oSheet.Name in ('Elenco Prezzi'):
4379  return
4380  try:
4381  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4382  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
4383  elif oSheet.Name == 'Analisi di Prezzo':
4384  sStRange = Circoscrive_Analisi(lrow)
4385 
4386  if oSheet.Name == 'CONTABILITA':
4387  partenza = cerca_partenza()
4388  if partenza[2] == '#reg':
4389  sblocca_cont()
4390  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
4391  return
4392  pass
4393  else:
4394  pass
4395  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
4396 
4397  except Exception:
4398  return
4399  try:
4400  sStRange.RangeAddress
4401  SR = sStRange.RangeAddress.StartRow
4402  ER = sStRange.RangeAddress.EndRow
4403  except:
4404  return
4405  return (SR, ER)
4406 
4407 
4408 
4409 
4410 
4415 
4416 
4417 
4418 
4419 
4421  '''
4422  Elimina le righe selezionate anche se non contigue.
4423  '''
4424  oDoc = LeenoUtils.getDocument()
4425  oDoc.enableAutomaticCalculation(False)
4426  oSheet = oDoc.CurrentController.ActiveSheet
4427 
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.""")
4431  return
4432 
4433  if oSheet.Name not in ('COMPUTO', 'CONTABILITA', 'VARIANTE', 'Analisi di Prezzo'):
4434  return
4435 
4436  try:
4437  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4438  except AttributeError:
4439  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4440  el_y = list()
4441  lista_y = list()
4442  try:
4443  len(oRangeAddress)
4444  for el in oRangeAddress:
4445  el_y.append((el.StartRow, el.EndRow))
4446  except TypeError:
4447  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4448  for y in el_y:
4449  for el in range(y[0], y[1] + 1):
4450  lista_y.append(el)
4451  oCellRangeAddr = uno.createUnoStruct('com.sun.star.table.CellRangeAddress')
4452  rigen = False
4453  for y in reversed(lista_y):
4454  if oSheet.getCellByPosition(2, y).CellStyle not in ('An-lavoraz-generica',
4455  'An-lavoraz-Cod-sx',
4456  'comp 1-a',
4457  'comp 1-a ROSSO',
4458  'comp sotto centro',
4459  'EP-mezzo',
4460  'Livello-0-scritta mini',
4461  'Livello-1-scritta mini',
4462  'livello2_') or \
4463  'Somma positivi e negativi [' in oSheet.getCellByPosition(8, y).String or \
4464  'SOMMANO' in oSheet.getCellByPosition(8, y).String:
4465  pass
4466  else:
4467  if oSheet.getCellByPosition(2, y).CellStyle in ('comp sotto centro'):
4468  rigen = True
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_'):
4480  Rinumera_TUTTI_Capitoli2(oSheet)
4481  if rigen == True:
4482  rigenera_parziali(False)
4483  oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges"))
4484  oDoc.enableAutomaticCalculation(True)
4485 
4486 
4488  '''
4489  Inserisce una nuova riga di misurazione nel computo
4490  '''
4491  oDoc = LeenoUtils.getDocument()
4492  oSheet = oDoc.CurrentController.ActiveSheet
4493  # ~lrow = LeggiPosizioneCorrente()[1]
4494  stile = oSheet.getCellByPosition(1, lrow).CellStyle
4495  if stile in (
4496  'comp Art-EP', 'comp Art-EP_R', 'Comp-Bianche in mezzo'
4497  ): # Comp-Bianche in mezzo Descr', 'comp 1-a', 'comp sotto centro'):# <stili computo
4498  lrow = lrow + 1 # PER INSERIMENTO SOTTO RIGA CORRENTE
4499  oSheet.getRows().insertByIndex(lrow, 1)
4500  # imposto gli stili
4501  oSheet.getCellRangeByPosition(
4502  5,
4503  lrow,
4504  7,
4505  lrow,
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'
4517  # ci metto le formule
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 +
4522  1) + '))'
4523  _gotoCella(2, lrow)
4524  # ~oDoc.CurrentController.select(oSheet.getCellByPosition(2, lrow))
4525  # ~oDoc.CurrentController.select(oDoc.createInstance("com.sun.star.sheet.SheetCellRanges"))
4526 
4527 
4529  '''
4530  Inserisce una nuova riga di misurazione in contabilità
4531  '''
4532  oDoc = LeenoUtils.getDocument()
4533  # vado alla vecchia maniera ## copio il range di righe computo da S5 ##
4534  oSheet = oDoc.CurrentController.ActiveSheet
4535  oSheetto = oDoc.getSheets().getByName('S5')
4536  oRangeAddress = oSheetto.getCellRangeByPosition(0, 24, 42, 24).getRangeAddress()
4537  # lrow = LeggiPosizioneCorrente()[1]
4538  stile = oSheet.getCellByPosition(1, lrow).CellStyle
4539  if oSheet.getCellByPosition(1,
4540  lrow + 1).CellStyle == 'comp sotto Bianche_R':
4541  return
4542  if stile in ('comp Art-EP_R', 'Data_bianca', 'Comp-Bianche in mezzo_R'):
4543 
4544  lrow = lrow + 1 # PER INSERIMENTO SOTTO RIGA CORRENTE
4545 
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'
4557  else:
4558  oSheet.getCellByPosition(1, lrow).CellStyle = 'Comp-Bianche in mezzo_R'
4559  _gotoCella(2, lrow)
4560  return
4561 
4562 
4564  '''
4565  @@@ MODIFICA IN CORSO CON 'LeenoAnalysis.copiaRigaAnalisi'
4566  Inserisce una nuova riga di misurazione in analisi di prezzo
4567  '''
4568  oDoc = LeenoUtils.getDocument()
4569  oSheet = oDoc.CurrentController.ActiveSheet
4570  stile = oSheet.getCellByPosition(0, lrow).CellStyle
4571  if stile in ('An-lavoraz-desc', 'An-lavoraz-Cod-sx'):
4572  lrow = lrow + 1
4573  oSheet.getRows().insertByIndex(lrow, 1)
4574  # imposto gli stili
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'
4581  # ci metto le formule
4582  # oDoc.enableAutomaticCalculation(False)
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(
4587  2,
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(
4592  4,
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(
4598  8, lrow
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) + ')'
4604  # oDoc.enableAutomaticCalculation(True)
4605  # preserva il Pesca
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.?'
4613  _gotoCella(1, lrow)
4614 
4615 
4616 
4617 
4619  '''
4620  @@ DA DOCUMENTARE
4621  '''
4622  Copia_riga_Ent()
4623 
4624 
4625 def Copia_riga_Ent(arg=None):
4626  '''
4627  Aggiunge riga di misurazione
4628  '''
4630  oDoc = LeenoUtils.getDocument()
4631  oSheet = oDoc.CurrentController.ActiveSheet
4632  lrow = LeggiPosizioneCorrente()[1]
4633  nome_sheet = oSheet.Name
4634  if nome_sheet in ('COMPUTO', 'VARIANTE'):
4635  if cfg.read('Generale', 'dettaglio') == '1':
4637  copia_riga_computo(lrow)
4638  elif nome_sheet == 'CONTABILITA':
4639  if cfg.read('Generale', 'dettaglio') == '1':
4641  copia_riga_contab(lrow)
4642  elif nome_sheet == 'Analisi di Prezzo':
4643  copia_riga_analisi(lrow)
4645 
4646 
4647 
4649  '''
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à)
4653  '''
4654  oDoc = LeenoUtils.getDocument()
4655  oSheet = oDoc.CurrentController.ActiveSheet
4656  lrow = LeggiPosizioneCorrente()[1]
4657 
4658  partenza = LeenoSheetUtils.cercaPartenza(oSheet, lrow)
4659  LeenoUtils.setGlobalVar('partenza', partenza)
4660  return partenza
4661 
4662 
4664  '''
4665  @@@ MODIFICA IN CORSO CON 'LeenoContab.sbloccaContabilita'
4666  Controlla che non ci siano atti contabili registrati e dà il consenso a procedere.
4667  '''
4668  partenza = LeenoUtils.getGlobalVar('partenza')
4669  oDoc = LeenoUtils.getDocument()
4670  oSheet = oDoc.CurrentController.ActiveSheet
4671  if oSheet.Name in ('CONTABILITA'):
4672  partenza = cerca_partenza()
4673  # ~DLG.chi(partenza[2])
4674  # ~DLG.chi(LeenoUtils.getGlobalVar('sblocca_computo'))
4675  if LeenoUtils.getGlobalVar('sblocca_computo') == 1:
4676  pass
4677  else:
4678  if partenza[2] == '':
4679  pass
4680  if partenza[2] == '#reg':
4681  if Dialogs.YesNoDialog(Title='Avviso: Voce già registrata!',
4682 
4683  Text= """Lavorando in questo punto del foglio,
4684 comprometterai la validità degli atti contabili già emessi.
4685 
4686 Vuoi procedere?
4687 
4688 SCEGLIENDO SI' SARAI COSTRETTO A RIGENERARLI!""") == 0:
4689  pass
4690  else:
4691  LeenoUtils.setGlobalVar('sblocca_computo', 1)
4692  # ~DLG.chi(LeenoUtils.getGlobalVar('sblocca_computo'))
4693 
4694 
4695 
4696 
4697 
4699  '''
4700  Evidenzia il codice di elenco prezzi della voce corrente.
4701  '''
4702  cerca_in_elenco()
4703 
4704 
4706  '''
4707  Evidenzia il codice di elenco prezzi della voce corrente.
4708  '''
4709  oDoc = LeenoUtils.getDocument()
4710  oSheet = oDoc.CurrentController.ActiveSheet
4711  lrow = LeggiPosizioneCorrente()[1]
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
4718  else:
4719  return
4720  elif oSheet.Name in ('Registro','SAL'):
4721  codice_da_cercare =oSheet.getCellByPosition(0, lrow).String.split('\n')[1]
4722  else:
4723  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
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
4728  GotoSheet('Elenco Prezzi')
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
4732  else:
4733  return
4734  oSheet = oDoc.getSheets().getByName("Analisi di Prezzo")
4735  oSheet.IsVisible = True
4736  GotoSheet('Analisi di Prezzo')
4737 
4738  if codice_da_cercare == "Cod. Art.?":
4739  return
4740  if codice_da_cercare != '':
4741  oCell = SheetUtils.uFindString(codice_da_cercare, oSheet)
4742  try:
4743  oDoc.CurrentController.select(
4744  oSheet.getCellRangeByPosition(oCell[0], oCell[1], 30, oCell[1]))
4745  except:
4746  _gotoCella(1, 2)
4747  return
4748 
4749 
4750 
4751 
4753  '''
4754  @@ DA DOCUMENTARE
4755  '''
4756  pesca_cod()
4757 
4758 
4760  '''
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.
4763  '''
4764  partenza = LeenoUtils.getGlobalVar('partenza')
4765  oDoc = LeenoUtils.getDocument()
4766  oSheet = oDoc.CurrentController.ActiveSheet
4767  lrow = LeggiPosizioneCorrente()[1]
4768 
4769  stili_computo = LeenoUtils.getGlobalVar('stili_computo')
4770  stili_contab = LeenoUtils.getGlobalVar('stili_contab')
4771  stili_analisi = LeenoUtils.getGlobalVar('stili_analisi')
4772  stili_elenco = LeenoUtils.getGlobalVar('stili_elenco')
4773 
4774  if oSheet.getCellByPosition(0, lrow).CellStyle not in stili_computo + stili_contab + stili_analisi + stili_elenco:
4775  return
4776  if oSheet.Name in ('Analisi di Prezzo'):
4777  partenza = cerca_partenza()
4778  cerca_in_elenco()
4779  GotoSheet('Elenco Prezzi')
4780 
4781 
4782  if oSheet.Name in ('CONTABILITA'):
4783  # controllo che non ci siano atti registrati
4784  partenza = cerca_partenza()
4785  if partenza[2] == '#reg':
4786  sblocca_cont()
4787  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
4788  return
4789  pass
4790  else:
4791  pass
4792 
4794  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4795  if oDoc.NamedRanges.hasByName("_Lib_1"):
4796  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
4797  if DLG.DlgSiNo(
4798  "Risulta già registrato un SAL. VUOI PROCEDERE COMUQUE?",
4799  'ATTENZIONE!') == 3:
4800  return
4801  if Dialogs.YesNoDialog(Title='ATTENZIONE!',
4802  Text="Risulta già registrato un SAL."
4803  "Vuoi procedere comunque?") == 0:
4804  return
4805  else:
4806  LeenoUtils.setGlobalVar('sblocca_computo', 1)
4807  partenza = cerca_partenza()
4808  if oSheet.getCellByPosition(1, partenza[1]).String != 'Cod. Art.?':
4809  cerca_in_elenco()
4810  GotoSheet('Elenco Prezzi')
4811 
4812  if oSheet.Name in ('Elenco Prezzi'):
4813  try:
4815  codice = oSheet.getCellByPosition(0, lrow).String
4816  GotoSheet(partenza[0])
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])
4821  else:
4822  oSheet.getCellByPosition(1, partenza[1]).String = codice
4823  _gotoCella(2, partenza[1] + 1)
4824  except NameError:
4825  return
4826 
4827 
4828 
4830  '''
4831  In CONTABILITA consente l'inserimento di nuove voci di misurazione
4832  partendo da voci già inserite in COMPUTO o VARIANTE.
4833  '''
4835  oDoc = LeenoUtils.getDocument()
4836  # ~oDoc.enableAutomaticCalculation(False)
4837  oSheet = oDoc.CurrentController.ActiveSheet
4838  if oSheet.Name == 'CONTABILITA':
4839  try:
4840  # controllo che non ci siano atti registrati
4841  partenza = cerca_partenza()
4842  if partenza[2] == '#reg':
4843  sblocca_cont()
4844  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
4845  return
4846  pass
4847  else:
4848  pass
4849 
4850  except Exception:
4851  pass
4852  lrow = LeggiPosizioneCorrente()[1]
4853 
4854  stili_contab = LeenoUtils.getGlobalVar('stili_contab')
4855 
4856  if oSheet.getCellByPosition(0, lrow).CellStyle not in stili_contab + (
4857  'comp Int_colonna_R_prima', ):
4858  return
4859  ins_voce_contab(arg=0)
4860  partenza = cerca_partenza()
4861  try:
4862  GotoSheet(cfg.read('Contabilita', 'ricicla_da'))
4863  except:
4864  Dialogs.Exclamation(Title = 'ATTENZIONE!',
4865  Text=' Stai cercando di riciclare le misure dal foglio ' + \
4866  cfg.read('Contabilita', 'ricicla_da'))
4868  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4869  lrow = LeggiPosizioneCorrente()[1]
4870  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
4871  sopra = sStRange.RangeAddress.StartRow + 2
4872  sotto = sStRange.RangeAddress.EndRow - 1
4873 
4874  oSrc = oSheet.getCellRangeByPosition(2, sopra, 8,
4875  sotto).getRangeAddress()
4876  oSheet.getCellByPosition(2, sopra - 1).CellBackColor = 13500076
4877  partenza = LeenoUtils.getGlobalVar('partenza')
4878  if partenza is None:
4879  return
4880  oDest = oDoc.getSheets().getByName('CONTABILITA')
4881  oCellAddress = oDest.getCellByPosition(2, partenza[1] + 1).getCellAddress()
4882  GotoSheet('CONTABILITA')
4883 
4884  if sotto != sopra:
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'
4888 
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
4892  rigenera_voce(partenza[1])
4893  # ~rigenera_parziali(False)
4894  _gotoCella(2, partenza[1] + 1)
4895  # ~oDoc.enableAutomaticCalculation(True)
4897 
4898 
4900  inverti_segno()
4901 
4903  '''
4904  Inverte il segno delle formule di quantità nei righi di misurazione selezionati.
4905  '''
4906  oDoc = LeenoUtils.getDocument()
4907  oSheet = oDoc.CurrentController.ActiveSheet
4908 
4909  # estrae il range o i ranges selezionati
4910  # (possono essere più di uno)
4911  try:
4912  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
4913  except AttributeError:
4914  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
4915 
4916  # inserisce in una lista le righe di inizio e fine
4917  # di ogni range come touples ((inizio, fine), (inizio, fine)...)
4918  el_y = list()
4919  try:
4920  len(oRangeAddress)
4921  for el in oRangeAddress:
4922  el_y.append((el.StartRow, el.EndRow))
4923  except TypeError:
4924  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
4925 
4926  # estrate tutte le righe incluse nel o nei range(s)
4927  # e le inserisce in una lista di righe
4928  lista = list()
4929  for y in el_y:
4930  for el in range(y[0], y[1] + 1):
4931  lista.append(el)
4932 
4933  # va ad eseguire il lavoro su ogni riga della lista
4934  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
4935  for lrow in lista:
4936  if 'comp 1-a' in oSheet.getCellByPosition(2, lrow).CellStyle:
4937  if 'ROSSO' in oSheet.getCellByPosition(2, lrow).CellStyle:
4938  # se VediVoce
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) + '))')
4944 
4945  for x in range(2, 10):
4946  oSheet.getCellByPosition(x, lrow).CellStyle = (
4947  oSheet.getCellByPosition(x, lrow).CellStyle.split(' ROSSO')[0])
4948  else:
4949  # se VediVoce
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) + '))')
4954 
4955  for x in range(2, 10):
4956  oSheet.getCellByPosition(x, lrow).CellStyle = (
4957  oSheet.getCellByPosition(x, lrow).CellStyle + ' ROSSO')
4958 
4959  elif oSheet.Name in ('CONTABILITA'):
4960  for lrow in lista:
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')
4970  else:
4971  for x in range(2, 12):
4972  oSheet.getCellByPosition(
4973  x, lrow).CellStyle = (
4974  oSheet.getCellByPosition(x, lrow).CellStyle.split(' ROSSO')[0])
4975 
4976 
4977 
4978 def valuta_cella(oCell):
4979  '''
4980  Estrae qualsiasi valore da una cella, restituendo una stringa, indipendentemente dal tipo originario.
4981  oCell { object } : cella da validare
4982  '''
4983  if oCell.Type.value == 'FORMULA':
4984  if re.search('[a-zA-Z]', oCell.Formula):
4985  valore = str(oCell.Value)
4986  else:
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':
4993  valore = ''
4994  if valore == ' ':
4995  valore = ''
4996  return valore
4997 
4998 
4999 
5001  '''
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
5006  '''
5007  oDoc = LeenoUtils.getDocument()
5009  oSheet = oDoc.CurrentController.ActiveSheet
5010  lrow = LeggiPosizioneCorrente()[1]
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 (
5015  'comp 1-a'
5016  ) and "*** VOCE AZZERATA ***" not in oSheet.getCellByPosition(2,
5017  lrow).String:
5018  for el in range(5, 9):
5019  if oSheet.getCellByPosition(el, lrow).Type.value == 'FORMULA':
5020  stringa = ''
5021  break
5022  else:
5023  stringa = None
5024 
5025  if stringa == '':
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:
5029  try:
5030  eval(
5031  oSheet.getCellByPosition(
5032  el, lrow).Formula.split('=')[1].replace(
5033  '^', '**'))
5034  # ~eval(oSheet.getCellByPosition(el, lrow).Formula.split('=')[1])
5035  stringa = stringa + '(' + oSheet.getCellByPosition(
5036  el, lrow).Formula.split('=')[-1] + ')*'
5037  except Exception:
5038  stringa = stringa + '(' + oSheet.getCellByPosition(
5039  el, lrow).String.split('=')[-1] + ')*'
5040  pass
5041  else:
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]
5048  else:
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('.', ',')
5056 
5057 
5058 
5060  '''
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
5065  '''
5067  oDoc = LeenoUtils.getDocument()
5068  try:
5069  oSheet = oDoc.CurrentController.ActiveSheet
5070  except Exception:
5071  return
5072  ER = SheetUtils.getUsedArea(oSheet).EndRow
5073 
5074  progress = Dialogs.Progress(Title='Rigenerazione in corso...', Text="Lettura dati")
5075  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))
5076  progress.setValue(0)
5077  progress.show()
5078 
5079  if bit == 1:
5080  for lrow in range(0, ER):
5081  progress.setValue(lrow)
5082  if oSheet.getCellByPosition(2, lrow).CellStyle in (
5083  'comp 1-a'
5084  ) and "*** VOCE AZZERATA ***" not in oSheet.getCellByPosition(
5085  2, lrow).String:
5086  for el in range(5, 9):
5087  if oSheet.getCellByPosition(el, lrow).Type.value == 'FORMULA':
5088  stringa = ''
5089  break
5090  else:
5091  stringa = None
5092  if stringa == '':
5093  for el in range(5, 9):
5094  if oSheet.getCellByPosition(
5095  el, lrow).Type.value == 'FORMULA':
5096  if '$' not in oSheet.getCellByPosition(
5097  el, lrow).Formula:
5098  try:
5099  eval(
5100  oSheet.getCellByPosition(
5101  el, lrow).Formula.split('=')
5102  [1].replace('^', '**'))
5103  # ~eval(oSheet.getCellByPosition(el, lrow).Formula.split('=')[1])
5104  stringa = stringa + '(' + oSheet.getCellByPosition(
5105  el, lrow).Formula.split('=')[-1] + ')*'
5106  except Exception:
5107  stringa = stringa + '(' + oSheet.getCellByPosition(
5108  el, lrow).String.split('=')[-1] + ')*'
5109  pass
5110  else:
5111  stringa = stringa + '*' + str(
5112  oSheet.getCellByPosition(el,
5113  lrow).String) + '*'
5114  while '**' in stringa:
5115  stringa = stringa.replace('**', '*')
5116  if stringa[0] == '*':
5117  stringa = stringa[1:-1]
5118  else:
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('.', ',')
5126  else:
5127  for lrow in range(0, ER):
5128  progress.hide()
5129  # ~progress.setValue(lrow)
5130  if ' ►' in oSheet.getCellByPosition(2, lrow).String:
5131  oSheet.getCellByPosition(
5132  2, lrow).String = oSheet.getCellByPosition(
5133  2, lrow).String.split(' ►')[0]
5134 
5135  progress.hide()
5137  return
5138 
5139 
5140 
5142  oDoc = LeenoUtils.getDocument()
5143  oSheet = oDoc.CurrentController.ActiveSheet
5144  # DLG.mri(oDoc.CurrentSelection.Validation)
5145 
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'
5151  valida_cella(oCell,
5152  '"COMPUTO";"VARIANTE"',
5153  titoloInput='Scegli...',
5154  msgInput='COMPUTO o VARIANTE',
5155  err=True)
5156  oCell.String = 'Scegli...'
5157 
5158 
5159 def valida_cella(oCell, lista_val, titoloInput='', msgInput='', err=False):
5160  '''
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
5168  '''
5169  # oDoc = LeenoUtils.getDocument()
5170  # oSheet = oDoc.CurrentController.ActiveSheet
5171 
5172  oTabVal = oCell.getPropertyValue("Validation")
5173  oTabVal.setPropertyValue('ConditionOperator', 1)
5174 
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",
5185  "EQUAL")
5186  oTabVal.setFormula1(lista_val)
5187  oCell.setPropertyValue("Validation", oTabVal)
5188 
5189 
5191  oDoc = LeenoUtils.getDocument()
5192  oCell = oDoc.CurrentSelection
5193  oSheet = oDoc.CurrentController.ActiveSheet
5194 
5195  i = oCell.RangeAddress.StartRow
5196  n = oCell.Rows.Count
5197  oSheet.getRows().removeByIndex(i, n)
5198 
5199 
5200 
5201 def comando(cmd):
5202  '''
5203  Esegue un comando di menù.
5204  cmd { string } : nome del comando di menù
5205 
5206  Elenco comandi:
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
5212  '''
5214  desktop = LeenoUtils.getDesktop()
5215  oFrame = desktop.getCurrentFrame()
5216  dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
5217  'com.sun.star.frame.DispatchHelper', ctx)
5218  dispatchHelper.executeDispatch(oFrame, ".uno:" + cmd, "", 0,
5219  list())
5220 
5221 
5222 
5225 
5226 
5227 def delete(arg):
5228  '''
5229  Elimina righe o colonne.
5230  arg { string } : 'R' per righe
5231  'C' per colonne
5232  '''
5233  # oDoc = LeenoUtils.getDocument()
5234  # oSheet = oDoc.CurrentController.ActiveSheet
5236  desktop = LeenoUtils.getDesktop()
5237  oFrame = desktop.getCurrentFrame()
5238  oProp = PropertyValue()
5239  oProp.Name = 'Flags'
5240  oProp.Value = arg
5241  properties = (oProp, )
5242 
5243  dispatchHelper = ctx.ServiceManager.createInstanceWithContext(
5244  'com.sun.star.frame.DispatchHelper', ctx)
5245  dispatchHelper.executeDispatch(oFrame, ".uno:DeleteCell", "", 0, properties)
5246 
5247 
5248 
5249 def paste_clip(arg=None, insCells=0):
5250  oDoc = LeenoUtils.getDocument()
5251  # oSheet = oDoc.CurrentController.ActiveSheet
5253  desktop = LeenoUtils.getDesktop()
5254  oFrame = desktop.getCurrentFrame()
5255  oProp = []
5256  oProp0 = PropertyValue()
5257  oProp0.Name = 'Flags'
5258  oProp0.Value = 'A'
5259  oProp1 = PropertyValue()
5260  oProp1.Name = 'FormulaCommand'
5261  oProp1.Value = 0
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)
5276  # insert mode ON
5277  if insCells == 1:
5278  oProp5 = PropertyValue()
5279  oProp5.Name = 'MoveMode'
5280  oProp5.Value = 0
5281  oProp.append(oProp5)
5282  properties = tuple(oProp)
5283 
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")) # unselect
5287 
5288 
5289 
5291  '''
5292  Incolla solo il formato cella
5293  '''
5294  oDoc = LeenoUtils.getDocument()
5296  desktop = LeenoUtils.getDesktop()
5297  oFrame = desktop.getCurrentFrame()
5298  oProp = []
5299  oProp0 = PropertyValue()
5300  oProp0.Name = 'Flags'
5301  oProp0.Value = 'T'
5302  oProp1 = PropertyValue()
5303  oProp1.Name = 'FormulaCommand'
5304  oProp1.Value = 0
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")) # unselect
5323 
5324 
5325 
5327  '''
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
5330  visibili.
5331  Liberamente ispirato a "Copy only visible cells" http://bit.ly/2j3bfq2
5332  '''
5333  oDoc = LeenoUtils.getDocument()
5334  oSheet = oDoc.CurrentController.ActiveSheet
5335  try:
5336  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
5337  except AttributeError:
5338  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
5339  # IS = oRangeAddress.Sheet
5340  SC = oRangeAddress.StartColumn
5341  EC = oRangeAddress.EndColumn
5342  SR = oRangeAddress.StartRow
5343  ER = oRangeAddress.EndRow
5344  if EC == 1023:
5345  EC = SheetUtils.getUsedArea(oSheet).EndColumn
5346  if ER == 1048575:
5347  ER = SheetUtils.getUsedArea(oSheet).EndRow
5348  righe = list()
5349  colonne = list()
5350  i = 0
5351  for nRow in range(SR, ER + 1):
5352  if not oSheet.getCellByPosition(SR, nRow).Rows.IsVisible:
5353  righe.append(i)
5354  i += 1
5355  i = 0
5356  for nCol in range(SC, EC + 1):
5357  if not oSheet.getCellByPosition(nCol, nRow).Columns.IsVisible:
5358  colonne.append(i)
5359  i += 1
5360 
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')
5365 
5366  oCellAddress = tmp.getCellByPosition(0, 0).getCellAddress()
5367  tmp.copyRange(oCellAddress, oRangeAddress)
5368 
5369  for i in reversed(righe):
5370  tmp.getRows().removeByIndex(i, 1)
5371  for i in reversed(colonne):
5372  tmp.getColumns().removeByIndex(i, 1)
5373 
5374  oRange = tmp.getCellRangeByPosition(0, 0, EC - SC - len(colonne),
5375  ER - SR - len(righe))
5376  oDoc.CurrentController.select(oRange)
5377 
5379  desktop = LeenoUtils.getDesktop()
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))
5386 
5387 
5388 # LeggiPosizioneCorrente ###########################################################
5390  '''
5391  Restituisce la tupla (IDcolonna, IDriga, NameSheet) della posizione corrente
5392  '''
5393  oDoc = LeenoUtils.getDocument()
5394  oSheet = oDoc.CurrentController.ActiveSheet
5395  try:
5396  if oDoc.getCurrentSelection().getRangeAddresses()[0]:
5397  nRow = oDoc.getCurrentSelection().getRangeAddresses()[0].StartRow
5398  nCol = oDoc.getCurrentSelection().getRangeAddresses(
5399  )[0].StartColumn
5400  except AttributeError:
5401  nRow = oDoc.getCurrentSelection().getRangeAddress().StartRow
5402  nCol = oDoc.getCurrentSelection().getRangeAddress().StartColumn
5403  return (nCol, nRow, oSheet.Name)
5404 
5405 
5407 
5408 
5410  '''
5411  Comando di menu per numera_voci()
5412  '''
5413  numera_voci(1)
5414 
5415 
5416 def numera_voci(bit=1): #
5417  '''
5418  @@@ MODIFICA IN CORSO CON 'LeenoSheetUtils.numeraVoci'
5419  bit { integer } : 1 rinumera tutto
5420  0 rinumera dalla voce corrente in giù
5421  '''
5422  oDoc = LeenoUtils.getDocument()
5423  oSheet = oDoc.CurrentController.ActiveSheet
5424  lastRow = SheetUtils.getUsedArea(oSheet).EndRow + 1
5425  lrow = LeggiPosizioneCorrente()[1]
5426  n = 1
5427 
5428  if bit == 0:
5429  for x in reversed(range(0, lrow)):
5430  if(
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
5434  break
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
5440  n += 1
5441  if bit == 1:
5442  for row in range(0, lastRow):
5443  # ~if oSheet.getCellByPosition(1,row).CellBackColor == 15066597:
5444  # ~oSheet.getCellByPosition(0,row).String = ''
5445  # ~elif oSheet.getCellByPosition(1,row).CellStyle in('comp Art-EP', 'comp Art-EP_R'):
5446  # ~oSheet.getCellByPosition(0,row).Value = n
5447  # ~n = n+1
5448  if oSheet.getCellByPosition(1, row).CellStyle in ('comp Art-EP','comp Art-EP_R'):
5449  oSheet.getCellByPosition(0, row).Value = n
5450  n = n + 1
5451  # ~oSheet.getCellByPosition(0,row).Value = n
5452  # ~n = n+1
5453 
5454 
5455 
5456 
5457 
5459  '''Crea la Lista Lavorazioni e Forniture dall'Elenco Prezzi,
5460 per la formulazione dell'offerta'''
5461  chiudi_dialoghi()
5462  oDoc = LeenoUtils.getDocument()
5463  GotoSheet('Elenco Prezzi')
5464  genera_sommario()
5465  oSheet = oDoc.CurrentController.ActiveSheet
5466  try:
5467  oDoc.Sheets.copyByName(oSheet.Name, 'Elenco Prezzi', 5)
5468  except Exception:
5469  pass
5470  nSheet = oDoc.getSheets().getByIndex(5).Name
5471  GotoSheet(nSheet)
5472  oSheet = oDoc.CurrentController.ActiveSheet
5473  oSheet.Name = 'Richiesta offerta'
5474  setTabColor(10079487)
5475  oSheet = oDoc.CurrentController.ActiveSheet
5476  fine = SheetUtils.getUsedArea(oSheet).EndRow + 1
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)
5497 
5498  formule = list()
5499  for x in range(3, SheetUtils.getUsedArea(oSheet).EndRow - 1):
5500  formule.append([
5501  '=IF(E' + str(x + 1) + '<>"";D' + str(x + 1) + '*E' + str(x + 1) +
5502  ';""'
5503  ])
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)
5509 
5510  oSheet.getCellRangeByPosition(
5511  5, 3, 5,
5512  fine).clearContents(VALUE + DATETIME + STRING + ANNOTATION + FORMULA +
5513  HARDATTR + OBJECTS + EDITATTR + FORMATTED)
5514 
5515  oSheet.getCellRangeByPosition(4, 3, 4, fine + 1).clearContents(
5516  VALUE + FORMULA + STRING) # cancella prezzi unitari
5517  oSheet.getCellRangeByPosition(0, fine - 1, 100, fine +
5518  1).clearContents(VALUE + FORMULA + STRING)
5519  oSheet.Columns.insertByIndex(0, 1)
5520 
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"
5528  for y in (2, 3):
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(
5533  y, x).String
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(
5537  5, x).Value
5538  oSheet.getColumns().getByName("A").Columns.Width = 650
5539 
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"
5555  # INSERISCI LA DATA E L'OFFERENTE
5556  oSheet.getCellByPosition(
5557  2,
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'
5565 
5566  # CONSOLIDA LA DATA
5567  oRange = oSheet.getCellRangeByPosition(2, fine + 10, 2, fine + 10)
5568  # Flags = com.sun.star.sheet.CellFlags.FORMULA
5569  aSaveData = oRange.getDataArray()
5570  oRange.setDataArray(aSaveData)
5571  oSheet.getCellRangeByPosition(
5572  0, 0,
5573  SheetUtils.getUsedArea(oSheet).EndColumn,
5574  SheetUtils.getUsedArea(oSheet).EndRow).CellBackColor = -1
5575  # imposta stile pagina ed intestazioni
5576  oSheet.PageStyle = 'PageStyle_COMPUTO_A4'
5577  pagestyle = oDoc.StyleFamilies.getByName('PageStyles').getByName(
5578  'PageStyle_COMPUTO_A4')
5579  pagestyle.HeaderIsOn = True
5580  # left = pagestyle.RightPageHeaderContent.LeftText.Text
5581 
5582  pagestyle.HeaderIsOn = True
5583  oHContent = pagestyle.RightPageHeaderContent
5584  filename = '' # uno.fileUrlToSystemPath(oDoc.getURL())
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
5593  _gotoCella(0, 1)
5594  return
5595 
5596 
5597 
5599  '''
5600  Inserisce una nuova riga voce in Elenco Prezzi
5601  '''
5602  oDoc = LeenoUtils.getDocument()
5603  oDoc.enableAutomaticCalculation(False)
5604 
5605  oSheet = oDoc.CurrentController.ActiveSheet
5606  _gotoCella(0, 3)
5607  oSheet.getRows().insertByIndex(3, 1)
5608 
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 %"
5615 
5616  for el in (12, 16, 20, 21): # (12, 16, 20):
5617  oSheet.getCellByPosition(el, 3).CellStyle = 'EP statistiche_q'
5618 
5619  for el in (13, 17, 23, 24, 25): # (12, 16, 20):
5620  oSheet.getCellByPosition(el, 3).CellStyle = 'EP statistiche'
5621 
5622  oSheet.getCellRangeByPosition(0, 3, 26, 3).clearContents(HARDATTR)
5623  oSheet.getCellByPosition(11,
5624  3).Formula = '=IF(ISERROR(N4/$N$2);"--";N4/$N$2)'
5625  # oSheet.getCellByPosition(11, 3).Formula = '=N4/$N$2'
5626  oSheet.getCellByPosition(12, 3).Formula = '=SUMIF(AA;A4;BB)'
5627  oSheet.getCellByPosition(13, 3).Formula = '=SUMIF(AA;A4;cEuro)'
5628 
5629  # copio le formule dalla riga sotto
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)
5635  valida_cella(
5636  oCell,
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)
5641 
5642 
5643 
5644 def rigenera_voce(lrow=None):
5645  '''
5646  Ripristina/ricalcola le formule di descrizione e somma di una voce.
5647  in COMPUTO, VARIANTE e CONTABILITA
5648  '''
5649  oDoc = LeenoUtils.getDocument()
5650  oSheet = oDoc.CurrentController.ActiveSheet
5651  try:
5652  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
5653  except Exception:
5654  return
5655  sopra = sStRange.RangeAddress.StartRow
5656  sotto = sStRange.RangeAddress.EndRow
5657  # attiva la progressbar
5658 # progress = Dialogs.Progress(Title='Rigenerazione in corso...', Text="Formule")
5659 # progress.setLimits(0, sotto - sopra)
5660 # k = 0
5661 # progress.setValue(k)
5662 # progress.show()
5663 
5664  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
5665 # progress.setValue(10)
5666  oSheet.getCellByPosition(
5667  1, sopra + 1
5668  ).CellStyle = 'comp Art-EP_R'
5669  oSheet.getCellByPosition(
5670  2, sopra + 1
5671  ).Formula = '=IF(LEN(VLOOKUP(B' + str(
5672  sopra + 2
5673  ) + ';elenco_prezzi;2;FALSE()))<($S1.$H$337+$S1.$H$338);VLOOKUP(B' + str(
5674  sopra + 2
5675  ) + ';elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B' + str(
5676  sopra + 2
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(
5683  9,
5684  sotto).Formula = '=SUBTOTAL(9;J' + str(sopra +
5685  2) + ':J' + str(sotto +
5686  1) + ')'
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(
5691  17,
5692  sotto).Formula = '=AB' + str(sotto + 1) + '*J' + str(sotto + 1)
5693  # oSheet.getCellByPosition(18, sotto).Formula = '=J'+ str(sotto+1) +'*L'+ 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(
5702  28,
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(
5707  30, sotto
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(
5712  36, sotto
5713  ).Formula = '=IF(ISERROR(S' + str(sotto + 1) + ');"";IF(S' + str(
5714  sotto + 1) + '<>"";S' + str(sotto + 1) + ';""))'
5715 
5716  formule = []
5717  for n in range (sopra + 2, sotto):
5718 # k += 1
5719 # progress.setValue(k)
5720 
5721  # elimina i collegamenti esterni
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("'")
5726  if len(ff) > 1:
5727  oSheet.getCellByPosition(2, n).Formula = ff[0] + ff[-1][1:]
5728 
5729  rosso = 0
5730  for x in range (5, 8):
5731  if 'ROSSO' in oSheet.getCellByPosition(x, n).CellStyle:
5732  rosso = 1
5733  break
5734  if rosso == 1:
5735  formula = (['=IF(PRODUCT(E' + str(n + 1) + ':I' +
5736  str(n + 1) + ')=0;"";-PRODUCT(E' + str(n + 1) +
5737  ':I' + str(n + 1) + '))'])
5738  else:
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)
5747 
5748  oRange = oSheet.getCellRangeByPosition(9, sopra + 2, 9, sotto - 1)
5749  formule = tuple(formule)
5750  # ~oDoc.CurrentController.select(oRange)
5751  # ~DLG.chi(formule)
5752  oRange.setFormulaArray(formule)
5753 
5754  if oSheet.Name in ('CONTABILITA'):
5755 # progress.setValue(10)
5756  oSheet.getCellByPosition(
5757  2, sopra + 1
5758  ).Formula = '=IF(LEN(VLOOKUP(B' + str(
5759  sopra + 2
5760  ) + ';elenco_prezzi;2;FALSE()))<($S1.$H$335+$S1.$H$336);VLOOKUP(B' + str(
5761  sopra + 2
5762  ) + ';elenco_prezzi;2;FALSE());CONCATENATE(LEFT(VLOOKUP(B' + str(
5763  sopra + 2
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(
5767  8, sotto - 1
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(
5774  9, sotto -
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(
5779  11, sotto -
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(
5793  17,
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(
5798  28,
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(
5803  30, sotto
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'
5809  formule = []
5810  for n in range (sopra + 2, sotto - 1):
5811 # k += 1
5812 # progress.setValue(k)
5813 
5814  # elimina i collegamenti esterni
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("'")
5819  if len(ff) > 1:
5820  oSheet.getCellByPosition(2, n).Formula = ff[0] + ff[-1][1:]
5821 
5822  rosso = 0
5823  for x in range (5, 8):
5824  if 'ROSSO' in oSheet.getCellByPosition(x, n).CellStyle:
5825  rosso = 1
5826  break
5827  if rosso == 1:
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) + '))'])
5834  else:
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)'])
5841 
5842  oRange = oSheet.getCellRangeByPosition(9, sopra + 2, 11, sotto - 2)
5843  formule = tuple(formule)
5844  oRange.setFormulaArray(formule)
5845 # progress.hide()
5846 
5847 
5848 
5849 
5850 def rigenera_tutte(arg=None, ):
5851  '''
5852  Ripristina le formule in tutto il foglio
5853  '''
5854 
5856 
5857  chiudi_dialoghi()
5858  oDoc = LeenoUtils.getDocument()
5859 
5860  riordina_ElencoPrezzi(oDoc)
5861 
5862  oSheet = oDoc.CurrentController.ActiveSheet
5863  nome = oSheet.Name
5864  stili_cat = LeenoUtils.getGlobalVar('stili_cat')
5865 
5866 
5867  # attiva la progressbar
5868  progress = Dialogs.Progress(Title='Rigenerazione di ' + nome + ' in corso...', Text="Lettura dati")
5869  progress.setLimits(0, LeenoSheetUtils.cercaUltimaVoce(oSheet))
5870  progress.setValue(0)
5871  progress.show()
5872  if nome in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
5873  try:
5874  oSheet = oDoc.Sheets.getByName(nome)
5875  row = LeenoSheetUtils.prossimaVoce(oSheet, 0, 1, True)
5876  oDoc.CurrentController.select(oSheet.getCellByPosition(0, row))
5877  last = LeenoSheetUtils.cercaUltimaVoce(oSheet)
5878  while row < last:
5879  progress.setValue(row)
5880  rigenera_voce(row)
5881  # ~sistema_stili(row)
5882  row = LeenoSheetUtils.prossimaVoce(oSheet, row, 1, True)
5883  except Exception:
5884  pass
5885  rigenera_parziali(True)
5886  Rinumera_TUTTI_Capitoli2(oSheet)
5887  numera_voci()
5888  fissa()
5889  progress.hide()
5890  # ~comando("CalculateHard")
5892 
5893 
5894 
5895 def sistema_stili(lrow=None):
5896  '''
5897  Ripristina stili di cella per una singola voce.
5898  in COMPUTO, VARIANTE e CONTABILITA
5899  '''
5900  # ~lrow = LeggiPosizioneCorrente()[1]
5901  oDoc = LeenoUtils.getDocument()
5902  oSheet = oDoc.CurrentController.ActiveSheet
5903  try:
5904  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
5905  except Exception:
5906  return
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'
5923  else:
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'
5929 
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):
5948  # ~oSheet.getCellByPosition(11, x).CellStyle = 'Blu ROSSO'
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': # parziale
5953  oSheet.getCellByPosition(
5954  9, x).CellStyle = 'Comp-Variante num sotto'
5955 
5956  for x in range(sopra + 2, sotto - 1):
5957  test = 0
5958  for y in range(2, 8):
5959  if oSheet.getCellByPosition(y, x).String != '':
5960  test = 1
5961  break
5962  for y in range (2, 8):
5963  rosso = 0
5964  if 'ROSSO' in oSheet.getCellByPosition(y, x).CellStyle:
5965  rosso = 1
5966  break
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(
5981  x + 1) + '))'
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 = ''
5991 
5992 
5993 
5994 def rigenera_parziali (arg=False):
5995  '''
5996  arg { boolean }: Se False rigenera solo voce corrente
5997  Rigenera i parziali di tutte le voci
5998  '''
5999  oDoc = LeenoUtils.getDocument()
6001  oSheet = oDoc.CurrentController.ActiveSheet
6002 
6003  if oSheet.Name not in ('COMPUTO', 'CONTABILITA', 'VARIANTE'):
6004  return
6005 
6006  sopra = 4
6007  sotto = SheetUtils.getLastUsedRow(oSheet) + 1
6008  lrow = LeggiPosizioneCorrente()[1]
6009 
6010  if arg == False:
6011  try:
6012  sopra = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.StartRow
6013  except:
6014  return
6015  sotto = LeenoComputo.circoscriveVoceComputo(oSheet, lrow).RangeAddress.EndRow
6016 
6017  # attiva la progressbar
6018  progress = Dialogs.Progress(Title='Rigenerazione in corso...', Text="Parziali")
6019  progress.setLimits(0, sotto - sopra)
6020  n = 0
6021  progress.setValue(n)
6022  progress.show()
6023  if lrow == True:
6024  sopra = lrow
6025  for i in range(sopra, sotto):
6026  n += 1
6027  progress.setValue(n)
6028  if 'Parziale [' in oSheet.getCellByPosition(8, i).Formula:
6029  parziale_core(oSheet, i)
6030  # ~oDoc.enableAutomaticCalculation(True)
6032  progress.hide()
6033  return
6034 
6035 
6036 
6037 def MENU_nuova_voce_scelta(): # assegnato a ctrl-shift-n
6038  '''
6039  Contestualizza in ogni tabella l'inserimento delle voci.
6040  '''
6041  oDoc = LeenoUtils.getDocument()
6043  # ~oDoc.enableAutomaticCalculation(False)
6044  oSheet = oDoc.CurrentController.ActiveSheet
6045 # lrow = LeggiPosizioneCorrente()[1]
6046 
6047  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
6049  elif oSheet.Name == 'Analisi di Prezzo':
6051  elif oSheet.Name == 'CONTABILITA':
6052  # ~LeenoContab.insertVoceContabilita(oSheet, lrow) <<< non va
6053  ins_voce_contab()
6054  elif oSheet.Name == 'Elenco Prezzi':
6055  ins_voce_elenco()
6057  # ~oDoc.enableAutomaticCalculation(True)
6058 
6059 # nuova_voce_contab ##################################################
6060 def ins_voce_contab(lrow=0, arg=1, cod=None):
6061  '''
6062  @@@ MODIFICA IN CORSO CON 'LeenoContab.insertVoceContabilita
6063  Inserisce una nuova voce in CONTABILITA.
6064  '''
6065  oDoc = LeenoUtils.getDocument()
6066  # ~oSheet = oDoc.CurrentController.ActiveSheet
6067  oSheet = oDoc.Sheets.getByName('CONTABILITA')
6068 
6069  stili_contab = LeenoUtils.getGlobalVar('stili_contab')
6070  stili_cat = LeenoUtils.getGlobalVar('stili_cat')
6071 
6072  if lrow == 0:
6073  lrow = LeggiPosizioneCorrente()[1]
6074  if oSheet.getCellByPosition(0, lrow + 1).CellStyle == 'uuuuu':
6075  return
6076  # ~else:
6077  # ~lrow += 1
6078  # nome = oSheet.Name
6079  try:
6080  # controllo che non ci siano atti registrati
6081  partenza = cerca_partenza()
6082  if partenza[2] == '#reg':
6083  sblocca_cont()
6084  if LeenoUtils.getGlobalVar('sblocca_computo') == 0:
6085  return
6086  else:
6087  pass
6088 
6089  except Exception:
6090  pass
6091 
6092  stile = oSheet.getCellByPosition(0, lrow).CellStyle
6093  nSal = 0
6094  # ~if stile in stili_cat:
6095  # ~lrow += 1
6096  # ~stile = oSheet.getCellByPosition(0, lrow).CellStyle
6097  if stile == 'Ultimus_centro_bordi_lati':
6098  i = lrow
6099  while i != 0:
6100  if oSheet.getCellByPosition(23, i).Value != 0:
6101  nSal = int(oSheet.getCellByPosition(23, i).Value)
6102  break
6103  i -= 1
6104  while oSheet.getCellByPosition(0, lrow).CellStyle == stile:
6105  lrow += 1
6106  if oSheet.getCellByPosition(0, lrow).CellStyle == 'uuuuu':
6107  lrow += 1
6108  # nSal += 1
6109  # else
6110  elif stile == 'Comp TOTALI':
6111  pass
6112  if stile in stili_cat:
6113  lrow += 1
6114  elif stile in (stili_contab):
6115  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
6116  nSal = int(oSheet.getCellByPosition(23, sStRange.RangeAddress.StartRow + 1).Value)
6117  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow)
6118  # ~ if stile == 'comp Int_colonna_R_prima':
6119  # ~ lrow += 1
6120 
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) # inserisco le righe
6125  oSheet.copyRange(oCellAddress, oRangeAddress)
6126  # ~oSheet.getCellRangeByPosition(0, lrow, 48, lrow + 5).Rows.OptimalHeight = True
6127  _gotoCella(1, lrow + 1)
6128 
6129  # ~nSal = 1
6130  # ~if oSheet.getCellByPosition(0,lrow).queryIntersection(oSheet.getCellRangeByName('_Lib_'+str(nSal)).getRangeAddress()):
6131  # ~DLG.chi('appartiene')
6132  # ~else:
6133  # ~DLG.chi('nooooo')
6134  # ~return
6135 
6136  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
6137  sopra = sStRange.RangeAddress.StartRow
6138  data = 0.0
6139  for n in reversed(range(0, sopra)):
6140  if oSheet.getCellByPosition(
6141  1, n).CellStyle == 'Ultimus_centro_bordi_lati':
6142  break
6143  if oSheet.getCellByPosition(1, n).CellStyle == 'Data_bianca':
6144  data = oSheet.getCellByPosition(1, n).Value
6145  break
6146  if data == 0.0:
6147  oSheet.getCellByPosition(1, sopra +
6148  2).Value = date.today().toordinal() - 693594
6149  else:
6150  oSheet.getCellByPosition(1, sopra + 2).Value = data
6151 
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)
6168 
6169 
6170  if oDoc.NamedRanges.hasByName('_Lib_' + str(nSal)):
6171  if lrow - 1 == oSheet.getCellRangeByName(
6172  '_Lib_' + str(nSal)).getRangeAddress().EndRow:
6173  nSal += 1
6174 
6175  oSheet.getCellByPosition(23, sopra + 1).Value = nSal
6176  oSheet.getCellByPosition(23, sopra + 1).CellStyle = 'Sal'
6177 
6178  oSheet.getCellByPosition(35, sopra + 4).Formula = '=B' + str(sopra + 2)
6179  oSheet.getCellByPosition(
6180  36, sopra +
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"
6184  if cod:
6185  oSheet.getCellByPosition(1, sopra + 1).String = cod
6186  numera_voci(0)
6187  if cfg.read('Generale', 'pesca_auto') == '1':
6188  if arg == 0:
6189  return
6190  pesca_cod()
6191 
6192 
6193 
6194 
6195 
6197  '''
6198  Riscrive le intestazioni di colonna e le formule dei totali in Elenco Prezzi.
6199  '''
6201  chiudi_dialoghi()
6202 
6203  oDoc = LeenoUtils.getDocument()
6204  oSheet = oDoc.Sheets.getByName('Elenco Prezzi')
6205 
6206  # oDialogo_attesa = dlg_attesa()
6207  # attesa().start() #mostra il dialogo
6208 
6209  struttura_off()
6210  oCellRangeAddr = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
6211  # SR = oCellRangeAddr.StartRow
6212  ER = oCellRangeAddr.EndRow
6213  # SC = oCellRangeAddr.StartColumn
6214  EC = oCellRangeAddr.EndColumn
6215  oSheet.getCellRangeByPosition(11, 3, EC, ER -
6216  1).clearContents(STRING + VALUE + FORMULA)
6217 
6218  oDoc.CurrentController.freezeAtPosition(0, 3)
6219  oSheet.getCellRangeByPosition(0, 0, 100, 0).CellStyle = "Default"
6220  # riscrivo le intestazioni di colonna
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 %'
6229 
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
6257 
6258  y = SheetUtils.uFindStringCol('Fine elenco', 0, oSheet) + 1
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)'
6264  # riga di totale importo COMPUTO
6265  y -= 1
6266  oSheet.getCellByPosition(12, y).String = 'TOTALE'
6267  oSheet.getCellByPosition(13, y).Formula = '=SUBTOTAL(9;N3:N' + str(y) + ')'
6268  # riga di totale importo CONTABILITA'
6269  oSheet.getCellByPosition(16, y).String = 'TOTALE'
6270  oSheet.getCellByPosition(17, y).Formula = '=SUBTOTAL(9;R3:R' + str(y) + ')'
6271  # rem riga di totale importo VARIANTE
6272  oSheet.getCellByPosition(20, y).String = 'TOTALE'
6273  oSheet.getCellByPosition(21, y).Formula = '=SUBTOTAL(9;V3:V' + str(y) + ')'
6274  # rem riga di totale importo PARALLELO
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'
6280 
6281  y += 1
6282  # oSheet.getCellRangeByName('C2').String = 'prezzi'
6283  # oSheet.getCellRangeByName('E2').Formula = '=COUNT(E3:E' + str(y) +')'
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)
6289  # riga_rossa()
6290  # oDialogo_attesa.endExecute()
6291 
6293  # MsgBox('Rigenerazione del foglio eseguita!','')
6294 
6295 
6296 
6298  '''
6299  Riscrive le intestazioni di colonna e le formule dei totali in COMPUTO.
6300  '''
6301  oDoc = LeenoUtils.getDocument()
6302  oSheet = oDoc.Sheets.getByName('COMPUTO')
6303  oDoc.CurrentController.setActiveSheet(oSheet)
6304  oDoc.CurrentController.freezeAtPosition(0, 3)
6305 
6306  lRow = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
6307  # arg = "cancella"
6308  # if arg == "cancella":
6309  # oSheet.Rows.removeByIndex(0, SheetUtils.getUsedArea(oSheet).EndRow+1)
6310 
6311  if LeenoSheetUtils.cercaUltimaVoce(oSheet) == 0:
6312  oRow = SheetUtils.uFindString("TOTALI COMPUTO", oSheet)
6313  try:
6314  lRowE = oRow.CellAddress.Row
6315  except Exception:
6316  lRowE = 3
6317  else:
6318  lRowE = lRow
6319 
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"
6327  # oSheet.getCellRangeByName('C1').CellStyle = 'comp Int_colonna'
6328  # oSheet.getCellRangeByName('C1').CellBackColor = 16762855
6329  # oSheet.getCellRangeByName('C1').String = 'COMPUTO'
6330 
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) + ')' # sicurezza
6334  oSheet.getCellByPosition(
6335  18,
6336  1).Formula = '=SUBTOTAL(9;S3:S' + str(lRowE + 1) + ')' # importo lavori
6337  oSheet.getCellByPosition(0, 1).Formula = '=AK2'
6338 
6339  oSheet.getCellByPosition(
6340  28,
6341  1).Formula = '=SUBTOTAL(9;AC3:AC' + str(lRowE +
6342  1) + ')' # importo materiali
6343 
6344  oSheet.getCellByPosition(29,
6345  1).Formula = '=AE2/S2' # Incidenza manodopera %
6346  oSheet.getCellByPosition(29, 1).CellStyle = "Comp TOTALI %"
6347  oSheet.getCellByPosition(
6348  30,
6349  1).Formula = '=SUBTOTAL(9;AE3:AE' + str(lRowE +
6350  1) + ')' # importo manodopera
6351  oSheet.getCellByPosition(36, 1).Formula = '=SUBTOTAL(9;AK3:AK' + str(
6352  lRowE + 1) + ')' # totale computo sole voci senza errori
6353 
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)
6357 
6358  # rem riga di intestazione
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(
6370  13, 2
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(
6375  24, 2
6376  ).String = 'Incidenza\nsul totale' # POTREBBE SERVIRE PER INDICARE L'INCIDENZA DI OGNI SINGOLA VOCE
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'
6395  # oCell = oSheet.getCellRangeByPosition(0, 0, 43, 2)
6396 
6397  # rem riga del totale
6398  oSheet.getCellByPosition(2, lRowE).String = "TOTALI COMPUTO"
6399  oSheet.getCellByPosition(
6400  17,
6401  lRowE).Formula = "=SUBTOTAL(9;R3:R" + str(lRowE +
6402  1) + ")" # importo sicurezza
6403  oSheet.getCellByPosition(
6404  18, lRowE).Formula = "=SUBTOTAL(9;S3:S" + str(lRowE +
6405  1) + ")" # importo lavori
6406  oSheet.getCellByPosition(29, lRowE).Formula = "=AE" + str(
6407  lRowE + 1) + "/S" + str(lRowE + 1) + "" # Incidenza manodopera %
6408  oSheet.getCellByPosition(30, lRowE).Formula = "=SUBTOTAL(9;AE3:AE" + str(
6409  lRowE + 1) + ")" # importo manodopera
6410  oSheet.getCellByPosition(36, lRowE).Formula = "=SUBTOTAL(9;AK3:AK" + str(
6411  lRowE + 1) + ")" # totale computo sole voci senza errori
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 %"
6416 
6418 
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"
6426  setTabColor(16762855)
6427 
6428 
6429 
6431  '''
6432  @@@ MODIFICA IN CORSO CON 'LeenoAnalysis.inizializzaAnalisi'
6433  Se non presente, crea il foglio 'Analisi di Prezzo' ed inserisce la prima scheda
6434  '''
6435  chiudi_dialoghi()
6436  oDoc = LeenoUtils.getDocument()
6437  SheetUtils.NominaArea(oDoc, 'S5', '$B$108:$P$133', 'blocco_analisi')
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)
6445  setTabColor(12189608)
6446  oRangeAddress = oDoc.NamedRanges.blocco_analisi.ReferredCells.RangeAddress
6447  oCellAddress = oSheet.getCellByPosition(
6448  0,
6449  SheetUtils.getUsedArea(oSheet).EndRow).getCellAddress()
6450  oDoc.CurrentController.select(oSheet.getCellByPosition(0, 2))
6451  oDoc.CurrentController.select(
6452  oDoc.createInstance(
6453  "com.sun.star.sheet.SheetCellRanges")) # unselect
6455  else:
6456  GotoSheet('Analisi di Prezzo')
6457  oSheet = oDoc.Sheets.getByName('Analisi di Prezzo')
6458  oDoc.CurrentController.setActiveSheet(oSheet)
6459  lrow = LeggiPosizioneCorrente()[1]
6460  urow = SheetUtils.getUsedArea(oSheet).EndRow
6461  if lrow >= urow:
6462  lrow = LeenoSheetUtils.cercaUltimaVoce(oSheet) - 5
6463  for n in range(lrow, SheetUtils.getUsedArea(oSheet).EndRow):
6464  if oSheet.getCellByPosition(
6465  0, n).CellStyle == 'An-sfondo-basso Att End':
6466  break
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")) # unselect
6474  oSheet.copyRange(oCellAddress, oRangeAddress)
6478 
6479 
6480 
6481 
6482 
6484  '''
6485  Inserisce la riga rossa di chiusura degli elaborati
6486  Questa riga è un riferimento per varie operazioni
6487  '''
6488  oDoc = LeenoUtils.getDocument()
6489  oSheet = oDoc.CurrentController.ActiveSheet
6491 
6492 
6493 def struct_colore(level):
6494  '''
6495  Mette in vista struttura secondo il colore
6496  level { integer } : specifica il livello di categoria
6497  '''
6499  oDoc = LeenoUtils.getDocument()
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
6505  # giallo(16777072,16777120,16777168)
6506  # verde(9502608,13696976,15794160)
6507  # viola(12632319,13684991,15790335)
6508  col0 = 16724787 # riga_rossa
6509  col1 = 16777072
6510  col2 = 16777120
6511  col3 = 16777168
6512  col4 = 12632319
6513  # attribuisce i colori
6514  for y in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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
6523  if level == 0:
6524  colore = col1
6525  myrange = (col1, col0)
6526  elif level == 1:
6527  colore = col2
6528  myrange = (col1, col2, col0)
6529  elif level == 2:
6530  colore = col3
6531  myrange = (col1, col2, col3, col0)
6532  elif level == 3:
6533  colore = col0
6534  myrange = (col1, col2, col3, col4, col0)
6535 
6536  for n in (3, 7):
6537  oCellRangeAddr.StartColumn = n
6538  oCellRangeAddr.EndColumn = n
6539  oSheet.group(oCellRangeAddr, 0)
6540  oSheet.getCellRangeByPosition(n, 0, n, 0).Columns.IsVisible = False
6541  test = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
6542  # attiva la progressbar
6543  progress = Dialogs.Progress(Title='Rigenerazione in corso...', Text="Lettura dati")
6544  progress.setLimits(0, test)
6545  progress.setValue(0)
6546  progress.show()
6547  lista = list()
6548  x = 0
6549  for n in range(0, test):
6550  x += 1
6551  progress.setValue(x)
6552  if oSheet.getCellByPosition(0, n).CellBackColor == colore:
6553  oSheet.getCellByPosition(0, n).Rows.Height = hriga
6554  sopra = n + 1
6555  for n in range(sopra + 1, test):
6556  if oSheet.getCellByPosition(0, n).CellBackColor in myrange:
6557  sotto = n - 1
6558  lista.append((sopra, sotto))
6559  break
6560  for el in lista:
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
6567  progress.hide()
6568  return
6569 
6570 
6571 
6573  '''
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.
6576  '''
6577  chiudi_dialoghi()
6578 
6579  if Dialogs.YesNoDialog(Title='AVVISO!',
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.
6583 
6584 L'OPERAZIONE POTREBBE RICHIEDERE DEL TEMPO E
6585 LibreOffice POTREBBE SEMBRARE BLOCCATO!
6586 
6587 Vuoi procedere comunque?''') == 0:
6588  return
6589 
6590  oDoc = LeenoUtils.getDocument()
6591  oSheet = oDoc.CurrentController.ActiveSheet
6592  oSheet.clearOutline()
6593  struct_colore(0) # attribuisce i colori
6594  struct_colore(1)
6595  struct_colore(2)
6596  struct_colore(3)
6597  return
6598 
6599 
6600 
6603 
6604 
6607 
6608 
6611 
6612 
6615 
6616 
6619 
6620 
6623 
6624 
6626  '''
6627  @@ DA DOCUMENTARE
6628  '''
6630  oDoc = LeenoUtils.getDocument()
6631  oSheet = oDoc.CurrentController.ActiveSheet
6632  # giallo(16777072,16777120,16777168)
6633  # verde(9502608,13696976,15794160)
6634  # viola(12632319,13684991,15790335)
6635  col1 = 16777072
6636  col2 = 16777120
6637  col3 = 16777168
6638  try:
6639  inizio = SheetUtils.uFindStringCol('ATTENZIONE!', 5, oSheet) + 1
6640  except:
6641  inizio = 5
6642  fine = SheetUtils.getUsedArea(oSheet).EndRow + 1
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
6651 
6652 
6653 
6655  '''
6656  Importa tutti gli stili da un documento di riferimento. Se non è
6657  selezionato, il file di riferimento è il template di leenO.
6658  '''
6660 
6661  if Dialogs.YesNoDialog(Title='Importa Stili in blocco?',
6662  Text='''Questa operazione sovrascriverà gli stili
6663 del documento attivo, se già presenti!
6664 
6665 Se non scegli un file di riferimento, saranno
6666 importati gli stili di default di LeenO.
6667 
6668 Vuoi continuare?''') == 0:
6669  return
6670  filename = Dialogs.FileSelect('Scegli il file di riferimento...', '*.ods')
6671  if filename is None:
6672  # desktop = LeenoUtils.getDesktop()
6673  filename = LeenO_path() + '/template/leeno/Computo_LeenO.ots'
6674  else:
6675  filename = uno.systemPathToFileUrl(filename)
6676  oDoc = LeenoUtils.getDocument()
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)
6683  GotoSheet(nome)
6685 
6686 
6687 
6689  '''
6690  Inserisce una riga con l'indicazione della somma parziale.
6691  '''
6693  oDoc = LeenoUtils.getDocument()
6694  oSheet = oDoc.CurrentController.ActiveSheet
6695  lrow = LeggiPosizioneCorrente()[1]
6696  if oSheet.getCellByPosition(1, lrow-1).CellStyle in ('comp Art-EP_R') or \
6697  lrow == 0:
6698  return
6699  if oSheet.Name in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
6700  parziale_core(oSheet, lrow)
6701  rigenera_parziali(False)
6703 
6704 
6705 
6706 def parziale_core(oSheet, lrow):
6707  '''
6708  lrow { double } : id della riga di inserimento
6709  '''
6710  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
6711  sopra = sStRange.RangeAddress.StartRow
6712  # sotto = sStRange.RangeAddress.EndRow
6713  if oSheet.Name in ('COMPUTO', 'VARIANTE'):
6714  if(oSheet.getCellByPosition(2, lrow).String == '' and
6715  oSheet.getCellByPosition(9, lrow).String == ''):
6716  pass
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)
6722 
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'):
6733  # i
6734  break
6735  oSheet.getCellByPosition(9, lrow).Formula = "=SUBTOTAL(9;J" + str(i) + ":J" + str(lrow + 1) + ")"
6736 
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 == ''):
6741  pass
6742 
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"):
6751  return
6752 
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());"]")'
6761 
6762  i = lrow
6763  while i > 0:
6764  if oSheet.getCellByPosition(
6765  9,
6766  i - 1).CellStyle in ('vuote2', 'Comp-Variante num sotto'):
6767  da = i
6768  break
6769  i -= 1
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 +
6773  1) + ')'
6774 
6775 
6776 
6777 def vedi_voce_xpwe(oSheet, lrow, vRif):
6778  """
6779  (riga d'inserimento, riga di riferimento)
6780  """
6781  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, vRif)
6782  # sStRange.RangeAddress
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())'
6791 
6792  # if oSheet.Name == 'CONTABILITA':
6793  # sformula = '=CONCATENATE("";"- vedi voce n.";TEXT(' + idvoce +';"@");" - art. ";' + art + ';" [";' + um + ';"]"'
6794  # else:
6795  sformula = ('=CONCATENATE("";"- vedi voce n.";TEXT(' +
6796  idvoce + ';"@");" - art. ";' +
6797  art +
6798  ';" - ";LEFT(' +
6799  des +
6800  ';$S1.$H$334);"... [";' +
6801  um + ';" ";TEXT(' +
6802  quantity + ';"0,00");"]";)')
6803  oSheet.getCellByPosition(2, lrow).Formula = sformula
6804  # aggiunge commento, annotazione
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
6808  if '-' in val:
6809  # ~if oSheet.Name == 'CONTABILITA':
6810  # ~oSheet.getCellByPosition(11, lrow).Formula = (
6811  # ~'=IF(PRODUCT(E' + str(lrow + 1) + ':I' + str(lrow + 1) +
6812  # ~')>=0;"";PRODUCT(E' + str(lrow + 1) + ':I' +
6813  # ~str(lrow + 1) + ')*-1)')
6814  # ~oSheet.getCellByPosition(9, lrow).String = ''
6815  # ~if oSheet.Name in ('COMPUTO', 'VARIANTE'):
6816  # ~oSheet.getCellByPosition(9, lrow).Formula = (
6817  # ~'=IF(PRODUCT(E' + str(lrow + 1) + ':I' + str(lrow + 1) +
6818  # ~')=0;"";PRODUCT(E' + str(lrow + 1) + ':I' + str(lrow + 1) + '))')
6819  for x in range(2, 12):
6820  oSheet.getCellByPosition(x, lrow).CellStyle = (
6821  oSheet.getCellByPosition(x, lrow).CellStyle + ' ROSSO')
6822  return '-'
6823 
6824 
6826  '''
6827  Inserisce un riferimento a voce precedente sulla riga corrente.
6828  '''
6829  oDoc = LeenoUtils.getDocument()
6830  oSheet = oDoc.CurrentController.ActiveSheet
6831  lrow = LeggiPosizioneCorrente()[1]
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'):
6835  copia_riga_computo(lrow)
6836  elif oSheet.Name in ('CONTABILITA'):
6837  copia_riga_contab(lrow)
6838  lrow += 1
6839  if oSheet.getCellByPosition(2, lrow).CellStyle == 'comp 1-a':
6840  to = basic_LeenO('ListenersSelectRange.getRange',
6841  "Seleziona voce di riferimento o indica n. d'ordine")
6842  if oSheet.Name not in to:
6843  to = '$' + oSheet.Name + '.$C$' + str(SheetUtils.uFindStringCol(to, 0, oSheet))
6844  try:
6845  to = int(to.split('$')[-1]) - 1
6846  except ValueError:
6847  return
6848  _gotoCella(2, lrow)
6849  # focus = oDoc.CurrentController.getFirstVisibleRow
6850  if to < lrow:
6851  vedi_voce_xpwe(oSheet, lrow, to)
6852 
6853 
6854 def strall(el, n=3, pos=0):
6855  '''
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
6860 
6861  '''
6862  # el ='o'
6863  if pos == 0:
6864  el = n * '0' + el
6865  else:
6866  el = el + n * '0'
6867  return el
6868 
6869 
6870 
6871 
6872 
6873 def setFormatoNumeri(valore):
6874  '''
6875  valore { integer } : id formato
6876  attribuisce alla selezione di celle un formato numerico a scelta
6877  valore = 36 (dd/mm/yyyy)
6878  '''
6879 
6881  desktop = LeenoUtils.getDesktop()
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,
6890  properties)
6891 
6893  '''
6894  Converte in numeri le stringhe o viceversa.
6895  '''
6896  oDoc = LeenoUtils.getDocument()
6897  oSheet = oDoc.CurrentController.ActiveSheet
6898  try:
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:
6909  setFormatoNumeri(36) #imposta il formato numerico data dd/mm/yyyy
6910  for y in range(sCol, eCol + 1):
6911  for x in range(sRow, eRow + 1):
6912  try:
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
6917  else:
6918  oSheet.getCellByPosition(y, x).Value = float(
6919  oSheet.getCellByPosition(y,
6920  x).String.replace(',', '.'))
6921  else:
6922  oSheet.getCellByPosition(
6923  y, x).String = oSheet.getCellByPosition(y, x).String
6924  except Exception:
6925  pass
6926  return
6927 
6928 
6929 
6930 
6931 
6933  '''
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
6936  '''
6937  oDoc = LeenoUtils.getDocument()
6938  if not oDoc.getSheets().hasByName('M1'):
6939  return
6940  try:
6941  LeenoUtils.getGlobalVar('oDlgMain').endExecute()
6942  except NameError:
6943  pass
6944  if len(oDoc.getURL()) == 0:
6945  Dialogs.Exclamation(Title = 'ATTENZIONE!',
6946  Text='''Prima di procedere, devi salvare il lavoro!
6947 Provvedi subito a dare un nome al file.''')
6948  salva_come()
6949  autoexec()
6950  try:
6951  LeenoUtils.setGlobalVar('sUltimus', uno.fileUrlToSystemPath(oDoc.getURL()))
6952  except Exception:
6953  pass
6954  DlgMain()
6955  return
6956 
6957 
6962 def get_Formula(n, a, b):
6963  """
6964  n { integer } : posizione cella
6965  a { string } : primo parametro da sostituire
6966  b { string } : secondo parametro da sostituire
6967  """
6968  v = dict(n=n, a=a, b=b)
6969  formulas = {
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)'
6974  }
6975  return formulas[n] % v
6976 
6977 
6978 def getCellStyle(level, pos):
6979  """
6980  level { integer } : livello(1 o 2)
6981  pos { integer } : posizione cella
6982  """
6983  styles = {
6984  2: {
6985  18: 'livello2 scritta mini',
6986  24: 'livello2 valuta mini %',
6987  29: 'livello2 valuta mini %',
6988  30: 'livello2 valuta mini'
6989  },
6990  1: {
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'
6995  }
6996  }
6997  return styles[level][pos]
6998 
6999 
7000 def SubSum(lrow, sub=False):
7001  """ Inserisce i dati nella riga
7002  sub { boolean } : specifica se sotto-categoria
7003  """
7004  if sub:
7005  myrange = (
7006  'livello2 scritta mini',
7007  'Livello-1-scritta minival',
7008  'Comp TOTALI',
7009  )
7010  level = 2
7011  else:
7012  myrange = (
7013  'Livello-1-scritta mini val',
7014  'Comp TOTALI',
7015  )
7016  level = 1
7017 
7018  oDoc = LeenoUtils.getDocument()
7019  oSheet = oDoc.CurrentController.ActiveSheet
7020  if oSheet.Name not in ('COMPUTO', 'VARIANTE'):
7021  return
7022  lrowE = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
7023  nextCap = lrowE
7024  for n in range(lrow + 1, lrowE):
7025  if oSheet.getCellByPosition(18, n).CellStyle in myrange:
7026  nextCap = n + 1
7027  break
7028  for n, a, b in (
7029  (
7030  18,
7031  lrow + 1,
7032  nextCap,
7033  ),
7034  (
7035  24,
7036  lrow + 1,
7037  lrowE + 1,
7038  ),
7039  (
7040  29,
7041  lrow + 1,
7042  lrowE + 1,
7043  ),
7044  (
7045  30,
7046  lrow + 1,
7047  nextCap,
7048  ),
7049  ):
7050  oSheet.getCellByPosition(n, lrow).Formula = get_Formula(n, a, b)
7051  oSheet.getCellByPosition(18, lrow).CellStyle = getCellStyle(level, n)
7052 
7053 
7054 
7057 
7058 
7060  '''
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'
7063  '''
7064  filtra_codice()
7065 
7066 
7067 def filtra_codice(voce=None):
7068  '''
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'
7071  '''
7072  oDoc = LeenoUtils.getDocument()
7073  # ~oDoc.enableAutomaticCalculation(False)
7075 
7076  oSheet = oDoc.CurrentController.ActiveSheet
7077 
7078  stili_computo = LeenoUtils.getGlobalVar('stili_computo')
7079  stili_contab = LeenoUtils.getGlobalVar('stili_contab')
7080 
7081  if oSheet.Name == "Elenco Prezzi":
7082  oCell = oSheet.getCellRangeByName('C2')
7083  voce = oDoc.Sheets.getByName('Elenco Prezzi').getCellByPosition(
7084  0, LeggiPosizioneCorrente()[1]).String
7085 
7086  # colora la descrizione scelta
7087  # ~oDoc.Sheets.getByName('Elenco Prezzi').getCellByPosition(
7088  # ~1, LeggiPosizioneCorrente()[1]).CellBackColor = 16777120
7089 
7090  if oCell.String == '<DIALOGO>' or oCell.String == '':
7091  try:
7092  elaborato = DLG.ScegliElaborato('Ricerca di ' + voce)
7093  GotoSheet(elaborato)
7094  except Exception:
7095  return
7096  else:
7097  elaborato = oSheet.getCellByPosition(2, 1).String
7098  try:
7099  GotoSheet(elaborato)
7100  except Exception:
7101  return
7102  oSheet = oDoc.Sheets.getByName(elaborato)
7103  _gotoCella(0, 6)
7105  oSheet.clearOutline()
7106  lrow = LeggiPosizioneCorrente()[1]
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
7112  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, lrow)
7113  sopra = sStRange.RangeAddress.StartRow
7114  if not voce:
7115  voce = oSheet.getCellByPosition(1, sopra + 1).String
7116  else:
7117  # ~DLG.MsgBox('Devi prima selezionare una voce di misurazione.', 'Avviso!')
7118  Dialogs.Exclamation(Title = 'ATTENZIONE!',
7119  Text='''Devi prima selezionare una voce di misurazione.''')
7120  return
7121  fine = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
7122 
7123  progress = Dialogs.Progress(Title='Applicazione filtro in corso...', Text="Lettura dati")
7124  progress.setLimits(0, fine)
7125  progress.setValue(0)
7126  progress.show()
7127 
7128  qui = None
7129  lista_pt = list()
7130  _gotoCella(0, 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'):
7136  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, n)
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))
7141  else:
7142 
7143  # ~# colora lo sfondo della voce filtrata
7144  # ~oSheet.getCellRangeByPosition(0, sopra, 40, sotto).CellBackColor = 16777120
7145 
7146  if qui == None:
7147  qui = sopra + 1
7148  progress.setValue(fine)
7149  for el in lista_pt:
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
7155  try:
7156  _gotoCella(0, qui)
7157  except:
7158  struttura_off()
7159  progress.hide()
7160  GotoSheet("Elenco Prezzi")
7161  Dialogs.Exclamation(Title = 'Ricerca conclusa', Text='Nessuna corrispondenza trovata')
7162  # ~oDoc.enableAutomaticCalculation(True)
7164  progress.hide()
7165 
7166 
7167 
7169  oDoc = LeenoUtils.getDocument()
7171  oSheet = oDoc.CurrentController.ActiveSheet
7172 
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'):
7182 
7184  '''
7185  @@ DA DOCUMENTARE
7186  '''
7187  oDoc = LeenoUtils.getDocument()
7188  oSheet = oDoc.CurrentController.ActiveSheet
7189  oSheet.clearOutline()
7190  # ~# attiva la progressbar
7191  progress = Dialogs.Progress(Title='Creazione vista struttura in corso...', Text="Lettura dati")
7192  progress.setLimits(0, 5)
7193  progress.setValue(0)
7194  progress.show()
7195  Rinumera_TUTTI_Capitoli2(oSheet)
7196  progress.setValue(1)
7197  struct(0)
7198  progress.setValue(2)
7199  struct(1)
7200  progress.setValue(3)
7201  struct(2)
7202  progress.setValue(4)
7203  struct(3)
7204  progress.setValue(5)
7205  progress.hide()
7206 
7207 
7209  '''
7210  @@ DA DOCUMENTARE
7211  '''
7212  oDoc = LeenoUtils.getDocument()
7213  oSheet = oDoc.CurrentController.ActiveSheet
7214  oSheet.clearOutline()
7215  struct(4)
7216 
7217 
7219  '''
7220  Cancella la vista in struttura
7221  '''
7222  struttura_off()
7223 
7224 
7226  '''
7227  Cancella la vista in struttura
7228  '''
7229  oDoc = LeenoUtils.getDocument()
7230  x = LeggiPosizioneCorrente()[0]
7231  lrow = LeggiPosizioneCorrente()[1]
7232  oSheet = oDoc.CurrentController.ActiveSheet
7233  oSheet.clearOutline()
7234  oDoc.CurrentController.setFirstVisibleColumn(0)
7235  oDoc.CurrentController.setFirstVisibleRow(lrow - 4)
7236  _gotoCella( x, lrow)
7237 
7238 
7239 def struct(level):
7240  ''' mette in vista struttura secondo categorie
7241  level { integer } : specifica il livello di categoria
7242  ### COMPUTO/VARIANTE ###
7243  0 = super-categoria
7244  1 = categoria
7245  2 = sotto-categoria
7246  3 = intera voce di misurazione
7247  ### ANALISI ###
7248  4 = simile all'elenco prezzi
7249  '''
7250  oDoc = LeenoUtils.getDocument()
7251  oSheet = oDoc.CurrentController.ActiveSheet
7252  iSheet = oSheet.RangeAddress.Sheet
7253  oCellRangeAddr = uno.createUnoStruct('com.sun.star.table.CellRangeAddress')
7254  oCellRangeAddr.Sheet = iSheet
7255 
7256  if level == 0:
7257  stile = 'Livello-0-scritta'
7258  myrange = (
7259  'Livello-0-scritta',
7260  'Comp TOTALI',
7261  )
7262  Dsopra = 1
7263  Dsotto = 1
7264  elif level == 1:
7265  stile = 'Livello-1-scritta'
7266  myrange = (
7267  'Livello-1-scritta',
7268  'Livello-0-scritta',
7269  'Comp TOTALI',
7270  )
7271  Dsopra = 1
7272  Dsotto = 1
7273  elif level == 2:
7274  stile = 'livello2 valuta'
7275  myrange = (
7276  'livello2 valuta',
7277  'Livello-1-scritta',
7278  'Livello-0-scritta',
7279  'Comp TOTALI',
7280  )
7281  Dsopra = 1
7282  Dsotto = 1
7283  elif level == 3:
7284  stile = 'Comp Start Attributo'
7285  myrange = (
7286  'Comp End Attributo',
7287  'Comp TOTALI',
7288  )
7289  Dsopra = 2
7290  Dsotto = 1
7291 
7292  elif level == 4: # Analisi di Prezzo
7293  stile = 'An-1_sigla'
7294  myrange = (
7295  'An.1v-Att Start',
7296  'Analisi_Sfondo',
7297  )
7298  Dsopra = 1
7299  Dsotto = -1
7300  # ~for n in(3, 5, 7):
7301  # ~oCellRangeAddr.StartColumn = n
7302  # ~oCellRangeAddr.EndColumn = n
7303  # ~oSheet.group(oCellRangeAddr,0)
7304  # ~oSheet.getCellRangeByPosition(n, 0, n, 0).Columns.IsVisible=False
7305 
7306  test = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 2
7307  lista_cat = list()
7308  for n in range(0, test):
7309  if oSheet.getCellByPosition(0, n).CellStyle == stile:
7310  sopra = n + Dsopra
7311  for n in range(sopra + 1, test):
7312  if oSheet.getCellByPosition(0, n).CellStyle in myrange:
7313  sotto = n - Dsotto
7314  lista_cat.append((sopra, sotto))
7315  break
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
7321 
7322 
7323 
7325  '''
7326  @@ DA DOCUMENTARE
7327  '''
7328  apri = LeenoUtils.createUnoService("com.sun.star.system.SystemShellExecute")
7329  apri.execute(LeenO_path() + '/MANUALE_LeenO.pdf', "", 0)
7330 
7331 
7332 
7334  '''
7335  @@ DA DOCUMENTARE
7336  '''
7338  Toolbars.Switch(True)
7339  oDoc = LeenoUtils.getDocument()
7340  Toolbars.AllOff()
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'):
7345  try:
7346  oSheet = oDoc.Sheets.getByName(el)
7347  oSheet.getCellRangeByName("A1:AT1").clearContents(EDITATTR +
7348  FORMATTED +
7349  HARDATTR)
7350  oSheet.getCellRangeByName("A1").String = ''
7351  except Exception:
7352  pass
7354 
7355 
7356 class trun(threading.Thread):
7357  '''Avvia processi automatici ad intervalli definiti di tempo'''
7358  def __init__(self):
7359  threading.Thread.__init__(self)
7360 
7361  def run(self):
7362  while True:
7363  minuti = 60 * int(cfg.read('Generale', 'pausa_backup'))
7364  time.sleep(minuti)
7365  bak()
7366 
7367 
7368 def autorun():
7369  '''
7370  @@ DA DOCUMENTARE
7371  '''
7372  # ~global utsave
7373  if int(cfg.read('Generale', 'copie_backup')) != 0:
7374  utsave = trun()
7375  utsave._stop()
7376  utsave.start()
7377  else:
7378  try:
7379  utsave._stop()
7380  utsave = False
7381  except:
7382  pass
7383 
7384 
7385 
7386 def autoexec():
7387  '''
7388  questa è richiamata da creaComputo()
7389  '''
7392  inizializza()
7395  # rinvia a autoexec in basic
7396  basic_LeenO('_variabili.autoexec')
7397  bak0()
7398  autorun()
7400  oGSheetSettings = ctx.ServiceManager.createInstanceWithContext("com.sun.star.sheet.GlobalSheetSettings", ctx)
7401  # Usa i parametri della stampante per la formattazione del testo
7402  oGSheetSettings.UsePrinterMetrics = True
7403 
7404  # attiva 'copia di backup', ma dall'apertura successiva di LibreOffice
7405  node = GetRegistryKeyContent("/org.openoffice.Office.Common/Save/Document", True)
7406  node.CreateBackup = True
7407  node.commitChanges()
7408  uso = int(cfg.read('Generale', 'conta_usi')) + 1
7409 
7410  if uso == 10 or (uso % 50) == 0:
7411  dlg_donazioni()
7412  cfg.write('Generale', 'conta_usi', str(uso))
7413  if cfg.read('Generale', 'movedirection') == '0':
7414  oGSheetSettings.MoveDirection = 0
7415  else:
7416  oGSheetSettings.MoveDirection = 1
7417  oDoc = LeenoUtils.getDocument()
7418  # RegularExpressions Wildcards are mutually exclusive, only one can have the value TRUE.
7419  # If both are set to TRUE via API calls then the last one set takes precedence.
7420  try:
7421  oDoc.Wildcards = False
7422  except Exception:
7423  pass
7424  oDoc.RegularExpressions = False
7425  oDoc.CalcAsShown = True # precisione come mostrato
7426  adegua_tmpl() # esegue degli aggiustamenti del template
7427  oSheet = oDoc.CurrentController.ActiveSheet
7428  for nome in ('VARIANTE', 'CONTABILITA', 'COMPUTO'):
7429  try:
7430  GotoSheet(nome)
7431  subst_str(' >(', ' ►(')
7432  except Exception:
7433  pass
7434  GotoSheet(oSheet.Name)
7435  Toolbars.Vedi()
7438  # if len(oDoc.getURL()) != 0:
7439  # scegli cosa visualizzare all'avvio:
7440  # vedi = conf.read(path_conf, 'Generale', 'visualizza')
7441  # if vedi == 'Menù Principale':
7442  # DlgMain()
7443  # elif vedi == 'Dati Generali':
7444  # vai_a_variabili()
7445  # elif vedi in('Elenco Prezzi', 'COMPUTO'):
7446  # GotoSheet(vedi)
7447 
7448 
7449 #
7450 
7452  '''
7453  Settaggio base di configurazione colonne in COMPUTO e VARIANTE
7454  '''
7455  oDoc = LeenoUtils.getDocument()
7457 
7458  oSheet = oDoc.CurrentController.ActiveSheet
7459 
7460  # raggruppo le colonne
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'):
7466  col = 46
7467  elif oSheet.Name == 'CONTABILITA':
7468  col = 39
7469  oCellRangeAddr.StartColumn = col
7470  oCellRangeAddr.EndColumn = ncol
7471  oSheet.ungroup(oCellRangeAddr, 0)
7472  oSheet.group(oCellRangeAddr, 0)
7473 
7474  oSheet.getCellRangeByPosition(col, 0, ncol -1, 0).Columns.IsVisible = False
7477 
7478 
7479 
7480 
7481 
7483  '''
7484  Apre un nuovo foglio e vi inserisce tutti gli stili di cella
7485  con relativo esempio
7486  '''
7487  oDoc = LeenoUtils.getDocument()
7488  sty = oDoc.StyleFamilies.getByName("CellStyles").getElementNames()
7489  if oDoc.Sheets.hasByName("stili"):
7490  oSheet = oDoc.Sheets.getByName("stili")
7491  else:
7492  sheet = oDoc.createInstance("com.sun.star.sheet.Spreadsheet")
7493  unione = oDoc.Sheets.insertByName('stili', sheet)
7494  oSheet = oDoc.Sheets.getByName("stili")
7495  GotoSheet("stili")
7496  # attiva la progressbar
7497  progress = Dialogs.Progress(Title='Stili cella', Text="Scrittura in corso...")
7498  progress.setLimits(0, len(sty))
7499  progress.show()
7500  i = 0
7501  sty = sorted(sty)
7502  for el in 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"
7508  i += 2
7509  progress.setValue(i)
7510  progress.hide()
7511 
7512 
7514  '''
7515  @@ DA DOCUMENTARE
7516  '''
7517  oDoc = LeenoUtils.getDocument()
7518  stili = oDoc.StyleFamilies.getByName('CellStyles').getElementNames()
7519  for el in stili:
7520  if not oDoc.StyleFamilies.getByName('CellStyles').getByName(el).isInUse():
7521  oDoc.StyleFamilies.getByName('CellStyles').removeByName(el)
7522 
7523 
7524 
7526  '''
7527  Inserisce tutti i dati e gli stili per preparare il lavoro.
7528  lanciata in autoexec()
7529  '''
7530  oDoc = LeenoUtils.getDocument()
7531 
7532  # oDoc.IsUndoEnabled = False
7533  oDoc.getSheets().getByName('copyright_LeenO').getCellRangeByName(
7534  'A3').String = '# © 2001-2013 Bartolomeo Aimar - © 2014-' + str(
7535  datetime.now().year) + ' Giuseppe Vizziello'
7536 
7537  oUDP = oDoc.getDocumentProperties().getUserDefinedProperties()
7538  oSheet = oDoc.getSheets().getByName('S1')
7539 
7540  oSheet.getCellRangeByName('G219').String = 'Copyright 2014-' + str(datetime.now().year)
7541 
7542  # allow non-numeric version codes (example: testing)
7543  rvc = version_code.read().split('-')[0]
7544  if isinstance(rvc, str):
7545  oSheet.getCellRangeByName('H194').String = rvc
7546  else:
7547  oSheet.getCellRangeByName('H194').Value = rvc
7548 
7549  oSheet.getCellRangeByName('I194').Value = LeenoUtils.getGlobalVar('Lmajor')
7550  oSheet.getCellRangeByName('J194').Value = LeenoUtils.getGlobalVar('Lminor')
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]
7554 
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]
7558 
7559  oSheet.getCellRangeByName('K194').String = LeenoUtils.getGlobalVar('Lsubv')
7560  oSheet.getCellRangeByName('H296').Value = LeenoUtils.getGlobalVar('Lmajor')
7561  oSheet.getCellRangeByName('I296').Value = LeenoUtils.getGlobalVar('Lminor')
7562  oSheet.getCellRangeByName('J296').String = LeenoUtils.getGlobalVar('Lsubv')
7563 
7564  if oDoc.getSheets().hasByName('CONTABILITA'):
7565  oSheet.getCellRangeByName('H328').Value = 1
7566  else:
7567  oSheet.getCellRangeByName('H328').Value = 0
7568 
7569 # inizializza la lista di scelta in elenco Prezzi
7570  oCell = oDoc.getSheets().getByName('Elenco Prezzi').getCellRangeByName('C2')
7571  valida_cella(oCell,
7572  '"<DIALOGO>";"COMPUTO";"VARIANTE";"CONTABILITA"',
7573  titoloInput='Scegli...',
7574  msgInput='Applica Filtra Codice a...',
7575  err=True)
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'
7581 # inizializza la lista di scelta per la copertona cP_Cop
7582  oCell = oDoc.getSheets().getByName('cP_Cop').getCellRangeByName('B19')
7583  # ~if oCell.String == '';
7584  valida_cella(oCell,
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...',
7590  err=False)
7591  # ~oCell.String = ""
7592  # Indica qual è il Documento Principale
7594  # ~nascondi_sheets()
7595 
7596 
7597 
7599  '''
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
7613  '''
7615  oDoc = LeenoUtils.getDocument()
7616  oDoc.enableAutomaticCalculation(False)
7617  # LE VARIABILI NUOVE VANNO AGGIUNTE IN config_default()
7618  # cambiare stile http://bit.ly/2cDcCJI
7619  ver_tmpl = oDoc.getDocumentProperties().getUserDefinedProperties().Versione
7620  if ver_tmpl > 200:
7621  basic_LeenO('_variabili.autoexec') # rinvia a autoexec in basic
7622 
7623  adegua_a = 217 # VERSIONE CORRENTE
7624 
7625  if ver_tmpl < adegua_a:
7626  if Dialogs.YesNoDialog(Title='Informazione',
7627  Text= '''Vuoi procedere con l'adeguamento di questo file
7628 alla versione di LeenO installata?''') == 0:
7629  Dialogs.Exclamation(Title = 'Avviso!',
7630  Text='''Non avendo effettuato l'adeguamento del file alla versione
7631 di LeenO installata, potresti avere dei malfunzionamenti!''')
7632 
7633  return
7635  if oDoc.getSheets().hasByName('S4'):
7636  oDoc.Sheets.removeByName('S4')
7637  # attiva la progressbar
7638  progress = Dialogs.Progress(Title='Adeguamento del lavoro in corso...',
7639  Text="Lettura dati")
7640  progress.setLimits(0, 10)
7641  progress.setValue(0)
7642  progress.show()
7643 
7644 
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(
7653  el, oStileCella)
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
7666 
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
7680  # dal template 212
7681  flags = VALUE + DATETIME + STRING + ANNOTATION + FORMULA + OBJECTS + EDITATTR # FORMATTED + HARDATTR
7682  progress.setValue(4)
7683  GotoSheet('M1')
7684  oSheet = oDoc.getSheets().getByName('M1')
7685  oSheet.getCellRangeByName('B23:E30').clearContents(flags)
7686  oSheet.getCellRangeByName('B23:E30').CellStyle = 'M1 scritte noP'
7687  # dal template 208
7688  # > adegua le formule delle descrizioni di voci
7689  GotoSheet('S1')
7690  oSheet = oDoc.getSheets().getByName('S1')
7691  oSheet.getCellRangeByName(
7692  'G334'
7693  ).String = '[Computo e Variante] Vedi Voce: PRIMI caratteri della voce'
7694  oSheet.getCellRangeByName('H334').Value = 50
7695  oSheet.getCellRangeByName(
7696  'I334'
7697  ).String = "Quanti caratteri della descrizione vuoi visualizzare usando il Vedi Voce?"
7698  oSheet.getCellRangeByName(
7699  'G335'
7700  ).String = '[Contabilità] Descrizioni abbreviate: PRIMI caratteri della voce'
7701  oSheet.getCellRangeByName('H335').Value = 100
7702  oSheet.getCellRangeByName(
7703  'I335'
7704  ).String = "Quanti caratteri vuoi visualizzare partendo dall'INIZIO della descrizione?"
7705  oSheet.getCellRangeByName(
7706  'G336'
7707  ).String = 'Descrizioni abbreviate: primi caratteri della voce'
7708  oSheet.getCellRangeByName('H336').Value = 120
7709  oSheet.getCellRangeByName(
7710  'I336'
7711  ).String = "[Contabilità] Descrizioni abbreviate: ULTIMI caratteri della voce"
7712  oSheet.getCellRangeByName(
7713  'G337'
7714  ).String = 'Descrizioni abbreviate: primi caratteri della voce'
7715  oSheet.getCellRangeByName('H337').Value = 100
7716  oSheet.getCellRangeByName(
7717  'I337'
7718  ).String = "Quanti caratteri vuoi visualizzare partendo dall'INIZIO della descrizione?"
7719  oSheet.getCellRangeByName(
7720  'G338'
7721  ).String = 'Descrizioni abbreviate: ultimi caratteri della voce'
7722  oSheet.getCellRangeByName('H338').Value = 120
7723  oSheet.getCellRangeByName(
7724  'I338'
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(
7734  'Setvar C_3').NumberFormat = LeenoFormat.getNumFormat('0,00%') # percentuale
7735  # < adegua le formule delle descrizioni di voci
7736  # dal 209 cambia nome di custom propierty
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,
7744  str(LeenoUtils.getGlobalVar('Lmajor')) + '.' +
7745  str(LeenoUtils.getGlobalVar('Lminor')) + '.x')
7746  progress.setValue(5)
7747  for el in ('COMPUTO', 'VARIANTE'):
7748  if oDoc.getSheets().hasByName(el):
7749  GotoSheet(el)
7750  oSheet = oDoc.getSheets().getByName(el)
7751  # sposto il vedivoce nella colonna E
7752  fine = SheetUtils.getUsedArea(oSheet).EndRow
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,
7761  n).Formula
7762  oSheet.getCellByPosition(5, n).String = ''
7763  oSheet.getCellByPosition(
7764  9, n
7765  ).Formula = '=IF(PRODUCT(E' + str(n + 1) + ':I' + str(
7766  n + 1) + ')=0;"";PRODUCT(E' + str(
7767  n + 1) + ':I' + str(n + 1) + '))'
7768  # sposto il vedivoce nella colonna E/
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 €'
7773  lrow = 4
7774  while lrow < n:
7775  oDoc.CurrentController.select(
7776  oSheet.getCellByPosition(0, lrow))
7777  sistema_stili()
7778  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 1)
7779  lrow += 1
7780  rigenera_tutte() # affido la rigenerazione delle formule al menu Viste
7781  # 214 aggiorna stili di cella per ogni colonna
7782  test = SheetUtils.getUsedArea(oSheet).EndRow + 1
7783  for y in range(0, test):
7784  # aggiorna formula vedi voce #214
7785  if ver_tmpl > 214:
7786  break
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'):
7790  try:
7791  vRif = int(
7792  oSheet.getCellByPosition(
7793  5, y).Formula.split('=J$')[-1]) - 1
7794  except Exception:
7795  vRif = int(
7796  oSheet.getCellByPosition(
7797  5, y).Formula.split('=J')[-1]) - 1
7798  if oSheet.getCellByPosition(9, y).Value < 0:
7799  _gotoCella(2, y)
7800  inverti = 1
7801  oSheet.getCellByPosition(5, y).String = ''
7802  vedi_voce_xpwe(oSheet, y, vRif)
7803  try:
7804  inverti
7805  inverti_segno()
7806  except Exception:
7807  pass
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]
7812  else:
7813  n = oSheet.getCellByPosition(
7814  5, y).Formula.split('J')[1]
7815  oSheet.getCellByPosition(5, y).Formula = '=J$' + n
7816 # contatta il canale Telegram
7817 # https://t.me/leeno_computometrico''', 'AVVISO!')
7818  progress.setValue(6)
7819  GotoSheet('S5')
7820  oSheet = oDoc.getSheets().getByName('S5')
7821  oSheet.getCellRangeByPosition(
7822  0, 0, 250,
7823  SheetUtils.getUsedArea(oSheet).EndRow).clearContents(EDITATTR +
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)'
7838  #
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'
7843 
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))'
7847 
7848  oSheet.getCellRangeByName('L25').CellStyle = 'Blu ROSSO'
7849  oSheet.getCellRangeByName('L25').Formula = '=IF(PRODUCT(E25:I25)>=0;"";PRODUCT(E25:I25)*-1)'
7850 
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'
7854 
7855  # CONTABILITA CONTABILITA CONTABILITA CONTABILITA CONTABILITA
7856  progress.setValue(7)
7857  if oDoc.getSheets().hasByName('CONTABILITA'):
7858  GotoSheet('CONTABILITA')
7859  oSheet = oDoc.getSheets().getByName('CONTABILITA')
7860  # sposto il vedivoce nella colonna E
7861  fine = SheetUtils.getUsedArea(oSheet).EndRow + 1
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(
7872  9,
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) + '))'
7876  # sposto il vedivoce nella colonna E/
7878  oSheet.getCellByPosition(
7879  28, n + 1).Formula = '=SUBTOTAL(9;AC3:AC' + str(n + 2)
7880  # ~rigenera_tutte() affido la rigenerazione delle formule al menu Viste
7881  lrow = 4
7882  while lrow < n:
7883  oDoc.CurrentController.select(oSheet.getCellByPosition(0, lrow))
7884  sistema_stili()
7885  lrow = LeenoSheetUtils.prossimaVoce(oSheet, lrow, 1)
7886  lrow += 1
7887  for el in oDoc.Sheets.ElementNames:
7888  oDoc.CurrentController.setActiveSheet(
7889  oDoc.getSheets().getByName(el))
7890  oSheet = oDoc.getSheets().getByName(el)
7892 # oDialogo_attesa.endExecute() # chiude il dialogo
7893  progress.setValue(8)
7895 # if Dialogs.YesNoDialog(Title='Informazione',
7896 # Text= '''Vuoi procedere con la rigenerazione di tutte le formule di ogni foglio?
7897 # Questo richidere del tempo.''') == 1:
7898  for el in ('COMPUTO', 'VARIANTE', 'CONTABILITA'):
7899  try:
7900  oSheet = oDoc.getSheets().getByName(el)
7901  GotoSheet(el)
7902  rigenera_tutte()
7903  except:
7904  pass
7905  GotoSheet('COMPUTO')
7906  progress.hide()
7907  Dialogs.Info(Title = 'Avviso', Text='Adeguamento del file completato con successo.')
7909 
7910 
7911 
7912 
7914  '''
7915  Visualizza il menù export/import XPWE
7916  '''
7917  oDoc = LeenoUtils.getDocument()
7918  if not oDoc.getSheets().hasByName('S2'):
7919  return
7920  psm = LeenoUtils.getComponentContext().ServiceManager
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"
7924  )
7925  oSheet = oDoc.CurrentController.ActiveSheet
7926  # oDialog1Model = Dialog_XPWE.Model
7927  for el in ("COMPUTO", "VARIANTE", "CONTABILITA", "Elenco Prezzi"):
7928  try:
7929  importo = oDoc.getSheets().getByName(el).getCellRangeByName(
7930  'A2').String
7931  if el == 'COMPUTO':
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
7938  except Exception:
7939  Dialog_XPWE.getControl(el).Enable = False
7940  Dialog_XPWE.Title = 'Esportazione XPWE'
7941  try:
7942  Dialog_XPWE.getControl(oSheet.Name).State = True
7943  except Exception:
7944  pass
7945  Dialog_XPWE.getControl(
7946  'FileControl1'
7947  ).Text = 'C:\\tmp\\prova.txt' # uno.fileUrlToSystemPath(oDoc.getURL())
7948  # ~systemPathToFileUrl
7949  lista = list()
7950  # Dialog_XPWE.execute()
7951  # ~try:
7952  # ~Dialog_XPWE.execute()
7953  # ~except Exception:
7954  # ~pass
7955  if Dialog_XPWE.execute() == 1:
7956  for el in ("COMPUTO", "VARIANTE", "CONTABILITA", "Elenco Prezzi"):
7957  if Dialog_XPWE.getControl(el).State == 1:
7958  lista.append(el)
7959  out_file = Dialogs.FileSelect('Salva con nome...', '*.xpwe', 1)
7960  if out_file == '':
7961  return
7962  testo = '\n'
7963  for el in lista:
7964  XPWE_out(el, out_file)
7965  testo = testo + '● ' + out_file + '-' + el + '.xpwe\n\n'
7966  # ~DLG.MsgBox('Esportazione in formato XPWE eseguita con successo su:\n' + testo, 'Avviso.')
7967  Dialogs.Info(Title = 'Avviso.',
7968  Text='Esportazione in formato XPWE eseguita con successo su:\n' + testo)
7969 
7970 
7971 
7972 def chiudi_dialoghi(event=None):
7973  '''
7974  @@ DA DOCUMENTARE
7975  '''
7976  try:
7977  oDialog1.endExecute()
7978  except:
7979  pass
7980  # ~return
7981  # ~if event:
7982  # ~event.Source.Context.endExecute()
7983  return
7984 
7985 
7986 
7988  '''
7989  Indica qual è il Documento Principale
7990  '''
7991  return
7992 
7993  # legge il percorso del documento principale
7994  sUltimus = LeenoUtils.getGlobalVar('sUltimus')
7995 
7996  oDoc = LeenoUtils.getDocument()
7997 
7998  # se si sta lavorando sul Documento Principale, non fa nulla
7999  try:
8000  if sUltimus == uno.fileUrlToSystemPath(oDoc.getURL()):
8001  return
8002  except Exception:
8003  # file senza nome
8004  return
8005 
8006  # mah... non vedo come potrebbe esserco questo errore
8007  # a meno di non aver eliminato il controller
8008  try:
8009  oSheet = oDoc.CurrentController.ActiveSheet
8010  except AttributeError:
8011  return
8012 
8013  d = {
8014  'COMPUTO': 'F1',
8015  'VARIANTE': 'F1',
8016  'Elenco Prezzi': 'A1',
8017  'CONTABILITA': 'F1',
8018  'Analisi di Prezzo': 'A1'
8019  }
8020  for el in d.keys():
8021  try:
8022  oSheet = oDoc.Sheets.getByName(el)
8023  oSheet.getCellRangeByName(d[el]).String = 'DP: ' + LeenoUtils.getGlobalVar('sUltimus')
8024  oSheet.getCellRangeByName("A1:AT1").clearContents(EDITATTR + FORMATTED + HARDATTR)
8025 
8026  except Exception:
8027  pass
8028 
8029 
8030 
8031 def ods2pdf(oDoc, sFile):
8032  '''
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.
8036  '''
8038  desktop = LeenoUtils.getDesktop()
8039  oFrame = desktop.getCurrentFrame()
8040  oProp = []
8041  oProp0 = PropertyValue()
8042  oProp0.Name = "URL"
8043  oProp0.Value = sFile # "file:///C:/TMP/000.pdf"
8044  oProp1 = PropertyValue()
8045  oProp1.Name = "FilterName"
8046  oProp1.Value = "calc_pdf_Export"
8047  oProp2 = PropertyValue()
8048  oProp2.Name = "FilterData"
8049  oProp2.Value = ()
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)
8056  return
8057 
8058 
8059 
8060 def DlgPDF():
8061  oDoc = LeenoUtils.getDocument()
8062  psm = LeenoUtils.getComponentContext().ServiceManager
8063  dp = psm.createInstance("com.sun.star.awt.DialogProvider")
8064  oDlgPDF = dp.createDialog(
8065  "vnd.sun.star.script:UltimusFree2.DlgPDF?language=Basic&location=application"
8066  )
8067  sUrl = LeenO_path() + '/python/pythonpath/Icons-Big/preview.png'
8068  oDlgPDF.getModel().ImageControl1.ImageURL = sUrl
8069 
8070  oSheet = oDoc.getSheets().getByName('S2')
8071 
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
8080  formulas = {
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]',
8089  }
8090  # ~DLG.chi(list(formulas.values()))
8091  # ~return
8092 
8093  lista = list(formulas.values())
8094 
8095  # ~oDlgPDF.getControl("ComboBox1").Text = "Prova"
8096  oDlgPDF.getControl("ComboBox1").addItems(lista, 1)
8097 
8098  oDlgPDF.execute()
8099 
8100 
8101 def DlgMain():
8102  '''
8103  Visualizza il menù principale dialog_fil
8104  '''
8105 
8106  oDoc = LeenoUtils.getDocument()
8107  oDoc.unlockControllers()
8108  psm = LeenoUtils.getComponentContext().ServiceManager
8109  oSheet = oDoc.CurrentController.ActiveSheet
8110  if not oDoc.getSheets().hasByName('S2'):
8111  Toolbars.AllOff()
8112  if(len(oDoc.getURL()) == 0 and
8113  SheetUtils.getUsedArea(oSheet).EndColumn == 0 and
8114  SheetUtils.getUsedArea(oSheet).EndRow == 0):
8115  oDoc.close(True)
8116  creaComputo()
8117  Toolbars.Vedi()
8118  dp = psm.createInstance("com.sun.star.awt.DialogProvider")
8119  oDlgMain = dp.createDialog(
8120  "vnd.sun.star.script:UltimusFree2.DlgMain?language=Basic&location=application"
8121  )
8122  LeenoUtils.setGlobalVar('oDlgMain', oDlgMain)
8123 
8124  oDlgMain.Title = 'Menù Principale (Ctrl+0)'
8125 
8126  sUrl = LeenO_path() + '/icons/Immagine.png'
8127  oDlgMain.getModel().ImageControl1.ImageURL = sUrl
8128 
8129  sString = oDlgMain.getControl("CommandButton13")
8130  try:
8131  if LeenoUtils.getGlobalVar('sUltimus') == uno.fileUrlToSystemPath(oDoc.getURL()):
8132  sString.setEnable(False)
8133  else:
8134  sString.setEnable(True)
8135  except Exception:
8136  pass
8137 
8138  sString = oDlgMain.getControl("Label12")
8139  sString.Text = version_code.read()#[:-9]
8140  sString = oDlgMain.getControl("Label_DDC")
8141  sString.Text = LeenoUtils.getGlobalVar('sUltimus')
8142 
8143  sString = oDlgMain.getControl("Label1")
8144  sString.Text = (
8145  str(LeenoUtils.getGlobalVar('Lmajor')) + '.' +
8146  str(LeenoUtils.getGlobalVar('Lminor')) + '.' +
8147  LeenoUtils.getGlobalVar('Lsubv'))
8148 
8149  sString = oDlgMain.getControl("Label2")
8150  try:
8151  oSheet = oDoc.Sheets.getByName('S1')
8152  except Exception:
8153  return
8154  sString.Text = oDoc.getDocumentProperties().getUserDefinedProperties(
8155  ).Versione # oSheet.getCellByPosition(7, 290).String
8156  # sString = oDlgMain.getControl("Label14") # Oggetto del lavoro
8157  sString = oDlgMain.getControl("TextField1") # Oggetto del lavoro
8158 
8159  sString.Text = oDoc.Sheets.getByName('S2').getCellRangeByName('C3').String
8160  try:
8161  oSheet = oDoc.Sheets.getByName('COMPUTO')
8162  sString = oDlgMain.getControl("Label8")
8163  sString.Text = "€ {:,.2f}".format(
8164  oSheet.getCellByPosition(18, 1).Value)
8165  except Exception:
8166  pass
8167  try:
8168  oSheet = oDoc.Sheets.getByName('VARIANTE')
8169  sString = oDlgMain.getControl("Label5")
8170  sString.Text = "€ {:,.2f}".format(
8171  oSheet.getCellByPosition(18, 1).Value)
8172  except Exception:
8173  pass
8174  try:
8175  oSheet = oDoc.Sheets.getByName('CONTABILITA')
8176  sString = oDlgMain.getControl("Label9")
8177  sString.Text = "€ {:,.2f}".format(
8178  oSheet.getCellByPosition(15, 1).Value)
8179  except Exception:
8180  pass
8181  # sString = oDlgMain.getControl("ComboBox1")
8182  # sString.Text = conf.read(path_conf, 'Generale', 'visualizza')
8183  oDlgMain.getControl('CheckBox1').State = int(
8184  cfg.read('Generale', 'dialogo'))
8185  # _gotoCella(x, y)
8187  oDlgMain.execute()
8188  sString = oDlgMain.getControl("Label_DDC").Text
8189  if oDlgMain.getControl('CheckBox1').State == 1:
8190  cfg.write('Generale', 'dialogo', '1')
8191  # sString = oDlgMain.getControl("ComboBox1")
8192  # conf.write(path_conf, 'Generale', 'visualizza', sString.getText())
8193  else:
8194  cfg.write('Generale', 'dialogo', '0')
8195  # conf.write(path_conf, 'Generale', 'visualizza', 'Senza Menù')
8196  oDoc.Sheets.getByName('S2').getCellRangeByName(
8197  'C3').String = oDlgMain.getControl("TextField1").Text
8198 
8199  d = {
8200  'COMPUTO': 'F1',
8201  'VARIANTE': 'F1',
8202  'Elenco Prezzi': 'A1',
8203  'CONTABILITA': 'F1',
8204  'Analisi di Prezzo': 'A1'
8205  }
8206  for el in d.keys():
8207  try:
8208  oSheet = oDoc.Sheets.getByName(el)
8209  if LeenoUtils.getGlobalVar('sUltimus') == uno.fileUrlToSystemPath(oDoc.getURL()):
8210  oSheet.getCellRangeByName(
8211  "A1:AT1").CellBackColor = 16773632 # 13434777 giallo
8212  oSheet.getCellRangeByName(
8213  d[el]).String = 'DP: Questo documento'
8214  else:
8215  oSheet.getCellRangeByName(
8216  "A1:AT1").clearContents(HARDATTR)
8217  oSheet.getCellRangeByName(
8218  d[el]).String = 'DP:' + LeenoUtils.getGlobalVar('sUltimus')
8219 
8220  except Exception:
8221  pass
8222  return
8223 
8224 
8225 
8226 def InputBox(sCella='', t=''):
8227  '''
8228  sCella { string } : stringa di default nella casella di testo
8229  t { string } : titolo del dialogo
8230  Visualizza un dialogo di richiesta testo
8231  '''
8232 
8233  psm = LeenoUtils.getComponentContext().ServiceManager
8234  dp = psm.createInstance("com.sun.star.awt.DialogProvider")
8235  oDialog1 = dp.createDialog(
8236  "vnd.sun.star.script:UltimusFree2.DlgTesto?language=Basic&location=application"
8237  )
8238  oDialog1Model = oDialog1.Model
8239 
8240  oDialog1Model.Title = t
8241 
8242  sString = oDialog1.getControl("TextField1")
8243  sString.Text = sCella
8244 
8245  if oDialog1.execute() == 0:
8246  return ''
8247  return sString.Text
8248 
8249 
8250 
8251 def hide_error(lErrori, icol):
8252  '''
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
8256  '''
8257  oDoc = LeenoUtils.getDocument()
8259  oSheet = oDoc.CurrentController.ActiveSheet
8260  # oSheet.clearOutline()
8261  n = 3
8262  test = LeenoSheetUtils.cercaUltimaVoce(oSheet) + 1
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):
8267  for el in lErrori:
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
8274 
8275 
8276 def bak0():
8277  '''
8278  Fa il backup del file di lavoro all'apertura.
8279  '''
8280  # tempo = ''.join(''.join(''.join(str(datetime.now()).split('.')[0].split(' ')).split('-')).split(':'))[:12]
8281  oDoc = LeenoUtils.getDocument()
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/'
8285  try:
8286  dir_bak = uno.fileUrlToSystemPath(dir_bak)
8287  except:
8288  pass
8289  # filename = '.'.join(os.path.basename(orig).split('.')[0:-1]) + '-'
8290  if len(orig) == 0:
8291  return
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)
8299 
8300 
8301 
8302 def bak():
8303  '''
8304  Esegue un numero definito di backup durante il lavoro.
8305  '''
8306  tempo = ''.join(''.join(''.join(
8307  str(datetime.now()).split('.')[0].split(' ')).split('-')).split(
8308  ':'))[:12]
8309  oDoc = LeenoUtils.getDocument()
8310  orig = oDoc.getURL()
8311  dest = '.'.join(
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]) + '-'
8315  if len(orig) == 0:
8316  return
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))
8323  n = 0
8324  nb = int(cfg.read('Generale', 'copie_backup')) # numero di copie)
8325  for el in reversed(lista):
8326  if filename in el:
8327  if n > nb - 1:
8328  os.remove(uno.fileUrlToSystemPath(dir_bak) + el)
8329  n += 1
8330  return
8331 
8332 
8333 
8334 
8336  """ Gestisce il nome del file OXT in leeno_version_code"""
8337 
8338  def __init__ (self):
8339  """ Class initialiser """
8340  pass
8341 
8342  def read ():
8343 
8344  if os.altsep:
8345  code_file = uno.fileUrlToSystemPath(LeenO_path() + os.altsep +
8346  'leeno_version_code')
8347  else:
8348  code_file = uno.fileUrlToSystemPath(LeenO_path() + os.sep +
8349  'leeno_version_code')
8350  f = open(code_file, 'r')
8351  return f.readline()
8352 
8353  def write ():
8354 
8355  if os.altsep:
8356  code_file = uno.fileUrlToSystemPath(LeenO_path() + os.altsep +
8357  'leeno_version_code')
8358  else:
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')
8365 
8366  new = (
8367  'LeenO-' +
8368  str(LeenoUtils.getGlobalVar('Lmajor')) + '.' +
8369  str(LeenoUtils.getGlobalVar('Lminor')) + '.' +
8370  LeenoUtils.getGlobalVar('Lsubv').split('.')[0] + '.' +
8371  Ldev + '-TESTING-' +
8372  tempo[:-6])
8373  of.write(new)
8374  of.close()
8375  return new
8376 
8378  '''
8379  Aggiorna il valore di versione del file description.xml
8380  '''
8381  if os.altsep:
8382  desc_file = uno.fileUrlToSystemPath(LeenO_path() + os.altsep +
8383  'description.xml')
8384  else:
8385  desc_file = uno.fileUrlToSystemPath(LeenO_path() + os.sep +
8386  'description.xml')
8387  f = open(desc_file, 'r')
8388  oxt_name = version_code.read()
8389 
8390  new = []
8391  for el in f.readlines():
8392  if '<version value=' in el:
8393  el.split('''"''')
8394  el = el.split('''"''')[0] +'''"'''+ oxt_name[6:100] +'''"'''+ el.split('''"''')[2]
8395  new.append(el)
8396 
8397  str_join = ''.join(new)
8398 
8399  of = open(desc_file, 'w')
8400  of.write(str_join)
8401  of.close()
8402  return
8403 
8404 
8405 
8406 
8408  '''Mostra / nasconde griglia'''
8409  oDoc = LeenoUtils.getDocument()
8410  oDoc.CurrentController.ShowGrid = not oDoc.CurrentController.ShowGrid
8411 
8412 
8414  '''
8415  Produce il pacchetto installabile
8416  '''
8417  make_pack()
8418 
8419 
8420 def make_pack(bar=0):
8421  '''
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...)
8425  '''
8427  oDoc = LeenoUtils.getDocument()
8428  try:
8429  if oDoc.getSheets().getByName('S1').getCellByPosition(
8430  7, 338).String == '':
8431  src_oxt = '_LeenO'
8432  else:
8433  src_oxt = oDoc.getSheets().getByName('S1').getCellByPosition(
8434  7, 338).String
8435  except Exception:
8436  pass
8437  oxt_name = version_code.write()
8438  description_upd() # aggiorna description.xml - da disattivare prima del rilascio
8439  if bar == 0:
8440  oDoc = LeenoUtils.getDocument()
8441  Toolbars.AllOff()
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):
8446  try:
8447  dest = os.getenv(
8448  "HOME") + '/' + src_oxt + '/leeno/src/Ultimus.oxt/'
8449  os.makedirs(dest)
8450  os.makedirs(os.getenv("HOME") + '/' + src_oxt + '/_SRC/OXT')
8451  except FileExistsError:
8452  pass
8453  nomeZip2 = os.getenv(
8454  "HOME") + '/' + src_oxt + '/_SRC/OXT/' + oxt_name + '.oxt'
8455  subprocess.Popen('caja ' + os.getenv("HOME") + '/' + src_oxt +
8456  '/_SRC/OXT',
8457  shell=True,
8458  stdout=subprocess.PIPE)
8459 
8460  else:
8461  nomeZip2 = '/media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/OXT/' + oxt_name + '.oxt'
8462  subprocess.Popen(
8463  'caja /media/giuserpe/PRIVATO/_dwg/ULTIMUSFREE/_SRC/OXT/',
8464  shell=True,
8465  stdout=subprocess.PIPE)
8466  elif sys.platform == 'win32':
8467  if not os.path.exists('w:/_dwg/ULTIMUSFREE/_SRC/OXT/'):
8468  try:
8469  os.makedirs(os.getenv("HOMEPATH") + '/' + src_oxt + '/')
8470  except FileExistsError:
8471  pass
8472  nomeZip2 = os.getenv(
8473  "HOMEPATH") + '/' + src_oxt + '/OXT/' + oxt_name + '.oxt'
8474  subprocess.Popen('explorer.exe ' + os.getenv("HOMEPATH") + '\\' +
8475  src_oxt + '\\OXT\\',
8476  shell=True,
8477  stdout=subprocess.PIPE)
8478  else:
8479  nomeZip2 = 'w:/_dwg/ULTIMUSFREE/_SRC/OXT/' + oxt_name + '.oxt'
8480  subprocess.Popen('explorer.exe w:\\_dwg\\ULTIMUSFREE\\_SRC\\OXT\\',
8481  shell=True,
8482  stdout=subprocess.PIPE)
8483  shutil.make_archive(nomeZip2, 'zip', oxt_path)
8484  shutil.move(nomeZip2 + '.zip', nomeZip2)
8486  # ~shutil.copyfile(nomeZip2, nomeZip)
8487 
8488 
8489 
8491  '''
8492  @@ DA DOCUMENTARE
8493  '''
8494  psm = LeenoUtils.getComponentContext().ServiceManager
8495  dp = psm.createInstance("com.sun.star.awt.DialogProvider")
8496  oDialog1 = dp.createDialog(
8497  "vnd.sun.star.script:UltimusFree2.DlgDonazioni?language=Basic&location=application"
8498  )
8499  # oDialog1Model = oDialog1.Model
8500  sUrl = LeenO_path() + '/icons/pizza.png'
8501  oDialog1.getModel().ImageControl1.ImageURL = sUrl
8502  oDialog1.execute()
8503 
8504 
8505 
8507  '''
8508  @@ DA DOCUMENTARE
8509  '''
8510  apri = LeenoUtils.createUnoService("com.sun.star.system.SystemShellExecute")
8511  apri.execute("https://leeno.org/donazioni/", "", 0)
8512 
8513 
8514 class XPWE_export_th(threading.Thread):
8515  '''
8516  @@ DA DOCUMENTARE
8517  '''
8518  def __init__(self):
8519  threading.Thread.__init__(self)
8520 
8521  def run(self):
8522  XPWE_export_run()
8523 
8524 
8526  '''
8527  @@ DA DOCUMENTARE
8528  '''
8529  XPWE_export_th().start()
8530 
8531 
8532 
8534  '''
8535  @@ DA DOCUMENTARE
8536  '''
8537  def __init__(self):
8538  threading.Thread.__init__(self)
8539 
8540  def run(self):
8541 # oDialogo_attesa = DLG.dlg_attesa()
8542  oDoc = LeenoUtils.getDocument()
8543  oSheet = oDoc.CurrentController.ActiveSheet
8544 
8545  # attiva la progressbar
8546  progress = Dialogs.Progress(Title='Esportazione di ' + oSheet.Name + ' in corso...', Text="Lettura dati")
8547  progress.setLimits(0, SheetUtils.getUsedArea(oSheet).EndRow)
8548  progress.setValue(0)
8549 
8550  if oSheet.Name not in ('COMPUTO', 'VARIANTE'):
8551  return
8552  descrizione = InputBox(t='inserisci una descrizione per la nuova riga')
8553  progress.show()
8554  i = 0
8555  while (i < SheetUtils.getUsedArea(oSheet).EndRow):
8556  progress.setValue(i)
8557  if oSheet.getCellByPosition(2, i).CellStyle == 'comp 1-a':
8558  sStRange = LeenoComputo.circoscriveVoceComputo(oSheet, i)
8559  qui = sStRange.RangeAddress.StartRow + 1
8560 
8561  i = sotto = sStRange.RangeAddress.EndRow + 3
8562  oDoc.CurrentController.select(oSheet.getCellByPosition(2, qui))
8563  Copia_riga_Ent()
8564  oSheet.getCellByPosition(2, qui + 1).String = descrizione
8565  LeenoSheetUtils.prossimaVoce(oSheet, sotto)
8566  i += 1
8567  progress.hide()
8568 
8569 
8571  '''
8572  inserisce, all'inizio di ogni voce di computo o variante,
8573  una nuova riga con una descrizione a scelta
8574  '''
8576 
8577 
8578 
8579 def ctrl_d():
8580  '''
8581  Copia il valore della prima cella superiore utile.
8582  '''
8583  oDoc = LeenoUtils.getDocument()
8584  oCell = oDoc.CurrentSelection
8585  oSheet = oDoc.CurrentController.ActiveSheet
8586  x = LeggiPosizioneCorrente()[0]
8587  lrow = LeggiPosizioneCorrente()[1]
8588  y = lrow - 1
8589  try:
8590  while oSheet.getCellByPosition(x, y).Type.value == 'EMPTY':
8591  y -= 1
8592  except Exception:
8593  return
8594  oDoc.CurrentController.select(oSheet.getCellByPosition(x, y))
8595  comando('Copy')
8596  oDoc.CurrentController.select(oCell)
8597  paste_clip(insCell=0)
8598  oDoc.CurrentController.select(
8599  oDoc.createInstance("com.sun.star.sheet.SheetCellRanges")) # unselect
8600 
8601 
8602 
8604  '''
8605  taglia il contenuto della selezione
8606  senza cancellare la formattazione delle celle
8607  '''
8608  oDoc = LeenoUtils.getDocument()
8609  oSheet = oDoc.CurrentController.ActiveSheet
8610  comando('Copy')
8611 
8612  try:
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
8622  # oRange = oSheet.getCellRangeByPosition(sCol, sRow, eCol, eRow)
8623  flags = VALUE + DATETIME + STRING + ANNOTATION + FORMULA + OBJECTS + EDITATTR # FORMATTED + HARDATTR
8624  oSheet.getCellRangeByPosition(sCol, sRow, eCol, eRow).clearContents(flags)
8625 
8626 
8627 
8629  '''
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.
8633  '''
8634  oDoc = LeenoUtils.getDocument()
8635  oSheet = oDoc.getSheets().getByName('elenco festività')
8636  oRangeAddress = oDoc.NamedRanges.feste.ReferredCells.RangeAddress
8637  SR = oRangeAddress.StartRow
8638  ER = oRangeAddress.EndRow
8639  lFeste = list()
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')
8644  test = SheetUtils.getUsedArea(oSheet).EndColumn + 1
8645  slist = list()
8646  for x in range(0, test):
8647  if oSheet.getCellByPosition(
8648  x, 3).String == 's' or oSheet.getCellByPosition(
8649  x, 3).String == 'd':
8650  slist.append(x)
8651  for x in range(0, test):
8652  if oSheet.getCellByPosition(x, 1).String in lFeste:
8653  slist.append(x)
8654 
8655  for x in range(2, SheetUtils.getUsedArea(oSheet).EndColumn + 1):
8656  for y in range(1, SheetUtils.getUsedArea(oSheet).EndRow + 1):
8657  if x in slist:
8658  oSheet.getCellByPosition(x, y).CellStyle = 'ok'
8659  else:
8660  oSheet.getCellByPosition(x, y).CellStyle = 'tabella'
8661 
8662 
8663 
8665  '''
8666  @@ DA DOCUMENTARE
8667  '''
8669  oDoc = LeenoUtils.getDocument()
8670 
8671 
8672  oSheet = oDoc.CurrentController.ActiveSheet
8673  lcol = LeggiPosizioneCorrente()[0]
8674  try:
8675  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
8676  except AttributeError:
8677  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
8678  el_y = list()
8679  lista_y = list()
8680  try:
8681  len(oRangeAddress)
8682  for el in oRangeAddress:
8683  el_y.append((el.StartRow, el.EndRow))
8684  except TypeError:
8685  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
8686  for y in el_y:
8687  for el in reversed(range(y[0], y[1] + 1)):
8688  lista_y.append(el)
8689  for y in lista_y:
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(
8695  ' $', '')
8696  while ' ' in testo:
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()
8702 
8703 
8704 
8706  '''
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.
8709  '''
8710  oDoc = LeenoUtils.getDocument()
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')
8716  for y in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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')
8723  for y in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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"):
8730  Dialogs.Exclamation(Title = 'ATTENZIONE!',
8731  Text="Risulta già registrato un SAL. NON E' POSSIBILE PROCEDERE.")
8732  # ~DLG.MsgBox(
8733  # ~"Risulta già registrato un SAL. NON E' POSSIBILE PROCEDERE.",
8734  # ~'ATTENZIONE!')
8735  return
8736  oSheet = oDoc.getSheets().getByName('S5')
8737  oSheet.getCellRangeByName('C23').merge(flag)
8738  oSheet.getCellRangeByName('C24').merge(flag)
8739  oSheet = oDoc.getSheets().getByName('CONTABILITA')
8740  for y in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
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)
8745  else:
8746  oSheet = oDoc.getSheets().getByName('S5')
8747  oSheet.getCellRangeByName('C23:I23').merge(flag)
8748  oSheet.getCellRangeByName('C24:I24').merge(flag)
8749  return
8750 
8751 
8752 
8754  '''
8755  Comando di menu per numera_colonna()
8756  '''
8757  numera_colonna()
8758 
8760  '''Inserisce l'indice di colonna nelle prime 100 colonne del rigo selezionato
8761 Associato a Ctrl+Shift+C'''
8762  oDoc = LeenoUtils.getDocument()
8763  oSheet = oDoc.CurrentController.ActiveSheet
8764  lrow = LeggiPosizioneCorrente()[1]
8765  for x in range(0, 50):
8766  if oSheet.getCellByPosition(x, lrow).Type.value == 'EMPTY':
8767  larg = oSheet.getCellByPosition(x, lrow).Columns.Width
8768  # ~oSheet.getCellByPosition(x, lrow).Value = larg
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'
8774 
8775 
8776 
8777 def subst_str(cerca, sostituisce):
8778  '''
8779  Sostituisce stringhe di testi nel foglio corrente
8780  '''
8781  oDoc = LeenoUtils.getDocument()
8782  oSheet = oDoc.CurrentController.ActiveSheet
8783  ReplaceDescriptor = oSheet.createReplaceDescriptor()
8784  ReplaceDescriptor.SearchString = cerca
8785  ReplaceDescriptor.ReplaceString = sostituisce
8786  oSheet.replaceAll(ReplaceDescriptor)
8787 
8788 
8789 
8790 def processo(arg):
8791  '''Verifica l'esistenza di un processo di sistema'''
8792  ps = subprocess.Popen("ps -A", shell=True, stdout=subprocess.PIPE)
8793  # arg = 'soffice'
8794  if arg in (str(ps.stdout.read())):
8795  return True
8796  return False
8797 
8798 
8799 
8800 def GetRegistryKeyContent(sKeyName, bForUpdate):
8801  '''Dà accesso alla configurazione utente di LibreOffice'''
8802  oConfigProvider = LeenoUtils.createUnoService(
8803  "com.sun.star.configuration.ConfigurationProvider")
8804  arg = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
8805  arg.Name = "nodepath"
8806  arg.Value = sKeyName
8807  if bForUpdate:
8808  GetRegistryKeyContent = oConfigProvider.createInstanceWithArguments(
8809  "com.sun.star.configuration.ConfigurationUpdateAccess", (arg, ))
8810  else:
8811  GetRegistryKeyContent = oConfigProvider.createInstanceWithArguments(
8812  "com.sun.star.configuration.ConfigurationAccess", (arg, ))
8813  return GetRegistryKeyContent
8814 
8815 
8816 
8817 
8818 
8820  '''
8821  Cancella area di stampa di tutti i fogli ad esclusione di quello
8822  corrente del foglio cP_Cop
8823  '''
8825  oDoc = LeenoUtils.getDocument()
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(())
8832  return
8833 
8834 
8835 
8836 
8837 
8839  ''' Imposta area di stampa il relazione all'elaborato da produrre'''
8840  oDoc = LeenoUtils.getDocument()
8841  oSheet = oDoc.CurrentController.ActiveSheet
8842  oSheet.removeAllManualPageBreaks()
8843  ER = SheetUtils.getLastUsedRow(oSheet)
8844 
8845  iSheet = oSheet.RangeAddress.Sheet
8846  oTitles = uno.createUnoStruct('com.sun.star.table.CellRangeAddress')
8847  oTitles.Sheet = iSheet
8848 
8849  if oSheet.Name in ("VARIANTE", "COMPUTO", "COMPUTO_print", 'Elenco Prezzi', 'CONTABILITA', 'Registro', 'SAL'):
8850 
8851  oSheet.getCellByPosition(0, 2).Rows.Height = 800
8852  SR = 2
8853  EC = 41
8854  # riga da ripetere
8855  oTitles.StartRow = 2
8856  oTitles.EndRow = 2
8857  oSheet.setTitleRows(oTitles)
8858  oSheet.setPrintTitleRows(True)
8859  if oSheet.Name == 'Elenco Prezzi':
8860  EC = 6
8861  ER -= 1
8862  if oSheet.Name == 'CONTABILITA':
8863  EC = 15
8864  if oDoc.NamedRanges.hasByName('_Lib_1'):
8865  return
8866  if oSheet.Name in ('Analisi di Prezzo'):
8867  EC = 7
8868  SR = 1
8869  ER -= 1
8870  oSheet.setPrintTitleRows(False)
8871 # imposta area di stampa
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
8877  oStampa.EndRow = ER
8878  oSheet.setPrintAreas((oStampa,))
8879  return
8880 
8881 
8882 
8883 
8884 
8886  '''
8887  Configura intestazioni e pie' di pagina degli stili di stampa
8888  e propone un'anteprima di stampa
8889  '''
8890  oDoc = LeenoUtils.getDocument()
8891  if not oDoc.getSheets().hasByName('M1'):
8892  return
8893 
8894  set_area_stampa()
8895 
8896  if Dialogs.YesNoDialog(Title='AVVISO!',
8897  Text='''Vuoi attribuire il colore bianco allo sfondo delle celle?
8898 Le formattazioni dirette impostate durante il lavoro andranno perse.
8899 
8900 Per ripristinare i colori, tipici dei fogli di LeenO, basterà selezionare
8901 le celle ed usare "CTRL+M".
8902 
8903 Procedo cambiando i colori?''') == 1:
8905 
8906  oSheet = oDoc.CurrentController.ActiveSheet
8907  oSheet.removeAllManualPageBreaks()
8909 
8910  # committente = oDoc.NamedRanges.Super_ego_8.ReferredCells.String
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'
8916  # ~luogo = '\nLocalità: ' + oDoc.getSheets().getByName('S2').getCellRangeByName("C4").String
8917 
8918  # try:
8919  # oSheet = oDoc.CurrentController.ActiveSheet
8920  # except Exception:
8921  # pass
8922  # su_dx = oDoc.NamedRanges.Bozza_8.ReferredCells.String
8923 
8924  # cancella stili di pagina #######################################
8925  # ~stili_pagina = list()
8926  # ~fine = oDoc.StyleFamilies.getByName('PageStyles').Count
8927  # ~for n in range(0, fine):
8928  # ~oAktPage = oDoc.StyleFamilies.getByName('PageStyles').getByIndex(n)
8929  # ~stili_pagina.append(oAktPage.DisplayName)
8930  # ~for el in stili_pagina:
8931  # ~if el not in ('PageStyle_Analisi di Prezzo', 'Page_Style_COPERTINE',
8932  # 'Page_Style_Libretto_Misure2', 'PageStyle_REGISTRO_A4', 'PageStyle_COMPUTO_A4',
8933  # 'PageStyle_Elenco Prezzi'):
8934  # ~oDoc.StyleFamilies.getByName('PageStyles').removeByName(el)
8935  # ~return
8936  # cancella stili di pagina #######################################
8937 
8938  # crea solo gli stili che servono
8939  # il ciclo for per questa operazione non va, quindi procedo per passi singoli
8940  # ~try:
8941  # ~oTablePageStyles.insertByName('Page_Style_COPERTINE', oPgStyle)
8942  # ~except:
8943  # ~pass
8944  # ~try:
8945  # ~oTablePageStyles.insertByName('PageStyle_COMPUTO_A4', oPgStyle)
8946  # ~except:
8947  # ~pass
8948  # ~try:
8949  # ~oTablePageStyles.insertByName('PageStyle_Elenco Prezzi', oPgStyle)
8950  # ~except:
8951  # ~pass
8952  # ~try:
8953  # ~oTablePageStyles.insertByName('Page_Style_Libretto_Misure2', oPgStyle)
8954  # ~except:
8955  # ~pass
8956  # ~try:
8957  # ~oTablePageStyles.insertByName('PageStyle_REGISTRO_A4', oPgStyle)
8958  # ~except:
8959  # ~pass
8960 
8961  stili = {
8962  'cP_Cop': 'Page_Style_COPERTINE',
8963  'COMPUTO': 'PageStyle_COMPUTO_A4',
8964  'VARIANTE': 'PageStyle_COMPUTO_A4',
8965  'Elenco Prezzi': 'PageStyle_Elenco Prezzi',
8966  # ~'Analisi di Prezzo': 'PageStyle_Analisi di Prezzo',
8967  'Analisi di Prezzo': 'PageStyle_COMPUTO_A4',
8968  'CONTABILITA': 'Page_Style_Libretto_Misure2',
8969  'Registro': 'PageStyle_REGISTRO_A4',
8970  'SAL': 'PageStyle_REGISTRO_A4',
8971  }
8972 
8973 
8974  oStyleFam = oDoc.StyleFamilies
8975  oTablePageStyles = oStyleFam.getByName("PageStyles")
8976  oPgStyle = oDoc.createInstance("com.sun.star.style.PageStyle")
8977  for el in stili.keys():
8978  try:
8979  oDoc.getSheets().getByName(el).PageStyle = stili[el]
8980  except Exception:
8981  pass
8982 
8987  if cfg.read('Generale', 'dettaglio') == '1':
8988  dettaglio_misure(0)
8989  dettaglio_misure(1)
8990  else:
8991  dettaglio_misure(0)
8992  for n in range(0, oDoc.StyleFamilies.getByName('PageStyles').Count):
8993  oAktPage = oDoc.StyleFamilies.getByName('PageStyles').getByIndex(n)
8994  # ~chi((n , oAktPage.DisplayName))
8995  oAktPage.HeaderIsOn = True
8996  oAktPage.FooterIsOn = True
8997 
8998  oAktPage.TopMargin = 1500
8999  oAktPage.BottomMargin = 800
9000  oAktPage.LeftMargin = 1500
9001  oAktPage.RightMargin = 1000
9002 
9003  oAktPage.FooterLeftMargin = 0
9004  oAktPage.FooterRightMargin = 0
9005  oAktPage.HeaderLeftMargin = 0
9006  oAktPage.HeaderRightMargin = 0
9007 
9008  oAktPage.HeaderBodyDistance = 0
9009  oAktPage.FooterBodyDistance = 0
9010 
9011  if oAktPage.DisplayName == 'Page_Style_COPERTINE':
9012  oAktPage.HeaderIsOn = False
9013  oAktPage.FooterIsOn = False
9014  # Adatto lo zoom alla larghezza pagina
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
9025  # if oAktPage.DisplayName in ('PageStyle_Analisi di Prezzo'):
9026  # htxt = 10.0
9027  bordo = oAktPage.TopBorder
9028  bordo.LineWidth = 0
9029  bordo.OuterLineWidth = 0
9030  oAktPage.TopBorder = bordo
9031 
9032  bordo = oAktPage.BottomBorder
9033  bordo.LineWidth = 0
9034  bordo.OuterLineWidth = 0
9035  oAktPage.BottomBorder = bordo
9036 
9037  bordo = oAktPage.RightBorder
9038  bordo.LineWidth = 0
9039  bordo.OuterLineWidth = 0
9040  oAktPage.RightBorder = bordo
9041 
9042  bordo = oAktPage.LeftBorder
9043  bordo.LineWidth = 0
9044  bordo.OuterLineWidth = 0
9045  oAktPage.LeftBorder = bordo
9046  # Adatto lo zoom alla larghezza pagina
9047  oAktPage.PageScale = 0
9048  oAktPage.ScaleToPagesX = 1
9049  oAktPage.ScaleToPagesY = 0
9050 
9051  # ~HEADER
9052  oHeader = oAktPage.RightPageHeaderContent
9053  # ~oAktPage.PageScale = 95
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
9057 
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
9061 
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
9065 
9066  oAktPage.RightPageHeaderContent = oHeader
9067  # ~FOOTER
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
9076  # ~oHLText = oFooter.RightText.Text.String = '#/##'
9077  oAktPage.RightPageFooterContent = oFooter
9078 
9079  if oAktPage.DisplayName == 'Page_Style_Libretto_Misure2':
9080  # ~HEADER
9081  oHeader = oAktPage.RightPageHeaderContent
9082  # oHLText = oHeader.LeftText.Text.String = committente + '\nLibretto delle misure n.'
9083  # oHRText = oHeader.RightText.Text.String = luogo
9084  oAktPage.RightPageHeaderContent = oHeader
9085  # ~FOOTER
9086  oFooter = oAktPage.RightPageFooterContent
9087  # oHLText = oFooter.CenterText.Text.String = "L'IMPRESA IL DIRETTORE DEI LAVORI"
9088  # oHLText = oFooter.LeftText.Text.String = "realizzato con LeenO.org\n" + os.path.basename(
9089  # oDoc.getURL() + '\n\n\n')
9090  oAktPage.RightPageFooterContent = oFooter
9091 
9092  if oAktPage.DisplayName == 'PageStyle_REGISTRO_A4':
9093  # ~HEADER
9094  oHeader = oAktPage.RightPageHeaderContent
9095  # oHLText = oHeader.LeftText.Text.String = committente + '\nRegistro di contabilità n.'
9096  # oHRText = oHeader.RightText.Text.String = luogo
9097  oAktPage.RightPageHeaderContent = oHeader
9098  # ~FOOTER
9099  oFooter = oAktPage.RightPageFooterContent
9100  # oHLText = oFooter.CenterText.Text.String = ''
9101  # oHLText = oFooter.LeftText.Text.String = "realizzato con LeenO.org\n" + os.path.basename(
9102  # oDoc.getURL() + '\n\n\n')
9103  oAktPage.RightPageFooterContent = oFooter
9104  try:
9105  if oDoc.CurrentController.ActiveSheet.Name in ('COMPUTO', 'VARIANTE',
9106  'CONTABILITA',
9107  'Elenco Prezzi'):
9108  _gotoCella(0, 3)
9109  if oDoc.CurrentController.ActiveSheet.Name in ('Analisi di Prezzo'):
9110  _gotoCella(0, 2)
9111  setPreview(1)
9112  except Exception:
9113  pass
9114  # bordo lato destro in attesa di LibreOffice 6.2
9115  # bordo = oAktPage.RightBorder
9116  # bordo.LineWidth = 0
9117  # bordo.OuterLineWidth = 0
9118  # oAktPage.RightBorder = bordo
9120  last = SheetUtils.getUsedArea(oSheet).EndRow
9121  # ~oSheet.getCellRangeByPosition(1, 0, 41, last).Rows.OptimalHeight = True
9122  return
9123 
9124 
9125 
9126 def fissa():
9127  '''
9128  @@ DA DOCUMENTARE
9129  '''
9130  oDoc = LeenoUtils.getDocument()
9131  oSheet = oDoc.CurrentController.ActiveSheet
9132  lcol = LeggiPosizioneCorrente()[0]
9133  lrow = LeggiPosizioneCorrente()[1]
9134  if oSheet.Name in (
9135  'COMPUTO',
9136  'VARIANTE',
9137  'Elenco Prezzi'
9138  ):
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)
9146  # ~_gotoCella(lcol, lrow)
9147 
9148 
9149 
9150 
9151 
9153  '''
9154  Consente la visualizzazione selettiva delle voci di COMPUTO che fanno
9155  capo alla stessa voce di Elenco Prezzi.
9156  '''
9157  chiudi_dialoghi()
9158 
9159  def ricorrenze():
9160  '''Trova i codici di prezzo ricorrenti nel COMPUTO'''
9161  oDoc = LeenoUtils.getDocument()
9162  oSheet = oDoc.CurrentController.ActiveSheet
9163  struttura_off()
9164  last = SheetUtils.getUsedArea(oSheet).EndRow
9165  lista = list()
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))
9170  for el in unici:
9171  lista.remove(el)
9172  iSheet = oSheet.RangeAddress.Sheet
9173  oCellRangeAddr = uno.createUnoStruct(
9174  'com.sun.star.table.CellRangeAddress')
9175  oCellRangeAddr.Sheet = iSheet
9176  # lrow = 0
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:
9180  oRange = LeenoComputo.circoscriveVoceComputo(oSheet, n).RangeAddress
9181  oCellRangeAddr.StartRow = oRange.StartRow
9182  oCellRangeAddr.EndRow = oRange.EndRow
9183  oSheet.group(oCellRangeAddr, 1)
9184  lista = list(set(lista))
9185  lista.sort()
9186  return lista
9187 
9188  # try:
9189  # lista_ricorrenze
9190  # except Exception:
9191  lista_ricorrenze = ricorrenze()
9192  LeenoUtils.setGlobalVar('lista_ricorrenze', lista_ricorrenze)
9193  if len(lista_ricorrenze) == 0:
9194  # ~DLG.MsgBox('Non ci sono voci di prezzo ricorrenti.', 'Informazione')
9195  Dialogs.Info(Title = 'Informazione',
9196  Text="Non ci sono voci di prezzo ricorrenti.")
9197  return
9198  psm = LeenoUtils.getComponentContext().ServiceManager
9199  dp = psm.createInstance("com.sun.star.awt.DialogProvider")
9200  oDlg = dp.createDialog(
9201  "vnd.sun.star.script:UltimusFree2.DlgLista?language=Basic&location=application"
9202  )
9203  # oDialog1Model = oDlg.Model
9204  # oDlg.Title = 'Si ripetono '+ str(len(lista_ricorrenze)) + ' voci di prezzo'
9205  oDlg.Title = 'Seleziona il codice e dai OK...'
9206  oDlg.getControl('ListBox1').addItems(lista_ricorrenze, 0)
9207  if oDlg.execute() == 0:
9208  return
9209  filtra_codice(oDlg.getControl('ListBox1').SelectedItem)
9210  # if oDlg.getControl('CheckBox1').State == 1:
9211  # oDlg.getControl('ListBox1').removeItems(0, len(lista_ricorrenze))
9212  # lista_ricorrenze = ricorrenze()
9213  # oDlg.getControl('ListBox1').addItems(lista_ricorrenze, 0)
9214  # oDlg.getControl('CheckBox1').State = 0
9215  # oDlg.execute()
9216 
9217 
9218 def trova_np():
9219  '''
9220  Raggruppa le righe in modo da rendere evidenti i nuovi prezzi
9221  '''
9222  chiudi_dialoghi()
9223  oDoc = LeenoUtils.getDocument()
9224  oSheet = oDoc.CurrentController.ActiveSheet
9225  oDoc.enableAutomaticCalculation(False)
9226 
9227  struttura_off()
9228  oCellRangeAddr = oDoc.NamedRanges.elenco_prezzi.ReferredCells.RangeAddress
9229  for el in range(3, SheetUtils.getUsedArea(oSheet).EndRow):
9230  if oSheet.getCellByPosition(
9231  12,
9232  el).Value == 0 and oSheet.getCellByPosition(20, el).Value > 0:
9233  pass
9234  else:
9235  oCellRangeAddr.StartRow = el
9236  oCellRangeAddr.EndRow = el
9237  oSheet.group(oCellRangeAddr, 1)
9238  oSheet.getCellRangeByPosition(0, el, 1, el).Rows.IsVisible = False
9239 
9240  oDoc.enableAutomaticCalculation(True)
9241 
9242 
9243 
9245  '''
9246  @@ DA DOCUMENTARE
9247  '''
9248  # elimina voci doppie hard - grezza e lenta, ma efficace
9249  oDoc = LeenoUtils.getDocument()
9250  oSheet = oDoc.getSheets().getByName('Elenco Prezzi')
9251  riordina_ElencoPrezzi(oDoc)
9252  fine = SheetUtils.getUsedArea(oSheet).EndRow + 1
9253 
9254  # attiva la progressbar
9255  progress = Dialogs.Progress(Title='Ricerca delle voci da eliminare in corso...', Text="Lettura dati")
9256  progress.setLimits(0, fine)
9257  progress.setValue(0)
9258  progress.show()
9259 
9260  oSheet.getCellByPosition(30, 3).Formula = '=IF(A4=A3;1;0)'
9261  oDoc.CurrentController.select(oSheet.getCellByPosition(30, 3))
9262  comando('Copy')
9263  oDoc.CurrentController.select(
9264  oSheet.getCellRangeByPosition(30, 3, 30, fine))
9265  paste_clip(insCells=1)
9266 
9267  for i in reversed(range(0, fine)):
9268  progress.setValue(i)
9269  if oSheet.getCellByPosition(30, i).Value == 1:
9270  _gotoCella(30, i)
9271  oSheet.getRows().removeByIndex(i, 1)
9272  oSheet.getCellRangeByPosition(30, 3, 30, fine).clearContents(FORMULA)
9273  _gotoCella(0, 3)
9274  progress.hide()
9275 
9276 
9277 
9278 def MENU_hl():
9279  '''
9280  Sostituisce hiperlink alla stringa nella colonna B, se questa è un
9281  indirizzo di file o cartella
9282  '''
9283  oDoc = LeenoUtils.getDocument()
9284  oSheet = oDoc.CurrentController.ActiveSheet
9285  for el in reversed(range(0, SheetUtils.getUsedArea(oSheet).EndRow)):
9286  try:
9287  if oSheet.getCellByPosition(1, el).String[1] == ':':
9288  stringa = '=HYPERLINK("' + oSheet.getCellByPosition(
9289  1, el).String + '";">>>")'
9290  oSheet.getCellByPosition(1, el).Formula = stringa
9291  except Exception:
9292  pass
9293 
9294 
9295 
9297  '''
9298  Raggruppa e nasconde tutte le voci di misura in cui non compare
9299  la stringa cercata.
9300  '''
9302  oDoc = LeenoUtils.getDocument()
9303  oSheet = oDoc.CurrentController.ActiveSheet
9304 
9305  iSheet = oSheet.RangeAddress.Sheet
9306  oCellRangeAddr = uno.createUnoStruct('com.sun.star.table.CellRangeAddress')
9307  oCellRangeAddr.Sheet = iSheet
9308  fine = SheetUtils.getUsedArea(oSheet).EndRow + 1
9309  el_y = list()
9310  if 'comp 1-a' in oDoc.getCurrentSelection().CellStyle or \
9311  'Descr' in oDoc.getCurrentSelection().CellStyle:
9312  testo = oDoc.getCurrentSelection().String
9313  else:
9314  testo = ''
9315  descrizione = InputBox(
9316  testo, t='Inserisci la descrizione da cercare o OK per conferma.')
9317  if descrizione in (None, '', ' '):
9318  struttura_off()
9319  oSheet.getCellRangeByPosition(2, 0, 2, 1048575).clearContents(HARDATTR)
9320  return
9321 
9322  struttura_off()
9323  oSheet.getCellRangeByPosition(2, 0, 2, 1048575).clearContents(HARDATTR)
9324 
9325  y = 4
9326  progress = Dialogs.Progress(Title='Applicazione filtro in corso...', Text="Lettura dati")
9327  progress.setLimits(0, fine)
9328  progress.setValue(0)
9329  progress.show()
9330  lRow = SheetUtils.sStrColtoList(descrizione, 2, oSheet, y)
9331  if len(lRow) == 0:
9332  progress.hide()
9333  # ~DLG.MsgBox('''Testo non trovato.''', 'ATTENZIONE!')
9334  Dialogs.Exclamation (Title = 'ATTENZIONE!',
9335  Text="Testo non trovato.")
9336 
9337  return
9338  el_y = list()
9339  for y in lRow:
9340  progress.setValue(y)
9341  oSheet.getCellByPosition(2, y).CellBackColor = 15757935
9342  el_y.append(seleziona_voce(y))
9343  lista_y = list()
9344  lista_y.append(2)
9345  for el in el_y:
9346  y = el[0]
9347  progress.setValue(y)
9348  lista_y.append(y)
9349  y = el[1]
9350  lista_y.append(y)
9351  if oSheet.Name == 'CONTABILITA':
9352  lista_y.append(fine - 2)
9353  else:
9354  lista_y.append(fine - 3)
9355  i = 0
9356  while len(lista_y[i:]) > 1:
9357  SR = lista_y[i:][0] + 1
9358  ER = lista_y[i:][1]
9359  if ER > SR:
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
9365  i += 2
9366  _gotoCella(2, lRow[0])
9367  progress.hide()
9369 
9370 
9373 
9374 
9377 
9378 
9381 
9382 
9383 
9384 def errore():
9385  '''
9386  @@ DA DOCUMENTARE
9387  '''
9388  DLG.MsgBox(traceback.format_exc())
9389 
9390 # ~from collections import OrderedDict
9391 def somma():
9392  '''
9393  Mostra la somme dei valori di una selezione su singola colonna. Utile quando la
9394  finestra di Calc non mostra la statusbar.
9395  '''
9396  oDoc = LeenoUtils.getDocument()
9397  oSheet = oDoc.CurrentController.ActiveSheet
9398  lcol = LeggiPosizioneCorrente()[0]
9399  try:
9400  oRangeAddress = oDoc.getCurrentSelection().getRangeAddresses()
9401  except AttributeError:
9402  oRangeAddress = oDoc.getCurrentSelection().getRangeAddress()
9403  el_y = list()
9404  lista_y = list()
9405  try:
9406  len(oRangeAddress)
9407  for el in oRangeAddress:
9408  el_y.append((el.StartRow, el.EndRow))
9409  except TypeError:
9410  el_y.append((oRangeAddress.StartRow, oRangeAddress.EndRow))
9411  for y in el_y:
9412  for el in range(y[0], y[1] + 1):
9413  lista_y.append(el)
9414  somma = list()
9415  for y in lista_y:
9416  somma.append(oSheet.getCellByPosition(lcol, y).Value)
9417  DLG.chi(sum(somma))
9418 
9419 
9420 
9421 
9423  #calendario
9424  oDoc = LeenoUtils.getDocument()
9425  oSheet = oDoc.CurrentController.ActiveSheet
9426  x = LeggiPosizioneCorrente()[0]
9427  y = LeggiPosizioneCorrente()[1]
9428  testo = Dialogs.pickDate()
9429  lst = str(testo).split('-')
9430  try:
9431  testo = lst[2] + '/' + lst[1] + '/' + lst[0]
9432  oSheet.getCellByPosition(x, y).String = testo
9433  except:
9434  pass
9435  return
9436 
9437 
9438 def PdfDlg():
9439  # dimensione verticale dei checkbox == dimensione bottoni
9440  #dummy, hItems = Dialogs.getButtonSize('', Icon="Icons-24x24/settings.png")
9441  nWidth, hItems = Dialogs.getEditBox('aa')
9442 
9443  # dimensione dell'icona col PDF
9444  imgW = Dialogs.getBigIconSize()[0] * 2
9445 
9446  oDoc = LeenoUtils.getDocument()
9447  oSheet = oDoc.CurrentController.ActiveSheet
9448  oSheets = list(oDoc.getSheets().getElementNames())
9449 
9450 
9451  return Dialogs.Dialog(Title='Esportazione PDFPDFPDFPDFPDF', Horz=False, CanClose=True, Items=[
9452  Dialogs.HSizer(Items=[
9453  Dialogs.VSizer(Items=[
9454  Dialogs.Spacer(),
9455  Dialogs.ImageControl(Image='Icons-Big/pdf.png', MinWidth=imgW / 10),
9456  Dialogs.Spacer(),
9457  ]),
9458  # ~Dialogs.VSizer(Items=[
9459  # ~Dialogs.FixedText(Text='Elenco_prova'),
9460  # ~Dialogs.Spacer(),
9461  # ~Dialogs.Edit(Id='npElencoPrezzi', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
9462  # ~Dialogs.Spacer(),
9463  # ~Dialogs.Edit(Id='npComputoMetrico', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
9464  # ~Dialogs.Spacer(),
9465  # ~Dialogs.Edit(Id='npCostiManodopera', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
9466  # ~Dialogs.Spacer(),
9467  # ~Dialogs.Edit(Id='npQuadroEconomico', Align=1, FixedHeight=hItems, FixedWidth=nWidth),
9468  # ~]),
9469  Dialogs.Spacer(),
9470  Dialogs.VSizer(Items=[
9471  Dialogs.FixedText(Text='Oggetto'),
9472  Dialogs.Spacer(),
9473  Dialogs.ListBox(List=oSheets, FixedHeight=hItems * 1, FixedWidth=nWidth * 6),
9474  # ~Dialogs.Spacer(),
9475  # ~Dialogs.CheckBox(Id="cbElencoPrezzi", Label="Elenco prezzi", FixedHeight=hItems),
9476  # ~Dialogs.Spacer(),
9477  # ~Dialogs.CheckBox(Id="cbComputoMetrico", Label="Computo metrico", FixedHeight=hItems),
9478  # ~Dialogs.Spacer(),
9479  # ~Dialogs.CheckBox(Id="cbCostiManodopera", Label="Costi manodopera", FixedHeight=hItems),
9480  # ~Dialogs.Spacer(),
9481  # ~Dialogs.CheckBox(Id="cbQuadroEconomico", Label="Quadro economico", FixedHeight=hItems),
9482  ]),
9483  Dialogs.Spacer(),
9484  ]),
9485  Dialogs.Spacer(),
9486  Dialogs.Spacer(),
9487  Dialogs.FixedText(Text='Cartella di destinazione:'),
9488  Dialogs.Spacer(),
9489  Dialogs.PathControl(Id="pathEdit"),
9490  Dialogs.Spacer(),
9491  Dialogs.HSizer(Items=[
9492  Dialogs.Spacer(),
9493  Dialogs.Button(Label='Ok', MinWidth=Dialogs.MINBTNWIDTH, Icon='Icons-24x24/ok.png', RetVal=1),
9494  Dialogs.Spacer(),
9495  Dialogs.Button(Label='Annulla', MinWidth=Dialogs.MINBTNWIDTH, Icon='Icons-24x24/cancel.png', RetVal=-1),
9496  Dialogs.Spacer()
9497  ])
9498  ])
9499 
9500 
9501 
9503  DelPrintArea()
9504  set_area_stampa()
9505  tempo = ''.join(''.join(''.join(
9506  str(datetime.now()).split('.')[0].split(' ')).split('-')).split(
9507  ':'))[:12]
9508  oDoc = LeenoUtils.getDocument()
9509  orig = oDoc.getURL()
9510  dest = orig.split('.')[0] + '-' + tempo + '.pdf'
9511  ods2pdf(oDoc, dest)
9512  # ~DLG.chi(dest)
9513  # ~rem ----------------------------------------------------------------------
9514 
9515 
9516 
9523 
9524 # name org.openoffice.script.DummyImplementationForPythonScripts should be changed to something
9525 # different(must be unique within an office installation !)
9526 # --- faked component, dummy to allow registration with unopkg, no functionality expected
9527 # import unohelper
9528 # questo mi consente di inserire i comandi python in Accelerators.xcu
9529 # vedi pag.264 di "Manuel du programmeur oBasic"
9530 # <<< vedi in description.xml
9531 
pyleeno.sblocca_cont
def sblocca_cont()
Definition: pyleeno.py:4663
pyleeno.debug_validation
def debug_validation()
Definition: pyleeno.py:5141
pyleeno.DlgPDF
def DlgPDF()
Definition: pyleeno.py:8060
pyleeno.trova_ricorrenze
def trova_ricorrenze()
Definition: pyleeno.py:9152
LeenoEvents.pulisci
def pulisci()
Definition: LeenoEvents.py:152
pyleeno.MENU_filtro_descrizione
def MENU_filtro_descrizione()
Definition: pyleeno.py:9296
pyleeno.voce_breve
def voce_breve()
Definition: pyleeno.py:1857
pyleeno.bak
def bak()
Definition: pyleeno.py:8302
pyleeno.Tutti_Subtotali
def Tutti_Subtotali(oSheet)
Definition: pyleeno.py:992
pyleeno.MENU_converti_stringhe
def MENU_converti_stringhe()
Definition: pyleeno.py:6892
pyleeno.MENU_Inser_SuperCapitolo
def MENU_Inser_SuperCapitolo()
Definition: pyleeno.py:944
pyleeno.GotoSheet
def GotoSheet(nSheet, fattore=100)
Definition: pyleeno.py:1560
pyleeno.version_code.__init__
def __init__(self)
Definition: pyleeno.py:8338
pyleeno.ScriviNomeDocumentoPrincipale
def ScriviNomeDocumentoPrincipale()
Definition: pyleeno.py:7987
pyleeno.salva_come
def salva_come(nomefile=None)
Definition: pyleeno.py:1781
pyleeno.Filtra_computo
def Filtra_computo(nSheet, nCol, sString)
Definition: pyleeno.py:1400
pyleeno.inizializza
def inizializza()
Definition: pyleeno.py:7525
LeenoSheetUtils.inserCapitolo
def inserCapitolo(oSheet, lrow, sTesto='Categoria')
Definition: LeenoSheetUtils.py:567
pyleeno.parziale_core
def parziale_core(oSheet, lrow)
Definition: pyleeno.py:6706
pyleeno.ColumnNameToNumber
def ColumnNameToNumber(oSheet, cColumnName)
Definition: pyleeno.py:4076
pyleeno.seleziona
def seleziona(lrow=None)
Definition: pyleeno.py:4267
pyleeno.voce_breve_ep
def voce_breve_ep()
Definition: pyleeno.py:2030
pyleeno.MENU_importa_stili
def MENU_importa_stili()
Definition: pyleeno.py:6654
pyleeno.valida_cella
def valida_cella(oCell, lista_val, titoloInput='', msgInput='', err=False)
Definition: pyleeno.py:5159
pyleeno.cancella_analisi_da_ep
def cancella_analisi_da_ep()
Definition: pyleeno.py:3881
pyleeno.struct_colore
def struct_colore(level)
Definition: pyleeno.py:6493
pyleeno.MENU_cerca_in_elenco
def MENU_cerca_in_elenco()
Definition: pyleeno.py:4698
pyleeno.inverti_segno
def inverti_segno()
Definition: pyleeno.py:4902
pyleeno.EliminaVociDoppieElencoPrezzi
def EliminaVociDoppieElencoPrezzi()
Definition: pyleeno.py:2745
pyleeno.sistema_cose
def sistema_cose()
Definition: pyleeno.py:8664
LeenoUtils.getGlobalVar
def getGlobalVar(name)
Definition: LeenoUtils.py:123
pyleeno.MENU_copia_celle_visibili
def MENU_copia_celle_visibili()
Definition: pyleeno.py:5326
LeenoSheetUtils.adattaAltezzaRiga
def adattaAltezzaRiga(oSheet)
Definition: LeenoSheetUtils.py:468
pyleeno.donazioni
def donazioni()
Definition: pyleeno.py:8506
pyleeno.MENU_make_pack
def MENU_make_pack()
Definition: pyleeno.py:8413
pyleeno.Rinumera_TUTTI_Capitoli2
def Rinumera_TUTTI_Capitoli2(oSheet)
Definition: pyleeno.py:981
pyleeno.vai_a_S1
def vai_a_S1()
Definition: pyleeno.py:1517
SheetUtils.sStrColtoList
def sStrColtoList(sString, nCol, oSheet, start=2, equal=0)
Definition: SheetUtils.py:429
pyleeno.struttura_Elenco
def struttura_Elenco()
Definition: pyleeno.py:6572
SheetUtils.simpleSortColumn
def simpleSortColumn(oRange, column, sortAscending)
Definition: SheetUtils.py:499
LeenoComputo.ins_voce_computo
def ins_voce_computo(cod=None)
Definition: LeenoComputo.py:170
pyleeno.Copia_riga_Ent
def Copia_riga_Ent(arg=None)
Definition: pyleeno.py:4625
pyleeno.make_pack
def make_pack(bar=0)
Definition: pyleeno.py:8420
pyleeno.richiesta_offerta
def richiesta_offerta()
Definition: pyleeno.py:5458
pyleeno.MENU_mostra_fogli
def MENU_mostra_fogli()
MENU_unisci_fogli moved to SheetUtils.py.
Definition: pyleeno.py:1312
LeenoUtils.getDocument
def getDocument()
Definition: LeenoUtils.py:67
Dialogs.Spacer
Definition: Dialogs.py:616
pyleeno.bak0
def bak0()
Definition: pyleeno.py:8276
pyleeno.pesca_cod
def pesca_cod()
Definition: pyleeno.py:4759
LeenoSheetUtils.eliminaVoce
def eliminaVoce(oSheet, lrow)
Definition: LeenoSheetUtils.py:319
Dialogs.PathControl
Definition: Dialogs.py:1256
LeenoContab.struttura_CONTAB
def struttura_CONTAB()
Definition: LeenoContab.py:348
pyleeno.mostra_fogli_principali
def mostra_fogli_principali()
Definition: pyleeno.py:1330
pyleeno.raggruppa_righe_voce
def raggruppa_righe_voce(lrow, flag=1)
Definition: pyleeno.py:4223
pyleeno.ColumnNumberToName
def ColumnNumberToName(oSheet, cColumnNumb)
Definition: pyleeno.py:4066
pyleeno.inizializza_elenco
def inizializza_elenco()
Definition: pyleeno.py:6196
pyleeno.sproteggi_sheet_TUTTE
def sproteggi_sheet_TUTTE()
Definition: pyleeno.py:1652
LeenoSheetUtils.inserSottoCapitolo
def inserSottoCapitolo(oSheet, lrow, sTesto)
Definition: LeenoSheetUtils.py:610
SheetUtils.uFindStringCol
def uFindStringCol(sString, nCol, oSheet, start=2, equal=0, up=False)
Definition: SheetUtils.py:403
pyleeno.MENU_grid_switch
def MENU_grid_switch()
Definition: pyleeno.py:8407
pyleeno.struct
def struct(level)
Definition: pyleeno.py:7239
pyleeno.colora_vecchio_elenco
def colora_vecchio_elenco()
ns_ins moved to LeenoImport_XmlToscana.py
Definition: pyleeno.py:6625
pyleeno.valuta_cella
def valuta_cella(oCell)
Definition: pyleeno.py:4978
pyleeno.rigenera_parziali
def rigenera_parziali(arg=False)
Definition: pyleeno.py:5994
LeenoUtils.DocumentRefresh
def DocumentRefresh(boo)
Definition: LeenoUtils.py:109
pyleeno.MENU_suffisso_codice
def MENU_suffisso_codice()
Definition: pyleeno.py:1912
pyleeno.cerca_partenza
def cerca_partenza()
Definition: pyleeno.py:4648
pyleeno.struttura_off
def struttura_off()
Definition: pyleeno.py:7225
LeenoSheetUtils.cercaUltimaVoce
def cercaUltimaVoce(oSheet)
Definition: LeenoSheetUtils.py:184
pyleeno.copia_sheet
def copia_sheet(nSheet, tag)
Definition: pyleeno.py:1377
pyleeno.numera_voci
def numera_voci(bit=1)
Definition: pyleeno.py:5416
Dialogs.ImageControl
Definition: Dialogs.py:1387
pyleeno.set_area_stampa
def set_area_stampa()
Definition: pyleeno.py:8838
pyleeno.inserisci_nuova_riga_con_descrizione_th
Definition: pyleeno.py:8533
pyleeno.inizializza_computo
def inizializza_computo()
Definition: pyleeno.py:6297
LeenoSheetUtils.prossimaVoce
def prossimaVoce(oSheet, lrow, n=1, saltaCat=False)
Definition: LeenoSheetUtils.py:281
pyleeno.get_Formula
def get_Formula(n, a, b)
import pdb; pdb.set_trace() #debugger
Definition: pyleeno.py:6962
LeenoFormat.getNumFormat
def getNumFormat(FormatString)
Definition: LeenoFormat.py:5
pyleeno.descrizione_in_una_colonna
def descrizione_in_una_colonna(flag=False)
Definition: pyleeno.py:8705
pyleeno.numera_colonna
def numera_colonna()
Definition: pyleeno.py:8759
pyleeno.MENU_filtra_codice
def MENU_filtra_codice()
GESTIONE DELLE VISTE IN STRUTTURA ####################################.
Definition: pyleeno.py:7059
pyleeno.vedi_voce_xpwe
def vedi_voce_xpwe(oSheet, lrow, vRif)
Definition: pyleeno.py:6777
pyleeno.GetRegistryKeyContent
def GetRegistryKeyContent(sKeyName, bForUpdate)
Definition: pyleeno.py:8800
Dialogs.FixedText
Definition: Dialogs.py:989
pyleeno.inserisci_nuova_riga_con_descrizione_th.run
def run(self)
Definition: pyleeno.py:8540
SheetUtils.getUsedArea
def getUsedArea(oSheet)
Definition: SheetUtils.py:373
pyleeno.MENU_struttura_on
def MENU_struttura_on()
Definition: pyleeno.py:7168
pyleeno.struttura_Analisi
def struttura_Analisi()
Definition: pyleeno.py:7208
SheetUtils.uFindString
def uFindString(sString, oSheet, up=False)
Definition: SheetUtils.py:450
pyleeno.vai_a_variabili
def vai_a_variabili()
Definition: pyleeno.py:1542
pyleeno.Ins_Categorie
def Ins_Categorie(n)
Definition: pyleeno.py:893
pyleeno.avvia_IDE
def avvia_IDE()
Definition: pyleeno.py:811
LeenoSheetUtils.setLarghezzaColonne
def setLarghezzaColonne(oSheet)
Definition: LeenoSheetUtils.py:95
pyleeno.MENU_ricicla_misure
def MENU_ricicla_misure()
Definition: pyleeno.py:4829
SheetUtils.NominaArea
def NominaArea(oDoc, sSheet, sRange, sName)
Definition: SheetUtils.py:511
pyleeno.MENU_azzera_voce
def MENU_azzera_voce()
Definition: pyleeno.py:4088
pyleeno.hide_error
def hide_error(lErrori, icol)
Definition: pyleeno.py:8251
pyleeno.version_code.read
def read()
Definition: pyleeno.py:8342
pyleeno.somma
def somma()
Definition: pyleeno.py:9391
pyleeno.creaUsobollo
def creaUsobollo()
Definition: pyleeno.py:281
pyleeno.MENU_Inser_SottoCapitolo
def MENU_Inser_SottoCapitolo()
Definition: pyleeno.py:876
LeenoUtils.getServiceManager
def getServiceManager()
Definition: LeenoUtils.py:84
pyleeno.catalogo_stili_cella
def catalogo_stili_cella()
Definition: pyleeno.py:7482
pyleeno.MENU_Copia_riga_Ent
def MENU_Copia_riga_Ent()
Definition: pyleeno.py:4618
pyleeno.MENU_Inser_Capitolo
def MENU_Inser_Capitolo()
Definition: pyleeno.py:959
LeenoUtils.getComponentContext
def getComponentContext()
Definition: LeenoUtils.py:47
pyleeno.rigenera_tutte
def rigenera_tutte(arg=None)
Definition: pyleeno.py:5850
pyleeno.ctrl_d
def ctrl_d()
Definition: pyleeno.py:8579
LeenoContab.attiva_contabilita
def attiva_contabilita()
CONTABILITA ## CONTABILITA ## CONTABILITA ## CONTABILITA ## CONTABILITA #.
Definition: LeenoContab.py:291
pyleeno.trun
Definition: pyleeno.py:7356
Dialogs.YesNoDialog
def YesNoDialog(*Title, Text)
Definition: Dialogs.py:2545
pyleeno.elimina_stili_cella
def elimina_stili_cella()
Definition: pyleeno.py:7513
pyleeno.elimina_voci_doppie
def elimina_voci_doppie()
Definition: pyleeno.py:9244
Dialogs.ListBox
Definition: Dialogs.py:1670
pyleeno.sistema_stili
def sistema_stili(lrow=None)
Definition: pyleeno.py:5895
pyleeno.MENU_taglia_x
def MENU_taglia_x()
Definition: pyleeno.py:8603
Dialogs.Info
def Info(*Title='', Text='')
Definition: Dialogs.py:2539
pyleeno.vai_a_M1
def vai_a_M1()
Definition: pyleeno.py:1499
LeenoSheetUtils.inserisciRigaRossa
def inserisciRigaRossa(oSheet)
Definition: LeenoSheetUtils.py:398
Dialogs.Exclamation
def Exclamation(*Title='', Text='')
Definition: Dialogs.py:2536
pyleeno.MENU_nuova_voce_scelta
def MENU_nuova_voce_scelta()
Definition: pyleeno.py:6037
pyleeno.MENU_Rinumera_TUTTI_Capitoli2
def MENU_Rinumera_TUTTI_Capitoli2()
Definition: pyleeno.py:975
pyleeno.MENU_sproteggi_sheet_TUTTE
def MENU_sproteggi_sheet_TUTTE()
Definition: pyleeno.py:1645
pyleeno.MENU_vedi_voce
def MENU_vedi_voce()
Definition: pyleeno.py:6825
pyleeno.Inser_SuperCapitolo
def Inser_SuperCapitolo()
Definition: pyleeno.py:951
pyleeno.dlg_donazioni
def dlg_donazioni()
Definition: pyleeno.py:8490
pyleeno.MENU_elimina_voce
def MENU_elimina_voce()
Definition: pyleeno.py:4411
pyleeno.vista_terra_terra
def vista_terra_terra()
Definition: pyleeno.py:7451
pyleeno.vai_a_Computo
def vai_a_Computo()
Definition: pyleeno.py:1534
pyleeno.adegua_tmpl
def adegua_tmpl()
Definition: pyleeno.py:7598
pyleeno.trova_np
def trova_np()
Definition: pyleeno.py:9218
pyleeno.autoexec_off
def autoexec_off()
Definition: pyleeno.py:7333
pyleeno.calendario_mensile
def calendario_mensile()
Definition: pyleeno.py:8628
LeenoUtils.setGlobalVar
def setGlobalVar(name, value)
Definition: LeenoUtils.py:131
LeenoSheetUtils.cercaPartenza
def cercaPartenza(oSheet, lrow)
Definition: LeenoSheetUtils.py:205
Dialogs.FileSelect
def FileSelect(titolo='Scegli il file...', est=' *.*', mode=0, startPath=None)
SOME COMMON DIALOGS.
Definition: Dialogs.py:2448
pyleeno.autorun
def autorun()
Definition: pyleeno.py:7368
pyleeno.DelPrintArea
def DelPrintArea()
Definition: pyleeno.py:8819
Dialogs.Progress
Definition: Dialogs.py:2583
pyleeno.copia_riga_computo
def copia_riga_computo(lrow)
Definition: pyleeno.py:4487
Dialogs.HSizer
Definition: Dialogs.py:706
pyleeno.seleziona_voce
def seleziona_voce(lrow=None)
Definition: pyleeno.py:4367
pyleeno.show_sheets
def show_sheets(x=True)
Definition: pyleeno.py:1749
pyleeno.filtra_codice
def filtra_codice(voce=None)
Definition: pyleeno.py:7067
pyleeno.cancella_voci_non_usate
def cancella_voci_non_usate()
Definition: pyleeno.py:1942
pyleeno.MENU_nasconde_voci_azzerate
def MENU_nasconde_voci_azzerate()
Definition: pyleeno.py:4249
SheetUtils.FixNamedArea
def FixNamedArea()
Definition: SheetUtils.py:529
pyleeno.inserisci_nuova_riga_con_descrizione_th.__init__
def __init__(self)
Definition: pyleeno.py:8537
pyleeno.MENU_elimina_voci_azzerate
def MENU_elimina_voci_azzerate()
Definition: pyleeno.py:4191
pyleeno.MENU_numera_voci
def MENU_numera_voci()
numera le voci di computo o contabilità
Definition: pyleeno.py:5409
pyleeno.Inser_SottoCapitolo
def Inser_SottoCapitolo()
Definition: pyleeno.py:883
pyleeno.ins_voce_elenco
def ins_voce_elenco()
Definition: pyleeno.py:5598
LeenoAnalysis.MENU_impagina_analisi
def MENU_impagina_analisi()
Definition: LeenoAnalysis.py:123
LeenoSheetUtils.SbiancaCellePrintArea
def SbiancaCellePrintArea()
Definition: LeenoSheetUtils.py:52
pyleeno.txt_Format
def txt_Format(stile)
Definition: pyleeno.py:1728
pyleeno.Inser_Capitolo
def Inser_Capitolo()
Definition: pyleeno.py:966
pyleeno.version_code.write
def write()
Definition: pyleeno.py:8353
pyleeno.MENU_struttura_off
def MENU_struttura_off()
Definition: pyleeno.py:7218
pyleeno.scelta_viste
def scelta_viste()
Definition: pyleeno.py:2053
pyleeno.stampa_PDF
def stampa_PDF()
Definition: pyleeno.py:9502
pyleeno.Menu_adattaAltezzaRiga
def Menu_adattaAltezzaRiga()
adatta_altezza_riga moved to LeenoSheetUtils.py as adattaAltezzaRiga
Definition: pyleeno.py:1852
pyleeno.SubSum_SottoCap
def SubSum_SottoCap(lrow)
Definition: pyleeno.py:1102
pyleeno.genera_sommario
def genera_sommario()
Definition: pyleeno.py:2622
pyleeno.ods2pdf
def ods2pdf(oDoc, sFile)
Definition: pyleeno.py:8031
LeenoFormat.getFormatString
def getFormatString(stile_cella)
Definition: LeenoFormat.py:25
pyleeno.trun.__init__
def __init__(self)
Definition: pyleeno.py:7358
pyleeno.MENU_nuovo_usobollo
def MENU_nuovo_usobollo()
Definition: pyleeno.py:303
pyleeno.dettaglio_misura_rigo
def dettaglio_misura_rigo()
Definition: pyleeno.py:5000
Dialogs.Dialog
Definition: Dialogs.py:2189
LeenoComputo.insertVoceComputoGrezza
def insertVoceComputoGrezza(oSheet, lrow)
Definition: LeenoComputo.py:115
Dialogs.Button
Definition: Dialogs.py:1527
LeenoUtils.createUnoService
def createUnoService(serv)
Definition: LeenoUtils.py:91
pyleeno.MENU_avvia_IDE
def MENU_avvia_IDE()
Definition: pyleeno.py:804
pyleeno.tante_analisi_in_ep
def tante_analisi_in_ep()
Definition: pyleeno.py:3957
pyleeno.riordina_ElencoPrezzi
def riordina_ElencoPrezzi(oDoc)
Definition: pyleeno.py:2713
LeenoUtils.getDesktop
def getDesktop()
Definition: LeenoUtils.py:59
pyleeno.calendario
def calendario()
Definition: pyleeno.py:9422
LeenoConfig.Config
Definition: LeenoConfig.py:26
pyleeno.MENU_inverti_segno
def MENU_inverti_segno()
Definition: pyleeno.py:4899
pyleeno.ssUltimus
def ssUltimus()
Definition: pyleeno.py:6932
LeenoComputo.circoscriveVoceComputo
def circoscriveVoceComputo(oSheet, lrow)
Definition: LeenoComputo.py:65
Dialogs.VSizer
Definition: Dialogs.py:848
pyleeno.setFormatoNumeri
def setFormatoNumeri(valore)
Definition: pyleeno.py:6873
pyleeno.XPWE_export_th.run
def run(self)
Definition: pyleeno.py:8521
pyleeno.codice_voce
def codice_voce(lrow, cod=None)
Definition: pyleeno.py:664
LeenoSheetUtils.inserSuperCapitolo
def inserSuperCapitolo(oSheet, lrow, sTesto='Super Categoria')
Definition: LeenoSheetUtils.py:524
LeenoSheetUtils.elimina_voce
def elimina_voce(lrow=None, msg=1)
Definition: LeenoSheetUtils.py:332
pyleeno.invia_voce_interno
def invia_voce_interno()
Definition: pyleeno.py:310
pyleeno.setPreview
def setPreview(arg=0)
Definition: pyleeno.py:1684
pyleeno.fissa
def fissa()
Definition: pyleeno.py:9126
pyleeno.MENU_invia_voce
def MENU_invia_voce()
Definition: pyleeno.py:355
SheetUtils.visualizza_PageBreak
def visualizza_PageBreak(arg=True)
Definition: SheetUtils.py:550
pyleeno.genera_variante
def genera_variante()
Definition: pyleeno.py:2575
pyleeno.InputBox
def InputBox(sCella='', t='')
Definition: pyleeno.py:8226
pyleeno.Circoscrive_Analisi
def Circoscrive_Analisi(lrow)
Definition: pyleeno.py:4038
pyleeno.MENU_copia_sorgente_per_git
def MENU_copia_sorgente_per_git()
Definition: pyleeno.py:748
pyleeno.MENU_doppioni
def MENU_doppioni()
Definition: pyleeno.py:2740
pyleeno.description_upd
def description_upd()
Definition: pyleeno.py:8377
pyleeno.struttura_ComputoM
def struttura_ComputoM()
Definition: pyleeno.py:7183
pyleeno.rigenera_voce
def rigenera_voce(lrow=None)
Definition: pyleeno.py:5644
pyleeno.version_code
Definition: pyleeno.py:8335
pyleeno.ins_voce_contab
def ins_voce_contab(lrow=0, arg=1, cod=None)
Definition: pyleeno.py:6060
pyleeno.MENU_firme_in_calce
def MENU_firme_in_calce(lrowF=None)
Definition: pyleeno.py:3550
LeenoEvents.assegna
def assegna()
Definition: LeenoEvents.py:85
Dialogs.getBigIconSize
def getBigIconSize()
Definition: Dialogs.py:103
pyleeno.debug_ConditionalFormat
def debug_ConditionalFormat()
Definition: pyleeno.py:5190
pyleeno.MENU_apri_manuale
def MENU_apri_manuale()
Definition: pyleeno.py:7324
pyleeno.dettaglio_misure
def dettaglio_misure(bit)
Definition: pyleeno.py:5059
SheetUtils.getLastUsedRow
def getLastUsedRow(oSheet)
Definition: SheetUtils.py:392
pyleeno.vai_a_ElencoPrezzi
def vai_a_ElencoPrezzi(event=None)
Definition: pyleeno.py:1526
pyleeno.MENU_nuovo_computo
def MENU_nuovo_computo()
Definition: pyleeno.py:295
pyleeno.MENU_mostra_tabs_computo
def MENU_mostra_tabs_computo()
Definition: pyleeno.py:1361
pyleeno.MENU_sistema_pagine
def MENU_sistema_pagine()
Definition: pyleeno.py:8885
pyleeno.LeenO_path
def LeenO_path()
Definition: pyleeno.py:245
pyleeno.MENU_pesca_cod
def MENU_pesca_cod()
Definition: pyleeno.py:4752
pyleeno.trun.run
def run(self)
Definition: pyleeno.py:7361
pyleeno.Sincronizza_SottoCap_Tag_Capitolo_Cor
def Sincronizza_SottoCap_Tag_Capitolo_Cor(oSheet)
Definition: pyleeno.py:1227
pyleeno.getCellStyle
def getCellStyle(level, pos)
Definition: pyleeno.py:6978
pyleeno.errore
def errore()
sardegna_2019 moved to LeenoImport.py
Definition: pyleeno.py:9384
pyleeno.strall
def strall(el, n=3, pos=0)
Definition: pyleeno.py:6854
pyleeno.loVersion
def loVersion()
Definition: pyleeno.py:1833
pyleeno.paste_format
def paste_format()
Definition: pyleeno.py:5290
pyleeno.delete
def delete(arg)
SheetUtils.visualizza_PageBreak moved to SheetUtils.py.
Definition: pyleeno.py:5227
pyleeno.copia_riga_contab
def copia_riga_contab(lrow)
Definition: pyleeno.py:4528
pyleeno.MENU_leeno_conf
def MENU_leeno_conf()
Definition: pyleeno.py:97
pyleeno.vai_a_Scorciatoie
def vai_a_Scorciatoie()
Definition: pyleeno.py:1551
pyleeno.MENU_mostra_fogli_principali
def MENU_mostra_fogli_principali()
Definition: pyleeno.py:1323
pyleeno.basic_LeenO
def basic_LeenO(funcname, *args)
https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=27805&p=127383
Definition: pyleeno.py:81
Dialogs.pickDate
def pickDate(curDate=None)
Definition: Dialogs.py:2699
pyleeno.MENU_elimina_righe
def MENU_elimina_righe()
Definition: pyleeno.py:4420
pyleeno.cerca_in_elenco
def cerca_in_elenco()
Definition: pyleeno.py:4705
pyleeno.XPWE_export_th.__init__
def __init__(self)
Definition: pyleeno.py:8518
pyleeno.oggi
def oggi()
Definition: pyleeno.py:738
pyleeno.vai_a_S2
def vai_a_S2()
Definition: pyleeno.py:1508
pyleeno.ordina_col
def ordina_col(ncol)
Definition: pyleeno.py:1594
Dialogs.getEditBox
def getEditBox(txt)
Definition: Dialogs.py:134
pyleeno.subst_str
def subst_str(cerca, sostituisce)
Definition: pyleeno.py:8777
pyleeno.MENU_inserisci_nuova_riga_con_descrizione
def MENU_inserisci_nuova_riga_con_descrizione()
Definition: pyleeno.py:8570
pyleeno.XPWE_export_run
def XPWE_export_run()
Definition: pyleeno.py:7913
pyleeno.MENU_riordina_ElencoPrezzi
def MENU_riordina_ElencoPrezzi()
Definition: pyleeno.py:2703
pyleeno.creaComputo
def creaComputo(arg=1)
Definition: pyleeno.py:256
pyleeno.PdfDlg
def PdfDlg()
Definition: pyleeno.py:9438
pyleeno.nascondi_sheets
def nascondi_sheets()
Definition: pyleeno.py:1774
pyleeno.XPWE_export_th
Definition: pyleeno.py:8514
pyleeno.MENU_parziale
def MENU_parziale()
Definition: pyleeno.py:6688
pyleeno.autoexec
def autoexec()
Definition: pyleeno.py:7386
pyleeno.MENU_XPWE_export
def MENU_XPWE_export()
Definition: pyleeno.py:8525
pyleeno.MENU_analisi_in_ElencoPrezzi
def MENU_analisi_in_ElencoPrezzi()
Definition: pyleeno.py:3899
LeenoSheetUtils.setVisibilitaColonne
def setVisibilitaColonne(oSheet, sValori)
Definition: LeenoSheetUtils.py:81
pyleeno.MENU_hl
def MENU_hl()
Definition: pyleeno.py:9278
pyleeno.MENU_numera_colonna
def MENU_numera_colonna()
Definition: pyleeno.py:8753
pyleeno.processo
def processo(arg)
Definition: pyleeno.py:8790
pyleeno.XPWE_out
def XPWE_out(elaborato, out_file)
Scrive un file.
Definition: pyleeno.py:2832
pyleeno.comando
def comando(cmd)
Definition: pyleeno.py:5201
pyleeno.MENU_mostra_tabs_contab
def MENU_mostra_tabs_contab()
Definition: pyleeno.py:1345
pyleeno.chiudi_dialoghi
def chiudi_dialoghi(event=None)
Definition: pyleeno.py:7972
pyleeno.MENU_inserisci_Riga_rossa
def MENU_inserisci_Riga_rossa()
Definition: pyleeno.py:6483
pyleeno.inizializza_analisi
def inizializza_analisi()
Definition: pyleeno.py:6430
pyleeno.SubSum_SuperCap
def SubSum_SuperCap(lrow)
Definition: pyleeno.py:1034
pyleeno.LeggiPosizioneCorrente
def LeggiPosizioneCorrente()
Definition: pyleeno.py:5389
pyleeno.getDCCSheet
def getDCCSheet()
Definition: pyleeno.py:721
pyleeno.copia_riga_analisi
def copia_riga_analisi(lrow)
Definition: pyleeno.py:4563
pyleeno.SubSum
def SubSum(lrow, sub=False)
Definition: pyleeno.py:7000
pyleeno.DlgMain
def DlgMain()
Definition: pyleeno.py:8101
pyleeno.SubSum_Cap
def SubSum_Cap(lrow)
Definition: pyleeno.py:1161
pyleeno.setTabColor
def setTabColor(colore)
Definition: pyleeno.py:1705
pyleeno.paste_clip
def paste_clip(arg=None, insCells=0)
Definition: pyleeno.py:5249