Activated menu items in own extension menus

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
joesch
Posts: 53
Joined: Mon Apr 20, 2020 9:49 am
Location: Germany, near Berlin

Activated menu items in own extension menus

Post by joesch »

Hello,
the headline is maybe a little bit unclear, but there are in OO at various places of menus entries which can be activated and where this activation is visualized by a check mark, e.g.:

ActivatedMenuItem.gif

How can you get this behavior for your own menus, which are passed to extensions via Addon.xcu?
Of course this is also about own menu items (with which macros should be started) and not about standard menu items existing in OO which contain the 'checkmark functionality' anyway.
E.g. a macro is to be started with a menu item, which assigns an event to the current table

Code: Select all

Sub activate_2()
	Dim mEventProps(1) as new com.sun.star.beans.PropertyValue
	mEventProps(0).Name = "EventType"
	mEventProps(0).Value = "Script"
	mEventProps(1).Name = "Script"
	mEventProps(1).Value = "vnd.sun.star.script:SpecialInput.work.Zwei_Nachkommastellen?language=Basic&location=application"
	ThisComponent.CurrentController.ActiveSheet.Events.ReplaceByName("OnChange", mEventProps())
End Sub
and at the same time this menu item should get the check mark to show the user that the event, at the current time, is assigned.




greetings
Jörg
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Activated menu items in own extension menus

Post by JeJe »

Try checkitem

https://www.openoffice.org/api/docs/com ... pMenu.html

Edit:
or maybe a check mark for the image if you can set that? OO will have one in its icon set I expect.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
joesch
Posts: 53
Joined: Mon Apr 20, 2020 9:49 am
Location: Germany, near Berlin

Re: Activated menu items in own extension menus

Post by joesch »

Thank you.
But with this information I can't come to a solution alone, do you have a code example for me?

My Addon.xcu looks like this and defines a submenu in the edit menu. In this submenu, I want to check, for example, the menu item titled "detect 2 decimal places (0.00)":

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
	<node oor:name="AddonUI">
		<node oor:name="OfficeMenuBarMerging"> 
			<node oor:name="org.openoffice.specialinput" oor:op="replace">
				<node oor:name="m000" oor:op="replace"> 
					<prop oor:name="MergePoint"> 
						<value>.uno:EditMenu\.uno:ChangesMenu</value> 
					</prop> 
					<prop oor:name="MergeCommand"> 
						<value>AddAfter</value> 
					</prop> 
					<prop oor:name="MergeFallback"> 
						<value>AddPath</value> 
					</prop> 
					<prop oor:name="MergeContext" oor:type="xs:string"> 
						<value>com.sun.star.sheet.SpreadsheetDocument</value> 
					</prop> 
					<node oor:name="MenuItems"> 
						<node oor:name="m001" oor:op="replace">
							<prop oor:name="Context" oor:type="xs:string">
								<value>com.sun.star.sheet.SpreadsheetDocument</value>
							</prop>
							<prop oor:name="Title" oor:type="xs:string">
								<value xml:lang="en-US">Special Input</value>
								<value xml:lang="de">Spezialeingabe</value>
							</prop>
							<prop oor:name="ImageIdentifier" oor:type="xs:string">
								<value></value>
							</prop>
							<node oor:name="Submenu">
								<node oor:name="m002" oor:op="replace">
									<prop oor:name="Context" oor:type="xs:string">
										<value>com.sun.star.sheet.SpreadsheetDocument</value>
									</prop>
									<prop oor:name="URL" oor:type="xs:string">
										<value>vnd.sun.star.script:SpecialInput.work.activate_2?language=Basic&location=application</value>
									</prop>
									<prop oor:name="Title" oor:type="xs:string">
										<value xml:lang="en-US">detect 2 decimal places (0.00)</value>
										<value xml:lang="de">2 Dezimalstellen erkennen (0,00)</value>
									</prop>
									<prop oor:name="Target" oor:type="xs:string">
										<value>_self</value>
									</prop>
								</node>
								<node oor:name="m003" oor:op="replace">
									<prop oor:name="Context" oor:type="xs:string">
										<value>com.sun.star.sheet.SpreadsheetDocument</value>
									</prop>
									<prop oor:name="URL" oor:type="xs:string">
										<value>vnd.sun.star.script:SpecialInput.work.activate_3?language=Basic&location=application</value>
									</prop>
									<prop oor:name="Title" oor:type="xs:string">
										<value xml:lang="en-US">detect 3 decimal places (0.000)</value>
										<value xml:lang="de">3 Dezimalstellen erkennen (0,000)</value>
									</prop>
									<prop oor:name="Target" oor:type="xs:string">
										<value>_self</value>
									</prop>
								</node>
								<node oor:name="m004" oor:op="replace">
									<prop oor:name="Context" oor:type="xs:string">
										<value>com.sun.star.sheet.SpreadsheetDocument</value>
									</prop>
									<prop oor:name="URL" oor:type="xs:string">
										<value>vnd.sun.star.script:SpecialInput.work.deactivate_special_input?language=Basic&location=application</value>
									</prop>
									<prop oor:name="Title" oor:type="xs:string">
										<value xml:lang="en-US">Deactivate</value>
										<value xml:lang="de">Deaktivieren</value>
									</prop>
									<prop oor:name="Target" oor:type="xs:string">
										<value>_self</value>
									</prop>
								</node>
								<node oor:name="m005" oor:op="replace">
									<prop oor:name="Context" oor:type="xs:string">
										<value>com.sun.star.sheet.SpreadsheetDocument</value>
									</prop>
									<prop oor:name="URL" oor:type="xs:string">
										<value>private:separator</value>
									</prop>
								</node>
								<node oor:name="m006" oor:op="replace">
									<prop oor:name="Context" oor:type="xs:string">
										<value>com.sun.star.sheet.SpreadsheetDocument</value>
									</prop>
									<prop oor:name="URL" oor:type="xs:string">
										<value>vnd.sun.star.script:SpecialInput.work.Ueber?language=Basic&location=application</value>
									</prop>
									<prop oor:name="Title" oor:type="xs:string">
										<value xml:lang="en-US">About...</value>
										<value xml:lang="de">&#220;ber...</value>
									</prop>
									<prop oor:name="Target" oor:type="xs:string">
										<value>_self</value>
									</prop>
									<prop oor:name="ImageIdentifier" oor:type="xs:string">
										<value></value>
									</prop>
								</node>
							</node>
						</node>
					</node> 
				</node> 
			</node>
		</node>
	</node>
</oor:component-data>

greetings,
Jörg
Post Reply