2 LeenO - modulo di gestione eventi del documento e dei fogli
6 from com.sun.star.beans
import PropertyValue
8 import LeenoBasicBridge
12 Attribuisce specifica macro ad evento di un foglio
23 oProp0 = PropertyValue()
24 oProp0.Name =
'EventType'
25 oProp0.Value =
'Script'
26 oProp1 = PropertyValue()
27 oProp1.Name =
'Script'
28 oProp1.Value = miamacro
33 properties = tuple(oProp)
35 oSheet = oDoc.getSheets().getByName(nSheet)
37 oSheet.Events,
'replaceByName',
38 (nEvento, uno.Any(
'[]com.sun.star.beans.PropertyValue', properties))
46 Attribuisce specifica macro ad evento del documento
52 oProp0 = PropertyValue()
53 oProp0.Name =
'EventType'
54 oProp0.Value =
'Script'
55 oProp1 = PropertyValue()
56 oProp1.Name =
'Script'
57 oProp1.Value = miamacro
62 properties = tuple(oProp)
66 oDoc.Events,
'replaceByName',
67 (nEvento, uno.Any(
'[]com.sun.star.beans.PropertyValue', properties))
75 Ricostruisce la URL della macro
77 if sys.platform ==
'linux' or sys.platform ==
'darwin':
78 pmacro = LeenoBasicBridge.myPath.split(
'/')
79 elif sys.platform ==
'win32':
80 pmacro = LeenoBasicBridge.myPath.split(
'\\')
81 return 'vnd.sun.star.script:' +
'|'.join((pmacro[-3:])) +
'|' + modulo +
'.py$' + miamacro +
'?language=Python&location=user:uno_packages'
87 Assegna le macro agli eventi del documento dei fogli
98 '''sotto Linux l'assegnazione delle macro agli eventi deve passare attraverso Basic, quindi:'''
101 macro_SHEET (
"Elenco Prezzi",
"OnFocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
103 if oDoc.getSheets().hasByName(
'Analisi di Prezzo'):
105 macro_SHEET (
"Analisi di Prezzo",
"OnFocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
108 macro_SHEET (
"COMPUTO",
"OnFocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
110 if oDoc.getSheets().hasByName(
"VARIANTE"):
112 macro_SHEET (
"VARIANTE",
"OnFocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
114 if oDoc.getSheets().hasByName(
"CONTABILITA"):
116 macro_SHEET (
"CONTABILITA",
"OnFocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
117 macro_SHEET (
"S2",
"OnUnfocus",
"vnd.sun.star.script:UltimusFree2.Header_Footer.set_header_auto?language=Basic&location=application")
119 macro_SHEET (
"S1",
"OnUnfocus",
'vnd.sun.star.script:UltimusFree2.PY_bridge.Vedi?language=Basic&location=application')
123 macro_DOC (
"OnNew",
"vnd.sun.star.script:Standard.Controllo.Controlla_Esistenza_LibUltimus?language=Basic&location=document")
125 macro_DOC (
"OnLoad",
"vnd.sun.star.script:Standard.Controllo.Controlla_Esistenza_LibUltimus?language=Basic&location=document")
126 macro_DOC (
"OnPrepareUnload",
"vnd.sun.star.script:UltimusFree2._variabili.autoexec_off?language=Basic&location=application")
127 macro_DOC (
"OnUnload",
"vnd.sun.star.script:UltimusFree2.Lupo_0.Svuota_Globale?language=Basic&location=application")
128 macro_DOC (
"OnSave",
macro_URL(
"LeenoBasicBridge",
"bak0"))
131 macro_DOC (
"OnSaveAs",
"vnd.sun.star.script:UltimusFree2.Lupo_0.Svuota_Globale?language=Basic&location=application")
133 macro_DOC (
"OnSaveAsFailed",
"vnd.sun.star.script:UltimusFree2._variabili.autoexec?language=Basic&location=application")
137 macro_DOC (
"OnFocus",
macro_URL(
"LeenoToolbars",
"Vedi"))
154 Rimuove le macro dagli eventi del codumento e dei fogli.
155 Assegna al document le macro per il controllo dell'esistenza di LeenO
158 lista_fogli = oDoc.Sheets.ElementNames
160 eventi = oDoc.CurrentController.ActiveSheet.Events.ElementNames
161 eventi_doc = oDoc.Events.ElementNames
162 for nome
in lista_fogli:
166 for ev
in eventi_doc:
168 macro_DOC (
"OnNew",
"vnd.sun.star.script:Standard.Controllo.Controlla_Esistenza_LibUltimus?language=Basic&location=document")
169 macro_DOC (
"OnLoad",
"vnd.sun.star.script:Standard.Controllo.Controlla_Esistenza_LibUltimus?language=Basic&location=document")