UnoControlDialogModel Resizable

Creating a macro - Writing a Script - Using the API

UnoControlDialogModel Resizable

Postby rjsteele » Tue Oct 09, 2012 9:24 pm

I see that "sizeable" is one of the properties of the UnoControlDialogModel. Is setting this property to TRUE supposed to give the user the ability to resize the dialog. I have a dialog with a calc spreadsheet embedded in it. I want to allow the user to resize the dialog. The dialog also has other controls as well.
Raymond
Solaris 10 x86 StarrOffice 9 - basis3.1
rjsteele
 
Posts: 23
Joined: Fri Jul 27, 2012 9:20 pm

Re: UnoControlDialogModel Resizable

Postby hanya » Wed Oct 10, 2012 2:48 pm

It can not be changed by the API. It looks dlg:window node support resizeable attribute in XDL file but it does not work with the dialog executed by the dialog provider.
Here is an example to make a dialog through general window creation mechanism. In the case, child controls should be created by code by it is troublesome so I embed the dialog created by the dialog editor as child window into the resizeable outer dialog. You need to resize and reposition child controls yourself.

Code: Select all   Expand viewCollapse view
' This is an example to make resizable modal dialog.
' A dialog created by the dialog editor can be embedded
' to make easy to create dialog.

' This example requires Standard.Dialog in application dialog
' with list box named ListBox1.
Sub ResizableDialogTest11
  ' parent
  oParent = ThisComponent.getCurrentController()._
      getFrame().getContainerWindow()
  ' create base window as modal dialog
  oBaseDialog = CreateBaseDialog(oParent)
  ' embed the dialog created by the dialog editor
  sURL = "vnd.sun.star.script:Standard.Dialog1?location=application"
  oDialog = CreateInnerDialog(oBaseDialog, sURL)
 
  ' to show the dialog, have to be done by the outer dialog
  If oBaseDialog.execute() > 0 Then
    msgbox "Do something..."
  End If
  oBaseDialog.dispose()
End Sub


' Create new base dialog.
' @param oParent parent window peer
' @return dialog window
Function CreateBaseDialog(oParent As Variant) As Variant
  oToolkit = oParent.getToolkit()
  WA = com.sun.star.awt.WindowAttribute
  aRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
  oDesc = CreateUnoStruct("com.sun.star.awt.WindowDescriptor")
  With oDesc
    .Type = com.sun.star.awt.WindowClass.SIMPLE
    .WindowServiceName = "dialog"
    .Parent = oParent
    .ParentIndex = -1
    .Bounds = aRect
    .WindowAttributes = WA.CLOSEABLE OR WA.MOVEABLE OR WA.SIZEABLE OR WA.BORDER
  End With
  oDialog = oToolkit.createWindow(oDesc)
  oDialog.addTopWindowListener(CreateUnoListener(_
      "WindowListener_", "com.sun.star.awt.XTopWindowListener"))
  oDialog.addWindowListener(CreateUnoListener(_
      "WindowListener_", "com.sun.star.awt.XWindowListener"))
  CreateBaseDialog = oDialog
End Function


' Create child dialog embedded
' @param oParent parent window
' @param sURL dialog URL, without toolbar
Function CreateInnerDialog(oParent As Variant, sURL As String) As Variant
  PS = com.sun.star.awt.PosSize
  oDP = CreateUnoService("com.sun.star.awt.ContainerWindowProvider")
  oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
  oChildDialog.setPosSize(0, 0, 0, 0, PS.POS)
  oChildDialog.setVisible(True)
  aSize = oChildDialog.getPosSize()
  oParent.setPosSize(0, 0, aSize.Width, aSize.Height, PS.SIZE)
  oChildDialog.addWindowListener(CreateUnoListener(_
      "oDialogWindow_", "com.sun.star.awt.XWindowListener"))
  CreateInnerDialog = oChildDialog
End Function

'
' XWindowListener
Sub oDialogWindow_windowResized(ev)
  ' this called indirect by resizeing of the outer dialog
  aRect = ev.Source.getPosSize()
 
  ' dialog controls have to be repositioned and resized by hand
  oListBox = ev.Source.getControl("ListBox1")
  oListBox.setPosSize(aRect.Width - 10 - oListBox.getPosSize().Width, _
                      0, 0, 0, com.sun.star.awt.PosSize.X)
End Sub
Sub oDialogWindow_windowMoved(ev)
End Sub
Sub oDialogWindow_windowShown(ev)
End Sub
Sub oDialogWindow_windowHidden(ev)
End Sub

' Listeners for base dialog
' XTopWindowListener
Sub WindowListener_disposing(ev)
End Sub
Sub WindowListener_windowOpened(ev)
End Sub
Sub WindowListener_windowClosing(ev)
  ' helps to close the window by close button of the window
  ev.Source.endExecute()
End Sub
Sub WindowListener_windowClosed(ev)
End Sub
Sub WindowListener_windowMinimized(ev)
End Sub
Sub WindowListener_windowNormalized(ev)
End Sub
Sub WindowListener_windowActivated(ev)
End Sub
Sub WindowListener_windowDeactivated(ev)
End Sub

' XWindowListener
Sub WindowListener_windowResized(ev)
  ' resize inner dialog as first child window
  aSize = ev.Source.getSize()
  ev.Source.Windows(0).setPosSize(0, 0, _
        aSize.Width, aSize.Height, com.sun.star.awt.PosSize.SIZE)
End Sub
Sub WindowListener_windowMoved(ev)
End Sub
Sub WindowListener_windowShown(ev)
End Sub
Sub WindowListener_windowHidden(ev)
End Sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: UnoControlDialogModel Resizable

Postby rjsteele » Thu Oct 11, 2012 4:51 pm

Hanya,

Thanks for the response. I will try to implement this as soon as I can. I got pulled in another direction for the time being. Hopefully, when I do try, you will be available for follow-up questions.
Raymond
Solaris 10 x86 StarrOffice 9 - basis3.1
rjsteele
 
Posts: 23
Joined: Fri Jul 27, 2012 9:20 pm

Re: UnoControlDialogModel Resizable

Postby roland65 » Wed Apr 09, 2014 9:03 am

Hi,

I've tried the ResizableDialogTest11 example and it doesn't work properly in LibreOffice 4.x : the inner child dialog is shown as a separate window (non resizable) and not embedded in the resizable parent.
Any idea on how to fix this?
Thanks a lot,
RB
LibreOffice 5.x on Ubuntu
roland65
 
Posts: 21
Joined: Tue Oct 18, 2011 6:41 pm

Re: UnoControlDialogModel Resizable

Postby hanya » Wed Apr 09, 2014 9:56 am

Set "With title bar" of the dialog to No to make it embedded in the parent dialog.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: UnoControlDialogModel Resizable

Postby roland65 » Wed Apr 09, 2014 2:24 pm

Very nice! I couldn't think the answer was so simple...
Thanks a lot,
RB
LibreOffice 5.x on Ubuntu
roland65
 
Posts: 21
Joined: Tue Oct 18, 2011 6:41 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests