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>
33 #include "AccObject.hxx"
34 #include "AccEventListener.hxx"
35 #include "UAccCOM_i.c"
36 #include "AccResource.hxx"
40 using namespace com::sun::star::uno
;
41 using namespace com::sun::star::accessibility
;
42 using namespace com::sun::star::accessibility::AccessibleRole
;
43 using namespace com::sun::star::accessibility::AccessibleStateType
;
45 //Role mapping table,left side is UNO role, right side is MSAA role
46 const short ROLE_TABLE
[][2] =
48 {UNKNOWN
, IA2_ROLE_UNKNOWN
},
49 {ALERT
, ROLE_SYSTEM_DIALOG
},
50 {COLUMN_HEADER
, ROLE_SYSTEM_COLUMNHEADER
},
51 //{CANVAS , ROLE_SYSTEM_CLIENT},
52 {CANVAS
, IA2_ROLE_CANVAS
},
53 {CHECK_BOX
, ROLE_SYSTEM_CHECKBUTTON
},
54 {CHECK_MENU_ITEM
, IA2_ROLE_CHECK_MENU_ITEM
},
55 {COLOR_CHOOSER
, IA2_ROLE_COLOR_CHOOSER
},
56 {COMBO_BOX
, ROLE_SYSTEM_COMBOBOX
},
57 {DATE_EDITOR
, IA2_ROLE_DATE_EDITOR
},
58 {DESKTOP_ICON
, IA2_ROLE_DESKTOP_ICON
},
59 {DESKTOP_PANE
, IA2_ROLE_DESKTOP_PANE
},
60 {DIRECTORY_PANE
, IA2_ROLE_DIRECTORY_PANE
},
61 {DIALOG
, ROLE_SYSTEM_DIALOG
},
62 {DOCUMENT
, ROLE_SYSTEM_DOCUMENT
},
63 {EMBEDDED_OBJECT
, IA2_ROLE_EMBEDDED_OBJECT
},
64 {END_NOTE
, IA2_ROLE_ENDNOTE
},
65 {FILE_CHOOSER
, IA2_ROLE_FILE_CHOOSER
},
66 {FILLER
, ROLE_SYSTEM_WHITESPACE
},
67 {FONT_CHOOSER
, IA2_ROLE_FONT_CHOOSER
},
68 {FOOTER
, IA2_ROLE_FOOTER
},
69 {FOOTNOTE
, IA2_ROLE_FOOTNOTE
},
70 //{FRAME, IA2_ROLE_FRAME},
71 {FRAME
, ROLE_SYSTEM_DIALOG
},
72 {GLASS_PANE
, IA2_ROLE_GLASS_PANE
},
73 {GRAPHIC
, ROLE_SYSTEM_GRAPHIC
},
74 {GROUP_BOX
, ROLE_SYSTEM_GROUPING
},
75 {HEADER
, IA2_ROLE_HEADER
},
76 {HEADING
, IA2_ROLE_HEADING
},
77 {HYPER_LINK
, ROLE_SYSTEM_TEXT
},
78 {ICON
, IA2_ROLE_ICON
},
79 {INTERNAL_FRAME
, IA2_ROLE_INTERNAL_FRAME
},
80 {LABEL
, ROLE_SYSTEM_STATICTEXT
},
81 {LAYERED_PANE
, IA2_ROLE_LAYERED_PANE
},
82 {LIST
, ROLE_SYSTEM_LIST
},
83 {LIST_ITEM
, ROLE_SYSTEM_LISTITEM
},
84 //{MENU , ROLE_SYSTEM_MENUPOPUP},
85 {MENU
, ROLE_SYSTEM_MENUITEM
},
86 {MENU_BAR
, ROLE_SYSTEM_MENUBAR
},
87 {MENU_ITEM
, ROLE_SYSTEM_MENUITEM
},
88 {OPTION_PANE
, IA2_ROLE_OPTION_PANE
},
89 {PAGE_TAB
, ROLE_SYSTEM_PAGETAB
},
90 {PAGE_TAB_LIST
, ROLE_SYSTEM_PAGETABLIST
},
91 {PANEL
, IA2_ROLE_OPTION_PANE
},
92 {PARAGRAPH
, IA2_ROLE_PARAGRAPH
},
93 {PASSWORD_TEXT
, ROLE_SYSTEM_TEXT
},
94 {POPUP_MENU
, ROLE_SYSTEM_MENUPOPUP
},
95 {PUSH_BUTTON
, ROLE_SYSTEM_PUSHBUTTON
},
96 {PROGRESS_BAR
, ROLE_SYSTEM_PROGRESSBAR
},
97 {RADIO_BUTTON
, ROLE_SYSTEM_RADIOBUTTON
},
98 {RADIO_MENU_ITEM
, IA2_ROLE_RADIO_MENU_ITEM
},
99 {ROW_HEADER
, ROLE_SYSTEM_ROWHEADER
},
100 {ROOT_PANE
, IA2_ROLE_ROOT_PANE
},
101 {SCROLL_BAR
, ROLE_SYSTEM_SCROLLBAR
},
102 {SCROLL_PANE
, IA2_ROLE_SCROLL_PANE
},
103 {SHAPE
, IA2_ROLE_SHAPE
},
104 {SEPARATOR
, ROLE_SYSTEM_SEPARATOR
},
105 {SLIDER
, ROLE_SYSTEM_SLIDER
},
106 {SPIN_BOX
, ROLE_SYSTEM_SPINBUTTON
},
107 {SPLIT_PANE
, IA2_ROLE_SPLIT_PANE
},
108 {STATUS_BAR
, ROLE_SYSTEM_STATUSBAR
},
109 {TABLE
, ROLE_SYSTEM_TABLE
},
110 {TABLE_CELL
, ROLE_SYSTEM_CELL
},
111 {TEXT
, ROLE_SYSTEM_TEXT
},
112 {TEXT_FRAME
, IA2_ROLE_TEXT_FRAME
},
113 //for change toggle button to push button for jaws
114 {TOGGLE_BUTTON
, ROLE_SYSTEM_PUSHBUTTON
},
116 {TOOL_BAR
, ROLE_SYSTEM_TOOLBAR
},
117 {TOOL_TIP
, ROLE_SYSTEM_TOOLTIP
},
118 {TREE
, ROLE_SYSTEM_OUTLINE
},
119 {VIEW_PORT
, IA2_ROLE_VIEW_PORT
},
120 {WINDOW
, ROLE_SYSTEM_WINDOW
},
121 {BUTTON_DROPDOWN
, ROLE_SYSTEM_BUTTONDROPDOWN
},
122 {BUTTON_MENU
, ROLE_SYSTEM_BUTTONMENU
},
123 {CAPTION
, IA2_ROLE_CAPTION
},
124 {CHART
, IA2_ROLE_SHAPE
},
125 {EDIT_BAR
, IA2_ROLE_EDITBAR
},
126 {FORM
, IA2_ROLE_FORM
},
127 {IMAGE_MAP
, IA2_ROLE_IMAGE_MAP
},
128 {NOTE
, IA2_ROLE_NOTE
},
129 {PAGE
, IA2_ROLE_PAGE
},
130 {RULER
, IA2_ROLE_RULER
},
131 {SECTION
, IA2_ROLE_SECTION
},
132 {TREE_ITEM
, ROLE_SYSTEM_OUTLINEITEM
},
133 {TREE_TABLE
, ROLE_SYSTEM_OUTLINE
},
134 {COMMENT
, IA2_ROLE_TEXT_FRAME
},
135 {COMMENT_END
, IA2_ROLE_TEXT_FRAME
},
136 {DOCUMENT_PRESENTATION
, ROLE_SYSTEM_DOCUMENT
},
137 {DOCUMENT_SPREADSHEET
, ROLE_SYSTEM_DOCUMENT
},
138 {DOCUMENT_TEXT
, ROLE_SYSTEM_DOCUMENT
}
144 * @param pXAcc Uno XAccessible interface of control.
145 * @param Agent The agent kept in all listeners,it's the sole interface by which
146 * listener communicate with windows manager.
147 * @param listener listener that registers in UNO system.
150 AccObject::AccObject(XAccessible
* pAcc
, AccObjectManagerAgent
* pAgent
,
151 AccEventListener
* pListener
) :
156 m_pListener (pListener
),
157 m_bShouldDestroy(sal_False
),
160 ImplInitializeCreateObj();
162 m_xAccContextRef
= m_xAccRef
->getAccessibleContext();
163 m_xAccActionRef
= Reference
< XAccessibleAction
> (m_xAccContextRef
,UNO_QUERY
);
164 m_accRole
= m_xAccContextRef
-> getAccessibleRole();
167 m_pIMAcc
->SetXAccessible(reinterpret_cast<hyper
>(m_xAccRef
.get()));
168 m_pIMAcc
->Put_XAccAgent(reinterpret_cast<hyper
>(pAgent
));
169 m_pIMAcc
->SetDefaultAction(reinterpret_cast<hyper
>(m_xAccActionRef
.get()));
177 AccObject::~AccObject()
181 m_xAccActionRef
= NULL
;
182 m_xAccContextRef
= NULL
;
188 * Insert a child element.
189 * @param pChild Child element that should be inserted into child list.
190 * @param pos Insert position.
193 void AccObject::InsertChild( AccObject
* pChild
,short pos
)
196 std::vector
<AccObject
*>::iterator iter
;
197 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
198 if(iter
!=m_childrenList
.end())
202 m_childrenList
.push_back(pChild
);
206 std::vector
<AccObject
*>::iterator iter
=m_childrenList
.begin()+pos
;
207 m_childrenList
.insert(iter
,pChild
);
210 pChild
->SetParentObj(this);
214 * Delete a child element
215 * @param pChild Child element that should be inserted into child list.
216 * @param pos Insert position.
219 void AccObject::DeleteChild( AccObject
* pChild
)
221 std::vector
<AccObject
*>::iterator iter
;
222 iter
= std::find(m_childrenList
.begin(),m_childrenList
.end(),pChild
);
223 if(iter
!=m_childrenList
.end())
225 m_childrenList
.erase(iter
);
227 pChild
->SetParentObj(NULL
);
232 * In order to windows API WindowFromAccessibleObject,we sometimes to set a pure
233 * top window accessible object created by windows system as top ancestor.
237 void AccObject::UpdateValidWindow()
240 m_pIMAcc
->Put_XAccWindowHandle(m_pParantID
);
244 * Translate all UNO basic information into MSAA com information.
246 * @return If the method is correctly processed.
248 void AccObject::ImplInitializeCreateObj()
250 m_pIMAcc
= UAccCOMCreateInstance();
256 * Update name property to com object.
260 void AccObject::UpdateName( )
267 if( ( TEXT_FRAME
== m_accRole
) && ( m_pParentObj
!=NULL
)&& ( SCROLL_PANE
== m_pParentObj
-> m_accRole
) )
268 m_pIMAcc
->Put_XAccName( m_pParentObj
->m_xAccContextRef
->getAccessibleName().getStr() );
269 //IAccessibility2 Implementation 2009-----
270 if ( PARAGRAPH
== m_accRole
)
272 ::rtl::OUString
emptyStr("");
273 m_pIMAcc
->Put_XAccName(emptyStr
.getStr());
275 //-----IAccessibility2 Implementation 2009
277 m_pIMAcc
->Put_XAccName(m_xAccContextRef
->getAccessibleName().getStr());
282 * Update description property to com object.
283 * no content for update description
287 void AccObject::UpdateDescription()
294 m_pIMAcc
->Put_XAccDescription(m_xAccContextRef
->getAccessibleDescription().getStr());
299 * Update default action property to com object.
303 void AccObject::UpdateAction()
305 m_xAccActionRef
= Reference
< XAccessibleAction
> (m_xAccContextRef
,UNO_QUERY
);
307 if( m_xAccActionRef
.is() && m_pIMAcc
)
309 if( m_xAccActionRef
->getAccessibleActionCount() > 0 )
311 UpdateDefaultAction( );
312 m_pIMAcc
->SetDefaultAction(
313 reinterpret_cast<hyper
>(m_xAccActionRef
.get()));
319 * Update value property to com object.
323 void AccObject::UpdateValue()
325 if( NULL
== m_pIMAcc
|| !m_xAccContextRef
.is() )
331 Reference
< XAccessibleValue
> pRValue(m_xAccContextRef
.get(),UNO_QUERY
);
335 pAny
= pRValue
->getCurrentValue();
342 * Set special default action description string via UNO role.
343 * @param Role UNO role
346 void AccObject::UpdateDefaultAction( )
348 if(!m_xAccActionRef
.is())
357 case RADIO_MENU_ITEM
:
358 case CHECK_MENU_ITEM
:
362 case BUTTON_DROPDOWN
:
363 m_pIMAcc
->Put_ActionDescription( m_xAccActionRef
->getAccessibleActionDescription((sal_Int32
)0).getStr() );
369 * Set value property via pAny.
370 * @param pAny New value.
373 void AccObject::SetValue( Any pAny
)
375 unsigned short pUNumberString
[100];
376 memset( pUNumberString
, 0 , sizeof( pUNumberString
) );
378 if( NULL
== m_pIMAcc
|| !m_xAccContextRef
.is() )
383 Reference
< XAccessibleText
> pRText(m_xAccContextRef
,UNO_QUERY
);
388 // 3. date editor's msaa value should be the same as spinbox
397 val
= pRText
->getText();
399 m_pIMAcc
->Put_XAccValue( val
.getStr() );
402 //case CHECK_BOX: //Commented by Li Xing to disable the value for general checkbox
406 m_pIMAcc
->Put_XAccValue( GetMAccessibleValueFromAny(pAny
).getStr() );
408 // Added by Li Xing, only the checkbox in tree should have the value.
410 if( ( m_pParentObj
!=NULL
) && (TREE
== m_pParentObj
->m_accRole
|| TREE_ITEM
== m_pParentObj
->m_accRole
))
411 m_pIMAcc
->Put_XAccValue( GetMAccessibleValueFromAny(pAny
).getStr() );
421 ::rtl::OUString
AccObject::GetMAccessibleValueFromAny(Any pAny
)
423 ::rtl::OUString strValue
;
428 if(pAny
.getValueType() == cppu::UnoType
<cppu::UnoUnsignedShortType
>::get() )
433 strValue
=::rtl::OUString::number(val
);
437 else if(pAny
.getValueType() == cppu::UnoType
<rtl::OUString
>::get())
443 else if(pAny
.getValueType() == cppu::UnoType
<Sequence
< ::rtl::OUString
>>::get())
445 Sequence
< ::rtl::OUString
> val
;
449 int count
= val
.getLength();
451 for( int iIndex
= 0;iIndex
< count
;iIndex
++ )
453 strValue
+= val
[iIndex
];
458 else if(pAny
.getValueType() == cppu::UnoType
<double>::get())
463 strValue
=::rtl::OUString::number(val
);
466 else if(pAny
.getValueType() == cppu::UnoType
<sal_Int32
>::get())
471 strValue
=::rtl::OUString::number(val
);
474 else if (pAny
.getValueType() == cppu::UnoType
<com::sun::star::accessibility::TextSegment
>::get())
476 com::sun::star::accessibility::TextSegment val
;
479 ::rtl::OUString
realVal(val
.SegmentText
);
488 * Set name property via pAny.
489 * @param pAny New accessible name.
492 void AccObject::SetName( Any pAny
)
494 if( NULL
== m_pIMAcc
)
497 m_pIMAcc
->Put_XAccName( GetMAccessibleValueFromAny(pAny
).getStr() );
502 * Set description property via pAny.
503 * @param pAny New accessible description.
506 void AccObject::SetDescription( Any pAny
)
508 if( NULL
== m_pIMAcc
)
510 m_pIMAcc
->Put_XAccDescription( GetMAccessibleValueFromAny(pAny
).getStr() );
514 * Set role property via pAny
515 * @param Role New accessible role.
518 void AccObject::SetRole( short Role
)
520 if( NULL
== m_pIMAcc
)
522 m_pIMAcc
->Put_XAccRole( Role
);
526 * Get role property via pAny
528 * @return accessible role
530 short AccObject::GetRole() const
536 * Get MSAA state from UNO state
537 * @Role xState UNO state.
540 DWORD
AccObject::GetMSAAStateFromUNO(short xState
)
542 DWORD IState
= UNO_MSAA_UNMAPPING
;
544 if( !m_xAccContextRef
.is() )
549 short Role
= m_accRole
;
554 IState
= STATE_SYSTEM_BUSY
;
557 if( Role
== PUSH_BUTTON
|| Role
== TOGGLE_BUTTON
)
559 IState
= STATE_SYSTEM_PRESSED
;
562 IState
= STATE_SYSTEM_CHECKED
;
565 IState
= STATE_SYSTEM_UNAVAILABLE
;
568 IState
= STATE_SYSTEM_EXPANDED
;
571 IState
= STATE_SYSTEM_FOCUSABLE
;
574 IState
= STATE_SYSTEM_FOCUSED
;
577 IState
= STATE_SYSTEM_MIXED
;
579 case MULTI_SELECTABLE
:
580 IState
= STATE_SYSTEM_MULTISELECTABLE
;
583 IState
= STATE_SYSTEM_PRESSED
;
586 IState
= STATE_SYSTEM_SIZEABLE
;
589 if( m_accRole
== MENU
|| m_accRole
== MENU_ITEM
)
591 IState
= UNO_MSAA_UNMAPPING
;
595 IState
= STATE_SYSTEM_SELECTABLE
;
599 if( m_accRole
== MENU
|| m_accRole
== MENU_ITEM
)
601 IState
= UNO_MSAA_UNMAPPING
;
605 IState
= STATE_SYSTEM_SELECTED
;
609 IState
= STATE_SYSTEM_FOCUSED
;
613 sal_Bool isExpanded
= sal_True
;
614 sal_Bool isExpandable
= sal_True
;
615 if( Role
== PUSH_BUTTON
|| Role
== TOGGLE_BUTTON
|| BUTTON_DROPDOWN
== Role
)
617 IState
= STATE_SYSTEM_HASPOPUP
;
621 GetExpandedState(&isExpandable
,&isExpanded
);
623 IState
= STATE_SYSTEM_COLLAPSED
;
627 //Remove the SENSITIVE state mapping. There is no corresponding MSAA state.
629 // IState = STATE_SYSTEM_PROTECTED;
633 m_pIMAcc
->DecreaseState( STATE_SYSTEM_READONLY
);
637 IState
= STATE_SYSTEM_OFFSCREEN
;
640 IState
= STATE_SYSTEM_MOVEABLE
;
643 IState
= STATE_SYSTEM_COLLAPSED
;
646 IState
= STATE_SYSTEM_DEFAULT
;
656 * Decrease state of com object
657 * @param xState The lost state.
660 void AccObject::DecreaseState( short xState
)
662 if( NULL
== m_pIMAcc
)
667 if( xState
== FOCUSABLE
)
669 short Role
= m_accRole
;
671 || Role
== RADIO_MENU_ITEM
672 || Role
== CHECK_MENU_ITEM
)
676 if (Role
== TOGGLE_BUTTON
|| Role
== PUSH_BUTTON
|| BUTTON_DROPDOWN
== Role
)
678 if( ( m_pParentObj
!=NULL
) && (TOOL_BAR
== m_pParentObj
->m_accRole
) )
684 else if( xState
== AccessibleStateType::VISIBLE
)
686 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
688 else if( xState
== AccessibleStateType::SHOWING
)
690 m_pIMAcc
->IncreaseState( STATE_SYSTEM_OFFSCREEN
);
693 DWORD msState
= GetMSAAStateFromUNO(xState
);
694 if(msState
!=UNO_MSAA_UNMAPPING
)
695 m_pIMAcc
->DecreaseState(msState
);
699 * Increase state of com object
700 * @param xState The new state.
703 void AccObject::IncreaseState( short xState
)
705 if( NULL
== m_pIMAcc
)
712 if( xState
== AccessibleStateType::VISIBLE
)
714 m_pIMAcc
->DecreaseState( STATE_SYSTEM_INVISIBLE
);
716 else if( xState
== AccessibleStateType::SHOWING
)
718 m_pIMAcc
->DecreaseState( STATE_SYSTEM_OFFSCREEN
);
722 DWORD msState
= GetMSAAStateFromUNO(xState
);
723 if(msState
!=UNO_MSAA_UNMAPPING
)
724 m_pIMAcc
->IncreaseState( msState
);
728 * Get next child element
730 * @return AccObject Object interface.
732 AccObject
* AccObject::NextChild()
734 IAccChildList::iterator pInd
= m_childrenList
.begin();
735 if( pInd
!= m_childrenList
.end() )
740 * update action description desc
744 void AccObject::UpdateActionDesc()
751 ::rtl::OUString pXString
= m_xAccContextRef
->getAccessibleDescription();
752 m_pIMAcc
->Put_XAccDescription(pXString
.getStr());
753 long Role
= m_accRole
;
755 if( Role
== PUSH_BUTTON
|| Role
== RADIO_BUTTON
|| Role
== MENU_ITEM
||
756 Role
== LIST_ITEM
|| Role
== CHECK_BOX
|| Role
== TREE_ITEM
||
757 Role
== CHECK_MENU_ITEM
|| Role
== RADIO_MENU_ITEM
)
759 UpdateDefaultAction( );
764 if( m_xAccActionRef
.is() )
766 if( m_xAccActionRef
->getAccessibleActionCount() > 0 )
768 if (!(Role
== SPIN_BOX
|| Role
== COMBO_BOX
|| Role
== DATE_EDITOR
||
769 Role
== EDIT_BAR
|| Role
== PASSWORD_TEXT
|| Role
== TEXT
))
771 pXString
= m_xAccActionRef
->getAccessibleActionDescription( 0 );
772 //Solution:If string length is more than zero,action will will be set.
773 if( pXString
.getLength() > 0)
774 m_pIMAcc
->Put_ActionDescription( pXString
.getStr() );
782 * update role information from uno to com
786 void AccObject::UpdateRole()
793 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
794 m_pIMAcc
->Put_XAccRole( ROLE_SYSTEM_WINDOW
);
795 short iRoleIndex
= pContext
->getAccessibleRole();
796 if ((0 <= iRoleIndex
) && (iRoleIndex
< SAL_N_ELEMENTS(ROLE_TABLE
)))
798 short iIA2Role
= ROLE_TABLE
[iRoleIndex
][1] ;
799 m_pIMAcc
->Put_XAccRole( iIA2Role
);
804 * update state information from uno to com
808 void AccObject::UpdateState()
815 XAccessibleContext
* pContext
= m_xAccContextRef
.get();
816 Reference
< XAccessibleStateSet
> pRState
= pContext
->getAccessibleStateSet();
823 m_pIMAcc
->SetState(0L);
825 if ( m_accRole
== POPUP_MENU
)
830 Sequence
<short> pStates
= pRState
->getStates();
831 int count
= pStates
.getLength();
833 sal_Bool isEnable
= sal_False
;
834 sal_Bool isShowing
= sal_False
;
835 sal_Bool isEditable
= sal_False
;
836 sal_Bool isVisible
= sal_False
;
837 sal_Bool isFocusable
= sal_False
;
839 for( int iIndex
= 0;iIndex
< count
;iIndex
++ )
841 if( pStates
[iIndex
] == ENABLED
)
843 else if( pStates
[iIndex
] == SHOWING
)
844 isShowing
= sal_True
;
845 else if( pStates
[iIndex
] == VISIBLE
)
846 isVisible
= sal_True
;
847 else if( pStates
[iIndex
] == EDITABLE
)
848 isEditable
= sal_True
;
849 else if (pStates
[iIndex
] == FOCUSABLE
)
850 isFocusable
= sal_True
;
851 IncreaseState( pStates
[iIndex
]);
853 sal_Bool bIsMenuItem
= m_accRole
== MENU_ITEM
|| m_accRole
== RADIO_MENU_ITEM
|| m_accRole
== CHECK_MENU_ITEM
;
857 if(!(isShowing
&& isVisible
) )
859 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
860 m_pIMAcc
->DecreaseState( STATE_SYSTEM_FOCUSABLE
);
865 if(!(isShowing
|| isVisible
) )
866 m_pIMAcc
->IncreaseState( STATE_SYSTEM_INVISIBLE
);
869 short Role
= m_accRole
;
876 m_pIMAcc
->IncreaseState( STATE_SYSTEM_READONLY
);
879 // 2. editable combobox -> readonly ------ bridge
880 case EMBEDDED_OBJECT
:
901 m_pIMAcc
->IncreaseState( STATE_SYSTEM_READONLY
);
912 if(!(Role
== FILLER
|| Role
== END_NOTE
|| Role
== FOOTER
|| Role
== FOOTNOTE
|| Role
== GROUP_BOX
|| Role
== RULER
913 || Role
== HEADER
|| Role
== ICON
|| Role
== INTERNAL_FRAME
|| Role
== LABEL
|| Role
== LAYERED_PANE
914 || Role
== SCROLL_BAR
|| Role
== SCROLL_PANE
|| Role
== SPLIT_PANE
|| Role
== STATUS_BAR
|| Role
== TOOL_TIP
))
916 if( SEPARATOR
== Role
)
918 if( ( m_pParentObj
!= NULL
) && ( MENU
== m_pParentObj
->m_accRole
|| POPUP_MENU
== m_pParentObj
->m_accRole
))
919 IncreaseState( FOCUSABLE
);
922 else if (TABLE_CELL
== Role
|| TABLE
== Role
|| PANEL
== Role
|| OPTION_PANE
== Role
||
923 COLUMN_HEADER
== Role
)
926 IncreaseState( FOCUSABLE
);
932 if ( isShowing
&& isVisible
)
934 IncreaseState( FOCUSABLE
);
939 IncreaseState( FOCUSABLE
);
946 m_pIMAcc
->IncreaseState( STATE_SYSTEM_UNAVAILABLE
);
947 if( !((Role
== MENU_ITEM
) ||
948 (Role
== RADIO_MENU_ITEM
) ||
949 (Role
== CHECK_MENU_ITEM
)) )
951 if ( Role
== TOGGLE_BUTTON
|| Role
== PUSH_BUTTON
|| BUTTON_DROPDOWN
== Role
)
953 if(( m_pParentObj
!= NULL
)&& (TOOL_BAR
== m_pParentObj
->m_accRole
) )
954 IncreaseState( FOCUSABLE
);
956 DecreaseState( FOCUSABLE
);
959 DecreaseState( FOCUSABLE
);
961 else if( isShowing
|| isVisible
)
963 IncreaseState( FOCUSABLE
);
973 if( pContext
->getAccessibleChildCount() > 0 )
974 m_pIMAcc
->IncreaseState( STATE_SYSTEM_HASPOPUP
);
977 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 ::com::sun::star::awt::Point pCPoint
= pRComponent
->getLocationOnScreen();
1002 ::com::sun::star::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 sal_Bool
AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
1021 if( NULL
== 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
.insert(IAccSelectionList::value_type(index
,accObj
));
1052 IAccSelectionList
& AccObject::GetSelection()
1054 return m_selectionList
;
1059 * Set self to focus object in parant child list
1063 void AccObject::setFocus()
1067 IncreaseState(FOCUSED
);
1068 m_pIMAcc
->Put_XAccFocus(CHILDID_SELF
);
1075 * Unset self from focus object in parant 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
= sal_False
;
1091 *isExpandable
= sal_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
] )
1110 *isExpanded
= sal_True
;
1112 else if( EXPANDABLE
== pStates
[iIndex
] )
1114 *isExpandable
= sal_True
;
1119 void AccObject::NotifyDestroy(sal_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(NULL
);
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 sal_Bool
AccObject::ifShouldDestroy()
1191 return m_bShouldDestroy
;
1194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */