######!\Python27\python # -*- coding: utf-8 -*- # All imports import sys import os # Changes for LliureX #Llog(os.environ[miHOME]+"/salt4") sys.path.append(sys.exec_prefix) sltversion="4.0.10" #Constantes que indican la plataforma esLinux=False esMac=False miHOME='APPDATA' pyLIB=sys.exec_prefix+"\\lib" if sys.platform.lower().find('linux')>=0: esLinux=True miHOME='HOME' pyLIB=sys.exec_prefix+"/lib" sys.path.append(pyLIB) # 1. Obtener srvPath if esLinux: srvPath="/usr/share/salt-server" import uno else: import uno srvPath=os.environ['PROGRAMFILES']+"/salt4" srvPath=os.path.abspath(srvPath) srvPath2=os.path.abspath(os.environ[miHOME]+"/salt4") #alternativo # 2. Obtener usrPath usrPath=os.path.abspath(os.environ[miHOME]+"/.salt4") try: if os.environ['USERNAME']=='root': usrPath=os.path.abspath("/root/.salt4") except: pass try: if os.environ['USER']=='root': usrPath=os.path.abspath("/root/.salt4") except: pass if not os.path.exists(usrPath): os.mkdir(usrPath) # 3. Buscar archivo de configuracien if not os.path.exists(os.path.abspath(srvPath+'/sltsrv.config')) and os.path.exists(os.path.abspath(srvPath2+'/sltsrv.config')): srvPath=srvPath2 # 4. Copiar config si es necesario _config=os.path.abspath('/var/lib/salt/sltsrv.config') if not os.path.exists(_config): _config=os.path.abspath(srvPath+'/sltsrv.config') if os.path.exists(_config): if os.path.exists(os.path.abspath(usrPath+'/sltsrv.config')): # 2to3 #fsrv=file(_config,'rb') fsrv=open(_config,'rb') # 2to3 #fusr=file(os.path.abspath(usrPath+'/sltsrv.config'),'rb') fusr=open(os.path.abspath(usrPath+'/sltsrv.config'),'rb') cfgsrv=eval(fsrv.read()) cfgusr=eval(fusr.read()) fsrv.close() fusr.close() if not 'entorn' in cfgsrv or not 'entorn' in cfgusr or not 'sltinitime' in cfgsrv['entorn'] or not 'sltinitime' in cfgusr['entorn'] or cfgsrv['entorn']['sltinitime']!=cfgusr['entorn']['sltinitime']: import shutil shutil.copy(_config,os.path.abspath(usrPath+'/sltsrv.config')) try: for root,dirs, files in os.walk(usrPath): for name in files: if name[0:3]=='tmp': os.remove(os.path.join(root,name)) except: pass else: import shutil shutil.copy(_config,os.path.abspath(usrPath+'/sltsrv.config')) try: for root,dirs, files in os.walk(usrPath): for name in files: if name[0:3]=='tmp': os.remove(os.path.join(root,name)) except: pass def Llog(msg): f=open(os.path.abspath(usrPath+'/salt4.log'),'a') f.write(str(msg)) f.close() # Leer configuracion # 2to3 # f=file(os.path.abspath(usrPath+'/sltsrv.config'),'rb') f=open(os.path.abspath(usrPath+'/sltsrv.config'),'rb') scfg=f.read() f.close() cfg=eval(scfg) if 'entorn' in cfg: if 'sltsrvpaths' in cfg['entorn']: sys.path.extend(cfg['entorn']['sltsrvpaths']) ooopath=sys.executable bn=os.path.basename(ooopath) ooopath=os.path.dirname(ooopath) ooopathpy="" while bn!="": if bn.lower()=="program": ooopath=os.path.abspath(ooopath+"/program") break elif bn.lower().find("python-")>-1: ooopathpy=os.path.abspath(ooopath+"/"+bn) bn=os.path.basename(ooopath) ooopath=os.path.dirname(ooopath) if ooopathpy!="": sys.path.append(os.path.abspath(ooopathpy+"/lib")) sys.path.append(os.path.abspath(ooopathpy)) else: sys.path.append(os.path.abspath(ooopath+"/python-core-2.3.4/lib")) sys.path.append(os.path.abspath(ooopath+"/python-core-2.3.4")) sys.path.append(ooopath) try: import unohelper except: pass import socket import codecs import platform from com.sun.star.task import XJobExecutor #Numero de lineas en lis ListBox if esLinux: nitems=16 else: nitems=16 #20 def sltDate(): #Fecha del addon try: _txt=__name__ finally: return _txt if os.path.exists(os.path.abspath(__file__)): return time.localtime(os.stat(os.path.abspath(__file__))[8]) else: return None def uts(s): #Pasar cadena unicode a string i=0 t="" while i255: c=quitarFF(c) t=t+chr(ord(c)) i=i+1 return t def quitarFF(pal): #Eliminar caracteres unicode superiores a 255 n=ord(pal) if n==8216 or n==8219 or n==8224: ret="'" elif n==8221: ret=chr(148) elif n==8220: ret=chr(147) elif n==8217: ret=chr(146) else: ret="_" return ret def ucodeSiLinux(s): if esLinux: try: _s=unicode(s,'latin-1').encode('utf-8') except: _s=s else: _s=s return _s def socketConnect(): try: sck=socket.socket(socket.AF_INET,socket.SOCK_STREAM) sck.connect(('localhost',20001)) except: #iniciar server import os,time # 2to3 #f=file(os.path.abspath(usrPath+'/sltsrv.config'),'rb') f=open(os.path.abspath(usrPath+'/sltsrv.config'),'rb') scfg=f.read() f.close() cfg=eval(scfg) if 'entorn' in cfg: if 'sltsrvexe' in cfg['entorn']: if 'sltsrvpath' in cfg['entorn']: sltsrvpath=os.path.abspath(cfg['entorn']['sltsrvpath']) os.chdir(sltsrvpath) if 'sltsrvexe' in cfg['entorn']: sltsrvargs=cfg['entorn']['sltsrvexe'] sltsrvexe=os.path.abspath(sltsrvargs[0]) if esLinux: modo=os.P_NOWAIT else: modo=os.P_DETACH os.spawnve(modo,sltsrvexe,sltsrvargs,os.environ) i=5 while i>0: try: time.sleep(2) sck.connect(('localhost',20001)) except: i=i-1 else: break if i<=0: msg=MsgWindow('Cal iniciar el servidor Salt4') sck=None else: msg=MsgWindow('Cal iniciar el servidor Salt4') sck=None return sck class uooUNOext: #simular la clase uooUNOobj llamada desde sltooo_extern (test) def __init__(self, ctx): #component context self.ctx=ctx def action(self,args): smgr = self.ctx.ServiceManager import doooLib doooLib.getServiceManager(sMan=smgr) doooLib.getDesktop() # retrieve the desktop object desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx ) # get current document model model = desktop.getCurrentComponent() # access the document's text property #text = model.Text # create a cursor #cursor = text.createTextCursor() #Cursor vcursorsupplier=model.getCurrentController() vcursor=vcursorsupplier.getViewCursor() text=vcursor.getText() cur=text.createTextCursorByRange(vcursor.getStart()) #Funcion a realizar if args=="dicc": oDic=DicSaltWindow(desktop) oDic.Load() oDic.Show("tren") oDic.Espera() elif args=="diccbil": oDic=DicBilWindow(desktop) oDic.Load() oDic.Espera() elif args=="sin": pass elif args=="verbs": oVerbs=VerbsWindow(desktop) oVerbs.Load() oVerbs.Espera() elif args=="info": oInfo=InfoWindow(desktop) oInfo.Espera() elif args=="mouse": ListenFields(model) Espera() # implement a UNO component by deriving from the standard unohelper.Base class # and from the interface(s) you want to implement. class uooUNOobj( unohelper.Base, XJobExecutor ): def __init__( self, ctx ): # store the component context for later use self.ctx = ctx def trigger( self, args ): # note: args[0] == "HelloWorld", see below config settings # retrieve the desktop object desktop = self.ctx.ServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", self.ctx ) import doooLib doooLib.getServiceManager(sMan=self.ctx.ServiceManager) # get current document model model = desktop.getCurrentComponent() # access the document's text property #text = model.Text # create a cursor #cursor = text.createTextCursor() #Cursor vcursorsupplier=model.getCurrentController() vcursor=vcursorsupplier.getViewCursor() text=vcursor.getText() cur=text.createTextCursorByRange(vcursor.getStart()) #Funcion a realizar if args=="dicc": oDic=DicSaltWindow(desktop) oDic.Load() #oDic.Espera() elif args=="diccbil": oDic=DicBilWindow(desktop) oDic.Load() #oDic.Espera() elif args=="sin": pass elif args=="verbs": oVerbs=VerbsWindow(desktop) oVerbs.Load() #oVerbs.Espera() elif args=="info": oInfo=InfoWindow(desktop) #oInfo.Espera() elif args=="mouse": ListenFields(model) Espera() class uooDoc: """ Documento para presentar informacion desde los utilities""" def __init__(self,desktop,ncolumns=0): self.pagini=True self.desktop=desktop self.doc=None def NewDoc(self,ncolumns=0): #Obtener un nuevo documentos (con o sin formato de columnas) self.pagini=True model=self.desktop.getCurrentComponent() text=model.Text cur=text.createTextCursor() cur.gotoEnd(1) if cur.String!="": #Documento en uso: obtener uno nuevo doc=self.desktop.loadComponentFromURL("private:factory/swriter","_blank",0,()) text=doc.Text cur=text.createTextCursor() cur.gotoEnd(1) self.cursor=cur if ncolumns!=0: #Formato columnas oSect=model.createInstance("com.sun.star.text.TextSection") #oSect.setName("sltVerbs") oCols=model.createInstance("com.sun.star.text.TextColumns") oCols.setColumnCount(ncolumns) oSect.TextColumns=oCols text.insertTextContent(cur,oSect,True) def PrintDoc(self,fpath): #Presentar como documento el archivo cuyo path esta en fpath #Antes de abrir otro cerramos el anterior (si hay) if self.doc!=None: try: self.doc.close(True) except: pass url=self.ConvertToUrl(fpath) flags=uno.getConstantByName("com.sun.star.frame.FrameSearchFlag.CREATE")+uno.getConstantByName("com.sun.star.frame.FrameSearchFlag.ALL") self.doc=self.desktop.loadComponentFromURL(url,"Salt",flags,()) def PrintLine(self,lin,bold=None,italic=None,font=None,size=None,color=None): #Mover linea al final del documento self.cursor.gotoEnd(0) self.cursor.String=lin if bold!=None: if bold==True: self.cursor.CharWeight=150 else: self.cursor.CharWeight=100 if italic!=None: if italic==True: self.cursor.CharPosture=2 else: self.cursor.CharPosture=0 if font!=None: self.cursor.CharFontName=font if size!=None: self.cursor.CharHeight=size if color!=None: self.cursor.CharColor=color def NewPage(self): #Sub InsertPageBreak( oCursor ) #oText = oCursor.getText() #oText.insertControlCharacter( oCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False ) #oCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE #End Sub if not self.pagini: self.PrintLine("") text=self.cursor.getText() text.insertControlCharacter(self.cursor,uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK"),0) self.cursor.BreakType=uno.getConstantByName("com.sun.star.style.BreakType.PAGE_BEFORE") self.pagini=False #self.cursor.BreakType=5 #self.cursor.gotoEnd(0) #self.cursor.String='\n' def GotoEnd(self): #Dejar que se vea el final del documento vcur=self.desktop.getCurrentComponent().getCurrentController().getViewCursor() vcur.gotoEnd(0) def ConvertToUrl(self,fpath): #Convertir formato path a URL y devolver el valor convertido furl=fpath furl.replace("\\","/") furl="file:///"+furl return furl from doooWindowLib import DBListenerWindow import time class dicWindow(DBListenerWindow): #Eventos def lbxLemas_clicked(self,oItemEvent): txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def txtConsulta_changed(self,oTextEvent): txt=self.NoAcc(uts(self.getEditText("txtConsulta"))) self.Refresh(txt) def txtConsulta_keypressed(self,oKeyEvent): if oKeyEvent.KeyCode==1024 or oKeyEvent.KeyCode==1280: self.setFocus("lbxLemas") self.selectListBoxItemPos("lbxLemas",0,True) txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def scrLemas_changed(self,oAdjustmentEvent): self.Refresh(oAdjustmentEvent.Value) def cmbCancel_clicked( self, oActionEvent ): """This is called when the Cancel button is clicked.""" self.windowClose() def windowClosing(self,oActionEvent): pass def windowDeactivated(self,oActionEvent): pass #self.windowToFront() #Metodos def Espera(self): while not self.terminar: time.sleep(1) def Refresh(self,txt): #Presentar items en la lista a partir de txt self.removeListBoxItems("lbxLemas",0,self.getListBoxItemCount("lbxLemas")) if str(type(txt))=="": txt=uts(txt) if str(type(txt))=="": if txt.isdigit(): ini=int(txt) if ini>len(self.llms): ini=len(self.llms) elif txt=="": ini=0 else: try: (k,n)=self.bt.set_location(txt) if k>=txt: ini=eval(n) else: ini=len(self.llms) except: ini=len(self.llms) else: ini=int(txt) i=ini while i": txt=uts(txt) if str(type(txt))=="": if txt.isdigit(): ini=int(txt) if ini>len(self.lvbs): ini=len(self.lvbs) elif txt=="": ini=0 else: try: k=txt n=self.bt.get(k) #(k,n)=self.bt.set_location(txt) if k>=txt and n != None: ini=eval(n) else: ini=len(self.lvbs) except Exception as e: ini=len(self.lvbs) else: ini=int(txt) i=ini while i": for llin in lin: self.doc.PrintLine(ucodeSiLinux(llin)+'\n',bold=False,size=12) elif self.NoAcc(lin.split()[0]).isupper(): self.doc.PrintLine('\n'+ucodeSiLinux(lin)+'\n',bold=True,size=14) elif self.NoAcc(lin.split()[0]).istitle(): self.doc.PrintLine(ucodeSiLinux(lin)+'\n',bold=True,size=12) self.windowToFront() #Para que se vea el final self.doc.GotoEnd() def NoAcc(self,s): #Devuelve la cadena solo con vocales sin acentuar s=s.replace('\E0','a') s=s.replace('\E1','a') s=s.replace('\E8','e') s=s.replace('\E9','e') s=s.replace('\ED','i') s=s.replace('\EF','i') s=s.replace('\F2','o') s=s.replace('\F3','o') s=s.replace('\FA','u') s=s.replace('\FC','u') s=s.replace('l\B7','l') s=s.replace('\F1','n') s=s.replace('\E7','c') return s # end of class VerbsWindow class DicSaltWindow(DBListenerWindow): def __init__(self,desktop): DBListenerWindow.__init__( self, "D. Salt" ) self.addOptionButton( "optDir", 6, 10, 70, 16, "Directe", itemListenerProc = self.optDir_clicked ) self.addOptionButton( "optInv", 81, 10, 80, 16, "Invers", itemListenerProc = self.optInv_clicked ) self.addEdit( "txtConsulta", 6, 30, 200, 16, "",textListenerProc=self.txtConsulta_changed,keyListenerProc=self.txtConsulta_keypressed ) self.setEditEditable("txtConsulta",True) self.addListBox( "lbxLemas", 6, 55,180,220, bDropdown=False,itemListenerProc = self.lbxLemas_clicked ) self.addScrollBar("scrLemas",184,55,20,220,bOrientation=1,adjustmentListenerProc=self.scrLemas_changed) self.addButton( "cmbCancel", 16, 350, 125, 22, "Cancel·la", actionListenerProc = self.cmbCancel_clicked ) wpos={'left':-1,'top':137,'width':250,'height':400} self.setWindowPosSize( wpos['left'], wpos['top'], 250, 400 ) self.terminar=False self.llms=[] # bsddb # self.bt=bsddb.btopen(None) self.bt={} self.tl="lema" #tipo de lista (lema, amel) self.setOptionButtonState("optDir",True) self.desktop=desktop self.doc=uooDoc(desktop) #self.sck=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #self.sck.connect(('localhost',20001)) self.sck=socketConnect() if self.sck==None: self.windowClose() self.setFocus("txtConsulta") #Eventos def optDir_clicked(self,oItemEvent): self.tl="lema" self.Load() def optInv_clicked(self,oItemEvent): self.tl="amel" self.Load() def lbxLemas_clicked(self,oItemEvent): txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def txtConsulta_changed(self,oTextEvent): txt=self.NoAcc(uts(self.getEditText("txtConsulta"))) self.Refresh(txt) def txtConsulta_keypressed(self,oKeyEvent): if oKeyEvent.KeyCode==1024 or oKeyEvent.KeyCode==1280: self.setFocus("lbxLemas") self.selectListBoxItemPos("lbxLemas",0,True) txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def scrLemas_changed(self,oAdjustmentEvent): self.Refresh(oAdjustmentEvent.Value) def cmbCancel_clicked( self, oActionEvent ): """This is called when the Cancel button is clicked.""" self.windowClose() def windowClosed(self,oActionEvent): self.terminar=True self.sck.close() #if platform.system()=="Windows": rect=self.getWindowPosSize() self.wp["dicsaltwindow"]=str({'left':rect.X,'top':rect.Y,'width':rect.Width,'height':rect.Height}) self.wp.sync() self.wp.close() def windowClosing(self,oActionEvent): pass def windowDeactivated(self,oActionEvent): pass #self.windowToFront() #Metodos def Espera(self): while not self.terminar: time.sleep(1) def Load(self): #Cargar lista de palabras i=0 tmp="" self.llms=[] # bsddb # self.bt.close() # self.bt=bsddb.btopen(None) self.bt={} self.setEditText("txtConsulta","") #Cargar lista de lemas datos=str(('dicsalt',('_lista',self.tl,usrPath))).encode('latin-1') self.sck.send(datos) datos=self.sck.recv(200000).decode('latin-1') comando,(lema,tl,tmp)=eval(datos) # 2to3 #f=file(tmp,'r+b') f=open(tmp,'r+b') self.llms=eval(f.read()) f.close() for i in range(len(self.llms)): k=ucodeSiLinux(self.llms[i]) self.bt[self.Invers(self.NoAcc(k))]=str(i) if k!=self.llms[i]: self.llms[i]=k self.setScrollBarScrollValueMax("scrLemas",i) self.Refresh(0) self.windowToFront() def Refresh(self,txt): #Presentar items en la lista a partir de txt self.removeListBoxItems("lbxLemas",0,self.getListBoxItemCount("lbxLemas")) # TODO if str(type(txt))=="": txt=uts(txt) if str(type(txt))=="": if txt.isdigit(): ini=int(txt) if ini>len(self.llms): ini=len(self.llms) elif txt=="": ini=0 else: try: txt=self.Invers(txt) k=txt n=self.bt.get(k) #(k,n)=self.bt.set_location(txt) if k>=txt: ini=eval(n) else: ini=len(self.llms) except Exception as e: ini=len(self.llms) else: ini=int(txt) i=ini while iVal", itemListenerProc = self.optCV_clicked ) self.addOptionButton( "optVC", 90, 10, 75, 16, u"Val>Cas", itemListenerProc = self.optVC_clicked ) self.addEdit( "txtConsulta", 6, 30, 200, 16, "",textListenerProc=self.txtConsulta_changed,keyListenerProc=self.txtConsulta_keypressed ) self.setEditEditable("txtConsulta",True) self.addListBox( "lbxLemas", 6, 55,200,220, bDropdown=False,itemListenerProc = self.lbxLemas_clicked ) self.addScrollBar("scrLemas",207,55,20,220,bOrientation=1,adjustmentListenerProc=self.scrLemas_changed) self.addButton( "cmbCancel", 40, 350, 106, 22, "Cancel·la", actionListenerProc = self.cmbCancel_clicked ) wpos={'left':-1,'top':137,'width':166,'height':400} self.setWindowPosSize( wpos['left'], wpos['top'], 250, 400 ) self.terminar=False self.llms=[] # bsddb #self.bt=bsddb.btopen(None) self.bt={} # bsddb.btopen(None) self.tl="cv" #tipo de lista (cv, vc) self.setOptionButtonState("optCV",True) self.setWindowTitle(u"C > V") self.desktop=desktop self.doc=uooDoc(desktop) #self.sck=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #self.sck.connect(('localhost',20001)) self.sck=socketConnect() if self.sck==None: self.windowClose() self.setFocus("txtConsulta") #Eventos def optCV_clicked(self,oItemEvent): self.setWindowTitle(u"C > V") self.tl="cv" self.Load() def optVC_clicked(self,oItemEvent): self.setWindowTitle(u"V > C") self.tl="vc" self.Load() def lbxLemas_clicked(self,oItemEvent): txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def txtConsulta_changed(self,oTextEvent): txt=self.NoAcc(uts(self.getEditText("txtConsulta"))) self.Refresh(txt) def txtConsulta_keypressed(self,oKeyEvent): if oKeyEvent.KeyCode==1024 or oKeyEvent.KeyCode==1280: self.setFocus("lbxLemas") self.selectListBoxItemPos("lbxLemas",0,True) txt=self.getListBoxSelectedItem("lbxLemas") self.Show(txt) def scrLemas_changed(self,oAdjustmentEvent): self.Refresh(oAdjustmentEvent.Value) def cmbCancel_clicked( self, oActionEvent ): """This is called when the Cancel button is clicked.""" self.windowClose() def windowClosed(self,oActionEvent): self.terminar=True self.sck.close() #if platform.system()=="Windows": rect=self.getWindowPosSize() self.wp["dicbilwindow"]=str({'left':rect.X,'top':rect.Y,'width':rect.Width,'height':rect.Height}) self.wp.sync() self.wp.close() def windowClosing(self,oActionEvent): pass def windowDeactivated(self,oActionEvent): pass #self.windowToFront() #Metodos def Espera(self): while not self.terminar: time.sleep(1) def Load(self): #Cargar lista de palabras i=0 tmp="" self.llms=[] #self.bt.close() self.bt={} self.setEditText("txtConsulta","") #Cargar lista de lemas datos=str(('dicbil',('_lista',self.tl,usrPath))).encode('utf-8') self.sck.send(datos) datos=self.sck.recv(200000).decode('utf-8') comando,(lema,tl,tmp)=eval(datos) f=open(tmp,'r+b') self.llms=eval(f.read()) f.close() for i in range(len(self.llms)): k=ucodeSiLinux(self.llms[i]) self.bt[self.NoAcc(k)]=str(i) if k!=self.llms[i]: self.llms[i]=k self.setScrollBarScrollValueMax("scrLemas",i) self.Refresh(0) self.windowToFront() def Refresh(self,txt): #Presentar items en la lista a partir de txt self.removeListBoxItems("lbxLemas",0,self.getListBoxItemCount("lbxLemas")) #TODO if str(type(txt))=="": txt=uts(txt) if str(type(txt))=="": if txt.isdigit(): ini=int(txt) if ini>len(self.llms): ini=len(self.llms) elif txt=="": ini=0 else: try: k=txt n=self.bt.get(k) #(k,n)=self.bt.set_location(txt) if k>=txt: ini=eval(n) else: ini=len(self.llms) except Exception as e: ini=len(self.llms) else: ini=int(txt) i=ini while i": for s in cred: txt=txt+str(s)+" " #txt=txt[0:-2]+"\n\n" txt=txt+"\n\n" #else: # txt=txt+cred+":\n" self.setFixedTextText("lblCredits",txt) #Eventos def cmbCancel_clicked( self, oActionEvent ): """This is called when the Cancel button is clicked.""" self.windowClose() def windowClosed(self,oActionEvent): self.terminar=True self.sck.close() #if platform.system()=="Windows": rect=self.getWindowPosSize() self.wp["infowindow"]=str({'left':rect.X,'top':rect.Y,'width':rect.Width,'height':rect.Height}) self.wp.sync() self.wp.close() def windowClosing(self,oActionEvent): pass #Metodos def Espera(self): while not self.terminar: time.sleep(1) # end of class InfoWindow class MsgWindow(DBListenerWindow): def __init__(self,msg): DBListenerWindow.__init__( self, u"Missatge del Salt") self.addFixedText("txtMsg",5,10,300,16,msg) self.setFixedTextAlignment("txtMsg",1) self.addButton( "cmbCancel", 310, 10, 60, 16, "Tanca", actionListenerProc = self.cmbCancel_clicked ) wpos={'left':100,'top':200,'width':460,'height':40} try: #if platform.system()=="Windows": #self.wp=bsddb.btopen(os.path.abspath(ooopath+"/sltwpos")) #if self.wp.has_key("msgwindow"): #(k,p)=self.wp.set_location("msgwindow") #wpos=eval(p) self.wp={'dicbilwindow': "{'width': 166L, 'top': 245L, 'height': 400L, 'left': 323L}", 'infowindow': "{'width': 1130L, 'top': 137L, 'height': 750L, 'left': 1L}", 'dicsaltwindow': "{'width': 250L, 'top': 233L, 'height': 400L, 'left': 719L}", 'verbswindow': "{'width': 166L, 'top': 397L, 'height': 400L, 'left': 644L}"} if "msgwindow" in self.wp: (k,p)=self.wp.set_location("msgwindow") wpos=eval(p) finally: self.setWindowPosSize( wpos['left'], wpos['top'], 460, 40 ) self.windowToFront() #Eventos def cmbCancel_clicked( self, oActionEvent ): """This is called when the Cancel button is clicked.""" self.windowClose() def windowClosed(self,oActionEvent): #if platform.system()=="Windows": rect=self.getWindowPosSize() self.wp["msgwindow"]=str({'left':rect.X,'top':rect.Y,'width':rect.Width,'height':rect.Height}) self.wp.sync() self.wp.close() # end of class MsgWindow # pythonloader looks for a static g_ImplementationHelper variable g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation( \ uooUNOobj, # UNO object class "org.openoffice.Office.addon.salt.util.uooUNOobj", # implementation name # Change this name for your own # script ("com.sun.star.task.Job",),) # list of implemented services # (the only service)