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 #ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLETOOLBOX_HXX
24 #define ACCESSIBILITY_STANDARD_VCLXACCESSIBLETOOLBOX_HXX
25 
26 #include <map>
27 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
28 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
29 
30 //	----------------------------------------------------
31 //	class VCLXAccessibleToolBox
32 //	----------------------------------------------------
33 
34 typedef ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessibleSelection > VCLXAccessibleToolBox_BASE;
35 
36 typedef std::map< sal_Int32, com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > ToolBoxItemsMap;
37 
38 class VCLXAccessibleToolBoxItem;
39 class ToolBox;
40 
41 class VCLXAccessibleToolBox : public VCLXAccessibleComponent, public VCLXAccessibleToolBox_BASE
42 {
43 private:
44     ToolBoxItemsMap             m_aAccessibleChildren;
45 
46 	VCLXAccessibleToolBoxItem*	GetItem_Impl( sal_Int32 _nPos, bool _bMustHaveFocus );
47 
48 	void						UpdateFocus_Impl();
49 	void						ReleaseFocus_Impl( sal_Int32 _nPos );
50 	void						UpdateChecked_Impl( sal_Int32 _nPos );
51 	void						UpdateIndeterminate_Impl( sal_Int32 _nPos );
52 	void						UpdateItem_Impl( sal_Int32 _nPos, sal_Bool _bItemAdded );
53 	void						UpdateAllItems_Impl();
54 	void						UpdateItemName_Impl( sal_Int32 _nPos );
55 	void						UpdateItemEnabled_Impl( sal_Int32 _nPos );
56 	void						UpdateCustomPopupItemp_Impl( Window* pWindow, bool bOpen );
57     void                        HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent, bool _bShow );
58     void                        ReleaseSubToolBox( ToolBox* _pSubToolBox );
59 
60 protected:
61 	virtual	~VCLXAccessibleToolBox();
62 
63     virtual void	FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
64 	virtual void	ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
65 	virtual void	ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent );
66 
67 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent );
68 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetItemWindowAccessible( const VclWindowEvent& rVclWindowEvent );
69 
70 	// XComponent
71 	virtual void SAL_CALL disposing();
72 
73 public:
74 	VCLXAccessibleToolBox( VCLXWindow* pVCLXWindow );
75 
76 	// XInterface
77 	DECLARE_XINTERFACE( )
78 
79 	// XTypeProvider
80 	DECLARE_XTYPEPROVIDER( )
81 
82 	// XServiceInfo
83 	virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
84 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
85 
86 	// XAccessibleContext
87 	virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
88 	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);
89 	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);
90 
91     // XAccessibleSelection
92     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
93     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
94     virtual void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
95     virtual void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
96     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
97     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);
98     virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
99 
100 private:
101 	void implReleaseToolboxItem(
102 			ToolBoxItemsMap::iterator& _rMapPos,
103 			bool _bNotifyRemoval,
104 			bool _bDispose
105 		);
106 };
107 
108 #endif // ACCESSIBILITY_STANDARD_VCLXACCESSIBLETOOLBOX_HXX
109 
110