summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java
blob: 043a97fac60ac3c7a2bdde4b8cfb615ff8b608ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import com.sun.star.ui.*;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.RuntimeException;

// A helper class to determine the menu element type
public class MenuElement
{
    static public boolean IsMenuEntry( com.sun.star.beans.XPropertySet xMenuElement ) {
        com.sun.star.lang.XServiceInfo xServiceInfo =
            (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
                com.sun.star.lang.XServiceInfo.class, xMenuElement );

        return xServiceInfo.supportsService( "com.sun.star.ui.ActionTrigger" );
    }

    static public boolean IsMenuSeparator( com.sun.star.beans.XPropertySet xMenuElement ) {
        com.sun.star.lang.XServiceInfo xServiceInfo =
            (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
                com.sun.star.lang.XServiceInfo.class, xMenuElement );

        return xServiceInfo.supportsService( "com.sun.star.ui.ActionTriggerSeparator" );
    }
}