1*3a700b0aSSteve Yin /************************************************************** 25fdc4257SSteve Yin * 3*3a700b0aSSteve Yin * Licensed to the Apache Software Foundation (ASF) under one 4*3a700b0aSSteve Yin * or more contributor license agreements. See the NOTICE file 5*3a700b0aSSteve Yin * distributed with this work for additional information 6*3a700b0aSSteve Yin * regarding copyright ownership. The ASF licenses this file 7*3a700b0aSSteve Yin * to you under the Apache License, Version 2.0 (the 8*3a700b0aSSteve Yin * "License"); you may not use this file except in compliance 9*3a700b0aSSteve Yin * with the License. You may obtain a copy of the License at 105fdc4257SSteve Yin * 11*3a700b0aSSteve Yin * http://www.apache.org/licenses/LICENSE-2.0 125fdc4257SSteve Yin * 13*3a700b0aSSteve Yin * Unless required by applicable law or agreed to in writing, 14*3a700b0aSSteve Yin * software distributed under the License is distributed on an 15*3a700b0aSSteve Yin * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3a700b0aSSteve Yin * KIND, either express or implied. See the License for the 17*3a700b0aSSteve Yin * specific language governing permissions and limitations 18*3a700b0aSSteve Yin * under the License. 195fdc4257SSteve Yin * 20*3a700b0aSSteve Yin *************************************************************/ 215fdc4257SSteve Yin 225fdc4257SSteve Yin #include "stdafx.h" 235fdc4257SSteve Yin #include "UAccCOM2.h" 245fdc4257SSteve Yin #include "AccRelation.h" 255fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessible.hpp> 265fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleContext.hpp> 275fdc4257SSteve Yin #include "MAccessible.h" 285fdc4257SSteve Yin 295fdc4257SSteve Yin using namespace com::sun::star::accessibility; 305fdc4257SSteve Yin using namespace com::sun::star::uno; 315fdc4257SSteve Yin 325fdc4257SSteve Yin /** 335fdc4257SSteve Yin * Get relation type. 345fdc4257SSteve Yin * @param relationType Variant to get relation type. 355fdc4257SSteve Yin * @return Result. 365fdc4257SSteve Yin */ 375fdc4257SSteve Yin STDMETHODIMP CAccRelation::get_relationType(BSTR * relationType) 385fdc4257SSteve Yin { 395fdc4257SSteve Yin 405fdc4257SSteve Yin CHECK_ENABLE_INF 415fdc4257SSteve Yin 425fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 435fdc4257SSteve Yin 445fdc4257SSteve Yin if (relationType == NULL) 455fdc4257SSteve Yin return E_INVALIDARG; 465fdc4257SSteve Yin 475fdc4257SSteve Yin int type = relation.RelationType; 485fdc4257SSteve Yin SAFE_SYSFREESTRING(*relationType); 495fdc4257SSteve Yin 505fdc4257SSteve Yin *relationType = getRelationTypeBSTR(type); 515fdc4257SSteve Yin return S_OK; 525fdc4257SSteve Yin 535fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 545fdc4257SSteve Yin } 555fdc4257SSteve Yin 565fdc4257SSteve Yin // Gets what the type of localized relation is. 575fdc4257SSteve Yin STDMETHODIMP CAccRelation::get_localizedRelationType(BSTR *) 585fdc4257SSteve Yin { 595fdc4257SSteve Yin 605fdc4257SSteve Yin 615fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 625fdc4257SSteve Yin 635fdc4257SSteve Yin return S_OK; 645fdc4257SSteve Yin 655fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 665fdc4257SSteve Yin } 675fdc4257SSteve Yin 685fdc4257SSteve Yin /** 695fdc4257SSteve Yin * Get targets length. 705fdc4257SSteve Yin * @param nTargets Variant to get targets length. 715fdc4257SSteve Yin * @return Result. 725fdc4257SSteve Yin */ 735fdc4257SSteve Yin STDMETHODIMP CAccRelation::get_nTargets(long * nTargets) 745fdc4257SSteve Yin { 755fdc4257SSteve Yin 765fdc4257SSteve Yin 775fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 785fdc4257SSteve Yin 795fdc4257SSteve Yin CHECK_ENABLE_INF 805fdc4257SSteve Yin if (nTargets == NULL) 815fdc4257SSteve Yin return E_INVALIDARG; 825fdc4257SSteve Yin 835fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = relation.TargetSet; 845fdc4257SSteve Yin *nTargets = xTargets.getLength(); 855fdc4257SSteve Yin return S_OK; 865fdc4257SSteve Yin 875fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 885fdc4257SSteve Yin } 895fdc4257SSteve Yin 905fdc4257SSteve Yin /** 915fdc4257SSteve Yin * Get special target. 925fdc4257SSteve Yin * @param targetIndex target index. 935fdc4257SSteve Yin * @param target Variant to get special target. 945fdc4257SSteve Yin * @return Result. 955fdc4257SSteve Yin */ 965fdc4257SSteve Yin STDMETHODIMP CAccRelation::get_target(long targetIndex, IUnknown * * target) 975fdc4257SSteve Yin { 985fdc4257SSteve Yin 995fdc4257SSteve Yin CHECK_ENABLE_INF 1005fdc4257SSteve Yin 1015fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1025fdc4257SSteve Yin 1035fdc4257SSteve Yin if (target == NULL) 1045fdc4257SSteve Yin return E_FAIL; 1055fdc4257SSteve Yin 1065fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = relation.TargetSet; 1075fdc4257SSteve Yin int nCount = xTargets.getLength(); 1085fdc4257SSteve Yin if( targetIndex >= nCount ) 1095fdc4257SSteve Yin return E_FAIL; 1105fdc4257SSteve Yin 1115fdc4257SSteve Yin Reference<XInterface> pRAcc = xTargets[targetIndex]; 1125fdc4257SSteve Yin IAccessible* pRet = NULL; 1135fdc4257SSteve Yin 1145fdc4257SSteve Yin BOOL isGet = CMAccessible::get_IAccessibleFromXAccessible((long)pRAcc.get(),&pRet); 1155fdc4257SSteve Yin if(isGet) 1165fdc4257SSteve Yin { 1175fdc4257SSteve Yin *target = /*(IAccessible2 *)*/(IUnknown*)pRet; 1185fdc4257SSteve Yin pRet->AddRef(); 1195fdc4257SSteve Yin return S_OK; 1205fdc4257SSteve Yin } 1215fdc4257SSteve Yin 1225fdc4257SSteve Yin return E_FAIL; 1235fdc4257SSteve Yin 1245fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1255fdc4257SSteve Yin } 1265fdc4257SSteve Yin 1275fdc4257SSteve Yin /** 1285fdc4257SSteve Yin * Get special targets. 1295fdc4257SSteve Yin * @param maxTargets Special targets count. 1305fdc4257SSteve Yin * @param target Variant to get special target. 1315fdc4257SSteve Yin * @param nTargets Variant to accept actual target length. 1325fdc4257SSteve Yin * @return Result. 1335fdc4257SSteve Yin */ 1345fdc4257SSteve Yin STDMETHODIMP CAccRelation::get_targets(long, IUnknown * * target, long * nTargets) 1355fdc4257SSteve Yin { 1365fdc4257SSteve Yin 1375fdc4257SSteve Yin CHECK_ENABLE_INF 1385fdc4257SSteve Yin 1395fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1405fdc4257SSteve Yin 1415fdc4257SSteve Yin // #CHECK# 1425fdc4257SSteve Yin if(target == NULL) 1435fdc4257SSteve Yin return E_INVALIDARG; 1445fdc4257SSteve Yin if (nTargets == NULL) 1455fdc4257SSteve Yin return E_INVALIDARG; 1465fdc4257SSteve Yin 1475fdc4257SSteve Yin Sequence< Reference< XInterface > > xTargets = relation.TargetSet; 1485fdc4257SSteve Yin int nCount = xTargets.getLength(); 1495fdc4257SSteve Yin 1505fdc4257SSteve Yin *target = (IUnknown*)::CoTaskMemAlloc(nCount*sizeof(IUnknown)); 1515fdc4257SSteve Yin 1525fdc4257SSteve Yin // #CHECK Memory Allocation# 1535fdc4257SSteve Yin if(*target == NULL) 1545fdc4257SSteve Yin { 1555fdc4257SSteve Yin return E_FAIL; 1565fdc4257SSteve Yin } 1575fdc4257SSteve Yin 1585fdc4257SSteve Yin for(int i=0; i<nCount ; i++) 1595fdc4257SSteve Yin { 1605fdc4257SSteve Yin IUnknown* pAcc = NULL; 1615fdc4257SSteve Yin HRESULT hr = get_target(i,&pAcc); 1625fdc4257SSteve Yin if(SUCCEEDED(hr)) 1635fdc4257SSteve Yin target[i] = pAcc; 1645fdc4257SSteve Yin } 1655fdc4257SSteve Yin 1665fdc4257SSteve Yin *nTargets = nCount; 1675fdc4257SSteve Yin return S_OK; 1685fdc4257SSteve Yin 1695fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1705fdc4257SSteve Yin } 1715fdc4257SSteve Yin 1725fdc4257SSteve Yin /** 1735fdc4257SSteve Yin * Put UNO interface. 1745fdc4257SSteve Yin * @param pXSubInterface AccessibleRelation pointer. 1755fdc4257SSteve Yin * @return Result. 1765fdc4257SSteve Yin */ 1775fdc4257SSteve Yin STDMETHODIMP CAccRelation::put_XSubInterface(long pXSubInterface) 1785fdc4257SSteve Yin { 1795fdc4257SSteve Yin 1805fdc4257SSteve Yin relation = *((AccessibleRelation*)pXSubInterface); 1815fdc4257SSteve Yin return S_OK; 1825fdc4257SSteve Yin } 1835fdc4257SSteve Yin 1845fdc4257SSteve Yin /** 1855fdc4257SSteve Yin * Get relation type string by type. 1865fdc4257SSteve Yin * @param type Relation type. 1875fdc4257SSteve Yin * @return relation type string. 1885fdc4257SSteve Yin */ 1895fdc4257SSteve Yin BSTR CAccRelation::getRelationTypeBSTR(int type) 1905fdc4257SSteve Yin { 1915fdc4257SSteve Yin static struct TYPE_BSTR_MAP 1925fdc4257SSteve Yin { 1935fdc4257SSteve Yin LPCTSTR string; 1945fdc4257SSteve Yin int type; 1955fdc4257SSteve Yin } 1965fdc4257SSteve Yin map[] = 1975fdc4257SSteve Yin { 1985fdc4257SSteve Yin {_T("INVALID") , 0}, 1995fdc4257SSteve Yin {IA2_RELATION_FLOWS_FROM , 1}, 2005fdc4257SSteve Yin {IA2_RELATION_FLOWS_TO , 2}, 2015fdc4257SSteve Yin {IA2_RELATION_CONTROLLED_BY , 3}, 2025fdc4257SSteve Yin {IA2_RELATION_CONTROLLER_FOR, 4}, 2035fdc4257SSteve Yin {IA2_RELATION_LABEL_FOR , 5}, 2045fdc4257SSteve Yin {IA2_RELATION_LABELED_BY , 6}, 2055fdc4257SSteve Yin {IA2_RELATION_MEMBER_OF , 7}, 2065fdc4257SSteve Yin {IA2_RELATION_SUBWINDOW_OF , 8}, 2075fdc4257SSteve Yin {IA2_RELATION_NODE_CHILD_OF, 9}, 2085fdc4257SSteve Yin {IA2_RELATION_DESCRIBED_BY , 10}, 2095fdc4257SSteve Yin }; 2105fdc4257SSteve Yin 2115fdc4257SSteve Yin USES_CONVERSION; 2125fdc4257SSteve Yin 2135fdc4257SSteve Yin return (type >= 0 && type <= 10) ? T2BSTR(map[type].string) : _T(""); 2145fdc4257SSteve Yin } 215