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 "AccHyperLink.h" 255fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessible.hpp> 265fdc4257SSteve Yin #include <com/sun/star/accessibility/XAccessibleAction.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 using namespace com::sun::star::awt; 325fdc4257SSteve Yin 335fdc4257SSteve Yin /** 345fdc4257SSteve Yin * Returns the number of action. 355fdc4257SSteve Yin * 365fdc4257SSteve Yin * @param nActions the number of action. 375fdc4257SSteve Yin */ 385fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::nActions(/*[out,retval]*/long* nActions) 395fdc4257SSteve Yin { 405fdc4257SSteve Yin 415fdc4257SSteve Yin return CAccActionBase::nActions(nActions); 425fdc4257SSteve Yin } 435fdc4257SSteve Yin 445fdc4257SSteve Yin /** 455fdc4257SSteve Yin * Performs specified action on the object. 465fdc4257SSteve Yin * 475fdc4257SSteve Yin * @param actionIndex the index of action. 485fdc4257SSteve Yin */ 495fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::doAction(/* [in] */ long actionIndex) 505fdc4257SSteve Yin { 515fdc4257SSteve Yin 525fdc4257SSteve Yin return CAccActionBase::doAction(actionIndex); 535fdc4257SSteve Yin } 545fdc4257SSteve Yin 555fdc4257SSteve Yin /** 565fdc4257SSteve Yin * Gets description of specified action. 575fdc4257SSteve Yin * 585fdc4257SSteve Yin * @param actionIndex the index of action. 595fdc4257SSteve Yin * @param description the description string of the specified action. 605fdc4257SSteve Yin */ 615fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_description(long actionIndex,BSTR __RPC_FAR *description) 625fdc4257SSteve Yin { 635fdc4257SSteve Yin 645fdc4257SSteve Yin return CAccActionBase::get_description(actionIndex, description); 655fdc4257SSteve Yin } 665fdc4257SSteve Yin 675fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_name( long actionIndex, BSTR __RPC_FAR *name) 685fdc4257SSteve Yin { 695fdc4257SSteve Yin 705fdc4257SSteve Yin return CAccActionBase::get_name(actionIndex, name); 715fdc4257SSteve Yin } 725fdc4257SSteve Yin 735fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_localizedName( long actionIndex, BSTR __RPC_FAR *localizedName) 745fdc4257SSteve Yin { 755fdc4257SSteve Yin 765fdc4257SSteve Yin return CAccActionBase::get_name(actionIndex, localizedName); 775fdc4257SSteve Yin } 785fdc4257SSteve Yin 795fdc4257SSteve Yin /** 805fdc4257SSteve Yin * Returns key binding object (if any) associated with specified action 815fdc4257SSteve Yin * key binding is string. 825fdc4257SSteve Yin * e.g. "alt+d" (like IAccessible::get_accKeyboardShortcut). 835fdc4257SSteve Yin * 845fdc4257SSteve Yin * @param actionIndex the index of action. 855fdc4257SSteve Yin * @param nMaxBinding the max number of key binding. 865fdc4257SSteve Yin * @param keyBinding the key binding array. 875fdc4257SSteve Yin * @param nBinding the actual number of key binding returned. 885fdc4257SSteve Yin */ 895fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_keyBinding( 905fdc4257SSteve Yin /* [in] */ long actionIndex, 915fdc4257SSteve Yin /* [in] */ long nMaxBinding, 925fdc4257SSteve Yin /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding, 935fdc4257SSteve Yin /* [retval][out] */ long __RPC_FAR *nBinding) 945fdc4257SSteve Yin { 955fdc4257SSteve Yin 965fdc4257SSteve Yin return CAccActionBase::get_keyBinding(actionIndex, nMaxBinding, keyBinding, nBinding); 975fdc4257SSteve Yin } 985fdc4257SSteve Yin 995fdc4257SSteve Yin /** 1005fdc4257SSteve Yin * get an object 1015fdc4257SSteve Yin * @param 1025fdc4257SSteve Yin * @return Result. 1035fdc4257SSteve Yin */ 1045fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_anchor(/* [in] */ long index, 1055fdc4257SSteve Yin /* [retval][out] */ VARIANT __RPC_FAR *anchor) 1065fdc4257SSteve Yin { 1075fdc4257SSteve Yin 1085fdc4257SSteve Yin CHECK_ENABLE_INF 1095fdc4257SSteve Yin 1105fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1115fdc4257SSteve Yin 1125fdc4257SSteve Yin // #CHECK# 1135fdc4257SSteve Yin if(anchor == NULL) 1145fdc4257SSteve Yin { 1155fdc4257SSteve Yin return E_INVALIDARG; 1165fdc4257SSteve Yin } 1175fdc4257SSteve Yin // #CHECK XInterface# 1185fdc4257SSteve Yin if(!pRXLink.is()) 1195fdc4257SSteve Yin { 1205fdc4257SSteve Yin return E_FAIL; 1215fdc4257SSteve Yin } 1225fdc4257SSteve Yin // Get Any type value via pRXLink. 1235fdc4257SSteve Yin ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionAnchor(index); 1245fdc4257SSteve Yin // Convert Any to VARIANT. 1255fdc4257SSteve Yin CMAccessible::ConvertAnyToVariant(anyVal, anchor); 1265fdc4257SSteve Yin 1275fdc4257SSteve Yin return S_OK; 1285fdc4257SSteve Yin 1295fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1305fdc4257SSteve Yin } 1315fdc4257SSteve Yin 1325fdc4257SSteve Yin /** 1335fdc4257SSteve Yin * get an object 1345fdc4257SSteve Yin * @param 1355fdc4257SSteve Yin * @return Result. 1365fdc4257SSteve Yin */ 1375fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_anchorTarget(/* [in] */ long index, 1385fdc4257SSteve Yin /* [retval][out] */ VARIANT __RPC_FAR *anchorTarget) 1395fdc4257SSteve Yin { 1405fdc4257SSteve Yin 1415fdc4257SSteve Yin 1425fdc4257SSteve Yin CHECK_ENABLE_INF 1435fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1445fdc4257SSteve Yin 1455fdc4257SSteve Yin // #CHECK# 1465fdc4257SSteve Yin if(anchorTarget == NULL) 1475fdc4257SSteve Yin { 1485fdc4257SSteve Yin return E_INVALIDARG; 1495fdc4257SSteve Yin } 1505fdc4257SSteve Yin // #CHECK XInterface# 1515fdc4257SSteve Yin if(!pRXLink.is()) 1525fdc4257SSteve Yin { 1535fdc4257SSteve Yin return E_FAIL; 1545fdc4257SSteve Yin } 1555fdc4257SSteve Yin // Get Any type value via pRXLink. 1565fdc4257SSteve Yin ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionObject(index); 1575fdc4257SSteve Yin // Convert Any to VARIANT. 1585fdc4257SSteve Yin CMAccessible::ConvertAnyToVariant(anyVal, anchorTarget); 1595fdc4257SSteve Yin 1605fdc4257SSteve Yin return S_OK; 1615fdc4257SSteve Yin 1625fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1635fdc4257SSteve Yin } 1645fdc4257SSteve Yin 1655fdc4257SSteve Yin 1665fdc4257SSteve Yin /** 1675fdc4257SSteve Yin * Get start index. 1685fdc4257SSteve Yin * @param index Variant to get start index. 1695fdc4257SSteve Yin * @return Result. 1705fdc4257SSteve Yin */ 1715fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_startIndex(/* [retval][out] */ long __RPC_FAR *index) 1725fdc4257SSteve Yin { 1735fdc4257SSteve Yin 1745fdc4257SSteve Yin CHECK_ENABLE_INF 1755fdc4257SSteve Yin 1765fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 1775fdc4257SSteve Yin 1785fdc4257SSteve Yin // #CHECK# 1795fdc4257SSteve Yin if(index == NULL) 1805fdc4257SSteve Yin { 1815fdc4257SSteve Yin return E_INVALIDARG; 1825fdc4257SSteve Yin } 1835fdc4257SSteve Yin *index = GetXInterface()->getStartIndex(); 1845fdc4257SSteve Yin 1855fdc4257SSteve Yin return S_OK; 1865fdc4257SSteve Yin 1875fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 1885fdc4257SSteve Yin } 1895fdc4257SSteve Yin 1905fdc4257SSteve Yin /** 1915fdc4257SSteve Yin * Get start index. 1925fdc4257SSteve Yin * @param index Variant to get end index. 1935fdc4257SSteve Yin * @return Result. 1945fdc4257SSteve Yin */ 1955fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_endIndex(/* [retval][out] */ long __RPC_FAR *index) 1965fdc4257SSteve Yin { 1975fdc4257SSteve Yin 1985fdc4257SSteve Yin CHECK_ENABLE_INF 1995fdc4257SSteve Yin 2005fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2015fdc4257SSteve Yin 2025fdc4257SSteve Yin // #CHECK# 2035fdc4257SSteve Yin if(index == NULL) 2045fdc4257SSteve Yin { 2055fdc4257SSteve Yin return E_INVALIDARG; 2065fdc4257SSteve Yin } 2075fdc4257SSteve Yin // #CHECK XInterface# 2085fdc4257SSteve Yin if(!pRXLink.is()) 2095fdc4257SSteve Yin { 2105fdc4257SSteve Yin return E_FAIL; 2115fdc4257SSteve Yin } 2125fdc4257SSteve Yin *index = GetXInterface()->getEndIndex(); 2135fdc4257SSteve Yin 2145fdc4257SSteve Yin return S_OK; 2155fdc4257SSteve Yin 2165fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2175fdc4257SSteve Yin } 2185fdc4257SSteve Yin 2195fdc4257SSteve Yin /** 2205fdc4257SSteve Yin * Judge if the hyperlink is valid. 2215fdc4257SSteve Yin * @param valid Variant to get validity. 2225fdc4257SSteve Yin * @return Result. 2235fdc4257SSteve Yin */ 2245fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::get_valid(/* [retval][out] */ boolean __RPC_FAR *valid) 2255fdc4257SSteve Yin { 2265fdc4257SSteve Yin 2275fdc4257SSteve Yin CHECK_ENABLE_INF 2285fdc4257SSteve Yin 2295fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2305fdc4257SSteve Yin 2315fdc4257SSteve Yin // #CHECK# 2325fdc4257SSteve Yin if(valid == NULL) 2335fdc4257SSteve Yin { 2345fdc4257SSteve Yin return E_INVALIDARG; 2355fdc4257SSteve Yin } 2365fdc4257SSteve Yin // #CHECK XInterface# 2375fdc4257SSteve Yin if(!pRXLink.is()) 2385fdc4257SSteve Yin { 2395fdc4257SSteve Yin return E_FAIL; 2405fdc4257SSteve Yin } 2415fdc4257SSteve Yin *valid = GetXInterface()->isValid(); 2425fdc4257SSteve Yin 2435fdc4257SSteve Yin return S_OK; 2445fdc4257SSteve Yin 2455fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2465fdc4257SSteve Yin } 2475fdc4257SSteve Yin 2485fdc4257SSteve Yin /** 2495fdc4257SSteve Yin * Put UNO interface. 2505fdc4257SSteve Yin * @param pXInterface XAccessibleContext interface. 2515fdc4257SSteve Yin * @return Result. 2525fdc4257SSteve Yin */ 2535fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::put_XInterface(long pXInterface) 2545fdc4257SSteve Yin { 2555fdc4257SSteve Yin 2565fdc4257SSteve Yin CHECK_ENABLE_INF 2575fdc4257SSteve Yin 2585fdc4257SSteve Yin ENTER_PROTECTED_BLOCK 2595fdc4257SSteve Yin 2605fdc4257SSteve Yin CAccActionBase::put_XInterface(pXInterface); 2615fdc4257SSteve Yin //special query. 2625fdc4257SSteve Yin if(pUNOInterface != NULL) 2635fdc4257SSteve Yin { 2645fdc4257SSteve Yin Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 2655fdc4257SSteve Yin if( !pRContext.is() ) 2665fdc4257SSteve Yin { 2675fdc4257SSteve Yin return E_FAIL; 2685fdc4257SSteve Yin } 2695fdc4257SSteve Yin Reference<XAccessibleHyperlink> pRXI(pRContext,UNO_QUERY); 2705fdc4257SSteve Yin if( !pRXI.is() ) 2715fdc4257SSteve Yin { 2725fdc4257SSteve Yin pRXLink = NULL; 2735fdc4257SSteve Yin } 2745fdc4257SSteve Yin else 2755fdc4257SSteve Yin pRXLink = pRXI.get(); 2765fdc4257SSteve Yin } 2775fdc4257SSteve Yin return S_OK; 2785fdc4257SSteve Yin 2795fdc4257SSteve Yin LEAVE_PROTECTED_BLOCK 2805fdc4257SSteve Yin } 2815fdc4257SSteve Yin 2825fdc4257SSteve Yin /** 2835fdc4257SSteve Yin * Put UNO interface. 2845fdc4257SSteve Yin * @param pXSubInterface XAccessibleHyperlink interface. 2855fdc4257SSteve Yin * @return Result. 2865fdc4257SSteve Yin */ 2875fdc4257SSteve Yin STDMETHODIMP CAccHyperLink::put_XSubInterface(long pXSubInterface) 2885fdc4257SSteve Yin { 2895fdc4257SSteve Yin 2905fdc4257SSteve Yin CHECK_ENABLE_INF 2915fdc4257SSteve Yin 2925fdc4257SSteve Yin pRXLink = (XAccessibleHyperlink*)pXSubInterface; 2935fdc4257SSteve Yin pRXAct = (XAccessibleAction*)pXSubInterface; 2945fdc4257SSteve Yin 2955fdc4257SSteve Yin return S_OK; 2965fdc4257SSteve Yin } 297