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 
48cdf0e10cSrcweir     AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 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 
59cdf0e10cSrcweir     AccessibleHyperlink::~AccessibleHyperlink()
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         delete pFld;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     // XAccessibleAction
65cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir     	 return isValid() ? 1 : 0;
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
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 
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 
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
112cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir     	return uno::Any();
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir     	return uno::Any();
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir     	return nStartIdx;
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir     	return nEndIdx;
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleHyperlink::isValid(  ) throw (uno::RuntimeException)
133cdf0e10cSrcweir     {
134cdf0e10cSrcweir     	return rTA.IsValid();
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir }  // end of namespace accessibility
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //------------------------------------------------------------------------
140*9b8096d0SSteve Yin 
141*9b8096d0SSteve Yin // MT IA2: Accessiblehyperlink.hxx from IA2 CWS - meanwhile we also introduced one in DEV300 (above)
142*9b8096d0SSteve Yin // Keeping this for reference - we probably should get support for image maps in our implementation...
143*9b8096d0SSteve Yin 
144*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
145*9b8096d0SSteve Yin 
146*9b8096d0SSteve Yin /*
147*9b8096d0SSteve Yin 
148*9b8096d0SSteve Yin class SVX_DLLPUBLIC SvxAccessibleHyperlink :
149*9b8096d0SSteve Yin 		public ::cppu::WeakImplHelper1<
150*9b8096d0SSteve Yin 		::com::sun::star::accessibility::XAccessibleHyperlink >
151*9b8096d0SSteve Yin {
152*9b8096d0SSteve Yin 	SvxURLField* mpField;
153*9b8096d0SSteve Yin 	sal_Int32 nStartIdx;
154*9b8096d0SSteve Yin 	sal_Int32 nEndIdx;
155*9b8096d0SSteve Yin 
156*9b8096d0SSteve Yin 	ImageMap* mpImageMap;
157*9b8096d0SSteve Yin 	SdrObject* m_pShape;
158*9b8096d0SSteve Yin 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >  shapeParent;
159*9b8096d0SSteve Yin 
160*9b8096d0SSteve Yin public:
161*9b8096d0SSteve Yin 
162*9b8096d0SSteve Yin 	SvxAccessibleHyperlink(){};
163*9b8096d0SSteve Yin 	//SvxAccessibleHyperlink(::rtl::OUString name, const Imagemap* pImageMap);
164*9b8096d0SSteve Yin 	SvxAccessibleHyperlink(const SvxURLField* p, sal_Int32 nStt, sal_Int32 nEnd);
165*9b8096d0SSteve Yin 	SvxAccessibleHyperlink(SdrObject* p, ::accessibility::AccessibleShape* pAcc);
166*9b8096d0SSteve Yin 	virtual ~SvxAccessibleHyperlink();
167*9b8096d0SSteve Yin 	//void setImageMap(ImageMap* pMap);
168*9b8096d0SSteve Yin 	//void setXAccessibleImage(::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > parent);
169*9b8096d0SSteve Yin 	::rtl::OUString GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException);
170*9b8096d0SSteve Yin 	sal_Bool IsValidHyperlink();
171*9b8096d0SSteve Yin 
172*9b8096d0SSteve Yin 	// XAccessibleAction
173*9b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getAccessibleActionCount()
174*9b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
175*9b8096d0SSteve Yin     virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex )
176*9b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
177*9b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
178*9b8096d0SSteve Yin     virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription(
179*9b8096d0SSteve Yin 				sal_Int32 nIndex )
180*9b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
181*9b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
182*9b8096d0SSteve Yin     virtual ::com::sun::star::uno::Reference<
183*9b8096d0SSteve Yin 			::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
184*9b8096d0SSteve Yin 		   	getAccessibleActionKeyBinding( sal_Int32 nIndex )
185*9b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
186*9b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
187*9b8096d0SSteve Yin 
188*9b8096d0SSteve Yin 	// XAccessibleHyperlink
189*9b8096d0SSteve Yin     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionAnchor(
190*9b8096d0SSteve Yin 				sal_Int32 nIndex )
191*9b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
192*9b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
193*9b8096d0SSteve Yin     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleActionObject(
194*9b8096d0SSteve Yin 			sal_Int32 nIndex )
195*9b8096d0SSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
196*9b8096d0SSteve Yin 				::com::sun::star::uno::RuntimeException);
197*9b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getStartIndex()
198*9b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
199*9b8096d0SSteve Yin     virtual sal_Int32 SAL_CALL getEndIndex()
200*9b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
201*9b8096d0SSteve Yin     virtual sal_Bool SAL_CALL isValid(  )
202*9b8096d0SSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
203*9b8096d0SSteve Yin };
204*9b8096d0SSteve Yin 
205*9b8096d0SSteve Yin 
206*9b8096d0SSteve Yin SvxAccessibleHyperlink::SvxAccessibleHyperlink( const SvxURLField *p,
207*9b8096d0SSteve Yin 										  sal_Int32 nStt, sal_Int32 nEnd ) :
208*9b8096d0SSteve Yin 	nStartIdx( nStt ),
209*9b8096d0SSteve Yin 	nEndIdx( nEnd ),
210*9b8096d0SSteve Yin 	m_pShape(NULL),
211*9b8096d0SSteve Yin 	shapeParent(NULL)
212*9b8096d0SSteve Yin {
213*9b8096d0SSteve Yin 	if(p)
214*9b8096d0SSteve Yin 		mpField = (SvxURLField*)p->Clone();
215*9b8096d0SSteve Yin 	else
216*9b8096d0SSteve Yin 		mpField = NULL;
217*9b8096d0SSteve Yin }
218*9b8096d0SSteve Yin 
219*9b8096d0SSteve Yin SvxAccessibleHyperlink::SvxAccessibleHyperlink(SdrObject* p,
220*9b8096d0SSteve Yin 											::accessibility::AccessibleShape* pAcc) :
221*9b8096d0SSteve Yin 	nStartIdx( -1 ),
222*9b8096d0SSteve Yin 	nEndIdx( -1 ),
223*9b8096d0SSteve Yin 	mpField(NULL),
224*9b8096d0SSteve Yin 	m_pShape(p)
225*9b8096d0SSteve Yin {
226*9b8096d0SSteve Yin 	mpImageMap = m_pShape->GetModel()->GetImageMapForObject(m_pShape);
227*9b8096d0SSteve Yin 	shapeParent = dynamic_cast< XAccessible* >(pAcc);
228*9b8096d0SSteve Yin }
229*9b8096d0SSteve Yin 
230*9b8096d0SSteve Yin SvxAccessibleHyperlink::~SvxAccessibleHyperlink()
231*9b8096d0SSteve Yin {
232*9b8096d0SSteve Yin 	if(mpField)
233*9b8096d0SSteve Yin 		delete mpField;
234*9b8096d0SSteve Yin }
235*9b8096d0SSteve Yin 
236*9b8096d0SSteve Yin ::rtl::OUString SvxAccessibleHyperlink::GetHyperlinkURL(sal_Int32 nIndex) throw (::com::sun::star::lang::IndexOutOfBoundsException)
237*9b8096d0SSteve Yin {
238*9b8096d0SSteve Yin 	if( mpField )
239*9b8096d0SSteve Yin 	{
240*9b8096d0SSteve Yin 		if (nIndex != 0)
241*9b8096d0SSteve Yin 	        throw ::com::sun::star::lang::IndexOutOfBoundsException();
242*9b8096d0SSteve Yin 		return ::rtl::OUString( mpField->GetURL() );
243*9b8096d0SSteve Yin 	}
244*9b8096d0SSteve Yin 	else if (mpImageMap)
245*9b8096d0SSteve Yin 	{
246*9b8096d0SSteve Yin 		if (nIndex < 0 || nIndex >=mpImageMap->GetIMapObjectCount())
247*9b8096d0SSteve Yin 			throw IndexOutOfBoundsException();
248*9b8096d0SSteve Yin 
249*9b8096d0SSteve Yin 		IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
250*9b8096d0SSteve Yin 		if (pMapObj->GetURL().Len())
251*9b8096d0SSteve Yin 			return ::rtl::OUString( pMapObj->GetURL() );
252*9b8096d0SSteve Yin 	}
253*9b8096d0SSteve Yin 	else
254*9b8096d0SSteve Yin 	{
255*9b8096d0SSteve Yin 		if (nIndex != 0)
256*9b8096d0SSteve Yin 	        throw ::com::sun::star::lang::IndexOutOfBoundsException();
257*9b8096d0SSteve Yin 
258*9b8096d0SSteve Yin 		SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( m_pShape );
259*9b8096d0SSteve Yin 
260*9b8096d0SSteve Yin 		if(pUnoCtrl)
261*9b8096d0SSteve Yin 		{
262*9b8096d0SSteve Yin 			try
263*9b8096d0SSteve Yin 			{
264*9b8096d0SSteve Yin 				uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
265*9b8096d0SSteve Yin 				uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
266*9b8096d0SSteve Yin 				uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
267*9b8096d0SSteve Yin 
268*9b8096d0SSteve Yin 				form::FormButtonType eButtonType = form::FormButtonType_URL;
269*9b8096d0SSteve Yin 				const ::rtl::OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
270*9b8096d0SSteve Yin 				if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
271*9b8096d0SSteve Yin 				{
272*9b8096d0SSteve Yin 					::rtl::OUString aString;
273*9b8096d0SSteve Yin 
274*9b8096d0SSteve Yin 					// URL
275*9b8096d0SSteve Yin 					const ::rtl::OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
276*9b8096d0SSteve Yin 					if(xPropInfo->hasPropertyByName(sTargetURL))
277*9b8096d0SSteve Yin 					{
278*9b8096d0SSteve Yin 						if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
279*9b8096d0SSteve Yin 							return aString;
280*9b8096d0SSteve Yin 					}
281*9b8096d0SSteve Yin 				}
282*9b8096d0SSteve Yin 			}
283*9b8096d0SSteve Yin 			catch( uno::Exception& )
284*9b8096d0SSteve Yin 			{
285*9b8096d0SSteve Yin 			}
286*9b8096d0SSteve Yin 		}
287*9b8096d0SSteve Yin 		// If hyperlink can't be got from sdrobject, query the corresponding document to retrieve the link info
288*9b8096d0SSteve Yin 		uno::Reference< XAccessibleGroupPosition > xGroupPosition (shapeParent, uno::UNO_QUERY);
289*9b8096d0SSteve Yin 		if (xGroupPosition.is())
290*9b8096d0SSteve Yin 			return xGroupPosition->getObjectLink( uno::makeAny( shapeParent ) );
291*9b8096d0SSteve Yin 	}
292*9b8096d0SSteve Yin 	return ::rtl::OUString();
293*9b8096d0SSteve Yin }
294*9b8096d0SSteve Yin 
295*9b8096d0SSteve Yin // Just check whether the first hyperlink is valid
296*9b8096d0SSteve Yin sal_Bool SvxAccessibleHyperlink::IsValidHyperlink()
297*9b8096d0SSteve Yin {
298*9b8096d0SSteve Yin 	::rtl::OUString url = GetHyperlinkURL(0);
299*9b8096d0SSteve Yin 	if (url.getLength() > 0)
300*9b8096d0SSteve Yin 		return sal_True;
301*9b8096d0SSteve Yin 	else
302*9b8096d0SSteve Yin 		return sal_False;
303*9b8096d0SSteve Yin }
304*9b8096d0SSteve Yin // XAccessibleAction
305*9b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getAccessibleActionCount()
306*9b8096d0SSteve Yin 		throw (RuntimeException)
307*9b8096d0SSteve Yin {
308*9b8096d0SSteve Yin 	if (mpImageMap)
309*9b8096d0SSteve Yin 		return mpImageMap->GetIMapObjectCount();
310*9b8096d0SSteve Yin 	else
311*9b8096d0SSteve Yin 		return 1;	// only shape link or url field
312*9b8096d0SSteve Yin 
313*9b8096d0SSteve Yin 	//return mpField ? 1 : (mpImageMap ? mpImageMap->GetIMapObjectCount() : 0);
314*9b8096d0SSteve Yin }
315*9b8096d0SSteve Yin 
316*9b8096d0SSteve Yin sal_Bool SAL_CALL SvxAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
317*9b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
318*9b8096d0SSteve Yin {
319*9b8096d0SSteve Yin 	vos::OGuard aGuard(Application::GetSolarMutex());
320*9b8096d0SSteve Yin 
321*9b8096d0SSteve Yin 	sal_Bool bRet = sal_False;
322*9b8096d0SSteve Yin 
323*9b8096d0SSteve Yin 	OUString url = GetHyperlinkURL(nIndex);
324*9b8096d0SSteve Yin 
325*9b8096d0SSteve Yin 	if( url.getLength() > 0 )
326*9b8096d0SSteve Yin 	{
327*9b8096d0SSteve Yin 		SfxStringItem aStrItem(SID_FILE_NAME, url);
328*9b8096d0SSteve Yin 		const SfxObjectShell* pDocSh = SfxObjectShell::Current();
329*9b8096d0SSteve Yin 		if( pDocSh )
330*9b8096d0SSteve Yin 		{
331*9b8096d0SSteve Yin 			SfxMedium* pSfxMedium = pDocSh->GetMedium();
332*9b8096d0SSteve Yin 			if( pSfxMedium)
333*9b8096d0SSteve Yin 			{
334*9b8096d0SSteve Yin 				SfxStringItem aReferer(SID_REFERER, pSfxMedium->GetName());
335*9b8096d0SSteve Yin 				SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
336*9b8096d0SSteve Yin 				SfxViewFrame* pFrame = SfxViewFrame::Current();
337*9b8096d0SSteve Yin 				if( pFrame )
338*9b8096d0SSteve Yin 				{
339*9b8096d0SSteve Yin 					pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
340*9b8096d0SSteve Yin 						    	&aStrItem, &aBrowseItem, &aReferer, 0L);
341*9b8096d0SSteve Yin 					bRet = sal_True;
342*9b8096d0SSteve Yin 				}
343*9b8096d0SSteve Yin 			}
344*9b8096d0SSteve Yin 		}
345*9b8096d0SSteve Yin 	}
346*9b8096d0SSteve Yin 
347*9b8096d0SSteve Yin 	return bRet;
348*9b8096d0SSteve Yin }
349*9b8096d0SSteve Yin 
350*9b8096d0SSteve Yin OUString SAL_CALL SvxAccessibleHyperlink::getAccessibleActionDescription(
351*9b8096d0SSteve Yin 		sal_Int32 nIndex )
352*9b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
353*9b8096d0SSteve Yin {
354*9b8096d0SSteve Yin 	return GetHyperlinkURL(nIndex);
355*9b8096d0SSteve Yin }
356*9b8096d0SSteve Yin 
357*9b8096d0SSteve Yin ::com::sun::star::uno::Reference< XAccessibleKeyBinding > SAL_CALL
358*9b8096d0SSteve Yin 	SvxAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 )
359*9b8096d0SSteve Yin 	throw (IndexOutOfBoundsException, RuntimeException)
360*9b8096d0SSteve Yin {
361*9b8096d0SSteve Yin 	::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding;
362*9b8096d0SSteve Yin 
363*9b8096d0SSteve Yin 	if( mpField || m_pShape)
364*9b8096d0SSteve Yin 	{
365*9b8096d0SSteve Yin 		::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
366*9b8096d0SSteve Yin 		   	new ::comphelper::OAccessibleKeyBindingHelper();
367*9b8096d0SSteve Yin 		xKeyBinding = pKeyBindingHelper;
368*9b8096d0SSteve Yin 
369*9b8096d0SSteve Yin 		::com::sun::star::awt::KeyStroke aKeyStroke;
370*9b8096d0SSteve Yin 		aKeyStroke.Modifiers = 0;
371*9b8096d0SSteve Yin 		aKeyStroke.KeyCode = KEY_RETURN;
372*9b8096d0SSteve Yin 		aKeyStroke.KeyChar = 0;
373*9b8096d0SSteve Yin 		aKeyStroke.KeyFunc = 0;
374*9b8096d0SSteve Yin 		pKeyBindingHelper->AddKeyBinding( aKeyStroke );
375*9b8096d0SSteve Yin 	}
376*9b8096d0SSteve Yin 
377*9b8096d0SSteve Yin 	return xKeyBinding;
378*9b8096d0SSteve Yin }
379*9b8096d0SSteve Yin 
380*9b8096d0SSteve Yin // XAccessibleHyperlink
381*9b8096d0SSteve Yin Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionAnchor(
382*9b8096d0SSteve Yin 		sal_Int32 nIndex )
383*9b8096d0SSteve Yin 		throw (IndexOutOfBoundsException, RuntimeException)
384*9b8096d0SSteve Yin {
385*9b8096d0SSteve Yin 	Any aRet;
386*9b8096d0SSteve Yin 
387*9b8096d0SSteve Yin 	::rtl::OUString retText;
388*9b8096d0SSteve Yin 	if(mpField && nIndex == 0)
389*9b8096d0SSteve Yin 	{
390*9b8096d0SSteve Yin 		retText = mpField->GetRepresentation();
391*9b8096d0SSteve Yin 		aRet <<= retText;
392*9b8096d0SSteve Yin 		return aRet;
393*9b8096d0SSteve Yin 	}
394*9b8096d0SSteve Yin 	else if(mpImageMap)
395*9b8096d0SSteve Yin 	{
396*9b8096d0SSteve Yin 		IMapObject* pMapObj = mpImageMap->GetIMapObject(sal_uInt16(nIndex));
397*9b8096d0SSteve Yin 		if(pMapObj && pMapObj->GetURL().Len())
398*9b8096d0SSteve Yin 			aRet <<= shapeParent;
399*9b8096d0SSteve Yin 			return aRet;
400*9b8096d0SSteve Yin 	}
401*9b8096d0SSteve Yin 	else if (nIndex == 0)
402*9b8096d0SSteve Yin 	{
403*9b8096d0SSteve Yin 		aRet <<= shapeParent;
404*9b8096d0SSteve Yin 		return aRet;
405*9b8096d0SSteve Yin 	}
406*9b8096d0SSteve Yin 	return aRet;
407*9b8096d0SSteve Yin }
408*9b8096d0SSteve Yin 
409*9b8096d0SSteve Yin Any SAL_CALL SvxAccessibleHyperlink::getAccessibleActionObject(
410*9b8096d0SSteve Yin 			sal_Int32 nIndex )
411*9b8096d0SSteve Yin 	throw (IndexOutOfBoundsException, RuntimeException)
412*9b8096d0SSteve Yin {
413*9b8096d0SSteve Yin 	::rtl::OUString retText = GetHyperlinkURL(nIndex);
414*9b8096d0SSteve Yin 	Any aRet;
415*9b8096d0SSteve Yin 	aRet <<= retText;
416*9b8096d0SSteve Yin 	return aRet;
417*9b8096d0SSteve Yin }
418*9b8096d0SSteve Yin 
419*9b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getStartIndex()
420*9b8096d0SSteve Yin 		throw (RuntimeException)
421*9b8096d0SSteve Yin {
422*9b8096d0SSteve Yin 	return nStartIdx;
423*9b8096d0SSteve Yin }
424*9b8096d0SSteve Yin 
425*9b8096d0SSteve Yin sal_Int32 SAL_CALL SvxAccessibleHyperlink::getEndIndex()
426*9b8096d0SSteve Yin 		throw (RuntimeException)
427*9b8096d0SSteve Yin {
428*9b8096d0SSteve Yin 	return nEndIdx;
429*9b8096d0SSteve Yin }
430*9b8096d0SSteve Yin 
431*9b8096d0SSteve Yin sal_Bool SAL_CALL SvxAccessibleHyperlink::isValid(  )
432*9b8096d0SSteve Yin 		throw (RuntimeException)
433*9b8096d0SSteve Yin {
434*9b8096d0SSteve Yin 	vos::OGuard aGuard(Application::GetSolarMutex());
435*9b8096d0SSteve Yin 	//return mpField ? sal_True: ( mpImageMap ? sal_True : sal_False );
436*9b8096d0SSteve Yin 	if (mpField || m_pShape)
437*9b8096d0SSteve Yin 		return sal_True;
438*9b8096d0SSteve Yin 	else
439*9b8096d0SSteve Yin 		return sal_False;
440*9b8096d0SSteve Yin }
441*9b8096d0SSteve Yin 
442*9b8096d0SSteve Yin */
443*9b8096d0SSteve Yin 
444*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
445*9b8096d0SSteve Yin 
446*9b8096d0SSteve Yin 
447