xref: /AOO41X/main/editeng/source/accessibility/AccessibleHyperlink.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2008 by Sun Microsystems, Inc.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * $RCSfile: AccessibleEditableTextPara.cxx,v $
10*cdf0e10cSrcweir  * $Revision: 1.53 $
11*cdf0e10cSrcweir  *
12*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
13*cdf0e10cSrcweir  *
14*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
15*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
16*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
17*cdf0e10cSrcweir  *
18*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
19*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
22*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
23*cdf0e10cSrcweir  *
24*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
25*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
26*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
27*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
28*cdf0e10cSrcweir  *
29*cdf0e10cSrcweir  ************************************************************************/
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
32*cdf0e10cSrcweir #include "precompiled_editeng.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
36*cdf0e10cSrcweir #include <comphelper/accessiblekeybindinghelper.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "AccessibleHyperlink.hxx"
39*cdf0e10cSrcweir #include "editeng/unoedprx.hxx"
40*cdf0e10cSrcweir #include <editeng/flditem.hxx>
41*cdf0e10cSrcweir #include <vcl/keycodes.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using namespace ::com::sun::star;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //------------------------------------------------------------------------
47*cdf0e10cSrcweir //
48*cdf0e10cSrcweir // AccessibleHyperlink implementation
49*cdf0e10cSrcweir //
50*cdf0e10cSrcweir //------------------------------------------------------------------------
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace accessibility
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir     AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const ::rtl::OUString& rD )
56*cdf0e10cSrcweir     : rTA( r )
57*cdf0e10cSrcweir     {
58*cdf0e10cSrcweir         pFld = p;
59*cdf0e10cSrcweir         nPara = nP;
60*cdf0e10cSrcweir         nRealIdx = nR;
61*cdf0e10cSrcweir         nStartIdx = nStt;
62*cdf0e10cSrcweir         nEndIdx = nEnd;
63*cdf0e10cSrcweir         aDescription = rD;
64*cdf0e10cSrcweir     }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     AccessibleHyperlink::~AccessibleHyperlink()
67*cdf0e10cSrcweir     {
68*cdf0e10cSrcweir         delete pFld;
69*cdf0e10cSrcweir     }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     // XAccessibleAction
72*cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
73*cdf0e10cSrcweir     {
74*cdf0e10cSrcweir     	 return isValid() ? 1 : 0;
75*cdf0e10cSrcweir     }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex  ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
78*cdf0e10cSrcweir     {
79*cdf0e10cSrcweir     	sal_Bool bRet = sal_False;
80*cdf0e10cSrcweir     	if ( isValid() && ( nIndex == 0 ) )
81*cdf0e10cSrcweir     	{
82*cdf0e10cSrcweir     	    rTA.FieldClicked( *pFld, nPara, nRealIdx );
83*cdf0e10cSrcweir     	    bRet = sal_True;
84*cdf0e10cSrcweir     	}
85*cdf0e10cSrcweir     	return bRet;
86*cdf0e10cSrcweir     }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     ::rtl::OUString  SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
89*cdf0e10cSrcweir     {
90*cdf0e10cSrcweir     	::rtl::OUString aDesc;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     	if ( isValid() && ( nIndex == 0 ) )
93*cdf0e10cSrcweir     	    aDesc = aDescription;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     	return aDesc;
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir     	uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     	if( isValid() && ( nIndex == 0 ) )
103*cdf0e10cSrcweir     	{
104*cdf0e10cSrcweir     		::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
105*cdf0e10cSrcweir     		xKeyBinding = pKeyBindingHelper;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir             awt::KeyStroke aKeyStroke;
108*cdf0e10cSrcweir     		aKeyStroke.Modifiers = 0;
109*cdf0e10cSrcweir     		aKeyStroke.KeyCode = KEY_RETURN;
110*cdf0e10cSrcweir     		aKeyStroke.KeyChar = 0;
111*cdf0e10cSrcweir     		aKeyStroke.KeyFunc = 0;
112*cdf0e10cSrcweir     		pKeyBindingHelper->AddKeyBinding( aKeyStroke );
113*cdf0e10cSrcweir     	}
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     	return xKeyBinding;
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     // XAccessibleHyperlink
119*cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
120*cdf0e10cSrcweir     {
121*cdf0e10cSrcweir     	return uno::Any();
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
125*cdf0e10cSrcweir     {
126*cdf0e10cSrcweir     	return uno::Any();
127*cdf0e10cSrcweir     }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
130*cdf0e10cSrcweir     {
131*cdf0e10cSrcweir     	return nStartIdx;
132*cdf0e10cSrcweir     }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir     	return nEndIdx;
137*cdf0e10cSrcweir     }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleHyperlink::isValid(  ) throw (uno::RuntimeException)
140*cdf0e10cSrcweir     {
141*cdf0e10cSrcweir     	return rTA.IsValid();
142*cdf0e10cSrcweir     }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir }  // end of namespace accessibility
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir //------------------------------------------------------------------------
147