| View previous topic :: View next topic |
| Author |
Message |
zman General User


Joined: 03 Jul 2005 Posts: 14
|
Posted: Sun Jul 03, 2005 11:41 pm Post subject: Hide Menubar and toolbar |
|
|
Hello,
I'm searching if it's possible to hide all toolbar just with a macro when I open a file and the opposite when I close this file.
It's because I use the mode full screen but I don't know what to do to desactivate (do not show) the small window "desactivate the mode full screen "
Thank a lot for your help ans sorry for my bad english  |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Mon Jul 04, 2005 9:57 am Post subject: |
|
|
Two ways, one for OOo 1.1.x, the other for 2.0 .
For 2.0 there is a straight-forward and easy way to do it now:
| Code: |
Sub hideallBars_inOOo2( )
doc = Stardesktop.getCurrentComponent()
frame = doc.CurrentController.Frame
lmgr = frame.LayoutManager
lmgr.setVisible(False)
End Sub |
For 1.1.x you need to make use of dispatch calls, please search through the code snippets section, the thread is called something like "Toggle view of menubars". Also if you want to make it work right, you need to catch states of those dispatches before switching the view (I have sent in some code to do that in an explicit thread called "State of dispatched" or something like that). All in all this is a very complicated mechanism.
OOo 2.0 API is just a lot slicker .
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
zman General User


Joined: 03 Jul 2005 Posts: 14
|
Posted: Mon Jul 04, 2005 10:33 am Post subject: |
|
|
Thanks a lot for your help
 |
|
| Back to top |
|
 |
bluegecko General User

Joined: 12 Jun 2007 Posts: 49 Location: Portugal
|
Posted: Tue Jun 12, 2007 5:30 am Post subject: |
|
|
Hi there,
I know the last post in this thread was a couple of years ago, but still - I don't want to start a new thread. Cybb20's hide toolbars macro works great in OOo 2.2 (Writer), but there's a little problem: whilst CTRL-D shows the Font dialog as it should, CTRL-F doesn't show the Find dialog. There may be other dialogs that remain hidden, too; I haven't tried.
I'm thinking along the lines of coding the macro to hide individual (named) toolbars. It should be really simple, but I've only just started playing with OOo macros, so please indulge me!
Thanks in advance. |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
bluegecko General User

Joined: 12 Jun 2007 Posts: 49 Location: Portugal
|
Posted: Tue Jun 12, 2007 9:00 am Post subject: |
|
|
Thank you, Serge, for the hint - I also found that document (the address is http://specs.openoffice.org/ui_in_general/api/ProgrammaticControlOfMenuAndToolbarItems.sxw). It was essential for coding the main menu. Amazingly, I managed to get the thing working, at least for me. ' '
The full macro follows. It lets you toggle between normal and full screen display (in Writer at least); obviously, it's most useful if you assign the macro (FullScreenToggle) to a key - F11 makes sense.
Full screen will hide the main menu, the standard user-defined toolbar, anything that normal "full screen" mode hide, and that irritating "full screen" button. It won't hide other toolbars you have showing (tables, fontwork etc). Still, it should be easy to add additional toolbars to the code. All dialogs will work as normal. As I've set the zoom setting in full page mode to "page width", I've also removed the horizontal scrollbar.
As I'm a newbie with OOo macros, I don't yet know how to store original settings, so when reverting to the original view by running the macro again (or pressing F11 a second time), the zoom ratio is set to 100%.
Here goes:
| Code: |
rem **********************************************************************
rem FULLSCREEN TOGGLE
rem **********************************************************************
rem ---- if main menu is visible, triggers FullScreenOpen
rem ---- if main menu is hidden, triggers FullScreenClose
Sub FullScreenToggle
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl="private:resource/menubar/menubar"
If layout.IsElementVisible(sUrl) Then
FullScreenOpen
Else
FullScreenClose
Endif
End Sub
rem **********************************************************************
rem FULLSCREEN OPEN (triggered by FullScreenToggle)
rem **********************************************************************
rem ---- hides most toolbars, including default user-defined
rem ---- also hides the "full screen" button
rem ---- zooms to page width; horizontal toolbar is therefore hidden
sub FullScreenOpen
rem DEFINE VARIABLES
rem ----------------------------------------------------------------------
dim document as object
dim dispatcher as object
rem GET ACCESS TO THE DOCUMENT
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ZOOM TO PAGE WIDTH
rem ----------------------------------------------------------------------
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Zoom.Value"
args2(0).Value = 0
args2(1).Name = "Zoom.ValueSet"
args2(1).Value = 28703
args2(2).Name = "Zoom.Type"
args2(2).Value = 3
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args2())
rem REMOVE HORIZONTAL SCROLLBAR
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "HScroll"
args3(0).Value = false
dispatcher.executeDispatch(document, ".uno:HScroll", "", 0, args3())
rem TRIGGER FULL SCREEN
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "FullScreen"
args4(0).Value = true
dispatcher.executeDispatch(document, ".uno:FullScreen", "", 0, args4())
rem REMOVE UNWANTED SCROLLBARS
rem ----------------------------------------------------------------------
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl1="private:resource/toolbar/custom_toolbar_1"
sUrl2="private:resource/menubar/menubar"
sUrl3="private:resource/toolbar/fullscreenbar"
layout.hideElement(sUrl1)
layout.hideElement(sUrl2)
layout.hideElement(sUrl3)
end sub
rem **********************************************************************
rem FULLSCREEN CLOSE (triggered by FullScreenToggle)
rem **********************************************************************
rem ---- reverts to normal view
rem ---- I'm newbie, and don't know how to save the previous zoom ratio.
rem ---- Zoom is therefore set to 100%
sub FullScreenClose
rem DEFINE VARIABLES
rem ----------------------------------------------------------------------
dim document as object
dim dispatcher as object
rem GET ACCESS TO THE DOCUMENT
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ZOOM TO 100%
rem ----------------------------------------------------------------------
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Zoom.Value"
args2(0).Value = 100
args2(1).Name = "Zoom.ValueSet"
args2(1).Value = 28703
args2(2).Name = "Zoom.Type"
args2(2).Value = 0
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args2())
rem ADD HORIZONTAL SCROLLBAR
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "HScroll"
args3(0).Value = true
dispatcher.executeDispatch(document, ".uno:HScroll", "", 0, args3())
rem TOGGLE BACK FULL SCREEN VIEW
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "FullScreen"
args4(0).Value = false
dispatcher.executeDispatch(document, ".uno:FullScreen", "", 0, args4())
rem ADD TOOLBARS PREVIOUSLY REMOVED
rem ----------------------------------------------------------------------
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl1="private:resource/toolbar/custom_toolbar_1"
sUrl2="private:resource/menubar/menubar"
sUrl3="private:resource/toolbar/fullscreenbar"
layout.showElement(sUrl1)
layout.showElement(sUrl2)
end sub
|
Yes yes, I know, all this could probably be done with far more elegant and efficient code, but be gentle - it's my first time (and it works!) |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Sun Aug 14, 2011 6:20 am Post subject: |
|
|
| does anybody know how to code a macro to show/hide the new LibreOffice 3.4.x Findbar? |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Sun Aug 14, 2011 7:13 am Post subject: |
|
|
nevermind, here's the code to toggle ON/OFF the Findbar
| Code: | Sub ShowHideFindbar
' modified version of Toolbar macro by noranthon
' as seen on http://www.oooforum.org/forum/viewtopic.phtml?t=44460
' assign this macro to a toolbar button or keyboard hotkey to toggle on/off the Findbar
' if Findbar is OFF, the macro shows the Findbar
' if Findbar is ON, the macro hides the Findbar
Dim sUrl as String : sUrl = "private:resource/toolbar/findbar"
If ThisComponent.CurrentController.Frame.LayoutManager.IsElementVisible( sUrl ) Then
ThisComponent.CurrentController.Frame.LayoutManager.hideElement( sUrl )
Else ThisComponent.CurrentController.Frame.LayoutManager.showElement( sUrl )
EndIf
End Sub |
|
|
| Back to top |
|
 |
boukli Newbie

Joined: 30 Jun 2012 Posts: 1
|
Posted: Sat Jun 30, 2012 3:25 am Post subject: |
|
|
A slight modification of bluegecko's macro. With it you get a REAL full screen view. The only difference is that it triggers "Browse view" before "full screen", then permitting you to get a blank page all over your screen. I also removed the zoom changes, as they are not useful anymore.
With this, OOo becomes the simplest text editor ever.
Enjoy !
| Code: |
rem **********************************************************************
rem FULLSCREEN TOGGLE
rem **********************************************************************
rem ---- if main menu is visible, triggers FullScreenOpen
rem ---- if main menu is hidden, triggers FullScreenClose
Sub FullScreenToggle
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl="private:resource/menubar/menubar"
If layout.IsElementVisible(sUrl) Then
FullScreenOpen
Else
FullScreenClose
Endif
End Sub
rem **********************************************************************
rem FULLSCREEN OPEN (triggered by FullScreenToggle)
rem **********************************************************************
rem ---- hides most toolbars, including default user-defined
rem ---- also hides the "full screen" button d
sub FullScreenOpen
rem DEFINE VARIABLES
rem ----------------------------------------------------------------------
dim document as object
dim dispatcher as object
rem GET ACCESS TO THE DOCUMENT
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem REMOVE UNWANTED SCROLLBARS
rem ----------------------------------------------------------------------
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl1="private:resource/toolbar/custom_toolbar_1"
sUrl2="private:resource/menubar/menubar"
sUrl3="private:resource/toolbar/fullscreenbar"
layout.hideElement(sUrl1)
layout.hideElement(sUrl2)
layout.hideElement(sUrl3)
rem TRIGGER BROWSE VIEW
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "BrowseView"
args3(0).Value = true
dispatcher.executeDispatch(document, ".uno:BrowseView", "", 0, args3())
rem TRIGGER FULL SCREEN
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "FullScreen"
args4(0).Value = true
dispatcher.executeDispatch(document, ".uno:FullScreen", "", 0, args4())
end sub
rem **********************************************************************
rem FULLSCREEN CLOSE (triggered by FullScreenToggle)
rem **********************************************************************
rem ---- reverts to normal view
sub FullScreenClose
rem DEFINE VARIABLES
rem ----------------------------------------------------------------------
dim document as object
dim dispatcher as object
rem GET ACCESS TO THE DOCUMENT
rem ----------------------------------------------------------------------
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem TOGGLE BACK FULL SCREEN VIEW
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "FullScreen"
args2(0).Value = false
dispatcher.executeDispatch(document, ".uno:FullScreen", "", 0, args2())
rem TOGGLE BACK BROWSE VIEW
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "BrowseView"
args3(0).Value = false
dispatcher.executeDispatch(document, ".uno:BrowseView", "", 0, args3())
rem ADD TOOLBARS PREVIOUSLY REMOVED
rem ----------------------------------------------------------------------
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl1="private:resource/toolbar/custom_toolbar_1"
sUrl2="private:resource/menubar/menubar"
sUrl3="private:resource/toolbar/fullscreenbar"
layout.showElement(sUrl1)
layout.showElement(sUrl2)
end sub
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|