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 _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
25 #define _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
26 
27 #include <com/sun/star/accessibility/XAccessible.hpp>
28 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <comphelper/accessiblecomponenthelper.hxx>
31 #include <cppuhelper/implbase3.hxx>
32 #include <tools/link.hxx>
33 #include <svl/lstner.hxx>
34 
35 #include <vector>
36 
37 class DialogWindow;
38 class DlgEditor;
39 class DlgEdModel;
40 class DlgEdObj;
41 class VCLExternalSolarLock;
42 class VclSimpleEvent;
43 class VclWindowEvent;
44 
45 namespace utl {
46 class AccessibleStateSetHelper;
47 }
48 
49 
50 //	----------------------------------------------------
51 //	class AccessibleDialogWindow
52 //	----------------------------------------------------
53 
54 typedef ::comphelper::OAccessibleExtendedComponentHelper	AccessibleExtendedComponentHelper_BASE;
55 
56 typedef ::cppu::ImplHelper3	<
57 	::com::sun::star::accessibility::XAccessible,
58 	::com::sun::star::accessibility::XAccessibleSelection,
59 	::com::sun::star::lang::XServiceInfo > AccessibleDialogWindow_BASE;
60 
61 class AccessibleDialogWindow :	public AccessibleExtendedComponentHelper_BASE,
62 								public AccessibleDialogWindow_BASE,
63 								public SfxListener
64 {
65 private:
66 
67 	class ChildDescriptor
68 	{
69 	public:
70 		DlgEdObj*																					pDlgEdObj;
71 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >	rxAccessible;
72 
73 		ChildDescriptor( DlgEdObj* _pDlgEdObj );
74 		~ChildDescriptor();
75 
76 		ChildDescriptor( const ChildDescriptor& rDesc );
77 		ChildDescriptor& operator=( const ChildDescriptor& rDesc );
78 
79 		bool operator==( const ChildDescriptor& rDesc );
80 		bool operator<( const ChildDescriptor& rDesc ) const;
81 	};
82 
83 	typedef ::std::vector< ChildDescriptor > AccessibleChildren;
84 
85 	AccessibleChildren		m_aAccessibleChildren;
86 	VCLExternalSolarLock*	m_pExternalLock;
87 	DialogWindow*			m_pDialogWindow;
88 	DlgEditor*				m_pDlgEditor;
89 	DlgEdModel*				m_pDlgEdModel;
90 
91 protected:
92 	void					UpdateFocused();
93 	void					UpdateSelected();
94 	void					UpdateBounds();
95 
96 	sal_Bool				IsChildVisible( const ChildDescriptor& rDesc );
97 
98 	void					InsertChild( const ChildDescriptor& rDesc );
99 	void					RemoveChild( const ChildDescriptor& rDesc );
100 	void					UpdateChild( const ChildDescriptor& rDesc );
101 	void					UpdateChildren();
102 	void					SortChildren();
103 
104 	DECL_LINK( WindowEventListener, VclSimpleEvent* );
105 
106 	virtual void			ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
107 	virtual void			FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
108 
109 	// OCommonAccessibleComponent
110 	virtual ::com::sun::star::awt::Rectangle SAL_CALL	implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
111 
112 	// XComponent
113 	virtual void SAL_CALL	disposing();
114 
115 public:
116 	AccessibleDialogWindow( DialogWindow* pDialogWindow );
117 	~AccessibleDialogWindow();
118 
119 	// SfxListener
120 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
121 
122 	// XInterface
123 	DECLARE_XINTERFACE()
124 
125 	// XTypeProvider
126 	DECLARE_XTYPEPROVIDER()
127 
128 	// XServiceInfo
129 	virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
130 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
131 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
132 
133 	// XAccessible
134 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
135 
136 	// XAccessibleContext
137 	virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
138 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
139 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
140 	virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
141 	virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
142 	virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
143 	virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
144 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
145 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
146 	virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
147 
148 	// XAccessibleComponent
149 	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);
150 	virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
151 	virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
152 	virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
153 
154 	// XAccessibleExtendedComponent
155 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont(	) throw (::com::sun::star::uno::RuntimeException);
156 	virtual ::rtl::OUString SAL_CALL getTitledBorderText(  ) throw (::com::sun::star::uno::RuntimeException);
157 	virtual ::rtl::OUString SAL_CALL getToolTipText(  ) throw (::com::sun::star::uno::RuntimeException);
158 
159 	// XAccessibleSelection
160 	virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
161 	virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
162 	virtual void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
163 	virtual void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
164 	virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
165 	virtual ::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);
166 	virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
167 };
168 
169 
170 #endif // _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
171 
172