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 _SVX_ACCESSIBILITY_ACCESSIBLE_CELL_HXX
25 #define _SVX_ACCESSIBILITY_ACCESSIBLE_CELL_HXX
26 
27 #include <com/sun/star/accessibility/XAccessible.hpp>
28 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/drawing/XShape.hpp>
31 
32 #include <rtl/ref.hxx>
33 
34 #include <editeng/AccessibleContextBase.hxx>
35 #include <editeng/AccessibleComponentBase.hxx>
36 #include <svx/IAccessibleViewForwarderListener.hxx>
37 #include <svx/AccessibleTextHelper.hxx>
38 #include <svx/AccessibleShapeTreeInfo.hxx>
39 
40 #include <cppuhelper/implbase1.hxx>
41 
42 #include "cell.hxx"
43 
44 #include <boost/noncopyable.hpp>
45 
46 class SdrObject;
47 
48 
49 namespace accessibility
50 {
51 
52 class AccessibleShapeInfo;
53 class AccessibleShapeTreeInfo;
54 class IAccessibleParent;
55 
56 typedef ::cppu::ImplInheritanceHelper1< AccessibleContextBase, ::com::sun::star::accessibility::XAccessibleExtendedComponent > AccessibleCellBase;
57 
58 class AccessibleCell : boost::noncopyable, public AccessibleCellBase, public AccessibleComponentBase, public IAccessibleViewForwarderListener
59 {
60 public:
61 	AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo);
62 	virtual ~AccessibleCell (void);
63 
64     virtual void Init (void);
65 
66     virtual bool operator== (const AccessibleCell& rAccessibleCell);
67 
68 	virtual sal_Bool SetState (sal_Int16 aState);
69 	virtual sal_Bool ResetState (sal_Int16 aState);
70     sal_Bool GetState (sal_Int16 aState);
71 
72 	// XInterface
73     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
74     virtual void SAL_CALL acquire(  ) throw ();
75     virtual void SAL_CALL release(  ) throw ();
76 
77 	// XAccessibleContext
78     virtual sal_Int32 SAL_CALL getAccessibleChildCount(void) throw(::com::sun::star::uno::RuntimeException);
79     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleChild(sal_Int32 nIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
80 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet(void) throw(::com::sun::star::uno::RuntimeException);
81 	virtual	sal_Int32 SAL_CALL getAccessibleIndexInParent(void) throw(::com::sun::star::uno::RuntimeException);
82 	virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException);
83 
84 	// XAccessibleComponent
85     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException);
86     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const ::com::sun::star::awt::Point& aPoint) throw(::com::sun::star::uno::RuntimeException);
87 	virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(void) throw(::com::sun::star::uno::RuntimeException);
88     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(void) throw(::com::sun::star::uno::RuntimeException);
89     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(void) throw(::com::sun::star::uno::RuntimeException);
90     virtual ::com::sun::star::awt::Size SAL_CALL getSize(void) throw(::com::sun::star::uno::RuntimeException);
91     virtual void SAL_CALL addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException);
92 	virtual void SAL_CALL removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
93     virtual void SAL_CALL grabFocus (void) throw (::com::sun::star::uno::RuntimeException);
94 	virtual sal_Int32 SAL_CALL getForeground(void) throw(::com::sun::star::uno::RuntimeException);
95     virtual sal_Int32 SAL_CALL getBackground(void) throw(::com::sun::star::uno::RuntimeException);
96 
97     // XAccessibleExtendedComponent
98     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont (void) throw (::com::sun::star::uno::RuntimeException);
99     virtual ::rtl::OUString SAL_CALL getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException);
100     virtual ::rtl::OUString SAL_CALL getToolTipText (void) throw (::com::sun::star::uno::RuntimeException);
101 
102     // XAccessibleEventBroadcaster
103     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener) throw(::com::sun::star::uno::RuntimeException);
104     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener) throw(::com::sun::star::uno::RuntimeException);
105 
106 	// XServiceInfo
107 	virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw(::com::sun::star::uno::RuntimeException);
108     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw(::com::sun::star::uno::RuntimeException);
109 
110     // IAccessibleViewForwarderListener
111     virtual void ViewForwarderChanged (ChangeType aChangeType, const IAccessibleViewForwarder* pViewForwarder);
112 
113 	using cppu::WeakComponentImplHelperBase::addEventListener;
114 	using cppu::WeakComponentImplHelperBase::removeEventListener;
115 
116     // Misc
117 
118 	/** set the index _nIndex at the accessible cell param	_nIndex The new index in parent.
119 	*/
120 	inline void setIndexInParent(sal_Int32 _nIndex) { mnIndexInParent = _nIndex; }
121 
122 protected:
123     /// Bundle of information passed to all shapes in a document tree.
124     AccessibleShapeTreeInfo maShapeTreeInfo;
125 
126 	/// the index in parent.
127 	sal_Int32 mnIndexInParent;
128 
129     /// The accessible text engine.  May be NULL if it can not be created.
130     AccessibleTextHelper* mpText;
131 
132 	sdr::table::CellRef mxCell;
133 
134     /// This method is called from the component helper base class while disposing.
135     virtual void SAL_CALL disposing (void);
136 
137 private:
138     explicit AccessibleCell(void);	// not implemented
139     explicit AccessibleCell(const AccessibleCell&); // not implemented
140     AccessibleCell& operator=(const AccessibleCell&); // not implemented
141 };
142 
143 } // end of namespace accessibility
144 
145 #endif
146