von sarotti » Mo, 01.12.2008 17:34
Hallo zusammen,
nach
längerer Suche bin ich doch im englischsprachigen Forum fündig geworden. Hierzu ein paar Links:
http://www.oooforum.org/forum/viewtopic ... highlight=
http://www.oooforum.org/forum/viewtopic ... lbar+macro
...und eine Zusammenfassung der Makros:
1. Benutzerspezifische Symbolleiste ausblenden
Code: Alles auswählen
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
Code: Alles auswählen
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
3. Symbolleisten alle verstecken
Code: Alles auswählen
Sub hideAllBars( )
doc = Stardesktop.getCurrentComponent()
frame = doc.CurrentController.Frame
lmgr = frame.LayoutManager
lmgr.setVisible(False)
' wait 5000
' lmgr.setVisible(true)
End Sub
Gruss
sarotti
Hallo zusammen,
nach [u]längerer[/u] Suche bin ich doch im englischsprachigen Forum fündig geworden. Hierzu ein paar Links:
[url]http://www.oooforum.org/forum/viewtopic.phtml?t=21611&highlight=[/url]
[url]http://www.oooforum.org/forum/viewtopic.phtml?t=65195&highlight=toolbar+macro[/url]
...und eine Zusammenfassung der Makros:
[b]1. Benutzerspezifische Symbolleiste ausblenden[/b]
[code]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
[/code]
[b]2. Kopiern von Symbolleisten in ein anderes Dokument[/b]
[code]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[/code]
[b]3. Symbolleisten alle verstecken[/b]
[code]Sub hideAllBars( )
doc = Stardesktop.getCurrentComponent()
frame = doc.CurrentController.Frame
lmgr = frame.LayoutManager
lmgr.setVisible(False)
' wait 5000
' lmgr.setVisible(true)
End Sub[/code]
Gruss
sarotti