Symbolleisten ein-/ausblenden und vererben

Programmierung unter AOO/LO (StarBasic, Python, Java, ...)

Moderator: Moderatoren

sarotti
****
Beiträge: 105
Registriert: So, 12.03.2006 17:40
Wohnort: Nähe Krefeld

Symbolleisten ein-/ausblenden und vererben

Beitrag von sarotti »

Hallo zusammen,

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?

Vorschußdank auf alle Tippgeber ;-)

Gruss
sarotti
sarotti
****
Beiträge: 105
Registriert: So, 12.03.2006 17:40
Wohnort: Nähe Krefeld

[GELÖST] Symbolleisten ein-/ausblenden und vererben [&Tipps]

Beitrag von sarotti »

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
Benutzeravatar
komma4
********
Beiträge: 5332
Registriert: Mi, 03.05.2006 23:29
Wohnort: Chon Buri Thailand Asia
Kontaktdaten:

Re: Symbolleisten ein-/ausblenden und vererben

Beitrag von komma4 »

Danke für die Rückmeldung - werde ich bestimmt auch mal brauchen.

Das [Gelöst] musst Du in's erste posting des threads setzen - sonst sieht man es nicht.
Cheers
Winfried
aktuell: LO 5.3.5.2 30m0(Build:2) SUSE rpm, unter Linux openSuSE Leap 42.3 x86_64/KDE5
DateTime2 Einfügen von Datum/Zeit/Zeitstempel (als OOo Extension)
Antworten