[Solved] Add a submenu to Calc's menu bar

Creating a macro - Writing a Script - Using the API

[Solved] Add a submenu to Calc's menu bar

Postby Isabella59 » Mon May 05, 2014 3:57 pm

Hello,

somehow I cannot find a hint on how to add a sub-menu to Calc's menu bar. Well, yes, you can add it permantly, which is not quite what I want. When the user opens a certain document the menu bar should include an entry for he special tasks to be performed with this document. I've done this for Excel before. Ahhhh, yes, I know Open Office ain't quite like Excel, it's much more flexible. Part of my problem is probably that I still think "Excel" :knock:
I would like to manipulate he standard menu bar File Edit View ... Window Help when the document is openend, and return to the standard menu bar when the document is closed. After opening the document, the menu bar should look like this: File Edit View ... Window <my_menu> Help, I do want to do it by coding BASIC.

Any hint welcome.

Isabella
Last edited by Hagar Delest on Mon May 05, 2014 9:23 pm, edited 1 time in total.
Reason: tagged [Solved].
Kind regards,

Isabella
OpenOffice 4.x on Red Hat
Isabella59
 
Posts: 12
Joined: Mon Aug 05, 2013 1:56 pm

Re: Add a submenu to Calc's menu bar

Postby Villeroy » Mon May 05, 2014 5:07 pm

Well, then add it permanently to the document in question so it will disappear when the document is closed. You see the "Save in" list box? There you can choose to save the toolbar either in the office profile or in the current document.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27382
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Add a submenu to Calc's menu bar

Postby Isabella59 » Mon May 05, 2014 6:57 pm

Nope, maybe I didn't express myself clearly. Hope I don't misunderstand you
I would like to implement this scenario:
1. User opens a Calc document.
2. The "MenuBuilder" macro starts, the menu bar changes to File Edit View ... Window <my_menu> Help where <my_entry> is my insertion, of course a drop-down menu with the stuff a user can do with the document.
3. When the user is finished and closes the document, the menu is to disappear, restoring the standard.
BTW in the meantime I found a macro cookbook - alas, it's in German - whichj describes what to do.
Link: http://www.wollmux.net/wiki/images/f/f9 ... chbuch.pdf
Kind regards,

Isabella
OpenOffice 4.x on Red Hat
Isabella59
 
Posts: 12
Joined: Mon Aug 05, 2013 1:56 pm

Re: Add a submenu to Calc's menu bar

Postby Isabella59 » Mon May 05, 2014 7:01 pm

See, I dreaded it, I guess I did misunderstand you. Were you thinking Tools --> Customize, tab Menu? So you're saying my custom entry will dissapear when the document is closed if I store the altered menu bar with the document?
Kind regards,

Isabella
OpenOffice 4.x on Red Hat
Isabella59
 
Posts: 12
Joined: Mon Aug 05, 2013 1:56 pm

Re: Add a submenu to Calc's menu bar

Postby Villeroy » Mon May 05, 2014 7:20 pm

A custom tool barcan be stored within the document. When the document is not loaded the toolbar will be loaded neither.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27382
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Add a submenu to Calc's menu bar

Postby Isabella59 » Mon May 05, 2014 7:47 pm

Thanks for the answer. I'll mark this one solved.
Kind regards,

Isabella
OpenOffice 4.x on Red Hat
Isabella59
 
Posts: 12
Joined: Mon Aug 05, 2013 1:56 pm

Re: Add a submenu to Calc's menu bar

Postby Isabella59 » Mon May 05, 2014 8:01 pm

Thanks for the answer. I'll mark this one solved.For everyone not able to read and understand German, here's the code: Source: http://www.wollmux.net/wiki/images/f/f9 ... chbuch.pdf. I just copied and pasted it. No translation

Code: Select all   Expand viewCollapse view
public const AL_TOOLBAR = "private:resource/toolbar/custom_altoolbar"
'/** MAK017_Check_AL_ToolbarErzeugen
'*************************************************************************.
'* @kurztext prüft, ob der AL Toolbar vorhanden ist. Wenn nein, wird er erzeugt.
'* Die Funktion prüft, ob der AL Toolbar vorhanden ist. Wenn nein, wird er erzeugt.
'* Die AL Symbolleiste wird für viele Funktionen benötigt und muss vorhanden sein.
'*
'* @return bFlag as boolean true, wenn vorhanden, false bei Fehler oder wenn nicht vorhanden
'*************************************************************************
'*/
function MAK017_Check_AL_ToolbarErzeugen
dim oModuleCfgMgrSupplier as variant
dim oModuleCfgMgr as variant
dim i%
MAK017_Check_AL_ToolbarErzeugen = true 'Vorgabe
For i = 0 to uBound(aModTB())
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(aModTB(i))
if ( oModuleCfgMgr.hasSettings( AL_TOOLBAR )) then
'vorhanden, nichts tun...
exit function
else 'Toolbar erzeugen
ToolbarErzeugen
exit function
end if
next
MAK017_Check_AL_ToolbarErzeugen = false 'bei Fehler
end function
'/** ToolbarErzeugen
'*************************************************************************.
'* @kurztext erzeugt eine Symbolleiste (AL) in den Modulen
'* Die Funktion erzeugt eine (Custom_) Symbolleiste in den Modulen.
'* Sie wird hier benutzt, um die AL Symbolleiste zu erzeugen, die später den
'* aktuellen AL-Plan anzeigt. Die Symbolleiste muss per Makro geändert
'* werden können, dies geht derzeit nur mit "Custom_" Symbolleisten, die von
'* Extensions nicht erzeugt werden können.
'*
'*************************************************************************
'*/
sub ToolbarErzeugen
dim oModuleCfgMgrSupplier as variant
dim oModuleCfgMgr as variant
dim oToolbarSettings as variant
dim oToolbarItem as variant
dim i%
MAK017_dyn.MAK017_InitAL
'use this if you want to store the menu globally
For i = 0 to uBound(aModTB()) 'für alle Module
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(aModTB(i))
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 = "AL_aktuell"
REM *** Create a button for our new custom toolbar
oToolbarItem = AL_CreateToolbarItem( ALCHGURL, "AL: " & sALakt)
oToolbarSettings.insertByIndex( 0, oToolbarItem )
REM *** Set the settings for our new custom toolbar. (replace/insert)
if ( oModuleCfgMgr.hasSettings( AL_TOOLBAR )) then
oModuleCfgMgr.replaceSettings( AL_TOOLBAR, oToolbarSettings )
else
oModuleCfgMgr.insertSettings( AL_TOOLBAR, oToolbarSettings )
endif
oModuleCfgMgr.store
next
REM Flag setzen
bToolbarFlag = true
MAK017_def.MAK017_SaveNewPref() 'Werte sichern
End Sub
'/** AL_CreateToolbarItem
'*************************************************************************.
'* @kurztext erzeugt ein Symbol/Schaltfläche im AL Toolbar
'* Die Funktion erzeugt ein Symbol/Schaltfläche im AL Toolbar
'*
'* @param1 Command as string der verknüpfte Befehl (Makro)
'* @param2 Label as string der angezeigte Name des Buttons
'*
'* @return aToolbarItem PropertyValue des Controlelementes
'*
'*************************************************************************
'*/
Function AL_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
AL_CreateToolbarItem = aToolbarItem()
End Function
'/** ToolbarEntfernen
'*************************************************************************.
'* @kurztext entfernt die AL Symbolleiste aus den Modulen
'* Die Funktion entfernt die AL Symbolleiste aus den Modulen
'*
'*************************************************************************
'*/
sub ToolbarEntfernen
dim oModuleCfgMgrSupplier as variant
dim oModuleCfgMgr as variant
dim i%
MAK017_InitAL
For i = 0 to uBound(aModTB())
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(aModTB(i))
if ( oModuleCfgMgr.hasSettings( AL_TOOLBAR )) then
oModuleCfgMgr.removeSettings( AL_TOOLBAR ) 'entfernen
LHM – Makro-Kochbuch 2012 101
oModuleCfgMgr.store
end if
next
REM Flag entfernen
bToolbarFlag = false
MAK017_def.MAK017_SaveNewPref() 'Werte sichern
end sub
Kind regards,

Isabella
OpenOffice 4.x on Red Hat
Isabella59
 
Posts: 12
Joined: Mon Aug 05, 2013 1:56 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 10 guests