Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <com/sun/star/uno/Any.hxx>
22 : #include <com/sun/star/uno/Reference.hxx>
23 : #include <comphelper/accessiblekeybindinghelper.hxx>
24 :
25 : #include "AccessibleHyperlink.hxx"
26 : #include "editeng/unoedprx.hxx"
27 : #include <editeng/flditem.hxx>
28 : #include <vcl/keycodes.hxx>
29 :
30 : using namespace ::com::sun::star;
31 :
32 :
33 :
34 :
35 : // AccessibleHyperlink implementation
36 :
37 :
38 :
39 : namespace accessibility
40 : {
41 :
42 0 : AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_Int32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD )
43 0 : : rTA( r )
44 : {
45 0 : pFld = p;
46 0 : nPara = nP;
47 0 : nRealIdx = nR;
48 0 : nStartIdx = nStt;
49 0 : nEndIdx = nEnd;
50 0 : aDescription = rD;
51 0 : }
52 :
53 0 : AccessibleHyperlink::~AccessibleHyperlink()
54 : {
55 0 : delete pFld;
56 0 : }
57 :
58 : // XAccessibleAction
59 0 : sal_Int32 SAL_CALL AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException, std::exception)
60 : {
61 0 : return isValid() ? 1 : 0;
62 : }
63 :
64 0 : sal_Bool SAL_CALL AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
65 : {
66 0 : sal_Bool bRet = sal_False;
67 0 : if ( isValid() && ( nIndex == 0 ) )
68 : {
69 0 : rTA.FieldClicked( *pFld, nPara, nRealIdx );
70 0 : bRet = sal_True;
71 : }
72 0 : return bRet;
73 : }
74 :
75 0 : OUString SAL_CALL AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
76 : {
77 0 : OUString aDesc;
78 :
79 0 : if ( isValid() && ( nIndex == 0 ) )
80 0 : aDesc = aDescription;
81 :
82 0 : return aDesc;
83 : }
84 :
85 0 : uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
86 : {
87 0 : uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > xKeyBinding;
88 :
89 0 : if( isValid() && ( nIndex == 0 ) )
90 : {
91 0 : ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
92 0 : xKeyBinding = pKeyBindingHelper;
93 :
94 0 : awt::KeyStroke aKeyStroke;
95 0 : aKeyStroke.Modifiers = 0;
96 0 : aKeyStroke.KeyCode = KEY_RETURN;
97 0 : aKeyStroke.KeyChar = 0;
98 0 : aKeyStroke.KeyFunc = 0;
99 0 : pKeyBindingHelper->AddKeyBinding( aKeyStroke );
100 : }
101 :
102 0 : return xKeyBinding;
103 : }
104 :
105 : // XAccessibleHyperlink
106 0 : uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
107 : {
108 0 : return uno::Any();
109 : }
110 :
111 0 : uno::Any SAL_CALL AccessibleHyperlink::getAccessibleActionObject( sal_Int32 /*nIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
112 : {
113 0 : return uno::Any();
114 : }
115 :
116 0 : sal_Int32 SAL_CALL AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException, std::exception)
117 : {
118 0 : return nStartIdx;
119 : }
120 :
121 0 : sal_Int32 SAL_CALL AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException, std::exception)
122 : {
123 0 : return nEndIdx;
124 : }
125 :
126 0 : sal_Bool SAL_CALL AccessibleHyperlink::isValid( ) throw (uno::RuntimeException, std::exception)
127 : {
128 0 : return rTA.IsValid();
129 : }
130 :
131 : } // end of namespace accessibility
132 :
133 :
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|