xref: /trunk/main/sc/source/ui/inc/AccessibleDocument.hxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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 
25 #ifndef _SC_ACCESSIBLEDOCUMENT_HXX
26 #define _SC_ACCESSIBLEDOCUMENT_HXX
27 
28 #include "AccessibleDocumentBase.hxx"
29 #include "viewdata.hxx"
30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31 #include <com/sun/star/view/XSelectionChangeListener.hpp>
32 //#include <cppuhelper/implbase2.hxx>
33 #include <cppuhelper/implbase3.hxx>
34 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
35 #include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp>
36 #include <svx/IAccessibleViewForwarder.hxx>
37 
38 class ScTabViewShell;
39 class ScAccessibleSpreadsheet;
40 class ScChildrenShapes;
41 class ScAccessibleEditObject;
42 
43 namespace accessibility
44 {
45     class AccessibleShape;
46 }
47 namespace utl
48 {
49     class AccessibleRelationSetHelper;
50 }
51 
52 /** @descr
53         This base class provides an implementation of the
54         <code>AccessibleContext</code> service.
55 */
56 
57 typedef cppu::ImplHelper3< ::com::sun::star::accessibility::XAccessibleSelection,
58                             ::com::sun::star::accessibility::XAccessibleExtendedAttributes,
59                             ::com::sun::star::view::XSelectionChangeListener >
60                     ScAccessibleDocumentImpl;
61 
62 class ScAccessibleDocument
63     :   public ScAccessibleDocumentBase,
64         public ScAccessibleDocumentImpl,
65            public com::sun::star::accessibility::XAccessibleGetAccFlowTo,
66         public accessibility::IAccessibleViewForwarder
67 {
68 public:
69     //=====  internal  ========================================================
70     ScAccessibleDocument(
71         const ::com::sun::star::uno::Reference<
72         ::com::sun::star::accessibility::XAccessible>& rxParent,
73         ScTabViewShell* pViewShell,
74         ScSplitPos eSplitPos);
75 
76     virtual void Init();
77 
78 
79     DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
80 protected:
81     virtual ~ScAccessibleDocument(void);
82 
83     using ScAccessibleDocumentBase::IsDefunc;
84 
85 public:
86 
87     virtual void SAL_CALL disposing();
88 
89    ///=====  SfxListener  =====================================================
90 
91     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
92 
93     ///=====  XInterface  =====================================================
94 
95     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
96         ::com::sun::star::uno::Type const & rType )
97         throw (::com::sun::star::uno::RuntimeException);
98 
99     virtual void SAL_CALL acquire() throw ();
100 
101     virtual void SAL_CALL release() throw ();
102 
103     ///=====  XAccessibleComponent  ============================================
104 
105     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
106         SAL_CALL getAccessibleAtPoint(
107         const ::com::sun::star::awt::Point& rPoint )
108         throw (::com::sun::star::uno::RuntimeException);
109 
110     virtual void SAL_CALL grabFocus(  )
111         throw (::com::sun::star::uno::RuntimeException);
112 
113     ///=====  XAccessibleContext  ==============================================
114 
115     /// Return the number of currently visible children.
116     virtual sal_Int32 SAL_CALL
117         getAccessibleChildCount(void)
118         throw (::com::sun::star::uno::RuntimeException);
119 
120     /// Return the specified child or NULL if index is invalid.
121     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
122         getAccessibleChild(sal_Int32 nIndex)
123         throw (::com::sun::star::uno::RuntimeException,
124                 ::com::sun::star::lang::IndexOutOfBoundsException);
125 
126     /// Return the set of current states.
127     virtual ::com::sun::star::uno::Reference<
128             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
129         getAccessibleStateSet(void)
130         throw (::com::sun::star::uno::RuntimeException);
131 
132     virtual ::rtl::OUString SAL_CALL
133         getAccessibleName(void)
134         throw (::com::sun::star::uno::RuntimeException);
135 
136     virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes()
137         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
138     ///=====  XAccessibleSelection  ===========================================
139 
140     virtual void SAL_CALL
141         selectAccessibleChild( sal_Int32 nChildIndex )
142         throw (::com::sun::star::lang::IndexOutOfBoundsException,
143         ::com::sun::star::uno::RuntimeException);
144 
145     virtual sal_Bool SAL_CALL
146         isAccessibleChildSelected( sal_Int32 nChildIndex )
147         throw (::com::sun::star::lang::IndexOutOfBoundsException,
148         ::com::sun::star::uno::RuntimeException);
149 
150     virtual void SAL_CALL
151         clearAccessibleSelection(  )
152         throw (::com::sun::star::uno::RuntimeException);
153 
154     virtual void SAL_CALL
155         selectAllAccessibleChildren(  )
156         throw (::com::sun::star::uno::RuntimeException);
157 
158     virtual sal_Int32 SAL_CALL
159         getSelectedAccessibleChildCount(  )
160         throw (::com::sun::star::uno::RuntimeException);
161 
162     virtual ::com::sun::star::uno::Reference<
163         ::com::sun::star::accessibility::XAccessible > SAL_CALL
164         getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
165         throw (::com::sun::star::lang::IndexOutOfBoundsException,
166         ::com::sun::star::uno::RuntimeException);
167 
168     virtual void SAL_CALL
169         deselectAccessibleChild( sal_Int32 nChildIndex )
170         throw (::com::sun::star::lang::IndexOutOfBoundsException,
171         ::com::sun::star::uno::RuntimeException);
172 
173     ///=====  XSelectionListener  =============================================
174 
175     virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent )
176         throw (::com::sun::star::uno::RuntimeException);
177 
178     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
179         throw (::com::sun::star::uno::RuntimeException);
180 
181     ///=====  XServiceInfo  ===================================================
182 
183     /** Returns an identifier for the implementation of this object.
184     */
185     virtual ::rtl::OUString SAL_CALL
186         getImplementationName(void)
187         throw (::com::sun::star::uno::RuntimeException);
188 
189     /** Returns a list of all supported services.
190     */
191     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
192         getSupportedServiceNames(void)
193         throw (::com::sun::star::uno::RuntimeException);
194 
195     ///=====  XTypeProvider  ===================================================
196 
197     /// returns the possible types
198     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
199         getTypes()
200         throw (::com::sun::star::uno::RuntimeException);
201 
202     /** Returns a implementation id.
203     */
204     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
205         getImplementationId(void)
206         throw (::com::sun::star::uno::RuntimeException);
207 
208     ///=====  IAccessibleViewForwarder  ========================================
209 
210     /** This method informs you about the state of the forwarder.  Do not
211         use it when the returned value is <false/>.
212 
213         @return
214             Return <true/> if the view forwarder is valid and <false/> else.
215      */
216     virtual sal_Bool IsValid (void) const;
217 
218     /** Returns the area of the underlying document that is visible in the
219     * corresponding window.
220 
221         @return
222             The rectangle of the visible part of the document. The values
223             are, contrary to the base class, in internal coordinates.
224      */
225     virtual Rectangle GetVisibleArea() const;
226 
227     /** Transform the specified point from internal coordinates to an
228         absolute screen position.
229 
230         @param rPoint
231             Point in internal coordinates.
232 
233         @return
234             The same point but in screen coordinates relative to the upper
235             left corner of the (current) screen.
236      */
237     virtual Point LogicToPixel (const Point& rPoint) const;
238 
239     /** Transform the specified size from internal coordinates to a screen
240     * oriented pixel size.
241 
242         @param rSize
243             Size in internal coordinates.
244 
245         @return
246             The same size but in screen coordinates.
247      */
248     virtual Size LogicToPixel (const Size& rSize) const;
249 
250     /** Transform the specified point from absolute screen coordinates to
251         internal coordinates.
252 
253         @param rPoint
254             Point in screen coordinates relative to the upper left corner of
255             the (current) screen.
256 
257         @return
258             The same point but in internal coordinates.
259      */
260     virtual Point PixelToLogic (const Point& rPoint) const;
261 
262     /** Transform the specified size from screen coordinates to internal
263         coordinates.
264 
265         @param rSize
266             Size in screen coordinates.
267 
268         @return
269             The same size but in internal coordinates.
270      */
271     virtual Size PixelToLogic (const Size& rSize) const;
272 
273     ///======== internal =====================================================
274 
275     utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
276 
277     ::com::sun::star::uno::Reference
278         < ::com::sun::star::accessibility::XAccessible >
279         GetAccessibleSpreadsheet();
280 
281 protected:
282     /// Return this object's description.
283     virtual ::rtl::OUString SAL_CALL
284         createAccessibleDescription(void)
285         throw (::com::sun::star::uno::RuntimeException);
286 
287     /// Return the object's current name.
288     virtual ::rtl::OUString SAL_CALL
289         createAccessibleName(void)
290         throw (::com::sun::star::uno::RuntimeException);
291 
292     /// Return the object's current bounding box relative to the desktop.
293     virtual Rectangle GetBoundingBoxOnScreen(void) const
294         throw (::com::sun::star::uno::RuntimeException);
295 
296     /// Return the object's current bounding box relative to the parent object.
297     virtual Rectangle GetBoundingBox(void) const
298         throw (::com::sun::star::uno::RuntimeException);
299 
300 private:
301     ScTabViewShell* mpViewShell;
302     ScSplitPos      meSplitPos;
303     ScAccessibleSpreadsheet* mpAccessibleSpreadsheet;
304     ScChildrenShapes* mpChildrenShapes;
305     ScAccessibleEditObject* mpTempAccEdit;
306     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc;
307     Rectangle maVisArea;
308     sal_Bool mbCompleteSheetSelected;
309 
310 public:
311     SCTAB getVisibleTable() const; // use it in ScChildrenShapes
312 
313 private:
314     void FreeAccessibleSpreadsheet();
315 
316     sal_Bool IsTableSelected() const;
317 
318     sal_Bool IsDefunc(
319         const com::sun::star::uno::Reference<
320         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
321     sal_Bool IsEditable(
322         const com::sun::star::uno::Reference<
323         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
324 
325     void AddChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
326     void RemoveChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
327 
328     rtl::OUString GetCurrentCellName() const;
329     rtl::OUString GetCurrentCellDescription() const;
330 
331     Rectangle GetVisibleArea_Impl() const;
332     com::sun::star::uno::Sequence< com::sun::star::uno::Any > GetScAccFlowToSequence();
333 public:
334     ScDocument *GetDocument() const ;
335     ScAddress   GetCurCellAddress() const;
336     //=====  XAccessibleGetAccFromXShape  ============================================
337     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
338         SAL_CALL get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
339         throw ( ::com::sun::star::uno::RuntimeException );
340 
341      virtual sal_Int32 SAL_CALL getForeground(  )
342         throw (::com::sun::star::uno::RuntimeException);
343 
344     virtual sal_Int32 SAL_CALL getBackground(  )
345         throw (::com::sun::star::uno::RuntimeException);
346 protected:
347     void SwitchViewFireFocus();
348 };
349 
350 
351 #endif
352