1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5190118d0SAndrew Rist  * distributed with this work for additional information
6190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10190118d0SAndrew Rist  *
11190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12190118d0SAndrew Rist  *
13190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist  * software distributed under the License is distributed on an
15190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17190118d0SAndrew Rist  * specific language governing permissions and limitations
18190118d0SAndrew Rist  * under the License.
19190118d0SAndrew Rist  *
20190118d0SAndrew Rist  *************************************************************/
21190118d0SAndrew Rist 
22190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
29cdf0e10cSrcweir #include <comphelper/accessiblekeybindinghelper.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "AccessibleHyperlink.hxx"
32cdf0e10cSrcweir #include "editeng/unoedprx.hxx"
33cdf0e10cSrcweir #include <editeng/flditem.hxx>
34cdf0e10cSrcweir #include <vcl/keycodes.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //------------------------------------------------------------------------
40cdf0e10cSrcweir //
41cdf0e10cSrcweir // AccessibleHyperlink implementation
42cdf0e10cSrcweir //
43cdf0e10cSrcweir //------------------------------------------------------------------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace accessibility
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 
AccessibleHyperlink(SvxAccessibleTextAdapter & r,SvxFieldItem * p,sal_uInt32 nP,sal_uInt16 nR,sal_Int32 nStt,sal_Int32 nEnd,const::rtl::OUString & rD)48*7a980842SDamjanJovanovic     AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const ::rtl::OUString& rD )
49cdf0e10cSrcweir     : rTA( r )
50cdf0e10cSrcweir     {
51cdf0e10cSrcweir         pFld = p;
52cdf0e10cSrcweir         nPara = nP;
53cdf0e10cSrcweir         nRealIdx = nR;
54cdf0e10cSrcweir         nStartIdx = nStt;
55cdf0e10cSrcweir         nEndIdx = nEnd;
56cdf0e10cSrcweir         aDescription = rD;
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
~AccessibleHyperlink()59cdf0e10cSrcweir     AccessibleHyperlink::~AccessibleHyperlink()
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         delete pFld;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     // XAccessibleAction
getAccessibleActionCount()65cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir     	 return isValid() ? 1 : 0;
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
doAccessibleAction(sal_Int32 nIndex)70cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex  ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir     	sal_Bool bRet = sal_False;
73cdf0e10cSrcweir     	if ( isValid() && ( nIndex == 0 ) )
74cdf0e10cSrcweir     	{
75cdf0e10cSrcweir     	    rTA.FieldClicked( *pFld, nPara, nRealIdx );
76cdf0e10cSrcweir     	    bRet = sal_True;
77cdf0e10cSrcweir     	}
78cdf0e10cSrcweir     	return bRet;
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir 
getAccessibleActionDescription(sal_Int32 nIndex)81cdf0e10cSrcweir     ::rtl::OUString  SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir     	::rtl::OUString aDesc;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     	if ( isValid() && ( nIndex == 0 ) )
86cdf0e10cSrcweir     	    aDesc = aDescription;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     	return aDesc;
89cdf0e10cSrcweir     }
90cdf0e10cSrcweir 
getAccessibleActionKeyBinding(sal_Int32 nIndex)91cdf0e10cSrcweir     uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir     	uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     	if( isValid() && ( nIndex == 0 ) )
96cdf0e10cSrcweir     	{
97cdf0e10cSrcweir     		::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
98cdf0e10cSrcweir     		xKeyBinding = pKeyBindingHelper;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             awt::KeyStroke aKeyStroke;
101cdf0e10cSrcweir     		aKeyStroke.Modifiers = 0;
102cdf0e10cSrcweir     		aKeyStroke.KeyCode = KEY_RETURN;
103cdf0e10cSrcweir     		aKeyStroke.KeyChar = 0;
104cdf0e10cSrcweir     		aKeyStroke.KeyFunc = 0;
105cdf0e10cSrcweir     		pKeyBindingHelper->AddKeyBinding( aKeyStroke );
106cdf0e10cSrcweir     	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     	return xKeyBinding;
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     // XAccessibleHyperlink
getAccessibleActionAnchor(sal_Int32)112cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir     	return uno::Any();
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir 
getAccessibleActionObject(sal_Int32)117cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir     	return uno::Any();
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
getStartIndex()122cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir     	return nStartIdx;
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
getEndIndex()127cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir     	return nEndIdx;
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir 
isValid()132cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleHyperlink::isValid(  ) throw (uno::RuntimeException)
133cdf0e10cSrcweir     {
134cdf0e10cSrcweir     	return rTA.IsValid();
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir }  // end of namespace accessibility
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //------------------------------------------------------------------------
1409b8096d0SSteve Yin 
1419b8096d0SSteve Yin // MT IA2: Accessiblehyperlink.hxx from IA2 CWS - meanwhile we also introduced one in DEV300 (above)
1429b8096d0SSteve Yin // Keeping this for reference - we probably should get support for image maps in our implementation...
1439b8096d0SSteve Yin 
1449b8096d0SSteve Yin 
1459b8096d0SSteve Yin /*
1469b8096d0SSteve Yin 
1479b8096d0SSteve Yin class SVX_DLLPUBLIC SvxAccessibleHyperlink :
1489b8096d0SSteve Yin 		public ::cppu::WeakImplHelper1<
1499b8096d0SSteve Yin 		::com::sun::star::accessibility::XAccessibleHyperlink >
1509b8096d0SSteve Yin {
1519b8096d0SSteve Yin 	SvxURLField* mpField;
1529b8096d0SSteve Yin 	sal_Int32 nStartIdx;
1539b8096d0SSteve Yin 	sal_Int32 nEndIdx;
1549b8096d0SSteve Yin 
1559b8096d0SSteve Yin 	ImageMap* mpImageMap;
1569b8096d0SSteve Yin 	SdrObject* m_pShape;
1579b8096d0SSteve Yin 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >  shapeParent;
1589b8096d0SSteve Yin 
1599b8096d0SSteve Yin public:
1609b8096d0SSteve Yin 
1619b8096d0SSteve Yin 	SvxAccessibleHyperlink(){};
1629b8096d0SSteve Yin 	//SvxAccessibleHyperlink(::rtl::OUString name, const Imagemap* pImageMap);
1639b8096d0SSteve Yin 	SvxAccessibleHyperlink(const SvxURLField* p, sal_Int32 nStt, sal_Int32 nEnd);
1649b8096d0SSteve Yin 	SvxAccessibleHyperlink(SdrObject* p, ::accessibility::AccessibleShape* pAcc);
1659b8096d0SSteve Yin 	virtual ~SvxAccessibleHyperlink();
1669b8096d0SSteve Yin 	//void setImageMap(ImageMap* pMap);
1679b8096d0SSteve Yin 	//void setXAccessibleImage(::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > parent);
1689b8096d0SSteve Yin 	::rtl::OUString GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException);
1699b8096d0SSteve Yin 	sal_Bool IsValidHyperlink();
1709b8096d0SSteve Yin 
1719b8096d0SSteve Yin 	// XAccessibleAction
1729b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getAccessibleActionCount()
1739b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
1749b8096d0SSteve Yin     virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex )
1759b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
1769b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
1779b8096d0SSteve Yin     virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription(
1789b8096d0SSteve Yin 				sal_Int32 nIndex )
1799b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
1809b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
1819b8096d0SSteve Yin     virtual ::com::sun::star::uno::Reference<
1829b8096d0SSteve Yin 			::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
1839b8096d0SSteve Yin 		   	getAccessibleActionKeyBinding( sal_Int32 nIndex )
1849b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
1859b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
1869b8096d0SSteve Yin 
1879b8096d0SSteve Yin 	// XAccessibleHyperlink
1889b8096d0SSteve Yin     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionAnchor(
1899b8096d0SSteve Yin 				sal_Int32 nIndex )
1909b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
1919b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
1929b8096d0SSteve Yin     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionObject(
1939b8096d0SSteve Yin 			sal_Int32 nIndex )
1949b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
1959b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
1969b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getStartIndex()
1979b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
1989b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getEndIndex()
1999b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
2009b8096d0SSteve Yin     virtual sal_Bool SAL_CALL isValid(  )
2019b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
2029b8096d0SSteve Yin };
2039b8096d0SSteve Yin 
2049b8096d0SSteve Yin 
2059b8096d0SSteve Yin SvxAccessibleHyperlink::SvxAccessibleHyperlink( const SvxURLField *p,
2069b8096d0SSteve Yin 										  sal_Int32 nStt, sal_Int32 nEnd ) :
2079b8096d0SSteve Yin 	nStartIdx( nStt ),
2089b8096d0SSteve Yin 	nEndIdx( nEnd ),
2099b8096d0SSteve Yin 	m_pShape(NULL),
2109b8096d0SSteve Yin 	shapeParent(NULL)
2119b8096d0SSteve Yin {
2129b8096d0SSteve Yin 	if(p)
2139b8096d0SSteve Yin 		mpField = (SvxURLField*)p->Clone();
2149b8096d0SSteve Yin 	else
2159b8096d0SSteve Yin 		mpField = NULL;
2169b8096d0SSteve Yin }
2179b8096d0SSteve Yin 
2189b8096d0SSteve Yin SvxAccessibleHyperlink::SvxAccessibleHyperlink(SdrObject* p,
2199b8096d0SSteve Yin 											::accessibility::AccessibleShape* pAcc) :
2209b8096d0SSteve Yin 	nStartIdx( -1 ),
2219b8096d0SSteve Yin 	nEndIdx( -1 ),
2229b8096d0SSteve Yin 	mpField(NULL),
2239b8096d0SSteve Yin 	m_pShape(p)
2249b8096d0SSteve Yin {
2259b8096d0SSteve Yin 	mpImageMap = m_pShape->GetModel()->GetImageMapForObject(m_pShape);
2269b8096d0SSteve Yin 	shapeParent = dynamic_cast< XAccessible* >(pAcc);
2279b8096d0SSteve Yin }
2289b8096d0SSteve Yin 
2299b8096d0SSteve Yin SvxAccessibleHyperlink::~SvxAccessibleHyperlink()
2309b8096d0SSteve Yin {
2319b8096d0SSteve Yin 	if(mpField)
2329b8096d0SSteve Yin 		delete mpField;
2339b8096d0SSteve Yin }
2349b8096d0SSteve Yin 
2359b8096d0SSteve Yin ::rtl::OUString SvxAccessibleHyperlink::GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException)
2369b8096d0SSteve Yin {
2379b8096d0SSteve Yin 	if( mpField )
2389b8096d0SSteve Yin 	{
2399b8096d0SSteve Yin 		if (nIndex != 0)
2409b8096d0SSteve Yin 	        throw ::com::sun::star::lang::IndexOutOfBoundsException();
2419b8096d0SSteve Yin 		return ::rtl::OUString( mpField->GetURL() );
2429b8096d0SSteve Yin 	}
2439b8096d0SSteve Yin 	else if (mpImageMap)
2449b8096d0SSteve Yin 	{
2459b8096d0SSteve Yin 		if (nIndex < 0 || nIndex >=mpImageMap->GetIMapObjectCount())
2469b8096d0SSteve Yin 			throw IndexOutOfBoundsException();
2479b8096d0SSteve Yin 
2489b8096d0SSteve Yin 		IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
2499b8096d0SSteve Yin 		if (pMapObj->GetURL().Len())
2509b8096d0SSteve Yin 			return ::rtl::OUString( pMapObj->GetURL() );
2519b8096d0SSteve Yin 	}
2529b8096d0SSteve Yin 	else
2539b8096d0SSteve Yin 	{
2549b8096d0SSteve Yin 		if (nIndex != 0)
2559b8096d0SSteve Yin 	        throw ::com::sun::star::lang::IndexOutOfBoundsException();
2569b8096d0SSteve Yin 
2579b8096d0SSteve Yin 		SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( m_pShape );
2589b8096d0SSteve Yin 
2599b8096d0SSteve Yin 		if(pUnoCtrl)
2609b8096d0SSteve Yin 		{
2619b8096d0SSteve Yin 			try
2629b8096d0SSteve Yin 			{
2639b8096d0SSteve Yin 				uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
2649b8096d0SSteve Yin 				uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
2659b8096d0SSteve Yin 				uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
2669b8096d0SSteve Yin 
2679b8096d0SSteve Yin 				form::FormButtonType eButtonType = form::FormButtonType_URL;
2689b8096d0SSteve Yin 				const ::rtl::OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
2699b8096d0SSteve Yin 				if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
2709b8096d0SSteve Yin 				{
2719b8096d0SSteve Yin 					::rtl::OUString aString;
2729b8096d0SSteve Yin 
2739b8096d0SSteve Yin 					// URL
2749b8096d0SSteve Yin 					const ::rtl::OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
2759b8096d0SSteve Yin 					if(xPropInfo->hasPropertyByName(sTargetURL))
2769b8096d0SSteve Yin 					{
2779b8096d0SSteve Yin 						if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
2789b8096d0SSteve Yin 							return aString;
2799b8096d0SSteve Yin 					}
2809b8096d0SSteve Yin 				}
2819b8096d0SSteve Yin 			}
2829b8096d0SSteve Yin 			catch( uno::Exception& )
2839b8096d0SSteve Yin 			{
2849b8096d0SSteve Yin 			}
2859b8096d0SSteve Yin 		}
2869b8096d0SSteve Yin 		// If hyperlink can't be got from sdrobject, query the corresponding document to retrieve the link info
2879b8096d0SSteve Yin 		uno::Reference< XAccessibleGroupPosition > xGroupPosition (shapeParent, uno::UNO_QUERY);
2889b8096d0SSteve Yin 		if (xGroupPosition.is())
2899b8096d0SSteve Yin 			return xGroupPosition->getObjectLink( uno::makeAny( shapeParent ) );
2909b8096d0SSteve Yin 	}
2919b8096d0SSteve Yin 	return ::rtl::OUString();
2929b8096d0SSteve Yin }
2939b8096d0SSteve Yin 
2949b8096d0SSteve Yin // Just check whether the first hyperlink is valid
2959b8096d0SSteve Yin sal_Bool SvxAccessibleHyperlink::IsValidHyperlink()
2969b8096d0SSteve Yin {
2979b8096d0SSteve Yin 	::rtl::OUString url = GetHyperlinkURL(0);
2989b8096d0SSteve Yin 	if (url.getLength() > 0)
2999b8096d0SSteve Yin 		return sal_True;
3009b8096d0SSteve Yin 	else
3019b8096d0SSteve Yin 		return sal_False;
3029b8096d0SSteve Yin }
3039b8096d0SSteve Yin // XAccessibleAction
3049b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getAccessibleActionCount()
3059b8096d0SSteve Yin 		throw (RuntimeException)
3069b8096d0SSteve Yin {
3079b8096d0SSteve Yin 	if (mpImageMap)
3089b8096d0SSteve Yin 		return mpImageMap->GetIMapObjectCount();
3099b8096d0SSteve Yin 	else
3109b8096d0SSteve Yin 		return 1;	// only shape link or url field
3119b8096d0SSteve Yin 
3129b8096d0SSteve Yin 	//return mpField ? 1 : (mpImageMap ? mpImageMap->GetIMapObjectCount() : 0);
3139b8096d0SSteve Yin }
3149b8096d0SSteve Yin 
3159b8096d0SSteve Yin sal_Bool SAL_CALL SvxAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
3169b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
3179b8096d0SSteve Yin {
3189b8096d0SSteve Yin 	vos::OGuard aGuard(Application::GetSolarMutex());
3199b8096d0SSteve Yin 
3209b8096d0SSteve Yin 	sal_Bool bRet = sal_False;
3219b8096d0SSteve Yin 
3229b8096d0SSteve Yin 	OUString url = GetHyperlinkURL(nIndex);
3239b8096d0SSteve Yin 
3249b8096d0SSteve Yin 	if( url.getLength() > 0 )
3259b8096d0SSteve Yin 	{
3269b8096d0SSteve Yin 		SfxStringItem aStrItem(SID_FILE_NAME, url);
3279b8096d0SSteve Yin 		const SfxObjectShell* pDocSh = SfxObjectShell::Current();
3289b8096d0SSteve Yin 		if( pDocSh )
3299b8096d0SSteve Yin 		{
3309b8096d0SSteve Yin 			SfxMedium* pSfxMedium = pDocSh->GetMedium();
3319b8096d0SSteve Yin 			if( pSfxMedium)
3329b8096d0SSteve Yin 			{
3339b8096d0SSteve Yin 				SfxStringItem aReferer(SID_REFERER, pSfxMedium->GetName());
3349b8096d0SSteve Yin 				SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
3359b8096d0SSteve Yin 				SfxViewFrame* pFrame = SfxViewFrame::Current();
3369b8096d0SSteve Yin 				if( pFrame )
3379b8096d0SSteve Yin 				{
3389b8096d0SSteve Yin 					pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
3399b8096d0SSteve Yin 						    	&aStrItem, &aBrowseItem, &aReferer, 0L);
3409b8096d0SSteve Yin 					bRet = sal_True;
3419b8096d0SSteve Yin 				}
3429b8096d0SSteve Yin 			}
3439b8096d0SSteve Yin 		}
3449b8096d0SSteve Yin 	}
3459b8096d0SSteve Yin 
3469b8096d0SSteve Yin 	return bRet;
3479b8096d0SSteve Yin }
3489b8096d0SSteve Yin 
3499b8096d0SSteve Yin OUString SAL_CALL SvxAccessibleHyperlink::getAccessibleActionDescription(
3509b8096d0SSteve Yin 		sal_Int32 nIndex )
3519b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
3529b8096d0SSteve Yin {
3539b8096d0SSteve Yin 	return GetHyperlinkURL(nIndex);
3549b8096d0SSteve Yin }
3559b8096d0SSteve Yin 
3569b8096d0SSteve Yin ::com::sun::star::uno::Reference< XAccessibleKeyBinding > SAL_CALL
3579b8096d0SSteve Yin 	SvxAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 )
3589b8096d0SSteve Yin 	throw (IndexOutOfBoundsException, RuntimeException)
3599b8096d0SSteve Yin {
3609b8096d0SSteve Yin 	::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding;
3619b8096d0SSteve Yin 
3629b8096d0SSteve Yin 	if( mpField || m_pShape)
3639b8096d0SSteve Yin 	{
3649b8096d0SSteve Yin 		::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
3659b8096d0SSteve Yin 		   	new ::comphelper::OAccessibleKeyBindingHelper();
3669b8096d0SSteve Yin 		xKeyBinding = pKeyBindingHelper;
3679b8096d0SSteve Yin 
3689b8096d0SSteve Yin 		::com::sun::star::awt::KeyStroke aKeyStroke;
3699b8096d0SSteve Yin 		aKeyStroke.Modifiers = 0;
3709b8096d0SSteve Yin 		aKeyStroke.KeyCode = KEY_RETURN;
3719b8096d0SSteve Yin 		aKeyStroke.KeyChar = 0;
3729b8096d0SSteve Yin 		aKeyStroke.KeyFunc = 0;
3739b8096d0SSteve Yin 		pKeyBindingHelper->AddKeyBinding( aKeyStroke );
3749b8096d0SSteve Yin 	}
3759b8096d0SSteve Yin 
3769b8096d0SSteve Yin 	return xKeyBinding;
3779b8096d0SSteve Yin }
3789b8096d0SSteve Yin 
3799b8096d0SSteve Yin // XAccessibleHyperlink
3809b8096d0SSteve Yin Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionAnchor(
3819b8096d0SSteve Yin 		sal_Int32 nIndex )
3829b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
3839b8096d0SSteve Yin {
3849b8096d0SSteve Yin 	Any aRet;
3859b8096d0SSteve Yin 
3869b8096d0SSteve Yin 	::rtl::OUString retText;
3879b8096d0SSteve Yin 	if(mpField && nIndex == 0)
3889b8096d0SSteve Yin 	{
3899b8096d0SSteve Yin 		retText = mpField->GetRepresentation();
3909b8096d0SSteve Yin 		aRet <<= retText;
3919b8096d0SSteve Yin 		return aRet;
3929b8096d0SSteve Yin 	}
3939b8096d0SSteve Yin 	else if(mpImageMap)
3949b8096d0SSteve Yin 	{
3959b8096d0SSteve Yin 		IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
3969b8096d0SSteve Yin 		if(pMapObj && pMapObj->GetURL().Len())
3979b8096d0SSteve Yin 			aRet <<= shapeParent;
3989b8096d0SSteve Yin 			return aRet;
3999b8096d0SSteve Yin 	}
4009b8096d0SSteve Yin 	else if (nIndex == 0)
4019b8096d0SSteve Yin 	{
4029b8096d0SSteve Yin 		aRet <<= shapeParent;
4039b8096d0SSteve Yin 		return aRet;
4049b8096d0SSteve Yin 	}
4059b8096d0SSteve Yin 	return aRet;
4069b8096d0SSteve Yin }
4079b8096d0SSteve Yin 
4089b8096d0SSteve Yin Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionObject(
4099b8096d0SSteve Yin 			sal_Int32 nIndex )
4109b8096d0SSteve Yin 	throw (IndexOutOfBoundsException, RuntimeException)
4119b8096d0SSteve Yin {
4129b8096d0SSteve Yin 	::rtl::OUString retText = GetHyperlinkURL(nIndex);
4139b8096d0SSteve Yin 	Any aRet;
4149b8096d0SSteve Yin 	aRet <<= retText;
4159b8096d0SSteve Yin 	return aRet;
4169b8096d0SSteve Yin }
4179b8096d0SSteve Yin 
4189b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getStartIndex()
4199b8096d0SSteve Yin 		throw (RuntimeException)
4209b8096d0SSteve Yin {
4219b8096d0SSteve Yin 	return nStartIdx;
4229b8096d0SSteve Yin }
4239b8096d0SSteve Yin 
4249b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getEndIndex()
4259b8096d0SSteve Yin 		throw (RuntimeException)
4269b8096d0SSteve Yin {
4279b8096d0SSteve Yin 	return nEndIdx;
4289b8096d0SSteve Yin }
4299b8096d0SSteve Yin 
4309b8096d0SSteve Yin sal_Bool SAL_CALL SvxAccessibleHyperlink::isValid(  )
4319b8096d0SSteve Yin 		throw (RuntimeException)
4329b8096d0SSteve Yin {
4339b8096d0SSteve Yin 	vos::OGuard aGuard(Application::GetSolarMutex());
4349b8096d0SSteve Yin 	//return mpField ? sal_True: ( mpImageMap ? sal_True : sal_False );
4359b8096d0SSteve Yin 	if (mpField || m_pShape)
4369b8096d0SSteve Yin 		return sal_True;
4379b8096d0SSteve Yin 	else
4389b8096d0SSteve Yin 		return sal_False;
4399b8096d0SSteve Yin }
4409b8096d0SSteve Yin 
4419b8096d0SSteve Yin */
4429b8096d0SSteve Yin 
4439b8096d0SSteve Yin 
4449b8096d0SSteve Yin 
445