Toggle the image on a extension toolbar button

Discussions about using 3rd party extension with OpenOffice.org
Post Reply
northshaman
Posts: 5
Joined: Thu Dec 21, 2023 11:20 am

Toggle the image on a extension toolbar button

Post by northshaman »

Hi!
Is there any way to implement toggle the image on a extension toolbar button when you click on it? In few topics on this forum that I find, it's not possible to get properties of the buttons from this panel in runtime. Maybe there is some other way? For example, through an xcu file?
I appreciate your help in advance.
JeJe
Volunteer
Posts: 2923
Joined: Wed Mar 09, 2016 2:40 pm

Re: Toggle the image on a extension toolbar button

Post by JeJe »

Have your extension create a non-extension toolbar after installation.

(Edit: if that would work)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
northshaman
Posts: 5
Joined: Thu Dec 21, 2023 11:20 am

Re: Toggle the image on a extension toolbar button

Post by northshaman »

I can add or remove buttons on a standardBar. But I want to do the same with my extended panel. For example, in runtime, add or remove a button, change the button image, hide or show buttons.
Last edited by northshaman on Fri Dec 22, 2023 3:17 pm, edited 1 time in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.6.0.3 (x64)
JeJe
Volunteer
Posts: 2923
Joined: Wed Mar 09, 2016 2:40 pm

Re: Toggle the image on a extension toolbar button

Post by JeJe »

Is the button on a toolbar or a panel?

Edit: A panel is something like the navigator or the sidebar panels. A Toolbar is like the formatting toolbar.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
northshaman
Posts: 5
Joined: Thu Dec 21, 2023 11:20 am

Re: Toggle the image on a extension toolbar button

Post by northshaman »

in the configuration file it's called toolbar.
Here's part of my xcu configuration:

Code: Select all

<node oor:name="OfficeToolBar">
	<node oor:name="sumra.dataunit.DataUnitExtension.toolbar" oor:op="replace">
		<prop oor:name="Title" oor:type="xs:string">
			<value>Data Unit Extension</value>
		</prop>
		<node oor:name="t01" oor:op="replace">
			<prop oor:name="URL" oor:type="xs:string">
				<value>com.data.Data?CONNECTION_SETTING</value>
			</prop>
			<prop oor:name="Target" oor:type="xs:string">
				<value>_self</value>
			</prop>
			<prop oor:name="Context" oor:type="xs:string">
				<value>com.sun.star.text.TextDocument</value>
			</prop>
			<prop oor:name="Title" oor:type="xs:string">
				<value xml:lang="en-US">Connection settings</value>
			</prop>
		</node>
		<node oor:name="t02" oor:op="replace">
			<prop oor:name="URL" oor:type="xs:string">
				<value>service:com.data.ChangeMode</value>
			</prop>
			<prop oor:name="Target" oor:type="xs:string">
				<value>_self</value>
			</prop>
			<prop oor:name="Context" oor:type="xs:string">
				<value>com.sun.star.sheet.TextDocument</value>
			</prop>
			<prop oor:name="Title" oor:type="xs:string">
				<value xml:lang="en-US">Change view mode</value>
			</prop>
		</node>
	</node>
</node>
And this how it's looks in office:
Image
Windows 10, Openoffice 4.1.11, LibreOffice 7.6.0.3 (x64)
JeJe
Volunteer
Posts: 2923
Joined: Wed Mar 09, 2016 2:40 pm

Re: Toggle the image on a extension toolbar button

Post by JeJe »

My suggestion is instead of creating a toolbar tied in with the extension - add a normal toolbar after the extension is installed to calc - and then via the toolbar's settings in the frame's layout manager you can modify the buttons at runtime.

The normal way of showing a change in the button is to highlite it though, not change the icon.

Another easy way of showing a changed button state would be to change the text color for the toolbar... eg red text signifying "on". This change would apply to all buttons on the toolbar though, so not suitable if you have more than that one button.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
northshaman
Posts: 5
Joined: Thu Dec 21, 2023 11:20 am

Re: Toggle the image on a extension toolbar button

Post by northshaman »

Thanks for your answers!
Dynamically add buttons to standard toolbar works. To change the button icon, I use two different urls and two buttons with the same command but different arguments. When you click on the button, I delete button and insert another one in its place. But with this approach i get proplems with "jumping" buttons on the toolbar. After inserting button, a gap appears between the previous button and the inserted one, which collapse when the window size is changed. Can you tell me what interface or method can be used to update the window display after replacing the button?
I tried to use this code, but it doesn't work =(

Code: Select all

/****/
XUIElementSettings xuiElementSettings = UnoRuntime.queryInterface(XUIElementSettings.class, element);
/****/
xuiElementSettings.setSettings(settings);
xuiElementSettings.updateSettings();
/****/
XUpdatable updatable = UnoRuntime.queryInterface(XUpdatable.class, e);
updatable.update();
Attachments
photo_2023-12-25_11-17-55.jpg
photo_2023-12-25_11-17-55.jpg (9.35 KiB) Viewed 5864 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.6.0.3 (x64)
JeJe
Volunteer
Posts: 2923
Joined: Wed Mar 09, 2016 2:40 pm

Re: Toggle the image on a extension toolbar button

Post by JeJe »

There are two ways of changing the toolbar - one is to change it for the current controller/frame's layout manager which doesn't affect other frames or new frames. The other is to change the toolbar for the module (eg Writer module) so all frames are affected.

In either case MRI should help you explore the layout manager to find a way of refreshing the current toolbar

viewtopic.php?t=49294
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
northshaman
Posts: 5
Joined: Thu Dec 21, 2023 11:20 am

Re: Toggle the image on a extension toolbar button

Post by northshaman »

Thank you!
Windows 10, Openoffice 4.1.11, LibreOffice 7.6.0.3 (x64)
Post Reply