leider habe ich bisher im Forum hierzu nichts entdeckt was hier hilft....
Es geht darum per Makro selbst zusammengestellte Symbolleisten bei Bedarf ein- bzw. wieder auszublenden. Leider habe ich nirgends einen Hinweis auf den Zugriff auf Symbolleisten gefunden.
(Eine Seite komplett ohne Menüleisten... etc. darzustellen ist in Thomas OO-Base Buch beschrieben...hilft aber nicht für meine Belange, da hier alles und nicht selektiv ein- bzw. ausgeschaltet wird.)
Für die echten Könner direkt noch eine Folgefrage:
Wie kann ich eine einmal erstellt Menüleiste, die in einem Dokument gespeichert ist in ein anderes Dokument übertragen/vererben?
Sub ToolBarEinAus
Dim sUrl as String : sUrl = "private:resource/toolbar/custom_toolbar_5b34" 'oder z.B. "private:resource/toolbar/standardbar" für Standardleiste
oDocSymb=ThisComponent.CurrentController.Frame.LayoutManager
If oDocSymb.IsElementVisible( sUrl ) Then
oDocSymb.hideElement( sUrl )
Else
oDocSymb.showElement( sUrl )
End If
end sub
2. Kopiern von Symbolleisten in ein anderes Dokument
Sub ToolbarCopy
REM *** Copies all custom toolbars located in one document to another one
REM *** A custom toolbar name MUST start with "custom_"
sCustomToolbar = "private:resource/toolbar/custom_"
REM *** Retrieve the desktop service ***
oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
REM *** Propterties for loadComponentFromUrl ***
Dim OpenProperties(3) as new com.sun.star.beans.PropertyValue
OpenProperties(0).Name = "Hidden"
OpenProperties(0).Value = True
OpenProperties(1).Name = "AsTemplate"
OpenProperties(1).Value = False
OpenProperties(2).Name = "MacroExecutionMode"
OpenProperties(2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE
REM *** Load two documents ***
sSourceUrl = "file:///c:/document1.odt"
sTargetUrl = "file:///c:/document2.odt"
oDoc1 = oDesktop.loadComponentFromUrl(sSourceUrl, "_default", 0, OpenProperties())
oDoc2 = oDesktop.loadComponentFromUrl(sTargetUrl, "_default", 0, OpenProperties())
oSourceUICfgMgr = oDoc1.getUIConfigurationManager()
oTargetUICfgMgr = oDoc2.getUIConfigurationManager()
REM *** Type number for the toolbar, retrieved from com.sun.star.ui.UIElementType
TOOLBAR_TYPE = 3
oToolbars() = oSourceUICfgMgr.getUIElementsInfo( TOOLBAR_TYPE )
msgbox oSourceUICfgMgr.dbg_supportedInterfaces
REM *** Retrieve all toolbars stored in the document ***
bCopied = false
nMaxTbxIndex = ubound( oToolbars() )
for i = 0 to nMaxTbxIndex
oToolbarPropsSeq = oToolbars(i)
nMaxToolbarPropIndex = ubound( oToolbarPropsSeq )
for j = 0 to nMaxToolbarPropIndex
oToolbarProps = oToolbarPropsSeq(j)
if oToolbarProps.Name = "ResourceURL" then
if InStr( oToolbarProps.Value, sCustomToolbar ) = 1 then
msgbox oToolbarProps.Value
REM *** Retrieve the toolbar settings from the
REM *** source document ui configuration manager
oToolbar = oSourceUICfgMgr.getSettings( oToolbarProps.Value, False )
REM *** Insert/replace the toolbar settings to the target document
REM *** ui configuration manager.
if oTargetUICfgMgr.hasSettings( oToolbarProps.Value ) then
oTargetUICfgMgr.replaceSettings( oToolbarProps.Value, oToolbar )
else
oTargetUICfgMgr.insertSettings( oToolbarProps.Value, oToolbar )
endif
end if
bCopied = true
end if
next j
next i
REM *** Store the changes to the document
if bCopied = true then
oTargetUICfgMgr.store()
oDoc2.store()
end if
oDoc1.close( true )
oDoc2.close( true )
End Sub