1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew 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