xref: /AOO41X/main/sc/inc/AccessibleFilterMenu.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_ACCESSIBLEFILTERMENU_HXX
29 #define SC_ACCESSIBLEFILTERMENU_HXX
30 
31 #include "AccessibleContextBase.hxx"
32 #include "cppuhelper/implbase1.hxx"
33 
34 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
35 #include <com/sun/star/accessibility/XAccessibleText.hpp>
36 #include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp>
37 #include <com/sun/star/accessibility/TextSegment.hpp>
38 
39 #include <vector>
40 
41 namespace com { namespace sun { namespace star {
42     namespace accessibility {
43         struct AccessibleEventObject;
44     }
45 }}}
46 
47 class ScDocument;
48 class ScMenuFloatingWindow;
49 
50 typedef ::cppu::ImplHelper1<
51         ::com::sun::star::accessibility::XAccessibleSelection > ScAccessibleFilterMenu_BASE;
52 
53 class ScAccessibleFilterMenu :
54     public ScAccessibleContextBase,
55     public ScAccessibleFilterMenu_BASE
56 {
57 public:
58     explicit ScAccessibleFilterMenu(
59         const ::com::sun::star::uno::Reference<
60             ::com::sun::star::accessibility::XAccessible>& rxParent,
61             ScMenuFloatingWindow* pWin, const ::rtl::OUString& rName, size_t nMenuPos, ScDocument* pDoc);
62     virtual ~ScAccessibleFilterMenu();
63 
64 	// XAccessibleComponent
65 
66     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
67 		SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )
68 		    throw (::com::sun::star::uno::RuntimeException);
69 
70     virtual sal_Bool SAL_CALL isVisible()
71 		throw (::com::sun::star::uno::RuntimeException);
72 
73     virtual void SAL_CALL grabFocus()
74 		throw (::com::sun::star::uno::RuntimeException);
75 
76     virtual sal_Int32 SAL_CALL getForeground()
77         throw (::com::sun::star::uno::RuntimeException);
78 
79     virtual sal_Int32 SAL_CALL getBackground()
80         throw (::com::sun::star::uno::RuntimeException);
81 
82 	// XAccessibleContext
83 
84 	virtual ::rtl::OUString SAL_CALL getAccessibleName()
85         throw (::com::sun::star::uno::RuntimeException);
86 
87     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
88         throw (::com::sun::star::uno::RuntimeException);
89 
90     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
91     	getAccessibleChild(sal_Int32 nIndex)
92             throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException);
93 
94 	virtual ::com::sun::star::uno::Reference<
95         ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
96     	getAccessibleStateSet()
97             throw (::com::sun::star::uno::RuntimeException);
98 
99 	virtual ::rtl::OUString SAL_CALL getImplementationName()
100         throw (::com::sun::star::uno::RuntimeException);
101 
102     // XAccessibleEventBroadcaster
103 
104     using ScAccessibleContextBase::addEventListener;
105     using ScAccessibleContextBase::removeEventListener;
106 
107 	virtual void SAL_CALL
108     	addEventListener(
109         	const ::com::sun::star::uno::Reference<
110                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
111         throw (com::sun::star::uno::RuntimeException);
112 
113     //	Remove an existing event listener.
114 	virtual void SAL_CALL
115     	removeEventListener(
116 			const ::com::sun::star::uno::Reference<
117                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
118         throw (com::sun::star::uno::RuntimeException);
119 
120     // XAccessibleSelection
121 
122     virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex)
123         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
124 
125     virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex)
126         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
127 
128     virtual void SAL_CALL clearAccessibleSelection()
129         throw (::com::sun::star::uno::RuntimeException);
130 
131     virtual void SAL_CALL selectAllAccessibleChildren()
132         throw (::com::sun::star::uno::RuntimeException);
133 
134     virtual ::sal_Int32 SAL_CALL getSelectedAccessibleChildCount()
135         throw (::com::sun::star::uno::RuntimeException);
136 
137     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
138         getSelectedAccessibleChild(sal_Int32 nChildIndex)
139             throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
140 
141     virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex)
142         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
143 
144     // XInterface
145 
146 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
147 		::com::sun::star::uno::Type const & rType )
148 		    throw (::com::sun::star::uno::RuntimeException);
149 
150 	virtual void SAL_CALL acquire() throw ();
151 	virtual void SAL_CALL release() throw ();
152 
153     // XTypeProvider
154 
155     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
156         throw (::com::sun::star::uno::RuntimeException);
157 
158     // non-UNO methods
159 
160     void appendMenuItem(const ::rtl::OUString& rName, bool bEnabled, size_t nMenuPos);
161     void setMenuPos(size_t nMenuPos);
162     void setEnabled(bool bEnabled);
163 
164 protected:
165 
166     sal_Int32 getMenuItemCount() const;
167 
168 	virtual Rectangle GetBoundingBoxOnScreen() const
169 		throw (::com::sun::star::uno::RuntimeException);
170 
171 	virtual Rectangle GetBoundingBox() const
172 		throw (::com::sun::star::uno::RuntimeException);
173 
174 private:
175     bool isSelected() const;
176     bool isFocused() const;
177 
178     void updateStates();
179 
180 private:
181     ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > maMenuItems;
182     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > mxStateSet;
183 
184     size_t mnMenuPos;
185     ScMenuFloatingWindow* mpWindow;
186     ScDocument* mpDoc;
187 
188     bool mbEnabled:1;
189 };
190 
191 #endif
192