def MessageBox(Document, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): ParentWin = Document.CurrentController.Frame.ContainerWindow MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not (MsgType in MsgTypes): MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.MessageText = MsgText if MsgTitle: msgbox.CaptionText = MsgTitle return msgbox.execute()
def MessageBox(Document, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): ParentWin = Document.CurrentController.Frame.ContainerWindow MsgType = MsgType.lower() # available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not (MsgType in MsgTypes): MsgType = "messbox" # describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin # aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.MessageText = MsgText if MsgTitle: msgbox.CaptionText = MsgTitle return msgbox.execute()
def execute(self, args): """ Arguments: - `args`: """ try: from org.creativecommons.license.store import RdfLoaderThread for item in args: if item.Name == "Environment": lEnvironment = item.Value break #Display license information when opening CC licensed documents for item in lEnvironment: if item.Name == "EnvType": sEnvType = item.Value if item.Name == "EventName": sEventName = item.Value if item.Name == "Frame": m_xFrame = item.Value #Only parse the rdf graph at the start-up of LibreOffice if sEventName == "OnStartApp": RdfLoaderThread().start() #Check for license info only if loading a new document if sEventName == "OnLoad": self.updateCurrentComponent() docProperties = self.xCurrentComponent.getDocumentInfo() #if this document has license information if docProperties.getPropertySetInfo().\ hasPropertyByName("license"): message = ("This work is licensed under a " "" + docProperties.\ getPropertyValue("License Name") + "" + " License available at \n" "" + docProperties.getPropertyValue("license")) parentwin = self.xCurrentComponent.\ CurrentController.Frame.ContainerWindow tk = parentwin.getToolkit() #describe window properties. aDescriptor = WindowDescriptor() from com.sun.star.awt.VclWindowPeerAttribute import OK aDescriptor.WindowAttributes = OK aDescriptor.WindowServiceName = "messbox" aDescriptor.ParentIndex = -1 aDescriptor.Parent = parentwin msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(message) msgbox.execute() except: traceback.print_exc()
def createNewPreviewFrame(self, xMSF, listener): xToolkit = None try: xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit") except Exception: # TODO Auto-generated catch block traceback.print_exc() #describe the window and its properties aDescriptor = WindowDescriptor() aDescriptor.Type = TOP aDescriptor.WindowServiceName = "window" aDescriptor.ParentIndex = -1 aDescriptor.Parent = None aDescriptor.Bounds = Rectangle(10, 10, 640, 480) #Set Window Attributes gnDefaultWindowAttributes = \ com_sun_star_awt_WindowAttribute_BORDER + \ com_sun_star_awt_WindowAttribute_MOVEABLE + \ com_sun_star_awt_WindowAttribute_SIZEABLE + \ com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN aDescriptor.WindowAttributes = gnDefaultWindowAttributes #create a new blank container window xPeer = None try: xPeer = xToolkit.createWindow(aDescriptor) except IllegalArgumentException: traceback.print_exc() #define some further properties of the frame window #if it's needed .-) #xPeer->setBackground(...); #create new empty frame and set window on it xFrame = None try: xFrame = xMSF.createInstance("com.sun.star.frame.Frame") except Exception: traceback.print_exc() xFrame.initialize(xPeer) #from now this frame is useable ... #and not part of the desktop tree. #You are alone with him .-) if listener is not None: Desktop.getDesktop(xMSF).addTerminateListener( TerminateListenerProcAdapter(listener)) return xFrame
def createNewPreviewFrame(self, xMSF, listener): xToolkit = None try: xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit") except Exception: # TODO Auto-generated catch block traceback.print_exc() #describe the window and its properties aDescriptor = WindowDescriptor() aDescriptor.Type = TOP aDescriptor.WindowServiceName = "window" aDescriptor.ParentIndex = -1 aDescriptor.Parent = None aDescriptor.Bounds = Rectangle(10, 10, 640, 480) #Set Window Attributes gnDefaultWindowAttributes = \ com_sun_star_awt_WindowAttribute_BORDER + \ com_sun_star_awt_WindowAttribute_MOVEABLE + \ com_sun_star_awt_WindowAttribute_SIZEABLE + \ com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN aDescriptor.WindowAttributes = gnDefaultWindowAttributes #create a new blank container window xPeer = None try: xPeer = xToolkit.createWindow(aDescriptor) except IllegalArgumentException: traceback.print_exc() #define some further properties of the frame window #if it's needed .-) #xPeer->setBackground(...); #create new empty frame and set window on it xFrame = None try: xFrame = xMSF.createInstance("com.sun.star.frame.Frame") except Exception: traceback.print_exc() xFrame.initialize(xPeer) #from now this frame is usable ... #and not part of the desktop tree. #You are alone with him .-) if listener is not None: Desktop.getDesktop(xMSF).addTerminateListener(listener) return xFrame
def createPreviewFrame(self, xmsf, xControl): controlPeer = xControl.Peer r = xControl.PosSize toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit") aDescriptor = WindowDescriptor() aDescriptor.Type = SIMPLE aDescriptor.WindowServiceName = "window" aDescriptor.ParentIndex = -1 aDescriptor.Parent = controlPeer #xWindowPeer; #argument ! aDescriptor.Bounds = Rectangle(0, 0, r.Width, r.Height) aDescriptor.WindowAttributes = CLIPCHILDREN | SHOW self.xWindow = toolkit.createWindow(aDescriptor) self.xFrame = xmsf.createInstance("com.sun.star.frame.Frame") self.xFrame.initialize(self.xWindow) self.xWindow.setVisible(True)
def create_dlg(toolkit, parent): from com.sun.star.awt.VclWindowPeerAttribute import OK, OK_CANCEL, YES_NO, YES_NO_CANCEL, RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_RETRY, DEF_YES, DEF_NO #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = "messbox" aDescriptor.ParentIndex = -1 aDescriptor.Parent = parent #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = OK tk = parent.getToolkit() msgbox = tk.createWindow(aDescriptor) #msgbox.setMessageText("Hi there!") #msgbox.setCaptionText("a title") dlg = toolkit.createWindow(aDescriptor) return dlg
def messageBox(document, message): #doc = XSCRIPTCONTEXT.getDocument() window = document.CurrentController.Frame.ContainerWindow aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = "infobox" aDescriptor.ParentIndex = -1 aDescriptor.Parent = window #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = OK tk = window.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setCaptionText("Conversion to Unicode") msgbox.setMessageText(message) return msgbox.execute()
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if MsgType not in MsgTypes: MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle: msgbox.setCaptionText(MsgTitle) return msgbox.execute()
def messagebox(tekst, ctx): desktop = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) doc = desktop.getCurrentComponent() c = doc.getCurrentController() pw = c.Frame.ContainerWindow d = WindowDescriptor() d.Type = MODALTOP d.WindowServiceName = "messbox" d.ParentIndex = -1 d.Parent = pw d.WindowAttributes = OK tk = pw.getToolkit() mb = tk.createWindow(d) mb.setMessageText(tekst) mb.setCaptionText("Oei") return mb.execute()
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if MsgType not in MsgTypes: MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle : msgbox.setCaptionText(MsgTitle) return msgbox.execute()
def MessageBox(MsgText, MsgTitle="GnuCash to Ooo", MsgType="messbox", MsgButtons=OK, ParentWin=None): global crout crout = 'MessageBox' global last_input_MessageBox ## last_input_MessageBox = str(MsgText) if not ParentWin: doc = XSCRIPTCONTEXT.getDocument() try: ParentWin = doc.CurrentController.Frame.ContainerWindow except AttributeError: ParentWin = doc.Frame.ContainerWindow MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not (MsgType in MsgTypes): MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle: msgbox.setCaptionText(MsgTitle) return msgbox.execute()
def alert(self, msg, title = u'Alert'): """Opens an alert window with a message and title, and requires user to click 'Ok'""" parentWin = self.model.CurrentController.Frame.ContainerWindow aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = 'messbox' aDescriptor.ParentIndex = -1 aDescriptor.Parent = parentWin aDescriptor.WindowAttributes = OK tk = parentWin.getToolkit() box = tk.createWindow(aDescriptor) box.setMessageText(msg) if title: box.setCaptionText(title) box.execute()
def messagebox(tekst, ctx): desktop = ctx.ServiceManager.createInstanceWithContext( 'com.sun.star.frame.Desktop', ctx) doc = desktop.getCurrentComponent() c = doc.getCurrentController() pw = c.Frame.ContainerWindow d = WindowDescriptor() d.Type = MODALTOP d.WindowServiceName = 'messbox' d.ParentIndex = -1 d.Parent = pw d.WindowAttributes = OK tk = pw.getToolkit() mb = tk.createWindow(d) mb.setMessageText(tekst) mb.setCaptionText('Oei') return mb.execute()
def MessageBox(MsgText, MsgTitle="GnuCash to Ooo", MsgType="messbox", MsgButtons=OK, ParentWin=None): global crout crout = 'MessageBox' global last_input_MessageBox ## last_input_MessageBox = str(MsgText) if not ParentWin: doc = XSCRIPTCONTEXT.getDocument() try: ParentWin = doc.CurrentController.Frame.ContainerWindow except AttributeError: ParentWin = doc.Frame.ContainerWindow MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not ( MsgType in MsgTypes ): MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle : msgbox.setCaptionText(MsgTitle) return msgbox.execute()