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