von Axel Richter » Sa, 05.02.2011 18:47
Hallo j_gon,
http://www.google.de/#q=openoffice+macr ... on+the+fly
Meine Essenz daraus:
Code: Alles auswählen
sub addButton
oSheet = thiscomponent.sheets(0)
oPage = oSheet.drawpage
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x = 10000
aPoint.y = 10000
aSize.Width = 10000
aSize.Height = 1600
btn = thiscomponent.createInstance("com.sun.star.drawing.ControlShape")
oControlModel = thiscomponent.createInstance( "com.sun.star.form.component.CommandButton" )
btn.control = oControlModel
btn.Size = aSize
btn.Position = aPoint
btn.Control.Label = "Klick mich!"
oPage.add(btn)
oForm = btn.control.parent
nIndex = oForm.Count-1 'Der Button wurde soeben eingefügt, deshalb ist es sehr wahrscheinlich, dass er das letzte Element der Controls-Liste der Form ist.
Dim oEvent as new com.sun.star.script.ScriptEventDescriptor
oEvent.ListenerType = "com.sun.star.awt.XActionListener"
oEvent.EventMethod = "actionPerformed"
oEvent.ScriptType = "StarBasic"
oEvent.ScriptCode = "vnd.sun.star.script:Standard.Module1.test"
oForm.registerScriptEvent(nIndex, oEvent)
thiscomponent.currentcontroller.setformdesignmode(false)
end sub
sub test(oEvent)
xray oEvent
end sub
viele Grüße
Axel
Hallo j_gon,
[url]http://www.google.de/#q=openoffice+macro+sheet+form+control+on+the+fly[/url]
Meine Essenz daraus:
[code]
sub addButton
oSheet = thiscomponent.sheets(0)
oPage = oSheet.drawpage
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x = 10000
aPoint.y = 10000
aSize.Width = 10000
aSize.Height = 1600
btn = thiscomponent.createInstance("com.sun.star.drawing.ControlShape")
oControlModel = thiscomponent.createInstance( "com.sun.star.form.component.CommandButton" )
btn.control = oControlModel
btn.Size = aSize
btn.Position = aPoint
btn.Control.Label = "Klick mich!"
oPage.add(btn)
oForm = btn.control.parent
nIndex = oForm.Count-1 'Der Button wurde soeben eingefügt, deshalb ist es sehr wahrscheinlich, dass er das letzte Element der Controls-Liste der Form ist.
Dim oEvent as new com.sun.star.script.ScriptEventDescriptor
oEvent.ListenerType = "com.sun.star.awt.XActionListener"
oEvent.EventMethod = "actionPerformed"
oEvent.ScriptType = "StarBasic"
oEvent.ScriptCode = "vnd.sun.star.script:Standard.Module1.test"
oForm.registerScriptEvent(nIndex, oEvent)
thiscomponent.currentcontroller.setformdesignmode(false)
end sub
sub test(oEvent)
xray oEvent
end sub
[/code]
viele Grüße
Axel