1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/uno/Sequence.h>
21 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleText.hpp>
27 #include <o3tl/char16_t2wchar_t.hxx>
28 #include <o3tl/safeint.hxx>
29 #include <sal/log.hxx>
37 #include <AccObject.hxx>
38 #include <AccEventListener.hxx>
41 #pragma clang diagnostic push
42 #pragma clang diagnostic ignored "-Wextra-tokens"
43 // "#endif !_MIDL_USE_GUIDDEF_" in midl-generated code
45 #include <UAccCOM_i.c>
47 #pragma clang diagnostic pop
50 using namespace com::sun::star::uno
;
51 using namespace com::sun::star::accessibility
;
53 constexpr DWORD MSAA_NO_STATE
= 0x00000000;
58 * Map a UNO accessible role to an IAccessible2 role.
59 * @param nUnoRole The UNO role (css::accessibility::AccessibleRole).
60 * @return IAccessible2 role.
62 short lcl_mapToIAccessible2Role(sal_Int16 nUnoRole
)
66 case css::accessibility::AccessibleRole::UNKNOWN
:
67 return IA2_ROLE_UNKNOWN
;
68 case css::accessibility::AccessibleRole::ALERT
:
69 return ROLE_SYSTEM_DIALOG
;
70 case css::accessibility::AccessibleRole::BLOCK_QUOTE
:
71 return IA2_ROLE_BLOCK_QUOTE
;
72 case css::accessibility::AccessibleRole::COLUMN_HEADER
:
73 return ROLE_SYSTEM_COLUMNHEADER
;
74 case css::accessibility::AccessibleRole::CANVAS
:
75 return IA2_ROLE_CANVAS
;
76 case css::accessibility::AccessibleRole::CHECK_BOX
:
77 return ROLE_SYSTEM_CHECKBUTTON
;
78 case css::accessibility::AccessibleRole::CHECK_MENU_ITEM
:
79 return IA2_ROLE_CHECK_MENU_ITEM
;
80 case css::accessibility::AccessibleRole::COLOR_CHOOSER
:
81 return IA2_ROLE_COLOR_CHOOSER
;
82 case css::accessibility::AccessibleRole::COMBO_BOX
:
83 return ROLE_SYSTEM_COMBOBOX
;
84 case css::accessibility::AccessibleRole::DATE_EDITOR
:
85 return IA2_ROLE_DATE_EDITOR
;
86 case css::accessibility::AccessibleRole::DESKTOP_ICON
:
87 return IA2_ROLE_DESKTOP_ICON
;
88 case css::accessibility::AccessibleRole::DESKTOP_PANE
:
89 return IA2_ROLE_DESKTOP_PANE
;
90 case css::accessibility::AccessibleRole::DIRECTORY_PANE
:
91 return IA2_ROLE_DIRECTORY_PANE
;
92 case css::accessibility::AccessibleRole::DIALOG
:
93 return ROLE_SYSTEM_DIALOG
;
94 case css::accessibility::AccessibleRole::DOCUMENT
:
95 return ROLE_SYSTEM_DOCUMENT
;
96 case css::accessibility::AccessibleRole::EMBEDDED_OBJECT
:
97 return IA2_ROLE_EMBEDDED_OBJECT
;
98 case css::accessibility::AccessibleRole::END_NOTE
:
99 return IA2_ROLE_ENDNOTE
;
100 case css::accessibility::AccessibleRole::FILE_CHOOSER
:
101 return IA2_ROLE_FILE_CHOOSER
;
102 case css::accessibility::AccessibleRole::FILLER
:
103 return ROLE_SYSTEM_WHITESPACE
;
104 case css::accessibility::AccessibleRole::FONT_CHOOSER
:
105 return IA2_ROLE_FONT_CHOOSER
;
106 case css::accessibility::AccessibleRole::FOOTER
:
107 return IA2_ROLE_FOOTER
;
108 case css::accessibility::AccessibleRole::FOOTNOTE
:
109 return IA2_ROLE_FOOTNOTE
;
110 case css::accessibility::AccessibleRole::FRAME
:
111 return IA2_ROLE_FRAME
;
112 case css::accessibility::AccessibleRole::GLASS_PANE
:
113 return IA2_ROLE_GLASS_PANE
;
114 case css::accessibility::AccessibleRole::GRAPHIC
:
115 return ROLE_SYSTEM_GRAPHIC
;
116 case css::accessibility::AccessibleRole::GROUP_BOX
:
117 return ROLE_SYSTEM_GROUPING
;
118 case css::accessibility::AccessibleRole::HEADER
:
119 return IA2_ROLE_HEADER
;
120 case css::accessibility::AccessibleRole::HEADING
:
121 return IA2_ROLE_HEADING
;
122 case css::accessibility::AccessibleRole::HYPER_LINK
:
123 return ROLE_SYSTEM_TEXT
;
124 case css::accessibility::AccessibleRole::ICON
:
125 return IA2_ROLE_ICON
;
126 case css::accessibility::AccessibleRole::INTERNAL_FRAME
:
127 return IA2_ROLE_INTERNAL_FRAME
;
128 case css::accessibility::AccessibleRole::LABEL
:
129 return ROLE_SYSTEM_STATICTEXT
;
130 case css::accessibility::AccessibleRole::LAYERED_PANE
:
131 return IA2_ROLE_LAYERED_PANE
;
132 case css::accessibility::AccessibleRole::LIST
:
133 return ROLE_SYSTEM_LIST
;
134 case css::accessibility::AccessibleRole::LIST_ITEM
:
135 return ROLE_SYSTEM_LISTITEM
;
136 case css::accessibility::AccessibleRole::MENU
:
137 return ROLE_SYSTEM_MENUITEM
;
138 case css::accessibility::AccessibleRole::MENU_BAR
:
139 return ROLE_SYSTEM_MENUBAR
;
140 case css::accessibility::AccessibleRole::MENU_ITEM
:
141 return ROLE_SYSTEM_MENUITEM
;
142 case css::accessibility::AccessibleRole::OPTION_PANE
:
143 return IA2_ROLE_OPTION_PANE
;
144 case css::accessibility::AccessibleRole::PAGE_TAB
:
145 return ROLE_SYSTEM_PAGETAB
;
146 case css::accessibility::AccessibleRole::PAGE_TAB_LIST
:
147 return ROLE_SYSTEM_PAGETABLIST
;
148 case css::accessibility::AccessibleRole::PANEL
:
149 return IA2_ROLE_OPTION_PANE
;
150 case css::accessibility::AccessibleRole::PARAGRAPH
:
151 return IA2_ROLE_PARAGRAPH
;
152 case css::accessibility::AccessibleRole::PASSWORD_TEXT
:
153 return ROLE_SYSTEM_TEXT
;
154 case css::accessibility::AccessibleRole::POPUP_MENU
:
155 return ROLE_SYSTEM_MENUPOPUP
;
156 case css::accessibility::AccessibleRole::PUSH_BUTTON
:
157 return ROLE_SYSTEM_PUSHBUTTON
;
158 case css::accessibility::AccessibleRole::PROGRESS_BAR
:
159 return ROLE_SYSTEM_PROGRESSBAR
;
160 case css::accessibility::AccessibleRole::RADIO_BUTTON
:
161 return ROLE_SYSTEM_RADIOBUTTON
;
162 case css::accessibility::AccessibleRole::RADIO_MENU_ITEM
:
163 return IA2_ROLE_RADIO_MENU_ITEM
;
164 case css::accessibility::AccessibleRole::ROW_HEADER
:
165 return ROLE_SYSTEM_ROWHEADER
;
166 case css::accessibility::AccessibleRole::ROOT_PANE
:
167 return IA2_ROLE_ROOT_PANE
;
168 case css::accessibility::AccessibleRole::SCROLL_BAR
:
169 return ROLE_SYSTEM_SCROLLBAR
;
170 case css::accessibility::AccessibleRole::SCROLL_PANE
:
171 return IA2_ROLE_SCROLL_PANE
;
172 case css::accessibility::AccessibleRole::SHAPE
:
173 return IA2_ROLE_SHAPE
;
174 case css::accessibility::AccessibleRole::SEPARATOR
:
175 return ROLE_SYSTEM_SEPARATOR
;
176 case css::accessibility::AccessibleRole::SLIDER
:
177 return ROLE_SYSTEM_SLIDER
;
178 case css::accessibility::AccessibleRole::SPIN_BOX
:
179 return ROLE_SYSTEM_SPINBUTTON
;
180 case css::accessibility::AccessibleRole::SPLIT_PANE
:
181 return IA2_ROLE_SPLIT_PANE
;
182 case css::accessibility::AccessibleRole::STATUS_BAR
:
183 return ROLE_SYSTEM_STATUSBAR
;
184 case css::accessibility::AccessibleRole::TABLE
:
185 return ROLE_SYSTEM_TABLE
;
186 case css::accessibility::AccessibleRole::TABLE_CELL
:
187 return ROLE_SYSTEM_CELL
;
188 case css::accessibility::AccessibleRole::TEXT
:
189 return ROLE_SYSTEM_TEXT
;
190 case css::accessibility::AccessibleRole::TEXT_FRAME
:
191 return IA2_ROLE_TEXT_FRAME
;
192 case css::accessibility::AccessibleRole::TOGGLE_BUTTON
:
193 return ROLE_SYSTEM_PUSHBUTTON
;
194 case css::accessibility::AccessibleRole::TOOL_BAR
:
195 return ROLE_SYSTEM_TOOLBAR
;
196 case css::accessibility::AccessibleRole::TOOL_TIP
:
197 return ROLE_SYSTEM_TOOLTIP
;
198 case css::accessibility::AccessibleRole::TREE
:
199 return ROLE_SYSTEM_OUTLINE
;
200 case css::accessibility::AccessibleRole::VIEW_PORT
:
201 return IA2_ROLE_VIEW_PORT
;
202 case css::accessibility::AccessibleRole::WINDOW
:
203 return ROLE_SYSTEM_WINDOW
;
204 case css::accessibility::AccessibleRole::BUTTON_DROPDOWN
:
205 return ROLE_SYSTEM_BUTTONDROPDOWN
;
206 case css::accessibility::AccessibleRole::BUTTON_MENU
:
207 return ROLE_SYSTEM_BUTTONMENU
;
208 case css::accessibility::AccessibleRole::CAPTION
:
209 return IA2_ROLE_CAPTION
;
210 case css::accessibility::AccessibleRole::CHART
:
211 return IA2_ROLE_SHAPE
;
212 case css::accessibility::AccessibleRole::EDIT_BAR
:
213 return IA2_ROLE_EDITBAR
;
214 case css::accessibility::AccessibleRole::FORM
:
215 return IA2_ROLE_FORM
;
216 case css::accessibility::AccessibleRole::IMAGE_MAP
:
217 return IA2_ROLE_IMAGE_MAP
;
218 case css::accessibility::AccessibleRole::NOTE
:
219 return IA2_ROLE_NOTE
;
220 case css::accessibility::AccessibleRole::PAGE
:
221 return IA2_ROLE_PAGE
;
222 case css::accessibility::AccessibleRole::RULER
:
223 return IA2_ROLE_RULER
;
224 case css::accessibility::AccessibleRole::SECTION
:
225 return IA2_ROLE_SECTION
;
226 case css::accessibility::AccessibleRole::TREE_ITEM
:
227 return ROLE_SYSTEM_OUTLINEITEM
;
228 case css::accessibility::AccessibleRole::TREE_TABLE
:
229 return ROLE_SYSTEM_OUTLINE
;
230 case css::accessibility::AccessibleRole::COMMENT
:
231 return IA2_ROLE_TEXT_FRAME
;
232 case css::accessibility::AccessibleRole::COMMENT_END
:
233 return IA2_ROLE_TEXT_FRAME
;
234 case css::accessibility::AccessibleRole::DOCUMENT_PRESENTATION
:
235 return ROLE_SYSTEM_DOCUMENT
;
236 case css::accessibility::AccessibleRole::DOCUMENT_SPREADSHEET
:
237 return ROLE_SYSTEM_DOCUMENT
;
238 case css::accessibility::AccessibleRole::DOCUMENT_TEXT
:
239 return ROLE_SYSTEM_DOCUMENT
;
240 case css::accessibility::AccessibleRole::STATIC
:
241 return ROLE_SYSTEM_STATICTEXT
;
242 case css::accessibility::AccessibleRole::NOTIFICATION
:
243 return ROLE_SYSTEM_ALERT
;
245 SAL_WARN("iacc2", "Unmapped role: " << nUnoRole
);
246 return IA2_ROLE_UNKNOWN
;
254 * @param pXAcc Uno XAccessible interface of control.
255 * @param pManager The accessible object manager kept in all listeners.
256 * @param listener listener that registers in UNO system.
259 AccObject::AccObject(XAccessible
* pAcc
, AccObjectWinManager
* pManager
) :
261 m_pParantID (nullptr),
262 m_pIMAcc (UAccCOMCreateInstance()),
263 m_pParentObj(nullptr),
264 m_pListener (nullptr),
269 m_xAccContextRef
= m_xAccRef
->getAccessibleContext();
270 m_accRole
= m_xAccContextRef
-> getAccessibleRole();
272 m_pIMAcc
->SetXAccessible(reinterpret_cast<hyper
>(m_xAccRef
.get()));
273 m_pIMAcc
->Put_XAccObjectManager(reinterpret_cast<hyper
>(pManager
));
280 AccObject::~AccObject()
283 m_xAccContextRef
= nullptr;
288 * Insert a child element.
289 * @param pChild Child element that should be inserted into child list.
292 void AccObject::InsertChild(AccObject
* pChild
)
294 std::vector
<AccObject
*>::iterator iter
;
295 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
296 if(iter
!=m_childrenList
.end())
299 m_childrenList
.push_back(pChild
);
301 pChild
->SetParentObj(this);
305 * Delete a child element
306 * @param pChild Child element that should be inserted into child list.
307 * @param pos Insert position.
310 void AccObject::DeleteChild( AccObject
* pChild
)
312 std::vector
<AccObject
*>::iterator iter
;
313 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
314 if(iter
!=m_childrenList
.end())
316 m_childrenList
.erase(iter
);
317 pChild
->SetParentObj(nullptr);
322 * In order to windows API WindowFromAccessibleObject, we sometimes to set a pure
323 * top window accessible object created by windows system as top ancestor.
327 void AccObject::UpdateValidWindow() { m_pIMAcc
->Put_XAccWindowHandle(m_pParantID
); }
330 * Update value property to com object.
334 void AccObject::UpdateValue()
336 if (!m_xAccContextRef
.is())
342 Reference
< XAccessibleValue
> pRValue(m_xAccContextRef
,UNO_QUERY
);
346 pAny
= pRValue
->getCurrentValue();
353 * Set value property via pAny.
354 * @param pAny New value.
357 void AccObject::SetValue( Any pAny
)
359 if (!m_xAccContextRef
.is())
364 Reference
< XAccessibleText
> pRText(m_xAccContextRef
,UNO_QUERY
);
368 case AccessibleRole::SPIN_BOX
:
369 // 3. date editor's msaa value should be the same as spinbox
370 case AccessibleRole::DATE_EDITOR
:
371 case AccessibleRole::TEXT
:
372 case AccessibleRole::BLOCK_QUOTE
:
373 case AccessibleRole::PARAGRAPH
:
374 case AccessibleRole::HEADING
:
375 case AccessibleRole::TABLE_CELL
:
379 val
= pRText
->getText();
381 m_pIMAcc
->Put_XAccValue( o3tl::toW(val
.getStr()) );
383 case AccessibleRole::TREE_ITEM
:
384 //case CHECK_BOX: //Commented by Li Xing to disable the value for general checkbox
385 case AccessibleRole::COMBO_BOX
:
386 case AccessibleRole::NOTE
:
387 case AccessibleRole::SCROLL_BAR
:
388 m_pIMAcc
->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
390 // Added by Li Xing, only the checkbox in tree should have the value.
391 case AccessibleRole::CHECK_BOX
:
392 if( ( m_pParentObj
!=nullptr ) && (AccessibleRole::TREE
== m_pParentObj
->m_accRole
|| AccessibleRole::TREE_ITEM
== m_pParentObj
->m_accRole
))
393 m_pIMAcc
->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
402 OUString
AccObject::GetMAccessibleValueFromAny(Any pAny
)
406 if(pAny
.getValueType() == cppu::UnoType
<cppu::UnoUnsignedShortType
>::get() )
411 strValue
=OUString::number(val
);
415 else if(pAny
.getValueType() == cppu::UnoType
<OUString
>::get())
421 else if(pAny
.getValueType() == cppu::UnoType
<Sequence
< OUString
>>::get())
423 Sequence
< OUString
> val
;
426 for (const OUString
& rElem
: val
)
430 else if(pAny
.getValueType() == cppu::UnoType
<double>::get())
435 strValue
=OUString::number(val
);
438 else if(pAny
.getValueType() == cppu::UnoType
<sal_Int32
>::get())
443 strValue
=OUString::number(val
);
446 else if (pAny
.getValueType() == cppu::UnoType
<css::accessibility::TextSegment
>::get())
448 css::accessibility::TextSegment val
;
451 OUString
realVal(val
.SegmentText
);
461 * Get role property via pAny
463 * @return accessible role
465 short AccObject::GetRole() const
471 * Get MSAA state from UNO state
472 * @Role nState UNO state.
475 DWORD
AccObject::GetMSAAStateFromUNO(sal_Int64 nState
)
477 if( !m_xAccContextRef
.is() )
480 return MSAA_NO_STATE
;
485 case AccessibleStateType::BUSY
:
486 return STATE_SYSTEM_BUSY
;
487 case AccessibleStateType::CHECKED
:
488 if (m_accRole
== AccessibleRole::PUSH_BUTTON
|| m_accRole
== AccessibleRole::TOGGLE_BUTTON
)
489 return STATE_SYSTEM_PRESSED
;
490 return STATE_SYSTEM_CHECKED
;
491 case AccessibleStateType::DEFUNC
:
492 return STATE_SYSTEM_UNAVAILABLE
;
493 case AccessibleStateType::EXPANDED
:
494 return STATE_SYSTEM_EXPANDED
;
495 case AccessibleStateType::FOCUSABLE
:
496 return STATE_SYSTEM_FOCUSABLE
;
497 case AccessibleStateType::FOCUSED
:
498 return STATE_SYSTEM_FOCUSED
;
499 case AccessibleStateType::INDETERMINATE
:
500 return STATE_SYSTEM_MIXED
;
501 case AccessibleStateType::MULTI_SELECTABLE
:
502 return STATE_SYSTEM_MULTISELECTABLE
;
503 case AccessibleStateType::PRESSED
:
504 return STATE_SYSTEM_PRESSED
;
505 case AccessibleStateType::RESIZABLE
:
506 return STATE_SYSTEM_SIZEABLE
;
507 case AccessibleStateType::SELECTABLE
:
508 if (m_accRole
== AccessibleRole::MENU
|| m_accRole
== AccessibleRole::MENU_ITEM
)
509 return MSAA_NO_STATE
;
510 return STATE_SYSTEM_SELECTABLE
;
511 case AccessibleStateType::SELECTED
:
512 if (m_accRole
== AccessibleRole::MENU
|| m_accRole
== AccessibleRole::MENU_ITEM
)
513 return MSAA_NO_STATE
;
514 return STATE_SYSTEM_SELECTED
;
515 case AccessibleStateType::ARMED
:
516 return STATE_SYSTEM_FOCUSED
;
517 case AccessibleStateType::EXPANDABLE
:
519 if (m_accRole
== AccessibleRole::PUSH_BUTTON
520 || m_accRole
== AccessibleRole::TOGGLE_BUTTON
521 || m_accRole
== AccessibleRole::BUTTON_DROPDOWN
)
522 return STATE_SYSTEM_HASPOPUP
;
524 if (!(m_xAccContextRef
->getAccessibleStateSet() & AccessibleStateType::EXPANDED
))
525 return STATE_SYSTEM_COLLAPSED
;
527 return MSAA_NO_STATE
;
529 //Remove the SENSITIVE state mapping. There is no corresponding MSAA state.
531 // IState = STATE_SYSTEM_PROTECTED;
532 case AccessibleStateType::EDITABLE
:
533 m_pIMAcc
->DecreaseState(STATE_SYSTEM_READONLY
);
534 return MSAA_NO_STATE
;
535 case AccessibleStateType::OFFSCREEN
:
536 return STATE_SYSTEM_OFFSCREEN
;
537 case AccessibleStateType::MOVEABLE
:
538 return STATE_SYSTEM_MOVEABLE
;
539 case AccessibleStateType::COLLAPSE
:
540 return STATE_SYSTEM_COLLAPSED
;
542 case AccessibleStateType::DEFAULT
:
543 return STATE_SYSTEM_DEFAULT
;
545 return MSAA_NO_STATE
;
550 * Decrease state of com object
551 * @param xState The lost state.
554 void AccObject::DecreaseState( sal_Int64 xState
)
556 if (xState
== AccessibleStateType::FOCUSABLE
)
558 if (m_accRole
== AccessibleRole::MENU_ITEM
|| m_accRole
== AccessibleRole::RADIO_MENU_ITEM
559 || m_accRole
== AccessibleRole::CHECK_MENU_ITEM
)
563 if (m_accRole
== AccessibleRole::TOGGLE_BUTTON
564 || m_accRole
== AccessibleRole::PUSH_BUTTON
565 || m_accRole
== AccessibleRole::BUTTON_DROPDOWN
)
567 if ((m_pParentObj
!= nullptr)
568 && (AccessibleRole::TOOL_BAR
== m_pParentObj
->m_accRole
))
574 else if( xState
== AccessibleStateType::VISIBLE
)
576 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
578 else if( xState
== AccessibleStateType::SHOWING
)
580 m_pIMAcc
->IncreaseState( STATE_SYSTEM_OFFSCREEN
);
583 DWORD msState
= GetMSAAStateFromUNO(xState
);
584 if (msState
!= MSAA_NO_STATE
)
585 m_pIMAcc
->DecreaseState(msState
);
589 * Increase state of com object
590 * @param xState The new state.
593 void AccObject::IncreaseState( sal_Int64 xState
)
595 if( xState
== AccessibleStateType::VISIBLE
)
597 m_pIMAcc
->DecreaseState( STATE_SYSTEM_INVISIBLE
);
599 else if( xState
== AccessibleStateType::SHOWING
)
601 m_pIMAcc
->DecreaseState( STATE_SYSTEM_OFFSCREEN
);
605 DWORD msState
= GetMSAAStateFromUNO(xState
);
606 if (msState
!= MSAA_NO_STATE
)
607 m_pIMAcc
->IncreaseState( msState
);
611 * Get next child element
613 * @return AccObject Object interface.
615 AccObject
* AccObject::NextChild()
617 IAccChildList::iterator pInd
= m_childrenList
.begin();
618 if( pInd
!= m_childrenList
.end() )
624 * update role information from uno to com
628 void AccObject::UpdateRole()
630 const sal_Int16 nUnoRole
= m_xAccContextRef
->getAccessibleRole();
631 short nIA2Role
= lcl_mapToIAccessible2Role(nUnoRole
);
632 m_pIMAcc
->Put_XAccRole(nIA2Role
);
636 * update state information from uno to com
640 void AccObject::UpdateState()
642 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
643 sal_Int64 nRState
= pContext
->getAccessibleStateSet();
645 m_pIMAcc
->SetState(0);
647 if (m_accRole
== AccessibleRole::POPUP_MENU
)
652 bool isEnable
= false;
653 bool isShowing
= false;
654 bool isEditable
= false;
655 bool isVisible
= false;
657 for (int i
=0; i
<63; ++i
)
659 sal_Int64 nState
= sal_Int64(1) << i
;
660 if (!(nState
& nRState
))
662 if (nState
== AccessibleStateType::ENABLED
)
664 else if (nState
== AccessibleStateType::SHOWING
)
666 else if (nState
== AccessibleStateType::VISIBLE
)
668 else if (nState
== AccessibleStateType::EDITABLE
)
670 IncreaseState(nState
);
673 bool bIsMenuItem
= m_accRole
== AccessibleRole::MENU_ITEM
674 || m_accRole
== AccessibleRole::RADIO_MENU_ITEM
675 || m_accRole
== AccessibleRole::CHECK_MENU_ITEM
;
679 if(!(isShowing
&& isVisible
) )
681 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
686 if(!(isShowing
|| isVisible
) )
687 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
692 case AccessibleRole::LABEL
:
693 case AccessibleRole::STATIC
:
694 case AccessibleRole::NOTIFICATION
:
695 case AccessibleRole::TEXT
:
696 // 2. editable combobox -> readonly ------ bridge
697 case AccessibleRole::EMBEDDED_OBJECT
:
698 case AccessibleRole::END_NOTE
:
699 case AccessibleRole::FOOTER
:
700 case AccessibleRole::FOOTNOTE
:
701 case AccessibleRole::GRAPHIC
:
702 case AccessibleRole::HEADER
:
703 case AccessibleRole::HEADING
:
706 case AccessibleRole::BLOCK_QUOTE
:
707 case AccessibleRole::PARAGRAPH
:
708 case AccessibleRole::PASSWORD_TEXT
:
709 case AccessibleRole::SHAPE
:
710 case AccessibleRole::SPIN_BOX
:
711 case AccessibleRole::TABLE
:
712 case AccessibleRole::TABLE_CELL
:
713 case AccessibleRole::TEXT_FRAME
:
714 case AccessibleRole::DATE_EDITOR
:
715 case AccessibleRole::DOCUMENT
:
716 case AccessibleRole::COLUMN_HEADER
:
719 m_pIMAcc
->IncreaseState( STATE_SYSTEM_READONLY
);
727 m_pIMAcc
->IncreaseState( STATE_SYSTEM_UNAVAILABLE
);
731 case AccessibleRole::POPUP_MENU
:
732 case AccessibleRole::MENU
:
733 if( pContext
->getAccessibleChildCount() > 0 )
734 m_pIMAcc
->IncreaseState( STATE_SYSTEM_HASPOPUP
);
736 case AccessibleRole::PASSWORD_TEXT
:
737 m_pIMAcc
->IncreaseState( STATE_SYSTEM_PROTECTED
);
745 * Public method to mapping information between MSAA and UNO.
747 * @return If the method is correctly processed.
749 bool AccObject::UpdateAccessibleInfoFromUnoToMSAA()
751 if (!m_xAccContextRef
.is())
768 * Set self to focus object in parent child list
772 void AccObject::setFocus()
774 IncreaseState(AccessibleStateType::FOCUSED
);
775 m_pIMAcc
->Put_XAccFocus(CHILDID_SELF
);
781 * Unset self from focus object in parent child list.
785 void AccObject::unsetFocus()
787 DecreaseState(AccessibleStateType::FOCUSED
);
788 m_pIMAcc
->Put_XAccFocus(UACC_NO_FOCUS
);
791 void AccObject::NotifyDestroy() { m_pIMAcc
->NotifyDestroy(); }
793 void AccObject::SetParentObj(AccObject
* pParentAccObj
)
795 m_pParentObj
= pParentAccObj
;
798 m_pIMAcc
->Put_XAccParent(m_pParentObj
->GetIMAccessible());
800 m_pIMAcc
->Put_XAccParent(nullptr);
802 //ResID means ChildID in MSAA
803 void AccObject::SetResID(long id
)
806 m_pIMAcc
->Put_XAccChildID(m_resID
);
808 //return COM interface in acc object
809 IMAccessible
* AccObject::GetIMAccessible()
814 Reference
<XAccessible
> const& AccObject::GetXAccessible()
819 void AccObject::SetParentHWND(HWND hWnd
)
824 rtl::Reference
<AccEventListener
> AccObject::SetListener(rtl::Reference
<AccEventListener
> const& pListener
)
826 rtl::Reference
<AccEventListener
> pRet(m_pListener
);
827 m_pListener
= pListener
;
831 long AccObject::GetResID()
836 HWND
AccObject::GetParentHWND()
841 AccObject
* AccObject::GetParentObj()
846 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */