xref: /AOO41X/main/accessibility/inc/accessibility/standard/accessiblemenubasecomponent.hxx (revision ffad8df045fe8db79e3e50f731c1fa6ab6501c83)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ACCESSIBILITY_STANDARD_ACCESSIBLEMENUBASECOMPONENT_HXX
25 #define ACCESSIBILITY_STANDARD_ACCESSIBLEMENUBASECOMPONENT_HXX
26 
27 #include <com/sun/star/accessibility/XAccessible.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/awt/Point.hpp>
30 #include <comphelper/accessiblecomponenthelper.hxx>
31 #ifndef _CPPUHELPER_IMPLBASE2_HXX
32 #include <cppuhelper/implbase2.hxx>
33 #endif
34 #include <tools/link.hxx>
35 
36 #include <vector>
37 
38 class Menu;
39 class VclSimpleEvent;
40 class VclMenuEvent;
41 class VCLExternalSolarLock;
42 
43 namespace utl {
44 class AccessibleStateSetHelper;
45 }
46 
47 //  ----------------------------------------------------
48 //  class OAccessibleMenuBaseComponent
49 //  ----------------------------------------------------
50 
51 typedef ::comphelper::OAccessibleExtendedComponentHelper    AccessibleExtendedComponentHelper_BASE;
52 
53 typedef ::cppu::ImplHelper2<
54     ::com::sun::star::accessibility::XAccessible,
55     ::com::sun::star::lang::XServiceInfo > OAccessibleMenuBaseComponent_BASE;
56 
57 class OAccessibleMenuBaseComponent : public AccessibleExtendedComponentHelper_BASE,
58                                      public OAccessibleMenuBaseComponent_BASE
59 {
60     friend class OAccessibleMenuItemComponent;
61     friend class VCLXAccessibleMenuItem;
62     friend class VCLXAccessibleMenu;
63 
64 private:
65     VCLExternalSolarLock*   m_pExternalLock;
66 
67 protected:
68     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > AccessibleChildren;
69 
70     AccessibleChildren      m_aAccessibleChildren;
71     Menu*                   m_pMenu;
72 
73     sal_Bool                m_bEnabled;
74     sal_Bool                m_bFocused;
75     sal_Bool                m_bVisible;
76     sal_Bool                m_bSelected;
77     sal_Bool                m_bChecked;
78 
GetMenu()79     Menu*                   GetMenu() { return m_pMenu; }
80 
81     virtual sal_Bool        IsEnabled();
82     virtual sal_Bool        IsFocused();
83     virtual sal_Bool        IsVisible();
84     virtual sal_Bool        IsSelected();
85     virtual sal_Bool        IsChecked();
86 
87     void                    SetEnabled( sal_Bool bEnabled );
88     void                    SetFocused( sal_Bool bFocused );
89     void                    SetVisible( sal_Bool bVisible );
90     void                    SetSelected( sal_Bool bSelected );
91     void                    SetChecked( sal_Bool bChecked );
92 
93     void                    UpdateEnabled( sal_Int32 i, sal_Bool bEnabled );
94     void                    UpdateFocused( sal_Int32 i, sal_Bool bFocused );
95     void                    UpdateVisible();
96     void                    UpdateSelected( sal_Int32 i, sal_Bool bSelected );
97     void                    UpdateChecked( sal_Int32 i, sal_Bool bChecked );
98     void                    UpdateAccessibleName( sal_Int32 i );
99     void                    UpdateItemText( sal_Int32 i );
100 
101     sal_Int32               GetChildCount();
102 
103     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChild( sal_Int32 i );
104     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAt( const ::com::sun::star::awt::Point& rPoint );
105 
106     void                    InsertChild( sal_Int32 i );
107     void                    RemoveChild( sal_Int32 i );
108 
109     virtual sal_Bool        IsHighlighted();
110     sal_Bool                IsChildHighlighted();
111 
112     virtual sal_Bool        IsMenuHideDisabledEntries();
113 
114     void                    SelectChild( sal_Int32 i );
115     void                    DeSelectAll();
116     sal_Bool                IsChildSelected( sal_Int32 i );
117 
118     virtual void            Select();
119     virtual void            DeSelect();
120     virtual void            Click();
121     virtual sal_Bool        IsPopupMenuOpen();
122 
123     DECL_LINK( MenuEventListener, VclSimpleEvent* );
124 
125     virtual void            ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent );
126 
127     virtual void            FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) = 0;
128 
129     // XComponent
130     virtual void SAL_CALL   disposing();
131 
132 public:
133     OAccessibleMenuBaseComponent( Menu* pMenu );
134     virtual ~OAccessibleMenuBaseComponent();
135 
136     void                    SetStates();
137 
138     // XInterface
139     DECLARE_XINTERFACE()
140 
141     // XTypeProvider
142     DECLARE_XTYPEPROVIDER()
143 
144     // XServiceInfo
145     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
146 
147     // XAccessible
148     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
149 
150     // XAccessibleContext
151     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
152 };
153 
154 #endif // ACCESSIBILITY_STANDARD_ACCESSIBLEMENUBASECOMPONENT_HXX
155 
156