Andrew Douglas Pitonyak wrote:
What are the basic steps to create a simple toolbar in basic?
Assume, for example, that I desire a toolbar associated with Writer
documents that supports commands such as next page, previous page,
document start, etc...
Must I create an addon? I assume no.
Hi Andrew,
You don't need to create an add-on, but it would make life much easier
if you just want to use built-in commands. No coding, just define the
content of your toolbar in a xml file.
If I wanted the toolbar in a specific document, I assume that I can use
the documents configuration manager to create and then store the toolbar.
Yes, that's possible.
For all Writer documents, however, I am guessing that I need to use the
ConfigurationProvider service, but this is only a guess.
No, that's not the way to go. You have to retrieve the module ui
configuration manager and there you can change module dependent
toolbars. (See Basic example below)
My next guess is the layout manager, but that just seems wrong. I would
love to see a simple example in Basic.
You can manipulate position, size and visibility of the toolbar with the
layout manager. You should also use it if you want to make transient
changes to the ui.
See the following example to create a persistent module dependent custom
toolbar.
---------
REM ***** BASIC *****
Sub Main
REM *** Creates a new custom toolbar persistently for the Basic IDE
REM *** The name of our new custom toolbar. A custom toolbar name MUST
REM *** start with "custom_"!
sToolbar = "private:resource/toolbar/custom_toolbar"
REM *** Retrieve the module configuration manager from central module
configuration manager supplier
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
REM *** Retrieve the module configuration manager with the module
identifier
REM *** See com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
"com.sun.star.script.BasicIDE" )
REM *** Create a settings container which will define the structure of
our new
REM *** custom toolbar.
oToolbarSettings = oModuleCfgMgr.createSettings()
REM *** Set a title for our new custom toolbar
oToolbarSettings.UIName = "My little custom toolbar"
REM *** Create a button for our new custom toolbar
sString = "My Macro's"
oToolbarItem = CreateToolbarItem( "macro:///Standard.Module1.Test()",
"Standard.Module1.Test" )
oToolbarSettings.insertByIndex( nCount, oToolbarItem )
REM *** Set the settings for our new custom toolbar. (replace/insert)
if ( oModuleCfgMgr.hasSettings( sToolbar )) then
oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings )
else
oModuleCfgMgr.insertSettings( sToolbar, oToolbarSettings )
endif
End Sub
Function CreateToolbarItem( Command as String, Label as String ) as Variant
Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue
aToolbarItem(0).Name = "CommandURL"
aToolbarItem(0).Value = Command
aToolbarItem(1).Name = "Label"
aToolbarItem(1).Value = Label
aToolbarItem(2).Name = "Type"
aToolbarItem(2).Value = 0
aToolbarItem(3).Name = "Visible"
aToolbarItem(3).Value = true
CreateToolbarItem = aToolbarItem()
End Function
Sub Test
MsgBox "Test"
End Sub
Regards,
Carsten
--
Carsten Driesner (cd) - Project Lead OpenOffice.org Framework
Framework wiki: http://wiki.services.openoffice.org/wiki/Framework
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]