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