Bump for 3.6-28
[LibreOffice.git] / editeng / source / accessibility / AccessibleHyperlink.cxx
blob8248022e9a28b70d3f06036a55da3562f5f0fc52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <comphelper/accessiblekeybindinghelper.hxx>
34 #include "AccessibleHyperlink.hxx"
35 #include "editeng/unoedprx.hxx"
36 #include <editeng/flditem.hxx>
37 #include <vcl/keycodes.hxx>
39 using namespace ::com::sun::star;
42 //------------------------------------------------------------------------
44 // AccessibleHyperlink implementation
46 //------------------------------------------------------------------------
48 namespace accessibility
51 AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_uInt16 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const ::rtl::OUString& rD )
52 : rTA( r )
54 pFld = p;
55 nPara = nP;
56 nRealIdx = nR;
57 nStartIdx = nStt;
58 nEndIdx = nEnd;
59 aDescription = rD;
62 AccessibleHyperlink::~AccessibleHyperlink()
64 delete pFld;
67 // XAccessibleAction
68 sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
70 return isValid() ? 1 : 0;
73 sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
75 sal_Bool bRet = sal_False;
76 if ( isValid() && ( nIndex == 0 ) )
78 rTA.FieldClicked( *pFld, nPara, nRealIdx );
79 bRet = sal_True;
81 return bRet;
84 ::rtl::OUString SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
86 ::rtl::OUString aDesc;
88 if ( isValid() && ( nIndex == 0 ) )
89 aDesc = aDescription;
91 return aDesc;
94 uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
96 uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
98 if( isValid() && ( nIndex == 0 ) )
100 ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
101 xKeyBinding = pKeyBindingHelper;
103 awt::KeyStroke aKeyStroke;
104 aKeyStroke.Modifiers = 0;
105 aKeyStroke.KeyCode = KEY_RETURN;
106 aKeyStroke.KeyChar = 0;
107 aKeyStroke.KeyFunc = 0;
108 pKeyBindingHelper->AddKeyBinding( aKeyStroke );
111 return xKeyBinding;
114 // XAccessibleHyperlink
115 uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
117 return uno::Any();
120 uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
122 return uno::Any();
125 sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
127 return nStartIdx;
130 sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
132 return nEndIdx;
135 sal_Bool SAL_CALL AccessibleHyperlink::isValid( ) throw (uno::RuntimeException)
137 return rTA.IsValid();
140 } // end of namespace accessibility
142 //------------------------------------------------------------------------
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */