LibreOffice Module sw (master) 1
accnotexthyperlink.cxx
Go to the documentation of this file.
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#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
21
23#include <swurl.hxx>
24#include <vcl/svapp.hxx>
25#include <frmfmt.hxx>
26
28
29#include <fmturl.hxx>
30
31#include <vcl/imap.hxx>
32#include <vcl/imapobj.hxx>
33#include <vcl/keycodes.hxx>
34
35#include <accmap.hxx>
36
37using namespace css;
38using namespace css::lang;
39using namespace css::uno;
40using namespace css::accessibility;
41
43 mxFrame( p ),
44 mpFrame( aFrame )
45{
46}
47
48// XAccessibleAction
50{
52
54 ImageMap* pMap = aURL.GetMap();
55 if( pMap != nullptr )
56 {
57 return pMap->GetIMapObjectCount();
58 }
59 else if( !aURL.GetURL().isEmpty() )
60 {
61 return 1;
62 }
63
64 return 0;
65}
66
68{
69 SolarMutexGuard aGuard;
70
71 if(nIndex < 0 || nIndex >= getAccessibleActionCount())
72 throw lang::IndexOutOfBoundsException();
73
74 bool bRet = false;
76 ImageMap* pMap = aURL.GetMap();
77 if( pMap != nullptr )
78 {
79 IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
80 if (!pMapObj->GetURL().isEmpty())
81 {
82 SwViewShell *pVSh = mxFrame->GetShell();
83 if( pVSh )
84 {
85 LoadURL( *pVSh, pMapObj->GetURL(), LoadUrlFlags::NONE,
86 pMapObj->GetTarget() );
87 bRet = true;
88 }
89 }
90 }
91 else if (!aURL.GetURL().isEmpty())
92 {
93 SwViewShell *pVSh = mxFrame->GetShell();
94 if( pVSh )
95 {
96 LoadURL( *pVSh, aURL.GetURL(), LoadUrlFlags::NONE,
97 aURL.GetTargetFrameName() );
98 bRet = true;
99 }
100 }
101
102 return bRet;
103}
104
106 sal_Int32 nIndex )
107{
109
110 OUString sDesc;
111
112 if(nIndex < 0 || nIndex >= getAccessibleActionCount())
113 throw lang::IndexOutOfBoundsException();
114
116 ImageMap* pMap = aURL.GetMap();
117 if( pMap != nullptr )
118 {
119 IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
120 if (!pMapObj->GetDesc().isEmpty())
121 sDesc = pMapObj->GetDesc();
122 else if (!pMapObj->GetURL().isEmpty())
123 sDesc = pMapObj->GetURL();
124 }
125 else if( !aURL.GetURL().isEmpty() )
126 sDesc = aURL.GetName();
127
128 return sDesc;
129}
130
131Reference< XAccessibleKeyBinding > SAL_CALL
133{
135
136 Reference< XAccessibleKeyBinding > xKeyBinding;
137
138 if(nIndex < 0 || nIndex >= getAccessibleActionCount())
139 throw lang::IndexOutOfBoundsException();
140
141 bool bIsValid = false;
143 ImageMap* pMap = aURL.GetMap();
144 if( pMap != nullptr )
145 {
146 IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
147 if (!pMapObj->GetURL().isEmpty())
148 bIsValid = true;
149 }
150 else if (!aURL.GetURL().isEmpty())
151 bIsValid = true;
152
153 if(bIsValid)
154 {
156 new ::comphelper::OAccessibleKeyBindingHelper();
157 xKeyBinding = pKeyBindingHelper;
158
159 css::awt::KeyStroke aKeyStroke;
160 aKeyStroke.Modifiers = 0;
161 aKeyStroke.KeyCode = KEY_RETURN;
162 aKeyStroke.KeyChar = 0;
163 aKeyStroke.KeyFunc = 0;
164 pKeyBindingHelper->AddKeyBinding( aKeyStroke );
165 }
166
167 return xKeyBinding;
168}
169
170// XAccessibleHyperlink
172 sal_Int32 nIndex )
173{
175
176 if(nIndex < 0 || nIndex >= getAccessibleActionCount())
177 throw lang::IndexOutOfBoundsException();
178
179 Any aRet;
180 //SwFrame* pAnchor = static_cast<SwFlyFrame*>(mpFrame)->GetAnchor();
181 Reference< XAccessible > xAnchor = mxFrame->GetAccessibleMap()->GetContext(mpFrame);
182 //SwAccessibleNoTextFrame* pFrame = xFrame.get();
183 //Reference< XAccessible > xAnchor = (XAccessible*)pFrame;
184 aRet <<= xAnchor;
185 return aRet;
186}
187
189 sal_Int32 nIndex )
190{
192
193 if(nIndex < 0 || nIndex >= getAccessibleActionCount())
194 throw lang::IndexOutOfBoundsException();
195
197 OUString retText;
198 ImageMap* pMap = aURL.GetMap();
199 if( pMap != nullptr )
200 {
201 IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
202 if (!pMapObj->GetURL().isEmpty())
203 retText = pMapObj->GetURL();
204 }
205 else if ( !aURL.GetURL().isEmpty() )
206 retText = aURL.GetURL();
207
208 Any aRet;
209 aRet <<= retText;
210 return aRet;
211}
212
214{
215 return 0;
216}
217
219{
220 return 0;
221}
222
224{
226
228
229 if( aURL.GetMap() || !aURL.GetURL().isEmpty() )
230 return true;
231 return false;
232}
233
234/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetURL() const
const OUString & GetTarget() const
const OUString & GetDesc() const
IMapObject * GetIMapObject(size_t nPos) const
size_t GetIMapObjectCount() const
Base class of the Writer layout elements.
Definition: frame.hxx:315
URL aURL
virtual OUString GetURL() const override
sal_Int32 nIndex
void * p
constexpr sal_uInt16 KEY_RETURN
unsigned char sal_Bool
void LoadURL(SwViewShell &rVSh, const OUString &rURL, LoadUrlFlags nFilter, const OUString &rTargetFrameName)
Definition: wrtsh2.cxx:504