xref: /AOO41X/main/svtools/source/control/vclxaccessibleheaderbaritem.cxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
24 #include "precompiled_svtools.hxx"
25 
26 #ifndef _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_
27 #include <svtools/vclxaccessibleheaderbaritem.hxx>
28 #endif
29 
30 #ifndef _HEADBAR_HXX
31 #include <svtools/headbar.hxx>
32 #endif
33 
34 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
35 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
38 #include <com/sun/star/accessibility/AccessibleRole.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
41 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
42 #endif
43 
44 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
45 #include <unotools/accessiblestatesethelper.hxx>
46 #endif
47 #ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
48 #include <unotools/accessiblerelationsethelper.hxx>
49 #endif
50 #ifndef _SV_SVAPP_HXX
51 #include <vcl/svapp.hxx>
52 #endif
53 #ifndef _TOOLKIT_AWT_VCLXFONT_HXX_
54 #include <toolkit/awt/vclxfont.hxx>
55 #endif
56 #ifndef _TOOLKIT_HELPER_EXTERNALLOCK_HXX_
57 #include <toolkit/helper/externallock.hxx>
58 #endif
59 #ifndef _TOOLKIT_HELPER_CONVERT_HXX_
60 #include <toolkit/helper/convert.hxx>
61 #endif
62 
63 #include <vector>
64 
65 
66 using namespace ::com::sun::star;
67 using namespace ::com::sun::star::uno;
68 using namespace ::com::sun::star::lang;
69 using namespace ::com::sun::star::accessibility;
70 using namespace ::comphelper;
71 
DBG_NAME(VCLXAccessibleHeaderBarItem)72 DBG_NAME( VCLXAccessibleHeaderBarItem )
73 
74 //  ----------------------------------------------------
75 //  class AccessibleTabBar
76 //  ----------------------------------------------------
77 
78 VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar*    pHeadBar, sal_Int32 _nIndexInParent )
79     :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
80     ,m_pHeadBar( pHeadBar )
81     ,m_nIndexInParent(_nIndexInParent + 1)
82 
83 {
84     DBG_CTOR( VCLXAccessibleHeaderBarItem, NULL );
85     m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
86 }
87 
88 // -----------------------------------------------------------------------------
89 
~VCLXAccessibleHeaderBarItem()90 VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem()
91 {
92     delete m_pExternalLock;
93     m_pExternalLock = NULL;
94 }
95 
96 // -----------------------------------------------------------------------------
97 
IMPL_LINK(VCLXAccessibleHeaderBarItem,WindowEventListener,VclSimpleEvent *,pEvent)98 IMPL_LINK( VCLXAccessibleHeaderBarItem, WindowEventListener, VclSimpleEvent*, pEvent )
99 {
100     DBG_CHKTHIS( VCLXAccessibleHeaderBarItem, 0 );
101     DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleHeaderBarItem::WindowEventListener: unknown window event!" );
102 
103     if ( pEvent && pEvent->ISA( VclWindowEvent ) )
104     {
105         DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleHeaderBarItem::WindowEventListener: no window!" );
106         if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
107         {
108             ProcessWindowEvent( *(VclWindowEvent*)pEvent );
109         }
110     }
111 
112     return 0;
113 }
114 
115 // -----------------------------------------------------------------------------
116 
ProcessWindowEvent(const VclWindowEvent &)117 void VCLXAccessibleHeaderBarItem::ProcessWindowEvent( const VclWindowEvent& )
118 {
119     Any aOldValue, aNewValue;
120 }
121 
122 // -----------------------------------------------------------------------------
123 
FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)124 void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
125 {
126     if ( m_pHeadBar )
127     {
128         if ( m_pHeadBar->IsEnabled() )
129             rStateSet.AddState( AccessibleStateType::ENABLED );
130 
131         if ( m_pHeadBar->IsVisible() )
132         {
133             rStateSet.AddState( AccessibleStateType::VISIBLE );
134         }
135         rStateSet.AddState( AccessibleStateType::SELECTABLE );
136         rStateSet.AddState( AccessibleStateType::RESIZABLE );
137     }
138 }
139 
140 // -----------------------------------------------------------------------------
141 // OCommonAccessibleComponent
142 // -----------------------------------------------------------------------------
143 
implGetBounds()144 awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds() throw (RuntimeException)
145 {
146     awt::Rectangle aBounds;
147     OExternalLockGuard aGuard( this );
148 
149     ::com::sun::star::awt::Size aSize;
150 
151     if ( m_pHeadBar )
152         aBounds = AWTRectangle( m_pHeadBar->GetItemRect( sal_uInt16( m_nIndexInParent ) ) );
153 
154     return aBounds;
155 }
156 
157 // -----------------------------------------------------------------------------
158 // XInterface
159 // -----------------------------------------------------------------------------
160 
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleHeaderBarItem,AccessibleExtendedComponentHelper_BASE,VCLXAccessibleHeaderBarItem_BASE)161 IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE )
162 
163 // -----------------------------------------------------------------------------
164 // XTypeProvider
165 // -----------------------------------------------------------------------------
166 
167 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE )
168 
169 // -----------------------------------------------------------------------------
170 // XComponent
171 // -----------------------------------------------------------------------------
172 
173 void VCLXAccessibleHeaderBarItem::disposing()
174 {
175     AccessibleExtendedComponentHelper_BASE::disposing();
176 }
177 
178 // -----------------------------------------------------------------------------
179 // XServiceInfo
180 // -----------------------------------------------------------------------------
181 
getImplementationName()182 ::rtl::OUString VCLXAccessibleHeaderBarItem::getImplementationName() throw (RuntimeException)
183 {
184     return ::rtl::OUString::createFromAscii( "com.sun.star.comp.svtools.AccessibleHeaderBarItem" );
185 }
186 
187 // -----------------------------------------------------------------------------
188 
supportsService(const::rtl::OUString & rServiceName)189 sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
190 {
191     Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
192     const ::rtl::OUString* pNames = aNames.getConstArray();
193     const ::rtl::OUString* pEnd = pNames + aNames.getLength();
194     for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
195         ;
196 
197     return pNames != pEnd;
198 }
199 
200 // -----------------------------------------------------------------------------
201 
getSupportedServiceNames()202 Sequence< ::rtl::OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames() throw (RuntimeException)
203 {
204     Sequence< ::rtl::OUString > aNames(1);
205     aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBarItem" );
206     return aNames;
207 }
208 
209 // -----------------------------------------------------------------------------
210 // XAccessible
211 // -----------------------------------------------------------------------------
212 
getAccessibleContext()213 Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException)
214 {
215     OExternalLockGuard aGuard( this );
216 
217     return this;
218 }
219 
220 // -----------------------------------------------------------------------------
221 // XAccessibleContext
222 // -----------------------------------------------------------------------------
223 
getAccessibleChildCount()224 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException)
225 {
226     OExternalLockGuard aGuard( this );
227 
228     return 0;
229 }
230 
231 // -----------------------------------------------------------------------------
232 
getAccessibleChild(sal_Int32 i)233 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
234 {
235     OExternalLockGuard aGuard( this );
236 
237     if ( i < 0 || i >= getAccessibleChildCount() )
238         throw IndexOutOfBoundsException();
239 
240     return Reference< XAccessible >();
241 }
242 
243 // -----------------------------------------------------------------------------
244 
getAccessibleParent()245 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent() throw (RuntimeException)
246 {
247     OExternalLockGuard aGuard( this );
248 
249     Reference< XAccessible > xParent;
250     if ( m_pHeadBar )
251     {
252         xParent = m_pHeadBar->GetAccessible();
253     }
254 
255     return xParent;
256 }
257 
258 // -----------------------------------------------------------------------------
259 
getAccessibleIndexInParent()260 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent() throw (RuntimeException)
261 {
262     OExternalLockGuard aGuard( this );
263     return m_nIndexInParent - 1;
264 }
265 
266 // -----------------------------------------------------------------------------
267 
getAccessibleRole()268 sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole() throw (RuntimeException)
269 {
270     OExternalLockGuard aGuard( this );
271 
272     return AccessibleRole::COLUMN_HEADER;
273 }
274 
275 // -----------------------------------------------------------------------------
276 
getAccessibleDescription()277 ::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription() throw (RuntimeException)
278 {
279     OExternalLockGuard aGuard( this );
280     ::rtl::OUString sDescription;
281     return sDescription;
282 }
283 
284 // -----------------------------------------------------------------------------
285 
getAccessibleName()286 ::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException)
287 {
288     OExternalLockGuard aGuard( this );
289 
290     ::rtl::OUString sName;
291     if(m_pHeadBar)
292         sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) );
293     return sName;
294 }
295 
296 // -----------------------------------------------------------------------------
297 
getAccessibleRelationSet()298 Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet(  ) throw (RuntimeException)
299 {
300     OExternalLockGuard aGuard( this );
301 
302     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
303     Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
304     return xSet;
305 }
306 
307 // -----------------------------------------------------------------------------
308 
getAccessibleStateSet()309 Reference< XAccessibleStateSet > VCLXAccessibleHeaderBarItem::getAccessibleStateSet(  ) throw (RuntimeException)
310 {
311     OExternalLockGuard aGuard( this );
312 
313     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
314     Reference< XAccessibleStateSet > xSet = pStateSetHelper;
315 
316     if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
317     {
318         FillAccessibleStateSet( *pStateSetHelper );
319     }
320     else
321     {
322         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
323     }
324 
325     return xSet;
326 }
327 
328 // -----------------------------------------------------------------------------
329 
getLocale()330 com::sun::star::lang::Locale VCLXAccessibleHeaderBarItem::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException)
331 {
332     OExternalLockGuard aGuard( this );
333 
334     return Application::GetSettings().GetLocale();
335 }
336 
337 // -----------------------------------------------------------------------------
338 // XAccessibleComponent
339 // -----------------------------------------------------------------------------
340 
getAccessibleAtPoint(const awt::Point &)341 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
342 {
343     OExternalLockGuard aGuard( this );
344 
345     return Reference< XAccessible >();
346 }
347 
348 // -----------------------------------------------------------------------------
349 
getForeground()350 sal_Int32 VCLXAccessibleHeaderBarItem::getForeground() throw (RuntimeException)
351 {
352     OExternalLockGuard aGuard( this );
353 
354     sal_Int32 nColor = 0;
355     return nColor;
356 }
357 
358 // -----------------------------------------------------------------------------
359 
getBackground()360 sal_Int32 VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException)
361 {
362     OExternalLockGuard aGuard( this );
363 
364     sal_Int32 nColor = 0;
365     return nColor;
366 }
367 
368 // -----------------------------------------------------------------------------
369 // XAccessibleExtendedComponent
370 // -----------------------------------------------------------------------------
371 
getFont()372 Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException)
373 {
374     OExternalLockGuard aGuard( this );
375 
376     Reference< awt::XFont > xFont;
377     return xFont;
378 }
379 
380 // -----------------------------------------------------------------------------
381 
getTitledBorderText()382 ::rtl::OUString VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException)
383 {
384     OExternalLockGuard aGuard( this );
385 
386     ::rtl::OUString sText;
387     return sText;
388 }
389 
390 // -----------------------------------------------------------------------------
391 
getToolTipText()392 ::rtl::OUString VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException)
393 {
394     OExternalLockGuard aGuard( this );
395 
396     ::rtl::OUString sText;
397     if ( m_pHeadBar )
398         sText = m_pHeadBar->GetQuickHelpText();
399 
400     return sText;
401 }
402