LibreOffice Module accessibility (master) 1
accessibletabbarpage.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <svtools/tabbar.hxx>
22#include <com/sun/star/accessibility/AccessibleEventId.hpp>
23#include <com/sun/star/accessibility/AccessibleRole.hpp>
24#include <com/sun/star/accessibility/AccessibleStateType.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29#include <vcl/svapp.hxx>
30#include <vcl/settings.hxx>
33
34
35namespace accessibility
36{
37
38
39 using namespace ::com::sun::star::accessibility;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star;
43 using namespace ::comphelper;
44
45
46
47
48 AccessibleTabBarPage::AccessibleTabBarPage( TabBar* pTabBar, sal_uInt16 nPageId, const Reference< XAccessible >& rxParent )
49 :ImplInheritanceHelper( pTabBar )
50 ,m_nPageId( nPageId )
51 ,m_xParent( rxParent )
52 {
55
56 if ( m_pTabBar )
57 m_sPageText = m_pTabBar->GetPageText( m_nPageId );
58 }
59
60
62 {
63 OExternalLockGuard aGuard( this );
64
65 bool bEnabled = false;
66 if ( m_pTabBar )
67 bEnabled = m_pTabBar->IsPageEnabled( m_nPageId );
68
69 return bEnabled;
70 }
71
72
74 {
75 bool bShowing = false;
76
77 if ( m_pTabBar && m_pTabBar->IsVisible() )
78 bShowing = true;
79
80 return bShowing;
81 }
82
83
85 {
86 bool bSelected = false;
87
88 if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_nPageId )
89 bSelected = true;
90
91 return bSelected;
92 }
93
94
96 {
97 if ( m_bShowing != bShowing )
98 {
99 Any aOldValue, aNewValue;
100 if ( m_bShowing )
101 aOldValue <<= AccessibleStateType::SHOWING;
102 else
103 aNewValue <<= AccessibleStateType::SHOWING;
104 m_bShowing = bShowing;
105 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
106 }
107 }
108
109
111 {
112 if ( m_bSelected != bSelected )
113 {
114 Any aOldValue, aNewValue;
115 if ( m_bSelected )
116 aOldValue <<= AccessibleStateType::SELECTED;
117 else
118 aNewValue <<= AccessibleStateType::SELECTED;
119 m_bSelected = bSelected;
120 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
121 }
122 }
123
124
125 void AccessibleTabBarPage::SetPageText( const OUString& sPageText )
126 {
127 if ( m_sPageText != sPageText )
128 {
129 Any aOldValue, aNewValue;
130 aOldValue <<= m_sPageText;
131 aNewValue <<= sPageText;
132 m_sPageText = sPageText;
133 NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
134 }
135 }
136
137
139 {
140 if ( IsEnabled() )
141 {
142 rStateSet |= AccessibleStateType::ENABLED;
143 rStateSet |= AccessibleStateType::SENSITIVE;
144 }
145
146 rStateSet |= AccessibleStateType::VISIBLE;
147
148 if ( IsShowing() )
149 rStateSet |= AccessibleStateType::SHOWING;
150
151 rStateSet |= AccessibleStateType::SELECTABLE;
152
153 if ( IsSelected() )
154 rStateSet |= AccessibleStateType::SELECTED;
155 }
156
157
158 // OCommonAccessibleComponent
159
160
162 {
163 awt::Rectangle aBounds;
164 if ( m_pTabBar )
165 {
166 // get bounding rectangle relative to the AccessibleTabBar
167 aBounds = AWTRectangle( m_pTabBar->GetPageRect( m_nPageId ) );
168
169 // get position of the AccessibleTabBarPageList relative to the AccessibleTabBar
171 if ( xParent.is() )
172 {
173 Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
174 if ( xParentComponent.is() )
175 {
176 awt::Point aParentLoc = xParentComponent->getLocation();
177
178 // calculate bounding rectangle relative to the AccessibleTabBarPageList
179 aBounds.X -= aParentLoc.X;
180 aBounds.Y -= aParentLoc.Y;
181 }
182 }
183 }
184
185 return aBounds;
186 }
187
188
189 // XComponent
190
191
193 {
195 m_sPageText.clear();
196 }
197
198
199 // XServiceInfo
200
201
203 {
204 return "com.sun.star.comp.svtools.AccessibleTabBarPage";
205 }
206
207
208 sal_Bool AccessibleTabBarPage::supportsService( const OUString& rServiceName )
209 {
210 return cppu::supportsService(this, rServiceName);
211 }
212
213
215 {
216 return { "com.sun.star.awt.AccessibleTabBarPage" };
217 }
218
219
220 // XAccessible
221
222
224 {
225 OExternalLockGuard aGuard( this );
226
227 return this;
228 }
229
230
231 // XAccessibleContext
232
233
235 {
236 return 0;
237 }
238
239
241 {
242 OExternalLockGuard aGuard( this );
243
244 throw IndexOutOfBoundsException();
245 }
246
247
249 {
250 OExternalLockGuard aGuard( this );
251
252 return m_xParent;
253 }
254
255
257 {
258 OExternalLockGuard aGuard( this );
259
260 sal_Int64 nIndexInParent = -1;
261 if ( m_pTabBar )
262 nIndexInParent = m_pTabBar->GetPagePos( m_nPageId );
263
264 return nIndexInParent;
265 }
266
267
269 {
270 return AccessibleRole::PAGE_TAB;
271 }
272
273
275 {
276 OExternalLockGuard aGuard( this );
277
278 OUString sDescription;
279 if ( m_pTabBar )
280 sDescription = m_pTabBar->GetHelpText( m_nPageId );
281
282 return sDescription;
283 }
284
285
287 {
288 OExternalLockGuard aGuard( this );
289
290 return m_sPageText;
291 }
292
293
295 {
296 OExternalLockGuard aGuard( this );
297
299 }
300
301
303 {
304 OExternalLockGuard aGuard( this );
305
306 sal_Int64 nStateSet = 0;
307
308 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
309 {
310 FillAccessibleStateSet( nStateSet );
311 }
312 else
313 {
314 nStateSet |= AccessibleStateType::DEFUNC;
315 }
316
317 return nStateSet;
318 }
319
320
322 {
323 OExternalLockGuard aGuard( this );
324
326 }
327
328
329 // XAccessibleComponent
330
331
333 {
335 }
336
337
339 {
340 // no focus
341 }
342
343
345 {
346 OExternalLockGuard aGuard( this );
347
348 sal_Int32 nColor = 0;
350 if ( xParent.is() )
351 {
352 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
353 if ( xParentComp.is() )
354 nColor = xParentComp->getForeground();
355 }
356
357 return nColor;
358 }
359
360
362 {
363 OExternalLockGuard aGuard( this );
364
365 sal_Int32 nColor = 0;
367 if ( xParent.is() )
368 {
369 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
370 if ( xParentComp.is() )
371 nColor = xParentComp->getBackground();
372 }
373
374 return nColor;
375 }
376
377
378 // XAccessibleExtendedComponent
379
380
382 {
383 OExternalLockGuard aGuard( this );
384
387 if ( xParent.is() )
388 {
389 Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
390 if ( xParentComp.is() )
391 xFont = xParentComp->getFont();
392 }
393
394 return xFont;
395 }
396
397
399 {
400 OExternalLockGuard aGuard( this );
401
402 return m_sPageText;
403 }
404
405
407 {
408 return OUString();
409 }
410
411
412} // namespace accessibility
413
414
415/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nPageId
const LanguageTag & GetLanguageTag() const
static const AllSettings & GetSettings()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
virtual void SAL_CALL disposing() override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual void SAL_CALL grabFocus() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual OUString SAL_CALL getTitledBorderText() override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
css::uno::Reference< css::accessibility::XAccessible > m_xParent
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getAccessibleDescription() override
void SetPageText(const OUString &sPageText)
AccessibleTabBarPage(TabBar *pTabBar, sal_uInt16 nPageId, const css::uno::Reference< css::accessibility::XAccessible > &rxParent)
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::lang::Locale SAL_CALL getLocale() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual css::awt::Rectangle implGetBounds() override
void FillAccessibleStateSet(sal_Int64 &rStateSet)
virtual OUString SAL_CALL getAccessibleName() override
virtual OUString SAL_CALL getToolTipText() override
virtual void SAL_CALL disposing() override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool