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>
35 #include <AccObject.hxx>
36 #include <AccEventListener.hxx>
39 #pragma clang diagnostic push
40 #pragma clang diagnostic ignored "-Wextra-tokens"
41 // "#endif !_MIDL_USE_GUIDDEF_" in midl-generated code
43 #include <UAccCOM_i.c>
45 #pragma clang diagnostic pop
49 using namespace com::sun::star::uno
;
50 using namespace com::sun::star::accessibility
;
51 using namespace com::sun::star::accessibility::AccessibleRole
;
52 using namespace com::sun::star::accessibility::AccessibleStateType
;
54 //Role mapping table,left side is UNO role, right side is MSAA role
55 const short ROLE_TABLE
[][2] =
57 {UNKNOWN
, IA2_ROLE_UNKNOWN
},
58 {ALERT
, ROLE_SYSTEM_DIALOG
},
59 {COLUMN_HEADER
, ROLE_SYSTEM_COLUMNHEADER
},
60 //{CANVAS , ROLE_SYSTEM_CLIENT},
61 {CANVAS
, IA2_ROLE_CANVAS
},
62 {CHECK_BOX
, ROLE_SYSTEM_CHECKBUTTON
},
63 {CHECK_MENU_ITEM
, IA2_ROLE_CHECK_MENU_ITEM
},
64 {COLOR_CHOOSER
, IA2_ROLE_COLOR_CHOOSER
},
65 {COMBO_BOX
, ROLE_SYSTEM_COMBOBOX
},
66 {DATE_EDITOR
, IA2_ROLE_DATE_EDITOR
},
67 {DESKTOP_ICON
, IA2_ROLE_DESKTOP_ICON
},
68 {DESKTOP_PANE
, IA2_ROLE_DESKTOP_PANE
},
69 {DIRECTORY_PANE
, IA2_ROLE_DIRECTORY_PANE
},
70 {DIALOG
, ROLE_SYSTEM_DIALOG
},
71 {DOCUMENT
, ROLE_SYSTEM_DOCUMENT
},
72 {EMBEDDED_OBJECT
, IA2_ROLE_EMBEDDED_OBJECT
},
73 {END_NOTE
, IA2_ROLE_ENDNOTE
},
74 {FILE_CHOOSER
, IA2_ROLE_FILE_CHOOSER
},
75 {FILLER
, ROLE_SYSTEM_WHITESPACE
},
76 {FONT_CHOOSER
, IA2_ROLE_FONT_CHOOSER
},
77 {FOOTER
, IA2_ROLE_FOOTER
},
78 {FOOTNOTE
, IA2_ROLE_FOOTNOTE
},
79 //{FRAME, IA2_ROLE_FRAME},
80 {FRAME
, ROLE_SYSTEM_DIALOG
},
81 {GLASS_PANE
, IA2_ROLE_GLASS_PANE
},
82 {GRAPHIC
, ROLE_SYSTEM_GRAPHIC
},
83 {GROUP_BOX
, ROLE_SYSTEM_GROUPING
},
84 {HEADER
, IA2_ROLE_HEADER
},
85 {HEADING
, IA2_ROLE_HEADING
},
86 {HYPER_LINK
, ROLE_SYSTEM_TEXT
},
87 {ICON
, IA2_ROLE_ICON
},
88 {INTERNAL_FRAME
, IA2_ROLE_INTERNAL_FRAME
},
89 {LABEL
, ROLE_SYSTEM_STATICTEXT
},
90 {LAYERED_PANE
, IA2_ROLE_LAYERED_PANE
},
91 {LIST
, ROLE_SYSTEM_LIST
},
92 {LIST_ITEM
, ROLE_SYSTEM_LISTITEM
},
93 //{MENU , ROLE_SYSTEM_MENUPOPUP},
94 {MENU
, ROLE_SYSTEM_MENUITEM
},
95 {MENU_BAR
, ROLE_SYSTEM_MENUBAR
},
96 {MENU_ITEM
, ROLE_SYSTEM_MENUITEM
},
97 {OPTION_PANE
, IA2_ROLE_OPTION_PANE
},
98 {PAGE_TAB
, ROLE_SYSTEM_PAGETAB
},
99 {PAGE_TAB_LIST
, ROLE_SYSTEM_PAGETABLIST
},
100 {PANEL
, IA2_ROLE_OPTION_PANE
},
101 {PARAGRAPH
, IA2_ROLE_PARAGRAPH
},
102 {PASSWORD_TEXT
, ROLE_SYSTEM_TEXT
},
103 {POPUP_MENU
, ROLE_SYSTEM_MENUPOPUP
},
104 {PUSH_BUTTON
, ROLE_SYSTEM_PUSHBUTTON
},
105 {PROGRESS_BAR
, ROLE_SYSTEM_PROGRESSBAR
},
106 {RADIO_BUTTON
, ROLE_SYSTEM_RADIOBUTTON
},
107 {RADIO_MENU_ITEM
, IA2_ROLE_RADIO_MENU_ITEM
},
108 {ROW_HEADER
, ROLE_SYSTEM_ROWHEADER
},
109 {ROOT_PANE
, IA2_ROLE_ROOT_PANE
},
110 {SCROLL_BAR
, ROLE_SYSTEM_SCROLLBAR
},
111 {SCROLL_PANE
, IA2_ROLE_SCROLL_PANE
},
112 {SHAPE
, IA2_ROLE_SHAPE
},
113 {SEPARATOR
, ROLE_SYSTEM_SEPARATOR
},
114 {SLIDER
, ROLE_SYSTEM_SLIDER
},
115 {SPIN_BOX
, ROLE_SYSTEM_SPINBUTTON
},
116 {SPLIT_PANE
, IA2_ROLE_SPLIT_PANE
},
117 {STATUS_BAR
, ROLE_SYSTEM_STATUSBAR
},
118 {TABLE
, ROLE_SYSTEM_TABLE
},
119 {TABLE_CELL
, ROLE_SYSTEM_CELL
},
120 {TEXT
, ROLE_SYSTEM_TEXT
},
121 {TEXT_FRAME
, IA2_ROLE_TEXT_FRAME
},
122 //for change toggle button to push button for jaws
123 {TOGGLE_BUTTON
, ROLE_SYSTEM_PUSHBUTTON
},
125 {TOOL_BAR
, ROLE_SYSTEM_TOOLBAR
},
126 {TOOL_TIP
, ROLE_SYSTEM_TOOLTIP
},
127 {TREE
, ROLE_SYSTEM_OUTLINE
},
128 {VIEW_PORT
, IA2_ROLE_VIEW_PORT
},
129 {WINDOW
, ROLE_SYSTEM_WINDOW
},
130 {BUTTON_DROPDOWN
, ROLE_SYSTEM_BUTTONDROPDOWN
},
131 {BUTTON_MENU
, ROLE_SYSTEM_BUTTONMENU
},
132 {CAPTION
, IA2_ROLE_CAPTION
},
133 {CHART
, IA2_ROLE_SHAPE
},
134 {EDIT_BAR
, IA2_ROLE_EDITBAR
},
135 {FORM
, IA2_ROLE_FORM
},
136 {IMAGE_MAP
, IA2_ROLE_IMAGE_MAP
},
137 {NOTE
, IA2_ROLE_NOTE
},
138 {PAGE
, IA2_ROLE_PAGE
},
139 {RULER
, IA2_ROLE_RULER
},
140 {SECTION
, IA2_ROLE_SECTION
},
141 {TREE_ITEM
, ROLE_SYSTEM_OUTLINEITEM
},
142 {TREE_TABLE
, ROLE_SYSTEM_OUTLINE
},
143 {COMMENT
, IA2_ROLE_TEXT_FRAME
},
144 {COMMENT_END
, IA2_ROLE_TEXT_FRAME
},
145 {DOCUMENT_PRESENTATION
, ROLE_SYSTEM_DOCUMENT
},
146 {DOCUMENT_SPREADSHEET
, ROLE_SYSTEM_DOCUMENT
},
147 {DOCUMENT_TEXT
, ROLE_SYSTEM_DOCUMENT
},
148 {STATIC
, IA2_ROLE_TEXT_FRAME
}
154 * @param pXAcc Uno XAccessible interface of control.
155 * @param Agent The agent kept in all listeners,it's the sole interface by which
156 * listener communicate with windows manager.
157 * @param listener listener that registers in UNO system.
160 AccObject::AccObject(XAccessible
* pAcc
, AccObjectManagerAgent
* pAgent
,
161 AccEventListener
* pListener
) :
163 m_pParantID (nullptr),
164 m_bShouldDestroy(false),
166 m_pParentObj(nullptr),
167 m_pListener (pListener
),
170 ImplInitializeCreateObj();
172 m_xAccContextRef
= m_xAccRef
->getAccessibleContext();
173 m_xAccActionRef
.set(m_xAccContextRef
,UNO_QUERY
);
174 m_accRole
= m_xAccContextRef
-> getAccessibleRole();
177 m_pIMAcc
->SetXAccessible(reinterpret_cast<hyper
>(m_xAccRef
.get()));
178 m_pIMAcc
->Put_XAccAgent(reinterpret_cast<hyper
>(pAgent
));
179 m_pIMAcc
->SetDefaultAction(reinterpret_cast<hyper
>(m_xAccActionRef
.get()));
187 AccObject::~AccObject()
191 m_xAccActionRef
= nullptr;
192 m_xAccContextRef
= nullptr;
197 * Insert a child element.
198 * @param pChild Child element that should be inserted into child list.
199 * @param pos Insert position.
202 void AccObject::InsertChild( AccObject
* pChild
,short pos
)
205 std::vector
<AccObject
*>::iterator iter
;
206 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
207 if(iter
!=m_childrenList
.end())
211 m_childrenList
.push_back(pChild
);
215 iter
=m_childrenList
.begin()+pos
;
216 m_childrenList
.insert(iter
,pChild
);
219 pChild
->SetParentObj(this);
223 * Delete a child element
224 * @param pChild Child element that should be inserted into child list.
225 * @param pos Insert position.
228 void AccObject::DeleteChild( AccObject
* pChild
)
230 std::vector
<AccObject
*>::iterator iter
;
231 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
232 if(iter
!=m_childrenList
.end())
234 m_childrenList
.erase(iter
);
236 pChild
->SetParentObj(nullptr);
241 * In order to windows API WindowFromAccessibleObject, we sometimes to set a pure
242 * top window accessible object created by windows system as top ancestor.
246 void AccObject::UpdateValidWindow()
249 m_pIMAcc
->Put_XAccWindowHandle(m_pParantID
);
253 * Translate all UNO basic information into MSAA com information.
255 * @return If the method is correctly processed.
257 void AccObject::ImplInitializeCreateObj()
259 m_pIMAcc
= UAccCOMCreateInstance();
265 * Update name property to com object.
269 void AccObject::UpdateName( )
276 if( ( TEXT_FRAME
== m_accRole
) && ( m_pParentObj
!=nullptr )&& ( SCROLL_PANE
== m_pParentObj
-> m_accRole
) )
277 m_pIMAcc
->Put_XAccName( o3tl::toW(m_pParentObj
->m_xAccContextRef
->getAccessibleName().getStr()) );
278 //IAccessibility2 Implementation 2009-----
279 if ( PARAGRAPH
== m_accRole
)
281 m_pIMAcc
->Put_XAccName(L
"");
283 //-----IAccessibility2 Implementation 2009
285 m_pIMAcc
->Put_XAccName(o3tl::toW(m_xAccContextRef
->getAccessibleName().getStr()));
290 * Update description property to com object.
291 * no content for update description
295 void AccObject::UpdateDescription()
302 m_pIMAcc
->Put_XAccDescription(o3tl::toW(m_xAccContextRef
->getAccessibleDescription().getStr()));
307 * Update default action property to com object.
311 void AccObject::UpdateAction()
313 m_xAccActionRef
.set(m_xAccContextRef
,UNO_QUERY
);
315 if( m_xAccActionRef
.is() && m_pIMAcc
)
317 if( m_xAccActionRef
->getAccessibleActionCount() > 0 )
319 UpdateDefaultAction( );
320 m_pIMAcc
->SetDefaultAction(
321 reinterpret_cast<hyper
>(m_xAccActionRef
.get()));
327 * Update value property to com object.
331 void AccObject::UpdateValue()
333 if( nullptr == m_pIMAcc
|| !m_xAccContextRef
.is() )
339 Reference
< XAccessibleValue
> pRValue(m_xAccContextRef
,UNO_QUERY
);
343 pAny
= pRValue
->getCurrentValue();
350 * Set special default action description string via UNO role.
351 * @param Role UNO role
354 void AccObject::UpdateDefaultAction( )
356 if(!m_xAccActionRef
.is())
365 case RADIO_MENU_ITEM
:
366 case CHECK_MENU_ITEM
:
370 case BUTTON_DROPDOWN
:
371 m_pIMAcc
->Put_ActionDescription( o3tl::toW(m_xAccActionRef
->getAccessibleActionDescription(sal_Int32(0)).getStr()) );
377 * Set value property via pAny.
378 * @param pAny New value.
381 void AccObject::SetValue( Any pAny
)
383 if( nullptr == m_pIMAcc
|| !m_xAccContextRef
.is() )
388 Reference
< XAccessibleText
> pRText(m_xAccContextRef
,UNO_QUERY
);
393 // 3. date editor's msaa value should be the same as spinbox
402 val
= pRText
->getText();
404 m_pIMAcc
->Put_XAccValue( o3tl::toW(val
.getStr()) );
407 //case CHECK_BOX: //Commented by Li Xing to disable the value for general checkbox
411 m_pIMAcc
->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
413 // Added by Li Xing, only the checkbox in tree should have the value.
415 if( ( m_pParentObj
!=nullptr ) && (TREE
== m_pParentObj
->m_accRole
|| TREE_ITEM
== m_pParentObj
->m_accRole
))
416 m_pIMAcc
->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
425 OUString
AccObject::GetMAccessibleValueFromAny(Any pAny
)
429 if(nullptr == m_pIMAcc
)
432 if(pAny
.getValueType() == cppu::UnoType
<cppu::UnoUnsignedShortType
>::get() )
437 strValue
=OUString::number(val
);
441 else if(pAny
.getValueType() == cppu::UnoType
<OUString
>::get())
447 else if(pAny
.getValueType() == cppu::UnoType
<Sequence
< OUString
>>::get())
449 Sequence
< OUString
> val
;
453 int count
= val
.getLength();
455 for( int iIndex
= 0;iIndex
< count
;iIndex
++ )
457 strValue
+= val
[iIndex
];
462 else if(pAny
.getValueType() == cppu::UnoType
<double>::get())
467 strValue
=OUString::number(val
);
470 else if(pAny
.getValueType() == cppu::UnoType
<sal_Int32
>::get())
475 strValue
=OUString::number(val
);
478 else if (pAny
.getValueType() == cppu::UnoType
<css::accessibility::TextSegment
>::get())
480 css::accessibility::TextSegment val
;
483 OUString
realVal(val
.SegmentText
);
492 * Set name property via pAny.
493 * @param pAny New accessible name.
496 void AccObject::SetName( Any pAny
)
498 if( nullptr == m_pIMAcc
)
501 m_pIMAcc
->Put_XAccName( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
506 * Set description property via pAny.
507 * @param pAny New accessible description.
510 void AccObject::SetDescription( Any pAny
)
512 if( nullptr == m_pIMAcc
)
514 m_pIMAcc
->Put_XAccDescription( o3tl::toW(GetMAccessibleValueFromAny(pAny
).getStr()) );
518 * Set role property via pAny
519 * @param Role New accessible role.
522 void AccObject::SetRole( short Role
)
524 if( nullptr == m_pIMAcc
)
526 m_pIMAcc
->Put_XAccRole( Role
);
530 * Get role property via pAny
532 * @return accessible role
534 short AccObject::GetRole() const
540 * Get MSAA state from UNO state
541 * @Role xState UNO state.
544 DWORD
AccObject::GetMSAAStateFromUNO(short xState
)
546 DWORD IState
= UNO_MSAA_UNMAPPING
;
548 if( !m_xAccContextRef
.is() )
553 short Role
= m_accRole
;
558 IState
= STATE_SYSTEM_BUSY
;
561 if( Role
== PUSH_BUTTON
|| Role
== TOGGLE_BUTTON
)
563 IState
= STATE_SYSTEM_PRESSED
;
566 IState
= STATE_SYSTEM_CHECKED
;
569 IState
= STATE_SYSTEM_UNAVAILABLE
;
572 IState
= STATE_SYSTEM_EXPANDED
;
575 IState
= STATE_SYSTEM_FOCUSABLE
;
578 IState
= STATE_SYSTEM_FOCUSED
;
581 IState
= STATE_SYSTEM_MIXED
;
583 case MULTI_SELECTABLE
:
584 IState
= STATE_SYSTEM_MULTISELECTABLE
;
587 IState
= STATE_SYSTEM_PRESSED
;
590 IState
= STATE_SYSTEM_SIZEABLE
;
593 if( m_accRole
== MENU
|| m_accRole
== MENU_ITEM
)
595 IState
= UNO_MSAA_UNMAPPING
;
599 IState
= STATE_SYSTEM_SELECTABLE
;
603 if( m_accRole
== MENU
|| m_accRole
== MENU_ITEM
)
605 IState
= UNO_MSAA_UNMAPPING
;
609 IState
= STATE_SYSTEM_SELECTED
;
613 IState
= STATE_SYSTEM_FOCUSED
;
617 sal_Bool isExpanded
= true;
618 sal_Bool isExpandable
= true;
619 if( Role
== PUSH_BUTTON
|| Role
== TOGGLE_BUTTON
|| BUTTON_DROPDOWN
== Role
)
621 IState
= STATE_SYSTEM_HASPOPUP
;
625 GetExpandedState(&isExpandable
,&isExpanded
);
627 IState
= STATE_SYSTEM_COLLAPSED
;
631 //Remove the SENSITIVE state mapping. There is no corresponding MSAA state.
633 // IState = STATE_SYSTEM_PROTECTED;
637 m_pIMAcc
->DecreaseState( STATE_SYSTEM_READONLY
);
641 IState
= STATE_SYSTEM_OFFSCREEN
;
644 IState
= STATE_SYSTEM_MOVEABLE
;
647 IState
= STATE_SYSTEM_COLLAPSED
;
650 IState
= STATE_SYSTEM_DEFAULT
;
660 * Decrease state of com object
661 * @param xState The lost state.
664 void AccObject::DecreaseState( short xState
)
666 if( nullptr == m_pIMAcc
)
671 if( xState
== FOCUSABLE
)
673 short Role
= m_accRole
;
675 || Role
== RADIO_MENU_ITEM
676 || Role
== CHECK_MENU_ITEM
)
680 if (Role
== TOGGLE_BUTTON
|| Role
== PUSH_BUTTON
|| BUTTON_DROPDOWN
== Role
)
682 if( ( m_pParentObj
!=nullptr ) && (TOOL_BAR
== m_pParentObj
->m_accRole
) )
688 else if( xState
== AccessibleStateType::VISIBLE
)
690 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
692 else if( xState
== AccessibleStateType::SHOWING
)
694 m_pIMAcc
->IncreaseState( STATE_SYSTEM_OFFSCREEN
);
697 DWORD msState
= GetMSAAStateFromUNO(xState
);
698 if(msState
!=UNO_MSAA_UNMAPPING
)
699 m_pIMAcc
->DecreaseState(msState
);
703 * Increase state of com object
704 * @param xState The new state.
707 void AccObject::IncreaseState( short xState
)
709 if( nullptr == m_pIMAcc
)
716 if( xState
== AccessibleStateType::VISIBLE
)
718 m_pIMAcc
->DecreaseState( STATE_SYSTEM_INVISIBLE
);
720 else if( xState
== AccessibleStateType::SHOWING
)
722 m_pIMAcc
->DecreaseState( STATE_SYSTEM_OFFSCREEN
);
726 DWORD msState
= GetMSAAStateFromUNO(xState
);
727 if(msState
!=UNO_MSAA_UNMAPPING
)
728 m_pIMAcc
->IncreaseState( msState
);
732 * Get next child element
734 * @return AccObject Object interface.
736 AccObject
* AccObject::NextChild()
738 IAccChildList::iterator pInd
= m_childrenList
.begin();
739 if( pInd
!= m_childrenList
.end() )
744 * update action description desc
748 void AccObject::UpdateActionDesc()
755 OUString pXString
= m_xAccContextRef
->getAccessibleDescription();
756 m_pIMAcc
->Put_XAccDescription(o3tl::toW(pXString
.getStr()));
757 long Role
= m_accRole
;
759 if( Role
== PUSH_BUTTON
|| Role
== RADIO_BUTTON
|| Role
== MENU_ITEM
||
760 Role
== LIST_ITEM
|| Role
== CHECK_BOX
|| Role
== TREE_ITEM
||
761 Role
== CHECK_MENU_ITEM
|| Role
== RADIO_MENU_ITEM
)
763 UpdateDefaultAction( );
768 if( m_xAccActionRef
.is() )
770 if( m_xAccActionRef
->getAccessibleActionCount() > 0 )
772 if (!(Role
== SPIN_BOX
|| Role
== COMBO_BOX
|| Role
== DATE_EDITOR
||
773 Role
== EDIT_BAR
|| Role
== PASSWORD_TEXT
|| Role
== TEXT
))
775 pXString
= m_xAccActionRef
->getAccessibleActionDescription( 0 );
776 //Solution: if string length is more than zero, action is set.
777 if( pXString
.getLength() > 0)
778 m_pIMAcc
->Put_ActionDescription( o3tl::toW(pXString
.getStr()) );
786 * update role information from uno to com
790 void AccObject::UpdateRole()
797 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
798 m_pIMAcc
->Put_XAccRole( ROLE_SYSTEM_WINDOW
);
799 sal_Int16 iRoleIndex
= pContext
->getAccessibleRole();
800 if ((0 <= iRoleIndex
) && (sal_uInt16(iRoleIndex
) < SAL_N_ELEMENTS(ROLE_TABLE
)))
802 short iIA2Role
= ROLE_TABLE
[iRoleIndex
][1] ;
803 m_pIMAcc
->Put_XAccRole( iIA2Role
);
808 * update state information from uno to com
812 void AccObject::UpdateState()
819 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
820 Reference
< XAccessibleStateSet
> pRState
= pContext
->getAccessibleStateSet();
827 m_pIMAcc
->SetState(0);
829 if ( m_accRole
== POPUP_MENU
)
834 Sequence
<short> pStates
= pRState
->getStates();
835 int count
= pStates
.getLength();
837 bool isEnable
= false;
838 bool isShowing
= false;
839 bool isEditable
= false;
840 bool isVisible
= false;
841 bool isFocusable
= false;
843 for( int iIndex
= 0;iIndex
< count
;iIndex
++ )
845 if( pStates
[iIndex
] == ENABLED
)
847 else if( pStates
[iIndex
] == SHOWING
)
849 else if( pStates
[iIndex
] == VISIBLE
)
851 else if( pStates
[iIndex
] == EDITABLE
)
853 else if (pStates
[iIndex
] == FOCUSABLE
)
855 IncreaseState( pStates
[iIndex
]);
857 bool bIsMenuItem
= m_accRole
== MENU_ITEM
|| m_accRole
== RADIO_MENU_ITEM
|| m_accRole
== CHECK_MENU_ITEM
;
861 if(!(isShowing
&& isVisible
) )
863 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
864 m_pIMAcc
->DecreaseState( STATE_SYSTEM_FOCUSABLE
);
869 if(!(isShowing
|| isVisible
) )
870 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
873 short Role
= m_accRole
;
879 m_pIMAcc
->IncreaseState( STATE_SYSTEM_READONLY
);
882 // 2. editable combobox -> readonly ------ bridge
883 case EMBEDDED_OBJECT
:
904 m_pIMAcc
->IncreaseState( STATE_SYSTEM_READONLY
);
914 if(!(Role
== FILLER
|| Role
== END_NOTE
|| Role
== FOOTER
|| Role
== FOOTNOTE
|| Role
== GROUP_BOX
|| Role
== RULER
915 || Role
== HEADER
|| Role
== ICON
|| Role
== INTERNAL_FRAME
|| Role
== LABEL
|| Role
== LAYERED_PANE
916 || Role
== SCROLL_BAR
|| Role
== SCROLL_PANE
|| Role
== SPLIT_PANE
|| Role
== STATIC
|| Role
== STATUS_BAR
917 || Role
== TOOL_TIP
))
919 if( SEPARATOR
== Role
)
921 if( ( m_pParentObj
!= nullptr ) && ( MENU
== m_pParentObj
->m_accRole
|| POPUP_MENU
== m_pParentObj
->m_accRole
))
922 IncreaseState( FOCUSABLE
);
925 else if (TABLE_CELL
== Role
|| TABLE
== Role
|| PANEL
== Role
|| OPTION_PANE
== Role
||
926 COLUMN_HEADER
== Role
)
929 IncreaseState( FOCUSABLE
);
935 if ( isShowing
&& isVisible
)
937 IncreaseState( FOCUSABLE
);
942 IncreaseState( FOCUSABLE
);
949 m_pIMAcc
->IncreaseState( STATE_SYSTEM_UNAVAILABLE
);
950 if( !((Role
== MENU_ITEM
) ||
951 (Role
== RADIO_MENU_ITEM
) ||
952 (Role
== CHECK_MENU_ITEM
)) )
954 if ( Role
== TOGGLE_BUTTON
|| Role
== PUSH_BUTTON
|| BUTTON_DROPDOWN
== Role
)
956 if(( m_pParentObj
!= nullptr )&& (TOOL_BAR
== m_pParentObj
->m_accRole
) )
957 IncreaseState( FOCUSABLE
);
959 DecreaseState( FOCUSABLE
);
962 DecreaseState( FOCUSABLE
);
964 else if( isShowing
|| isVisible
)
966 IncreaseState( FOCUSABLE
);
974 if( pContext
->getAccessibleChildCount() > 0 )
975 m_pIMAcc
->IncreaseState( STATE_SYSTEM_HASPOPUP
);
978 m_pIMAcc
->IncreaseState( STATE_SYSTEM_PROTECTED
);
986 * update location information from uno to com
990 void AccObject::UpdateLocation()
996 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
998 Reference
< XAccessibleComponent
> pRComponent(pContext
,UNO_QUERY
);
999 if( pRComponent
.is() )
1001 css::awt::Point pCPoint
= pRComponent
->getLocationOnScreen();
1002 css::awt::Size pCSize
= pRComponent
->getSize();
1003 Location tempLocation
;
1004 tempLocation
.m_dLeft
= pCPoint
.X
;
1005 tempLocation
.m_dTop
= pCPoint
.Y
;
1006 tempLocation
.m_dWidth
= pCSize
.Width
;
1007 tempLocation
.m_dHeight
= pCSize
.Height
;
1008 m_pIMAcc
->Put_XAccLocation( tempLocation
);
1015 * Public method to mapping information between MSAA and UNO.
1017 * @return If the method is correctly processed.
1019 bool AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
1021 if( nullptr == m_pIMAcc
|| !m_xAccContextRef
.is() )
1043 * Add a child selected element.
1044 * @param pAccObj Child object pointer.
1047 void AccObject::AddSelect( long index
, AccObject
* accObj
)
1049 m_selectionList
.emplace(index
,accObj
);
1052 IAccSelectionList
& AccObject::GetSelection()
1054 return m_selectionList
;
1059 * Set self to focus object in parent child list
1063 void AccObject::setFocus()
1067 IncreaseState(FOCUSED
);
1068 m_pIMAcc
->Put_XAccFocus(CHILDID_SELF
);
1075 * Unset self from focus object in parent child list.
1079 void AccObject::unsetFocus()
1083 DecreaseState( FOCUSED
);
1084 m_pIMAcc
->Put_XAccFocus(UACC_NO_FOCUS
);
1088 void AccObject::GetExpandedState( sal_Bool
* isExpandable
, sal_Bool
* isExpanded
)
1090 *isExpanded
= false;
1091 *isExpandable
= false;
1093 if( !m_xAccContextRef
.is() )
1097 Reference
< XAccessibleStateSet
> pRState
= m_xAccContextRef
->getAccessibleStateSet();
1103 Sequence
<short> pStates
= pRState
->getStates();
1104 int count
= pStates
.getLength();
1106 for( int iIndex
= 0;iIndex
< count
;iIndex
++ )
1108 if( EXPANDED
== pStates
[iIndex
] )
1112 else if( EXPANDABLE
== pStates
[iIndex
] )
1114 *isExpandable
= true;
1119 void AccObject::NotifyDestroy(bool ifDelete
)
1121 m_bShouldDestroy
=ifDelete
;
1123 m_pIMAcc
->NotifyDestroy(m_bShouldDestroy
);
1126 void AccObject::SetParentObj(AccObject
* pParentAccObj
)
1128 m_pParentObj
= pParentAccObj
;
1134 m_pIMAcc
->Put_XAccParent(m_pParentObj
->GetIMAccessible());
1138 m_pIMAcc
->Put_XAccParent(nullptr);
1142 //ResID means ChildID in MSAA
1143 void AccObject::SetResID(long id
)
1147 m_pIMAcc
->Put_XAccChildID(m_resID
);
1149 //return COM interface in acc object
1150 IMAccessible
* AccObject::GetIMAccessible()
1155 Reference
<XAccessible
> const& AccObject::GetXAccessible()
1160 void AccObject::SetParentHWND(HWND hWnd
)
1165 void AccObject::SetListener(rtl::Reference
<AccEventListener
> const& pListener
)
1167 m_pListener
= pListener
;
1170 AccEventListener
* AccObject::getListener()
1172 return m_pListener
.get();
1175 long AccObject::GetResID()
1180 HWND
AccObject::GetParentHWND()
1185 AccObject
* AccObject::GetParentObj()
1187 return m_pParentObj
;
1189 bool AccObject::ifShouldDestroy()
1191 return m_bShouldDestroy
;
1194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */