User:Regina/HowTo Symbol For Character Style
The feature request tdf#106681 asks for a symbol in the toolbar, which assigns a character style. This text describes, how this is possible with the current version of LibreOffice. It is tested with a Windows Version of LibreOffice 220.127.116.11.alpha0+, the developer version from 2017-03-02.
It is already possible to assign a character style via menu Styles. The solution here, transfers that solution to a toolbar.
Make an own toolbar
Goto▸ and click on the button . Name the toolbar e.g. "myStyles". This toolbar is empty. Add a command to it. It does not matter, which command you use; you will change it later on anyway. But it gives you the necessary structure of the source file. OK. The new toolbar might be placed in the top right corner and you see only the small dotted handle. Drag the new toolbar to a position, where you can notice it. Close LibreOffice.
Edit the toolbar configuration file
The toolbar configuration file is in your user profile. Goto▸ ▸ ▸ ▸ ▸ . You should see a file, which name starts with custom_toolbar. Open that file in an editor. Its content will look similar to this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd"> <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:uiname="myStyles"> <toolbar:toolbaritem xlink:href=".uno:HelpIndex" toolbar:text="LibreOfficeDev Help"/> </toolbar:toolbar>
You need a line <toolbar:toolbaritem … /> for each symbol in the toolbar. The part xlink:href= contains the information, which command will be executed, when you click on the symbol. The part toolbar:text contains the text, which is shown on the symbol, in case it has no icon or you have chosen to show the text.
Copy the needed command
The needed command is already used in menu Symbols. Therefore we open its configuration file and copy the command from there. Goto the installation directory. Goto▸ ▸ ▸ ▸ ▸ . Open the file menubar.xml in an editor, readonly is sufficient. Look for line <menu:menu menu:id=".uno:FormatStylesMenu">, about line #563. The lines below that have commands in the part menu:id, which assign a style; first the paragraph styles and then the character styles. Copy the text .uno:StyleApply?Style:string=Strong%20Emphasis&FamilyName:string=CharacterStyles from line #578 to the clipboard, for example.
Paste into your toolbar
Go back to the configuration file of your toolbar. Paste the text from the clipboard to replace the text in the xlink:href part. Then edit the content of the part toolbar:text accordingly. You will get a line like this:
<toolbar:toolbaritem xlink:href=".uno:StyleApply?Style:string=Strong%20Emphasis&FamilyName:string=CharacterStyles" toolbar:text="Style Strong Emphasis"/>
Notice, that the blank in the name of the style is replaced by %20. You can now copy this line and change the text after Style:string= to any character style you want to get.
Save the altered configuration file and restart LibreOffice. Your toolbar should have a symbol for e.g. assigning the character style Strong Emphasis.
Assign an icon
For to assign an icon to this command, you first need to generate suitable png-images. You need one in 16×16 pixel for small icon size, and one in 26×26 (Galaxy) or 24×24 (others) for large icon size, and one in 32×32 for Extra Large icon size, in case your theme supports this. You can reuse one of the already existing icons as well.
Goto▸ ▸ ▸ . It has a field Toolbar icon size. It is set to Automatic as default. With that setting, you cannot assign an icon. Therefore first set the icon size to small. OK. Use item Customize Toolbar… from the context menu of your toolbar. Select your command and then click on button ▸ . Click on button and find the small png-image. OK. The imported image will be top left in the list; click on it. OK. Instead of importing a new icon, you can choose one of those already shown in the list as well.
Next go back to▸ ▸ ▸ and set the icon size to large. Then assign the icon to your symbol the same way as described above. If necessary do the same for the Extra Large size. After that is done, you turn the icon size back to Automatic.
Of cause you can insert such command in any existing toolbar too. And you can do it not only in your user profile, but as administrator in the common files in folder share too.
This text does not solve the feature request, but is thought as a workaround till a more user-friendly solution is implemented.