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_VCLXACCESSIBLETOOLBOXITEM_HXX
24 #define ACCESSIBILITY_STANDARD_VCLXACCESSIBLETOOLBOXITEM_HXX
25 
26 #include <com/sun/star/accessibility/XAccessible.hpp>
27 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_ACTION_HPP_
28 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
29 #endif
30 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
31 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
32 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
33 #include <com/sun/star/accessibility/XAccessibleText.hpp>
34 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
35 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #ifndef _CPPUHELPER_IMPLBASE4_HXX_
38 #include <cppuhelper/implbase4.hxx>
39 #endif
40 #include <comphelper/accessibletexthelper.hxx>
41 #include <tools/solar.h>
42 
43 // class VCLXAccessibleToolBoxItem ---------------------------------------------
44 
45 class ToolBox;
46 
47 typedef ::comphelper::OAccessibleTextHelper AccessibleTextHelper_BASE;
48 typedef ::cppu::ImplHelper4 < ::com::sun::star::accessibility::XAccessible,
49 							  ::com::sun::star::accessibility::XAccessibleAction,
50 							  ::com::sun::star::accessibility::XAccessibleValue,
51 							  ::com::sun::star::lang::XServiceInfo > VCLXAccessibleToolBoxItem_BASE;
52 
53 class VCLExternalSolarLock;
54 
55 class VCLXAccessibleToolBoxItem : public AccessibleTextHelper_BASE,
56 								  public VCLXAccessibleToolBoxItem_BASE
57 {
58 private:
59 	::rtl::OUString			m_sOldName;
60     ToolBox*				m_pToolBox;
61 	VCLExternalSolarLock*	m_pExternalLock;
62 	sal_Int32				m_nIndexInParent;
63 	sal_Int16 				m_nRole;
64 	sal_uInt16					m_nItemId;
65 	sal_Bool				m_bHasFocus;
66 	sal_Bool				m_bIsChecked;
67     bool                    m_bIndeterminate;
68 
69 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >	m_xChild;
70 
71 public:
getIndexInParent() const72 	inline sal_Int32	getIndexInParent() const					{ return m_nIndexInParent; }
setIndexInParent(sal_Int32 _nNewIndex)73 	inline void			setIndexInParent( sal_Int32 _nNewIndex )	{ m_nIndexInParent = _nNewIndex; }
74 
75 protected:
76 	virtual ~VCLXAccessibleToolBoxItem();
77 
78 	virtual void SAL_CALL					disposing();
79 
80 	/// implements the calculation of the bounding rectangle
81 	virtual ::com::sun::star::awt::Rectangle SAL_CALL	implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
82 
83 	// OCommonAccessibleText
84 	virtual ::rtl::OUString								implGetText();
85 	virtual ::com::sun::star::lang::Locale				implGetLocale();
86 	virtual void										implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex );
87 
88 	::rtl::OUString GetText( bool _bAsName );
89 
90 public:
91 	VCLXAccessibleToolBoxItem( ToolBox*	_pToolBox, sal_Int32 _nPos );
92 
93 	void				SetFocus( sal_Bool _bFocus );
HasFocus() const94 	inline sal_Bool		HasFocus() const { return m_bHasFocus; }
95 	void				SetChecked( sal_Bool _bCheck );
IsChecked() const96 	inline sal_Bool		IsChecked() const { return m_bIsChecked; }
97     void                SetIndeterminate( bool _bIndeterminate );
IsIndeterminate() const98     inline bool         IsIndeterminate() const { return m_bIndeterminate; }
ReleaseToolBox()99 	inline void			ReleaseToolBox() { m_pToolBox = NULL; }
100 	void				NameChanged();
101     void                SetChild( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _xChild );
102     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
GetChild() const103                         GetChild() const { return m_xChild; }
104     void                NotifyChildEvent( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _xChild, bool _bShow );
105 
106     void                ToggleEnableState();
107 
108 	// XInterface
109 	DECLARE_XINTERFACE( )
110 	DECLARE_XTYPEPROVIDER( )
111 
112 	// XServiceInfo
113 	virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
114 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
115 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
116 
117 	// XAccessible
118 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
119 
120 	// XAccessibleContext
121 	virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
122 	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);
123 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
124 	virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
125 	virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
126 	virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
127 	virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
128 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
129 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
130 
131 	// XAccessibleText
132 	virtual sal_Int32 SAL_CALL getCaretPosition() throw (::com::sun::star::uno::RuntimeException);
133 	virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
134     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);
135 	virtual ::com::sun::star::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
136     virtual sal_Int32 SAL_CALL getIndexAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
137 	virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
138     virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
139 
140 	// XAccessibleComponent
141 	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);
142 	virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
143 	virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
144 	virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
145 
146 	// XAccessibleExtendedComponent
147 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont(	) throw (::com::sun::star::uno::RuntimeException);
148 	virtual ::com::sun::star::awt::FontDescriptor SAL_CALL getFontMetrics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont >& xFont ) throw (::com::sun::star::uno::RuntimeException);
149 	virtual ::rtl::OUString SAL_CALL getTitledBorderText(  ) throw (::com::sun::star::uno::RuntimeException);
150 	virtual ::rtl::OUString SAL_CALL getToolTipText(  ) throw (::com::sun::star::uno::RuntimeException);
151 
152 	// XAccessibleAction
153 	virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) throw (::com::sun::star::uno::RuntimeException);
154 	virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
155 	virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
156 	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);
157 
158 	// XAccessibleValue
159 	virtual ::com::sun::star::uno::Any SAL_CALL getCurrentValue(  ) throw (::com::sun::star::uno::RuntimeException);
160 	virtual sal_Bool SAL_CALL setCurrentValue( const ::com::sun::star::uno::Any& aNumber ) throw (::com::sun::star::uno::RuntimeException);
161 	virtual ::com::sun::star::uno::Any SAL_CALL getMaximumValue(  ) throw (::com::sun::star::uno::RuntimeException);
162 	virtual ::com::sun::star::uno::Any SAL_CALL getMinimumValue(  ) throw (::com::sun::star::uno::RuntimeException);
163 };
164 
165 #endif // ACCESSIBILITY_STANDARD_VCLXACCESSIBLETOOLBOXITEM_HXX
166 
167