Bump version to 4.1-6
[LibreOffice.git] / editeng / source / accessibility / AccessibleHyperlink.cxx
blob0407c88b019cb6a94aa38a63e28f78c925c5f503
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/uno/Any.hxx>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <comphelper/accessiblekeybindinghelper.hxx>
25 #include "AccessibleHyperlink.hxx"
26 #include "editeng/unoedprx.hxx"
27 #include <editeng/flditem.hxx>
28 #include <vcl/keycodes.hxx>
30 using namespace ::com::sun::star;
33 //------------------------------------------------------------------------
35 // AccessibleHyperlink implementation
37 //------------------------------------------------------------------------
39 namespace accessibility
42 AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_Int32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD )
43 : rTA( r )
45 pFld = p;
46 nPara = nP;
47 nRealIdx = nR;
48 nStartIdx = nStt;
49 nEndIdx = nEnd;
50 aDescription = rD;
53 AccessibleHyperlink::~AccessibleHyperlink()
55 delete pFld;
58 // XAccessibleAction
59 sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException)
61 return isValid() ? 1 : 0;
64 sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
66 sal_Bool bRet = sal_False;
67 if ( isValid() && ( nIndex == 0 ) )
69 rTA.FieldClicked( *pFld, nPara, nRealIdx );
70 bRet = sal_True;
72 return bRet;
75 OUString SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
77 OUString aDesc;
79 if ( isValid() && ( nIndex == 0 ) )
80 aDesc = aDescription;
82 return aDesc;
85 uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
87 uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
89 if( isValid() && ( nIndex == 0 ) )
91 ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
92 xKeyBinding = pKeyBindingHelper;
94 awt::KeyStroke aKeyStroke;
95 aKeyStroke.Modifiers = 0;
96 aKeyStroke.KeyCode = KEY_RETURN;
97 aKeyStroke.KeyChar = 0;
98 aKeyStroke.KeyFunc = 0;
99 pKeyBindingHelper->AddKeyBinding( aKeyStroke );
102 return xKeyBinding;
105 // XAccessibleHyperlink
106 uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
108 return uno::Any();
111 uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
113 return uno::Any();
116 sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException)
118 return nStartIdx;
121 sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException)
123 return nEndIdx;
126 sal_Bool SAL_CALL AccessibleHyperlink::isValid( ) throw (uno::RuntimeException)
128 return rTA.IsValid();
131 } // end of namespace accessibility
133 //------------------------------------------------------------------------
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */