LibreOffice Module svx (master)  1
AccessibleFrameSelector.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 <com/sun/star/accessibility/AccessibleStateType.hpp>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
25 #include <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <svx/frmsel.hxx>
28 #include <svx/dialmgr.hxx>
29 
30 #include <frmsel.hrc>
31 
32 namespace svx::a11y {
33 
34 using ::com::sun::star::uno::Any;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::uno::RuntimeException;
38 
39 using namespace ::com::sun::star::accessibility;
40 
41 
43  : mpFrameSel(&rFrameSel)
44 {
45 }
46 
48 {
49 }
50 
52 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelector, OAccessibleComponentHelper, OAccessibleHelper_Base )
53 
54 Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
55 {
56  return this;
57 }
58 
60 {
61  SolarMutexGuard aGuard;
62  IsValid();
64 }
65 
66 Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
67 {
68  SolarMutexGuard aGuard;
69  IsValid();
70  Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
71  if( !xRet.is() )
72  throw RuntimeException();
73  return xRet;
74 }
75 
76 Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
77 {
78  SolarMutexGuard aGuard;
79  IsValid();
80  Reference< XAccessible > xRet = mpFrameSel->getAccessibleParent();
81  return xRet;
82 }
83 
85 {
86  return AccessibleRole::OPTION_PANE;
87 }
88 
90 {
91  SolarMutexGuard aGuard;
92  IsValid();
93  return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[0].first);
94 }
95 
97 {
98  SolarMutexGuard aGuard;
99  IsValid();
100  return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[0].first);
101 }
102 
103 Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
104 {
105  SolarMutexGuard aGuard;
106  IsValid();
108 }
109 
110 Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet( )
111 {
112  SolarMutexGuard aGuard;
114  Reference< XAccessibleStateSet > xRet = pStateSetHelper;
115 
116  if(!mpFrameSel)
117  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
118  else
119  {
120  const sal_Int16 aStandardStates[] =
121  {
122  AccessibleStateType::EDITABLE,
123  AccessibleStateType::FOCUSABLE,
124  AccessibleStateType::MULTI_SELECTABLE,
125  AccessibleStateType::SELECTABLE,
126  AccessibleStateType::SHOWING,
127  AccessibleStateType::VISIBLE,
128  AccessibleStateType::OPAQUE,
129  0};
130  sal_Int16 nState = 0;
131  while(aStandardStates[nState])
132  {
133  pStateSetHelper->AddState(aStandardStates[nState++]);
134  }
135  if(mpFrameSel->IsEnabled())
136  {
137  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
138  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
139  }
140 
141  if (mpFrameSel->HasFocus())
142  {
143  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
144  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
145  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
146  }
147  }
148  return xRet;
149 }
150 
151 Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
152  const css::awt::Point& aPt )
153 {
154  SolarMutexGuard aGuard;
155  IsValid();
156  //aPt is relative to the frame selector
157  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
158 }
159 
161 {
162  SolarMutexGuard aGuard;
163  IsValid();
165 }
166 
168 {
169  SolarMutexGuard aGuard;
170 
171  //see FrameSelector::Paint
173  return sal_Int32(rStyles.GetLabelTextColor());
174 }
175 
177 {
178  SolarMutexGuard aGuard;
179 
180  //see FrameSelector::Paint
182  return sal_Int32(rStyles.GetDialogColor());
183 }
184 
185 css::awt::Rectangle AccFrameSelector::implGetBounds()
186 {
187  SolarMutexGuard aGuard;
188  IsValid();
189 
190  css::awt::Rectangle aRet;
191 
192  const Point aOutPos;
193  Size aOutSize(mpFrameSel->GetOutputSizePixel());
194 
195  aRet.X = aOutPos.X();
196  aRet.Y = aOutPos.Y();
197  aRet.Width = aOutSize.Width();
198  aRet.Height = aOutSize.Height();
199 
200  return aRet;
201 }
202 
204 {
205  if(!mpFrameSel)
206  throw RuntimeException();
207 }
208 
210 {
211  mpFrameSel = nullptr;
212 }
213 
215  : mpFrameSel(&rFrameSel)
216  , meBorder(eBorder)
217 {
218 }
219 
221 {
222 }
223 
225 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelectorChild, OAccessibleComponentHelper, OAccessibleHelper_Base )
226 
227 Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
228 {
229  return this;
230 }
231 
233 {
234  SolarMutexGuard aGuard;
235  IsValid();
236  return 0;
237 }
238 
239 Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int32 )
240 {
241  throw RuntimeException();
242 }
243 
245 {
246  SolarMutexGuard aGuard;
247  IsValid();
248  Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
249  return xRet;
250 }
251 
253 {
254  return AccessibleRole::CHECK_BOX;
255 }
256 
258 {
259  SolarMutexGuard aGuard;
260  IsValid();
261  return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
262 }
263 
265 {
266  SolarMutexGuard aGuard;
267  IsValid();
268  return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
269 }
270 
271 Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
272 {
273  SolarMutexGuard aGuard;
274  IsValid();
275  Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
276  return xRet;
277 }
278 
279 Reference< XAccessibleStateSet > AccFrameSelectorChild::getAccessibleStateSet( )
280 {
281  SolarMutexGuard aGuard;
283  Reference< XAccessibleStateSet > xRet = pStateSetHelper;
284 
285  if(!mpFrameSel)
286  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
287  else
288  {
289  const sal_Int16 aStandardStates[] =
290  {
291  AccessibleStateType::EDITABLE,
292  AccessibleStateType::FOCUSABLE,
293  AccessibleStateType::MULTI_SELECTABLE,
294  AccessibleStateType::SELECTABLE,
295  AccessibleStateType::SHOWING,
296  AccessibleStateType::VISIBLE,
297  AccessibleStateType::OPAQUE,
298  0};
299  sal_Int16 nState = 0;
300  while(aStandardStates[nState])
301  {
302  pStateSetHelper->AddState(aStandardStates[nState++]);
303  }
304  if(mpFrameSel->IsEnabled())
305  {
306  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
307  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
308  }
309 
311  {
312  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
313  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
314  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
315  }
316  }
317  return xRet;
318 }
319 
321  const css::awt::Point& aPt )
322 {
323  SolarMutexGuard aGuard;
324  IsValid();
325  //aPt is relative to the frame selector
326  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
327 }
328 
330 {
331  SolarMutexGuard aGuard;
332  IsValid();
334  Point aPos = aSpot.TopLeft();
335  Size aSz = aSpot.GetSize();
336  css::awt::Rectangle aRet;
337  aRet.X = aPos.X();
338  aRet.Y = aPos.Y();
339  aRet.Width = aSz.Width();
340  aRet.Height = aSz.Height();
341  return aRet;
342 }
343 
345 {
346  SolarMutexGuard aGuard;
347  IsValid();
349 }
350 
352 {
353  SolarMutexGuard aGuard;
354 
355  //see FrameSelector::Paint
357  return sal_Int32(rStyles.GetLabelTextColor());
358 }
359 
361 {
362  SolarMutexGuard aGuard;
363 
364  //see FrameSelector::Paint
366  return sal_Int32(rStyles.GetDialogColor());
367 }
368 
370 {
371  if(!mpFrameSel)
372  throw RuntimeException();
373 }
374 
376 {
377  mpFrameSel = nullptr;
378 }
379 
380 }
381 
382 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int32 SAL_CALL getBackground() override
Point TopLeft() const
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
long Width() const
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
virtual sal_Int16 SAL_CALL getAccessibleRole() override
const Color & GetDialogColor() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
tools::Rectangle GetClickBoundRect(FrameBorderType eBorder) const
Returns the bounding rectangle of the specified frame border (if enabled).
Definition: frmsel.cxx:1052
long Height() const
virtual OUString SAL_CALL getAccessibleName() override
virtual OUString SAL_CALL getAccessibleDescription() override
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
virtual OUString SAL_CALL getAccessibleDescription() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
const Color & GetLabelTextColor() const
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Size const & GetOutputSizePixel() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual sal_Int32 SAL_CALL getBackground() override
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
a11yrelationset get_accessible_relation_set() const
Definition: frmsel.hxx:160
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: frmsel.cxx:1017
AccFrameSelectorChild(FrameSelector &rFrameSel, FrameBorderType eBorder)
FrameBorderType
Enumerates all borders a frame selection control can contain.
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual void SAL_CALL grabFocus() override
AccFrameSelector(FrameSelector &rFrameSel)
Size GetSize() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
bool IsBorderSelected(FrameBorderType eBorder) const
Returns true, if the specified frame border is selected.
Definition: frmsel.cxx:962
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: frmsel.hxx:158
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
sal_Int32 GetEnabledBorderCount() const
Returns the number of enabled frame borders.
Definition: frmsel.cxx:852
virtual sal_Int32 SAL_CALL getForeground() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getAccessibleName() override
rtl::Reference< a11y::AccFrameSelectorChild > GetChildAccessible(FrameBorderType eBorder)
Returns the accessibility child object of the specified frame border (if enabled).
Definition: frmsel.cxx:1024
void AddState(sal_Int16 aState)
sal_Int32 nState
const char first[]