xref: /AOO41X/main/winaccessibility/source/service/AccObject.cxx (revision 5fdc4257b5e43545f8f7841d9e8303d3a99b1714)
1*5fdc4257SSteve Yin /*************************************************************************
2*5fdc4257SSteve Yin  *
3*5fdc4257SSteve Yin  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*5fdc4257SSteve Yin  *
5*5fdc4257SSteve Yin  * Copyright IBM Corporation 2010.
6*5fdc4257SSteve Yin  * Copyright 2000, 2010 Oracle and/or its affiliates.
7*5fdc4257SSteve Yin  *
8*5fdc4257SSteve Yin  * OpenOffice.org - a multi-platform office productivity suite
9*5fdc4257SSteve Yin  *
10*5fdc4257SSteve Yin  * This file is part of OpenOffice.org.
11*5fdc4257SSteve Yin  *
12*5fdc4257SSteve Yin  * OpenOffice.org is free software: you can redistribute it and/or modify
13*5fdc4257SSteve Yin  * it under the terms of the GNU Lesser General Public License version 3
14*5fdc4257SSteve Yin  * only, as published by the Free Software Foundation.
15*5fdc4257SSteve Yin  *
16*5fdc4257SSteve Yin  * OpenOffice.org is distributed in the hope that it will be useful,
17*5fdc4257SSteve Yin  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18*5fdc4257SSteve Yin  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*5fdc4257SSteve Yin  * GNU Lesser General Public License version 3 for more details
20*5fdc4257SSteve Yin  * (a copy is included in the LICENSE file that accompanied this code).
21*5fdc4257SSteve Yin  *
22*5fdc4257SSteve Yin  * You should have received a copy of the GNU Lesser General Public License
23*5fdc4257SSteve Yin  * version 3 along with OpenOffice.org.  If not, see
24*5fdc4257SSteve Yin  * <http://www.openoffice.org/license.html>
25*5fdc4257SSteve Yin  * for a copy of the LGPLv3 License.
26*5fdc4257SSteve Yin  *
27*5fdc4257SSteve Yin  ************************************************************************/
28*5fdc4257SSteve Yin 
29*5fdc4257SSteve Yin #include <com/sun/star/uno/Sequence.h>
30*5fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31*5fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleRole.hpp>
32*5fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleValue.hpp>
33*5fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
34*5fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleText.hpp>
35*5fdc4257SSteve Yin 
36*5fdc4257SSteve Yin #include <stdlib.h>
37*5fdc4257SSteve Yin #include <memory.h>
38*5fdc4257SSteve Yin #include <stdio.h>
39*5fdc4257SSteve Yin #include <memory.h>
40*5fdc4257SSteve Yin #include <algorithm>
41*5fdc4257SSteve Yin #include <assert.h>
42*5fdc4257SSteve Yin 
43*5fdc4257SSteve Yin #include "AccObject.hxx"
44*5fdc4257SSteve Yin #include "AccEventListener.hxx"
45*5fdc4257SSteve Yin #include "UAccCOM_i.c"
46*5fdc4257SSteve Yin #include "AccResource.hxx"
47*5fdc4257SSteve Yin #include "AccessibleRole.h"
48*5fdc4257SSteve Yin 
49*5fdc4257SSteve Yin 
50*5fdc4257SSteve Yin 
51*5fdc4257SSteve Yin 
52*5fdc4257SSteve Yin using namespace std;
53*5fdc4257SSteve Yin using namespace com::sun::star::uno;
54*5fdc4257SSteve Yin using namespace com::sun::star::accessibility;
55*5fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleRole;
56*5fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleStateType;
57*5fdc4257SSteve Yin 
58*5fdc4257SSteve Yin 
59*5fdc4257SSteve Yin /**
60*5fdc4257SSteve Yin    * Constructor.
61*5fdc4257SSteve Yin    * @param pXAcc Uno XAccessible interface of control.
62*5fdc4257SSteve Yin    * @param Agent The agent kept in all listeners,it's the sole interface by which
63*5fdc4257SSteve Yin    *              listener communicate with windows manager.
64*5fdc4257SSteve Yin    * @param listener listener that registers in UNO system.
65*5fdc4257SSteve Yin    * @return.
66*5fdc4257SSteve Yin    */
67*5fdc4257SSteve Yin AccObject::AccObject(XAccessible* pAcc,AccObjectManagerAgent* pAgent ,AccEventListener* listener) :
68*5fdc4257SSteve Yin         m_pIMAcc	(NULL),
69*5fdc4257SSteve Yin         m_resID		(NULL),
70*5fdc4257SSteve Yin         m_pParantID	(NULL),
71*5fdc4257SSteve Yin         m_pParentObj(NULL),
72*5fdc4257SSteve Yin         m_accListener (listener),
73*5fdc4257SSteve Yin         m_bShouldDestroy(sal_False),
74*5fdc4257SSteve Yin         m_xAccRef( pAcc )
75*5fdc4257SSteve Yin {
76*5fdc4257SSteve Yin     sal_Bool bRet = ImplInitilizeCreateObj();
77*5fdc4257SSteve Yin 
78*5fdc4257SSteve Yin     m_xAccContextRef = m_xAccRef->getAccessibleContext();
79*5fdc4257SSteve Yin     m_xAccActionRef = Reference< XAccessibleAction > (m_xAccContextRef,UNO_QUERY);
80*5fdc4257SSteve Yin     m_accRole = m_xAccContextRef -> getAccessibleRole();
81*5fdc4257SSteve Yin     if( m_pIMAcc )
82*5fdc4257SSteve Yin     {
83*5fdc4257SSteve Yin         m_pIMAcc->SetXAccessible((long) m_xAccRef.get());
84*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccAgent((long)pAgent);
85*5fdc4257SSteve Yin         m_pIMAcc->SetDefaultAction((long)m_xAccActionRef.get());
86*5fdc4257SSteve Yin     }
87*5fdc4257SSteve Yin }
88*5fdc4257SSteve Yin /**
89*5fdc4257SSteve Yin    * Destructor.
90*5fdc4257SSteve Yin    * @param
91*5fdc4257SSteve Yin    * @return
92*5fdc4257SSteve Yin    */
93*5fdc4257SSteve Yin AccObject::~AccObject()
94*5fdc4257SSteve Yin {
95*5fdc4257SSteve Yin     m_pIMAcc = NULL;
96*5fdc4257SSteve Yin     m_xAccRef = NULL;
97*5fdc4257SSteve Yin     m_xAccActionRef = NULL;
98*5fdc4257SSteve Yin     m_xAccContextRef = NULL;
99*5fdc4257SSteve Yin }
100*5fdc4257SSteve Yin 
101*5fdc4257SSteve Yin 
102*5fdc4257SSteve Yin 
103*5fdc4257SSteve Yin /**
104*5fdc4257SSteve Yin    * Insert a child element.
105*5fdc4257SSteve Yin    * @param pChild Child element that should be inserted into child list.
106*5fdc4257SSteve Yin    * @param pos Insert postion.
107*5fdc4257SSteve Yin    * @return
108*5fdc4257SSteve Yin    */
109*5fdc4257SSteve Yin void AccObject::InsertChild( AccObject* pChild,short pos )
110*5fdc4257SSteve Yin {
111*5fdc4257SSteve Yin 
112*5fdc4257SSteve Yin     std::vector<AccObject*>::iterator iter;
113*5fdc4257SSteve Yin     iter = std::find(m_childrenList.begin(),m_childrenList.end(),pChild);
114*5fdc4257SSteve Yin     if(iter!=m_childrenList.end())
115*5fdc4257SSteve Yin         return;
116*5fdc4257SSteve Yin     if(LAST_CHILD==pos)
117*5fdc4257SSteve Yin     {
118*5fdc4257SSteve Yin         m_childrenList.push_back(pChild);
119*5fdc4257SSteve Yin     }
120*5fdc4257SSteve Yin     else
121*5fdc4257SSteve Yin     {
122*5fdc4257SSteve Yin         std::vector<AccObject*>::iterator iter=m_childrenList.begin()+pos;
123*5fdc4257SSteve Yin         m_childrenList.insert(iter,pChild);
124*5fdc4257SSteve Yin     }
125*5fdc4257SSteve Yin 
126*5fdc4257SSteve Yin     pChild->SetParentObj(this);
127*5fdc4257SSteve Yin }
128*5fdc4257SSteve Yin 
129*5fdc4257SSteve Yin /**
130*5fdc4257SSteve Yin    * Delete a child element
131*5fdc4257SSteve Yin    * @param pChild Child element that should be inserted into child list.
132*5fdc4257SSteve Yin    * @param pos Insert postion.
133*5fdc4257SSteve Yin    * @return
134*5fdc4257SSteve Yin    */
135*5fdc4257SSteve Yin void AccObject::DeleteChild( AccObject* pChild )
136*5fdc4257SSteve Yin {
137*5fdc4257SSteve Yin     std::vector<AccObject*>::iterator iter;
138*5fdc4257SSteve Yin     iter = std::find(m_childrenList.begin(),m_childrenList.end(),pChild);
139*5fdc4257SSteve Yin     if(iter!=m_childrenList.end())
140*5fdc4257SSteve Yin     {
141*5fdc4257SSteve Yin         m_childrenList.erase(iter);
142*5fdc4257SSteve Yin         if(m_pIMAcc)
143*5fdc4257SSteve Yin             pChild->SetParentObj(NULL);
144*5fdc4257SSteve Yin     }
145*5fdc4257SSteve Yin }
146*5fdc4257SSteve Yin 
147*5fdc4257SSteve Yin /**
148*5fdc4257SSteve Yin    * In order to windows API WindowFromAccessibleObject,we sometimes to set a pure
149*5fdc4257SSteve Yin    * top window accessible object created by windows system as top ancestor.
150*5fdc4257SSteve Yin    * @param.
151*5fdc4257SSteve Yin    * @return
152*5fdc4257SSteve Yin    */
153*5fdc4257SSteve Yin void AccObject::UpdateValidWindow()
154*5fdc4257SSteve Yin {
155*5fdc4257SSteve Yin     if(m_pIMAcc)
156*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccWindowHandle(m_pParantID);
157*5fdc4257SSteve Yin }
158*5fdc4257SSteve Yin 
159*5fdc4257SSteve Yin /**
160*5fdc4257SSteve Yin    * Translate all UNO basic information into MSAA com information.
161*5fdc4257SSteve Yin    * @param
162*5fdc4257SSteve Yin    * @return If the method is correctly processed.
163*5fdc4257SSteve Yin    */
164*5fdc4257SSteve Yin sal_Bool AccObject::ImplInitilizeCreateObj()
165*5fdc4257SSteve Yin {
166*5fdc4257SSteve Yin 
167*5fdc4257SSteve Yin     if ( S_OK != CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL ,
168*5fdc4257SSteve Yin                                    IID_IMAccessible,
169*5fdc4257SSteve Yin                                    (void **)&m_pIMAcc
170*5fdc4257SSteve Yin                                  )
171*5fdc4257SSteve Yin        )
172*5fdc4257SSteve Yin     {
173*5fdc4257SSteve Yin         return sal_False;
174*5fdc4257SSteve Yin     }
175*5fdc4257SSteve Yin 
176*5fdc4257SSteve Yin     return sal_True;
177*5fdc4257SSteve Yin }
178*5fdc4257SSteve Yin 
179*5fdc4257SSteve Yin /**
180*5fdc4257SSteve Yin    * Update name property to com object.
181*5fdc4257SSteve Yin    * @param
182*5fdc4257SSteve Yin    * @return
183*5fdc4257SSteve Yin    */
184*5fdc4257SSteve Yin void  AccObject::UpdateName( )
185*5fdc4257SSteve Yin {
186*5fdc4257SSteve Yin     if (!m_pIMAcc)
187*5fdc4257SSteve Yin     {
188*5fdc4257SSteve Yin         return;
189*5fdc4257SSteve Yin     }
190*5fdc4257SSteve Yin 
191*5fdc4257SSteve Yin     if( ( TEXT_FRAME == m_accRole   ) && ( m_pParentObj !=NULL )&& ( SCROLL_PANE == m_pParentObj -> m_accRole ) )
192*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccName( m_pParentObj->m_xAccContextRef->getAccessibleName().getStr() );
193*5fdc4257SSteve Yin 	//IAccessibility2 Implementation 2009-----
194*5fdc4257SSteve Yin     if ( PARAGRAPH == m_accRole)
195*5fdc4257SSteve Yin     {
196*5fdc4257SSteve Yin     	::rtl::OUString emptyStr = ::rtl::OUString::createFromAscii("");
197*5fdc4257SSteve Yin     	m_pIMAcc->Put_XAccName(emptyStr.getStr());
198*5fdc4257SSteve Yin     }
199*5fdc4257SSteve Yin 	//-----IAccessibility2 Implementation 2009
200*5fdc4257SSteve Yin     else
201*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccName(m_xAccContextRef->getAccessibleName().getStr());
202*5fdc4257SSteve Yin 
203*5fdc4257SSteve Yin     return ;
204*5fdc4257SSteve Yin }
205*5fdc4257SSteve Yin /**
206*5fdc4257SSteve Yin    * Update description property to com object.
207*5fdc4257SSteve Yin    * no content for update description
208*5fdc4257SSteve Yin    * @param
209*5fdc4257SSteve Yin    * @return
210*5fdc4257SSteve Yin    */
211*5fdc4257SSteve Yin void AccObject::UpdateDescription()
212*5fdc4257SSteve Yin {
213*5fdc4257SSteve Yin     if (!m_pIMAcc)
214*5fdc4257SSteve Yin     {
215*5fdc4257SSteve Yin         return;
216*5fdc4257SSteve Yin     }
217*5fdc4257SSteve Yin 
218*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription(m_xAccContextRef->getAccessibleDescription().getStr());
219*5fdc4257SSteve Yin     return ;
220*5fdc4257SSteve Yin }
221*5fdc4257SSteve Yin 
222*5fdc4257SSteve Yin /**
223*5fdc4257SSteve Yin    * Update default action property to com object.
224*5fdc4257SSteve Yin    * @param
225*5fdc4257SSteve Yin    * @return
226*5fdc4257SSteve Yin    */
227*5fdc4257SSteve Yin void  AccObject::UpdateAction()
228*5fdc4257SSteve Yin {
229*5fdc4257SSteve Yin     m_xAccActionRef = Reference< XAccessibleAction > (m_xAccContextRef,UNO_QUERY);
230*5fdc4257SSteve Yin 
231*5fdc4257SSteve Yin     if( m_xAccActionRef.is() && m_pIMAcc )
232*5fdc4257SSteve Yin     {
233*5fdc4257SSteve Yin         if( m_xAccActionRef->getAccessibleActionCount() > 0 )
234*5fdc4257SSteve Yin         {
235*5fdc4257SSteve Yin             UpdateDefaultAction( );
236*5fdc4257SSteve Yin             m_pIMAcc->SetDefaultAction((long)m_xAccActionRef.get());
237*5fdc4257SSteve Yin         }
238*5fdc4257SSteve Yin     }
239*5fdc4257SSteve Yin }
240*5fdc4257SSteve Yin 
241*5fdc4257SSteve Yin /**
242*5fdc4257SSteve Yin    * Update value property to com object.
243*5fdc4257SSteve Yin    * @param
244*5fdc4257SSteve Yin    * @return
245*5fdc4257SSteve Yin    */
246*5fdc4257SSteve Yin void AccObject::UpdateValue()
247*5fdc4257SSteve Yin {
248*5fdc4257SSteve Yin     if( NULL == m_pIMAcc  || !m_xAccContextRef.is() )
249*5fdc4257SSteve Yin     {
250*5fdc4257SSteve Yin         assert(false);
251*5fdc4257SSteve Yin         return ;
252*5fdc4257SSteve Yin     }
253*5fdc4257SSteve Yin 
254*5fdc4257SSteve Yin     Reference< XAccessibleValue > pRValue(m_xAccContextRef.get(),UNO_QUERY);
255*5fdc4257SSteve Yin     Any pAny;
256*5fdc4257SSteve Yin     if( pRValue.is() )
257*5fdc4257SSteve Yin     {
258*5fdc4257SSteve Yin         pAny = pRValue->getCurrentValue();
259*5fdc4257SSteve Yin     }
260*5fdc4257SSteve Yin 
261*5fdc4257SSteve Yin     SetValue( pAny );
262*5fdc4257SSteve Yin }
263*5fdc4257SSteve Yin 
264*5fdc4257SSteve Yin /**
265*5fdc4257SSteve Yin    * Set special default action description string via UNO role.
266*5fdc4257SSteve Yin    * @param Role UNO role
267*5fdc4257SSteve Yin    * @return
268*5fdc4257SSteve Yin    */
269*5fdc4257SSteve Yin void AccObject::UpdateDefaultAction( )
270*5fdc4257SSteve Yin {
271*5fdc4257SSteve Yin     if(!m_xAccActionRef.is())
272*5fdc4257SSteve Yin         return ;
273*5fdc4257SSteve Yin 
274*5fdc4257SSteve Yin     switch(m_accRole)
275*5fdc4257SSteve Yin     {
276*5fdc4257SSteve Yin     case PUSH_BUTTON:
277*5fdc4257SSteve Yin     case TOGGLE_BUTTON:
278*5fdc4257SSteve Yin     case RADIO_BUTTON:
279*5fdc4257SSteve Yin     case MENU_ITEM:
280*5fdc4257SSteve Yin     case RADIO_MENU_ITEM:
281*5fdc4257SSteve Yin     case CHECK_MENU_ITEM:
282*5fdc4257SSteve Yin     case LIST_ITEM:
283*5fdc4257SSteve Yin     case CHECK_BOX:
284*5fdc4257SSteve Yin     case TREE_ITEM:
285*5fdc4257SSteve Yin     case BUTTON_DROPDOWN:
286*5fdc4257SSteve Yin         m_pIMAcc->Put_ActionDescription( m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr() );
287*5fdc4257SSteve Yin         return;
288*5fdc4257SSteve Yin     }
289*5fdc4257SSteve Yin }
290*5fdc4257SSteve Yin 
291*5fdc4257SSteve Yin /**
292*5fdc4257SSteve Yin    * Set value property via pAny.
293*5fdc4257SSteve Yin    * @param pAny New value.
294*5fdc4257SSteve Yin    * @return
295*5fdc4257SSteve Yin    */
296*5fdc4257SSteve Yin void  AccObject::SetValue( Any pAny )
297*5fdc4257SSteve Yin {
298*5fdc4257SSteve Yin     unsigned short pUNumberString[100];
299*5fdc4257SSteve Yin     memset( pUNumberString, 0 , sizeof( pUNumberString) );
300*5fdc4257SSteve Yin 
301*5fdc4257SSteve Yin     if( NULL == m_pIMAcc || !m_xAccContextRef.is() )
302*5fdc4257SSteve Yin     {
303*5fdc4257SSteve Yin         assert(false);
304*5fdc4257SSteve Yin         return ;
305*5fdc4257SSteve Yin     }
306*5fdc4257SSteve Yin     Reference< XAccessibleText > pRText(m_xAccContextRef,UNO_QUERY);
307*5fdc4257SSteve Yin     ::rtl::OUString val;
308*5fdc4257SSteve Yin     int index = 0 ;
309*5fdc4257SSteve Yin     switch(m_accRole)
310*5fdc4257SSteve Yin     {
311*5fdc4257SSteve Yin     case SPIN_BOX:
312*5fdc4257SSteve Yin         // 3. date editor's msaa value should be the same as spinbox
313*5fdc4257SSteve Yin     case DATE_EDITOR:
314*5fdc4257SSteve Yin     case TEXT:
315*5fdc4257SSteve Yin     case PARAGRAPH:
316*5fdc4257SSteve Yin     case HEADING:
317*5fdc4257SSteve Yin 
318*5fdc4257SSteve Yin         if(pRText.get())
319*5fdc4257SSteve Yin         {
320*5fdc4257SSteve Yin             val = pRText->getText();
321*5fdc4257SSteve Yin         }
322*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccValue( val.getStr() );
323*5fdc4257SSteve Yin         break;
324*5fdc4257SSteve Yin     case TREE_ITEM:
325*5fdc4257SSteve Yin 	//IAccessibility2 Implementation 2009-----
326*5fdc4257SSteve Yin     //case CHECK_BOX:	//Commented by Li Xing to disable the value for general checkbox
327*5fdc4257SSteve Yin     case COMBO_BOX:
328*5fdc4257SSteve Yin     case TABLE_CELL:
329*5fdc4257SSteve Yin     case NOTE:
330*5fdc4257SSteve Yin     case SCROLL_BAR:
331*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccValue( GetMAccessibleValueFromAny(pAny).getStr() );
332*5fdc4257SSteve Yin         break ;
333*5fdc4257SSteve Yin 	// Added by Li Xing, only the checkbox in tree should have the value.
334*5fdc4257SSteve Yin 	case CHECK_BOX:
335*5fdc4257SSteve Yin 		if( ( m_pParentObj !=NULL ) && (TREE == m_pParentObj->m_accRole || TREE_ITEM == m_pParentObj->m_accRole ))
336*5fdc4257SSteve Yin 	        m_pIMAcc->Put_XAccValue( GetMAccessibleValueFromAny(pAny).getStr() );
337*5fdc4257SSteve Yin 	//-----IAccessibility2 Implementation 2009
338*5fdc4257SSteve Yin 		break;
339*5fdc4257SSteve Yin     default:
340*5fdc4257SSteve Yin         break;
341*5fdc4257SSteve Yin     }
342*5fdc4257SSteve Yin 
343*5fdc4257SSteve Yin     return;
344*5fdc4257SSteve Yin 
345*5fdc4257SSteve Yin 
346*5fdc4257SSteve Yin }
347*5fdc4257SSteve Yin ::rtl::OUString AccObject::GetMAccessibleValueFromAny(Any pAny)
348*5fdc4257SSteve Yin {
349*5fdc4257SSteve Yin     ::rtl::OUString strValue;
350*5fdc4257SSteve Yin 
351*5fdc4257SSteve Yin     if(NULL == m_pIMAcc)
352*5fdc4257SSteve Yin         return strValue;
353*5fdc4257SSteve Yin 
354*5fdc4257SSteve Yin     if(pAny.getValueType() == getCppuType( (sal_uInt16 *)0 ) )
355*5fdc4257SSteve Yin     {
356*5fdc4257SSteve Yin         sal_uInt16 val;
357*5fdc4257SSteve Yin         if (pAny >>= val)
358*5fdc4257SSteve Yin         {
359*5fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf((sal_Int32)val);
360*5fdc4257SSteve Yin 
361*5fdc4257SSteve Yin         }
362*5fdc4257SSteve Yin     }
363*5fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (::rtl::OUString *)0 ) )
364*5fdc4257SSteve Yin     {
365*5fdc4257SSteve Yin 
366*5fdc4257SSteve Yin         pAny >>= strValue ;
367*5fdc4257SSteve Yin 
368*5fdc4257SSteve Yin     }
369*5fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (Sequence< ::rtl::OUString > *)0 ) )
370*5fdc4257SSteve Yin     {
371*5fdc4257SSteve Yin         Sequence< ::rtl::OUString > val;
372*5fdc4257SSteve Yin         if (pAny >>= val)
373*5fdc4257SSteve Yin         {
374*5fdc4257SSteve Yin 
375*5fdc4257SSteve Yin             int count = val.getLength();
376*5fdc4257SSteve Yin 
377*5fdc4257SSteve Yin             for( int iIndex = 0;iIndex < count;iIndex++ )
378*5fdc4257SSteve Yin             {
379*5fdc4257SSteve Yin                 strValue += val[iIndex];
380*5fdc4257SSteve Yin             }
381*5fdc4257SSteve Yin 
382*5fdc4257SSteve Yin         }
383*5fdc4257SSteve Yin     }
384*5fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (double *)0 ) )
385*5fdc4257SSteve Yin     {
386*5fdc4257SSteve Yin         double val;
387*5fdc4257SSteve Yin         if (pAny >>= val)
388*5fdc4257SSteve Yin         {
389*5fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf(val);
390*5fdc4257SSteve Yin         }
391*5fdc4257SSteve Yin     }
392*5fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (sal_Int32 *)0 ) )
393*5fdc4257SSteve Yin     {
394*5fdc4257SSteve Yin         sal_Int32 val;
395*5fdc4257SSteve Yin         if (pAny >>= val)
396*5fdc4257SSteve Yin         {
397*5fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf(val);
398*5fdc4257SSteve Yin         }
399*5fdc4257SSteve Yin     }
400*5fdc4257SSteve Yin     else if (pAny.getValueType() == getCppuType( (com::sun::star::accessibility::TextSegment *)0 ) )
401*5fdc4257SSteve Yin     {
402*5fdc4257SSteve Yin         com::sun::star::accessibility::TextSegment val;
403*5fdc4257SSteve Yin         if (pAny >>= val)
404*5fdc4257SSteve Yin         {
405*5fdc4257SSteve Yin             ::rtl::OUString realVal(val.SegmentText);
406*5fdc4257SSteve Yin             strValue = realVal;
407*5fdc4257SSteve Yin 
408*5fdc4257SSteve Yin         }
409*5fdc4257SSteve Yin     }
410*5fdc4257SSteve Yin 
411*5fdc4257SSteve Yin     return strValue;
412*5fdc4257SSteve Yin }
413*5fdc4257SSteve Yin /**
414*5fdc4257SSteve Yin    * Set name property via pAny.
415*5fdc4257SSteve Yin    * @param pAny New accessible name.
416*5fdc4257SSteve Yin    * @return
417*5fdc4257SSteve Yin    */
418*5fdc4257SSteve Yin void  AccObject::SetName( Any pAny)
419*5fdc4257SSteve Yin {
420*5fdc4257SSteve Yin     if( NULL == m_pIMAcc )
421*5fdc4257SSteve Yin         return ;
422*5fdc4257SSteve Yin 
423*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccName( GetMAccessibleValueFromAny(pAny).getStr() );
424*5fdc4257SSteve Yin 
425*5fdc4257SSteve Yin }
426*5fdc4257SSteve Yin 
427*5fdc4257SSteve Yin /**
428*5fdc4257SSteve Yin    * Set description property via pAny.
429*5fdc4257SSteve Yin    * @param pAny New accessible description.
430*5fdc4257SSteve Yin    * @return
431*5fdc4257SSteve Yin    */
432*5fdc4257SSteve Yin void  AccObject::SetDescription( Any pAny )
433*5fdc4257SSteve Yin {
434*5fdc4257SSteve Yin     if( NULL == m_pIMAcc )
435*5fdc4257SSteve Yin         return ;
436*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription( GetMAccessibleValueFromAny(pAny).getStr() );
437*5fdc4257SSteve Yin }
438*5fdc4257SSteve Yin 
439*5fdc4257SSteve Yin /**
440*5fdc4257SSteve Yin    * Set role property via pAny
441*5fdc4257SSteve Yin    * @param Role New accessible role.
442*5fdc4257SSteve Yin    * @return
443*5fdc4257SSteve Yin    */
444*5fdc4257SSteve Yin void  AccObject::SetRole( short Role )
445*5fdc4257SSteve Yin {
446*5fdc4257SSteve Yin     if( NULL == m_pIMAcc )
447*5fdc4257SSteve Yin         return ;
448*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccRole( Role );
449*5fdc4257SSteve Yin }
450*5fdc4257SSteve Yin 
451*5fdc4257SSteve Yin /**
452*5fdc4257SSteve Yin * Get role property via pAny
453*5fdc4257SSteve Yin * @param
454*5fdc4257SSteve Yin * @return accessible role
455*5fdc4257SSteve Yin */
456*5fdc4257SSteve Yin short AccObject::GetRole() const
457*5fdc4257SSteve Yin {
458*5fdc4257SSteve Yin     return m_accRole;
459*5fdc4257SSteve Yin }
460*5fdc4257SSteve Yin 
461*5fdc4257SSteve Yin /**
462*5fdc4257SSteve Yin    * Get MSAA state from UNO state
463*5fdc4257SSteve Yin    * @Role xState UNO state.
464*5fdc4257SSteve Yin    * @return
465*5fdc4257SSteve Yin    */
466*5fdc4257SSteve Yin DWORD AccObject::GetMSAAStateFromUNO(short xState)
467*5fdc4257SSteve Yin {
468*5fdc4257SSteve Yin     DWORD IState = UNO_MSAA_UNMAPPING;
469*5fdc4257SSteve Yin 
470*5fdc4257SSteve Yin     if( !m_xAccContextRef.is() )
471*5fdc4257SSteve Yin     {
472*5fdc4257SSteve Yin         assert(false);
473*5fdc4257SSteve Yin         return IState;
474*5fdc4257SSteve Yin     }
475*5fdc4257SSteve Yin     short Role = m_accRole;
476*5fdc4257SSteve Yin 
477*5fdc4257SSteve Yin     switch( xState )
478*5fdc4257SSteve Yin     {
479*5fdc4257SSteve Yin     case  BUSY:
480*5fdc4257SSteve Yin         IState = STATE_SYSTEM_BUSY;
481*5fdc4257SSteve Yin         break;
482*5fdc4257SSteve Yin     case  CHECKED:
483*5fdc4257SSteve Yin         if( Role == PUSH_BUTTON || Role == TOGGLE_BUTTON )
484*5fdc4257SSteve Yin         {
485*5fdc4257SSteve Yin             IState = STATE_SYSTEM_PRESSED;
486*5fdc4257SSteve Yin         }
487*5fdc4257SSteve Yin         else
488*5fdc4257SSteve Yin             IState = STATE_SYSTEM_CHECKED;
489*5fdc4257SSteve Yin         break;
490*5fdc4257SSteve Yin     case  DEFUNC:
491*5fdc4257SSteve Yin         IState = STATE_SYSTEM_UNAVAILABLE;
492*5fdc4257SSteve Yin         break;
493*5fdc4257SSteve Yin     case  EXPANDED:
494*5fdc4257SSteve Yin         IState = STATE_SYSTEM_EXPANDED;
495*5fdc4257SSteve Yin         break;
496*5fdc4257SSteve Yin     case  FOCUSABLE:
497*5fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSABLE;
498*5fdc4257SSteve Yin         break;
499*5fdc4257SSteve Yin     case  FOCUSED:
500*5fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSED;
501*5fdc4257SSteve Yin         break;
502*5fdc4257SSteve Yin     case  INDETERMINATE:
503*5fdc4257SSteve Yin         IState = STATE_SYSTEM_MIXED;
504*5fdc4257SSteve Yin         break;
505*5fdc4257SSteve Yin     case  MULTI_SELECTABLE:
506*5fdc4257SSteve Yin         IState = STATE_SYSTEM_MULTISELECTABLE;
507*5fdc4257SSteve Yin         break;
508*5fdc4257SSteve Yin     case  PRESSED:
509*5fdc4257SSteve Yin         IState = STATE_SYSTEM_PRESSED;
510*5fdc4257SSteve Yin         break;
511*5fdc4257SSteve Yin     case  RESIZABLE:
512*5fdc4257SSteve Yin         IState = STATE_SYSTEM_SIZEABLE;
513*5fdc4257SSteve Yin         break;
514*5fdc4257SSteve Yin     case  SELECTABLE:
515*5fdc4257SSteve Yin         if( m_accRole == MENU || m_accRole == MENU_ITEM)
516*5fdc4257SSteve Yin         {
517*5fdc4257SSteve Yin             IState = UNO_MSAA_UNMAPPING;
518*5fdc4257SSteve Yin         }
519*5fdc4257SSteve Yin         else
520*5fdc4257SSteve Yin         {
521*5fdc4257SSteve Yin             IState = STATE_SYSTEM_SELECTABLE;
522*5fdc4257SSteve Yin         }
523*5fdc4257SSteve Yin         break;
524*5fdc4257SSteve Yin     case  SELECTED:
525*5fdc4257SSteve Yin         if( m_accRole == MENU || m_accRole == MENU_ITEM )
526*5fdc4257SSteve Yin         {
527*5fdc4257SSteve Yin             IState = UNO_MSAA_UNMAPPING;
528*5fdc4257SSteve Yin         }
529*5fdc4257SSteve Yin         else
530*5fdc4257SSteve Yin         {
531*5fdc4257SSteve Yin             IState = STATE_SYSTEM_SELECTED;
532*5fdc4257SSteve Yin         }
533*5fdc4257SSteve Yin         break;
534*5fdc4257SSteve Yin     case  ARMED:
535*5fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSED;
536*5fdc4257SSteve Yin         break;
537*5fdc4257SSteve Yin     case  EXPANDABLE:
538*5fdc4257SSteve Yin         {
539*5fdc4257SSteve Yin             sal_Bool isExpanded = sal_True;
540*5fdc4257SSteve Yin             sal_Bool isExpandable = sal_True;
541*5fdc4257SSteve Yin             if( Role == PUSH_BUTTON || Role == TOGGLE_BUTTON  || BUTTON_DROPDOWN == Role )
542*5fdc4257SSteve Yin             {
543*5fdc4257SSteve Yin                 IState = STATE_SYSTEM_HASPOPUP;
544*5fdc4257SSteve Yin             }
545*5fdc4257SSteve Yin             else
546*5fdc4257SSteve Yin             {
547*5fdc4257SSteve Yin                 GetExpandedState(&isExpandable,&isExpanded);
548*5fdc4257SSteve Yin                 if(!isExpanded)
549*5fdc4257SSteve Yin                     IState = STATE_SYSTEM_COLLAPSED;
550*5fdc4257SSteve Yin             }
551*5fdc4257SSteve Yin         }
552*5fdc4257SSteve Yin         break;
553*5fdc4257SSteve Yin 	//Remove the SENSITIVE state mapping. There is no corresponding MSAA state.
554*5fdc4257SSteve Yin     //case  SENSITIVE:
555*5fdc4257SSteve Yin     //    IState = STATE_SYSTEM_PROTECTED;
556*5fdc4257SSteve Yin     case EDITABLE:
557*5fdc4257SSteve Yin         if( m_pIMAcc )
558*5fdc4257SSteve Yin         {
559*5fdc4257SSteve Yin             m_pIMAcc->DecreaseState( STATE_SYSTEM_READONLY );
560*5fdc4257SSteve Yin         }
561*5fdc4257SSteve Yin         break;
562*5fdc4257SSteve Yin     case OFFSCREEN:
563*5fdc4257SSteve Yin         IState = STATE_SYSTEM_OFFSCREEN;
564*5fdc4257SSteve Yin         break;
565*5fdc4257SSteve Yin     case MOVEABLE:
566*5fdc4257SSteve Yin         IState = STATE_SYSTEM_MOVEABLE;
567*5fdc4257SSteve Yin         break;
568*5fdc4257SSteve Yin     case COLLAPSE:
569*5fdc4257SSteve Yin         IState = STATE_SYSTEM_COLLAPSED;
570*5fdc4257SSteve Yin         break;
571*5fdc4257SSteve Yin     case DEFAULT:
572*5fdc4257SSteve Yin         IState = STATE_SYSTEM_DEFAULT;
573*5fdc4257SSteve Yin         break;
574*5fdc4257SSteve Yin     default:
575*5fdc4257SSteve Yin         break;
576*5fdc4257SSteve Yin     }
577*5fdc4257SSteve Yin 
578*5fdc4257SSteve Yin     return IState;
579*5fdc4257SSteve Yin }
580*5fdc4257SSteve Yin 
581*5fdc4257SSteve Yin /**
582*5fdc4257SSteve Yin    * Decrease state of com object
583*5fdc4257SSteve Yin    * @param xState The lost state.
584*5fdc4257SSteve Yin    * @return
585*5fdc4257SSteve Yin    */
586*5fdc4257SSteve Yin void  AccObject::DecreaseState( short xState )
587*5fdc4257SSteve Yin {
588*5fdc4257SSteve Yin     if( NULL == m_pIMAcc )
589*5fdc4257SSteve Yin     {
590*5fdc4257SSteve Yin         return;
591*5fdc4257SSteve Yin     }
592*5fdc4257SSteve Yin 
593*5fdc4257SSteve Yin     if( xState == FOCUSABLE)
594*5fdc4257SSteve Yin     {
595*5fdc4257SSteve Yin         short Role = m_accRole ;
596*5fdc4257SSteve Yin         if(Role == MENU_ITEM
597*5fdc4257SSteve Yin                 || Role == RADIO_MENU_ITEM
598*5fdc4257SSteve Yin                 || Role == CHECK_MENU_ITEM)
599*5fdc4257SSteve Yin             return;
600*5fdc4257SSteve Yin         else
601*5fdc4257SSteve Yin         {
602*5fdc4257SSteve Yin             if (Role == TOGGLE_BUTTON || Role == PUSH_BUTTON || BUTTON_DROPDOWN == Role)
603*5fdc4257SSteve Yin             {
604*5fdc4257SSteve Yin                 if( ( m_pParentObj !=NULL ) && (TOOL_BAR == m_pParentObj->m_accRole ) )
605*5fdc4257SSteve Yin                     return;
606*5fdc4257SSteve Yin             }
607*5fdc4257SSteve Yin         }
608*5fdc4257SSteve Yin     }
609*5fdc4257SSteve Yin 
610*5fdc4257SSteve Yin     else if( xState == AccessibleStateType::VISIBLE  )
611*5fdc4257SSteve Yin     {
612*5fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
613*5fdc4257SSteve Yin     }
614*5fdc4257SSteve Yin     else if( xState == AccessibleStateType::SHOWING )
615*5fdc4257SSteve Yin     {
616*5fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_OFFSCREEN );
617*5fdc4257SSteve Yin     }
618*5fdc4257SSteve Yin 
619*5fdc4257SSteve Yin     DWORD msState = GetMSAAStateFromUNO(xState);
620*5fdc4257SSteve Yin     if(msState!=UNO_MSAA_UNMAPPING)
621*5fdc4257SSteve Yin         m_pIMAcc->DecreaseState(msState);
622*5fdc4257SSteve Yin }
623*5fdc4257SSteve Yin 
624*5fdc4257SSteve Yin /**
625*5fdc4257SSteve Yin    * Increase state of com object
626*5fdc4257SSteve Yin    * @param xState The new state.
627*5fdc4257SSteve Yin    * @return
628*5fdc4257SSteve Yin    */
629*5fdc4257SSteve Yin void AccObject::IncreaseState( short xState )
630*5fdc4257SSteve Yin {
631*5fdc4257SSteve Yin     if( NULL == m_pIMAcc )
632*5fdc4257SSteve Yin     {
633*5fdc4257SSteve Yin         assert(false);
634*5fdc4257SSteve Yin         return;
635*5fdc4257SSteve Yin     }
636*5fdc4257SSteve Yin 
637*5fdc4257SSteve Yin 
638*5fdc4257SSteve Yin     if( xState == AccessibleStateType::VISIBLE  )
639*5fdc4257SSteve Yin     {
640*5fdc4257SSteve Yin         m_pIMAcc->DecreaseState( STATE_SYSTEM_INVISIBLE );
641*5fdc4257SSteve Yin     }
642*5fdc4257SSteve Yin     else if( xState == AccessibleStateType::SHOWING )
643*5fdc4257SSteve Yin     {
644*5fdc4257SSteve Yin         m_pIMAcc->DecreaseState( STATE_SYSTEM_OFFSCREEN );
645*5fdc4257SSteve Yin     }
646*5fdc4257SSteve Yin 
647*5fdc4257SSteve Yin 
648*5fdc4257SSteve Yin     DWORD msState = GetMSAAStateFromUNO(xState);
649*5fdc4257SSteve Yin     if(msState!=UNO_MSAA_UNMAPPING)
650*5fdc4257SSteve Yin         m_pIMAcc->IncreaseState( msState );
651*5fdc4257SSteve Yin }
652*5fdc4257SSteve Yin 
653*5fdc4257SSteve Yin /**
654*5fdc4257SSteve Yin    * Get next child element
655*5fdc4257SSteve Yin    * @param
656*5fdc4257SSteve Yin    * @return AccObject Object interface.
657*5fdc4257SSteve Yin    */
658*5fdc4257SSteve Yin AccObject* AccObject::NextChild()
659*5fdc4257SSteve Yin {
660*5fdc4257SSteve Yin     IAccChildList::iterator pInd = m_childrenList.begin();
661*5fdc4257SSteve Yin     if( pInd != m_childrenList.end() )
662*5fdc4257SSteve Yin         return 	*pInd;
663*5fdc4257SSteve Yin     return NULL;
664*5fdc4257SSteve Yin }
665*5fdc4257SSteve Yin /**
666*5fdc4257SSteve Yin    * update action desciption desc
667*5fdc4257SSteve Yin    * @param
668*5fdc4257SSteve Yin    * @return
669*5fdc4257SSteve Yin    */
670*5fdc4257SSteve Yin void AccObject::UpdateActionDesc()
671*5fdc4257SSteve Yin {
672*5fdc4257SSteve Yin     if (!m_pIMAcc)
673*5fdc4257SSteve Yin     {
674*5fdc4257SSteve Yin         return;
675*5fdc4257SSteve Yin     }
676*5fdc4257SSteve Yin 
677*5fdc4257SSteve Yin     ::rtl::OUString	pXString = m_xAccContextRef->getAccessibleDescription();
678*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription(pXString.getStr());
679*5fdc4257SSteve Yin     long Role = m_accRole;
680*5fdc4257SSteve Yin 
681*5fdc4257SSteve Yin     if(  Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM ||
682*5fdc4257SSteve Yin             Role == LIST_ITEM || Role == CHECK_BOX || Role == TREE_ITEM ||
683*5fdc4257SSteve Yin             Role == CHECK_MENU_ITEM || Role == RADIO_MENU_ITEM )
684*5fdc4257SSteve Yin     {
685*5fdc4257SSteve Yin         UpdateDefaultAction(  );
686*5fdc4257SSteve Yin     }
687*5fdc4257SSteve Yin     else
688*5fdc4257SSteve Yin     {
689*5fdc4257SSteve Yin 
690*5fdc4257SSteve Yin         if( m_xAccActionRef.is() )
691*5fdc4257SSteve Yin         {
692*5fdc4257SSteve Yin             if( m_xAccActionRef->getAccessibleActionCount() > 0 )
693*5fdc4257SSteve Yin             {
694*5fdc4257SSteve Yin 				if (!(Role == SPIN_BOX || Role == COMBO_BOX || Role == DATE_EDITOR ||
695*5fdc4257SSteve Yin 					  Role == EDIT_BAR || Role == PASSWORD_TEXT || Role == TEXT))
696*5fdc4257SSteve Yin 				{
697*5fdc4257SSteve Yin 					pXString = m_xAccActionRef->getAccessibleActionDescription( 0 );
698*5fdc4257SSteve Yin 					//Solution:If string length is more than zero,action will will be set.
699*5fdc4257SSteve Yin 					if( pXString.getLength() > 0)
700*5fdc4257SSteve Yin 						m_pIMAcc->Put_ActionDescription( pXString.getStr() );
701*5fdc4257SSteve Yin 				}
702*5fdc4257SSteve Yin             }
703*5fdc4257SSteve Yin         }
704*5fdc4257SSteve Yin     }
705*5fdc4257SSteve Yin 
706*5fdc4257SSteve Yin }
707*5fdc4257SSteve Yin /**
708*5fdc4257SSteve Yin    * update role information from uno to com
709*5fdc4257SSteve Yin    * @param
710*5fdc4257SSteve Yin    * @return
711*5fdc4257SSteve Yin    */
712*5fdc4257SSteve Yin void AccObject::UpdateRole()
713*5fdc4257SSteve Yin {
714*5fdc4257SSteve Yin     if (!m_pIMAcc)
715*5fdc4257SSteve Yin     {
716*5fdc4257SSteve Yin         return;
717*5fdc4257SSteve Yin     }
718*5fdc4257SSteve Yin 
719*5fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
720*5fdc4257SSteve Yin     m_pIMAcc->Put_XAccRole( ROLE_SYSTEM_WINDOW  );
721*5fdc4257SSteve Yin     short iRoleIndex = pContext->getAccessibleRole();
722*5fdc4257SSteve Yin     if (( 0 <= iRoleIndex) && ( iRoleIndex <= (sizeof(ROLE_TABLE)/(sizeof(short)*2))))
723*5fdc4257SSteve Yin     {
724*5fdc4257SSteve Yin         short iIA2Role = ROLE_TABLE[iRoleIndex][1] ;
725*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccRole( iIA2Role  );
726*5fdc4257SSteve Yin     }
727*5fdc4257SSteve Yin 
728*5fdc4257SSteve Yin }
729*5fdc4257SSteve Yin /**
730*5fdc4257SSteve Yin    * update state information from uno to com
731*5fdc4257SSteve Yin    * @param
732*5fdc4257SSteve Yin    * @return
733*5fdc4257SSteve Yin    */
734*5fdc4257SSteve Yin void AccObject::UpdateState()
735*5fdc4257SSteve Yin {
736*5fdc4257SSteve Yin     if (!m_pIMAcc)
737*5fdc4257SSteve Yin     {
738*5fdc4257SSteve Yin         return;
739*5fdc4257SSteve Yin     }
740*5fdc4257SSteve Yin 
741*5fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
742*5fdc4257SSteve Yin     Reference< XAccessibleStateSet > pRState = pContext->getAccessibleStateSet();
743*5fdc4257SSteve Yin     if( !pRState.is() )
744*5fdc4257SSteve Yin     {
745*5fdc4257SSteve Yin         assert(false);
746*5fdc4257SSteve Yin         return ;
747*5fdc4257SSteve Yin     }
748*5fdc4257SSteve Yin 
749*5fdc4257SSteve Yin     m_pIMAcc->SetState(0L);
750*5fdc4257SSteve Yin 
751*5fdc4257SSteve Yin     if ( m_accRole == POPUP_MENU )
752*5fdc4257SSteve Yin     {
753*5fdc4257SSteve Yin         return;
754*5fdc4257SSteve Yin     }
755*5fdc4257SSteve Yin 
756*5fdc4257SSteve Yin     Sequence<short> pStates = pRState->getStates();
757*5fdc4257SSteve Yin     int count = pStates.getLength();
758*5fdc4257SSteve Yin 
759*5fdc4257SSteve Yin     sal_Bool isEnable = sal_False;
760*5fdc4257SSteve Yin     sal_Bool isShowing = sal_False;
761*5fdc4257SSteve Yin     sal_Bool isEditable = sal_False;
762*5fdc4257SSteve Yin     sal_Bool isVisible = sal_False;
763*5fdc4257SSteve Yin     sal_Bool isFocusable = sal_False;
764*5fdc4257SSteve Yin 
765*5fdc4257SSteve Yin     for( int iIndex = 0;iIndex < count;iIndex++ )
766*5fdc4257SSteve Yin     {
767*5fdc4257SSteve Yin         if( pStates[iIndex] == ENABLED )
768*5fdc4257SSteve Yin             isEnable = sal_True;
769*5fdc4257SSteve Yin         else if( pStates[iIndex] == SHOWING)
770*5fdc4257SSteve Yin             isShowing = sal_True;
771*5fdc4257SSteve Yin         else if( pStates[iIndex] == VISIBLE)
772*5fdc4257SSteve Yin             isVisible = sal_True;
773*5fdc4257SSteve Yin         else if( pStates[iIndex] == EDITABLE )
774*5fdc4257SSteve Yin             isEditable = sal_True;
775*5fdc4257SSteve Yin         else if (pStates[iIndex] == FOCUSABLE)
776*5fdc4257SSteve Yin             isFocusable = sal_True;
777*5fdc4257SSteve Yin         IncreaseState( pStates[iIndex]);
778*5fdc4257SSteve Yin     }
779*5fdc4257SSteve Yin     sal_Bool bIsMenuItem = m_accRole == MENU_ITEM || m_accRole == RADIO_MENU_ITEM || m_accRole == CHECK_MENU_ITEM;
780*5fdc4257SSteve Yin 
781*5fdc4257SSteve Yin     if(bIsMenuItem)
782*5fdc4257SSteve Yin     {
783*5fdc4257SSteve Yin         if(!(isShowing && isVisible) )
784*5fdc4257SSteve Yin         {
785*5fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
786*5fdc4257SSteve Yin             m_pIMAcc->DecreaseState( STATE_SYSTEM_FOCUSABLE );
787*5fdc4257SSteve Yin         }
788*5fdc4257SSteve Yin     }
789*5fdc4257SSteve Yin     else
790*5fdc4257SSteve Yin     {
791*5fdc4257SSteve Yin         if(!(isShowing || isVisible) )
792*5fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
793*5fdc4257SSteve Yin     }
794*5fdc4257SSteve Yin 
795*5fdc4257SSteve Yin     short Role = m_accRole;
796*5fdc4257SSteve Yin 
797*5fdc4257SSteve Yin     if( m_pIMAcc )
798*5fdc4257SSteve Yin     {
799*5fdc4257SSteve Yin         switch(m_accRole)
800*5fdc4257SSteve Yin         {
801*5fdc4257SSteve Yin         case LABEL:
802*5fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_READONLY );
803*5fdc4257SSteve Yin             break;
804*5fdc4257SSteve Yin         case TEXT:
805*5fdc4257SSteve Yin             // 2. editable combobox -> readonly ------ bridge
806*5fdc4257SSteve Yin         case EMBEDDED_OBJECT:
807*5fdc4257SSteve Yin         case END_NOTE:
808*5fdc4257SSteve Yin         case FOOTER:
809*5fdc4257SSteve Yin         case FOOTNOTE:
810*5fdc4257SSteve Yin         case GRAPHIC:
811*5fdc4257SSteve Yin         case HEADER:
812*5fdc4257SSteve Yin         case HEADING:
813*5fdc4257SSteve Yin 
814*5fdc4257SSteve Yin             //Image Map
815*5fdc4257SSteve Yin         case PARAGRAPH:
816*5fdc4257SSteve Yin         case PASSWORD_TEXT:
817*5fdc4257SSteve Yin         case SHAPE:
818*5fdc4257SSteve Yin         case SPIN_BOX:
819*5fdc4257SSteve Yin         case TABLE:
820*5fdc4257SSteve Yin         case TABLE_CELL:
821*5fdc4257SSteve Yin         case TEXT_FRAME:
822*5fdc4257SSteve Yin         case DATE_EDITOR:
823*5fdc4257SSteve Yin         case DOCUMENT:
824*5fdc4257SSteve Yin         case COLUMN_HEADER:
825*5fdc4257SSteve Yin             {
826*5fdc4257SSteve Yin                 if(!isEditable)
827*5fdc4257SSteve Yin                     m_pIMAcc->IncreaseState( STATE_SYSTEM_READONLY );
828*5fdc4257SSteve Yin             }
829*5fdc4257SSteve Yin             break;
830*5fdc4257SSteve Yin         default:
831*5fdc4257SSteve Yin             break;
832*5fdc4257SSteve Yin         }
833*5fdc4257SSteve Yin     }
834*5fdc4257SSteve Yin 
835*5fdc4257SSteve Yin     if( isEnable )
836*5fdc4257SSteve Yin     {
837*5fdc4257SSteve Yin 
838*5fdc4257SSteve Yin         if(!(Role == FILLER || Role == END_NOTE || Role == FOOTER || Role == FOOTNOTE || Role == GROUP_BOX || Role == RULER
839*5fdc4257SSteve Yin                 || Role == HEADER || Role == ICON || Role == INTERNAL_FRAME || Role == LABEL || Role == LAYERED_PANE
840*5fdc4257SSteve Yin                 || Role == SCROLL_BAR || Role == SCROLL_PANE || Role == SPLIT_PANE || Role == STATUS_BAR || Role == TOOL_TIP))
841*5fdc4257SSteve Yin         {
842*5fdc4257SSteve Yin             if( SEPARATOR == Role  )
843*5fdc4257SSteve Yin             {
844*5fdc4257SSteve Yin                 if( ( m_pParentObj != NULL ) && ( MENU == m_pParentObj->m_accRole  || POPUP_MENU == m_pParentObj->m_accRole ))
845*5fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
846*5fdc4257SSteve Yin             }
847*5fdc4257SSteve Yin 
848*5fdc4257SSteve Yin             else if (TABLE_CELL == Role || TABLE == Role || PANEL == Role || OPTION_PANE == Role ||
849*5fdc4257SSteve Yin                      COLUMN_HEADER == Role)
850*5fdc4257SSteve Yin             {
851*5fdc4257SSteve Yin                 if (isFocusable)
852*5fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
853*5fdc4257SSteve Yin             }
854*5fdc4257SSteve Yin             else
855*5fdc4257SSteve Yin             {
856*5fdc4257SSteve Yin                 if(bIsMenuItem)
857*5fdc4257SSteve Yin                 {
858*5fdc4257SSteve Yin                     if ( isShowing && isVisible)
859*5fdc4257SSteve Yin                     {
860*5fdc4257SSteve Yin                         IncreaseState( FOCUSABLE );
861*5fdc4257SSteve Yin                     }
862*5fdc4257SSteve Yin                 }
863*5fdc4257SSteve Yin                 else
864*5fdc4257SSteve Yin                 {
865*5fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
866*5fdc4257SSteve Yin                 }
867*5fdc4257SSteve Yin             }
868*5fdc4257SSteve Yin         }
869*5fdc4257SSteve Yin     }
870*5fdc4257SSteve Yin     else
871*5fdc4257SSteve Yin     {
872*5fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_UNAVAILABLE );
873*5fdc4257SSteve Yin         sal_Bool isDecreaseFocusable = sal_False;
874*5fdc4257SSteve Yin         if( !((Role == MENU_ITEM) ||
875*5fdc4257SSteve Yin                 (Role == RADIO_MENU_ITEM) ||
876*5fdc4257SSteve Yin                 (Role == CHECK_MENU_ITEM)) )
877*5fdc4257SSteve Yin         {
878*5fdc4257SSteve Yin             if  ( Role == TOGGLE_BUTTON || Role == PUSH_BUTTON || BUTTON_DROPDOWN == Role)
879*5fdc4257SSteve Yin             {
880*5fdc4257SSteve Yin                 if(( m_pParentObj != NULL )&& (TOOL_BAR ==  m_pParentObj->m_accRole ) )
881*5fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
882*5fdc4257SSteve Yin                 else
883*5fdc4257SSteve Yin                     DecreaseState( FOCUSABLE );
884*5fdc4257SSteve Yin             }
885*5fdc4257SSteve Yin             else
886*5fdc4257SSteve Yin                 DecreaseState( FOCUSABLE );
887*5fdc4257SSteve Yin         }
888*5fdc4257SSteve Yin         else if( isShowing || isVisible )
889*5fdc4257SSteve Yin         {
890*5fdc4257SSteve Yin             IncreaseState( FOCUSABLE );
891*5fdc4257SSteve Yin         }
892*5fdc4257SSteve Yin     }
893*5fdc4257SSteve Yin 
894*5fdc4257SSteve Yin     if( m_pIMAcc )
895*5fdc4257SSteve Yin     {
896*5fdc4257SSteve Yin         switch(m_accRole)
897*5fdc4257SSteve Yin         {
898*5fdc4257SSteve Yin         case POPUP_MENU:
899*5fdc4257SSteve Yin         case MENU:
900*5fdc4257SSteve Yin             if( pContext->getAccessibleChildCount() > 0 )
901*5fdc4257SSteve Yin                 m_pIMAcc->IncreaseState( STATE_SYSTEM_HASPOPUP );
902*5fdc4257SSteve Yin             break;
903*5fdc4257SSteve Yin         case PASSWORD_TEXT:
904*5fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_PROTECTED );
905*5fdc4257SSteve Yin             break;
906*5fdc4257SSteve Yin         default:
907*5fdc4257SSteve Yin             break;
908*5fdc4257SSteve Yin         }
909*5fdc4257SSteve Yin     }
910*5fdc4257SSteve Yin 
911*5fdc4257SSteve Yin }
912*5fdc4257SSteve Yin /**
913*5fdc4257SSteve Yin    * update location information from uno to com
914*5fdc4257SSteve Yin    * @param
915*5fdc4257SSteve Yin    * @return
916*5fdc4257SSteve Yin    */
917*5fdc4257SSteve Yin void AccObject::UpdateLocation()
918*5fdc4257SSteve Yin {
919*5fdc4257SSteve Yin     if (!m_pIMAcc)
920*5fdc4257SSteve Yin     {
921*5fdc4257SSteve Yin         return;
922*5fdc4257SSteve Yin     }
923*5fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
924*5fdc4257SSteve Yin 
925*5fdc4257SSteve Yin     Reference< XAccessibleComponent > pRComponent(pContext,UNO_QUERY);
926*5fdc4257SSteve Yin     if( pRComponent.is() )
927*5fdc4257SSteve Yin     {
928*5fdc4257SSteve Yin         ::com::sun::star::awt::Point pCPoint = pRComponent->getLocationOnScreen();
929*5fdc4257SSteve Yin         ::com::sun::star::awt::Size pCSize = pRComponent->getSize();
930*5fdc4257SSteve Yin         Location tempLocation;
931*5fdc4257SSteve Yin         tempLocation.m_dLeft = pCPoint.X;
932*5fdc4257SSteve Yin         tempLocation.m_dTop =  pCPoint.Y;
933*5fdc4257SSteve Yin         tempLocation.m_dWidth = pCSize.Width;
934*5fdc4257SSteve Yin         tempLocation.m_dHeight = pCSize.Height;
935*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccLocation( tempLocation );
936*5fdc4257SSteve Yin     }
937*5fdc4257SSteve Yin 
938*5fdc4257SSteve Yin }
939*5fdc4257SSteve Yin 
940*5fdc4257SSteve Yin 
941*5fdc4257SSteve Yin /**
942*5fdc4257SSteve Yin    * Public method to mapping information between MSAA and UNO.
943*5fdc4257SSteve Yin    * @param
944*5fdc4257SSteve Yin    * @return If the method is correctly processed.
945*5fdc4257SSteve Yin    */
946*5fdc4257SSteve Yin sal_Bool AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
947*5fdc4257SSteve Yin {
948*5fdc4257SSteve Yin     if( NULL == m_pIMAcc || !m_xAccContextRef.is()  )
949*5fdc4257SSteve Yin     {
950*5fdc4257SSteve Yin         assert(false);
951*5fdc4257SSteve Yin         return sal_False;
952*5fdc4257SSteve Yin     }
953*5fdc4257SSteve Yin 
954*5fdc4257SSteve Yin     UpdateName();
955*5fdc4257SSteve Yin 
956*5fdc4257SSteve Yin     UpdateValue();
957*5fdc4257SSteve Yin 
958*5fdc4257SSteve Yin     UpdateActionDesc();
959*5fdc4257SSteve Yin 
960*5fdc4257SSteve Yin     UpdateRole();
961*5fdc4257SSteve Yin 
962*5fdc4257SSteve Yin     UpdateLocation();
963*5fdc4257SSteve Yin 
964*5fdc4257SSteve Yin     UpdateState();
965*5fdc4257SSteve Yin 
966*5fdc4257SSteve Yin     return sal_True;
967*5fdc4257SSteve Yin }
968*5fdc4257SSteve Yin 
969*5fdc4257SSteve Yin /*
970*5fdc4257SSteve Yin    * Add a child selected element.
971*5fdc4257SSteve Yin    * @param pAccObj Child object pointer.
972*5fdc4257SSteve Yin    * @return
973*5fdc4257SSteve Yin    */
974*5fdc4257SSteve Yin void AccObject::AddSelect( long index, AccObject* accObj)
975*5fdc4257SSteve Yin {
976*5fdc4257SSteve Yin     m_selectionList.insert(IAccSelectionList::value_type(index,accObj));
977*5fdc4257SSteve Yin }
978*5fdc4257SSteve Yin 
979*5fdc4257SSteve Yin IAccSelectionList& AccObject::GetSelection()
980*5fdc4257SSteve Yin {
981*5fdc4257SSteve Yin     return m_selectionList;
982*5fdc4257SSteve Yin }
983*5fdc4257SSteve Yin 
984*5fdc4257SSteve Yin 
985*5fdc4257SSteve Yin /**
986*5fdc4257SSteve Yin    * Set self to focus object in parant child list
987*5fdc4257SSteve Yin    * @param
988*5fdc4257SSteve Yin    * @return
989*5fdc4257SSteve Yin    */
990*5fdc4257SSteve Yin void AccObject::setFocus()
991*5fdc4257SSteve Yin {
992*5fdc4257SSteve Yin     if(m_pIMAcc)
993*5fdc4257SSteve Yin     {
994*5fdc4257SSteve Yin         IncreaseState(FOCUSED);
995*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccFocus(CHILDID_SELF);
996*5fdc4257SSteve Yin 
997*5fdc4257SSteve Yin         UpdateRole();
998*5fdc4257SSteve Yin     }
999*5fdc4257SSteve Yin }
1000*5fdc4257SSteve Yin 
1001*5fdc4257SSteve Yin /**
1002*5fdc4257SSteve Yin    * Unset self from focus object in parant child list.
1003*5fdc4257SSteve Yin    * @param
1004*5fdc4257SSteve Yin    * @return
1005*5fdc4257SSteve Yin    */
1006*5fdc4257SSteve Yin void AccObject::unsetFocus()
1007*5fdc4257SSteve Yin {
1008*5fdc4257SSteve Yin     if(m_pIMAcc)
1009*5fdc4257SSteve Yin     {
1010*5fdc4257SSteve Yin         DecreaseState( FOCUSED );
1011*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccFocus(UACC_NO_FOCUS);
1012*5fdc4257SSteve Yin     }
1013*5fdc4257SSteve Yin }
1014*5fdc4257SSteve Yin 
1015*5fdc4257SSteve Yin void AccObject::GetExpandedState( sal_Bool* isExpandable, sal_Bool* isExpanded)
1016*5fdc4257SSteve Yin {
1017*5fdc4257SSteve Yin     *isExpanded = sal_False;
1018*5fdc4257SSteve Yin     *isExpandable = sal_False;
1019*5fdc4257SSteve Yin 
1020*5fdc4257SSteve Yin     if( !m_xAccContextRef.is() )
1021*5fdc4257SSteve Yin     {
1022*5fdc4257SSteve Yin         return;
1023*5fdc4257SSteve Yin     }
1024*5fdc4257SSteve Yin     Reference< XAccessibleStateSet > pRState = m_xAccContextRef->getAccessibleStateSet();
1025*5fdc4257SSteve Yin     if( !pRState.is() )
1026*5fdc4257SSteve Yin     {
1027*5fdc4257SSteve Yin         return;
1028*5fdc4257SSteve Yin     }
1029*5fdc4257SSteve Yin 
1030*5fdc4257SSteve Yin     Sequence<short> pStates = pRState->getStates();
1031*5fdc4257SSteve Yin     int count = pStates.getLength();
1032*5fdc4257SSteve Yin 
1033*5fdc4257SSteve Yin     for( int iIndex = 0;iIndex < count;iIndex++ )
1034*5fdc4257SSteve Yin     {
1035*5fdc4257SSteve Yin         if( EXPANDED == pStates[iIndex]  )
1036*5fdc4257SSteve Yin         {
1037*5fdc4257SSteve Yin             *isExpanded = sal_True;
1038*5fdc4257SSteve Yin         }
1039*5fdc4257SSteve Yin         else if( EXPANDABLE == pStates[iIndex]  )
1040*5fdc4257SSteve Yin         {
1041*5fdc4257SSteve Yin             *isExpandable = sal_True;
1042*5fdc4257SSteve Yin         }
1043*5fdc4257SSteve Yin     }
1044*5fdc4257SSteve Yin }
1045*5fdc4257SSteve Yin 
1046*5fdc4257SSteve Yin void AccObject::NotifyDestroy(sal_Bool ifDelete)
1047*5fdc4257SSteve Yin {
1048*5fdc4257SSteve Yin     m_bShouldDestroy=ifDelete;
1049*5fdc4257SSteve Yin     if(m_pIMAcc)
1050*5fdc4257SSteve Yin         m_pIMAcc->NotifyDestroy(m_bShouldDestroy);
1051*5fdc4257SSteve Yin }
1052*5fdc4257SSteve Yin 
1053*5fdc4257SSteve Yin void AccObject::SetParentObj(AccObject* pParentAccObj)
1054*5fdc4257SSteve Yin {
1055*5fdc4257SSteve Yin     m_pParentObj = pParentAccObj;
1056*5fdc4257SSteve Yin 
1057*5fdc4257SSteve Yin     if(m_pIMAcc)
1058*5fdc4257SSteve Yin     {
1059*5fdc4257SSteve Yin         if(m_pParentObj)
1060*5fdc4257SSteve Yin         {
1061*5fdc4257SSteve Yin             m_pIMAcc->Put_XAccParent(m_pParentObj->GetIMAccessible());
1062*5fdc4257SSteve Yin         }
1063*5fdc4257SSteve Yin         else
1064*5fdc4257SSteve Yin         {
1065*5fdc4257SSteve Yin             m_pIMAcc->Put_XAccParent(NULL);
1066*5fdc4257SSteve Yin         }
1067*5fdc4257SSteve Yin     }
1068*5fdc4257SSteve Yin }
1069*5fdc4257SSteve Yin //ResID means ChildID in MSAA
1070*5fdc4257SSteve Yin void AccObject::SetResID(long id)
1071*5fdc4257SSteve Yin {
1072*5fdc4257SSteve Yin     m_resID = id;
1073*5fdc4257SSteve Yin     if(m_pIMAcc)
1074*5fdc4257SSteve Yin         m_pIMAcc->Put_XAccChildID(m_resID);
1075*5fdc4257SSteve Yin }
1076*5fdc4257SSteve Yin //return COM interface in acc object
1077*5fdc4257SSteve Yin IMAccessible*  AccObject::GetIMAccessible()
1078*5fdc4257SSteve Yin {
1079*5fdc4257SSteve Yin     return m_pIMAcc;
1080*5fdc4257SSteve Yin }
1081*5fdc4257SSteve Yin 
1082*5fdc4257SSteve Yin Reference < XAccessible > AccObject::GetXAccessible()
1083*5fdc4257SSteve Yin {
1084*5fdc4257SSteve Yin     return m_xAccRef;
1085*5fdc4257SSteve Yin }
1086*5fdc4257SSteve Yin 
1087*5fdc4257SSteve Yin void AccObject::SetParentHWND(HWND hWnd)
1088*5fdc4257SSteve Yin {
1089*5fdc4257SSteve Yin     m_pParantID = hWnd;
1090*5fdc4257SSteve Yin }
1091*5fdc4257SSteve Yin void AccObject::SetListener( AccEventListener* Listener )
1092*5fdc4257SSteve Yin {
1093*5fdc4257SSteve Yin     m_accListener = Listener;
1094*5fdc4257SSteve Yin }
1095*5fdc4257SSteve Yin AccEventListener* AccObject::getListener()
1096*5fdc4257SSteve Yin {
1097*5fdc4257SSteve Yin     return m_accListener;
1098*5fdc4257SSteve Yin }
1099*5fdc4257SSteve Yin 
1100*5fdc4257SSteve Yin long AccObject::GetResID()
1101*5fdc4257SSteve Yin {
1102*5fdc4257SSteve Yin     return m_resID;
1103*5fdc4257SSteve Yin }
1104*5fdc4257SSteve Yin 
1105*5fdc4257SSteve Yin HWND AccObject::GetParentHWND()
1106*5fdc4257SSteve Yin {
1107*5fdc4257SSteve Yin     return m_pParantID;
1108*5fdc4257SSteve Yin }
1109*5fdc4257SSteve Yin 
1110*5fdc4257SSteve Yin AccObject* AccObject::GetParentObj()
1111*5fdc4257SSteve Yin {
1112*5fdc4257SSteve Yin     return m_pParentObj;
1113*5fdc4257SSteve Yin }
1114*5fdc4257SSteve Yin sal_Bool  AccObject::ifShouldDestroy()
1115*5fdc4257SSteve Yin {
1116*5fdc4257SSteve Yin     return m_bShouldDestroy;
1117*5fdc4257SSteve Yin }
1118