Code: Select all
import uno
def msgbox(message):
ctx = uno.getComponentContext()
sm = ctx.getServiceManager()
toolkit = sm.createInstanceWithContext('com.sun.star.awt.Toolkit',ctx)
MsgBox = toolkit.createMessageBox(toolkit.getDesktopWindow(),'QUERYBOX',2,'UNOPython',str(message))
#mri(toolkit)
return MsgBox.execute()
def mri(target):
ctx = uno.getComponentContext()
smgr = ctx.getServiceManager()
oMRI = smgr.createInstance( "mytools.Mri" )
oMRI.inspect(target )
def addingform():
from com.sun.star.awt import Point
from com.sun.star.awt import Size
oDoc = XSCRIPTCONTEXT.getDocument()
ctx = uno.getComponentContext()
sm = ctx.getServiceManager()
desktop = sm.createInstanceWithContext("com.sun.star.frame.Desktop",ctx)
doc = desktop.getCurrentComponent()
doc.getCurrentController().setFormDesignMode(True)
oSheet = doc.getSheets().getByName("Sheet1")
oDrawPage = oSheet.getDrawPage()
oForm = oDoc.createInstance("com.sun.star.form.component.Form")
oForm.Name = "Form1"
oForms = oDrawPage.getForms()
oForms.insertByIndex(0,oForm)
oButton = doc.createInstance("com.sun.star.form.component.CommandButton")
oButton.BackgroundColor = 15650253
oButton.Name = "_MY_BUTTON"
oButton.Label = "_MY_LABEL"
#oButton.Enabled = True
oForm.insertByName("_MY_BUTTON",oButton)
oShape = doc.createInstance("com.sun.star.drawing.ControlShape")
oShape.Control = oButton
oDrawPage.add(oShape)
oShape.Position = Point(1000,2000)
oShape.Size = Size(7560,4000)
act = ActionListener()
oShape.addEventListener(act)
doc.getCurrentController().setFormDesignMode(False)
#ri(oShape)
oControl = oForm.getByIndex(0)
# msgbox(oForm.getScriptEvents(0))
import uno, unohelper
from com.sun.star.awt import XActionListener
from com.sun.star.lang import EventObject
from com.sun.star.awt import ActionEvent
class ActionListener(unohelper.Base, XActionListener):
def __init__(self):
self.count = 0
def disposing(self, EventObject):
pass
# XActionListener
def actionPerformed(self,ActionEvent ):