By Unknown

LibreOffice on elementary: Part 3

LibreOffice certainly doesn't follow the elementary HIG, but there are a few tweaks to make it more elementary-like. This article describes a method to minimize the menu bar, create a hot key to toggle the menu, and create a menu toggle icon.

Create the Macro

In LibreWriter, go to Tools > Macros > Organize Macros > LibreOffice Basic. Navigate to Module1 and create a new Macro.
In the LibreOffice editor, paste the following code. Sub HideMenuBar
layout = Thiscomponent.CurrentController.Frame.LayoutManager
End Sub

Sub ShowMenuBar
layout = Thiscomponent.CurrentController.Frame.LayoutManager
End Sub

Sub MenuToggle
Dim sUrl as String : sUrl = "private:resource/menubar/menubar"
If NOT ThisComponent.CurrentController.Frame.LayoutManager.IsElementVisible( sUrl ) Then
ThisComponent.CurrentController.Frame.LayoutManager.showElement( sUrl )
ThisComponent.CurrentController.Frame.LayoutManager.hideElement( sUrl )
End Sub
Congratulations. You've completed the code portion. Let's integrate it and make it functional.

Create a HotKey Toggle

We are going to map our new MenuToggle to a hotkey. In our case, we think CONTROL+M seems intuitive, but you may chose any key option that makes sense for you.

From the menu, navigate to Tools > Customize > Keyboard. In the top "Shortcut keys" pane, select the hotkey that you wish. In the bottom-left "Category" pane, select LibreOffice Macros > user > Standard > module1. In the "Function" pane, choose MenuToggle. Select Modify and you're done.

Test that it works. You should now be able to show and hide the menu by using the new hotkey.

Create a Menu Button

From the menu, navigate to Tools > Customize > Toolbars. Create a new toolbar. I named my toolbar "Menu". Add a new item, and select it by: LibreOffice Macros > user > Standard > module1. Select MenuToggle and add it.

You may change the icon by selecting "Change Icon" under the "Modify" button.
Position your new toolbar to the far right.

Launch LibreOffice without a Menu

Again, navigate to Tools > Customize > Events. Add your new macro to the following events:
  • New Document
  • View Created
  • Activate Document
Be sure to save it in LibreOffice in the bottom dropdown menu.

Special Note About Faenza Icons

If you are using the modern Faenza icon theme, you must change the icon view to small. Go to Tools > Options > View .

Final View

Here's the finished product.
Thanks to Luca Tavecchio for the sweet tip!