xref: /trunk/main/sc/source/ui/inc/AccessibleCell.hxx (revision 4b4244d8473058f53d4f45cb9c8a849d8b28930e)
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_ACCESSIBLECELL_HXX
26 #define _SC_ACCESSIBLECELL_HXX
27 
28 #include "AccessibleCellBase.hxx"
29 #include "global.hxx"
30 #include "viewdata.hxx"
31 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
32 #include <unotools/accessiblerelationsethelper.hxx>
33 #include <editeng/AccessibleStaticTextBase.hxx>
34 #include <comphelper/uno3.hxx>
35 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XAccessibleExtendedAttributes_HPP_
36 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
37 #endif
38 #include <com/sun/star/ucb/CommandFailedException.hpp>
39 
40 class ScTabViewShell;
41 class ScAccessibleDocument;
42 
43 typedef cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleExtendedAttributes>
44                     ScAccessibleCellAttributeImpl;
45 
46 /** @descr
47         This base class provides an implementation of the
48         <code>AccessibleCell</code> service.
49 */
50 class ScAccessibleCell
51     :   public  ScAccessibleCellBase,
52         public  accessibility::AccessibleStaticTextBase,
53         public  ScAccessibleCellAttributeImpl
54 {
55 public:
56     //=====  internal  ========================================================
57     ScAccessibleCell(
58         const ::com::sun::star::uno::Reference<
59         ::com::sun::star::accessibility::XAccessible>& rxParent,
60         ScTabViewShell* pViewShell,
61         ScAddress& rCellAddress,
62         sal_Int32 nIndex,
63         ScSplitPos eSplitPos,
64         ScAccessibleDocument* pAccDoc);
65 
66     virtual void Init();
67 
68     using ScAccessibleCellBase::disposing;
69     virtual void SAL_CALL disposing();
70 
71 protected:
72     virtual ~ScAccessibleCell();
73 
74     using ScAccessibleCellBase::IsDefunc;
75 
76 public:
77     ///=====  XInterface  =====================================================
78 
79     DECLARE_XINTERFACE()
80 
81     ///=====  XTypeProvider  ===================================================
82 
83     DECLARE_XTYPEPROVIDER()
84 
85     ///=====  XAccessibleComponent  ============================================
86 
87     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
88         SAL_CALL getAccessibleAtPoint(
89         const ::com::sun::star::awt::Point& rPoint )
90         throw (::com::sun::star::uno::RuntimeException);
91 
92     virtual void SAL_CALL grabFocus(  )
93         throw (::com::sun::star::uno::RuntimeException);
94 
95 protected:
96     /// Return the object's current bounding box relative to the desktop.
97     virtual Rectangle GetBoundingBoxOnScreen(void) const
98         throw (::com::sun::star::uno::RuntimeException);
99 
100     /// Return the object's current bounding box relative to the parent object.
101     virtual Rectangle GetBoundingBox(void) const
102         throw (::com::sun::star::uno::RuntimeException);
103 
104 public:
105     ///=====  XAccessibleContext  ==============================================
106 
107     /// Return the number of currently visible children.
108     // is overloaded to calculate this on demand
109     virtual sal_Int32 SAL_CALL
110         getAccessibleChildCount(void)
111                     throw (::com::sun::star::uno::RuntimeException);
112 
113     /// Return the specified child or NULL if index is invalid.
114     // is overloaded to calculate this on demand
115     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
116         getAccessibleChild(sal_Int32 nIndex)
117         throw (::com::sun::star::uno::RuntimeException,
118                 ::com::sun::star::lang::IndexOutOfBoundsException);
119 
120     /// Return the set of current states.
121     virtual ::com::sun::star::uno::Reference<
122             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
123         getAccessibleStateSet(void)
124         throw (::com::sun::star::uno::RuntimeException);
125 
126     virtual ::com::sun::star::uno::Reference<
127         ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
128         getAccessibleRelationSet(void)
129         throw (::com::sun::star::uno::RuntimeException);
130 
131     ///=====  XServiceInfo  ====================================================
132 
133     /** Returns an identifier for the implementation of this object.
134     */
135     virtual ::rtl::OUString SAL_CALL
136         getImplementationName(void)
137         throw (::com::sun::star::uno::RuntimeException);
138 
139     /** Returns a list of all supported services.
140     */
141     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
142         getSupportedServiceNames(void)
143         throw (::com::sun::star::uno::RuntimeException);
144 
145     virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes()
146         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, com::sun::star::ucb::CommandFailedException) ;
147 
148     // Override this method to handle cell's ParaIndent attribute specially.
149     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes )
150         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
151 private:
152     ScTabViewShell* mpViewShell;
153     ScAccessibleDocument* mpAccDoc;
154 
155     ScSplitPos meSplitPos;
156 
157     sal_Bool IsDefunc(
158         const com::sun::star::uno::Reference<
159         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
160     virtual sal_Bool IsEditable(
161         const com::sun::star::uno::Reference<
162         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
163     sal_Bool IsOpaque(
164         const com::sun::star::uno::Reference<
165         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
166     sal_Bool IsSelected();
167 
168     ScDocument* GetDocument(ScTabViewShell* mpViewShell);
169 
170     ::std::auto_ptr< SvxEditSource > CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos);
171 
172     void FillDependends(utl::AccessibleRelationSetHelper* pRelationSet);
173     void FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet);
174     void AddRelation(const ScAddress& rCell,
175         const sal_uInt16 aRelationType,
176         ::utl::AccessibleRelationSetHelper* pRelationSet);
177     void AddRelation(const ScRange& rRange,
178         const sal_uInt16 aRelationType,
179         ::utl::AccessibleRelationSetHelper* pRelationSet);
180     sal_Bool IsFormulaMode();
181     sal_Bool IsDropdown();
182 };
183 
184 
185 #endif
186