1*3a700b0aSSteve Yin /**************************************************************
2*3a700b0aSSteve Yin  *
3*3a700b0aSSteve Yin  * Licensed to the Apache Software Foundation (ASF) under one
4*3a700b0aSSteve Yin  * or more contributor license agreements.  See the NOTICE file
5*3a700b0aSSteve Yin  * distributed with this work for additional information
6*3a700b0aSSteve Yin  * regarding copyright ownership.  The ASF licenses this file
7*3a700b0aSSteve Yin  * to you under the Apache License, Version 2.0 (the
8*3a700b0aSSteve Yin  * "License"); you may not use this file except in compliance
9*3a700b0aSSteve Yin  * with the License.  You may obtain a copy of the License at
10*3a700b0aSSteve Yin  *
11*3a700b0aSSteve Yin  *   http://www.apache.org/licenses/LICENSE-2.0
12*3a700b0aSSteve Yin  *
13*3a700b0aSSteve Yin  * Unless required by applicable law or agreed to in writing,
14*3a700b0aSSteve Yin  * software distributed under the License is distributed on an
15*3a700b0aSSteve Yin  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3a700b0aSSteve Yin  * KIND, either express or implied.  See the License for the
17*3a700b0aSSteve Yin  * specific language governing permissions and limitations
18*3a700b0aSSteve Yin  * under the License.
19*3a700b0aSSteve Yin  *
20*3a700b0aSSteve Yin  *************************************************************/
215fdc4257SSteve Yin 
225fdc4257SSteve Yin #include <com/sun/star/uno/Sequence.h>
235fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
245fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleRole.hpp>
255fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleValue.hpp>
265fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
275fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleText.hpp>
285fdc4257SSteve Yin 
295fdc4257SSteve Yin #include <stdlib.h>
305fdc4257SSteve Yin #include <memory.h>
315fdc4257SSteve Yin #include <stdio.h>
325fdc4257SSteve Yin #include <memory.h>
335fdc4257SSteve Yin #include <algorithm>
345fdc4257SSteve Yin #include <assert.h>
355fdc4257SSteve Yin 
365fdc4257SSteve Yin #include "AccObject.hxx"
375fdc4257SSteve Yin #include "AccEventListener.hxx"
385fdc4257SSteve Yin #include "UAccCOM_i.c"
395fdc4257SSteve Yin #include "AccResource.hxx"
405fdc4257SSteve Yin #include "AccessibleRole.h"
41*3a700b0aSSteve Yin 
42*3a700b0aSSteve Yin #include "act.hxx"
43*3a700b0aSSteve Yin 
445fdc4257SSteve Yin 
455fdc4257SSteve Yin using namespace std;
465fdc4257SSteve Yin using namespace com::sun::star::uno;
475fdc4257SSteve Yin using namespace com::sun::star::accessibility;
485fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleRole;
495fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleStateType;
505fdc4257SSteve Yin 
515fdc4257SSteve Yin 
525fdc4257SSteve Yin /**
535fdc4257SSteve Yin    * Constructor.
545fdc4257SSteve Yin    * @param pXAcc Uno XAccessible interface of control.
555fdc4257SSteve Yin    * @param Agent The agent kept in all listeners,it's the sole interface by which
565fdc4257SSteve Yin    *              listener communicate with windows manager.
575fdc4257SSteve Yin    * @param listener listener that registers in UNO system.
585fdc4257SSteve Yin    * @return.
595fdc4257SSteve Yin    */
605fdc4257SSteve Yin AccObject::AccObject(XAccessible* pAcc,AccObjectManagerAgent* pAgent ,AccEventListener* listener) :
615fdc4257SSteve Yin         m_pIMAcc	(NULL),
625fdc4257SSteve Yin         m_resID		(NULL),
635fdc4257SSteve Yin         m_pParantID	(NULL),
645fdc4257SSteve Yin         m_pParentObj(NULL),
655fdc4257SSteve Yin         m_accListener (listener),
665fdc4257SSteve Yin         m_bShouldDestroy(sal_False),
675fdc4257SSteve Yin         m_xAccRef( pAcc )
685fdc4257SSteve Yin {
695fdc4257SSteve Yin     sal_Bool bRet = ImplInitilizeCreateObj();
705fdc4257SSteve Yin 
715fdc4257SSteve Yin     m_xAccContextRef = m_xAccRef->getAccessibleContext();
725fdc4257SSteve Yin     m_xAccActionRef = Reference< XAccessibleAction > (m_xAccContextRef,UNO_QUERY);
735fdc4257SSteve Yin     m_accRole = m_xAccContextRef -> getAccessibleRole();
745fdc4257SSteve Yin     if( m_pIMAcc )
755fdc4257SSteve Yin     {
765fdc4257SSteve Yin         m_pIMAcc->SetXAccessible((long) m_xAccRef.get());
775fdc4257SSteve Yin         m_pIMAcc->Put_XAccAgent((long)pAgent);
785fdc4257SSteve Yin         m_pIMAcc->SetDefaultAction((long)m_xAccActionRef.get());
795fdc4257SSteve Yin     }
805fdc4257SSteve Yin }
815fdc4257SSteve Yin /**
825fdc4257SSteve Yin    * Destructor.
835fdc4257SSteve Yin    * @param
845fdc4257SSteve Yin    * @return
855fdc4257SSteve Yin    */
865fdc4257SSteve Yin AccObject::~AccObject()
875fdc4257SSteve Yin {
885fdc4257SSteve Yin     m_pIMAcc = NULL;
895fdc4257SSteve Yin     m_xAccRef = NULL;
905fdc4257SSteve Yin     m_xAccActionRef = NULL;
915fdc4257SSteve Yin     m_xAccContextRef = NULL;
925fdc4257SSteve Yin }
935fdc4257SSteve Yin 
945fdc4257SSteve Yin 
955fdc4257SSteve Yin 
965fdc4257SSteve Yin /**
975fdc4257SSteve Yin    * Insert a child element.
985fdc4257SSteve Yin    * @param pChild Child element that should be inserted into child list.
995fdc4257SSteve Yin    * @param pos Insert postion.
1005fdc4257SSteve Yin    * @return
1015fdc4257SSteve Yin    */
1025fdc4257SSteve Yin void AccObject::InsertChild( AccObject* pChild,short pos )
1035fdc4257SSteve Yin {
1045fdc4257SSteve Yin 
1055fdc4257SSteve Yin     std::vector<AccObject*>::iterator iter;
1065fdc4257SSteve Yin     iter = std::find(m_childrenList.begin(),m_childrenList.end(),pChild);
1075fdc4257SSteve Yin     if(iter!=m_childrenList.end())
1085fdc4257SSteve Yin         return;
1095fdc4257SSteve Yin     if(LAST_CHILD==pos)
1105fdc4257SSteve Yin     {
1115fdc4257SSteve Yin         m_childrenList.push_back(pChild);
1125fdc4257SSteve Yin     }
1135fdc4257SSteve Yin     else
1145fdc4257SSteve Yin     {
1155fdc4257SSteve Yin         std::vector<AccObject*>::iterator iter=m_childrenList.begin()+pos;
1165fdc4257SSteve Yin         m_childrenList.insert(iter,pChild);
1175fdc4257SSteve Yin     }
1185fdc4257SSteve Yin 
1195fdc4257SSteve Yin     pChild->SetParentObj(this);
1205fdc4257SSteve Yin }
1215fdc4257SSteve Yin 
1225fdc4257SSteve Yin /**
1235fdc4257SSteve Yin    * Delete a child element
1245fdc4257SSteve Yin    * @param pChild Child element that should be inserted into child list.
1255fdc4257SSteve Yin    * @param pos Insert postion.
1265fdc4257SSteve Yin    * @return
1275fdc4257SSteve Yin    */
1285fdc4257SSteve Yin void AccObject::DeleteChild( AccObject* pChild )
1295fdc4257SSteve Yin {
1305fdc4257SSteve Yin     std::vector<AccObject*>::iterator iter;
1315fdc4257SSteve Yin     iter = std::find(m_childrenList.begin(),m_childrenList.end(),pChild);
1325fdc4257SSteve Yin     if(iter!=m_childrenList.end())
1335fdc4257SSteve Yin     {
1345fdc4257SSteve Yin         m_childrenList.erase(iter);
1355fdc4257SSteve Yin         if(m_pIMAcc)
1365fdc4257SSteve Yin             pChild->SetParentObj(NULL);
1375fdc4257SSteve Yin     }
1385fdc4257SSteve Yin }
1395fdc4257SSteve Yin 
1405fdc4257SSteve Yin /**
1415fdc4257SSteve Yin    * In order to windows API WindowFromAccessibleObject,we sometimes to set a pure
1425fdc4257SSteve Yin    * top window accessible object created by windows system as top ancestor.
1435fdc4257SSteve Yin    * @param.
1445fdc4257SSteve Yin    * @return
1455fdc4257SSteve Yin    */
1465fdc4257SSteve Yin void AccObject::UpdateValidWindow()
1475fdc4257SSteve Yin {
1485fdc4257SSteve Yin     if(m_pIMAcc)
1495fdc4257SSteve Yin         m_pIMAcc->Put_XAccWindowHandle(m_pParantID);
1505fdc4257SSteve Yin }
1515fdc4257SSteve Yin 
1525fdc4257SSteve Yin /**
1535fdc4257SSteve Yin    * Translate all UNO basic information into MSAA com information.
1545fdc4257SSteve Yin    * @param
1555fdc4257SSteve Yin    * @return If the method is correctly processed.
1565fdc4257SSteve Yin    */
1575fdc4257SSteve Yin sal_Bool AccObject::ImplInitilizeCreateObj()
1585fdc4257SSteve Yin {
159*3a700b0aSSteve Yin 	HRESULT hr = CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL ,
1605fdc4257SSteve Yin                                    IID_IMAccessible,
161*3a700b0aSSteve Yin                                    (void **)&m_pIMAcc);
162*3a700b0aSSteve Yin 
163*3a700b0aSSteve Yin     if ( S_OK != hr )
1645fdc4257SSteve Yin     {
1655fdc4257SSteve Yin         return sal_False;
1665fdc4257SSteve Yin     }
1675fdc4257SSteve Yin 
1685fdc4257SSteve Yin     return sal_True;
1695fdc4257SSteve Yin }
1705fdc4257SSteve Yin 
1715fdc4257SSteve Yin /**
1725fdc4257SSteve Yin    * Update name property to com object.
1735fdc4257SSteve Yin    * @param
1745fdc4257SSteve Yin    * @return
1755fdc4257SSteve Yin    */
1765fdc4257SSteve Yin void  AccObject::UpdateName( )
1775fdc4257SSteve Yin {
1785fdc4257SSteve Yin     if (!m_pIMAcc)
1795fdc4257SSteve Yin     {
1805fdc4257SSteve Yin         return;
1815fdc4257SSteve Yin     }
1825fdc4257SSteve Yin 
1835fdc4257SSteve Yin     if( ( TEXT_FRAME == m_accRole   ) && ( m_pParentObj !=NULL )&& ( SCROLL_PANE == m_pParentObj -> m_accRole ) )
1845fdc4257SSteve Yin         m_pIMAcc->Put_XAccName( m_pParentObj->m_xAccContextRef->getAccessibleName().getStr() );
1855fdc4257SSteve Yin 	//IAccessibility2 Implementation 2009-----
1865fdc4257SSteve Yin     if ( PARAGRAPH == m_accRole)
1875fdc4257SSteve Yin     {
1885fdc4257SSteve Yin     	::rtl::OUString emptyStr = ::rtl::OUString::createFromAscii("");
1895fdc4257SSteve Yin     	m_pIMAcc->Put_XAccName(emptyStr.getStr());
1905fdc4257SSteve Yin     }
1915fdc4257SSteve Yin 	//-----IAccessibility2 Implementation 2009
1925fdc4257SSteve Yin     else
1935fdc4257SSteve Yin         m_pIMAcc->Put_XAccName(m_xAccContextRef->getAccessibleName().getStr());
1945fdc4257SSteve Yin 
1955fdc4257SSteve Yin     return ;
1965fdc4257SSteve Yin }
1975fdc4257SSteve Yin /**
1985fdc4257SSteve Yin    * Update description property to com object.
1995fdc4257SSteve Yin    * no content for update description
2005fdc4257SSteve Yin    * @param
2015fdc4257SSteve Yin    * @return
2025fdc4257SSteve Yin    */
2035fdc4257SSteve Yin void AccObject::UpdateDescription()
2045fdc4257SSteve Yin {
2055fdc4257SSteve Yin     if (!m_pIMAcc)
2065fdc4257SSteve Yin     {
2075fdc4257SSteve Yin         return;
2085fdc4257SSteve Yin     }
2095fdc4257SSteve Yin 
2105fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription(m_xAccContextRef->getAccessibleDescription().getStr());
2115fdc4257SSteve Yin     return ;
2125fdc4257SSteve Yin }
2135fdc4257SSteve Yin 
2145fdc4257SSteve Yin /**
2155fdc4257SSteve Yin    * Update default action property to com object.
2165fdc4257SSteve Yin    * @param
2175fdc4257SSteve Yin    * @return
2185fdc4257SSteve Yin    */
2195fdc4257SSteve Yin void  AccObject::UpdateAction()
2205fdc4257SSteve Yin {
2215fdc4257SSteve Yin     m_xAccActionRef = Reference< XAccessibleAction > (m_xAccContextRef,UNO_QUERY);
2225fdc4257SSteve Yin 
2235fdc4257SSteve Yin     if( m_xAccActionRef.is() && m_pIMAcc )
2245fdc4257SSteve Yin     {
2255fdc4257SSteve Yin         if( m_xAccActionRef->getAccessibleActionCount() > 0 )
2265fdc4257SSteve Yin         {
2275fdc4257SSteve Yin             UpdateDefaultAction( );
2285fdc4257SSteve Yin             m_pIMAcc->SetDefaultAction((long)m_xAccActionRef.get());
2295fdc4257SSteve Yin         }
2305fdc4257SSteve Yin     }
2315fdc4257SSteve Yin }
2325fdc4257SSteve Yin 
2335fdc4257SSteve Yin /**
2345fdc4257SSteve Yin    * Update value property to com object.
2355fdc4257SSteve Yin    * @param
2365fdc4257SSteve Yin    * @return
2375fdc4257SSteve Yin    */
2385fdc4257SSteve Yin void AccObject::UpdateValue()
2395fdc4257SSteve Yin {
2405fdc4257SSteve Yin     if( NULL == m_pIMAcc  || !m_xAccContextRef.is() )
2415fdc4257SSteve Yin     {
2425fdc4257SSteve Yin         assert(false);
2435fdc4257SSteve Yin         return ;
2445fdc4257SSteve Yin     }
2455fdc4257SSteve Yin 
2465fdc4257SSteve Yin     Reference< XAccessibleValue > pRValue(m_xAccContextRef.get(),UNO_QUERY);
2475fdc4257SSteve Yin     Any pAny;
2485fdc4257SSteve Yin     if( pRValue.is() )
2495fdc4257SSteve Yin     {
2505fdc4257SSteve Yin         pAny = pRValue->getCurrentValue();
2515fdc4257SSteve Yin     }
2525fdc4257SSteve Yin 
2535fdc4257SSteve Yin     SetValue( pAny );
2545fdc4257SSteve Yin }
2555fdc4257SSteve Yin 
2565fdc4257SSteve Yin /**
2575fdc4257SSteve Yin    * Set special default action description string via UNO role.
2585fdc4257SSteve Yin    * @param Role UNO role
2595fdc4257SSteve Yin    * @return
2605fdc4257SSteve Yin    */
2615fdc4257SSteve Yin void AccObject::UpdateDefaultAction( )
2625fdc4257SSteve Yin {
2635fdc4257SSteve Yin     if(!m_xAccActionRef.is())
2645fdc4257SSteve Yin         return ;
2655fdc4257SSteve Yin 
2665fdc4257SSteve Yin     switch(m_accRole)
2675fdc4257SSteve Yin     {
2685fdc4257SSteve Yin     case PUSH_BUTTON:
2695fdc4257SSteve Yin     case TOGGLE_BUTTON:
2705fdc4257SSteve Yin     case RADIO_BUTTON:
2715fdc4257SSteve Yin     case MENU_ITEM:
2725fdc4257SSteve Yin     case RADIO_MENU_ITEM:
2735fdc4257SSteve Yin     case CHECK_MENU_ITEM:
2745fdc4257SSteve Yin     case LIST_ITEM:
2755fdc4257SSteve Yin     case CHECK_BOX:
2765fdc4257SSteve Yin     case TREE_ITEM:
2775fdc4257SSteve Yin     case BUTTON_DROPDOWN:
2785fdc4257SSteve Yin         m_pIMAcc->Put_ActionDescription( m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr() );
2795fdc4257SSteve Yin         return;
2805fdc4257SSteve Yin     }
2815fdc4257SSteve Yin }
2825fdc4257SSteve Yin 
2835fdc4257SSteve Yin /**
2845fdc4257SSteve Yin    * Set value property via pAny.
2855fdc4257SSteve Yin    * @param pAny New value.
2865fdc4257SSteve Yin    * @return
2875fdc4257SSteve Yin    */
2885fdc4257SSteve Yin void  AccObject::SetValue( Any pAny )
2895fdc4257SSteve Yin {
2905fdc4257SSteve Yin     unsigned short pUNumberString[100];
2915fdc4257SSteve Yin     memset( pUNumberString, 0 , sizeof( pUNumberString) );
2925fdc4257SSteve Yin 
2935fdc4257SSteve Yin     if( NULL == m_pIMAcc || !m_xAccContextRef.is() )
2945fdc4257SSteve Yin     {
2955fdc4257SSteve Yin         assert(false);
2965fdc4257SSteve Yin         return ;
2975fdc4257SSteve Yin     }
2985fdc4257SSteve Yin     Reference< XAccessibleText > pRText(m_xAccContextRef,UNO_QUERY);
2995fdc4257SSteve Yin     ::rtl::OUString val;
3005fdc4257SSteve Yin     int index = 0 ;
3015fdc4257SSteve Yin     switch(m_accRole)
3025fdc4257SSteve Yin     {
3035fdc4257SSteve Yin     case SPIN_BOX:
3045fdc4257SSteve Yin         // 3. date editor's msaa value should be the same as spinbox
3055fdc4257SSteve Yin     case DATE_EDITOR:
3065fdc4257SSteve Yin     case TEXT:
3075fdc4257SSteve Yin     case PARAGRAPH:
3085fdc4257SSteve Yin     case HEADING:
3095fdc4257SSteve Yin 
3105fdc4257SSteve Yin         if(pRText.get())
3115fdc4257SSteve Yin         {
3125fdc4257SSteve Yin             val = pRText->getText();
3135fdc4257SSteve Yin         }
3145fdc4257SSteve Yin         m_pIMAcc->Put_XAccValue( val.getStr() );
3155fdc4257SSteve Yin         break;
3165fdc4257SSteve Yin     case TREE_ITEM:
3175fdc4257SSteve Yin 	//IAccessibility2 Implementation 2009-----
3185fdc4257SSteve Yin     //case CHECK_BOX:	//Commented by Li Xing to disable the value for general checkbox
3195fdc4257SSteve Yin     case COMBO_BOX:
3205fdc4257SSteve Yin     case TABLE_CELL:
3215fdc4257SSteve Yin     case NOTE:
3225fdc4257SSteve Yin     case SCROLL_BAR:
3235fdc4257SSteve Yin         m_pIMAcc->Put_XAccValue( GetMAccessibleValueFromAny(pAny).getStr() );
3245fdc4257SSteve Yin         break ;
3255fdc4257SSteve Yin 	// Added by Li Xing, only the checkbox in tree should have the value.
3265fdc4257SSteve Yin 	case CHECK_BOX:
3275fdc4257SSteve Yin 		if( ( m_pParentObj !=NULL ) && (TREE == m_pParentObj->m_accRole || TREE_ITEM == m_pParentObj->m_accRole ))
3285fdc4257SSteve Yin 	        m_pIMAcc->Put_XAccValue( GetMAccessibleValueFromAny(pAny).getStr() );
3295fdc4257SSteve Yin 	//-----IAccessibility2 Implementation 2009
3305fdc4257SSteve Yin 		break;
3315fdc4257SSteve Yin     default:
3325fdc4257SSteve Yin         break;
3335fdc4257SSteve Yin     }
3345fdc4257SSteve Yin 
3355fdc4257SSteve Yin     return;
3365fdc4257SSteve Yin 
3375fdc4257SSteve Yin 
3385fdc4257SSteve Yin }
3395fdc4257SSteve Yin ::rtl::OUString AccObject::GetMAccessibleValueFromAny(Any pAny)
3405fdc4257SSteve Yin {
3415fdc4257SSteve Yin     ::rtl::OUString strValue;
3425fdc4257SSteve Yin 
3435fdc4257SSteve Yin     if(NULL == m_pIMAcc)
3445fdc4257SSteve Yin         return strValue;
3455fdc4257SSteve Yin 
3465fdc4257SSteve Yin     if(pAny.getValueType() == getCppuType( (sal_uInt16 *)0 ) )
3475fdc4257SSteve Yin     {
3485fdc4257SSteve Yin         sal_uInt16 val;
3495fdc4257SSteve Yin         if (pAny >>= val)
3505fdc4257SSteve Yin         {
3515fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf((sal_Int32)val);
3525fdc4257SSteve Yin 
3535fdc4257SSteve Yin         }
3545fdc4257SSteve Yin     }
3555fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (::rtl::OUString *)0 ) )
3565fdc4257SSteve Yin     {
3575fdc4257SSteve Yin 
3585fdc4257SSteve Yin         pAny >>= strValue ;
3595fdc4257SSteve Yin 
3605fdc4257SSteve Yin     }
3615fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (Sequence< ::rtl::OUString > *)0 ) )
3625fdc4257SSteve Yin     {
3635fdc4257SSteve Yin         Sequence< ::rtl::OUString > val;
3645fdc4257SSteve Yin         if (pAny >>= val)
3655fdc4257SSteve Yin         {
3665fdc4257SSteve Yin 
3675fdc4257SSteve Yin             int count = val.getLength();
3685fdc4257SSteve Yin 
3695fdc4257SSteve Yin             for( int iIndex = 0;iIndex < count;iIndex++ )
3705fdc4257SSteve Yin             {
3715fdc4257SSteve Yin                 strValue += val[iIndex];
3725fdc4257SSteve Yin             }
3735fdc4257SSteve Yin 
3745fdc4257SSteve Yin         }
3755fdc4257SSteve Yin     }
3765fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (double *)0 ) )
3775fdc4257SSteve Yin     {
3785fdc4257SSteve Yin         double val;
3795fdc4257SSteve Yin         if (pAny >>= val)
3805fdc4257SSteve Yin         {
3815fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf(val);
3825fdc4257SSteve Yin         }
3835fdc4257SSteve Yin     }
3845fdc4257SSteve Yin     else if(pAny.getValueType() == getCppuType( (sal_Int32 *)0 ) )
3855fdc4257SSteve Yin     {
3865fdc4257SSteve Yin         sal_Int32 val;
3875fdc4257SSteve Yin         if (pAny >>= val)
3885fdc4257SSteve Yin         {
3895fdc4257SSteve Yin             strValue=::rtl::OUString::valueOf(val);
3905fdc4257SSteve Yin         }
3915fdc4257SSteve Yin     }
3925fdc4257SSteve Yin     else if (pAny.getValueType() == getCppuType( (com::sun::star::accessibility::TextSegment *)0 ) )
3935fdc4257SSteve Yin     {
3945fdc4257SSteve Yin         com::sun::star::accessibility::TextSegment val;
3955fdc4257SSteve Yin         if (pAny >>= val)
3965fdc4257SSteve Yin         {
3975fdc4257SSteve Yin             ::rtl::OUString realVal(val.SegmentText);
3985fdc4257SSteve Yin             strValue = realVal;
3995fdc4257SSteve Yin 
4005fdc4257SSteve Yin         }
4015fdc4257SSteve Yin     }
4025fdc4257SSteve Yin 
4035fdc4257SSteve Yin     return strValue;
4045fdc4257SSteve Yin }
4055fdc4257SSteve Yin /**
4065fdc4257SSteve Yin    * Set name property via pAny.
4075fdc4257SSteve Yin    * @param pAny New accessible name.
4085fdc4257SSteve Yin    * @return
4095fdc4257SSteve Yin    */
4105fdc4257SSteve Yin void  AccObject::SetName( Any pAny)
4115fdc4257SSteve Yin {
4125fdc4257SSteve Yin     if( NULL == m_pIMAcc )
4135fdc4257SSteve Yin         return ;
4145fdc4257SSteve Yin 
4155fdc4257SSteve Yin     m_pIMAcc->Put_XAccName( GetMAccessibleValueFromAny(pAny).getStr() );
4165fdc4257SSteve Yin 
4175fdc4257SSteve Yin }
4185fdc4257SSteve Yin 
4195fdc4257SSteve Yin /**
4205fdc4257SSteve Yin    * Set description property via pAny.
4215fdc4257SSteve Yin    * @param pAny New accessible description.
4225fdc4257SSteve Yin    * @return
4235fdc4257SSteve Yin    */
4245fdc4257SSteve Yin void  AccObject::SetDescription( Any pAny )
4255fdc4257SSteve Yin {
4265fdc4257SSteve Yin     if( NULL == m_pIMAcc )
4275fdc4257SSteve Yin         return ;
4285fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription( GetMAccessibleValueFromAny(pAny).getStr() );
4295fdc4257SSteve Yin }
4305fdc4257SSteve Yin 
4315fdc4257SSteve Yin /**
4325fdc4257SSteve Yin    * Set role property via pAny
4335fdc4257SSteve Yin    * @param Role New accessible role.
4345fdc4257SSteve Yin    * @return
4355fdc4257SSteve Yin    */
4365fdc4257SSteve Yin void  AccObject::SetRole( short Role )
4375fdc4257SSteve Yin {
4385fdc4257SSteve Yin     if( NULL == m_pIMAcc )
4395fdc4257SSteve Yin         return ;
4405fdc4257SSteve Yin     m_pIMAcc->Put_XAccRole( Role );
4415fdc4257SSteve Yin }
4425fdc4257SSteve Yin 
4435fdc4257SSteve Yin /**
4445fdc4257SSteve Yin * Get role property via pAny
4455fdc4257SSteve Yin * @param
4465fdc4257SSteve Yin * @return accessible role
4475fdc4257SSteve Yin */
4485fdc4257SSteve Yin short AccObject::GetRole() const
4495fdc4257SSteve Yin {
4505fdc4257SSteve Yin     return m_accRole;
4515fdc4257SSteve Yin }
4525fdc4257SSteve Yin 
4535fdc4257SSteve Yin /**
4545fdc4257SSteve Yin    * Get MSAA state from UNO state
4555fdc4257SSteve Yin    * @Role xState UNO state.
4565fdc4257SSteve Yin    * @return
4575fdc4257SSteve Yin    */
4585fdc4257SSteve Yin DWORD AccObject::GetMSAAStateFromUNO(short xState)
4595fdc4257SSteve Yin {
4605fdc4257SSteve Yin     DWORD IState = UNO_MSAA_UNMAPPING;
4615fdc4257SSteve Yin 
4625fdc4257SSteve Yin     if( !m_xAccContextRef.is() )
4635fdc4257SSteve Yin     {
4645fdc4257SSteve Yin         assert(false);
4655fdc4257SSteve Yin         return IState;
4665fdc4257SSteve Yin     }
4675fdc4257SSteve Yin     short Role = m_accRole;
4685fdc4257SSteve Yin 
4695fdc4257SSteve Yin     switch( xState )
4705fdc4257SSteve Yin     {
4715fdc4257SSteve Yin     case  BUSY:
4725fdc4257SSteve Yin         IState = STATE_SYSTEM_BUSY;
4735fdc4257SSteve Yin         break;
4745fdc4257SSteve Yin     case  CHECKED:
4755fdc4257SSteve Yin         if( Role == PUSH_BUTTON || Role == TOGGLE_BUTTON )
4765fdc4257SSteve Yin         {
4775fdc4257SSteve Yin             IState = STATE_SYSTEM_PRESSED;
4785fdc4257SSteve Yin         }
4795fdc4257SSteve Yin         else
4805fdc4257SSteve Yin             IState = STATE_SYSTEM_CHECKED;
4815fdc4257SSteve Yin         break;
4825fdc4257SSteve Yin     case  DEFUNC:
4835fdc4257SSteve Yin         IState = STATE_SYSTEM_UNAVAILABLE;
4845fdc4257SSteve Yin         break;
4855fdc4257SSteve Yin     case  EXPANDED:
4865fdc4257SSteve Yin         IState = STATE_SYSTEM_EXPANDED;
4875fdc4257SSteve Yin         break;
4885fdc4257SSteve Yin     case  FOCUSABLE:
4895fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSABLE;
4905fdc4257SSteve Yin         break;
4915fdc4257SSteve Yin     case  FOCUSED:
4925fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSED;
4935fdc4257SSteve Yin         break;
4945fdc4257SSteve Yin     case  INDETERMINATE:
4955fdc4257SSteve Yin         IState = STATE_SYSTEM_MIXED;
4965fdc4257SSteve Yin         break;
4975fdc4257SSteve Yin     case  MULTI_SELECTABLE:
4985fdc4257SSteve Yin         IState = STATE_SYSTEM_MULTISELECTABLE;
4995fdc4257SSteve Yin         break;
5005fdc4257SSteve Yin     case  PRESSED:
5015fdc4257SSteve Yin         IState = STATE_SYSTEM_PRESSED;
5025fdc4257SSteve Yin         break;
5035fdc4257SSteve Yin     case  RESIZABLE:
5045fdc4257SSteve Yin         IState = STATE_SYSTEM_SIZEABLE;
5055fdc4257SSteve Yin         break;
5065fdc4257SSteve Yin     case  SELECTABLE:
5075fdc4257SSteve Yin         if( m_accRole == MENU || m_accRole == MENU_ITEM)
5085fdc4257SSteve Yin         {
5095fdc4257SSteve Yin             IState = UNO_MSAA_UNMAPPING;
5105fdc4257SSteve Yin         }
5115fdc4257SSteve Yin         else
5125fdc4257SSteve Yin         {
5135fdc4257SSteve Yin             IState = STATE_SYSTEM_SELECTABLE;
5145fdc4257SSteve Yin         }
5155fdc4257SSteve Yin         break;
5165fdc4257SSteve Yin     case  SELECTED:
5175fdc4257SSteve Yin         if( m_accRole == MENU || m_accRole == MENU_ITEM )
5185fdc4257SSteve Yin         {
5195fdc4257SSteve Yin             IState = UNO_MSAA_UNMAPPING;
5205fdc4257SSteve Yin         }
5215fdc4257SSteve Yin         else
5225fdc4257SSteve Yin         {
5235fdc4257SSteve Yin             IState = STATE_SYSTEM_SELECTED;
5245fdc4257SSteve Yin         }
5255fdc4257SSteve Yin         break;
5265fdc4257SSteve Yin     case  ARMED:
5275fdc4257SSteve Yin         IState = STATE_SYSTEM_FOCUSED;
5285fdc4257SSteve Yin         break;
5295fdc4257SSteve Yin     case  EXPANDABLE:
5305fdc4257SSteve Yin         {
5315fdc4257SSteve Yin             sal_Bool isExpanded = sal_True;
5325fdc4257SSteve Yin             sal_Bool isExpandable = sal_True;
5335fdc4257SSteve Yin             if( Role == PUSH_BUTTON || Role == TOGGLE_BUTTON  || BUTTON_DROPDOWN == Role )
5345fdc4257SSteve Yin             {
5355fdc4257SSteve Yin                 IState = STATE_SYSTEM_HASPOPUP;
5365fdc4257SSteve Yin             }
5375fdc4257SSteve Yin             else
5385fdc4257SSteve Yin             {
5395fdc4257SSteve Yin                 GetExpandedState(&isExpandable,&isExpanded);
5405fdc4257SSteve Yin                 if(!isExpanded)
5415fdc4257SSteve Yin                     IState = STATE_SYSTEM_COLLAPSED;
5425fdc4257SSteve Yin             }
5435fdc4257SSteve Yin         }
5445fdc4257SSteve Yin         break;
5455fdc4257SSteve Yin 	//Remove the SENSITIVE state mapping. There is no corresponding MSAA state.
5465fdc4257SSteve Yin     //case  SENSITIVE:
5475fdc4257SSteve Yin     //    IState = STATE_SYSTEM_PROTECTED;
5485fdc4257SSteve Yin     case EDITABLE:
5495fdc4257SSteve Yin         if( m_pIMAcc )
5505fdc4257SSteve Yin         {
5515fdc4257SSteve Yin             m_pIMAcc->DecreaseState( STATE_SYSTEM_READONLY );
5525fdc4257SSteve Yin         }
5535fdc4257SSteve Yin         break;
5545fdc4257SSteve Yin     case OFFSCREEN:
5555fdc4257SSteve Yin         IState = STATE_SYSTEM_OFFSCREEN;
5565fdc4257SSteve Yin         break;
5575fdc4257SSteve Yin     case MOVEABLE:
5585fdc4257SSteve Yin         IState = STATE_SYSTEM_MOVEABLE;
5595fdc4257SSteve Yin         break;
5605fdc4257SSteve Yin     case COLLAPSE:
5615fdc4257SSteve Yin         IState = STATE_SYSTEM_COLLAPSED;
5625fdc4257SSteve Yin         break;
5635fdc4257SSteve Yin     case DEFAULT:
5645fdc4257SSteve Yin         IState = STATE_SYSTEM_DEFAULT;
5655fdc4257SSteve Yin         break;
5665fdc4257SSteve Yin     default:
5675fdc4257SSteve Yin         break;
5685fdc4257SSteve Yin     }
5695fdc4257SSteve Yin 
5705fdc4257SSteve Yin     return IState;
5715fdc4257SSteve Yin }
5725fdc4257SSteve Yin 
5735fdc4257SSteve Yin /**
5745fdc4257SSteve Yin    * Decrease state of com object
5755fdc4257SSteve Yin    * @param xState The lost state.
5765fdc4257SSteve Yin    * @return
5775fdc4257SSteve Yin    */
5785fdc4257SSteve Yin void  AccObject::DecreaseState( short xState )
5795fdc4257SSteve Yin {
5805fdc4257SSteve Yin     if( NULL == m_pIMAcc )
5815fdc4257SSteve Yin     {
5825fdc4257SSteve Yin         return;
5835fdc4257SSteve Yin     }
5845fdc4257SSteve Yin 
5855fdc4257SSteve Yin     if( xState == FOCUSABLE)
5865fdc4257SSteve Yin     {
5875fdc4257SSteve Yin         short Role = m_accRole ;
5885fdc4257SSteve Yin         if(Role == MENU_ITEM
5895fdc4257SSteve Yin                 || Role == RADIO_MENU_ITEM
5905fdc4257SSteve Yin                 || Role == CHECK_MENU_ITEM)
5915fdc4257SSteve Yin             return;
5925fdc4257SSteve Yin         else
5935fdc4257SSteve Yin         {
5945fdc4257SSteve Yin             if (Role == TOGGLE_BUTTON || Role == PUSH_BUTTON || BUTTON_DROPDOWN == Role)
5955fdc4257SSteve Yin             {
5965fdc4257SSteve Yin                 if( ( m_pParentObj !=NULL ) && (TOOL_BAR == m_pParentObj->m_accRole ) )
5975fdc4257SSteve Yin                     return;
5985fdc4257SSteve Yin             }
5995fdc4257SSteve Yin         }
6005fdc4257SSteve Yin     }
6015fdc4257SSteve Yin 
6025fdc4257SSteve Yin     else if( xState == AccessibleStateType::VISIBLE  )
6035fdc4257SSteve Yin     {
6045fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
6055fdc4257SSteve Yin     }
6065fdc4257SSteve Yin     else if( xState == AccessibleStateType::SHOWING )
6075fdc4257SSteve Yin     {
6085fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_OFFSCREEN );
6095fdc4257SSteve Yin     }
6105fdc4257SSteve Yin 
6115fdc4257SSteve Yin     DWORD msState = GetMSAAStateFromUNO(xState);
6125fdc4257SSteve Yin     if(msState!=UNO_MSAA_UNMAPPING)
6135fdc4257SSteve Yin         m_pIMAcc->DecreaseState(msState);
6145fdc4257SSteve Yin }
6155fdc4257SSteve Yin 
6165fdc4257SSteve Yin /**
6175fdc4257SSteve Yin    * Increase state of com object
6185fdc4257SSteve Yin    * @param xState The new state.
6195fdc4257SSteve Yin    * @return
6205fdc4257SSteve Yin    */
6215fdc4257SSteve Yin void AccObject::IncreaseState( short xState )
6225fdc4257SSteve Yin {
6235fdc4257SSteve Yin     if( NULL == m_pIMAcc )
6245fdc4257SSteve Yin     {
6255fdc4257SSteve Yin         assert(false);
6265fdc4257SSteve Yin         return;
6275fdc4257SSteve Yin     }
6285fdc4257SSteve Yin 
6295fdc4257SSteve Yin 
6305fdc4257SSteve Yin     if( xState == AccessibleStateType::VISIBLE  )
6315fdc4257SSteve Yin     {
6325fdc4257SSteve Yin         m_pIMAcc->DecreaseState( STATE_SYSTEM_INVISIBLE );
6335fdc4257SSteve Yin     }
6345fdc4257SSteve Yin     else if( xState == AccessibleStateType::SHOWING )
6355fdc4257SSteve Yin     {
6365fdc4257SSteve Yin         m_pIMAcc->DecreaseState( STATE_SYSTEM_OFFSCREEN );
6375fdc4257SSteve Yin     }
6385fdc4257SSteve Yin 
6395fdc4257SSteve Yin 
6405fdc4257SSteve Yin     DWORD msState = GetMSAAStateFromUNO(xState);
6415fdc4257SSteve Yin     if(msState!=UNO_MSAA_UNMAPPING)
6425fdc4257SSteve Yin         m_pIMAcc->IncreaseState( msState );
6435fdc4257SSteve Yin }
6445fdc4257SSteve Yin 
6455fdc4257SSteve Yin /**
6465fdc4257SSteve Yin    * Get next child element
6475fdc4257SSteve Yin    * @param
6485fdc4257SSteve Yin    * @return AccObject Object interface.
6495fdc4257SSteve Yin    */
6505fdc4257SSteve Yin AccObject* AccObject::NextChild()
6515fdc4257SSteve Yin {
6525fdc4257SSteve Yin     IAccChildList::iterator pInd = m_childrenList.begin();
6535fdc4257SSteve Yin     if( pInd != m_childrenList.end() )
6545fdc4257SSteve Yin         return 	*pInd;
6555fdc4257SSteve Yin     return NULL;
6565fdc4257SSteve Yin }
6575fdc4257SSteve Yin /**
6585fdc4257SSteve Yin    * update action desciption desc
6595fdc4257SSteve Yin    * @param
6605fdc4257SSteve Yin    * @return
6615fdc4257SSteve Yin    */
6625fdc4257SSteve Yin void AccObject::UpdateActionDesc()
6635fdc4257SSteve Yin {
6645fdc4257SSteve Yin     if (!m_pIMAcc)
6655fdc4257SSteve Yin     {
6665fdc4257SSteve Yin         return;
6675fdc4257SSteve Yin     }
6685fdc4257SSteve Yin 
6695fdc4257SSteve Yin     ::rtl::OUString	pXString = m_xAccContextRef->getAccessibleDescription();
6705fdc4257SSteve Yin     m_pIMAcc->Put_XAccDescription(pXString.getStr());
6715fdc4257SSteve Yin     long Role = m_accRole;
6725fdc4257SSteve Yin 
6735fdc4257SSteve Yin     if(  Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM ||
6745fdc4257SSteve Yin             Role == LIST_ITEM || Role == CHECK_BOX || Role == TREE_ITEM ||
6755fdc4257SSteve Yin             Role == CHECK_MENU_ITEM || Role == RADIO_MENU_ITEM )
6765fdc4257SSteve Yin     {
6775fdc4257SSteve Yin         UpdateDefaultAction(  );
6785fdc4257SSteve Yin     }
6795fdc4257SSteve Yin     else
6805fdc4257SSteve Yin     {
6815fdc4257SSteve Yin 
6825fdc4257SSteve Yin         if( m_xAccActionRef.is() )
6835fdc4257SSteve Yin         {
6845fdc4257SSteve Yin             if( m_xAccActionRef->getAccessibleActionCount() > 0 )
6855fdc4257SSteve Yin             {
686*3a700b0aSSteve Yin 				if (!(Role == SPIN_BOX || Role == COMBO_BOX || Role == DATE_EDITOR ||
687*3a700b0aSSteve Yin 					  Role == EDIT_BAR || Role == PASSWORD_TEXT || Role == TEXT))
6885fdc4257SSteve Yin 				{
6895fdc4257SSteve Yin 					pXString = m_xAccActionRef->getAccessibleActionDescription( 0 );
6905fdc4257SSteve Yin 					//Solution:If string length is more than zero,action will will be set.
6915fdc4257SSteve Yin 					if( pXString.getLength() > 0)
6925fdc4257SSteve Yin 						m_pIMAcc->Put_ActionDescription( pXString.getStr() );
693*3a700b0aSSteve Yin 				}
6945fdc4257SSteve Yin             }
6955fdc4257SSteve Yin         }
6965fdc4257SSteve Yin     }
6975fdc4257SSteve Yin 
6985fdc4257SSteve Yin }
6995fdc4257SSteve Yin /**
7005fdc4257SSteve Yin    * update role information from uno to com
7015fdc4257SSteve Yin    * @param
7025fdc4257SSteve Yin    * @return
7035fdc4257SSteve Yin    */
7045fdc4257SSteve Yin void AccObject::UpdateRole()
7055fdc4257SSteve Yin {
7065fdc4257SSteve Yin     if (!m_pIMAcc)
7075fdc4257SSteve Yin     {
7085fdc4257SSteve Yin         return;
7095fdc4257SSteve Yin     }
7105fdc4257SSteve Yin 
7115fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
7125fdc4257SSteve Yin     m_pIMAcc->Put_XAccRole( ROLE_SYSTEM_WINDOW  );
7135fdc4257SSteve Yin     short iRoleIndex = pContext->getAccessibleRole();
7145fdc4257SSteve Yin     if (( 0 <= iRoleIndex) && ( iRoleIndex <= (sizeof(ROLE_TABLE)/(sizeof(short)*2))))
7155fdc4257SSteve Yin     {
7165fdc4257SSteve Yin         short iIA2Role = ROLE_TABLE[iRoleIndex][1] ;
7175fdc4257SSteve Yin         m_pIMAcc->Put_XAccRole( iIA2Role  );
7185fdc4257SSteve Yin     }
7195fdc4257SSteve Yin 
7205fdc4257SSteve Yin }
7215fdc4257SSteve Yin /**
7225fdc4257SSteve Yin    * update state information from uno to com
7235fdc4257SSteve Yin    * @param
7245fdc4257SSteve Yin    * @return
7255fdc4257SSteve Yin    */
7265fdc4257SSteve Yin void AccObject::UpdateState()
7275fdc4257SSteve Yin {
7285fdc4257SSteve Yin     if (!m_pIMAcc)
7295fdc4257SSteve Yin     {
7305fdc4257SSteve Yin         return;
7315fdc4257SSteve Yin     }
7325fdc4257SSteve Yin 
7335fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
7345fdc4257SSteve Yin     Reference< XAccessibleStateSet > pRState = pContext->getAccessibleStateSet();
7355fdc4257SSteve Yin     if( !pRState.is() )
7365fdc4257SSteve Yin     {
7375fdc4257SSteve Yin         assert(false);
7385fdc4257SSteve Yin         return ;
7395fdc4257SSteve Yin     }
7405fdc4257SSteve Yin 
7415fdc4257SSteve Yin     m_pIMAcc->SetState(0L);
7425fdc4257SSteve Yin 
7435fdc4257SSteve Yin     if ( m_accRole == POPUP_MENU )
7445fdc4257SSteve Yin     {
7455fdc4257SSteve Yin         return;
7465fdc4257SSteve Yin     }
7475fdc4257SSteve Yin 
7485fdc4257SSteve Yin     Sequence<short> pStates = pRState->getStates();
7495fdc4257SSteve Yin     int count = pStates.getLength();
7505fdc4257SSteve Yin 
7515fdc4257SSteve Yin     sal_Bool isEnable = sal_False;
7525fdc4257SSteve Yin     sal_Bool isShowing = sal_False;
7535fdc4257SSteve Yin     sal_Bool isEditable = sal_False;
7545fdc4257SSteve Yin     sal_Bool isVisible = sal_False;
7555fdc4257SSteve Yin     sal_Bool isFocusable = sal_False;
7565fdc4257SSteve Yin 
7575fdc4257SSteve Yin     for( int iIndex = 0;iIndex < count;iIndex++ )
7585fdc4257SSteve Yin     {
7595fdc4257SSteve Yin         if( pStates[iIndex] == ENABLED )
7605fdc4257SSteve Yin             isEnable = sal_True;
7615fdc4257SSteve Yin         else if( pStates[iIndex] == SHOWING)
7625fdc4257SSteve Yin             isShowing = sal_True;
7635fdc4257SSteve Yin         else if( pStates[iIndex] == VISIBLE)
7645fdc4257SSteve Yin             isVisible = sal_True;
7655fdc4257SSteve Yin         else if( pStates[iIndex] == EDITABLE )
7665fdc4257SSteve Yin             isEditable = sal_True;
7675fdc4257SSteve Yin         else if (pStates[iIndex] == FOCUSABLE)
7685fdc4257SSteve Yin             isFocusable = sal_True;
7695fdc4257SSteve Yin         IncreaseState( pStates[iIndex]);
7705fdc4257SSteve Yin     }
7715fdc4257SSteve Yin     sal_Bool bIsMenuItem = m_accRole == MENU_ITEM || m_accRole == RADIO_MENU_ITEM || m_accRole == CHECK_MENU_ITEM;
7725fdc4257SSteve Yin 
7735fdc4257SSteve Yin     if(bIsMenuItem)
7745fdc4257SSteve Yin     {
7755fdc4257SSteve Yin         if(!(isShowing && isVisible) )
7765fdc4257SSteve Yin         {
7775fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
7785fdc4257SSteve Yin             m_pIMAcc->DecreaseState( STATE_SYSTEM_FOCUSABLE );
7795fdc4257SSteve Yin         }
7805fdc4257SSteve Yin     }
7815fdc4257SSteve Yin     else
7825fdc4257SSteve Yin     {
7835fdc4257SSteve Yin         if(!(isShowing || isVisible) )
7845fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_INVISIBLE );
7855fdc4257SSteve Yin     }
7865fdc4257SSteve Yin 
7875fdc4257SSteve Yin     short Role = m_accRole;
7885fdc4257SSteve Yin 
7895fdc4257SSteve Yin     if( m_pIMAcc )
7905fdc4257SSteve Yin     {
7915fdc4257SSteve Yin         switch(m_accRole)
7925fdc4257SSteve Yin         {
7935fdc4257SSteve Yin         case LABEL:
7945fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_READONLY );
7955fdc4257SSteve Yin             break;
7965fdc4257SSteve Yin         case TEXT:
7975fdc4257SSteve Yin             // 2. editable combobox -> readonly ------ bridge
7985fdc4257SSteve Yin         case EMBEDDED_OBJECT:
7995fdc4257SSteve Yin         case END_NOTE:
8005fdc4257SSteve Yin         case FOOTER:
8015fdc4257SSteve Yin         case FOOTNOTE:
8025fdc4257SSteve Yin         case GRAPHIC:
8035fdc4257SSteve Yin         case HEADER:
8045fdc4257SSteve Yin         case HEADING:
8055fdc4257SSteve Yin 
8065fdc4257SSteve Yin             //Image Map
8075fdc4257SSteve Yin         case PARAGRAPH:
8085fdc4257SSteve Yin         case PASSWORD_TEXT:
8095fdc4257SSteve Yin         case SHAPE:
8105fdc4257SSteve Yin         case SPIN_BOX:
8115fdc4257SSteve Yin         case TABLE:
8125fdc4257SSteve Yin         case TABLE_CELL:
8135fdc4257SSteve Yin         case TEXT_FRAME:
8145fdc4257SSteve Yin         case DATE_EDITOR:
8155fdc4257SSteve Yin         case DOCUMENT:
8165fdc4257SSteve Yin         case COLUMN_HEADER:
8175fdc4257SSteve Yin             {
8185fdc4257SSteve Yin                 if(!isEditable)
8195fdc4257SSteve Yin                     m_pIMAcc->IncreaseState( STATE_SYSTEM_READONLY );
8205fdc4257SSteve Yin             }
8215fdc4257SSteve Yin             break;
8225fdc4257SSteve Yin         default:
8235fdc4257SSteve Yin             break;
8245fdc4257SSteve Yin         }
8255fdc4257SSteve Yin     }
8265fdc4257SSteve Yin 
8275fdc4257SSteve Yin     if( isEnable )
8285fdc4257SSteve Yin     {
8295fdc4257SSteve Yin 
8305fdc4257SSteve Yin         if(!(Role == FILLER || Role == END_NOTE || Role == FOOTER || Role == FOOTNOTE || Role == GROUP_BOX || Role == RULER
8315fdc4257SSteve Yin                 || Role == HEADER || Role == ICON || Role == INTERNAL_FRAME || Role == LABEL || Role == LAYERED_PANE
8325fdc4257SSteve Yin                 || Role == SCROLL_BAR || Role == SCROLL_PANE || Role == SPLIT_PANE || Role == STATUS_BAR || Role == TOOL_TIP))
8335fdc4257SSteve Yin         {
8345fdc4257SSteve Yin             if( SEPARATOR == Role  )
8355fdc4257SSteve Yin             {
8365fdc4257SSteve Yin                 if( ( m_pParentObj != NULL ) && ( MENU == m_pParentObj->m_accRole  || POPUP_MENU == m_pParentObj->m_accRole ))
8375fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
8385fdc4257SSteve Yin             }
8395fdc4257SSteve Yin 
8405fdc4257SSteve Yin             else if (TABLE_CELL == Role || TABLE == Role || PANEL == Role || OPTION_PANE == Role ||
8415fdc4257SSteve Yin                      COLUMN_HEADER == Role)
8425fdc4257SSteve Yin             {
8435fdc4257SSteve Yin                 if (isFocusable)
8445fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
8455fdc4257SSteve Yin             }
8465fdc4257SSteve Yin             else
8475fdc4257SSteve Yin             {
8485fdc4257SSteve Yin                 if(bIsMenuItem)
8495fdc4257SSteve Yin                 {
8505fdc4257SSteve Yin                     if ( isShowing && isVisible)
8515fdc4257SSteve Yin                     {
8525fdc4257SSteve Yin                         IncreaseState( FOCUSABLE );
8535fdc4257SSteve Yin                     }
8545fdc4257SSteve Yin                 }
8555fdc4257SSteve Yin                 else
8565fdc4257SSteve Yin                 {
8575fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
8585fdc4257SSteve Yin                 }
8595fdc4257SSteve Yin             }
8605fdc4257SSteve Yin         }
8615fdc4257SSteve Yin     }
8625fdc4257SSteve Yin     else
8635fdc4257SSteve Yin     {
8645fdc4257SSteve Yin         m_pIMAcc->IncreaseState( STATE_SYSTEM_UNAVAILABLE );
8655fdc4257SSteve Yin         sal_Bool isDecreaseFocusable = sal_False;
8665fdc4257SSteve Yin         if( !((Role == MENU_ITEM) ||
8675fdc4257SSteve Yin                 (Role == RADIO_MENU_ITEM) ||
8685fdc4257SSteve Yin                 (Role == CHECK_MENU_ITEM)) )
8695fdc4257SSteve Yin         {
8705fdc4257SSteve Yin             if  ( Role == TOGGLE_BUTTON || Role == PUSH_BUTTON || BUTTON_DROPDOWN == Role)
8715fdc4257SSteve Yin             {
8725fdc4257SSteve Yin                 if(( m_pParentObj != NULL )&& (TOOL_BAR ==  m_pParentObj->m_accRole ) )
8735fdc4257SSteve Yin                     IncreaseState( FOCUSABLE );
8745fdc4257SSteve Yin                 else
8755fdc4257SSteve Yin                     DecreaseState( FOCUSABLE );
8765fdc4257SSteve Yin             }
8775fdc4257SSteve Yin             else
8785fdc4257SSteve Yin                 DecreaseState( FOCUSABLE );
8795fdc4257SSteve Yin         }
8805fdc4257SSteve Yin         else if( isShowing || isVisible )
8815fdc4257SSteve Yin         {
8825fdc4257SSteve Yin             IncreaseState( FOCUSABLE );
8835fdc4257SSteve Yin         }
8845fdc4257SSteve Yin     }
8855fdc4257SSteve Yin 
8865fdc4257SSteve Yin     if( m_pIMAcc )
8875fdc4257SSteve Yin     {
8885fdc4257SSteve Yin         switch(m_accRole)
8895fdc4257SSteve Yin         {
8905fdc4257SSteve Yin         case POPUP_MENU:
8915fdc4257SSteve Yin         case MENU:
8925fdc4257SSteve Yin             if( pContext->getAccessibleChildCount() > 0 )
8935fdc4257SSteve Yin                 m_pIMAcc->IncreaseState( STATE_SYSTEM_HASPOPUP );
8945fdc4257SSteve Yin             break;
8955fdc4257SSteve Yin         case PASSWORD_TEXT:
8965fdc4257SSteve Yin             m_pIMAcc->IncreaseState( STATE_SYSTEM_PROTECTED );
8975fdc4257SSteve Yin             break;
8985fdc4257SSteve Yin         default:
8995fdc4257SSteve Yin             break;
9005fdc4257SSteve Yin         }
9015fdc4257SSteve Yin     }
9025fdc4257SSteve Yin 
9035fdc4257SSteve Yin }
9045fdc4257SSteve Yin /**
9055fdc4257SSteve Yin    * update location information from uno to com
9065fdc4257SSteve Yin    * @param
9075fdc4257SSteve Yin    * @return
9085fdc4257SSteve Yin    */
9095fdc4257SSteve Yin void AccObject::UpdateLocation()
9105fdc4257SSteve Yin {
9115fdc4257SSteve Yin     if (!m_pIMAcc)
9125fdc4257SSteve Yin     {
9135fdc4257SSteve Yin         return;
9145fdc4257SSteve Yin     }
9155fdc4257SSteve Yin     XAccessibleContext* pContext  = m_xAccContextRef.get();
9165fdc4257SSteve Yin 
9175fdc4257SSteve Yin     Reference< XAccessibleComponent > pRComponent(pContext,UNO_QUERY);
9185fdc4257SSteve Yin     if( pRComponent.is() )
9195fdc4257SSteve Yin     {
9205fdc4257SSteve Yin         ::com::sun::star::awt::Point pCPoint = pRComponent->getLocationOnScreen();
9215fdc4257SSteve Yin         ::com::sun::star::awt::Size pCSize = pRComponent->getSize();
9225fdc4257SSteve Yin         Location tempLocation;
9235fdc4257SSteve Yin         tempLocation.m_dLeft = pCPoint.X;
9245fdc4257SSteve Yin         tempLocation.m_dTop =  pCPoint.Y;
9255fdc4257SSteve Yin         tempLocation.m_dWidth = pCSize.Width;
9265fdc4257SSteve Yin         tempLocation.m_dHeight = pCSize.Height;
9275fdc4257SSteve Yin         m_pIMAcc->Put_XAccLocation( tempLocation );
9285fdc4257SSteve Yin     }
9295fdc4257SSteve Yin 
9305fdc4257SSteve Yin }
9315fdc4257SSteve Yin 
9325fdc4257SSteve Yin 
9335fdc4257SSteve Yin /**
9345fdc4257SSteve Yin    * Public method to mapping information between MSAA and UNO.
9355fdc4257SSteve Yin    * @param
9365fdc4257SSteve Yin    * @return If the method is correctly processed.
9375fdc4257SSteve Yin    */
9385fdc4257SSteve Yin sal_Bool AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
9395fdc4257SSteve Yin {
9405fdc4257SSteve Yin     if( NULL == m_pIMAcc || !m_xAccContextRef.is()  )
9415fdc4257SSteve Yin     {
9425fdc4257SSteve Yin         assert(false);
9435fdc4257SSteve Yin         return sal_False;
9445fdc4257SSteve Yin     }
9455fdc4257SSteve Yin 
9465fdc4257SSteve Yin     UpdateName();
9475fdc4257SSteve Yin 
9485fdc4257SSteve Yin     UpdateValue();
9495fdc4257SSteve Yin 
9505fdc4257SSteve Yin     UpdateActionDesc();
9515fdc4257SSteve Yin 
9525fdc4257SSteve Yin     UpdateRole();
9535fdc4257SSteve Yin 
9545fdc4257SSteve Yin     UpdateLocation();
9555fdc4257SSteve Yin 
9565fdc4257SSteve Yin     UpdateState();
9575fdc4257SSteve Yin 
9585fdc4257SSteve Yin     return sal_True;
9595fdc4257SSteve Yin }
9605fdc4257SSteve Yin 
9615fdc4257SSteve Yin /*
9625fdc4257SSteve Yin    * Add a child selected element.
9635fdc4257SSteve Yin    * @param pAccObj Child object pointer.
9645fdc4257SSteve Yin    * @return
9655fdc4257SSteve Yin    */
9665fdc4257SSteve Yin void AccObject::AddSelect( long index, AccObject* accObj)
9675fdc4257SSteve Yin {
9685fdc4257SSteve Yin     m_selectionList.insert(IAccSelectionList::value_type(index,accObj));
9695fdc4257SSteve Yin }
9705fdc4257SSteve Yin 
9715fdc4257SSteve Yin IAccSelectionList& AccObject::GetSelection()
9725fdc4257SSteve Yin {
9735fdc4257SSteve Yin     return m_selectionList;
9745fdc4257SSteve Yin }
9755fdc4257SSteve Yin 
9765fdc4257SSteve Yin 
9775fdc4257SSteve Yin /**
9785fdc4257SSteve Yin    * Set self to focus object in parant child list
9795fdc4257SSteve Yin    * @param
9805fdc4257SSteve Yin    * @return
9815fdc4257SSteve Yin    */
9825fdc4257SSteve Yin void AccObject::setFocus()
9835fdc4257SSteve Yin {
9845fdc4257SSteve Yin     if(m_pIMAcc)
9855fdc4257SSteve Yin     {
9865fdc4257SSteve Yin         IncreaseState(FOCUSED);
9875fdc4257SSteve Yin         m_pIMAcc->Put_XAccFocus(CHILDID_SELF);
9885fdc4257SSteve Yin 
9895fdc4257SSteve Yin         UpdateRole();
9905fdc4257SSteve Yin     }
9915fdc4257SSteve Yin }
9925fdc4257SSteve Yin 
9935fdc4257SSteve Yin /**
9945fdc4257SSteve Yin    * Unset self from focus object in parant child list.
9955fdc4257SSteve Yin    * @param
9965fdc4257SSteve Yin    * @return
9975fdc4257SSteve Yin    */
9985fdc4257SSteve Yin void AccObject::unsetFocus()
9995fdc4257SSteve Yin {
10005fdc4257SSteve Yin     if(m_pIMAcc)
10015fdc4257SSteve Yin     {
10025fdc4257SSteve Yin         DecreaseState( FOCUSED );
10035fdc4257SSteve Yin         m_pIMAcc->Put_XAccFocus(UACC_NO_FOCUS);
10045fdc4257SSteve Yin     }
10055fdc4257SSteve Yin }
10065fdc4257SSteve Yin 
10075fdc4257SSteve Yin void AccObject::GetExpandedState( sal_Bool* isExpandable, sal_Bool* isExpanded)
10085fdc4257SSteve Yin {
10095fdc4257SSteve Yin     *isExpanded = sal_False;
10105fdc4257SSteve Yin     *isExpandable = sal_False;
10115fdc4257SSteve Yin 
10125fdc4257SSteve Yin     if( !m_xAccContextRef.is() )
10135fdc4257SSteve Yin     {
10145fdc4257SSteve Yin         return;
10155fdc4257SSteve Yin     }
10165fdc4257SSteve Yin     Reference< XAccessibleStateSet > pRState = m_xAccContextRef->getAccessibleStateSet();
10175fdc4257SSteve Yin     if( !pRState.is() )
10185fdc4257SSteve Yin     {
10195fdc4257SSteve Yin         return;
10205fdc4257SSteve Yin     }
10215fdc4257SSteve Yin 
10225fdc4257SSteve Yin     Sequence<short> pStates = pRState->getStates();
10235fdc4257SSteve Yin     int count = pStates.getLength();
10245fdc4257SSteve Yin 
10255fdc4257SSteve Yin     for( int iIndex = 0;iIndex < count;iIndex++ )
10265fdc4257SSteve Yin     {
10275fdc4257SSteve Yin         if( EXPANDED == pStates[iIndex]  )
10285fdc4257SSteve Yin         {
10295fdc4257SSteve Yin             *isExpanded = sal_True;
10305fdc4257SSteve Yin         }
10315fdc4257SSteve Yin         else if( EXPANDABLE == pStates[iIndex]  )
10325fdc4257SSteve Yin         {
10335fdc4257SSteve Yin             *isExpandable = sal_True;
10345fdc4257SSteve Yin         }
10355fdc4257SSteve Yin     }
10365fdc4257SSteve Yin }
10375fdc4257SSteve Yin 
10385fdc4257SSteve Yin void AccObject::NotifyDestroy(sal_Bool ifDelete)
10395fdc4257SSteve Yin {
10405fdc4257SSteve Yin     m_bShouldDestroy=ifDelete;
10415fdc4257SSteve Yin     if(m_pIMAcc)
10425fdc4257SSteve Yin         m_pIMAcc->NotifyDestroy(m_bShouldDestroy);
10435fdc4257SSteve Yin }
10445fdc4257SSteve Yin 
10455fdc4257SSteve Yin void AccObject::SetParentObj(AccObject* pParentAccObj)
10465fdc4257SSteve Yin {
10475fdc4257SSteve Yin     m_pParentObj = pParentAccObj;
10485fdc4257SSteve Yin 
10495fdc4257SSteve Yin     if(m_pIMAcc)
10505fdc4257SSteve Yin     {
10515fdc4257SSteve Yin         if(m_pParentObj)
10525fdc4257SSteve Yin         {
10535fdc4257SSteve Yin             m_pIMAcc->Put_XAccParent(m_pParentObj->GetIMAccessible());
10545fdc4257SSteve Yin         }
10555fdc4257SSteve Yin         else
10565fdc4257SSteve Yin         {
10575fdc4257SSteve Yin             m_pIMAcc->Put_XAccParent(NULL);
10585fdc4257SSteve Yin         }
10595fdc4257SSteve Yin     }
10605fdc4257SSteve Yin }
10615fdc4257SSteve Yin //ResID means ChildID in MSAA
10625fdc4257SSteve Yin void AccObject::SetResID(long id)
10635fdc4257SSteve Yin {
10645fdc4257SSteve Yin     m_resID = id;
10655fdc4257SSteve Yin     if(m_pIMAcc)
10665fdc4257SSteve Yin         m_pIMAcc->Put_XAccChildID(m_resID);
10675fdc4257SSteve Yin }
10685fdc4257SSteve Yin //return COM interface in acc object
10695fdc4257SSteve Yin IMAccessible*  AccObject::GetIMAccessible()
10705fdc4257SSteve Yin {
10715fdc4257SSteve Yin     return m_pIMAcc;
10725fdc4257SSteve Yin }
10735fdc4257SSteve Yin 
10745fdc4257SSteve Yin Reference < XAccessible > AccObject::GetXAccessible()
10755fdc4257SSteve Yin {
10765fdc4257SSteve Yin     return m_xAccRef;
10775fdc4257SSteve Yin }
10785fdc4257SSteve Yin 
10795fdc4257SSteve Yin void AccObject::SetParentHWND(HWND hWnd)
10805fdc4257SSteve Yin {
10815fdc4257SSteve Yin     m_pParantID = hWnd;
10825fdc4257SSteve Yin }
10835fdc4257SSteve Yin void AccObject::SetListener( AccEventListener* Listener )
10845fdc4257SSteve Yin {
10855fdc4257SSteve Yin     m_accListener = Listener;
10865fdc4257SSteve Yin }
10875fdc4257SSteve Yin AccEventListener* AccObject::getListener()
10885fdc4257SSteve Yin {
10895fdc4257SSteve Yin     return m_accListener;
10905fdc4257SSteve Yin }
10915fdc4257SSteve Yin 
10925fdc4257SSteve Yin long AccObject::GetResID()
10935fdc4257SSteve Yin {
10945fdc4257SSteve Yin     return m_resID;
10955fdc4257SSteve Yin }
10965fdc4257SSteve Yin 
10975fdc4257SSteve Yin HWND AccObject::GetParentHWND()
10985fdc4257SSteve Yin {
10995fdc4257SSteve Yin     return m_pParantID;
11005fdc4257SSteve Yin }
11015fdc4257SSteve Yin 
11025fdc4257SSteve Yin AccObject* AccObject::GetParentObj()
11035fdc4257SSteve Yin {
11045fdc4257SSteve Yin     return m_pParentObj;
11055fdc4257SSteve Yin }
11065fdc4257SSteve Yin sal_Bool  AccObject::ifShouldDestroy()
11075fdc4257SSteve Yin {
11085fdc4257SSteve Yin     return m_bShouldDestroy;
11095fdc4257SSteve Yin }
1110