With BaseExtensions, we are able to control the visibility of buttons and menus in ribbon and to control actions of commands. Regarding visibility, we are also able to target separators and injected features as well. This is based on an element to filter, and both cases use a similar syntax that can be explained as follows:
X="BaseExtensions:any"
Use this parameter when controlling visibility in ribbon. X
defines either visible
or enable
.
X-N-type
X defines either visible
, enable
or if
, while N defines any number larger than -1 (0, 1, ..... 9999).
This parameter defines the supported type of element.
X-N-key(-N)
This parameter defines the key for the element concerned. If there are several keys, use another N in to define the number of the key.
X-N-value(-N)
This parameter defines the value for the key, and is optional to use. For instance, if the element is a document property and this parameter is not present, any value for the document property will be accepted (empty included). If there are several values, use another N in to define the number of the value.
Define whether the logic is AND or OR (if several types of element)
In some cases it is necessary to depend the visibility on more than one type of element, for example if the button should only be visible if a particular style is present and the language of the document is English UK.
The logic is OR as default, meaning that the button will be visible when just one of the conditions evaluates to true. To ensure that it respects both conditions, add the following parameter:
visible-operator="AND"
Supported elements
We support the following elements when filtering:
- Bookmark (Word):
bookmarks
- Document properties (All):
documentprop
- Target built-in docprops by adding prefix to the key
BuiltIn.
(e.g. visible-1-key-1="BuiltIn.Title") - Use contains-logic adding prefix to the key
Contains.
(e.g. visible-1-key-1="Contains.MM_")
- Target built-in docprops by adding prefix to the key
- Inverse document properties (All):
!documentprop
- Document property is equal:
documentpropequals
- Extended doc prop visibility: docpropmap
- DocumentData:
documentdata
(If-type only) - Inverse DocumentData properties :
!DOCUMENTDATA
(If-type only) - DocumentData is equal:
DOCUMENTDATADOCPROPEQUALS
(If-type only) - Shapes (Word/PowerPoint):
shapes
- Inverse Shapes (Word/PowerPoint):
!shapes
- Styles (Word):
styles
- Content controls (Word/PowerPoint):
contentcontrol
- Inverse Content controls (Word/PowerPoint):
!contentcontrol
- Document language (Word):
lang
- Inverse document language (Word):
!lang
- Custom layout (PowerPoint):
customlayout
- Inverse custom layout (PowerPoint):
!customlayout
- XML part (All):
SdXmlPart
- Inverse XML part (All):
!SdXmlPart
- Registry key (HKCU): Registry
- Inverse registry key (HKCU):
!registry
- Registry key (HKLM):
HKLMCOMPAREREG
- Inverse registry key (HKLM):
!HKLMCOMPAREREG
- Accessible file:
FILELOCALACCESSIBLE
- Inverse accessible file:
!FILELOCALACCESSIBLE
- COMAddIns:
comaddins
- Office version (All):
OfficeVersion
- Document Compatibility (Word):
compatibilitymode
article - Custom XML:
CustomXml.PartName
- Inverse custom XML:
!CustomXml.PartName
-
Chart is selected:
ChartSelected
-
Chart is not selected:
!ChartSelected
-
Table is selected:
TableSelected
-
Table is not selected:
!TableSelected
-
Shape is selected:
ShapeSelected
-
Shape is not selected:
!ShapeSelected
Registry key (HKLM) limitations
HKLMCOMPAREREG is only supported in the Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node part of the registry (the hive used for 32-bit apps running on 64 bit Windows). It does not support keys in Computer\HKEY_LOCAL_MACHINE\SOFTWARE\ meaning outside of WOW6432Node.
Registry key (HKCU) limitations
Registry does not support DWORD type values. Instead it is recommended to use with string values (REG_SZ).
Control visibility in ribbon
We can show/hide and enable/disable buttons and menus in ribbon, even though they are connected to other Alloy plugins. We use the elements listed above. For instance, we can define a button to only be visible if a document property with a specific name and value is present.
In order to control visibility in ribbon, we define the parameters directly in the button or menu.
We support both visible
and enable
. If you use visible
when filtering, the button will be either shown or hidden depending on what is defined. In contrast, when enable
is used to filter, the button will be either enabled or disabled. Thus, the button will always be visible in ribbon when using enable
, but depending on what is defined in the filter, the user will either be able to click at the button or the button will be grey and not clickable.
Learn more and see examples of usage here.
Control actions of commands
We are able to control actions using an if
command, and thus affect other commands. Here, we define the parameters inside the command. This can be used to cancel the next commands in the chain if the if
command evaluates to false. We can also extend this and include a <True>
and <False>
element inside the command where we define what should happen if the if command evaluate to true/false.
Learn more and see examples of usage here.
Comments
0 comments
Article is closed for comments.