13a700b0aSSteve Yin /************************************************************** 25fdc4257SSteve Yin * 33a700b0aSSteve Yin * Licensed to the Apache Software Foundation (ASF) under one 43a700b0aSSteve Yin * or more contributor license agreements. See the NOTICE file 53a700b0aSSteve Yin * distributed with this work for additional information 63a700b0aSSteve Yin * regarding copyright ownership. The ASF licenses this file 73a700b0aSSteve Yin * to you under the Apache License, Version 2.0 (the 83a700b0aSSteve Yin * "License"); you may not use this file except in compliance 93a700b0aSSteve Yin * with the License. You may obtain a copy of the License at 105fdc4257SSteve Yin * 113a700b0aSSteve Yin * http://www.apache.org/licenses/LICENSE-2.0 125fdc4257SSteve Yin * 133a700b0aSSteve Yin * Unless required by applicable law or agreed to in writing, 143a700b0aSSteve Yin * software distributed under the License is distributed on an 153a700b0aSSteve Yin * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 163a700b0aSSteve Yin * KIND, either express or implied. See the License for the 173a700b0aSSteve Yin * specific language governing permissions and limitations 183a700b0aSSteve Yin * under the License. 195fdc4257SSteve Yin * 203a700b0aSSteve Yin *************************************************************/ 215fdc4257SSteve Yin 225fdc4257SSteve Yin #include "stdafx.h" 235fdc4257SSteve Yin #include "UAccCOM2.h" 245fdc4257SSteve Yin #include "MAccessible.h" 255fdc4257SSteve Yin 265fdc4257SSteve Yin #include <algorithm> 275fdc4257SSteve Yin #include "AccAction.h" 285fdc4257SSteve Yin 295fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleText.hpp> 305fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleEditableText.hpp> 315fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleImage.hpp> 325fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleTable.hpp> 335fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> 345fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleAction.hpp> 355fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp> 365fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleHyperText.hpp> 375fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> 385fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> 395fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp> 405fdc4257SSteve Yin #include <com/sun/star/accessibility/AccessibleRole.hpp> 415fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleGroupPosition.hpp> 425fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleValue.hpp> 435fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> 445fdc4257SSteve Yin #include <com/sun/star/style/LineSpacing.hpp> 455fdc4257SSteve Yin #include <com/sun/star/style/TabStop.hpp> 465fdc4257SSteve Yin #include <com/sun/star/container/XIndexReplace.hpp> 475fdc4257SSteve Yin 48*b0a7a3cfSSteve Yin #include "act.hxx" 493a700b0aSSteve Yin 505fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleStateType; 515fdc4257SSteve Yin 525fdc4257SSteve Yin // IA2 states mapping, and name 535fdc4257SSteve Yin // maintenance the consistency, change one array, change the three all 545fdc4257SSteve Yin long IA2_STATES[] = 555fdc4257SSteve Yin { 565fdc4257SSteve Yin IA2_STATE_ACTIVE, // = 0x1; 575fdc4257SSteve Yin IA2_STATE_ARMED, // = 0x2; 585fdc4257SSteve Yin IA2_STATE_DEFUNCT, // = 0x4; 595fdc4257SSteve Yin IA2_STATE_EDITABLE, // = 0x8; 605fdc4257SSteve Yin IA2_STATE_HORIZONTAL, // = 0x10; 615fdc4257SSteve Yin IA2_STATE_ICONIFIED, // = 0x20; 625fdc4257SSteve Yin IA2_STATE_INVALID_ENTRY, // = 0x80; 635fdc4257SSteve Yin IA2_STATE_MANAGES_DESCENDANTS, // = 0x100; 645fdc4257SSteve Yin IA2_STATE_MODAL, // = 0x200; 655fdc4257SSteve Yin IA2_STATE_MULTI_LINE, // = 0x400; 665fdc4257SSteve Yin IA2_STATE_OPAQUE, // = 0x800; 675fdc4257SSteve Yin IA2_STATE_REQUIRED, // = 0x2000; 685fdc4257SSteve Yin IA2_STATE_SELECTABLE_TEXT, // = 0x3000; 695fdc4257SSteve Yin IA2_STATE_SINGLE_LINE, // = 0x4000; 705fdc4257SSteve Yin IA2_STATE_STALE, // = 0x8000; 715fdc4257SSteve Yin IA2_STATE_SUPPORTS_AUTOCOMPLETION, // = 0x10000; 725fdc4257SSteve Yin IA2_STATE_TRANSIENT, //= 0x20000; 735fdc4257SSteve Yin IA2_STATE_VERTICAL // = 0x40000; 745fdc4257SSteve Yin }; 755fdc4257SSteve Yin /* 765fdc4257SSteve Yin 775fdc4257SSteve Yin <=== map ===> 785fdc4257SSteve Yin 795fdc4257SSteve Yin */ 805fdc4257SSteve Yin short UNO_STATES[] = 815fdc4257SSteve Yin { 825fdc4257SSteve Yin ACTIVE, // = (sal_Int16)1; 835fdc4257SSteve Yin ARMED, // = (sal_Int16)2; 845fdc4257SSteve Yin DEFUNC, // = (sal_Int16)5; 855fdc4257SSteve Yin EDITABLE, // = (sal_Int16)6; 865fdc4257SSteve Yin HORIZONTAL, // = (sal_Int16)12; 875fdc4257SSteve Yin ICONIFIED, // = (sal_Int16)13; 885fdc4257SSteve Yin -1, //IA2_STATE_INVALID_ENTRY 895fdc4257SSteve Yin MANAGES_DESCENDANTS, // = (sal_Int16)15; 905fdc4257SSteve Yin MODAL, // = (sal_Int16)16; 915fdc4257SSteve Yin MULTI_LINE, // = (sal_Int16)17; 925fdc4257SSteve Yin OPAQUE, // = (sal_Int16)19; 935fdc4257SSteve Yin -1, //IA2_STATE_REQUIRED 945fdc4257SSteve Yin -1, //IA2_STATE_SELECTABLE_TEXT 955fdc4257SSteve Yin SINGLE_LINE, // = (sal_Int16)26; 965fdc4257SSteve Yin STALE, // = (sal_Int16)27; 975fdc4257SSteve Yin -1, //IA2_STATE_SUPPORTS_AUTOCOMPLETION 985fdc4257SSteve Yin TRANSIENT, //IA2_STATE_TRANSIENT 995fdc4257SSteve Yin VERTICAL // = (sal_Int16)29; 1005fdc4257SSteve Yin }; 1015fdc4257SSteve Yin 1025fdc4257SSteve Yin // <=== map ===> 1035fdc4257SSteve Yin 1045fdc4257SSteve Yin BSTR IA2_STATES_NAME[] = 1055fdc4257SSteve Yin { 1065fdc4257SSteve Yin _T("Active"), 1075fdc4257SSteve Yin _T("Armed"), 1085fdc4257SSteve Yin _T("Defunct"), 1095fdc4257SSteve Yin _T("Editable"), 1105fdc4257SSteve Yin _T("Horizontal"), 1115fdc4257SSteve Yin _T("Iconified"), 1125fdc4257SSteve Yin _T("Invalid Entry"), 1135fdc4257SSteve Yin _T("Manages Decendents"), 1145fdc4257SSteve Yin _T("Modal"), 1155fdc4257SSteve Yin _T("Multi Line"), 1165fdc4257SSteve Yin _T("Opaque"), 1175fdc4257SSteve Yin _T("Required"), 1185fdc4257SSteve Yin _T("Selectable Text"), 1195fdc4257SSteve Yin _T("Single Line"), 1205fdc4257SSteve Yin _T("Stale"), 1215fdc4257SSteve Yin _T("Supports Autocompletion"), 1225fdc4257SSteve Yin _T("Transient"), 1235fdc4257SSteve Yin _T("Vertical") 1245fdc4257SSteve Yin }; 1255fdc4257SSteve Yin 1265fdc4257SSteve Yin // IA2 states mapping, and name 1275fdc4257SSteve Yin // maintenance the consistency. change one, change them all 1285fdc4257SSteve Yin 1295fdc4257SSteve Yin BSTR UNO_ALL_STATES[] = 1305fdc4257SSteve Yin { 1315fdc4257SSteve Yin _T("INVALID"), // INVALID ( 0 ) 1325fdc4257SSteve Yin _T("ACTIVE"), // ACTIVE ( 1 ) 1335fdc4257SSteve Yin _T("ARMED"), // ARMED ( 2 ) 1345fdc4257SSteve Yin _T("BUSY"), // BUSY ( 3 ) 1355fdc4257SSteve Yin _T("CHECKED"), // CHECKED ( 4 ) 1365fdc4257SSteve Yin _T("DEFUNC"), // DEFUNC ( 5 ) 1375fdc4257SSteve Yin _T("EDITABLE"), // EDITABLE ( 6 ) 1385fdc4257SSteve Yin _T("ENABLED"), // ENABLED ( 7 ) 1395fdc4257SSteve Yin _T("EXPANDABLE"), // EXPANDABLE ( 8 ) 1405fdc4257SSteve Yin _T("EXPANDED"), // EXPANDED ( 9 ) 1415fdc4257SSteve Yin _T("FOCUSABLE"), // FOCUSABLE ( 10 ) 1425fdc4257SSteve Yin _T("FOCUSED"), // FOCUSED ( 11 ) 1435fdc4257SSteve Yin _T("HORIZONTAL"), // HORIZONTAL ( 12 ) 1445fdc4257SSteve Yin _T("ICONIFIED"), // ICONIFIED ( 13 ) 1455fdc4257SSteve Yin _T("INDETERMINATE"), // INDETERMINATE ( 14 ) 1465fdc4257SSteve Yin _T("MANAGES_DESCENDANTS"),// MANAGES_DESCENDANTS ( 15 ) 1475fdc4257SSteve Yin _T("MODAL"), // MODAL ( 16 ) 1485fdc4257SSteve Yin _T("MULTI_LINE"), // MULTI_LINE ( 17 ) 1495fdc4257SSteve Yin _T("MULTI_SELECTABLE"), // MULTI_SELECTABLE ( 18 ) 1505fdc4257SSteve Yin _T("OPAQUE"), // OPAQUE ( 19 ) 1515fdc4257SSteve Yin _T("PRESSED"), // PRESSED ( 20 ) 1525fdc4257SSteve Yin _T("RESIZABLE"), // RESIZABLE ( 21 ) 1535fdc4257SSteve Yin _T("SELECTABLE"), // SELECTABLE ( 22 ) 1545fdc4257SSteve Yin _T("SELECTED"), // SELECTED ( 23 ) 1555fdc4257SSteve Yin _T("SENSITIVE"), // SENSITIVE ( 24 ) 1565fdc4257SSteve Yin _T("SHOWING"), // SHOWING ( 25 ) 1575fdc4257SSteve Yin _T("SINGLE_LINE"), // SINGLE_LINE ( 26 ) 1585fdc4257SSteve Yin _T("STALE"), // STALE ( 27 ) 1595fdc4257SSteve Yin _T("TRANSIENT"), // TRANSIENT ( 28 ) 1605fdc4257SSteve Yin _T("VERTICAL"), // VERTICAL ( 29 ) 1615fdc4257SSteve Yin _T("VISIBLE"), // VISIBLE ( 30 ) 1625fdc4257SSteve Yin _T("MOVEABLE"), // MOVEABLE ( 31 ) 1635fdc4257SSteve Yin _T("OFFSCREEN"), // OFFSCREEN ( 32 ) 1645fdc4257SSteve Yin _T("COLLAPSE"), // COLLAPSE ( 33 ) 1655fdc4257SSteve Yin _T("DEFAULT") // DEFAULT ( 34 ) 1665fdc4257SSteve Yin }; 1675fdc4257SSteve Yin 1685fdc4257SSteve Yin 1695fdc4257SSteve Yin using namespace com::sun::star::accessibility::AccessibleRole; 1705fdc4257SSteve Yin 1715fdc4257SSteve Yin 1725fdc4257SSteve Yin 1735fdc4257SSteve Yin #define QUERYXINTERFACE(ainterface) \ 1745fdc4257SSteve Yin { \ 1755fdc4257SSteve Yin if(pXAcc == NULL) \ 1765fdc4257SSteve Yin return FALSE; \ 1775fdc4257SSteve Yin pRContext = pXAcc->getAccessibleContext(); \ 1785fdc4257SSteve Yin if( !pRContext.is() ) \ 1795fdc4257SSteve Yin { \ 1805fdc4257SSteve Yin return FALSE; \ 1815fdc4257SSteve Yin } \ 1825fdc4257SSteve Yin Reference<X##ainterface> pRXI(pRContext,UNO_QUERY);\ 1835fdc4257SSteve Yin if( !pRXI.is() ) \ 1845fdc4257SSteve Yin { \ 1855fdc4257SSteve Yin return FALSE; \ 1865fdc4257SSteve Yin } \ 1875fdc4257SSteve Yin *ppXI = (XInterface*)pRXI.get(); \ 1885fdc4257SSteve Yin return TRUE; \ 1895fdc4257SSteve Yin } 1905fdc4257SSteve Yin 1915fdc4257SSteve Yin #define ISDESTROY() \ 1925fdc4257SSteve Yin if(m_isDestroy) \ 1935fdc4257SSteve Yin return S_FALSE; 1945fdc4257SSteve Yin 1955fdc4257SSteve Yin 1965fdc4257SSteve Yin AccObjectManagerAgent* CMAccessible::g_pAgent = NULL; 1975fdc4257SSteve Yin 1985fdc4257SSteve Yin CMAccessible::CMAccessible(): 1995fdc4257SSteve Yin m_iRole(0x00), 2005fdc4257SSteve Yin m_dState(0x00), 2015fdc4257SSteve Yin m_dChildID(0x00), 2025fdc4257SSteve Yin m_dFocusChildID(UACC_NO_FOCUS), 2035fdc4257SSteve Yin m_hwnd(NULL), 2045fdc4257SSteve Yin m_pIParent(NULL), 2055fdc4257SSteve Yin m_pszName(NULL), 2065fdc4257SSteve Yin m_pszValue(NULL), 2075fdc4257SSteve Yin m_pszDescription(NULL), 2085fdc4257SSteve Yin m_isDestroy(FALSE), 2095fdc4257SSteve Yin m_pszActionDescription(NULL), 2105fdc4257SSteve Yin m_pXAction(NULL), 2115fdc4257SSteve Yin m_bRequiresSave(FALSE), 2125fdc4257SSteve Yin pUNOInterface(NULL) 2135fdc4257SSteve Yin { 2145fdc4257SSteve Yin m_sLocation.m_dLeft=0; 2155fdc4257SSteve Yin m_sLocation.m_dTop = 0; 2165fdc4257SSteve Yin m_sLocation.m_dWidth=0; 2175fdc4257SSteve Yin m_sLocation.m_dHeight=0; 2185fdc4257SSteve Yin CEnumVariant::Create(&m_pEnumVar); 2195fdc4257SSteve Yin } 2205fdc4257SSteve Yin 2215fdc4257SSteve Yin CMAccessible::~CMAccessible() 2225fdc4257SSteve Yin { 2235fdc4257SSteve Yin if(m_pszName!=NULL) 2245fdc4257SSteve Yin { 2255fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszName); 2265fdc4257SSteve Yin m_pszName=NULL; 2275fdc4257SSteve Yin } 2285fdc4257SSteve Yin if(m_pszValue!=NULL) 2295fdc4257SSteve Yin { 2305fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszValue); 2315fdc4257SSteve Yin m_pszValue=NULL; 2325fdc4257SSteve Yin } 2335fdc4257SSteve Yin if(m_pszDescription!=NULL) 2345fdc4257SSteve Yin { 2355fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszDescription); 2365fdc4257SSteve Yin m_pszDescription=NULL; 2375fdc4257SSteve Yin } 2385fdc4257SSteve Yin 2395fdc4257SSteve Yin if(m_pszActionDescription!=NULL) 2405fdc4257SSteve Yin { 2415fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszActionDescription); 2425fdc4257SSteve Yin m_pszActionDescription=NULL; 2435fdc4257SSteve Yin } 2445fdc4257SSteve Yin 2455fdc4257SSteve Yin if(m_pIParent) 2465fdc4257SSteve Yin { 2475fdc4257SSteve Yin m_pIParent->Release(); 2485fdc4257SSteve Yin m_pIParent=NULL; 2495fdc4257SSteve Yin } 2505fdc4257SSteve Yin pRef = NULL; 2515fdc4257SSteve Yin m_pEnumVar->Release(); 2525fdc4257SSteve Yin m_containedObjects.clear(); 2535fdc4257SSteve Yin pRContext = NULL; 2545fdc4257SSteve Yin } 2555fdc4257SSteve Yin 2565fdc4257SSteve Yin /** 2575fdc4257SSteve Yin * Returns the Parent IAccessible interface pointer to AT. 2585fdc4257SSteve Yin * It should add reference, and the client should release the component. 2595fdc4257SSteve Yin * It should return E_FAIL when the parent point is null. 2605fdc4257SSteve Yin * @param ppdispParent [in,out] used to return the parent interface point. 2615fdc4257SSteve Yin * when the point is null, should return null. 2625fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if the m_pIParent is NULL. 2635fdc4257SSteve Yin */ 2645fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accParent(IDispatch **ppdispParent) 2655fdc4257SSteve Yin { 2665fdc4257SSteve Yin 2675fdc4257SSteve Yin CHECK_ENABLE_INF 2685fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2695fdc4257SSteve Yin ISDESTROY() 2705fdc4257SSteve Yin // #CHECK# 2715fdc4257SSteve Yin if(ppdispParent == NULL) 2725fdc4257SSteve Yin { 2735fdc4257SSteve Yin return E_INVALIDARG; 2745fdc4257SSteve Yin } 2755fdc4257SSteve Yin 2765fdc4257SSteve Yin if(m_pIParent) 2775fdc4257SSteve Yin { 2785fdc4257SSteve Yin *ppdispParent = m_pIParent; 2795fdc4257SSteve Yin (*ppdispParent)->AddRef(); 2805fdc4257SSteve Yin return S_OK; 2815fdc4257SSteve Yin } 2825fdc4257SSteve Yin else if(m_hwnd) 2835fdc4257SSteve Yin { 2845fdc4257SSteve Yin HRESULT hr = AccessibleObjectFromWindow(m_hwnd, OBJID_WINDOW, IID_IAccessible, (void**)ppdispParent); 2855fdc4257SSteve Yin if( ! SUCCEEDED( hr ) || ! ppdispParent ) 2865fdc4257SSteve Yin { 2875fdc4257SSteve Yin return S_FALSE; 2885fdc4257SSteve Yin } 2895fdc4257SSteve Yin return S_OK; 2905fdc4257SSteve Yin } 2915fdc4257SSteve Yin return S_FALSE; 2925fdc4257SSteve Yin 2935fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2945fdc4257SSteve Yin } 2955fdc4257SSteve Yin 2965fdc4257SSteve Yin /** 2975fdc4257SSteve Yin * Returns child count of current COM object. 2985fdc4257SSteve Yin * @param pcountChildren [in,out] used to return the children count. 2995fdc4257SSteve Yin * @return S_OK if successful. 3005fdc4257SSteve Yin */ 3015fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accChildCount(long *pcountChildren) 3025fdc4257SSteve Yin { 3035fdc4257SSteve Yin 3045fdc4257SSteve Yin CHECK_ENABLE_INF 3055fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 3065fdc4257SSteve Yin ISDESTROY() 3075fdc4257SSteve Yin // #CHECK# 3085fdc4257SSteve Yin if(pcountChildren == NULL) 3095fdc4257SSteve Yin { 3105fdc4257SSteve Yin return E_INVALIDARG; 3115fdc4257SSteve Yin } 3125fdc4257SSteve Yin 3135fdc4257SSteve Yin if(!pUNOInterface) 3145fdc4257SSteve Yin return S_FALSE; 3155fdc4257SSteve Yin 3165fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = pUNOInterface->getAccessibleContext(); 3175fdc4257SSteve Yin if( pRContext.is() ) 3185fdc4257SSteve Yin { 3195fdc4257SSteve Yin *pcountChildren = pRContext->getAccessibleChildCount(); 3205fdc4257SSteve Yin } 3215fdc4257SSteve Yin 3225fdc4257SSteve Yin return S_OK; 3235fdc4257SSteve Yin 3245fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 3255fdc4257SSteve Yin } 3265fdc4257SSteve Yin 3275fdc4257SSteve Yin /** 3285fdc4257SSteve Yin * Returns child interface pointer for AT according to input child ID. 3295fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 3305fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 3315fdc4257SSteve Yin * @param ppdispChild, [in,out] use to return the child interface point. 3325fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 3335fdc4257SSteve Yin */ 3345fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accChild(VARIANT varChild, IDispatch **ppdispChild) 3355fdc4257SSteve Yin { 3365fdc4257SSteve Yin 3375fdc4257SSteve Yin CHECK_ENABLE_INF 3385fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 3395fdc4257SSteve Yin ISDESTROY() 3405fdc4257SSteve Yin // #CHECK# 3415fdc4257SSteve Yin if(ppdispChild == NULL) 3425fdc4257SSteve Yin { 3435fdc4257SSteve Yin return E_INVALIDARG; 3445fdc4257SSteve Yin } 3455fdc4257SSteve Yin if(varChild.vt==VT_I4) 3465fdc4257SSteve Yin { 3475fdc4257SSteve Yin //get child interface pointer due to child ID 3485fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 3495fdc4257SSteve Yin { 3505fdc4257SSteve Yin AddRef(); 3515fdc4257SSteve Yin *ppdispChild = this; 3525fdc4257SSteve Yin return S_OK; 3535fdc4257SSteve Yin } 3545fdc4257SSteve Yin *ppdispChild = GetChildInterface(varChild.lVal); 3555fdc4257SSteve Yin (*ppdispChild)->AddRef(); 3565fdc4257SSteve Yin return (*ppdispChild)?S_OK:S_FALSE; 3575fdc4257SSteve Yin } 3585fdc4257SSteve Yin return S_FALSE; 3595fdc4257SSteve Yin 3605fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 3615fdc4257SSteve Yin } 3625fdc4257SSteve Yin 3635fdc4257SSteve Yin /** 3645fdc4257SSteve Yin * Returns the accessible name of the current COM object self or its one child to AT. 3655fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 3665fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 3675fdc4257SSteve Yin * @param pszName, [in,out] use to return the name of the proper object. 3685fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 3695fdc4257SSteve Yin */ 3705fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accName(VARIANT varChild, BSTR *pszName) 3715fdc4257SSteve Yin { 3725fdc4257SSteve Yin 3735fdc4257SSteve Yin CHECK_ENABLE_INF 3745fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 3755fdc4257SSteve Yin ISDESTROY() 3765fdc4257SSteve Yin // #CHECK# 3775fdc4257SSteve Yin if(pszName == NULL) 3785fdc4257SSteve Yin { 3795fdc4257SSteve Yin return E_INVALIDARG; 3805fdc4257SSteve Yin } 3815fdc4257SSteve Yin if(varChild.vt==VT_I4) 3825fdc4257SSteve Yin { 3835fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 3845fdc4257SSteve Yin { 3855fdc4257SSteve Yin SAFE_SYSFREESTRING(*pszName); 3865fdc4257SSteve Yin *pszName = SysAllocString(m_pszName); 3875fdc4257SSteve Yin return S_OK; 3885fdc4257SSteve Yin } 3895fdc4257SSteve Yin 3905fdc4257SSteve Yin long lVal = varChild.lVal; 3915fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 3925fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 3935fdc4257SSteve Yin if(!pChild) 3945fdc4257SSteve Yin return E_FAIL; 3955fdc4257SSteve Yin return pChild->get_accName(varChild,pszName); 3965fdc4257SSteve Yin } 3975fdc4257SSteve Yin return S_FALSE; 3985fdc4257SSteve Yin 3995fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 4005fdc4257SSteve Yin } 4015fdc4257SSteve Yin 4025fdc4257SSteve Yin /** 4035fdc4257SSteve Yin * Returns the accessible value of the current COM object self or its one child to AT. 4045fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 4055fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 4065fdc4257SSteve Yin * @param pszValue, [in,out] use to return the value of the proper object. 4075fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 4085fdc4257SSteve Yin */ 4095fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accValue(VARIANT varChild, BSTR *pszValue) 4105fdc4257SSteve Yin { 4115fdc4257SSteve Yin 4125fdc4257SSteve Yin CHECK_ENABLE_INF 4135fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4145fdc4257SSteve Yin ISDESTROY() 4155fdc4257SSteve Yin // #CHECK# 4165fdc4257SSteve Yin if( pszValue == NULL ) 4175fdc4257SSteve Yin { 4185fdc4257SSteve Yin return E_INVALIDARG; 4195fdc4257SSteve Yin } 4205fdc4257SSteve Yin if( varChild.vt==VT_I4 ) 4215fdc4257SSteve Yin { 4225fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 4235fdc4257SSteve Yin { 4245fdc4257SSteve Yin if(m_dState & STATE_SYSTEM_PROTECTED) 4255fdc4257SSteve Yin return E_ACCESSDENIED; 4265fdc4257SSteve Yin 4275fdc4257SSteve Yin if ( m_pszValue !=NULL && wcslen(m_pszValue) == 0 ) 4285fdc4257SSteve Yin return S_OK; 4295fdc4257SSteve Yin 4305fdc4257SSteve Yin SAFE_SYSFREESTRING(*pszValue); 4315fdc4257SSteve Yin *pszValue = SysAllocString(m_pszValue); 4325fdc4257SSteve Yin return S_OK; 4335fdc4257SSteve Yin } 4345fdc4257SSteve Yin 4355fdc4257SSteve Yin long lVal = varChild.lVal; 4365fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 4375fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 4385fdc4257SSteve Yin if(!pChild) 4395fdc4257SSteve Yin return E_FAIL; 4405fdc4257SSteve Yin return pChild->get_accValue(varChild,pszValue); 4415fdc4257SSteve Yin } 4425fdc4257SSteve Yin return S_FALSE; 4435fdc4257SSteve Yin 4445fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 4455fdc4257SSteve Yin } 4465fdc4257SSteve Yin 4475fdc4257SSteve Yin /** 4485fdc4257SSteve Yin * Returns the accessible description of the current COM object self or its one child to AT. 4495fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 4505fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 4515fdc4257SSteve Yin * @param pszDescription, [in,out] use to return the description of the proper object. 4525fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 4535fdc4257SSteve Yin */ 4545fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accDescription(VARIANT varChild, BSTR *pszDescription) 4555fdc4257SSteve Yin { 4565fdc4257SSteve Yin 4575fdc4257SSteve Yin CHECK_ENABLE_INF 4585fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4595fdc4257SSteve Yin ISDESTROY() 4605fdc4257SSteve Yin // #CHECK# 4615fdc4257SSteve Yin if(pszDescription == NULL) 4625fdc4257SSteve Yin { 4635fdc4257SSteve Yin return E_INVALIDARG; 4645fdc4257SSteve Yin } 4655fdc4257SSteve Yin if(varChild.vt==VT_I4) 4665fdc4257SSteve Yin { 4675fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 4685fdc4257SSteve Yin { 4695fdc4257SSteve Yin SAFE_SYSFREESTRING(*pszDescription); 4705fdc4257SSteve Yin *pszDescription = SysAllocString(m_pszDescription); 4715fdc4257SSteve Yin return S_OK; 4725fdc4257SSteve Yin } 4735fdc4257SSteve Yin 4745fdc4257SSteve Yin long lVal = varChild.lVal; 4755fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 4765fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 4775fdc4257SSteve Yin if(!pChild) 4785fdc4257SSteve Yin return E_FAIL; 4795fdc4257SSteve Yin return pChild->get_accDescription(varChild,pszDescription); 4805fdc4257SSteve Yin } 4815fdc4257SSteve Yin return S_FALSE; 4825fdc4257SSteve Yin 4835fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 4845fdc4257SSteve Yin } 4855fdc4257SSteve Yin 4865fdc4257SSteve Yin /** 4875fdc4257SSteve Yin * Returns the accessible role of the current COM object self or its one child to AT. 4885fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 4895fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 4905fdc4257SSteve Yin * @param pvarRole, [in,out] use to return the role of the proper object. 4915fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 4925fdc4257SSteve Yin */ 4935fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accRole(VARIANT varChild, VARIANT *pvarRole) 4945fdc4257SSteve Yin { 4955fdc4257SSteve Yin 4965fdc4257SSteve Yin CHECK_ENABLE_INF 4975fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 4985fdc4257SSteve Yin ISDESTROY() 4995fdc4257SSteve Yin // #CHECK# 5005fdc4257SSteve Yin if(pvarRole == NULL) 5015fdc4257SSteve Yin { 5025fdc4257SSteve Yin return E_INVALIDARG; 5035fdc4257SSteve Yin } 5045fdc4257SSteve Yin if(varChild.vt == VT_I4) 5055fdc4257SSteve Yin { 5065fdc4257SSteve Yin 5075fdc4257SSteve Yin if(varChild.lVal == CHILDID_SELF) 5085fdc4257SSteve Yin { 5095fdc4257SSteve Yin if( m_iRole < IA2_ROLE_CAPTION ) 5105fdc4257SSteve Yin { 5115fdc4257SSteve Yin VariantInit(pvarRole); 5125fdc4257SSteve Yin pvarRole->vt = VT_I4; 5135fdc4257SSteve Yin pvarRole->lVal = m_iRole; 5145fdc4257SSteve Yin } 5155fdc4257SSteve Yin else 5165fdc4257SSteve Yin { 5175fdc4257SSteve Yin VariantInit(pvarRole); 5185fdc4257SSteve Yin pvarRole->vt = VT_I4; 5195fdc4257SSteve Yin pvarRole->lVal = ROLE_SYSTEM_CLIENT; 5205fdc4257SSteve Yin } 5215fdc4257SSteve Yin return S_OK; 5225fdc4257SSteve Yin } 5235fdc4257SSteve Yin 5245fdc4257SSteve Yin 5255fdc4257SSteve Yin long lVal = varChild.lVal; 5265fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 5275fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 5285fdc4257SSteve Yin if(!pChild) 5295fdc4257SSteve Yin return E_FAIL; 5305fdc4257SSteve Yin return pChild->get_accRole(varChild,pvarRole); 5315fdc4257SSteve Yin } 5325fdc4257SSteve Yin return S_FALSE; 5335fdc4257SSteve Yin 5345fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 5355fdc4257SSteve Yin } 5365fdc4257SSteve Yin 5375fdc4257SSteve Yin /** 5385fdc4257SSteve Yin * Returns the accessible state of the current COM object self or its one child to AT. 5395fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 5405fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 5415fdc4257SSteve Yin * @param pvarState, [in,out] use to return the state of the proper object. 5425fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 5435fdc4257SSteve Yin */ 5445fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accState(VARIANT varChild, VARIANT *pvarState) 5455fdc4257SSteve Yin { 5465fdc4257SSteve Yin 5475fdc4257SSteve Yin CHECK_ENABLE_INF 5485fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 5495fdc4257SSteve Yin ISDESTROY() 5505fdc4257SSteve Yin // #CHECK# 5515fdc4257SSteve Yin if(pvarState == NULL) 5525fdc4257SSteve Yin { 5535fdc4257SSteve Yin return E_INVALIDARG; 5545fdc4257SSteve Yin } 5555fdc4257SSteve Yin if(varChild.vt==VT_I4) 5565fdc4257SSteve Yin { 5575fdc4257SSteve Yin if(varChild.lVal == CHILDID_SELF) 5585fdc4257SSteve Yin { 5595fdc4257SSteve Yin if(pUNOInterface) 5605fdc4257SSteve Yin { 5615fdc4257SSteve Yin Reference< XAccessibleContext > pContext = pUNOInterface->getAccessibleContext(); 5625fdc4257SSteve Yin if(pContext.is()) 5635fdc4257SSteve Yin { 5645fdc4257SSteve Yin // add the STATE_SYSTEM_LINKED state 5655fdc4257SSteve Yin Reference< XAccessibleHypertext > pRHypertext(pContext,UNO_QUERY); 5665fdc4257SSteve Yin if(pRHypertext.is()) 5675fdc4257SSteve Yin { 5685fdc4257SSteve Yin if( pRHypertext->getHyperLinkCount() > 0 ) 5695fdc4257SSteve Yin m_dState |= STATE_SYSTEM_LINKED; 5705fdc4257SSteve Yin else 5715fdc4257SSteve Yin m_dState &= ~STATE_SYSTEM_LINKED; 5725fdc4257SSteve Yin } 5735fdc4257SSteve Yin else 5745fdc4257SSteve Yin m_dState &= ~STATE_SYSTEM_LINKED; 5755fdc4257SSteve Yin } 5765fdc4257SSteve Yin } 5775fdc4257SSteve Yin 5785fdc4257SSteve Yin VariantInit(pvarState); 5795fdc4257SSteve Yin pvarState->vt = VT_I4; 5805fdc4257SSteve Yin pvarState->lVal = m_dState; 5815fdc4257SSteve Yin return S_OK; 5825fdc4257SSteve Yin } 5835fdc4257SSteve Yin 5845fdc4257SSteve Yin long lVal = varChild.lVal; 5855fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 5865fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 5875fdc4257SSteve Yin if(!pChild) 5885fdc4257SSteve Yin return E_FAIL; 5895fdc4257SSteve Yin return pChild->get_accState(varChild,pvarState); 5905fdc4257SSteve Yin } 5915fdc4257SSteve Yin return S_FALSE; 5925fdc4257SSteve Yin 5935fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 5945fdc4257SSteve Yin } 5955fdc4257SSteve Yin 5965fdc4257SSteve Yin /** 5975fdc4257SSteve Yin * Returns the accessible helpString of the current COM object self or its one child to AT. 5985fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 5995fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 6005fdc4257SSteve Yin * @param pszHelp, [in,out] use to return the helpString of the proper object. 6015fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 6025fdc4257SSteve Yin */ 6035fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accHelp(VARIANT, BSTR *) 6045fdc4257SSteve Yin { 6055fdc4257SSteve Yin return E_NOTIMPL; 6065fdc4257SSteve Yin } 6075fdc4257SSteve Yin 6085fdc4257SSteve Yin /** 6095fdc4257SSteve Yin * Returns the accessible HelpTopic of the current COM object self or its one child to AT. 6105fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 6115fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 6125fdc4257SSteve Yin * @param pszHelpFile, [in,out] use to return the HelpTopic of the proper object. 6135fdc4257SSteve Yin * @param pidTopic, use to return the HelpTopic ID of the proper object. 6145fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 6155fdc4257SSteve Yin * Not implemented yet 6165fdc4257SSteve Yin */ 6175fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accHelpTopic(BSTR *, VARIANT, long *) 6185fdc4257SSteve Yin { 6195fdc4257SSteve Yin return E_NOTIMPL; 6205fdc4257SSteve Yin } 6215fdc4257SSteve Yin 6225fdc4257SSteve Yin static void GetMnemonicChar( const ::rtl::OUString& aStr, WCHAR* wStr) 6235fdc4257SSteve Yin { 6245fdc4257SSteve Yin int nLen = aStr.pData->length; 6255fdc4257SSteve Yin int i = 0; 6265fdc4257SSteve Yin WCHAR* text = aStr.pData->buffer; 6275fdc4257SSteve Yin 6285fdc4257SSteve Yin while ( i < nLen ) 6295fdc4257SSteve Yin { 6305fdc4257SSteve Yin if ( text[i] == L'~' ) 6315fdc4257SSteve Yin if ( text[i+1] != L'~' ) 6325fdc4257SSteve Yin { 6335fdc4257SSteve Yin wStr[0] = text[i+1]; 6345fdc4257SSteve Yin break; 6355fdc4257SSteve Yin } 6365fdc4257SSteve Yin i++; 6375fdc4257SSteve Yin } 6385fdc4257SSteve Yin } 6395fdc4257SSteve Yin 6405fdc4257SSteve Yin /** 6415fdc4257SSteve Yin * Returns the accessible keyboard shortcut of the current COM object self or its one child to AT. 6425fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 6435fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 6445fdc4257SSteve Yin * @param pszKeyboardShortcut, [in,out] use to return the kbshortcut of the proper object. 6455fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 6465fdc4257SSteve Yin */ 6475fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut) 6485fdc4257SSteve Yin { 6495fdc4257SSteve Yin 6505fdc4257SSteve Yin CHECK_ENABLE_INF 6515fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 6525fdc4257SSteve Yin 6535fdc4257SSteve Yin ISDESTROY() 6545fdc4257SSteve Yin // #CHECK# 6555fdc4257SSteve Yin if(pszKeyboardShortcut == NULL) 6565fdc4257SSteve Yin { 6575fdc4257SSteve Yin return E_INVALIDARG; 6585fdc4257SSteve Yin } 6595fdc4257SSteve Yin 6605fdc4257SSteve Yin if(varChild.vt==VT_I4) 6615fdc4257SSteve Yin { 6625fdc4257SSteve Yin if(varChild.lVal == CHILDID_SELF) 6635fdc4257SSteve Yin { 6645fdc4257SSteve Yin if( pUNOInterface ) 6655fdc4257SSteve Yin { 6665fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 6675fdc4257SSteve Yin if( !pRContext.is() ) 6685fdc4257SSteve Yin return S_FALSE; 6695fdc4257SSteve Yin 6705fdc4257SSteve Yin Reference<XAccessibleAction> pRXI(pRContext,UNO_QUERY); 6715fdc4257SSteve Yin 6725fdc4257SSteve Yin OLECHAR wString[64]={0}; 6735fdc4257SSteve Yin 6745fdc4257SSteve Yin if( pRXI.is() && pRXI->getAccessibleActionCount() >= 1) 6755fdc4257SSteve Yin { 6765fdc4257SSteve Yin Reference< XAccessibleKeyBinding > binding = pRXI->getAccessibleActionKeyBinding(0); 6775fdc4257SSteve Yin if( binding.is() ) 6785fdc4257SSteve Yin { 6795fdc4257SSteve Yin long nCount = binding->getAccessibleKeyBindingCount(); 6805fdc4257SSteve Yin if(nCount >= 1) 6815fdc4257SSteve Yin { 6825fdc4257SSteve Yin CAccAction::GetkeyBindingStrByXkeyBinding( binding->getAccessibleKeyBinding(0),wString ); 6835fdc4257SSteve Yin } 6845fdc4257SSteve Yin } 6855fdc4257SSteve Yin } 6865fdc4257SSteve Yin if(wString[0] == 0) 6875fdc4257SSteve Yin { 6885fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext->getAccessibleRelationSet(); 6895fdc4257SSteve Yin if(!pRrelationSet.is()) 6905fdc4257SSteve Yin { 6915fdc4257SSteve Yin return S_FALSE; 6925fdc4257SSteve Yin } 6935fdc4257SSteve Yin 6945fdc4257SSteve Yin long nRelCount = pRrelationSet->getRelationCount(); 6955fdc4257SSteve Yin 6965fdc4257SSteve Yin // Modified by Steve Yin, for SODC_1552 6975fdc4257SSteve Yin if( /*nRelCount <= 0 &&*/ m_iRole == ROLE_SYSTEM_TEXT ) 6985fdc4257SSteve Yin { 6995fdc4257SSteve Yin VARIANT varParentRole; 7005fdc4257SSteve Yin VariantInit( &varParentRole ); 7015fdc4257SSteve Yin 7025fdc4257SSteve Yin m_pIParent->get_accRole(varChild, &varParentRole); 7035fdc4257SSteve Yin 7045fdc4257SSteve Yin if( m_pIParent && varParentRole.lVal == ROLE_SYSTEM_COMBOBOX ) // edit in comoboBox 7055fdc4257SSteve Yin { 7065fdc4257SSteve Yin m_pIParent->get_accKeyboardShortcut(varChild, pszKeyboardShortcut); 7075fdc4257SSteve Yin return S_OK; 7085fdc4257SSteve Yin } 7095fdc4257SSteve Yin } 7105fdc4257SSteve Yin 7115fdc4257SSteve Yin AccessibleRelation *paccRelation = NULL; 7125fdc4257SSteve Yin AccessibleRelation accRelation; 7135fdc4257SSteve Yin for(int i=0; i<nRelCount ; i++) 7145fdc4257SSteve Yin { 7155fdc4257SSteve Yin if( pRrelationSet->getRelation(i).RelationType == 6 ) 7165fdc4257SSteve Yin { 7175fdc4257SSteve Yin accRelation = pRrelationSet->getRelation(i); 7185fdc4257SSteve Yin paccRelation = &accRelation; 7195fdc4257SSteve Yin } 7205fdc4257SSteve Yin } 7215fdc4257SSteve Yin 7225fdc4257SSteve Yin if(paccRelation == NULL) 7235fdc4257SSteve Yin return S_FALSE; 7245fdc4257SSteve Yin 7255fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = paccRelation->TargetSet; 7265fdc4257SSteve Yin Reference<XInterface> pRAcc = xTargets[0]; 7275fdc4257SSteve Yin 7285fdc4257SSteve Yin XAccessible* pXAcc = (XAccessible*)pRAcc.get(); 7295fdc4257SSteve Yin 7305fdc4257SSteve Yin Reference<XAccessibleContext> pRLebelContext = pXAcc->getAccessibleContext(); 7315fdc4257SSteve Yin if(!pRLebelContext.is()) 7325fdc4257SSteve Yin return S_FALSE; 7335fdc4257SSteve Yin 7345fdc4257SSteve Yin pRrelationSet = pRLebelContext->getAccessibleRelationSet(); 7355fdc4257SSteve Yin nRelCount = pRrelationSet->getRelationCount(); 7365fdc4257SSteve Yin 7375fdc4257SSteve Yin paccRelation = NULL; 7385fdc4257SSteve Yin for(int j=0; j<nRelCount ; j++) 7395fdc4257SSteve Yin { 7405fdc4257SSteve Yin if( pRrelationSet->getRelation(j).RelationType == 5 ) 7415fdc4257SSteve Yin { 7425fdc4257SSteve Yin accRelation = pRrelationSet->getRelation(j); 7435fdc4257SSteve Yin paccRelation = &accRelation; 7445fdc4257SSteve Yin } 7455fdc4257SSteve Yin } 7465fdc4257SSteve Yin 7475fdc4257SSteve Yin if(paccRelation) 7485fdc4257SSteve Yin { 7495fdc4257SSteve Yin xTargets = paccRelation->TargetSet; 7505fdc4257SSteve Yin pRAcc = xTargets[0]; 7515fdc4257SSteve Yin if(pUNOInterface != (XAccessible*)pRAcc.get()) 7525fdc4257SSteve Yin return S_FALSE; 7535fdc4257SSteve Yin } 7545fdc4257SSteve Yin 7555fdc4257SSteve Yin Reference<XAccessibleExtendedComponent> pRXIE(pRLebelContext,UNO_QUERY); 7565fdc4257SSteve Yin if(!pRXIE.is()) 7575fdc4257SSteve Yin return S_FALSE; 7585fdc4257SSteve Yin 7595fdc4257SSteve Yin ::rtl::OUString ouStr = pRXIE->getTitledBorderText(); 7605fdc4257SSteve Yin WCHAR key[2] = {NULL}; 7615fdc4257SSteve Yin GetMnemonicChar(ouStr, key); 7625fdc4257SSteve Yin if(key[0] != 0) 7635fdc4257SSteve Yin { 7645fdc4257SSteve Yin wcscat(wString, L"Alt+"); 7655fdc4257SSteve Yin wcscat(wString, key); 7665fdc4257SSteve Yin } 7675fdc4257SSteve Yin else 7685fdc4257SSteve Yin return S_FALSE; 7695fdc4257SSteve Yin } 7705fdc4257SSteve Yin 7715fdc4257SSteve Yin SAFE_SYSFREESTRING(*pszKeyboardShortcut); 7725fdc4257SSteve Yin *pszKeyboardShortcut = SysAllocString(wString); 7735fdc4257SSteve Yin 7745fdc4257SSteve Yin return S_OK; 7755fdc4257SSteve Yin } 7765fdc4257SSteve Yin else 7775fdc4257SSteve Yin { 7785fdc4257SSteve Yin return S_FALSE; 7795fdc4257SSteve Yin } 7805fdc4257SSteve Yin } 7815fdc4257SSteve Yin 7825fdc4257SSteve Yin long lVal = varChild.lVal; 7835fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 7845fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 7855fdc4257SSteve Yin if(!pChild) 7865fdc4257SSteve Yin return E_FAIL; 7875fdc4257SSteve Yin 7885fdc4257SSteve Yin return pChild->get_accKeyboardShortcut(varChild,pszKeyboardShortcut); 7895fdc4257SSteve Yin } 7905fdc4257SSteve Yin return S_FALSE; 7915fdc4257SSteve Yin 7925fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 7935fdc4257SSteve Yin } 7945fdc4257SSteve Yin 7955fdc4257SSteve Yin /** 7965fdc4257SSteve Yin * Returns the current focused child to AT. 7975fdc4257SSteve Yin * @param pvarChild, [in,out] vt member of pvarChild must be VT_I4,and lVal member stores the child ID, 7985fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 7995fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 8005fdc4257SSteve Yin */ 8015fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accFocus(VARIANT *pvarChild) 8025fdc4257SSteve Yin { 8035fdc4257SSteve Yin 8045fdc4257SSteve Yin CHECK_ENABLE_INF 8055fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8065fdc4257SSteve Yin ISDESTROY() 8075fdc4257SSteve Yin // #CHECK# 8085fdc4257SSteve Yin if(pvarChild == NULL) 8095fdc4257SSteve Yin { 8105fdc4257SSteve Yin return E_INVALIDARG; 8115fdc4257SSteve Yin } 8125fdc4257SSteve Yin if( m_dFocusChildID==UACC_NO_FOCUS ) 8135fdc4257SSteve Yin { 8145fdc4257SSteve Yin pvarChild->vt = VT_EMPTY;//no focus on the object and its children 8155fdc4257SSteve Yin return S_OK; 8165fdc4257SSteve Yin } 8175fdc4257SSteve Yin //if the descendant of current object has focus indicated by m_dFocusChildID, return the IDispatch of this focused object 8185fdc4257SSteve Yin else 8195fdc4257SSteve Yin { 8205fdc4257SSteve Yin IMAccessible* pIMAcc = NULL; 8215fdc4257SSteve Yin g_pAgent->GetIAccessibleFromResID(m_dFocusChildID,&pIMAcc); 8225fdc4257SSteve Yin pIMAcc->AddRef(); 8235fdc4257SSteve Yin pvarChild->vt = VT_DISPATCH; 8245fdc4257SSteve Yin pvarChild->pdispVal = pIMAcc; 8255fdc4257SSteve Yin 8265fdc4257SSteve Yin } 8275fdc4257SSteve Yin return S_OK; 8285fdc4257SSteve Yin 8295fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 8305fdc4257SSteve Yin } 8315fdc4257SSteve Yin 8325fdc4257SSteve Yin /** 8335fdc4257SSteve Yin * Returns the selection of the current COM object to AT. 8345fdc4257SSteve Yin * @param pvarChildren,[in,out] 8355fdc4257SSteve Yin * if selection num is 0,return VT_EMPTY for vt, 8365fdc4257SSteve Yin * if selection num is 1,return VT_I4 for vt,and child index for lVal 8375fdc4257SSteve Yin * if selection num >1,return VT_UNKNOWN for vt, and IEnumVariant* for punkVal 8385fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 8395fdc4257SSteve Yin */ 8405fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_accSelection(VARIANT *pvarChildren) 8415fdc4257SSteve Yin { 8425fdc4257SSteve Yin 8435fdc4257SSteve Yin CHECK_ENABLE_INF 8445fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8455fdc4257SSteve Yin ISDESTROY() 8465fdc4257SSteve Yin // #CHECK# 8475fdc4257SSteve Yin if(pvarChildren == NULL) 8485fdc4257SSteve Yin { 8495fdc4257SSteve Yin return E_INVALIDARG; 8505fdc4257SSteve Yin } 8515fdc4257SSteve Yin switch(m_pEnumVar->GetCountOfElements()) 8525fdc4257SSteve Yin { 8535fdc4257SSteve Yin case 0: 8545fdc4257SSteve Yin pvarChildren->vt = VT_EMPTY; 8555fdc4257SSteve Yin break; 8565fdc4257SSteve Yin case 1: 8575fdc4257SSteve Yin VARIANT varTmp[1]; 8585fdc4257SSteve Yin ULONG count; 8595fdc4257SSteve Yin VariantInit(&varTmp[0]); 8605fdc4257SSteve Yin m_pEnumVar->Next(1,varTmp,&count); 8615fdc4257SSteve Yin if(count!=1) 8625fdc4257SSteve Yin return S_FALSE; 8635fdc4257SSteve Yin pvarChildren->vt = VT_I4; 8645fdc4257SSteve Yin pvarChildren->lVal = varTmp[0].lVal; 8655fdc4257SSteve Yin VariantClear(&varTmp[0]); 8665fdc4257SSteve Yin m_pEnumVar->Reset(); 8675fdc4257SSteve Yin break; 8685fdc4257SSteve Yin default: 8695fdc4257SSteve Yin pvarChildren->vt = VT_UNKNOWN; 8705fdc4257SSteve Yin m_pEnumVar->AddRef(); 8715fdc4257SSteve Yin pvarChildren->punkVal = m_pEnumVar; 8725fdc4257SSteve Yin break; 8735fdc4257SSteve Yin } 8745fdc4257SSteve Yin return S_OK; 8755fdc4257SSteve Yin 8765fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 8775fdc4257SSteve Yin } 8785fdc4257SSteve Yin 8795fdc4257SSteve Yin /** 8805fdc4257SSteve Yin * Returns the location of the current COM object self or its one child to AT. 8815fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 8825fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 8835fdc4257SSteve Yin * @param pxLeft, [in,out] use to return the x-coordination of the proper object. 8845fdc4257SSteve Yin * @param pyTop, [in,out] use to return the y-coordination of the proper object. 8855fdc4257SSteve Yin * @param pcxWidth, [in,out] use to return the x-coordination width of the proper object. 8865fdc4257SSteve Yin * @param pcyHeight, [in,out] use to return the y-coordination height of the proper object. 8875fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 8885fdc4257SSteve Yin */ 8895fdc4257SSteve Yin STDMETHODIMP CMAccessible::accLocation(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild) 8905fdc4257SSteve Yin { 8915fdc4257SSteve Yin 8925fdc4257SSteve Yin CHECK_ENABLE_INF 8935fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 8945fdc4257SSteve Yin ISDESTROY() 8955fdc4257SSteve Yin // #CHECK# 8965fdc4257SSteve Yin if(pxLeft == NULL || pyTop == NULL || pcxWidth == NULL || pcyHeight == NULL) 8975fdc4257SSteve Yin { 8985fdc4257SSteve Yin return E_INVALIDARG; 8995fdc4257SSteve Yin } 9005fdc4257SSteve Yin 9015fdc4257SSteve Yin if(varChild.vt==VT_I4) 9025fdc4257SSteve Yin { 9035fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 9045fdc4257SSteve Yin { 9055fdc4257SSteve Yin 9065fdc4257SSteve Yin if(pUNOInterface) 9075fdc4257SSteve Yin { 9085fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = pUNOInterface->getAccessibleContext(); 9095fdc4257SSteve Yin if( !pRContext.is() ) 9105fdc4257SSteve Yin return S_FALSE; 9115fdc4257SSteve Yin Reference< XAccessibleComponent > pRComponent(pRContext,UNO_QUERY); 9125fdc4257SSteve Yin if( !pRComponent.is() ) 9135fdc4257SSteve Yin return S_FALSE; 9145fdc4257SSteve Yin 9155fdc4257SSteve Yin ::com::sun::star::awt::Point pCPoint = pRComponent->getLocationOnScreen(); 9165fdc4257SSteve Yin ::com::sun::star::awt::Size pCSize = pRComponent->getSize(); 9175fdc4257SSteve Yin *pxLeft = pCPoint.X; 9185fdc4257SSteve Yin *pyTop = pCPoint.Y; 9195fdc4257SSteve Yin *pcxWidth = pCSize.Width; 9205fdc4257SSteve Yin *pcyHeight = pCSize.Height; 9215fdc4257SSteve Yin return S_OK; 9225fdc4257SSteve Yin } 9235fdc4257SSteve Yin else 9245fdc4257SSteve Yin { 9255fdc4257SSteve Yin *pxLeft = m_sLocation.m_dLeft; 9265fdc4257SSteve Yin *pyTop = m_sLocation.m_dTop; 9275fdc4257SSteve Yin *pcxWidth = m_sLocation.m_dWidth; 9285fdc4257SSteve Yin *pcyHeight = m_sLocation.m_dHeight; 9295fdc4257SSteve Yin return S_OK; 9305fdc4257SSteve Yin } 9315fdc4257SSteve Yin } 9325fdc4257SSteve Yin 9335fdc4257SSteve Yin } 9345fdc4257SSteve Yin return S_FALSE; 9355fdc4257SSteve Yin 9365fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9375fdc4257SSteve Yin } 9385fdc4257SSteve Yin 9395fdc4257SSteve Yin /** 9405fdc4257SSteve Yin * Returns the current focused child to AT. 9415fdc4257SSteve Yin * @param navDir, the direction flag of the navigation. 9425fdc4257SSteve Yin * @param varStart, the start child id of this navigation action. 9435fdc4257SSteve Yin * @param pvarEndUpAt, [in,out] the end up child of this navigation action. 9445fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 9455fdc4257SSteve Yin */ 9465fdc4257SSteve Yin STDMETHODIMP CMAccessible::accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt) 9475fdc4257SSteve Yin { 9485fdc4257SSteve Yin 9495fdc4257SSteve Yin CHECK_ENABLE_INF 9505fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 9515fdc4257SSteve Yin ISDESTROY() 9525fdc4257SSteve Yin // #CHECK# 9535fdc4257SSteve Yin if(pvarEndUpAt == NULL) 9545fdc4257SSteve Yin { 9555fdc4257SSteve Yin return E_INVALIDARG; 9565fdc4257SSteve Yin } 9575fdc4257SSteve Yin HRESULT ret = E_FAIL; 9585fdc4257SSteve Yin switch (navDir) 9595fdc4257SSteve Yin { 9605fdc4257SSteve Yin case NAVDIR_FIRSTCHILD: 9615fdc4257SSteve Yin ret = GetFirstChild(varStart,pvarEndUpAt); 9625fdc4257SSteve Yin break; 9635fdc4257SSteve Yin case NAVDIR_LASTCHILD: 9645fdc4257SSteve Yin ret = GetLastChild(varStart,pvarEndUpAt); 9655fdc4257SSteve Yin break; 9665fdc4257SSteve Yin case NAVDIR_NEXT: 9675fdc4257SSteve Yin ret = GetNextSibling(varStart,pvarEndUpAt); 9685fdc4257SSteve Yin break; 9695fdc4257SSteve Yin case NAVDIR_PREVIOUS: 9705fdc4257SSteve Yin ret = GetPreSibling(varStart,pvarEndUpAt); 9715fdc4257SSteve Yin break; 9725fdc4257SSteve Yin case NAVDIR_DOWN://do not implement temporarily 9735fdc4257SSteve Yin break; 9745fdc4257SSteve Yin case NAVDIR_UP://do not implement temporarily 9755fdc4257SSteve Yin break; 9765fdc4257SSteve Yin case NAVDIR_LEFT://do not implement temporarily 9775fdc4257SSteve Yin break; 9785fdc4257SSteve Yin case NAVDIR_RIGHT://do not implement temporarily 9795fdc4257SSteve Yin break; 9805fdc4257SSteve Yin default: 9815fdc4257SSteve Yin break; 9825fdc4257SSteve Yin }; 9835fdc4257SSteve Yin return ret; 9845fdc4257SSteve Yin 9855fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 9865fdc4257SSteve Yin } 9875fdc4257SSteve Yin 9885fdc4257SSteve Yin STDMETHODIMP CMAccessible::accHitTest(long xLeft, long yTop, VARIANT *pvarChild) 9895fdc4257SSteve Yin { 9905fdc4257SSteve Yin 9915fdc4257SSteve Yin CHECK_ENABLE_INF 9925fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 9935fdc4257SSteve Yin ISDESTROY() 9945fdc4257SSteve Yin // #CHECK# 9955fdc4257SSteve Yin if(pvarChild == NULL) 9965fdc4257SSteve Yin { 9975fdc4257SSteve Yin return E_INVALIDARG; 9985fdc4257SSteve Yin } 9995fdc4257SSteve Yin long x, y, w, h; 10005fdc4257SSteve Yin VARIANT varSelf; 10015fdc4257SSteve Yin VariantInit(&varSelf); 10025fdc4257SSteve Yin varSelf.vt = VT_I4; 10035fdc4257SSteve Yin varSelf.lVal = CHILDID_SELF; 10045fdc4257SSteve Yin accLocation(&x,&y,&w,&h,varSelf); 10055fdc4257SSteve Yin if( (x < xLeft && (x + w) >xLeft) && (y < yTop && (y + h) >yTop) ) 10065fdc4257SSteve Yin { 10075fdc4257SSteve Yin int i, nCount; 10085fdc4257SSteve Yin pvarChild->vt = VT_EMPTY; 10095fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = GetContextByXAcc(pUNOInterface); 10105fdc4257SSteve Yin nCount = pRContext->getAccessibleChildCount(); 10115fdc4257SSteve Yin if(nCount > 256) 10125fdc4257SSteve Yin return E_FAIL; 10135fdc4257SSteve Yin IMAccessible* child = NULL; 10145fdc4257SSteve Yin for( i = 0; i<nCount; i++) 10155fdc4257SSteve Yin { 10165fdc4257SSteve Yin 10175fdc4257SSteve Yin child = GetChildInterface(i + 1); 10185fdc4257SSteve Yin if(child && child->accHitTest(xLeft,yTop,pvarChild) == S_OK) 10195fdc4257SSteve Yin break; 10205fdc4257SSteve Yin } 10215fdc4257SSteve Yin 10225fdc4257SSteve Yin if(pvarChild->vt == VT_DISPATCH) 10235fdc4257SSteve Yin return S_OK; 10245fdc4257SSteve Yin 10255fdc4257SSteve Yin if( i < nCount) 10265fdc4257SSteve Yin { 10275fdc4257SSteve Yin pvarChild->vt = VT_DISPATCH; 10285fdc4257SSteve Yin pvarChild->pdispVal = child; 10295fdc4257SSteve Yin child->AddRef(); 10305fdc4257SSteve Yin } 10315fdc4257SSteve Yin else 10325fdc4257SSteve Yin { 10335fdc4257SSteve Yin pvarChild->vt = VT_I4; 10345fdc4257SSteve Yin pvarChild->lVal = CHILDID_SELF; 10355fdc4257SSteve Yin } 10365fdc4257SSteve Yin return S_OK; 10375fdc4257SSteve Yin } 10385fdc4257SSteve Yin return S_FALSE; 10395fdc4257SSteve Yin 10405fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 10415fdc4257SSteve Yin } 10425fdc4257SSteve Yin 10435fdc4257SSteve Yin /** 10445fdc4257SSteve Yin * Get The other Interface from CMAccessible. 10455fdc4257SSteve Yin * @param guidService, must be IID_IAccessible here. 10465fdc4257SSteve Yin * @param riid, the IID interface . 10475fdc4257SSteve Yin * @return S_OK if successful and S_FALSE if failure. 10485fdc4257SSteve Yin */ 10495fdc4257SSteve Yin STDMETHODIMP CMAccessible::QueryService(REFGUID guidService, REFIID riid, void** ppvObject) 10505fdc4257SSteve Yin { 10515fdc4257SSteve Yin if( InlineIsEqualGUID(guidService, IID_IAccessible) ) 10525fdc4257SSteve Yin return QueryInterface(riid, ppvObject); 10535fdc4257SSteve Yin return S_FALSE; 10545fdc4257SSteve Yin } 10555fdc4257SSteve Yin 10565fdc4257SSteve Yin /** 10575fdc4257SSteve Yin * Set the accessible name of the current COM object self or its one child from UNO. 10585fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 10595fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 10605fdc4257SSteve Yin * @param szName, the name used to set the name of the proper object. 10615fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 10625fdc4257SSteve Yin */ 10635fdc4257SSteve Yin STDMETHODIMP CMAccessible::put_accName(VARIANT varChild, BSTR szName) 10645fdc4257SSteve Yin { 10655fdc4257SSteve Yin 10665fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 10675fdc4257SSteve Yin ISDESTROY() 10685fdc4257SSteve Yin if(varChild.vt==VT_I4) 10695fdc4257SSteve Yin { 10705fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 10715fdc4257SSteve Yin { 10725fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszName); 10735fdc4257SSteve Yin m_pszName=SysAllocString(szName); 10745fdc4257SSteve Yin return S_OK; 10755fdc4257SSteve Yin } 10765fdc4257SSteve Yin 10775fdc4257SSteve Yin long lVal = varChild.lVal; 10785fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 10795fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 10805fdc4257SSteve Yin if(!pChild) 10815fdc4257SSteve Yin return E_FAIL; 10825fdc4257SSteve Yin return pChild->put_accName(varChild,szName); 10835fdc4257SSteve Yin } 10845fdc4257SSteve Yin return E_FAIL; 10855fdc4257SSteve Yin 10865fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 10875fdc4257SSteve Yin } 10885fdc4257SSteve Yin 10895fdc4257SSteve Yin /** 10905fdc4257SSteve Yin * Set the accessible value of the current COM object self or its one child from UNO. 10915fdc4257SSteve Yin * @param varChild, vt member of varChild must be VT_I4,and lVal member stores the child ID, 10925fdc4257SSteve Yin * the child ID specify child index from 0 to children count, 0 stands for object self. 10935fdc4257SSteve Yin * @param szValue, the value used to set the value of the proper object. 10945fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 10955fdc4257SSteve Yin */ 10965fdc4257SSteve Yin STDMETHODIMP CMAccessible::put_accValue(VARIANT varChild, BSTR szValue) 10975fdc4257SSteve Yin { 10985fdc4257SSteve Yin 10995fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 11005fdc4257SSteve Yin ISDESTROY() 11015fdc4257SSteve Yin if(varChild.vt==VT_I4) 11025fdc4257SSteve Yin { 11035fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 11045fdc4257SSteve Yin { 11055fdc4257SSteve Yin SysAllocString(m_pszValue); 11065fdc4257SSteve Yin m_pszValue=SysAllocString(szValue); 11075fdc4257SSteve Yin return S_OK; 11085fdc4257SSteve Yin } 11095fdc4257SSteve Yin 11105fdc4257SSteve Yin long lVal = varChild.lVal; 11115fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 11125fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 11135fdc4257SSteve Yin if(!pChild) 11145fdc4257SSteve Yin return E_FAIL; 11155fdc4257SSteve Yin return pChild->put_accValue(varChild,szValue); 11165fdc4257SSteve Yin } 11175fdc4257SSteve Yin return E_FAIL; 11185fdc4257SSteve Yin 11195fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 11205fdc4257SSteve Yin } 11215fdc4257SSteve Yin 11225fdc4257SSteve Yin /** 11235fdc4257SSteve Yin * Set the accessible name of the current COM object self from UNO. 11245fdc4257SSteve Yin * @param pszName, the name value used to set the name of the current object. 11255fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11265fdc4257SSteve Yin */ 11275fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccName(const OLECHAR __RPC_FAR *pszName) 11285fdc4257SSteve Yin { 11295fdc4257SSteve Yin 11305fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 11315fdc4257SSteve Yin ISDESTROY() 11325fdc4257SSteve Yin // #CHECK# 11335fdc4257SSteve Yin if(pszName == NULL) 11345fdc4257SSteve Yin { 11355fdc4257SSteve Yin return E_INVALIDARG; 11365fdc4257SSteve Yin } 11375fdc4257SSteve Yin 11385fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszName);//?? 11395fdc4257SSteve Yin m_pszName = SysAllocString(pszName); 11405fdc4257SSteve Yin if(m_pszName==NULL) 11415fdc4257SSteve Yin return E_FAIL; 11425fdc4257SSteve Yin return S_OK; 11435fdc4257SSteve Yin 11445fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 11455fdc4257SSteve Yin } 11465fdc4257SSteve Yin 11475fdc4257SSteve Yin /** 11485fdc4257SSteve Yin * Set the accessible role of the current COM object self from UNO. 11495fdc4257SSteve Yin * @param pRole, the role value used to set the role of the current object. 11505fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11515fdc4257SSteve Yin */ 11525fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccRole(unsigned short pRole) 11535fdc4257SSteve Yin { 11545fdc4257SSteve Yin m_iRole = pRole; 11555fdc4257SSteve Yin return S_OK; 11565fdc4257SSteve Yin } 11575fdc4257SSteve Yin 11585fdc4257SSteve Yin /** 11595fdc4257SSteve Yin * Add one state into the current state set for the current COM object from UNO. 11605fdc4257SSteve Yin * @param pXSate, the state used to set the name of the current object. 11615fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11625fdc4257SSteve Yin */ 11635fdc4257SSteve Yin STDMETHODIMP CMAccessible::DecreaseState(DWORD pXSate) 11645fdc4257SSteve Yin { 11655fdc4257SSteve Yin m_dState &= (~pXSate); 11665fdc4257SSteve Yin return S_OK; 11675fdc4257SSteve Yin } 11685fdc4257SSteve Yin 11695fdc4257SSteve Yin /** 11705fdc4257SSteve Yin * Delete one state into the current state set for the current COM object from UNO. 11715fdc4257SSteve Yin * @param pXSate, the state used to set the name of the current object. 11725fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11735fdc4257SSteve Yin */ 11745fdc4257SSteve Yin STDMETHODIMP CMAccessible::IncreaseState(DWORD pXSate) 11755fdc4257SSteve Yin { 11765fdc4257SSteve Yin m_dState |= pXSate; 11775fdc4257SSteve Yin return S_OK; 11785fdc4257SSteve Yin } 11795fdc4257SSteve Yin 11805fdc4257SSteve Yin /** 11815fdc4257SSteve Yin * Set state into the current state set for the current COM object from UNO. 11825fdc4257SSteve Yin * @param pXSate, the state used to set the name of the current object. 11835fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11845fdc4257SSteve Yin */ 11855fdc4257SSteve Yin STDMETHODIMP CMAccessible::SetState(DWORD pXSate) 11865fdc4257SSteve Yin { 11875fdc4257SSteve Yin m_dState = pXSate; 11885fdc4257SSteve Yin return S_OK; 11895fdc4257SSteve Yin } 11905fdc4257SSteve Yin 11915fdc4257SSteve Yin 11925fdc4257SSteve Yin 11935fdc4257SSteve Yin /** 11945fdc4257SSteve Yin * Set the accessible description of the current COM object self from UNO. 11955fdc4257SSteve Yin * @param pszDescription, the name used to set the description of the current object. 11965fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 11975fdc4257SSteve Yin */ 11985fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccDescription(const OLECHAR __RPC_FAR *pszDescription) 11995fdc4257SSteve Yin { 12005fdc4257SSteve Yin 12015fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 12025fdc4257SSteve Yin ISDESTROY() 12035fdc4257SSteve Yin // #CHECK# 12045fdc4257SSteve Yin if(pszDescription == NULL) 12055fdc4257SSteve Yin { 12065fdc4257SSteve Yin return E_INVALIDARG; 12075fdc4257SSteve Yin } 12085fdc4257SSteve Yin 12095fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszDescription); 12105fdc4257SSteve Yin m_pszDescription = SysAllocString(pszDescription); 12115fdc4257SSteve Yin 12125fdc4257SSteve Yin if(m_pszDescription==NULL) 12135fdc4257SSteve Yin return E_FAIL; 12145fdc4257SSteve Yin return S_OK; 12155fdc4257SSteve Yin 12165fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 12175fdc4257SSteve Yin } 12185fdc4257SSteve Yin 12195fdc4257SSteve Yin /** 12205fdc4257SSteve Yin * Set the accessible value of the current COM object self from UNO. 12215fdc4257SSteve Yin * @param pszAccValue, the name used to set the value of the current object. 12225fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 12235fdc4257SSteve Yin */ 12245fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccValue(const OLECHAR __RPC_FAR *pszAccValue) 12255fdc4257SSteve Yin { 12265fdc4257SSteve Yin 12275fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 12285fdc4257SSteve Yin ISDESTROY() 12295fdc4257SSteve Yin // #CHECK# 12305fdc4257SSteve Yin if(pszAccValue == NULL) 12315fdc4257SSteve Yin { 12325fdc4257SSteve Yin return E_INVALIDARG; 12335fdc4257SSteve Yin } 12345fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszValue); 12355fdc4257SSteve Yin m_pszValue = SysAllocString(pszAccValue); 12365fdc4257SSteve Yin if(m_pszValue==NULL) 12375fdc4257SSteve Yin return E_FAIL; 12385fdc4257SSteve Yin return S_OK; 12395fdc4257SSteve Yin 12405fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 12415fdc4257SSteve Yin } 12425fdc4257SSteve Yin 12435fdc4257SSteve Yin /** 12445fdc4257SSteve Yin * Set the HWND value of the current COM object self from UNO. It should set the parent IAccessible 12455fdc4257SSteve Yin * Object through the method AccessibleObjectFromWindow(...). 12465fdc4257SSteve Yin * @param hwnd, the HWND used to set the value of the current object. 12475fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 12485fdc4257SSteve Yin */ 12495fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccWindowHandle(HWND hwnd) 12505fdc4257SSteve Yin { 12515fdc4257SSteve Yin 12525fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 12535fdc4257SSteve Yin ISDESTROY() 12545fdc4257SSteve Yin m_hwnd = hwnd; 12555fdc4257SSteve Yin return S_OK; 12565fdc4257SSteve Yin 12575fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 12585fdc4257SSteve Yin } 12595fdc4257SSteve Yin 12605fdc4257SSteve Yin /** 12615fdc4257SSteve Yin * Set accessible focus by specifying child ID 12625fdc4257SSteve Yin * @param dChildID, the child id identifies the focus child. 12635fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 12645fdc4257SSteve Yin */ 12655fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccFocus(long dChildID) 12665fdc4257SSteve Yin { 12675fdc4257SSteve Yin 12685fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 12695fdc4257SSteve Yin ISDESTROY() 12705fdc4257SSteve Yin 12715fdc4257SSteve Yin if(dChildID==CHILDID_SELF) 12725fdc4257SSteve Yin { 12735fdc4257SSteve Yin if(m_pIParent) 12745fdc4257SSteve Yin { 12755fdc4257SSteve Yin m_pIParent->Put_XAccFocus(m_dChildID); 12765fdc4257SSteve Yin } 12775fdc4257SSteve Yin } 12785fdc4257SSteve Yin else 12795fdc4257SSteve Yin { 12805fdc4257SSteve Yin m_dFocusChildID = dChildID; 12815fdc4257SSteve Yin //traverse all ancestors to set the focused child ID so that when the get_accFocus is called on 12825fdc4257SSteve Yin //any of the ancestors, this id can be used to get the IAccessible of focused object. 12835fdc4257SSteve Yin if(m_pIParent) 12845fdc4257SSteve Yin { 12855fdc4257SSteve Yin m_pIParent->Put_XAccFocus(dChildID); 12865fdc4257SSteve Yin } 12875fdc4257SSteve Yin } 12885fdc4257SSteve Yin return S_OK; 12895fdc4257SSteve Yin 12905fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 12915fdc4257SSteve Yin } 12925fdc4257SSteve Yin 12935fdc4257SSteve Yin /** 12945fdc4257SSteve Yin *Set accessible object location for the current COM object 12955fdc4257SSteve Yin * @param sLocation, the location of the current object. 12965fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 12975fdc4257SSteve Yin */ 12985fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccLocation(const Location sLocation) 12995fdc4257SSteve Yin { 13005fdc4257SSteve Yin 13015fdc4257SSteve Yin this->m_sLocation = sLocation; 13025fdc4257SSteve Yin return S_OK; 13035fdc4257SSteve Yin } 13045fdc4257SSteve Yin 13055fdc4257SSteve Yin /** 13065fdc4257SSteve Yin * Set accessible parent object for the current COM object if 13075fdc4257SSteve Yin * the current object is a child of some COM object 13085fdc4257SSteve Yin * @param pIParent, the parent of the current object. 13095fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 13105fdc4257SSteve Yin */ 13115fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccParent(IMAccessible __RPC_FAR *pIParent) 13125fdc4257SSteve Yin { 13135fdc4257SSteve Yin this->m_pIParent = pIParent; 13145fdc4257SSteve Yin 13155fdc4257SSteve Yin if(pIParent) 13165fdc4257SSteve Yin m_pIParent->AddRef(); 13175fdc4257SSteve Yin 13185fdc4257SSteve Yin return S_OK; 13195fdc4257SSteve Yin } 13205fdc4257SSteve Yin 13215fdc4257SSteve Yin /** 13225fdc4257SSteve Yin * Set unique child id to COM 13235fdc4257SSteve Yin * @param dChildID, the id of the current object. 13245fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 13255fdc4257SSteve Yin */ 13265fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccChildID(long dChildID) 13275fdc4257SSteve Yin { 13285fdc4257SSteve Yin 13295fdc4257SSteve Yin this->m_dChildID = dChildID; 13305fdc4257SSteve Yin return S_OK; 13315fdc4257SSteve Yin } 13325fdc4257SSteve Yin 13335fdc4257SSteve Yin /** 13345fdc4257SSteve Yin * Set AccObjectManagerAgent object pointer to COM 13355fdc4257SSteve Yin * @param pAgent, the AccObjectManagerAgent point. 13365fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 13375fdc4257SSteve Yin */ 13385fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_XAccAgent(long pAgent) 13395fdc4257SSteve Yin { 13405fdc4257SSteve Yin g_pAgent = (AccObjectManagerAgent*)pAgent; 13415fdc4257SSteve Yin return S_OK; 13425fdc4257SSteve Yin } 13435fdc4257SSteve Yin 13445fdc4257SSteve Yin /** 13455fdc4257SSteve Yin * When a UNO control disposing, it disposes its listeners, 13465fdc4257SSteve Yin * then notify AccObject in bridge management, then notify 13475fdc4257SSteve Yin * COM that the XAccessible is invalid,so set pUNOInterface as NULL 13485fdc4257SSteve Yin * @param isDestroy, true is it need to be destroyed. 13495fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 13505fdc4257SSteve Yin */ 13515fdc4257SSteve Yin STDMETHODIMP CMAccessible::NotifyDestroy(BOOL isDestroy) 13525fdc4257SSteve Yin { 13535fdc4257SSteve Yin 13545fdc4257SSteve Yin m_isDestroy = isDestroy; 13555fdc4257SSteve Yin pUNOInterface = NULL; 13565fdc4257SSteve Yin return S_OK; 13575fdc4257SSteve Yin } 13585fdc4257SSteve Yin 13595fdc4257SSteve Yin /** 13605fdc4257SSteve Yin *private methods that help implement public functions 13615fdc4257SSteve Yin */ 13625fdc4257SSteve Yin 13635fdc4257SSteve Yin /** 13645fdc4257SSteve Yin * Return child interface pointer by child ID,note: need to call AddRef() 13655fdc4257SSteve Yin * @param lChildID, specify child index,which AT(such as Inspect32) gives. 13665fdc4257SSteve Yin * @return IMAccessible*, pointer to the corresponding child object. 13675fdc4257SSteve Yin */ 13685fdc4257SSteve Yin IMAccessible* CMAccessible::GetChildInterface(long dChildID)//for test 13695fdc4257SSteve Yin { 13705fdc4257SSteve Yin 13715fdc4257SSteve Yin long dChildIndex = 0; 13725fdc4257SSteve Yin if(dChildID<0) 13735fdc4257SSteve Yin { 13745fdc4257SSteve Yin if(g_pAgent) 13755fdc4257SSteve Yin { 13765fdc4257SSteve Yin IMAccessible* pIMAcc = NULL; 13775fdc4257SSteve Yin g_pAgent->GetIAccessibleFromResID(dChildID,&pIMAcc); 13785fdc4257SSteve Yin return pIMAcc; 13795fdc4257SSteve Yin } 13805fdc4257SSteve Yin return NULL; 13815fdc4257SSteve Yin } 13825fdc4257SSteve Yin else 13835fdc4257SSteve Yin { 13845fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = pUNOInterface->getAccessibleContext(); 13855fdc4257SSteve Yin if( !pRContext.is() ) 13865fdc4257SSteve Yin return NULL; 13875fdc4257SSteve Yin 13885fdc4257SSteve Yin if(dChildID<1 || dChildID>pRContext->getAccessibleChildCount()) 13895fdc4257SSteve Yin return NULL; 13905fdc4257SSteve Yin 13915fdc4257SSteve Yin IAccessible* pChild = NULL; 13925fdc4257SSteve Yin Reference< XAccessible > pXChild = pRContext->getAccessibleChild(dChildID-1); 13935fdc4257SSteve Yin BOOL isGet = get_IAccessibleFromXAccessible((long)pXChild.get(),&pChild); 13945fdc4257SSteve Yin 13955fdc4257SSteve Yin if(!isGet) 13965fdc4257SSteve Yin { 13975fdc4257SSteve Yin g_pAgent->InsertAccObj(pXChild.get(),pUNOInterface,(long)m_hwnd); 13985fdc4257SSteve Yin isGet = get_IAccessibleFromXAccessible((long)pXChild.get(),&pChild); 13995fdc4257SSteve Yin } 14005fdc4257SSteve Yin 14015fdc4257SSteve Yin if(isGet) 14025fdc4257SSteve Yin { 14035fdc4257SSteve Yin IMAccessible* pIMAcc = (IMAccessible*)pChild; 14045fdc4257SSteve Yin return pIMAcc; 14055fdc4257SSteve Yin } 14065fdc4257SSteve Yin } 14075fdc4257SSteve Yin 14085fdc4257SSteve Yin return NULL; 14095fdc4257SSteve Yin } 14105fdc4257SSteve Yin 14115fdc4257SSteve Yin /** 14125fdc4257SSteve Yin * For List, tree and table,these roles belong to manage_decendant in UNO, 14135fdc4257SSteve Yin * need to process specifically when navigate 14145fdc4257SSteve Yin * @return BOOL, if it is decendantmanager, return true. 14155fdc4257SSteve Yin */ 14165fdc4257SSteve Yin BOOL CMAccessible::IsDecendantManage() 14175fdc4257SSteve Yin { 14185fdc4257SSteve Yin 14195fdc4257SSteve Yin return (m_iRole==ROLE_SYSTEM_LIST)||(m_iRole==ROLE_SYSTEM_OUTLINE)||(m_iRole==ROLE_SYSTEM_TABLE); 14205fdc4257SSteve Yin } 14215fdc4257SSteve Yin 14225fdc4257SSteve Yin /** 14235fdc4257SSteve Yin * for decendantmanager circumstance,provide child interface when navigate 14245fdc4257SSteve Yin * @param varCur, the current child. 14255fdc4257SSteve Yin * @param flags, the navigation direction. 14265fdc4257SSteve Yin * @return IMAccessible*, the child of the end up node. 14275fdc4257SSteve Yin */ 14285fdc4257SSteve Yin IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) 14295fdc4257SSteve Yin { 14305fdc4257SSteve Yin 14315fdc4257SSteve Yin XAccessibleContext* pXContext = GetContextByXAcc(pUNOInterface); 14325fdc4257SSteve Yin if(pXContext==NULL) 14335fdc4257SSteve Yin { 14345fdc4257SSteve Yin return NULL; 14355fdc4257SSteve Yin } 14365fdc4257SSteve Yin 14375fdc4257SSteve Yin int count = pXContext->getAccessibleChildCount(); 14385fdc4257SSteve Yin if(count<1) 14395fdc4257SSteve Yin { 14405fdc4257SSteve Yin return NULL; 14415fdc4257SSteve Yin } 14425fdc4257SSteve Yin 14435fdc4257SSteve Yin IMAccessible* pCurChild = NULL; 14445fdc4257SSteve Yin XAccessible* pChildXAcc = NULL; 14455fdc4257SSteve Yin Reference<XAccessible> pRChildXAcc; 14465fdc4257SSteve Yin XAccessibleContext* pChildContext = NULL; 14475fdc4257SSteve Yin int index = 0,delta=0; 14485fdc4257SSteve Yin switch(flags) 14495fdc4257SSteve Yin { 14505fdc4257SSteve Yin case DM_FIRSTCHILD: 14515fdc4257SSteve Yin pRChildXAcc = pXContext->getAccessibleChild(0); 14525fdc4257SSteve Yin break; 14535fdc4257SSteve Yin case DM_LASTCHILD: 14545fdc4257SSteve Yin pRChildXAcc = pXContext->getAccessibleChild(count-1); 14555fdc4257SSteve Yin break; 14565fdc4257SSteve Yin case DM_NEXTCHILD: 14575fdc4257SSteve Yin case DM_PREVCHILD: 14585fdc4257SSteve Yin pCurChild = GetChildInterface(varCur.lVal); 14595fdc4257SSteve Yin if(pCurChild==NULL) 14605fdc4257SSteve Yin { 14615fdc4257SSteve Yin return NULL; 14625fdc4257SSteve Yin } 14635fdc4257SSteve Yin pCurChild->GetUNOInterface((long*)&pChildXAcc); 14645fdc4257SSteve Yin if(pChildXAcc==NULL) 14655fdc4257SSteve Yin { 14665fdc4257SSteve Yin return NULL; 14675fdc4257SSteve Yin } 14685fdc4257SSteve Yin pChildContext = GetContextByXAcc(pChildXAcc); 14695fdc4257SSteve Yin if(pChildContext == NULL) 14705fdc4257SSteve Yin { 14715fdc4257SSteve Yin return NULL; 14725fdc4257SSteve Yin } 14735fdc4257SSteve Yin delta = (flags==DM_NEXTCHILD)?1:-1; 14745fdc4257SSteve Yin //currently, getAccessibleIndexInParent is error in UNO for 14755fdc4257SSteve Yin //some kind of List,such as ValueSet, the index will be less 1 than 14765fdc4257SSteve Yin //what should be, need to fix UNO code 14775fdc4257SSteve Yin index = pChildContext->getAccessibleIndexInParent()+delta; 14785fdc4257SSteve Yin if((index>=0)&&(index<=count-1)) 14795fdc4257SSteve Yin { 14805fdc4257SSteve Yin pRChildXAcc = pXContext->getAccessibleChild(index); 14815fdc4257SSteve Yin } 14825fdc4257SSteve Yin break; 14835fdc4257SSteve Yin default: 14845fdc4257SSteve Yin break; 14855fdc4257SSteve Yin } 14865fdc4257SSteve Yin 14875fdc4257SSteve Yin if(!pRChildXAcc.is()) 14885fdc4257SSteve Yin { 14895fdc4257SSteve Yin return NULL; 14905fdc4257SSteve Yin } 14915fdc4257SSteve Yin pChildXAcc = pRChildXAcc.get(); 14925fdc4257SSteve Yin g_pAgent->InsertAccObj(pChildXAcc,pUNOInterface); 14935fdc4257SSteve Yin return g_pAgent->GetIMAccByXAcc(pChildXAcc); 14945fdc4257SSteve Yin } 14955fdc4257SSteve Yin 14965fdc4257SSteve Yin /** 14975fdc4257SSteve Yin *the following 4 private methods are for accNavigate implementation 14985fdc4257SSteve Yin */ 14995fdc4257SSteve Yin 15005fdc4257SSteve Yin /** 15015fdc4257SSteve Yin * Return first child for parent container, process differently according 15025fdc4257SSteve Yin * to whether it is decendant manage 15035fdc4257SSteve Yin * @param varStart, the start child id of this navigation action. 15045fdc4257SSteve Yin * @param pvarEndUpAt, [in,out] the end up child of this navigation action. 15055fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 15065fdc4257SSteve Yin */ 15075fdc4257SSteve Yin HRESULT CMAccessible::GetFirstChild(VARIANT varStart,VARIANT* pvarEndUpAt) 15085fdc4257SSteve Yin { 15095fdc4257SSteve Yin 15105fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 15115fdc4257SSteve Yin ISDESTROY() 15125fdc4257SSteve Yin // #CHECK# 15135fdc4257SSteve Yin if(pvarEndUpAt == NULL) 15145fdc4257SSteve Yin { 15155fdc4257SSteve Yin return E_INVALIDARG; 15165fdc4257SSteve Yin } 15175fdc4257SSteve Yin if(varStart.vt != VT_I4) 15185fdc4257SSteve Yin { 15195fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 15205fdc4257SSteve Yin return E_INVALIDARG; 15215fdc4257SSteve Yin } 15225fdc4257SSteve Yin 15235fdc4257SSteve Yin pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, DM_FIRSTCHILD); 15245fdc4257SSteve Yin if(pvarEndUpAt->pdispVal) 15255fdc4257SSteve Yin { 15265fdc4257SSteve Yin pvarEndUpAt->pdispVal->AddRef(); 15275fdc4257SSteve Yin pvarEndUpAt->vt = VT_DISPATCH; 15285fdc4257SSteve Yin return S_OK; 15295fdc4257SSteve Yin } 15305fdc4257SSteve Yin 15315fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 15325fdc4257SSteve Yin return E_FAIL; 15335fdc4257SSteve Yin 15345fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 15355fdc4257SSteve Yin } 15365fdc4257SSteve Yin 15375fdc4257SSteve Yin /** 15385fdc4257SSteve Yin * Return last child for parent container, process differently according 15395fdc4257SSteve Yin * to whether it is decendant manage 15405fdc4257SSteve Yin * @param varStart, the start child id of this navigation action. 15415fdc4257SSteve Yin * @param pvarEndUpAt, [in,out] the end up child of this navigation action. 15425fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 15435fdc4257SSteve Yin */ 15445fdc4257SSteve Yin HRESULT CMAccessible::GetLastChild(VARIANT varStart,VARIANT* pvarEndUpAt) 15455fdc4257SSteve Yin { 15465fdc4257SSteve Yin 15475fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 15485fdc4257SSteve Yin ISDESTROY() 15495fdc4257SSteve Yin // #CHECK# 15505fdc4257SSteve Yin if(pvarEndUpAt == NULL) 15515fdc4257SSteve Yin { 15525fdc4257SSteve Yin return E_INVALIDARG; 15535fdc4257SSteve Yin } 15545fdc4257SSteve Yin if(varStart.vt != VT_I4) 15555fdc4257SSteve Yin { 15565fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 15575fdc4257SSteve Yin return E_INVALIDARG; 15585fdc4257SSteve Yin } 15595fdc4257SSteve Yin 15605fdc4257SSteve Yin pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, DM_LASTCHILD); 15615fdc4257SSteve Yin if(pvarEndUpAt->pdispVal) 15625fdc4257SSteve Yin { 15635fdc4257SSteve Yin pvarEndUpAt->pdispVal->AddRef(); 15645fdc4257SSteve Yin pvarEndUpAt->vt = VT_DISPATCH; 15655fdc4257SSteve Yin return S_OK; 15665fdc4257SSteve Yin } 15675fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 15685fdc4257SSteve Yin return E_FAIL; 15695fdc4257SSteve Yin 15705fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 15715fdc4257SSteve Yin } 15725fdc4257SSteve Yin 15735fdc4257SSteve Yin /** 15745fdc4257SSteve Yin * The method GetNextSibling is general, whatever it is decendant manage or not 15755fdc4257SSteve Yin * Get the next sibling object. 15765fdc4257SSteve Yin * @param varStart, the start child id of this navigation action. 15775fdc4257SSteve Yin * @param pvarEndUpAt, [in,out] the end up child of this navigation action. 15785fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 15795fdc4257SSteve Yin */ 15805fdc4257SSteve Yin HRESULT CMAccessible::GetNextSibling(VARIANT varStart,VARIANT* pvarEndUpAt) 15815fdc4257SSteve Yin { 15825fdc4257SSteve Yin 15835fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 15845fdc4257SSteve Yin ISDESTROY() 15855fdc4257SSteve Yin if(varStart.vt != VT_I4) 15865fdc4257SSteve Yin { 15875fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 15885fdc4257SSteve Yin return E_INVALIDARG; 15895fdc4257SSteve Yin } 15905fdc4257SSteve Yin 15915fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = GetContextByXAcc(pUNOInterface); 15925fdc4257SSteve Yin if(pRContext.is()) 15935fdc4257SSteve Yin { 15945fdc4257SSteve Yin varStart.iVal = sal_Int16(pRContext->getAccessibleIndexInParent() + 2); 15955fdc4257SSteve Yin if(m_pIParent) 15965fdc4257SSteve Yin if( m_pIParent->get_accChild(varStart,&pvarEndUpAt->pdispVal) == S_OK) 15975fdc4257SSteve Yin { 15985fdc4257SSteve Yin pvarEndUpAt->vt = VT_DISPATCH; 15995fdc4257SSteve Yin return S_OK; 16005fdc4257SSteve Yin } 16015fdc4257SSteve Yin } 16025fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 16035fdc4257SSteve Yin return E_FAIL; 16045fdc4257SSteve Yin 16055fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 16065fdc4257SSteve Yin } 16075fdc4257SSteve Yin 16085fdc4257SSteve Yin /** 16095fdc4257SSteve Yin *the method GetPreSibling is general, whatever it is decendant manage or not 16105fdc4257SSteve Yin * @param varStart, the start child id of this navigation action. 16115fdc4257SSteve Yin * @param pvarEndUpAt, [in,out] the end up child of this navigation action. 16125fdc4257SSteve Yin * @return S_OK if successful and E_FAIL if failure. 16135fdc4257SSteve Yin */ 16145fdc4257SSteve Yin HRESULT CMAccessible::GetPreSibling(VARIANT varStart,VARIANT* pvarEndUpAt) 16155fdc4257SSteve Yin { 16165fdc4257SSteve Yin 16175fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 16185fdc4257SSteve Yin ISDESTROY() 16195fdc4257SSteve Yin // #CHECK# 16205fdc4257SSteve Yin if(pvarEndUpAt == NULL) 16215fdc4257SSteve Yin { 16225fdc4257SSteve Yin return E_INVALIDARG; 16235fdc4257SSteve Yin } 16245fdc4257SSteve Yin if(varStart.vt != VT_I4) 16255fdc4257SSteve Yin { 16265fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 16275fdc4257SSteve Yin return E_INVALIDARG; 16285fdc4257SSteve Yin } 16295fdc4257SSteve Yin 16305fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = GetContextByXAcc(pUNOInterface); 16315fdc4257SSteve Yin if(pRContext.is()) 16325fdc4257SSteve Yin { 16335fdc4257SSteve Yin varStart.iVal = sal_Int16(pRContext->getAccessibleIndexInParent()); 16345fdc4257SSteve Yin if(m_pIParent && varStart.iVal > 0) 16355fdc4257SSteve Yin if( m_pIParent->get_accChild(varStart,&pvarEndUpAt->pdispVal) == S_OK) 16365fdc4257SSteve Yin { 16375fdc4257SSteve Yin pvarEndUpAt->vt = VT_DISPATCH; 16385fdc4257SSteve Yin return S_OK; 16395fdc4257SSteve Yin } 16405fdc4257SSteve Yin } 16415fdc4257SSteve Yin pvarEndUpAt->vt = VT_EMPTY; 16425fdc4257SSteve Yin return E_FAIL; 16435fdc4257SSteve Yin 16445fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 16455fdc4257SSteve Yin } 16465fdc4257SSteve Yin 16475fdc4257SSteve Yin /** 16485fdc4257SSteve Yin * For IAccessible2 implementation methods 16495fdc4257SSteve Yin */ 16505fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_nRelations( long __RPC_FAR *nRelations) 16515fdc4257SSteve Yin { 16525fdc4257SSteve Yin 16535fdc4257SSteve Yin CHECK_ENABLE_INF 16545fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 16555fdc4257SSteve Yin 16565fdc4257SSteve Yin // #CHECK# 16575fdc4257SSteve Yin if(nRelations == NULL) 16585fdc4257SSteve Yin { 16595fdc4257SSteve Yin return E_INVALIDARG; 16605fdc4257SSteve Yin } 16615fdc4257SSteve Yin 16625fdc4257SSteve Yin *nRelations = 0; 16635fdc4257SSteve Yin 16645fdc4257SSteve Yin if( !pRContext.is() ) 16655fdc4257SSteve Yin return E_FAIL; 16665fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext.get()->getAccessibleRelationSet(); 16675fdc4257SSteve Yin if(!pRrelationSet.is()) 16685fdc4257SSteve Yin { 16695fdc4257SSteve Yin *nRelations = 0; 16705fdc4257SSteve Yin return S_OK; 16715fdc4257SSteve Yin } 16725fdc4257SSteve Yin 16735fdc4257SSteve Yin *nRelations = pRrelationSet->getRelationCount(); 16745fdc4257SSteve Yin return S_OK; 16755fdc4257SSteve Yin 16765fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 16775fdc4257SSteve Yin } 16785fdc4257SSteve Yin 16795fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_relation( long relationIndex, IAccessibleRelation __RPC_FAR *__RPC_FAR *relation) 16805fdc4257SSteve Yin { 16815fdc4257SSteve Yin 16825fdc4257SSteve Yin CHECK_ENABLE_INF 16835fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 16845fdc4257SSteve Yin ISDESTROY() 16855fdc4257SSteve Yin // #CHECK# 16865fdc4257SSteve Yin if(relation == NULL) 16875fdc4257SSteve Yin { 16885fdc4257SSteve Yin return E_INVALIDARG; 16895fdc4257SSteve Yin } 16905fdc4257SSteve Yin 16915fdc4257SSteve Yin if( !pRContext.is() ) 16925fdc4257SSteve Yin return E_FAIL; 16935fdc4257SSteve Yin 16945fdc4257SSteve Yin 16955fdc4257SSteve Yin long nMax = 0; 16965fdc4257SSteve Yin long nReal = 0; 16975fdc4257SSteve Yin get_nRelations(&nMax); 16985fdc4257SSteve Yin 16995fdc4257SSteve Yin *relation = (IAccessibleRelation*)::CoTaskMemAlloc(sizeof(IAccessibleRelation)); 17005fdc4257SSteve Yin 17015fdc4257SSteve Yin // #CHECK Memory Allocation# 17025fdc4257SSteve Yin if(*relation == NULL) 17035fdc4257SSteve Yin { 17045fdc4257SSteve Yin return E_FAIL; 17055fdc4257SSteve Yin } 17065fdc4257SSteve Yin 17075fdc4257SSteve Yin if( relationIndex < nMax ) 17085fdc4257SSteve Yin { 17095fdc4257SSteve Yin 17105fdc4257SSteve Yin 17115fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext.get()->getAccessibleRelationSet(); 17125fdc4257SSteve Yin if(!pRrelationSet.is()) 17135fdc4257SSteve Yin { 17145fdc4257SSteve Yin 17155fdc4257SSteve Yin return E_FAIL; 17165fdc4257SSteve Yin } 17175fdc4257SSteve Yin 17185fdc4257SSteve Yin IAccessibleRelation* pRelation = NULL; 1719*b0a7a3cfSSteve Yin ActivateActContext(); 17205fdc4257SSteve Yin HRESULT hr = CoCreateInstance( CLSID_AccRelation, NULL, CLSCTX_SERVER , 17215fdc4257SSteve Yin IID_IAccessibleRelation, 17225fdc4257SSteve Yin (void **)&pRelation); 1723*b0a7a3cfSSteve Yin DeactivateActContext(); 17245fdc4257SSteve Yin if(SUCCEEDED(hr)) 17255fdc4257SSteve Yin { 17265fdc4257SSteve Yin IUNOXWrapper* wrapper = NULL; 17275fdc4257SSteve Yin hr = pRelation->QueryInterface(IID_IUNOXWrapper, (void**)&wrapper); 17285fdc4257SSteve Yin if(SUCCEEDED(hr)) 17295fdc4257SSteve Yin { 17305fdc4257SSteve Yin AccessibleRelation accRelation = pRrelationSet->getRelation(relationIndex); 17315fdc4257SSteve Yin wrapper->put_XSubInterface((long)&accRelation); 17325fdc4257SSteve Yin wrapper->Release(); 17335fdc4257SSteve Yin *relation = pRelation; 17345fdc4257SSteve Yin return S_OK; 17355fdc4257SSteve Yin } 17365fdc4257SSteve Yin 17375fdc4257SSteve Yin } 17385fdc4257SSteve Yin } 17395fdc4257SSteve Yin 17405fdc4257SSteve Yin return E_FAIL; 17415fdc4257SSteve Yin 17425fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 17435fdc4257SSteve Yin } 17445fdc4257SSteve Yin 17455fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_relations( long, IAccessibleRelation __RPC_FAR *__RPC_FAR *relation, long __RPC_FAR *nRelations) 17465fdc4257SSteve Yin { 17475fdc4257SSteve Yin 17485fdc4257SSteve Yin CHECK_ENABLE_INF 17495fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 17505fdc4257SSteve Yin 17515fdc4257SSteve Yin // #CHECK# 17525fdc4257SSteve Yin if(relation == NULL || nRelations == NULL) 17535fdc4257SSteve Yin { 17545fdc4257SSteve Yin return E_INVALIDARG; 17555fdc4257SSteve Yin } 17565fdc4257SSteve Yin // #CHECK XInterface# 17575fdc4257SSteve Yin 17585fdc4257SSteve Yin if( !pRContext.is() ) 17595fdc4257SSteve Yin return E_FAIL; 17605fdc4257SSteve Yin 17615fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext.get()->getAccessibleRelationSet(); 17625fdc4257SSteve Yin if(!pRrelationSet.is()) 17635fdc4257SSteve Yin { 17645fdc4257SSteve Yin *nRelations = 0; 17655fdc4257SSteve Yin return S_OK; 17665fdc4257SSteve Yin } 17675fdc4257SSteve Yin 17685fdc4257SSteve Yin long nCount = pRrelationSet->getRelationCount(); 17695fdc4257SSteve Yin 17705fdc4257SSteve Yin *relation = (IAccessibleRelation*)::CoTaskMemAlloc(nCount*sizeof(IAccessibleRelation)); 17715fdc4257SSteve Yin 17725fdc4257SSteve Yin // #CHECK Memory Allocation# 17735fdc4257SSteve Yin if(*relation == NULL) 17745fdc4257SSteve Yin { 17755fdc4257SSteve Yin return E_FAIL; 17765fdc4257SSteve Yin } 17775fdc4257SSteve Yin 17785fdc4257SSteve Yin for(int i=0; i<nCount ; i++) 17795fdc4257SSteve Yin { 17805fdc4257SSteve Yin IAccessibleRelation* pRelation = NULL; 1781*b0a7a3cfSSteve Yin ActivateActContext(); 17825fdc4257SSteve Yin HRESULT hr = CoCreateInstance( CLSID_AccRelation, NULL, CLSCTX_SERVER , 17835fdc4257SSteve Yin IID_IAccessibleRelation, 17845fdc4257SSteve Yin (void **)&pRelation); 1785*b0a7a3cfSSteve Yin DeactivateActContext(); 17865fdc4257SSteve Yin if(SUCCEEDED(hr)) 17875fdc4257SSteve Yin { 17885fdc4257SSteve Yin IUNOXWrapper* wrapper = NULL; 17895fdc4257SSteve Yin hr = pRelation->QueryInterface(IID_IUNOXWrapper, (void**)&wrapper); 17905fdc4257SSteve Yin if(SUCCEEDED(hr)) 17915fdc4257SSteve Yin { 17925fdc4257SSteve Yin AccessibleRelation accRelation = pRrelationSet->getRelation(i); 17935fdc4257SSteve Yin wrapper->put_XSubInterface((long)&accRelation); 17945fdc4257SSteve Yin wrapper->Release(); 17955fdc4257SSteve Yin } 17965fdc4257SSteve Yin (relation)[i] = pRelation; 17975fdc4257SSteve Yin } 17985fdc4257SSteve Yin } 17995fdc4257SSteve Yin 18005fdc4257SSteve Yin *nRelations = nCount; 18015fdc4257SSteve Yin return S_OK; 18025fdc4257SSteve Yin 18035fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 18045fdc4257SSteve Yin } 18055fdc4257SSteve Yin 18065fdc4257SSteve Yin STDMETHODIMP CMAccessible::role(long __RPC_FAR *role) 18075fdc4257SSteve Yin { 18085fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 18095fdc4257SSteve Yin 18105fdc4257SSteve Yin (*role) = m_iRole; 18115fdc4257SSteve Yin 18125fdc4257SSteve Yin return S_OK; 18135fdc4257SSteve Yin 18145fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 18155fdc4257SSteve Yin } 18165fdc4257SSteve Yin 18175fdc4257SSteve Yin 18185fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_nActions(long __RPC_FAR *nActions) 18195fdc4257SSteve Yin { 18205fdc4257SSteve Yin 18215fdc4257SSteve Yin try 18225fdc4257SSteve Yin { 18235fdc4257SSteve Yin ISDESTROY() 18245fdc4257SSteve Yin // #CHECK# 18255fdc4257SSteve Yin if(nActions == NULL) 18265fdc4257SSteve Yin { 18275fdc4257SSteve Yin return E_INVALIDARG; 18285fdc4257SSteve Yin } 18295fdc4257SSteve Yin *nActions = 0L; 18305fdc4257SSteve Yin IAccessibleAction* pAcc = NULL; 18315fdc4257SSteve Yin HRESULT hr = QueryInterface(IID_IAccessibleAction, (void**)&pAcc); 18325fdc4257SSteve Yin if( hr == S_OK ) 18335fdc4257SSteve Yin { 18345fdc4257SSteve Yin pAcc->nActions(nActions); 18355fdc4257SSteve Yin pAcc->Release(); 18365fdc4257SSteve Yin } 18375fdc4257SSteve Yin 18385fdc4257SSteve Yin return S_OK; 18395fdc4257SSteve Yin } 18405fdc4257SSteve Yin catch(...) 18415fdc4257SSteve Yin { 18425fdc4257SSteve Yin *nActions = 0L; 18435fdc4257SSteve Yin return S_OK; 18445fdc4257SSteve Yin } 18455fdc4257SSteve Yin } 18465fdc4257SSteve Yin 18475fdc4257SSteve Yin 18485fdc4257SSteve Yin STDMETHODIMP CMAccessible:: scrollToPoint(enum IA2CoordinateType, long, long) 18495fdc4257SSteve Yin { 18505fdc4257SSteve Yin 18515fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 18525fdc4257SSteve Yin ISDESTROY() 18535fdc4257SSteve Yin return E_NOTIMPL; 18545fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 18555fdc4257SSteve Yin 18565fdc4257SSteve Yin } 18575fdc4257SSteve Yin STDMETHODIMP CMAccessible:: scrollTo(enum IA2ScrollType) 18585fdc4257SSteve Yin { 18595fdc4257SSteve Yin 18605fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 18615fdc4257SSteve Yin ISDESTROY() 18625fdc4257SSteve Yin 18635fdc4257SSteve Yin return E_NOTIMPL; 18645fdc4257SSteve Yin 18655fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 18665fdc4257SSteve Yin } 18675fdc4257SSteve Yin 18685fdc4257SSteve Yin static XAccessible* getTheParentOfMember(XAccessible* pXAcc) 18695fdc4257SSteve Yin { 18705fdc4257SSteve Yin // #CHECK# 18715fdc4257SSteve Yin if(pXAcc == NULL) 18725fdc4257SSteve Yin { 18735fdc4257SSteve Yin return NULL; 18745fdc4257SSteve Yin } 18755fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pXAcc->getAccessibleContext(); 18765fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext->getAccessibleRelationSet(); 18775fdc4257SSteve Yin long nRelations = pRrelationSet->getRelationCount(); 18785fdc4257SSteve Yin for(int i=0 ; i<nRelations ; i++) 18795fdc4257SSteve Yin { 18805fdc4257SSteve Yin AccessibleRelation accRelation = pRrelationSet->getRelation(i); 18815fdc4257SSteve Yin if(accRelation.RelationType == 7) 18825fdc4257SSteve Yin { 18835fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = accRelation.TargetSet; 18845fdc4257SSteve Yin return (XAccessible*)xTargets[0].get(); 18855fdc4257SSteve Yin } 18865fdc4257SSteve Yin } 18875fdc4257SSteve Yin return NULL; 18885fdc4257SSteve Yin } 18895fdc4257SSteve Yin 18905fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_groupPosition(long __RPC_FAR *groupLevel,long __RPC_FAR *similarItemsInGroup,long __RPC_FAR *positionInGroup) 18915fdc4257SSteve Yin { 18925fdc4257SSteve Yin 18935fdc4257SSteve Yin CHECK_ENABLE_INF 18945fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 18955fdc4257SSteve Yin ISDESTROY() 18965fdc4257SSteve Yin // #CHECK# 18975fdc4257SSteve Yin if(groupLevel == NULL || similarItemsInGroup == NULL || positionInGroup == NULL) 18985fdc4257SSteve Yin { 18995fdc4257SSteve Yin return E_INVALIDARG; 19005fdc4257SSteve Yin } 19015fdc4257SSteve Yin 19025fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 19035fdc4257SSteve Yin if(!pRContext.is()) 19045fdc4257SSteve Yin return E_FAIL; 19055fdc4257SSteve Yin long Role = pRContext->getAccessibleRole(); 19065fdc4257SSteve Yin 19075fdc4257SSteve Yin *groupLevel = 0; 19085fdc4257SSteve Yin *similarItemsInGroup = 0; 19095fdc4257SSteve Yin *positionInGroup = 0; 19105fdc4257SSteve Yin 19115fdc4257SSteve Yin if (Role != AccessibleRole::DOCUMENT) 19125fdc4257SSteve Yin { 19135fdc4257SSteve Yin Reference< XAccessibleGroupPosition > xGroupPosition( pRContext, UNO_QUERY ); 19145fdc4257SSteve Yin if ( xGroupPosition.is() ) 19155fdc4257SSteve Yin { 19165fdc4257SSteve Yin Sequence< sal_Int32 > rSeq = xGroupPosition->getGroupPosition( makeAny( pRContext ) ); 19175fdc4257SSteve Yin sal_Int32* pSeq = rSeq.getArray(); 19185fdc4257SSteve Yin if ( pSeq ) 19195fdc4257SSteve Yin { 19205fdc4257SSteve Yin *groupLevel = pSeq[0]; 19215fdc4257SSteve Yin *similarItemsInGroup = pSeq[1]; 19225fdc4257SSteve Yin *positionInGroup = pSeq[2]; 19235fdc4257SSteve Yin return S_OK; 19245fdc4257SSteve Yin } 19255fdc4257SSteve Yin return S_OK; 19265fdc4257SSteve Yin } 19275fdc4257SSteve Yin } 19285fdc4257SSteve Yin 19295fdc4257SSteve Yin Reference< XAccessible> pParentAcc = pRContext->getAccessibleParent(); 19305fdc4257SSteve Yin if( !pParentAcc.is() ) 19315fdc4257SSteve Yin { 19325fdc4257SSteve Yin return S_OK; 19335fdc4257SSteve Yin } 19345fdc4257SSteve Yin 19355fdc4257SSteve Yin Reference<XAccessibleContext> pRParentContext = pParentAcc->getAccessibleContext(); 19365fdc4257SSteve Yin 19375fdc4257SSteve Yin int level = 0; 19385fdc4257SSteve Yin int index = 0; 19395fdc4257SSteve Yin int number = 0; 19405fdc4257SSteve Yin 19415fdc4257SSteve Yin if( Role == RADIO_BUTTON ) 19425fdc4257SSteve Yin { 19435fdc4257SSteve Yin Reference<XAccessibleRelationSet> pRrelationSet = pRContext->getAccessibleRelationSet(); 19445fdc4257SSteve Yin long nRel = pRrelationSet->getRelationCount(); 19455fdc4257SSteve Yin for(int i=0 ; i<nRel ; i++) 19465fdc4257SSteve Yin { 19475fdc4257SSteve Yin AccessibleRelation accRelation = pRrelationSet->getRelation(i); 19485fdc4257SSteve Yin if(accRelation.RelationType == 7) 19495fdc4257SSteve Yin { 19505fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = accRelation.TargetSet; 19515fdc4257SSteve Yin int nCount = xTargets.getLength(); 19525fdc4257SSteve Yin 19535fdc4257SSteve Yin Reference<XInterface> pRAcc = xTargets[0]; 19545fdc4257SSteve Yin for(int j=0; j<pRParentContext->getAccessibleChildCount(); j++) 19555fdc4257SSteve Yin { 19565fdc4257SSteve Yin if( getTheParentOfMember(pRParentContext->getAccessibleChild(j).get()) 19575fdc4257SSteve Yin == (XAccessible*)pRAcc.get() && 19585fdc4257SSteve Yin pRParentContext->getAccessibleChild(j)->getAccessibleContext()->getAccessibleRole() == RADIO_BUTTON) 19595fdc4257SSteve Yin number++; 19605fdc4257SSteve Yin if(pRParentContext->getAccessibleChild(j).get() == pUNOInterface) 19615fdc4257SSteve Yin index = number; 19625fdc4257SSteve Yin } 19635fdc4257SSteve Yin } 19645fdc4257SSteve Yin } 19655fdc4257SSteve Yin *groupLevel = 1; 19665fdc4257SSteve Yin *similarItemsInGroup = number; 19675fdc4257SSteve Yin *positionInGroup = index; 19685fdc4257SSteve Yin return S_OK; 19695fdc4257SSteve Yin } 19705fdc4257SSteve Yin 19715fdc4257SSteve Yin else if ( COMBO_BOX == Role ) 19725fdc4257SSteve Yin { 19735fdc4257SSteve Yin *groupLevel = 1; 19745fdc4257SSteve Yin *similarItemsInGroup = 0; 19755fdc4257SSteve Yin *positionInGroup = -1; 19765fdc4257SSteve Yin 19775fdc4257SSteve Yin long nCount = pRContext->getAccessibleChildCount(); 19785fdc4257SSteve Yin if( 2 != nCount) 19795fdc4257SSteve Yin { 19805fdc4257SSteve Yin return S_OK; 19815fdc4257SSteve Yin } 19825fdc4257SSteve Yin Reference<XAccessible> xList=pRContext->getAccessibleChild(1); 19835fdc4257SSteve Yin if (!xList.is()) 19845fdc4257SSteve Yin { 19855fdc4257SSteve Yin return S_OK; 19865fdc4257SSteve Yin } 19875fdc4257SSteve Yin Reference<XAccessibleContext> xListContext(xList,UNO_QUERY); 19885fdc4257SSteve Yin if (!xListContext.is()) 19895fdc4257SSteve Yin { 19905fdc4257SSteve Yin return S_OK; 19915fdc4257SSteve Yin } 19925fdc4257SSteve Yin Reference<XAccessibleSelection> xListSel(xList,UNO_QUERY); 19935fdc4257SSteve Yin if (!xListSel.is()) 19945fdc4257SSteve Yin { 19955fdc4257SSteve Yin return S_OK; 19965fdc4257SSteve Yin } 19975fdc4257SSteve Yin *similarItemsInGroup = xListContext->getAccessibleChildCount(); 19985fdc4257SSteve Yin if (*similarItemsInGroup > 0 ) 19995fdc4257SSteve Yin { 20005fdc4257SSteve Yin try 20015fdc4257SSteve Yin { 20025fdc4257SSteve Yin Reference<XAccessible> xChild = xListSel->getSelectedAccessibleChild(0); 20035fdc4257SSteve Yin if (xChild.is()) 20045fdc4257SSteve Yin { 20055fdc4257SSteve Yin Reference<XAccessibleContext> xChildContext(xChild,UNO_QUERY); 20065fdc4257SSteve Yin if (xChildContext.is()) 20075fdc4257SSteve Yin { 20085fdc4257SSteve Yin *positionInGroup=xChildContext->getAccessibleIndexInParent() + 1 ; 20095fdc4257SSteve Yin return S_OK; 20105fdc4257SSteve Yin } 20115fdc4257SSteve Yin } 20125fdc4257SSteve Yin } 20135fdc4257SSteve Yin catch(...) 20145fdc4257SSteve Yin {} 20155fdc4257SSteve Yin } 20165fdc4257SSteve Yin return S_OK; 20175fdc4257SSteve Yin } 20185fdc4257SSteve Yin else if ( PAGE_TAB == Role ) 20195fdc4257SSteve Yin { 20205fdc4257SSteve Yin *groupLevel = 1; 20215fdc4257SSteve Yin *similarItemsInGroup = pRParentContext->getAccessibleChildCount(); 20225fdc4257SSteve Yin 20235fdc4257SSteve Yin if (*similarItemsInGroup > 0 ) 20245fdc4257SSteve Yin { 20255fdc4257SSteve Yin *positionInGroup=pRContext->getAccessibleIndexInParent() + 1 ; 20265fdc4257SSteve Yin } 20275fdc4257SSteve Yin else 20285fdc4257SSteve Yin { 20295fdc4257SSteve Yin *positionInGroup = -1; 20305fdc4257SSteve Yin } 20315fdc4257SSteve Yin return S_OK; 20325fdc4257SSteve Yin } 20335fdc4257SSteve Yin 20345fdc4257SSteve Yin 20355fdc4257SSteve Yin BOOL isFound = FALSE; 20365fdc4257SSteve Yin while( pParentAcc.is() && !isFound) 20375fdc4257SSteve Yin { 20385fdc4257SSteve Yin level++; 20395fdc4257SSteve Yin pRParentContext = pParentAcc->getAccessibleContext(); 20405fdc4257SSteve Yin Role = pRParentContext->getAccessibleRole(); 20415fdc4257SSteve Yin if( (Role == TREE) || (Role == LIST) ) 20425fdc4257SSteve Yin isFound = TRUE; 20435fdc4257SSteve Yin pParentAcc = pRParentContext->getAccessibleParent(); 20445fdc4257SSteve Yin } 20455fdc4257SSteve Yin 20465fdc4257SSteve Yin if( isFound ) 20475fdc4257SSteve Yin { 20485fdc4257SSteve Yin Reference< XAccessible> pTempAcc = pRContext->getAccessibleParent(); 20495fdc4257SSteve Yin pRParentContext = pTempAcc->getAccessibleContext(); 20505fdc4257SSteve Yin *groupLevel = level; 20515fdc4257SSteve Yin *similarItemsInGroup = pRParentContext->getAccessibleChildCount(); 20525fdc4257SSteve Yin *positionInGroup = pRContext->getAccessibleIndexInParent() + 1; 20535fdc4257SSteve Yin } 20545fdc4257SSteve Yin else 20555fdc4257SSteve Yin { 20565fdc4257SSteve Yin *groupLevel = 0; 20575fdc4257SSteve Yin *similarItemsInGroup = 0; 20585fdc4257SSteve Yin *positionInGroup = 0; 20595fdc4257SSteve Yin } 20605fdc4257SSteve Yin return S_OK; 20615fdc4257SSteve Yin 20625fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 20635fdc4257SSteve Yin } 20645fdc4257SSteve Yin 20655fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_extendedStates( long, BSTR __RPC_FAR *__RPC_FAR *, long __RPC_FAR *) 20665fdc4257SSteve Yin { 20675fdc4257SSteve Yin 20685fdc4257SSteve Yin CHECK_ENABLE_INF 20695fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 20705fdc4257SSteve Yin ISDESTROY() 20715fdc4257SSteve Yin 20725fdc4257SSteve Yin return E_NOTIMPL; 20735fdc4257SSteve Yin 20745fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 20755fdc4257SSteve Yin } 20765fdc4257SSteve Yin 20775fdc4257SSteve Yin 20785fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_uniqueID(long __RPC_FAR *uniqueID) 20795fdc4257SSteve Yin { 20805fdc4257SSteve Yin 20815fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 20825fdc4257SSteve Yin ISDESTROY() 20835fdc4257SSteve Yin // #CHECK# 20845fdc4257SSteve Yin if(uniqueID == NULL) 20855fdc4257SSteve Yin { 20865fdc4257SSteve Yin return E_INVALIDARG; 20875fdc4257SSteve Yin } 20885fdc4257SSteve Yin *uniqueID = m_dChildID; 20895fdc4257SSteve Yin return S_OK; 20905fdc4257SSteve Yin 20915fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 20925fdc4257SSteve Yin } 20935fdc4257SSteve Yin 20945fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_windowHandle(HWND __RPC_FAR *windowHandle) 20955fdc4257SSteve Yin { 20965fdc4257SSteve Yin 20975fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 20985fdc4257SSteve Yin ISDESTROY() 20995fdc4257SSteve Yin // #CHECK# 21005fdc4257SSteve Yin if(windowHandle == NULL) 21015fdc4257SSteve Yin { 21025fdc4257SSteve Yin return E_INVALIDARG; 21035fdc4257SSteve Yin } 21045fdc4257SSteve Yin 21055fdc4257SSteve Yin HWND nHwnd = m_hwnd; 21065fdc4257SSteve Yin IAccessible* pParent = m_pIParent; 21075fdc4257SSteve Yin CMAccessible* pChild = this; 21085fdc4257SSteve Yin while((nHwnd==0) && pParent) 21095fdc4257SSteve Yin { 21105fdc4257SSteve Yin pChild = (CMAccessible*)pParent; 21115fdc4257SSteve Yin if(pChild) 21125fdc4257SSteve Yin { 21135fdc4257SSteve Yin pParent = (IAccessible*)pChild->m_pIParent; 21145fdc4257SSteve Yin nHwnd = (HWND)pChild->m_hwnd; 21155fdc4257SSteve Yin } 21165fdc4257SSteve Yin else 21175fdc4257SSteve Yin pParent = NULL; 21185fdc4257SSteve Yin } 21195fdc4257SSteve Yin 21205fdc4257SSteve Yin *windowHandle = nHwnd; 21215fdc4257SSteve Yin return S_OK; 21225fdc4257SSteve Yin 21235fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 21245fdc4257SSteve Yin } 21255fdc4257SSteve Yin 21265fdc4257SSteve Yin /** 21275fdc4257SSteve Yin * Get XAccessibleContext directly from UNO by the stored XAccessible pointer 21285fdc4257SSteve Yin * @param pXAcc, UNO XAccessible object point. 21295fdc4257SSteve Yin * @return XAccessibleContext*, the context of the pXAcc. 21305fdc4257SSteve Yin */ 21315fdc4257SSteve Yin XAccessibleContext* CMAccessible::GetContextByXAcc( XAccessible* pXAcc ) 21325fdc4257SSteve Yin { 21335fdc4257SSteve Yin Reference< XAccessibleContext > pRContext; 21345fdc4257SSteve Yin if( pXAcc == NULL) 21355fdc4257SSteve Yin return NULL; 21365fdc4257SSteve Yin 21375fdc4257SSteve Yin pRContext = pXAcc->getAccessibleContext(); 21385fdc4257SSteve Yin if( !pRContext.is() ) 21395fdc4257SSteve Yin return NULL; 21405fdc4257SSteve Yin return pRContext.get(); 21415fdc4257SSteve Yin } 21425fdc4257SSteve Yin 21435fdc4257SSteve Yin /** 21445fdc4257SSteve Yin * Return the member variable m_pXAccessibleSelection, instead of 21455fdc4257SSteve Yin * get XAccessibleSelection according to XAccessibleContext because if so,it will 21465fdc4257SSteve Yin * depend on the UNO implementation code,so when COM is created, put XAccessibleSelection 21475fdc4257SSteve Yin * by bridge management system 21485fdc4257SSteve Yin * @return XAccessibleSelection*, the selection of the current object. 21495fdc4257SSteve Yin */ 21505fdc4257SSteve Yin Reference< XAccessibleSelection > CMAccessible::GetSelection() 21515fdc4257SSteve Yin { 21525fdc4257SSteve Yin if( pUNOInterface == NULL ) 21535fdc4257SSteve Yin return NULL; 21545fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = pUNOInterface->getAccessibleContext(); 21555fdc4257SSteve Yin if(pRContext.is()) 21565fdc4257SSteve Yin { 21575fdc4257SSteve Yin Reference< XAccessibleSelection > pRSelection(pRContext,UNO_QUERY); 21585fdc4257SSteve Yin return pRSelection; 21595fdc4257SSteve Yin } 21605fdc4257SSteve Yin return NULL; 21615fdc4257SSteve Yin } 21625fdc4257SSteve Yin 21635fdc4257SSteve Yin /** 21645fdc4257SSteve Yin * Select one XAccessible item, for accSelect implementation 21655fdc4257SSteve Yin * @param pItem, the item should be selected. 21665fdc4257SSteve Yin * @return S_OK if successful. 21675fdc4257SSteve Yin */ 21685fdc4257SSteve Yin HRESULT CMAccessible::SelectChild(XAccessible* pItem) 21695fdc4257SSteve Yin { 21705fdc4257SSteve Yin 21715fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 21725fdc4257SSteve Yin ISDESTROY() 21735fdc4257SSteve Yin XAccessibleContext* pParentContext = GetContextByXAcc( pUNOInterface ); 21745fdc4257SSteve Yin XAccessibleContext* pContext = GetContextByXAcc( pItem ); 21755fdc4257SSteve Yin if( pParentContext == NULL || pContext == NULL ) 21765fdc4257SSteve Yin return E_FAIL; 21775fdc4257SSteve Yin 21785fdc4257SSteve Yin Reference< XAccessibleSelection > pRSelection = GetSelection(); 21795fdc4257SSteve Yin if( !pRSelection.is() ) 21805fdc4257SSteve Yin return E_FAIL; 21815fdc4257SSteve Yin long Index = pContext->getAccessibleIndexInParent(); 21825fdc4257SSteve Yin pRSelection->selectAccessibleChild( Index ); 21835fdc4257SSteve Yin return S_OK; 21845fdc4257SSteve Yin 21855fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 21865fdc4257SSteve Yin } 21875fdc4257SSteve Yin 21885fdc4257SSteve Yin /** 21895fdc4257SSteve Yin * Deselect one XAccessible item, for accSelect implimentation 21905fdc4257SSteve Yin * @param pItem, the item should be deselected. 21915fdc4257SSteve Yin * @return S_OK if successful. 21925fdc4257SSteve Yin */ 21935fdc4257SSteve Yin HRESULT CMAccessible::DeSelectChild(XAccessible* pItem) 21945fdc4257SSteve Yin { 21955fdc4257SSteve Yin 21965fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 21975fdc4257SSteve Yin ISDESTROY() 21985fdc4257SSteve Yin XAccessibleContext* pParentContext = GetContextByXAcc( pUNOInterface ); 21995fdc4257SSteve Yin ; 22005fdc4257SSteve Yin XAccessibleContext* pContext = GetContextByXAcc( pItem ); 22015fdc4257SSteve Yin if( pParentContext == NULL || pContext == NULL ) 22025fdc4257SSteve Yin return E_INVALIDARG; 22035fdc4257SSteve Yin 22045fdc4257SSteve Yin Reference< XAccessibleSelection > pRSelection = GetSelection(); 22055fdc4257SSteve Yin if( !pRSelection.is() ) 22065fdc4257SSteve Yin return E_FAIL; 22075fdc4257SSteve Yin long Index = pContext->getAccessibleIndexInParent(); 22085fdc4257SSteve Yin pRSelection->deselectAccessibleChild( Index ); 22095fdc4257SSteve Yin 22105fdc4257SSteve Yin return S_OK; 22115fdc4257SSteve Yin 22125fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 22135fdc4257SSteve Yin } 22145fdc4257SSteve Yin 22155fdc4257SSteve Yin /** 22165fdc4257SSteve Yin * Select multiple XAccessible items,for implementation of accSelect 22175fdc4257SSteve Yin * @param pItem, the items should be selected. 22185fdc4257SSteve Yin * @param size, the size of the items. 22195fdc4257SSteve Yin * @return S_OK if successful. 22205fdc4257SSteve Yin */ 22215fdc4257SSteve Yin HRESULT CMAccessible::SelectMutipleChidren( XAccessible** pItem,int size ) 22225fdc4257SSteve Yin { 22235fdc4257SSteve Yin 22245fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 22255fdc4257SSteve Yin ISDESTROY() 22265fdc4257SSteve Yin // #CHECK# 22275fdc4257SSteve Yin if(pItem == NULL) 22285fdc4257SSteve Yin { 22295fdc4257SSteve Yin return E_INVALIDARG; 22305fdc4257SSteve Yin } 22315fdc4257SSteve Yin for(int index = 0;index < size;index++) 22325fdc4257SSteve Yin { 22335fdc4257SSteve Yin SelectChild( pItem[index] ); 22345fdc4257SSteve Yin } 22355fdc4257SSteve Yin return S_OK; 22365fdc4257SSteve Yin 22375fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 22385fdc4257SSteve Yin } 22395fdc4257SSteve Yin 22405fdc4257SSteve Yin /** 22415fdc4257SSteve Yin * Deselect multiple XAccessible items,for implementation of accSelect 22425fdc4257SSteve Yin * @param pItem, the items should be selected. 22435fdc4257SSteve Yin * @param size, the size of the items. 22445fdc4257SSteve Yin * @return S_OK if successful. 22455fdc4257SSteve Yin */ 22465fdc4257SSteve Yin HRESULT CMAccessible::DeSelectMutipleChildren( XAccessible** pItem,int size ) 22475fdc4257SSteve Yin { 22485fdc4257SSteve Yin 22495fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 22505fdc4257SSteve Yin ISDESTROY() 22515fdc4257SSteve Yin // #CHECK# 22525fdc4257SSteve Yin if(pItem == NULL) 22535fdc4257SSteve Yin { 22545fdc4257SSteve Yin return E_INVALIDARG; 22555fdc4257SSteve Yin } 22565fdc4257SSteve Yin for(int index = 0;index < size;index++) 22575fdc4257SSteve Yin { 22585fdc4257SSteve Yin DeSelectChild( pItem[index] ); 22595fdc4257SSteve Yin } 22605fdc4257SSteve Yin return S_OK; 22615fdc4257SSteve Yin 22625fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 22635fdc4257SSteve Yin } 22645fdc4257SSteve Yin 22655fdc4257SSteve Yin /** 22665fdc4257SSteve Yin * When COM is created, UNO set XAccessible pointer to it 22675fdc4257SSteve Yin * in order to COM can operate UNO information 22685fdc4257SSteve Yin * @param pXAcc, the XAccessible object of current object. 22695fdc4257SSteve Yin * @return S_OK if successful. 22705fdc4257SSteve Yin */ 22715fdc4257SSteve Yin STDMETHODIMP CMAccessible::SetXAccessible(long pXAcc) 22725fdc4257SSteve Yin { 22735fdc4257SSteve Yin pUNOInterface = (XAccessible*)pXAcc; 22745fdc4257SSteve Yin pRef = pUNOInterface; 22755fdc4257SSteve Yin m_pEnumVar->PutSelection(/*XAccessibleSelection*/(long)pUNOInterface); 22765fdc4257SSteve Yin 22775fdc4257SSteve Yin pRContext = pUNOInterface->getAccessibleContext(); 22785fdc4257SSteve Yin pRContextInterface = (XAccessibleContext*)pRContext.is(); 22795fdc4257SSteve Yin 22805fdc4257SSteve Yin return S_OK; 22815fdc4257SSteve Yin } 22825fdc4257SSteve Yin 22835fdc4257SSteve Yin /** 22845fdc4257SSteve Yin * accSelect method has many optional flags, needs to process comprehensively 22855fdc4257SSteve Yin * Mozilla and Microsoft do not implement SELFLAG_EXTENDSELECTION flag. 22865fdc4257SSteve Yin * The implementation of this flag is a little trouble-shooting,so we also 22875fdc4257SSteve Yin * do not implement it now 22885fdc4257SSteve Yin * @param flagsSelect, the selection flag of the select action. 22895fdc4257SSteve Yin * @param varChild, the child object pointer of current action. 22905fdc4257SSteve Yin * @return S_OK if successful. 22915fdc4257SSteve Yin */ 22925fdc4257SSteve Yin STDMETHODIMP CMAccessible::accSelect(long flagsSelect, VARIANT varChild) 22935fdc4257SSteve Yin { 22945fdc4257SSteve Yin 22955fdc4257SSteve Yin CHECK_ENABLE_INF 22965fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 22975fdc4257SSteve Yin ISDESTROY() 22985fdc4257SSteve Yin if( (flagsSelect&SELFLAG_ADDSELECTION) && 22995fdc4257SSteve Yin (SELFLAG_REMOVESELECTION&flagsSelect) ) 23005fdc4257SSteve Yin return E_INVALIDARG; 23015fdc4257SSteve Yin 23025fdc4257SSteve Yin if ( (flagsSelect&SELFLAG_TAKESELECTION) && 23035fdc4257SSteve Yin ( 23045fdc4257SSteve Yin (flagsSelect&SELFLAG_ADDSELECTION) || 23055fdc4257SSteve Yin (flagsSelect&SELFLAG_REMOVESELECTION) || 23065fdc4257SSteve Yin (flagsSelect&SELFLAG_EXTENDSELECTION ) 23075fdc4257SSteve Yin ) 23085fdc4257SSteve Yin ) 23095fdc4257SSteve Yin return E_INVALIDARG; 23105fdc4257SSteve Yin 23115fdc4257SSteve Yin if ( varChild.vt != VT_I4 ) 23125fdc4257SSteve Yin return E_INVALIDARG; 23135fdc4257SSteve Yin 23145fdc4257SSteve Yin IMAccessible* pSelectAcc; 23155fdc4257SSteve Yin if( varChild.lVal == CHILDID_SELF ) 23165fdc4257SSteve Yin { 23175fdc4257SSteve Yin pSelectAcc = this; 23185fdc4257SSteve Yin pSelectAcc->AddRef(); 23195fdc4257SSteve Yin } 23205fdc4257SSteve Yin else 23215fdc4257SSteve Yin { 23225fdc4257SSteve Yin pSelectAcc = GetChildInterface(varChild.lVal); 23235fdc4257SSteve Yin } 23245fdc4257SSteve Yin 23255fdc4257SSteve Yin if( pSelectAcc == NULL ) 23265fdc4257SSteve Yin return E_INVALIDARG; 23275fdc4257SSteve Yin 23285fdc4257SSteve Yin if( flagsSelect&SELFLAG_TAKEFOCUS ) 23295fdc4257SSteve Yin { 23305fdc4257SSteve Yin long pTempUNO = 0; 23315fdc4257SSteve Yin pSelectAcc->GetUNOInterface( &pTempUNO); 23325fdc4257SSteve Yin 23335fdc4257SSteve Yin if( pTempUNO == NULL ) 23345fdc4257SSteve Yin return NULL; 23355fdc4257SSteve Yin 23365fdc4257SSteve Yin Reference< XAccessibleContext > pRContext = ( (XAccessible*)pTempUNO)->getAccessibleContext(); 23375fdc4257SSteve Yin Reference< XAccessibleComponent > pRComponent(pRContext,UNO_QUERY); 23385fdc4257SSteve Yin Reference< XAccessible > pRParentXAcc = pRContext->getAccessibleParent(); 23395fdc4257SSteve Yin Reference< XAccessibleContext > pRParentContext = pRParentXAcc->getAccessibleContext(); 23405fdc4257SSteve Yin Reference< XAccessibleComponent > pRParentComponent(pRParentContext,UNO_QUERY); 23415fdc4257SSteve Yin Reference< XAccessibleSelection > pRParentSelection(pRParentContext,UNO_QUERY); 23425fdc4257SSteve Yin 23435fdc4257SSteve Yin 23445fdc4257SSteve Yin pRComponent->grabFocus(); 23455fdc4257SSteve Yin 23465fdc4257SSteve Yin if( flagsSelect & SELFLAG_TAKESELECTION ) 23475fdc4257SSteve Yin { 23485fdc4257SSteve Yin pRParentSelection->clearAccessibleSelection(); 23495fdc4257SSteve Yin pRParentSelection->selectAccessibleChild( pRContext->getAccessibleIndexInParent() ); 23505fdc4257SSteve Yin } 23515fdc4257SSteve Yin 23525fdc4257SSteve Yin if( flagsSelect & SELFLAG_ADDSELECTION ) 23535fdc4257SSteve Yin { 23545fdc4257SSteve Yin pRParentSelection->selectAccessibleChild( pRContext->getAccessibleIndexInParent() ); 23555fdc4257SSteve Yin } 23565fdc4257SSteve Yin 23575fdc4257SSteve Yin if( flagsSelect & SELFLAG_REMOVESELECTION ) 23585fdc4257SSteve Yin { 23595fdc4257SSteve Yin pRParentSelection->deselectAccessibleChild( pRContext->getAccessibleIndexInParent() ); 23605fdc4257SSteve Yin } 23615fdc4257SSteve Yin 23625fdc4257SSteve Yin if( flagsSelect & SELFLAG_EXTENDSELECTION ) 23635fdc4257SSteve Yin { 23645fdc4257SSteve Yin long indexInParrent = pRContext->getAccessibleIndexInParent(); 23655fdc4257SSteve Yin 23665fdc4257SSteve Yin if( pRParentSelection->isAccessibleChildSelected( indexInParrent + 1 ) || 23675fdc4257SSteve Yin pRParentSelection->isAccessibleChildSelected( indexInParrent - 1 ) ) 23685fdc4257SSteve Yin { 23695fdc4257SSteve Yin pRParentSelection->selectAccessibleChild( indexInParrent ); 23705fdc4257SSteve Yin } 23715fdc4257SSteve Yin } 23725fdc4257SSteve Yin 23735fdc4257SSteve Yin } 23745fdc4257SSteve Yin 23755fdc4257SSteve Yin pSelectAcc->Release(); 23765fdc4257SSteve Yin return S_OK; 23775fdc4257SSteve Yin 23785fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 23795fdc4257SSteve Yin } 23805fdc4257SSteve Yin 23815fdc4257SSteve Yin /** 23825fdc4257SSteve Yin * Return XAccessible interface pointer when needed 23835fdc4257SSteve Yin * @param pXAcc, [in, out] the Uno interface of the current object. 23845fdc4257SSteve Yin * @return S_OK if successful. 23855fdc4257SSteve Yin */ 23865fdc4257SSteve Yin STDMETHODIMP CMAccessible::GetUNOInterface(long* pXAcc) 23875fdc4257SSteve Yin { 23885fdc4257SSteve Yin // #CHECK# 23895fdc4257SSteve Yin if(pXAcc == NULL) 23905fdc4257SSteve Yin return E_INVALIDARG; 23915fdc4257SSteve Yin 23925fdc4257SSteve Yin *pXAcc = (long)pUNOInterface; 23935fdc4257SSteve Yin return S_OK; 23945fdc4257SSteve Yin } 23955fdc4257SSteve Yin 23965fdc4257SSteve Yin /** 23975fdc4257SSteve Yin * Helper method for Implementation of get_accDefaultAction 23985fdc4257SSteve Yin * @param pAction, the default action point of the current object. 23995fdc4257SSteve Yin * @return S_OK if successful. 24005fdc4257SSteve Yin */ 24015fdc4257SSteve Yin STDMETHODIMP CMAccessible::SetDefaultAction(long pAction) 24025fdc4257SSteve Yin { 24035fdc4257SSteve Yin m_pXAction = (XAccessibleAction*)pAction; 24045fdc4257SSteve Yin return S_OK; 24055fdc4257SSteve Yin } 24065fdc4257SSteve Yin 24075fdc4257SSteve Yin /** 24085fdc4257SSteve Yin * This method is called when AT open some UI elements initially 24095fdc4257SSteve Yin * the UI element takes the default action defined here 24105fdc4257SSteve Yin * @param varChild, the child id of the defaultaction. 24115fdc4257SSteve Yin * @param pszDefaultAction,[in/out] the description of the current action. 24125fdc4257SSteve Yin * @return S_OK if successful. 24135fdc4257SSteve Yin */ 24145fdc4257SSteve Yin HRESULT STDMETHODCALLTYPE CMAccessible::get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction) 24155fdc4257SSteve Yin { 24165fdc4257SSteve Yin 24175fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 24185fdc4257SSteve Yin ISDESTROY() 24195fdc4257SSteve Yin // #CHECK# 24205fdc4257SSteve Yin if(pszDefaultAction == NULL) 24215fdc4257SSteve Yin { 24225fdc4257SSteve Yin return E_INVALIDARG; 24235fdc4257SSteve Yin } 24245fdc4257SSteve Yin if(varChild.vt==VT_I4) 24255fdc4257SSteve Yin { 24265fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 24275fdc4257SSteve Yin { 24285fdc4257SSteve Yin if( m_pXAction == NULL ) 24295fdc4257SSteve Yin return DISP_E_MEMBERNOTFOUND; 24305fdc4257SSteve Yin SAFE_SYSFREESTRING(*pszDefaultAction); 24315fdc4257SSteve Yin *pszDefaultAction = SysAllocString(m_pszActionDescription); 24325fdc4257SSteve Yin return S_OK; 24335fdc4257SSteve Yin } 24345fdc4257SSteve Yin 24355fdc4257SSteve Yin long lVal = varChild.lVal; 24365fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 24375fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 24385fdc4257SSteve Yin if(!pChild) 24395fdc4257SSteve Yin return E_FAIL; 24405fdc4257SSteve Yin return pChild->get_accDefaultAction(varChild,pszDefaultAction); 24415fdc4257SSteve Yin } 24425fdc4257SSteve Yin return S_FALSE; 24435fdc4257SSteve Yin 24445fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 24455fdc4257SSteve Yin } 24465fdc4257SSteve Yin 24475fdc4257SSteve Yin /** 24485fdc4257SSteve Yin * AT call this method to operate application 24495fdc4257SSteve Yin * @param varChild, the child id of the action object. 24505fdc4257SSteve Yin * @return S_OK if successful. 24515fdc4257SSteve Yin */ 24525fdc4257SSteve Yin HRESULT STDMETHODCALLTYPE CMAccessible::accDoDefaultAction(VARIANT varChild) 24535fdc4257SSteve Yin { 24545fdc4257SSteve Yin 24555fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 24565fdc4257SSteve Yin ISDESTROY() 24575fdc4257SSteve Yin if( varChild.vt != VT_I4 ) 24585fdc4257SSteve Yin return E_INVALIDARG; 24595fdc4257SSteve Yin if( m_pXAction == NULL ) 24605fdc4257SSteve Yin return E_FAIL; 24615fdc4257SSteve Yin if( m_pXAction->getAccessibleActionCount() == 0 ) 24625fdc4257SSteve Yin return E_FAIL; 24635fdc4257SSteve Yin 24645fdc4257SSteve Yin if(varChild.lVal==CHILDID_SELF) 24655fdc4257SSteve Yin { 24665fdc4257SSteve Yin if(m_pXAction->getAccessibleActionCount() > 0) 24675fdc4257SSteve Yin m_pXAction->doAccessibleAction(0); 24685fdc4257SSteve Yin return S_OK; 24695fdc4257SSteve Yin } 24705fdc4257SSteve Yin 24715fdc4257SSteve Yin long lVal = varChild.lVal; 24725fdc4257SSteve Yin varChild.lVal = CHILDID_SELF; 24735fdc4257SSteve Yin IMAccessible *pChild = this->GetChildInterface(lVal); 24745fdc4257SSteve Yin if(!pChild) 24755fdc4257SSteve Yin return E_FAIL; 24765fdc4257SSteve Yin return pChild->accDoDefaultAction( varChild ); 24775fdc4257SSteve Yin 24785fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 24795fdc4257SSteve Yin } 24805fdc4257SSteve Yin 24815fdc4257SSteve Yin /** 24825fdc4257SSteve Yin * UNO set description information for action to COM. 24835fdc4257SSteve Yin * @param szAction, the action description of the current object. 24845fdc4257SSteve Yin * @return S_OK if successful. 24855fdc4257SSteve Yin */ 24865fdc4257SSteve Yin STDMETHODIMP CMAccessible::Put_ActionDescription( const OLECHAR* szAction) 24875fdc4257SSteve Yin { 24885fdc4257SSteve Yin 24895fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 24905fdc4257SSteve Yin ISDESTROY() 24915fdc4257SSteve Yin // #CHECK# 24925fdc4257SSteve Yin if(szAction == NULL) 24935fdc4257SSteve Yin { 24945fdc4257SSteve Yin return E_INVALIDARG; 24955fdc4257SSteve Yin } 24965fdc4257SSteve Yin SAFE_SYSFREESTRING(m_pszActionDescription ); 24975fdc4257SSteve Yin m_pszActionDescription = SysAllocString( szAction ); 24985fdc4257SSteve Yin return S_OK; 24995fdc4257SSteve Yin 25005fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 25015fdc4257SSteve Yin } 25025fdc4257SSteve Yin 25035fdc4257SSteve Yin BOOL CMAccessible::GetXInterfaceFromXAccessible(XAccessible* pXAcc, XInterface** ppXI, int index) 25045fdc4257SSteve Yin { 25055fdc4257SSteve Yin Reference< XAccessibleContext > pRContext; 25065fdc4257SSteve Yin 25075fdc4257SSteve Yin switch(index) 25085fdc4257SSteve Yin { 25095fdc4257SSteve Yin case XI_COMPONENT: 25105fdc4257SSteve Yin QUERYXINTERFACE(AccessibleComponent) 25115fdc4257SSteve Yin break; 25125fdc4257SSteve Yin case XI_TEXT: 25135fdc4257SSteve Yin QUERYXINTERFACE(AccessibleText) 25145fdc4257SSteve Yin break; 25155fdc4257SSteve Yin case XI_EDITABLETEXT: 25165fdc4257SSteve Yin QUERYXINTERFACE(AccessibleEditableText) 25175fdc4257SSteve Yin break; 25185fdc4257SSteve Yin case XI_TABLE: 25195fdc4257SSteve Yin QUERYXINTERFACE(AccessibleTable) 25205fdc4257SSteve Yin break; 25215fdc4257SSteve Yin case XI_SELECTION: 25225fdc4257SSteve Yin QUERYXINTERFACE(AccessibleSelection) 25235fdc4257SSteve Yin break; 25245fdc4257SSteve Yin case XI_EXTENDEDCOMP: 25255fdc4257SSteve Yin QUERYXINTERFACE(AccessibleExtendedComponent) 25265fdc4257SSteve Yin break; 25275fdc4257SSteve Yin case XI_KEYBINDING: 25285fdc4257SSteve Yin QUERYXINTERFACE(AccessibleKeyBinding) 25295fdc4257SSteve Yin break; 25305fdc4257SSteve Yin case XI_ACTION: 25315fdc4257SSteve Yin QUERYXINTERFACE(AccessibleAction) 25325fdc4257SSteve Yin break; 25335fdc4257SSteve Yin case XI_VALUE: 25345fdc4257SSteve Yin QUERYXINTERFACE(AccessibleValue) 25355fdc4257SSteve Yin break; 25365fdc4257SSteve Yin case XI_HYPERTEXT: 25375fdc4257SSteve Yin QUERYXINTERFACE(AccessibleHypertext) 25385fdc4257SSteve Yin break; 25395fdc4257SSteve Yin case XI_HYPERLINK: 25405fdc4257SSteve Yin QUERYXINTERFACE(AccessibleHyperlink) 25415fdc4257SSteve Yin break; 25425fdc4257SSteve Yin case XI_IMAGE: 25435fdc4257SSteve Yin QUERYXINTERFACE(AccessibleImage) 25445fdc4257SSteve Yin break; 25455fdc4257SSteve Yin default: 25465fdc4257SSteve Yin break; 25475fdc4257SSteve Yin } 25485fdc4257SSteve Yin 25495fdc4257SSteve Yin return FALSE; 25505fdc4257SSteve Yin } 25515fdc4257SSteve Yin 25525fdc4257SSteve Yin HRESULT WINAPI CMAccessible::SmartQI(void* pv, REFIID iid, void** ppvObject) 25535fdc4257SSteve Yin { 25545fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 25555fdc4257SSteve Yin ISDESTROY() 25565fdc4257SSteve Yin if( ImplIsEqualGUID(iid,IID_IAccIdentity) || 25575fdc4257SSteve Yin ImplIsEqualGUID(iid,IID_IStdMarshalInfo) || 25585fdc4257SSteve Yin ImplIsEqualGUID(iid,IID_IMarshal) || 25595fdc4257SSteve Yin ImplIsEqualGUID(iid,IID_IExternalConnection)|| 25605fdc4257SSteve Yin ImplIsEqualGUID(iid,IID_IOleWindow)) 25615fdc4257SSteve Yin return E_FAIL; 25625fdc4257SSteve Yin 25635fdc4257SSteve Yin 25645fdc4257SSteve Yin _UNO_AGGMAP_ENTRY* pMap = _GetAggEntries(); 25655fdc4257SSteve Yin while(pMap && pMap->piid) 25665fdc4257SSteve Yin { 25675fdc4257SSteve Yin if(ImplIsEqualGUID(iid, *pMap->piid)) 25685fdc4257SSteve Yin { 25695fdc4257SSteve Yin XInterface* pXI = NULL; 25705fdc4257SSteve Yin BOOL bFound = GetXInterfaceFromXAccessible(pUNOInterface,&pXI,pMap->XIFIndex); 25715fdc4257SSteve Yin if(!bFound) 25725fdc4257SSteve Yin { 25735fdc4257SSteve Yin return E_FAIL; 25745fdc4257SSteve Yin } 25755fdc4257SSteve Yin 25765fdc4257SSteve Yin XGUIDToComObjHash::iterator pIndTemp = m_containedObjects.find( iid ); 25775fdc4257SSteve Yin if ( pIndTemp != m_containedObjects.end() ) 25785fdc4257SSteve Yin { 25795fdc4257SSteve Yin return pIndTemp->second.p->QueryInterface( iid, ppvObject ); 25805fdc4257SSteve Yin } 25815fdc4257SSteve Yin else 25825fdc4257SSteve Yin { 2583*b0a7a3cfSSteve Yin ActivateActContext(); 25845fdc4257SSteve Yin HRESULT hr = pMap->pfnCreateInstance(pv, iid, ppvObject); 2585*b0a7a3cfSSteve Yin DeactivateActContext(); 25865fdc4257SSteve Yin if(hr == S_OK) 25875fdc4257SSteve Yin { 25885fdc4257SSteve Yin m_containedObjects.insert(XGUIDToComObjHash::value_type(*pMap->piid,(IUnknown*)*ppvObject)); 25895fdc4257SSteve Yin IUNOXWrapper* wrapper = NULL; 25905fdc4257SSteve Yin ((IUnknown*)*ppvObject)->QueryInterface(IID_IUNOXWrapper, (void**)&wrapper); 25915fdc4257SSteve Yin if(wrapper) 25925fdc4257SSteve Yin { 25935fdc4257SSteve Yin wrapper->put_XInterface((long)pUNOInterface); 25945fdc4257SSteve Yin wrapper->Release(); 25955fdc4257SSteve Yin } 25965fdc4257SSteve Yin return S_OK; 25975fdc4257SSteve Yin } 25985fdc4257SSteve Yin } 25995fdc4257SSteve Yin return E_FAIL; 26005fdc4257SSteve Yin } 26015fdc4257SSteve Yin pMap++; 26025fdc4257SSteve Yin } 26035fdc4257SSteve Yin return E_FAIL; 26045fdc4257SSteve Yin 26055fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 26065fdc4257SSteve Yin } 26075fdc4257SSteve Yin 26085fdc4257SSteve Yin BOOL CMAccessible::get_IAccessibleFromXAccessible(long pXAcc, IAccessible **ppIA) 26095fdc4257SSteve Yin { 26105fdc4257SSteve Yin 26115fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 26125fdc4257SSteve Yin 26135fdc4257SSteve Yin // #CHECK# 26145fdc4257SSteve Yin if(ppIA == NULL) 26155fdc4257SSteve Yin { 26165fdc4257SSteve Yin return E_INVALIDARG; 26175fdc4257SSteve Yin } 26185fdc4257SSteve Yin BOOL isGet = FALSE; 26195fdc4257SSteve Yin if(g_pAgent) 26205fdc4257SSteve Yin isGet = g_pAgent->GetIAccessibleFromXAccessible((XAccessible*)pXAcc,ppIA); 26215fdc4257SSteve Yin 26225fdc4257SSteve Yin if(isGet) 26235fdc4257SSteve Yin return TRUE; 26245fdc4257SSteve Yin else 26255fdc4257SSteve Yin return FALSE; 26265fdc4257SSteve Yin 26275fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 26285fdc4257SSteve Yin } 26295fdc4257SSteve Yin 26305fdc4257SSteve Yin void CMAccessible::get_OLECHARFromAny(Any& pAny, OLECHAR* pChar) 26315fdc4257SSteve Yin { 26325fdc4257SSteve Yin // #CHECK# 26335fdc4257SSteve Yin if(pChar == NULL) 26345fdc4257SSteve Yin return; 26355fdc4257SSteve Yin 26365fdc4257SSteve Yin switch(pAny.getValueTypeClass()) 26375fdc4257SSteve Yin { 26385fdc4257SSteve Yin case TypeClass_CHAR: 26395fdc4257SSteve Yin { 26405fdc4257SSteve Yin sal_Int8 val; 26415fdc4257SSteve Yin pAny >>= val; 26425fdc4257SSteve Yin swprintf( pChar, L"%d", val); 26435fdc4257SSteve Yin break; 26445fdc4257SSteve Yin } 26455fdc4257SSteve Yin case TypeClass_BOOLEAN: 26465fdc4257SSteve Yin { 26475fdc4257SSteve Yin sal_Bool val; 26485fdc4257SSteve Yin pAny >>= val; 26495fdc4257SSteve Yin swprintf( pChar, L"%d", val); 26505fdc4257SSteve Yin break; 26515fdc4257SSteve Yin } 26525fdc4257SSteve Yin case TypeClass_BYTE: 26535fdc4257SSteve Yin { 26545fdc4257SSteve Yin sal_Int8 val; 26555fdc4257SSteve Yin pAny >>= val; 26565fdc4257SSteve Yin swprintf( pChar, L"%d", val); 26575fdc4257SSteve Yin break; 26585fdc4257SSteve Yin } 26595fdc4257SSteve Yin case TypeClass_SHORT: 26605fdc4257SSteve Yin { 26615fdc4257SSteve Yin SHORT val; 26625fdc4257SSteve Yin pAny >>= val; 26635fdc4257SSteve Yin swprintf( pChar, L"%d", val); 26645fdc4257SSteve Yin break; 26655fdc4257SSteve Yin } 26665fdc4257SSteve Yin case TypeClass_UNSIGNED_SHORT: 26675fdc4257SSteve Yin { 26685fdc4257SSteve Yin USHORT val; 26695fdc4257SSteve Yin pAny >>= val; 26705fdc4257SSteve Yin swprintf( pChar, L"%d", val); 26715fdc4257SSteve Yin break; 26725fdc4257SSteve Yin } 26735fdc4257SSteve Yin case TypeClass_LONG: 26745fdc4257SSteve Yin { 26755fdc4257SSteve Yin LONG val; 26765fdc4257SSteve Yin pAny >>= val; 26775fdc4257SSteve Yin swprintf( pChar, L"%ld", val); 26785fdc4257SSteve Yin break; 26795fdc4257SSteve Yin } 26805fdc4257SSteve Yin case TypeClass_UNSIGNED_LONG: 26815fdc4257SSteve Yin { 26825fdc4257SSteve Yin ULONG val; 26835fdc4257SSteve Yin pAny >>= val; 26845fdc4257SSteve Yin swprintf( pChar, L"%ld", val); 26855fdc4257SSteve Yin break; 26865fdc4257SSteve Yin } 26875fdc4257SSteve Yin case TypeClass_FLOAT: 26885fdc4257SSteve Yin { 26895fdc4257SSteve Yin FLOAT val; 26905fdc4257SSteve Yin pAny >>= val; 26915fdc4257SSteve Yin swprintf( pChar, L"%.3f", val); 26925fdc4257SSteve Yin break; 26935fdc4257SSteve Yin } 26945fdc4257SSteve Yin case TypeClass_DOUBLE: 26955fdc4257SSteve Yin { 26965fdc4257SSteve Yin DOUBLE val; 26975fdc4257SSteve Yin pAny >>= val; 26985fdc4257SSteve Yin swprintf( pChar, L"%.6lf", val); 26995fdc4257SSteve Yin break; 27005fdc4257SSteve Yin } 27015fdc4257SSteve Yin case TypeClass_STRING: 27025fdc4257SSteve Yin { 27035fdc4257SSteve Yin ::rtl::OUString val; 27045fdc4257SSteve Yin pAny >>= val; 27055fdc4257SSteve Yin wcscpy(pChar, val.getStr()); 27065fdc4257SSteve Yin break; 27075fdc4257SSteve Yin } 27085fdc4257SSteve Yin case TypeClass_SEQUENCE: 27095fdc4257SSteve Yin { 27105fdc4257SSteve Yin if(pAny.getValueType() == getCppuType( (Sequence< ::rtl::OUString > *)0 ) ) 27115fdc4257SSteve Yin { 27125fdc4257SSteve Yin Sequence < ::rtl::OUString > val; 27135fdc4257SSteve Yin pAny >>= val; 27145fdc4257SSteve Yin 27155fdc4257SSteve Yin ::rtl::OUString pString; 27165fdc4257SSteve Yin 27175fdc4257SSteve Yin int count = val.getLength(); 27185fdc4257SSteve Yin 27195fdc4257SSteve Yin for( int iIndex = 0;iIndex < count;iIndex++ ) 27205fdc4257SSteve Yin { 27215fdc4257SSteve Yin pString += val[iIndex]; 27225fdc4257SSteve Yin } 27235fdc4257SSteve Yin wcscpy(pChar, pString.getStr()); 27245fdc4257SSteve Yin } 27255fdc4257SSteve Yin else if (pAny.getValueType() == getCppuType( (Sequence< ::com::sun::star::style::TabStop >* )0 ) ) 27265fdc4257SSteve Yin { 27275fdc4257SSteve Yin Sequence < ::com::sun::star::style::TabStop > val; 27285fdc4257SSteve Yin pAny >>= val; 27295fdc4257SSteve Yin int count = val.getLength(); 27305fdc4257SSteve Yin 27315fdc4257SSteve Yin for( int iIndex = 0;iIndex < count;iIndex++ ) 27325fdc4257SSteve Yin { 27335fdc4257SSteve Yin OLECHAR pAttrs[512] = {NULL}; 27345fdc4257SSteve Yin 27355fdc4257SSteve Yin OLECHAR pAttrsPosition[512] = {NULL}; 27365fdc4257SSteve Yin OLECHAR pAttrsDescimalChar[512] = {NULL}; 27375fdc4257SSteve Yin OLECHAR pAttrsFillChar[512] = {NULL}; 27385fdc4257SSteve Yin 27395fdc4257SSteve Yin ::com::sun::star::style::TabStop sigleVal = val[iIndex]; 27405fdc4257SSteve Yin 27415fdc4257SSteve Yin swprintf( pAttrsPosition, L"Position=%ld,TabAlign=%ld", 27425fdc4257SSteve Yin sigleVal.Position, sigleVal.Alignment); 27435fdc4257SSteve Yin 27445fdc4257SSteve Yin if(sigleVal.DecimalChar==';' || sigleVal.DecimalChar == ':' || sigleVal.DecimalChar == ',' || 27455fdc4257SSteve Yin sigleVal.DecimalChar == '=' || sigleVal.DecimalChar == '\\') 27465fdc4257SSteve Yin swprintf( pAttrsDescimalChar, L"DecimalChar=\\%c",sigleVal.DecimalChar); 27475fdc4257SSteve Yin else 27485fdc4257SSteve Yin swprintf( pAttrsDescimalChar, L"DecimalChar=%c",sigleVal.DecimalChar); 27495fdc4257SSteve Yin 27505fdc4257SSteve Yin if(sigleVal.FillChar==';' || sigleVal.FillChar == ':' || sigleVal.FillChar == ',' || 27515fdc4257SSteve Yin sigleVal.FillChar == '=' || sigleVal.FillChar == '\\') 27525fdc4257SSteve Yin swprintf( pAttrsFillChar, L"FillChar=\\%c",sigleVal.FillChar); 27535fdc4257SSteve Yin else 27545fdc4257SSteve Yin swprintf( pAttrsFillChar, L"FillChar=%c",sigleVal.FillChar); 27555fdc4257SSteve Yin 27565fdc4257SSteve Yin swprintf( pAttrs, L"%s,%s,%s,",pAttrsPosition,pAttrsDescimalChar,pAttrsFillChar); 27575fdc4257SSteve Yin 27585fdc4257SSteve Yin wcscat(pChar,pAttrs); 27595fdc4257SSteve Yin } 27605fdc4257SSteve Yin } 27615fdc4257SSteve Yin break; 27625fdc4257SSteve Yin } 27635fdc4257SSteve Yin case TypeClass_ENUM: 27645fdc4257SSteve Yin { 27655fdc4257SSteve Yin if (pAny.getValueType() == getCppuType( (::com::sun::star::awt::FontSlant* )0 ) ) 27665fdc4257SSteve Yin { 27675fdc4257SSteve Yin com::sun::star::awt::FontSlant val; 27685fdc4257SSteve Yin pAny >>= val; 27695fdc4257SSteve Yin swprintf( pChar, L"%d", val); 27705fdc4257SSteve Yin } 27715fdc4257SSteve Yin } 27725fdc4257SSteve Yin case TypeClass_STRUCT: 27735fdc4257SSteve Yin { 27745fdc4257SSteve Yin if (pAny.getValueType() == getCppuType( (::com::sun::star::style::LineSpacing* )0 ) ) 27755fdc4257SSteve Yin { 27765fdc4257SSteve Yin com::sun::star::style::LineSpacing val; 27775fdc4257SSteve Yin pAny >>= val; 27785fdc4257SSteve Yin swprintf( pChar, L"Mode=%ld,Height=%ld,", val.Mode, val.Height); 27795fdc4257SSteve Yin } 27805fdc4257SSteve Yin else if (pAny.getValueType() == getCppuType( (com::sun::star::accessibility::TextSegment *)0 ) ) 27815fdc4257SSteve Yin { 27825fdc4257SSteve Yin com::sun::star::accessibility::TextSegment val; 27835fdc4257SSteve Yin pAny >>= val; 27845fdc4257SSteve Yin ::rtl::OUString realVal(val.SegmentText); 27855fdc4257SSteve Yin wcscpy(pChar, realVal.getStr()); 27865fdc4257SSteve Yin } 27875fdc4257SSteve Yin break; 27885fdc4257SSteve Yin } 27895fdc4257SSteve Yin case TypeClass_VOID: 27905fdc4257SSteve Yin case TypeClass_HYPER: 27915fdc4257SSteve Yin case TypeClass_UNSIGNED_HYPER: 27925fdc4257SSteve Yin case TypeClass_TYPE: 27935fdc4257SSteve Yin case TypeClass_ANY: 27945fdc4257SSteve Yin case TypeClass_TYPEDEF: 27955fdc4257SSteve Yin case TypeClass_UNION: 27965fdc4257SSteve Yin case TypeClass_EXCEPTION: 27975fdc4257SSteve Yin case TypeClass_ARRAY: 27985fdc4257SSteve Yin case TypeClass_INTERFACE: 27995fdc4257SSteve Yin case TypeClass_SERVICE: 28005fdc4257SSteve Yin case TypeClass_MODULE: 28015fdc4257SSteve Yin case TypeClass_INTERFACE_METHOD: 28025fdc4257SSteve Yin case TypeClass_INTERFACE_ATTRIBUTE: 28035fdc4257SSteve Yin case TypeClass_UNKNOWN: 28045fdc4257SSteve Yin case TypeClass_PROPERTY: 28055fdc4257SSteve Yin case TypeClass_CONSTANT: 28065fdc4257SSteve Yin case TypeClass_CONSTANTS: 28075fdc4257SSteve Yin case TypeClass_SINGLETON: 28085fdc4257SSteve Yin case TypeClass_MAKE_FIXED_SIZE: 28095fdc4257SSteve Yin break; 28105fdc4257SSteve Yin default: 28115fdc4257SSteve Yin break; 28125fdc4257SSteve Yin } 28135fdc4257SSteve Yin } 28145fdc4257SSteve Yin 28155fdc4257SSteve Yin void CMAccessible::get_OLECHAR4Numbering(const Any& pAny, short numberingLevel,const OUString& numberingPrefix,OLECHAR* pChar) 28165fdc4257SSteve Yin { 28175fdc4257SSteve Yin if(pChar == NULL) 28185fdc4257SSteve Yin return; 28195fdc4257SSteve Yin Reference< ::com::sun::star::container::XIndexReplace > pXIndex; 28205fdc4257SSteve Yin if((pAny>>=pXIndex) && (numberingLevel !=-1))//numbering level is -1,means invalid value 28215fdc4257SSteve Yin { 28225fdc4257SSteve Yin Any aAny = pXIndex->getByIndex(numberingLevel); 28235fdc4257SSteve Yin Sequence< ::com::sun::star::beans::PropertyValue > aProps; 28245fdc4257SSteve Yin aAny >>= aProps; 28255fdc4257SSteve Yin const ::com::sun::star::beans::PropertyValue* pPropArray = aProps.getConstArray(); 28265fdc4257SSteve Yin sal_Int32 nCount = aProps.getLength(); 28275fdc4257SSteve Yin swprintf(pChar,L"Numbering:NumberingLevel=%d,",numberingLevel); 28285fdc4257SSteve Yin for( sal_Int32 i=0; i<nCount; i++ ) 28295fdc4257SSteve Yin { 28305fdc4257SSteve Yin ::com::sun::star::beans::PropertyValue rProp = pPropArray[i]; 28315fdc4257SSteve Yin if( (rProp.Name.compareTo(OUString::createFromAscii("BulletChar"))==0)|| 28325fdc4257SSteve Yin (rProp.Name.compareTo(OUString::createFromAscii("GraphicURL"))==0)|| 28335fdc4257SSteve Yin (rProp.Name.compareTo(OUString::createFromAscii("NumberingType"))==0)) 28345fdc4257SSteve Yin { 28355fdc4257SSteve Yin OLECHAR propStr[512] = {NULL}; 28365fdc4257SSteve Yin swprintf(propStr,L"%s=",rProp.Name.getStr()); 28375fdc4257SSteve Yin OLECHAR pTemp[256] = {NULL}; 28385fdc4257SSteve Yin CMAccessible::get_OLECHARFromAny(rProp.Value,pTemp); 28395fdc4257SSteve Yin if(rProp.Name.compareTo(OUString::createFromAscii("GraphicURL"))==0) 28405fdc4257SSteve Yin { 28415fdc4257SSteve Yin OLECHAR* pOccur = wcschr(pTemp,':'); 28425fdc4257SSteve Yin if(pOccur) 28435fdc4257SSteve Yin *pOccur = '.'; 28445fdc4257SSteve Yin } 28455fdc4257SSteve Yin wcscat(propStr,pTemp); 28465fdc4257SSteve Yin wcscat(pChar,propStr); 28475fdc4257SSteve Yin wcscat(pChar,L","); 28485fdc4257SSteve Yin 28495fdc4257SSteve Yin if(rProp.Name.compareTo(OUString::createFromAscii("NumberingType"))==0) 28505fdc4257SSteve Yin { 28515fdc4257SSteve Yin if(numberingPrefix.getLength()!=0) 28525fdc4257SSteve Yin { 28535fdc4257SSteve Yin swprintf(pTemp,L"NumberingPrefix=%s,",numberingPrefix.getStr()); 28545fdc4257SSteve Yin wcscat(pChar,pTemp); 28555fdc4257SSteve Yin } 28565fdc4257SSteve Yin } 28575fdc4257SSteve Yin } 28585fdc4257SSteve Yin } 28595fdc4257SSteve Yin } 28605fdc4257SSteve Yin 28615fdc4257SSteve Yin //Because now have three types numbering level: 28625fdc4257SSteve Yin //1.real numbering list,numbering level>=0 and numbering Rule !=NULL; 28635fdc4257SSteve Yin //2.common paragraph, numbering level >=0, and numbering Rule == NULL; 28645fdc4257SSteve Yin //3.TOC paragraph, numbering level >0, and numbering Rule ==NULL; 28655fdc4257SSteve Yin // IAText:numberinglevel base on 0, but TOC's level base on 1, 28665fdc4257SSteve Yin // so NumberingLevel value will be decreased 1 in bridge code. 28675fdc4257SSteve Yin else if(numberingLevel >0) 28685fdc4257SSteve Yin { 28695fdc4257SSteve Yin swprintf(pChar,L"Numbering:NumberingLevel=%d,NumberingType=4,NumberingPrefix=,",numberingLevel-1); 28705fdc4257SSteve Yin } 28715fdc4257SSteve Yin else 28725fdc4257SSteve Yin { 28735fdc4257SSteve Yin swprintf(pChar,L"Numbering:"); 28745fdc4257SSteve Yin } 28755fdc4257SSteve Yin } 28765fdc4257SSteve Yin 28775fdc4257SSteve Yin void CMAccessible::ConvertAnyToVariant(const ::com::sun::star::uno::Any &rAnyVal, VARIANT *pvData) 28785fdc4257SSteve Yin { 28795fdc4257SSteve Yin if(rAnyVal.hasValue()) 28805fdc4257SSteve Yin { 28815fdc4257SSteve Yin // Clear VARIANT variable. 28825fdc4257SSteve Yin VariantClear(pvData); 28835fdc4257SSteve Yin 28845fdc4257SSteve Yin // Set value according to value type. 28855fdc4257SSteve Yin switch(rAnyVal.getValueTypeClass()) 28865fdc4257SSteve Yin { 28875fdc4257SSteve Yin case TypeClass_CHAR: 28885fdc4257SSteve Yin pvData->vt = VT_UI1; 28895fdc4257SSteve Yin memcpy(&pvData->bVal, rAnyVal.getValue(), sizeof(sal_Char)); 28905fdc4257SSteve Yin break; 28915fdc4257SSteve Yin 28925fdc4257SSteve Yin case TypeClass_BOOLEAN: 28935fdc4257SSteve Yin pvData->vt = VT_BOOL; 28945fdc4257SSteve Yin memcpy(&pvData->boolVal, rAnyVal.getValue(), sizeof(sal_Bool)); 28955fdc4257SSteve Yin break; 28965fdc4257SSteve Yin 28975fdc4257SSteve Yin case TypeClass_BYTE: 28985fdc4257SSteve Yin pvData->vt = VT_UI1; 28995fdc4257SSteve Yin memcpy(&pvData->bVal, rAnyVal.getValue(), sizeof(sal_Int8)); 29005fdc4257SSteve Yin break; 29015fdc4257SSteve Yin 29025fdc4257SSteve Yin case TypeClass_SHORT: 29035fdc4257SSteve Yin pvData->vt = VT_I2; 29045fdc4257SSteve Yin memcpy(&pvData->iVal, rAnyVal.getValue(), sizeof(sal_Int16)); 29055fdc4257SSteve Yin break; 29065fdc4257SSteve Yin 29075fdc4257SSteve Yin case TypeClass_UNSIGNED_SHORT: 29085fdc4257SSteve Yin pvData->vt = VT_I2; 29095fdc4257SSteve Yin memcpy(&pvData->iVal, rAnyVal.getValue(), sizeof(sal_uInt16)); 29105fdc4257SSteve Yin break; 29115fdc4257SSteve Yin 29125fdc4257SSteve Yin case TypeClass_LONG: 29135fdc4257SSteve Yin pvData->vt = VT_I4; 29145fdc4257SSteve Yin memcpy(&pvData->lVal, rAnyVal.getValue(), sizeof(sal_Int32)); 29155fdc4257SSteve Yin break; 29165fdc4257SSteve Yin 29175fdc4257SSteve Yin case TypeClass_UNSIGNED_LONG: 29185fdc4257SSteve Yin pvData->vt = VT_I4; 29195fdc4257SSteve Yin memcpy(&pvData->lVal, rAnyVal.getValue(), sizeof(sal_uInt32)); 29205fdc4257SSteve Yin break; 29215fdc4257SSteve Yin 29225fdc4257SSteve Yin case TypeClass_FLOAT: 29235fdc4257SSteve Yin pvData->vt = VT_R4; 29245fdc4257SSteve Yin memcpy(&pvData->fltVal, rAnyVal.getValue(), sizeof(float)); 29255fdc4257SSteve Yin break; 29265fdc4257SSteve Yin 29275fdc4257SSteve Yin case TypeClass_DOUBLE: 29285fdc4257SSteve Yin pvData->vt = VT_R8; 29295fdc4257SSteve Yin memcpy(&pvData->dblVal, rAnyVal.getValue(), sizeof(double)); 29305fdc4257SSteve Yin break; 29315fdc4257SSteve Yin 29325fdc4257SSteve Yin case TypeClass_STRING: 29335fdc4257SSteve Yin { 29345fdc4257SSteve Yin pvData->vt = VT_BSTR; 29355fdc4257SSteve Yin ::rtl::OUString val; 29365fdc4257SSteve Yin rAnyVal >>= val; 29375fdc4257SSteve Yin pvData->bstrVal = SysAllocString((OLECHAR *)val.getStr()); 29385fdc4257SSteve Yin break; 29395fdc4257SSteve Yin } 29405fdc4257SSteve Yin 29415fdc4257SSteve Yin case TypeClass_VOID: 29425fdc4257SSteve Yin case TypeClass_HYPER: 29435fdc4257SSteve Yin case TypeClass_UNSIGNED_HYPER: 29445fdc4257SSteve Yin case TypeClass_TYPE: 29455fdc4257SSteve Yin case TypeClass_ANY: 29465fdc4257SSteve Yin case TypeClass_ENUM: 29475fdc4257SSteve Yin case TypeClass_TYPEDEF: 29485fdc4257SSteve Yin case TypeClass_STRUCT: 29495fdc4257SSteve Yin case TypeClass_UNION: 29505fdc4257SSteve Yin case TypeClass_EXCEPTION: 29515fdc4257SSteve Yin case TypeClass_SEQUENCE: 29525fdc4257SSteve Yin case TypeClass_ARRAY: 29535fdc4257SSteve Yin case TypeClass_INTERFACE: 29545fdc4257SSteve Yin { 29555fdc4257SSteve Yin Reference< XAccessible > pXAcc; 29565fdc4257SSteve Yin if(rAnyVal >>= pXAcc) 29575fdc4257SSteve Yin { 29585fdc4257SSteve Yin if(pXAcc.is()) 29595fdc4257SSteve Yin { 29605fdc4257SSteve Yin IAccessible* pIAcc = NULL; 29615fdc4257SSteve Yin get_IAccessibleFromXAccessible((long)pXAcc.get(), &pIAcc); 29625fdc4257SSteve Yin if(pIAcc == NULL) 29635fdc4257SSteve Yin { 29645fdc4257SSteve Yin Reference< XAccessibleContext > pXAccContext = pXAcc->getAccessibleContext(); 29655fdc4257SSteve Yin g_pAgent->InsertAccObj(pXAcc.get(),pXAccContext->getAccessibleParent().get()); 29665fdc4257SSteve Yin get_IAccessibleFromXAccessible((long)pXAcc.get(), &pIAcc); 29675fdc4257SSteve Yin } 29685fdc4257SSteve Yin if(pIAcc) 29695fdc4257SSteve Yin { 29705fdc4257SSteve Yin pIAcc->AddRef(); 29715fdc4257SSteve Yin 29725fdc4257SSteve Yin pvData->vt = VT_UNKNOWN; 29735fdc4257SSteve Yin pvData->pdispVal = (IAccessible2*)pIAcc; 29745fdc4257SSteve Yin break; 29755fdc4257SSteve Yin } 29765fdc4257SSteve Yin } 29775fdc4257SSteve Yin } 29785fdc4257SSteve Yin } 29795fdc4257SSteve Yin case TypeClass_SERVICE: 29805fdc4257SSteve Yin case TypeClass_MODULE: 29815fdc4257SSteve Yin case TypeClass_INTERFACE_METHOD: 29825fdc4257SSteve Yin case TypeClass_INTERFACE_ATTRIBUTE: 29835fdc4257SSteve Yin case TypeClass_UNKNOWN: 29845fdc4257SSteve Yin case TypeClass_PROPERTY: 29855fdc4257SSteve Yin case TypeClass_CONSTANT: 29865fdc4257SSteve Yin case TypeClass_CONSTANTS: 29875fdc4257SSteve Yin case TypeClass_SINGLETON: 29885fdc4257SSteve Yin case TypeClass_MAKE_FIXED_SIZE: 29895fdc4257SSteve Yin // Output the type string, if there is other uno value type. 29905fdc4257SSteve Yin pvData->vt = VT_BSTR; 29915fdc4257SSteve Yin pvData->bstrVal = SysAllocString(rAnyVal.getValueTypeName().getStr()); 29925fdc4257SSteve Yin break; 29935fdc4257SSteve Yin 29945fdc4257SSteve Yin default: 29955fdc4257SSteve Yin break; 29965fdc4257SSteve Yin } 29975fdc4257SSteve Yin } 29985fdc4257SSteve Yin else 29995fdc4257SSteve Yin { 30005fdc4257SSteve Yin VariantClear(pvData); 30015fdc4257SSteve Yin } 30025fdc4257SSteve Yin } 30035fdc4257SSteve Yin 30045fdc4257SSteve Yin STDMETHODIMP CMAccessible::Get_XAccChildID(long* childID) 30055fdc4257SSteve Yin { 30065fdc4257SSteve Yin // #CHECK# 30075fdc4257SSteve Yin if(childID == NULL) 30085fdc4257SSteve Yin { 30095fdc4257SSteve Yin return E_FAIL; 30105fdc4257SSteve Yin } 30115fdc4257SSteve Yin *childID = m_dChildID; 30125fdc4257SSteve Yin return S_OK; 30135fdc4257SSteve Yin } 30145fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_states(AccessibleStates __RPC_FAR *states ) 30155fdc4257SSteve Yin { 30165fdc4257SSteve Yin 30175fdc4257SSteve Yin CHECK_ENABLE_INF 30185fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 30195fdc4257SSteve Yin ISDESTROY() 30205fdc4257SSteve Yin // #CHECK XInterface# 30215fdc4257SSteve Yin if( !pRContext.is() ) 30225fdc4257SSteve Yin return E_FAIL; 30235fdc4257SSteve Yin 30245fdc4257SSteve Yin Reference<XAccessibleStateSet> pRStateSet = pRContext.get()->getAccessibleStateSet(); 30255fdc4257SSteve Yin if(!pRStateSet.is()) 30265fdc4257SSteve Yin { 30275fdc4257SSteve Yin return S_OK; 30285fdc4257SSteve Yin } 30295fdc4257SSteve Yin Sequence<short> pStates = pRStateSet->getStates(); 30305fdc4257SSteve Yin 30315fdc4257SSteve Yin 30325fdc4257SSteve Yin long count = pStates.getLength() ; 30335fdc4257SSteve Yin *states = 0x0; 30345fdc4257SSteve Yin for( int i = 0; i < count; i++ ) 30355fdc4257SSteve Yin { 30365fdc4257SSteve Yin for( int j = 0; j < sizeof(UNO_STATES) / sizeof(UNO_STATES[0]); j++ ) 30375fdc4257SSteve Yin { 30385fdc4257SSteve Yin if( pStates[i] == UNO_STATES[j] ) 30395fdc4257SSteve Yin { 30405fdc4257SSteve Yin *states |= IA2_STATES[j]; 30415fdc4257SSteve Yin break; 30425fdc4257SSteve Yin } 30435fdc4257SSteve Yin } 30445fdc4257SSteve Yin } 30455fdc4257SSteve Yin return S_OK; 30465fdc4257SSteve Yin 30475fdc4257SSteve Yin 30485fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 30495fdc4257SSteve Yin } 30505fdc4257SSteve Yin 30515fdc4257SSteve Yin // return the UNO roles 30525fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_extendedRole( BSTR __RPC_FAR * ) 30535fdc4257SSteve Yin { 30545fdc4257SSteve Yin 30555fdc4257SSteve Yin CHECK_ENABLE_INF 30565fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 30575fdc4257SSteve Yin ISDESTROY() 30585fdc4257SSteve Yin 30595fdc4257SSteve Yin return E_NOTIMPL; 30605fdc4257SSteve Yin 30615fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 30625fdc4257SSteve Yin } 30635fdc4257SSteve Yin 30645fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_localizedExtendedRole( BSTR __RPC_FAR * ) 30655fdc4257SSteve Yin { 30665fdc4257SSteve Yin 30675fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 30685fdc4257SSteve Yin ISDESTROY() 30695fdc4257SSteve Yin return E_NOTIMPL; 30705fdc4257SSteve Yin 30715fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 30725fdc4257SSteve Yin } 30735fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_nExtendedStates( long __RPC_FAR * ) 30745fdc4257SSteve Yin { 30755fdc4257SSteve Yin 30765fdc4257SSteve Yin CHECK_ENABLE_INF 30775fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 30785fdc4257SSteve Yin ISDESTROY() 30795fdc4257SSteve Yin 30805fdc4257SSteve Yin return E_NOTIMPL; 30815fdc4257SSteve Yin 30825fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 30835fdc4257SSteve Yin } 30845fdc4257SSteve Yin 30855fdc4257SSteve Yin 30865fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_localizedExtendedStates( long, BSTR __RPC_FAR *__RPC_FAR *, long __RPC_FAR *) 30875fdc4257SSteve Yin { 30885fdc4257SSteve Yin 30895fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 30905fdc4257SSteve Yin ISDESTROY() 30915fdc4257SSteve Yin return E_NOTIMPL; 30925fdc4257SSteve Yin 30935fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 30945fdc4257SSteve Yin } 30955fdc4257SSteve Yin 30965fdc4257SSteve Yin 30975fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_indexInParent( long __RPC_FAR *accParentIndex) 30985fdc4257SSteve Yin { 30995fdc4257SSteve Yin 31005fdc4257SSteve Yin CHECK_ENABLE_INF 31015fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 31025fdc4257SSteve Yin ISDESTROY() 31035fdc4257SSteve Yin // #CHECK# 31045fdc4257SSteve Yin if(accParentIndex == NULL) 31055fdc4257SSteve Yin return E_INVALIDARG; 31065fdc4257SSteve Yin 31075fdc4257SSteve Yin // #CHECK XInterface# 31085fdc4257SSteve Yin if( !pRContext.is() ) 31095fdc4257SSteve Yin return E_FAIL; 31105fdc4257SSteve Yin 31115fdc4257SSteve Yin *accParentIndex = pRContext.get()->getAccessibleIndexInParent(); 31125fdc4257SSteve Yin return S_OK; 31135fdc4257SSteve Yin 31145fdc4257SSteve Yin 31155fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 31165fdc4257SSteve Yin } 31175fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_locale( IA2Locale __RPC_FAR *locale ) 31185fdc4257SSteve Yin { 31195fdc4257SSteve Yin 31205fdc4257SSteve Yin CHECK_ENABLE_INF 31215fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 31225fdc4257SSteve Yin ISDESTROY() 31235fdc4257SSteve Yin if(locale == NULL) 31245fdc4257SSteve Yin return E_INVALIDARG; 31255fdc4257SSteve Yin // #CHECK XInterface# 31265fdc4257SSteve Yin 31275fdc4257SSteve Yin if( !pRContext.is() ) 31285fdc4257SSteve Yin return E_FAIL; 31295fdc4257SSteve Yin 31305fdc4257SSteve Yin ::com::sun::star::lang::Locale unoLoc = pRContext.get()->getLocale(); 31315fdc4257SSteve Yin locale->language = SysAllocString((OLECHAR*)unoLoc.Language.getStr()); 31325fdc4257SSteve Yin locale->country = SysAllocString((OLECHAR*)unoLoc.Country.getStr()); 31335fdc4257SSteve Yin locale->variant = SysAllocString((OLECHAR*)unoLoc.Variant.getStr()); 31345fdc4257SSteve Yin 31355fdc4257SSteve Yin return S_OK; 31365fdc4257SSteve Yin 31375fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 31385fdc4257SSteve Yin } 31395fdc4257SSteve Yin 31405fdc4257SSteve Yin DWORD GetMSAAStateFromUNO(short xState) 31415fdc4257SSteve Yin { 31425fdc4257SSteve Yin DWORD IState = STATE_SYSTEM_UNAVAILABLE; 31435fdc4257SSteve Yin switch( xState ) 31445fdc4257SSteve Yin { 31455fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::BUSY: 31465fdc4257SSteve Yin IState = STATE_SYSTEM_BUSY; 31475fdc4257SSteve Yin break; 31485fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::CHECKED: 31495fdc4257SSteve Yin IState = STATE_SYSTEM_CHECKED; 31505fdc4257SSteve Yin break; 31515fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::DEFUNC: 31525fdc4257SSteve Yin IState = STATE_SYSTEM_UNAVAILABLE; 31535fdc4257SSteve Yin break; 31545fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::EXPANDED: 31555fdc4257SSteve Yin IState = STATE_SYSTEM_EXPANDED; 31565fdc4257SSteve Yin break; 31575fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::FOCUSABLE: 31585fdc4257SSteve Yin IState = STATE_SYSTEM_FOCUSABLE; 31595fdc4257SSteve Yin break; 31605fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::FOCUSED: 31615fdc4257SSteve Yin IState = STATE_SYSTEM_FOCUSED; 31625fdc4257SSteve Yin break; 31635fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::INDETERMINATE: 31645fdc4257SSteve Yin IState = STATE_SYSTEM_MIXED; 31655fdc4257SSteve Yin break; 31665fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::MULTI_SELECTABLE: 31675fdc4257SSteve Yin IState = STATE_SYSTEM_MULTISELECTABLE; 31685fdc4257SSteve Yin break; 31695fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::PRESSED: 31705fdc4257SSteve Yin IState = STATE_SYSTEM_PRESSED; 31715fdc4257SSteve Yin break; 31725fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::RESIZABLE: 31735fdc4257SSteve Yin IState = STATE_SYSTEM_SIZEABLE; 31745fdc4257SSteve Yin break; 31755fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::SELECTABLE: 31765fdc4257SSteve Yin IState = STATE_SYSTEM_SELECTABLE; 31775fdc4257SSteve Yin break; 31785fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::SELECTED: 31795fdc4257SSteve Yin IState = STATE_SYSTEM_SELECTED; 31805fdc4257SSteve Yin break; 31815fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::ARMED: 31825fdc4257SSteve Yin IState = STATE_SYSTEM_FOCUSED; 31835fdc4257SSteve Yin break; 31845fdc4257SSteve Yin case /*AccessibleStateType::*/AccessibleStateType::EXPANDABLE: 31855fdc4257SSteve Yin IState = STATE_SYSTEM_COLLAPSED; 31865fdc4257SSteve Yin break; 31875fdc4257SSteve Yin default: 31885fdc4257SSteve Yin break; 31895fdc4257SSteve Yin } 31905fdc4257SSteve Yin return IState; 31915fdc4257SSteve Yin } 31925fdc4257SSteve Yin 31935fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_appName( BSTR __RPC_FAR *name) 31945fdc4257SSteve Yin { 31955fdc4257SSteve Yin 31965fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 31975fdc4257SSteve Yin ISDESTROY() 31985fdc4257SSteve Yin if(name == NULL) 31995fdc4257SSteve Yin return E_INVALIDARG; 32005fdc4257SSteve Yin 32015fdc4257SSteve Yin *name = SysAllocString(OLESTR("Hannover")); 32025fdc4257SSteve Yin return S_OK; 32035fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 32045fdc4257SSteve Yin } 32055fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_appVersion(BSTR __RPC_FAR *version) 32065fdc4257SSteve Yin { 32075fdc4257SSteve Yin 32085fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 32095fdc4257SSteve Yin ISDESTROY() 32105fdc4257SSteve Yin if(version == NULL) 32115fdc4257SSteve Yin return E_INVALIDARG; 32125fdc4257SSteve Yin *version=SysAllocString(OLESTR("3.0")); 32135fdc4257SSteve Yin return S_OK; 32145fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 32155fdc4257SSteve Yin } 32165fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_toolkitName(BSTR __RPC_FAR *name) 32175fdc4257SSteve Yin { 32185fdc4257SSteve Yin 32195fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 32205fdc4257SSteve Yin ISDESTROY() 32215fdc4257SSteve Yin if(name == NULL) 32225fdc4257SSteve Yin return E_INVALIDARG; 32235fdc4257SSteve Yin *name = SysAllocString(OLESTR(" ")); 32245fdc4257SSteve Yin return S_OK; 32255fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 32265fdc4257SSteve Yin } 32275fdc4257SSteve Yin STDMETHODIMP CMAccessible:: get_toolkitVersion(BSTR __RPC_FAR *version) 32285fdc4257SSteve Yin { 32295fdc4257SSteve Yin 32305fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 32315fdc4257SSteve Yin ISDESTROY() 32325fdc4257SSteve Yin if(version == NULL) 32335fdc4257SSteve Yin return E_INVALIDARG; 32345fdc4257SSteve Yin *version = SysAllocString(OLESTR(" ")); 32355fdc4257SSteve Yin return S_OK; 32365fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 32375fdc4257SSteve Yin } 32385fdc4257SSteve Yin 32395fdc4257SSteve Yin 32405fdc4257SSteve Yin STDMETHODIMP CMAccessible::get_attributes(/*[out]*/ BSTR *pAttr) 32415fdc4257SSteve Yin { 32425fdc4257SSteve Yin CHECK_ENABLE_INF 32435fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 32445fdc4257SSteve Yin if( !pRContext.is() ) 32455fdc4257SSteve Yin { 32465fdc4257SSteve Yin return E_FAIL; 32475fdc4257SSteve Yin } 32485fdc4257SSteve Yin Reference<XAccessibleExtendedAttributes> pRXI(pRContext,UNO_QUERY); 32495fdc4257SSteve Yin if( !pRXI.is() ) 32505fdc4257SSteve Yin return E_FAIL; 32515fdc4257SSteve Yin else 32525fdc4257SSteve Yin { 32535fdc4257SSteve Yin com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleExtendedAttributes> pRXAttr; 32545fdc4257SSteve Yin pRXAttr = pRXI.get(); 32555fdc4257SSteve Yin ::com::sun::star::uno::Any anyVal = pRXAttr->getExtendedAttributes(); 32565fdc4257SSteve Yin 32575fdc4257SSteve Yin ::rtl::OUString val; 32585fdc4257SSteve Yin anyVal >>= val; 32595fdc4257SSteve Yin 32605fdc4257SSteve Yin if(*pAttr) 32615fdc4257SSteve Yin SAFE_SYSFREESTRING(*pAttr); 32625fdc4257SSteve Yin *pAttr = SysAllocString((OLECHAR *)val.getStr()); 32635fdc4257SSteve Yin 32645fdc4257SSteve Yin return S_OK; 32655fdc4257SSteve Yin } 32665fdc4257SSteve Yin } 32675fdc4257SSteve Yin 3268