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 ACCESSIBILITY_EXT_ACCESSIBLELISTBOXENTRY_HXX_
29 #define ACCESSIBILITY_EXT_ACCESSIBLELISTBOXENTRY_HXX_
30 
31 #include <deque>
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
34 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
35 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
36 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
37 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
38 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <com/sun/star/lang/XEventListener.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <cppuhelper/compbase8.hxx>
43 #include <comphelper/broadcasthelper.hxx>
44 #include <comphelper/accessibletexthelper.hxx>
45 #include <tools/gen.hxx>
46 #include "accessibility/extended/listboxaccessible.hxx"
47 
48 // forward ---------------------------------------------------------------
49 
50 namespace com { namespace sun { namespace star { namespace awt {
51 	struct Point;
52 	struct Rectangle;
53 	struct Size;
54 	class XFocusListener;
55 } } } }
56 
57 class SvTreeListBox;
58 class SvLBoxEntry;
59 
60 //........................................................................
61 namespace accessibility
62 {
63 //........................................................................
64 
65 // class AccessibleListBoxEntry ------------------------------------------
66 
67 	typedef ::cppu::WeakAggComponentImplHelper8< ::com::sun::star::accessibility::XAccessible
68 												, ::com::sun::star::accessibility::XAccessibleContext
69 												, ::com::sun::star::accessibility::XAccessibleComponent
70 												, ::com::sun::star::accessibility::XAccessibleEventBroadcaster
71 												, ::com::sun::star::accessibility::XAccessibleAction
72 												, ::com::sun::star::accessibility::XAccessibleSelection
73 												, ::com::sun::star::accessibility::XAccessibleText
74 										    	, ::com::sun::star::lang::XServiceInfo > AccessibleListBoxEntry_BASE;
75 
76 	/** the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry */
77 	class AccessibleListBoxEntry:public ::comphelper::OBaseMutex
78 							   	,public AccessibleListBoxEntry_BASE
79 								,public ::comphelper::OCommonAccessibleText
80 								,public ListBoxAccessibleBase
81 	{
82 	friend class AccessibleListBox;
83 
84 	private:
85 		/** The treelistbox control */
86 		SvTreeListBox*						m_pListBox;
87 		::std::deque< sal_Int32 >			m_aEntryPath;
88 
89 	protected:
90         /// client id in the AccessibleEventNotifier queue
91         sal_uInt32                          m_nClientId;
92 
93         ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible >
94                                             m_aParent;
95 
96 	private:
97 		Rectangle				GetBoundingBox_Impl() const;
98 		Rectangle				GetBoundingBoxOnScreen_Impl() const;
99 		sal_Bool				IsAlive_Impl() const;
100 		sal_Bool				IsShowing_Impl() const;
101 
102 		Rectangle				GetBoundingBox() throw ( ::com::sun::star::lang::DisposedException );
103 		Rectangle				GetBoundingBoxOnScreen() throw ( ::com::sun::star::lang::DisposedException );
104     	void 					EnsureIsAlive() const throw ( ::com::sun::star::lang::DisposedException );
105 
106 	protected:
107 		virtual ~AccessibleListBoxEntry();
108 
109 		/** this function is called upon disposing the component
110 		*/
111 		virtual void SAL_CALL					disposing();
112 
113 		// ListBoxAccessible/XComponent
114 		virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
115 
116 		// OCommonAccessibleText
117 		virtual ::rtl::OUString					implGetText();
118 		virtual ::com::sun::star::lang::Locale	implGetLocale();
119 		virtual void							implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex );
120 
121 	public:
122 		/** Ctor()
123 			@param	_rListBox
124 				the view control
125 			@param	_pEntry
126 				the entry
127 			@param	_xParent
128 				is our parent accessible object
129 		*/
130 		AccessibleListBoxEntry(	SvTreeListBox& _rListBox, SvLBoxEntry* _pEntry,
131 								const ::com::sun::star::uno::Reference<
132 									::com::sun::star::accessibility::XAccessible >& _xParent );
133 
134 	protected:
135 		// XTypeProvider
136 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
137 
138 		// XServiceInfo
139 		virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
140 		virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
141 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException);
142 
143 		// XServiceInfo - static methods
144 		static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw(com::sun::star::uno::RuntimeException);
145 		static ::rtl::OUString getImplementationName_Static(void) throw(com::sun::star::uno::RuntimeException);
146 
147 		// XAccessible
148 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
149 
150 		// XAccessibleContext
151 		virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
152 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
153                 ::com::sun::star::uno::RuntimeException );
154 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
155 		virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
156 		virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
157 		virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
158 		virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
159 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
160 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
161 		virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
162 
163 		// XAccessibleComponent
164 		virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
165 		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);
166 		virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
167 		virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
168 		virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
169 		virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
170 		virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
171 		virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
172 		virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
173 
174 		// XAccessibleText
175 		virtual sal_Int32 SAL_CALL getCaretPosition() throw (::com::sun::star::uno::RuntimeException);
176 		virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
177 		virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
178 		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 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
179 		virtual ::com::sun::star::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
180 		virtual sal_Int32 SAL_CALL getCharacterCount() throw (::com::sun::star::uno::RuntimeException);
181 		virtual sal_Int32 SAL_CALL getIndexAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
182 		virtual ::rtl::OUString SAL_CALL getSelectedText() throw (::com::sun::star::uno::RuntimeException);
183 		virtual sal_Int32 SAL_CALL getSelectionStart() throw (::com::sun::star::uno::RuntimeException);
184 		virtual sal_Int32 SAL_CALL getSelectionEnd() throw (::com::sun::star::uno::RuntimeException);
185 		virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
186 		virtual ::rtl::OUString SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException);
187 		virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
188         virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
189         virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
190         virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
191 		virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
192 
193     	// XAccessibleEventBroadcaster
194         using cppu::WeakAggComponentImplHelperBase::addEventListener;
195 		virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
196         using cppu::WeakAggComponentImplHelperBase::removeEventListener;
197     	virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
198 
199     	// XAccessibleAction
200     	virtual sal_Int32 SAL_CALL getAccessibleActionCount(  ) throw (::com::sun::star::uno::RuntimeException);
201     	virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
202     	virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
203 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
204 
205 		// XAccessibleSelection
206 		void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
207 		sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
208 		void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
209 		void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
210 		sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
211 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
212 		void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
213 
214     private:
215         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > implGetParentAccessible( ) const;
216 	};
217 
218 //........................................................................
219 }// namespace accessibility
220 //........................................................................
221 
222 #endif // ACCESSIBILITY_EXT_ACCESSIBLELISTBOXENTRY_HXX_
223 
224