Hallo alle zusammen ,
gibt es die Möglichkeit ein Dialog zu erzeugen, aber zu verhindern, dass das Dokument gesperrt wird.
Ich fülle mittels einem Makro ein Dokument und schließ es dann. Es soll aber noch die Möglichkeit geben sich zumindest das Dokument anzuschauen.
Da dachte ich mir ich erzeug ein Dialog oder meinetwegen eine Toolbar
Könnt ihr mir helfen oder hab ich mich da in was verrant?
Global showing
Sub Run
dim document as object
document = ThisComponent.CurrentController.Frame
oDialogModel = createUnoService( "com.sun.star.awt.UnoControlDialogModel")
oButtonModel = oDialogModel.createInstance( "com.sun.star.awt.UnoControlButtonModel" )
oButtonModel.PositionX = 0
oButtonModel.PositionY = 0
oButtonModel.Width = 50
oButtonModel.Height = 18
oButtonModel.Label = "Beenden"
' insert the controls models into the dialog model
oDialogModel.insertByName( "btnClose", oButtonModel )
' create the dialog control and set the model
oDialog = createUnoService( "com.sun.star.awt.UnoControlDialog")
oDialog.setModel( oDialogModel )
oButtonControl = oDialog.Controls(0)
'now generate the container Window
oToolkit = createUnoService("com.sun.star.awt.Toolkit")
Dim WWith As Integer
Dim WHeight As Integer
Dim rBounds as new com.sun.star.awt.Rectangle
rBounds.width = oButtonControl.PosSize.Width
rBounds.height = oButtonControl.PosSize.Height
WWith = document.ContainerWindow.Size.Width - rBounds.width / 2
WHeight = document.ContainerWindow.Size.Height - rBounds.height / 2
rBounds.X = WWith / 2
rBounds.Y = WHeight / 2
oListener = CreateUnoListener("btnClose_", "com.sun.star.awt.XActionListener")
oButtonControl.addActionListener(oListener)
Dim wd as new com.sun.star.awt.WindowDescriptor
wd.Type = com.sun.star.awt.WindowClass.TOP
wd.Bounds = rBounds
with com.sun.star.awt.WindowAttribute
wd.WindowAttributes = .BORDER + .MOVEABLE + .CLOSEABLE
end with
wd.WindowServiceName = "dialog"
oContWin = oToolkit.createWindow(wd)
'now put it into a frame. This is to be able to close it.
oFrame = createUnoService("com.sun.star.frame.Frame")
oFrame.initialize(oContWin)
StarDesktop.Frames.append(oFrame)
oFrame.Name = "ms777Frame"
oFrame.Title = "ms7Title"
'last but not least let the progress bar show itself with the container window as the parent
oButtonControl.createPeer(oToolkit, oContWin)
oContWin.setTitle("Test")
oContWin.setVisible(True)
showing = true
' msgBox "Test"
WaitingForDialog
End Sub
sub WaitingForDialog
do while showing
wait 500
loop
end Sub
sub btnClose_actionPerformed(oEvent)
StopProgress()
showing = false
End Sub
Sub StopProgress
' the following lines can be called from everywhere to close the progress frame. No global var needed.
for k= StarDesktop.Frames.Count-1 to 0 step -1
oF = StarDesktop.Frames.getByIndex(k)
if oF.Name = "ms777Frame" then
oF.dispose
endif
next k
showing = false
End Sub