[api-dev] Create simple toolbar in basic

2006-12-12 Thread Andrew Douglas Pitonyak


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.

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.


For all Writer documents, however, I am guessing that I need to use the 
ConfigurationProvider service, but this is only a guess.


My next guess is the layout manager, but that just seems wrong. I would 
love to see a simple example in Basic.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Create simple toolbar in basic

2006-12-13 Thread Carsten Driesner

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]



Re: [api-dev] Create simple toolbar in basic

2006-12-13 Thread Andrew Douglas Pitonyak


Carsten Driesner wrote:

Andrew Douglas Pitonyak wrote:


What are the basic steps to create a simple toolbar in basic?

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.

Never done this before... I should learn how.




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) 


Thanks, the example was EXACTLY what I needed

In your example, you have the following code, which works:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

This code, however, has a problem:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   'oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.RemoveSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

While testing, I wanted to make a toolbar go away, so I "REMOVED" the 
settings. I was no longer able to create a new toolbar with the URL of 
the "removed" toolbar. There are no errors, it simply does nothing.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Create simple toolbar in basic

2006-12-14 Thread Carsten Driesner

Andrew Douglas Pitonyak wrote:


Carsten Driesner wrote:

Andrew Douglas Pitonyak wrote:


What are the basic steps to create a simple toolbar in basic?

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.

Never done this before... I should learn how.




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) 


Thanks, the example was EXACTLY what I needed

Hi Andrew,

Great to hear that my code example can help you.



In your example, you have the following code, which works:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

This code, however, has a problem:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   'oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.RemoveSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

While testing, I wanted to make a toolbar go away, so I "REMOVED" the 
settings. I was no longer able to create a new toolbar with the URL of 
the "removed" toolbar. There are no errors, it simply does nothing.


May be you have found a bug. I will check it. Just for your information, 
removing the configuration settings is not enough to really get rid of a 
toolbar. OpenOffice.org 2.0.x supports live-configuration and therefore 
would even show a toolbar without configuration data (the toolbar must 
be requested by the application code). You can see this if you use the 
toolbar configuration dialog via "Tools - Configure - Toolbar" and 
create a custom toolbar. You have to remove the window state of the 
toolbar via OpenOffice.org configuration access.


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]



Re: [api-dev] Create simple toolbar in basic

2006-12-14 Thread Andrew Douglas Pitonyak



Carsten Driesner wrote:

Andrew Douglas Pitonyak wrote:

In your example, you have the following code, which works:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

This code, however, has a problem:

 If ( oModuleCfgMgr.hasSettings( sTBURL )) Then
   'oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.RemoveSettings( sTBURL, oTBSettings )
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 Else
   oModuleCfgMgr.insertSettings( sTBURL, oTBSettings )
 End If

While testing, I wanted to make a toolbar go away, so I "REMOVED" the 
settings. I was no longer able to create a new toolbar with the URL 
of the "removed" toolbar. There are no errors, it simply does nothing.
May be you have found a bug. I will check it. Just for your 
information, removing the configuration settings is not enough to 
really get rid of a toolbar. OpenOffice.org 2.0.x supports 
live-configuration and therefore would even show a toolbar without 
configuration data (the toolbar must be requested by the application 
code). You can see this if you use the toolbar configuration dialog 
via "Tools - Configure - Toolbar" and create a custom toolbar. You 
have to remove the window state of the toolbar via OpenOffice.org 
configuration access.


Regards,
Carsten


I have been documenting all of this...
I must remove the "window state" using "configuration access". 

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Create simple toolbar in basic

2006-12-15 Thread Carsten Driesner

Andrew Douglas Pitonyak wrote:



I have been documenting all of this...
I must remove the "window state" using "configuration access". 


Hi Andrew,

On the first look this may seem to be complicated, but we chose to use 
two different configurations to store different aspects of a toolbar. 
The content of the toolbar is stored in the UI configuration, the state 
of the toolbar in the OpenOffice.org configuration. The content of a 
toolbar can also be stored in a document (something the OpenOffice.org 
configuration is not able to do).


Do you need help how to access the window state using the configuration 
access?
One more question, what toolbar setting do you want to remove (what's 
the name of the toolbar)?


Regards,
Carsten

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Create simple toolbar in basic

2006-12-17 Thread Andrew Douglas Pitonyak

Carsten Driesner wrote:

Andrew Douglas Pitonyak wrote:



I have been documenting all of this...
I must remove the "window state" using "configuration access". 


Hi Andrew,

On the first look this may seem to be complicated, but we chose to use 
two different configurations to store different aspects of a toolbar. 
The content of the toolbar is stored in the UI configuration, the 
state of the toolbar in the OpenOffice.org configuration. The content 
of a toolbar can also be stored in a document (something the 
OpenOffice.org configuration is not able to do).


Do you need help how to access the window state using the 
configuration access?
One more question, what toolbar setting do you want to remove (what's 
the name of the toolbar)?


Regards,
Carsten
Yes, I could use a simple example that demonstrates how to remove a 
toolbar that I create. I found this problem because I removed the 
settings, and then I could no longer insert them again and they were not 
there. If I know how to remove them from the configuration access, this 
would help.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Create simple toolbar in basic

2006-12-18 Thread Carsten Driesner

Andrew Douglas Pitonyak wrote:

Carsten Driesner wrote:

Andrew Douglas Pitonyak wrote:



I have been documenting all of this...
I must remove the "window state" using "configuration access". 


Hi Andrew,

On the first look this may seem to be complicated, but we chose to use 
two different configurations to store different aspects of a toolbar. 
The content of the toolbar is stored in the UI configuration, the 
state of the toolbar in the OpenOffice.org configuration. The content 
of a toolbar can also be stored in a document (something the 
OpenOffice.org configuration is not able to do).


Do you need help how to access the window state using the 
configuration access?
One more question, what toolbar setting do you want to remove (what's 
the name of the toolbar)?


Regards,
Carsten
Yes, I could use a simple example that demonstrates how to remove a 
toolbar that I create. I found this problem because I removed the 
settings, and then I could no longer insert them again and they were not 
there. If I know how to remove them from the configuration access, this 
would help.

Hi Andrew,

No problem at all. Please have a look at the following code snippet 
which removes the configuration settings for toolbar and the window 
state entry from the configuration.


REM  *  BASIC  *

Sub Main
REM *** Removes a custom toolbar persistently from the Basic IDE

REM *** The name of the custom toolbar. A custom toolbar name MUST
REM *** start with "custom_"!
sToolbar = "private:resource/toolbar/custom_toolbar"
sBasicIDEModuleIdentifier = "com.sun.star.script.BasicIDE"

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 single window state service
oWindowState = 
createUnoService("com.sun.star.ui.WindowStateConfiguration")


REM *** Retrieve the window state configuration for the Basic IDE
oBasicWindowState = oWindowState.getByName( 
sBasicIDEModuleIdentifier )


REM *** Remove the settings for our custom toolbar.
if ( oModuleCfgMgr.hasSettings( sToolbar )) then
oModuleCfgMgr.removeSettings( sToolbar, oToolbarSettings )
oModuleCfgMgr.store()
endif

REM *** Remove the window state settings for our custom toolbar
if oBasicWindowState.hasByName( sToolbar ) then
oBasicWindowState.removeByName( sToolbar )
end if
End Sub

If you have problems or questions don't hesitate to ask.

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]