OO-Snippets: Use of the PropertyBrowserController service

Commons

KeywordsProperty Browser, com.sun.star.awt.Toolkit, com.sun.star.frame.Frame, com.sun.star.form.PropertyBrowserController, introspectedObject
LanguageOOBasic
ApplicationOffice
AuthorsPaolo Mantovani (initial)
Supported Versions1.1.3  1.1.4  1.1.x  
Supported OSAll  
Question Is it possible to use the service com.sun.star.form.PropertyBrowserController from a OOBasic macro ?

The IDL documentation contains a java example for this service but it's not easy to translate it in OOBasic

Answer

Here you'll find an OOBasic "translation" of the example in the IDL documentation for the service com.sun.star.form.PropertyBrowserController.

The code does the following operations:

  • creates a new container window
  • creates a new empty frame and set the container window on it
  • creates the Property Browser controller and attach it on the frame
  • finally, takes an UNO control model as "introspectedObject" and shows it's properties and events
  • To see it working:

    Open the OOBasic IDE, add a new empty dialog (this will be the introspected Object) and run the following code:

    Code-Snippet-Listing (snippet-source)

    REM  *****  BASIC  *****
    
    Sub ShowPropertyBrowser()
    
    	' Create a rectangle struct
    	Dim aRect As New com.sun.star.awt.Rectangle
    	aRect.Y    = 0
    	aRect.X   = 0
    	aRect.width  = 350
    	aRect.height = 550
    
    	' Create a window descriptor and set up its properties
    	Dim aDescriptor As New com.sun.star.awt.WindowDescriptor
    	aDescriptor.Type = com.sun.star.awt.WindowClass.TOP
    '	aDescriptor.WindowServiceName = "window"
    '	aDescriptor.ParentIndex = -1
    '	aDescriptor.Parent = Null 'not available in OOBasic
    	aDescriptor.Bounds = aRect
    
    	aDescriptor.WindowAttributes = _
    	com.sun.star.awt.WindowAttribute.BORDER + _
    	com.sun.star.awt.WindowAttribute.MOVEABLE + _
    	com.sun.star.awt.WindowAttribute.SIZEABLE + _
    	com.sun.star.awt.WindowAttribute.CLOSEABLE
    
    	' Use a Toolkit to create a Window
    	oToolkit = createUnoService("com.sun.star.awt.Toolkit")
    	oContainerWindow = oToolkit.createWindow(aDescriptor)
    
    	' Create a new empty target frame.
    	oFrame = createUnoService("com.sun.star.frame.Frame")
    
    	' Set the container window on it.
    	oFrame.initialize(oContainerWindow)
    
    	' Insert the new frame in desktop hierarchy.
    	oFrameContainer = StarDesktop.getFrames()
    	oFrameContainer.append(oFrame)
    
    	' Make some other initializations.
    	oFrame.Name = "newly created 1"
    	oFrame.Title = "newly created 1"
    	oContainerWindow.setVisible(True)	
    		
    	' Create the Property Browser Controller
    	oPropBrowser = CreateUnoService("com.sun.star.form.PropertyBrowserController")
    	oPropBrowser.attachFrame(oFrame)
    	
    	' Now we have a component window !
    	' Make it visible
    	oFrame.ComponentWindow.setVisible(True)	
    
    	' Retrieve an UNO Control Model
    	oDlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
    	oCtrlModel = oDlg.getModel
    	
    	'also Form Controls works well(obvious)
    '	oCtrlModel = ThisComponent.DrawPage.Forms.Standard.PushButton
    		
    	' Show Control properties in the browser
    	oPropBrowser.introspectedObject = oCtrlModel
    
    End Sub
    
    

    Changelog

    DateUserModification
    2005-03-14paolomantovaniInitial version
    2005-03-14tomsontomfixed linking to IDL-Fields

    and