Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccHypertext.cxx
blob28d7525e2f8e8f06709195e9ff2261811d8e8072
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 .
20 #include "stdafx.h"
21 #include "AccHypertext.h"
22 #include "AccHyperLink.h"
23 #include "acccommon.h"
25 #if defined __clang__
26 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
28 #endif
29 #include <UAccCOM.h>
30 #if defined __clang__
31 #pragma clang diagnostic pop
32 #endif
34 #include <vcl/svapp.hxx>
37 using namespace com::sun::star::accessibility;
38 using namespace com::sun::star::uno;
41 /**
42 * Get special selection.
43 * @param startOffset Start selection offset.
44 * @param endOffset End selection offset.
45 * @param success Variant to accept the result of if the method call is successful.
46 * @return Result.
48 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::addSelection(long startOffset, long endOffset)
51 return CAccTextBase::get_addSelection(startOffset, endOffset);
55 /**
56 * Get special attributes.
57 * @param offset Offset.
58 * @param startOffset Variant to accept start offset.
59 * @param endOffset Variant to accept end offset.
60 * @param textAttributes Variant to accept attributes.
61 * @return Result.
63 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_attributes(long offset, long * startOffset, long * endOffset, BSTR * textAttributes)
66 return CAccTextBase::get_attributes(offset, startOffset, endOffset, textAttributes);
69 /**
70 * Get caret position.
71 * @param offset Variant to accept caret offset.
72 * @return Result.
74 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_caretOffset(long * offset)
77 return CAccTextBase::get_caretOffset(offset);
80 /**
81 * Get character extents.
82 * @param offset Offset.
83 * @param x Variant to accept x position.
84 * @param y Variant to accept y position.
85 * @param width Variant to accept width.
86 * @param Height Variant to accept height.
87 * @return Result.
89 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_characterExtents(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height)
92 return CAccTextBase::get_characterExtents(offset, coordType, x, y, width, height);
95 /**
96 * Get selections count.
97 * @param nSelections Variant to accept selections count.
98 * @return Result.
100 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_nSelections(long * nSelections)
103 return CAccTextBase::get_nSelections(nSelections);
107 * Get offset of some special point.
108 * @param x X position of one point.
109 * @param x Y position of one point.
110 * @param coordType Type.
111 * @param offset Variant to accept offset.
112 * @return Result.
114 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_offsetAtPoint(long x, long y, IA2CoordinateType coordType, long * offset)
116 return CAccTextBase::get_offsetAtPoint(x, y, coordType, offset);
120 * Get selection range.
121 * @param selection selection count.
122 * @param startOffset Variant to accept the start offset of special selection.
123 * @param endOffset Variant to accept the end offset of special selection.
124 * @return Result.
126 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_selection(long selection, long * startOffset, long * endOffset)
129 return CAccTextBase::get_selection(selection, startOffset, endOffset);
133 * Get special text.
134 * @param startOffset Start position of special range.
135 * @param endOffset End position of special range.
136 * @param text Variant to accept the text of special range.
137 * @return Result.
139 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_text(long startOffset, long endOffset, BSTR * text)
142 return CAccTextBase::get_text(startOffset, endOffset, text);
146 * Get special text before some position.
147 * @param offset Special position.
148 * @param boundaryType Boundary type.
149 * @param startOffset Variant to accept the start offset.
150 * @param endOffset Variant to accept the end offset.
151 * @param text Variant to accept the special text.
152 * @return Result.
154 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_textBeforeOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
157 return CAccTextBase::get_textBeforeOffset(offset, boundaryType,
158 startOffset, endOffset, text);
162 * Get special text after some position.
163 * @param offset Special position.
164 * @param boundaryType Boundary type.
165 * @param startOffset Variant to accept the start offset.
166 * @param endOffset Variant to accept the end offset.
167 * @param text Variant to accept the special text.
168 * @return Result.
170 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_textAfterOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
173 return CAccTextBase::get_textAfterOffset(offset, boundaryType,
174 startOffset, endOffset, text);
178 * Get special text at some position.
179 * @param offset Special position.
180 * @param boundaryType Boundary type.
181 * @param startOffset Variant to accept the start offset.
182 * @param endOffset Variant to accept the end offset.
183 * @param text Variant to accept the special text.
184 * @return Result.
186 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_textAtOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
189 return CAccTextBase::get_textAtOffset(offset, boundaryType,
190 startOffset, endOffset, text);
194 * Remove selection.
195 * @param selectionIndex Special selection index
196 * @param success Variant to accept the memthod called result.
197 * @return Result.
199 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::removeSelection(long selectionIndex)
202 return CAccTextBase::removeSelection(selectionIndex);
206 * Set caret position.
207 * @param offset Special position.
208 * @param success Variant to accept the memthod called result.
209 * @return Result.
211 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::setCaretOffset(long offset)
214 return CAccTextBase::setCaretOffset(offset);
218 * Set special selection.
219 * @param selectionIndex Special selection index.
220 * @param startOffset start position.
221 * @param endOffset end position.
222 * @param success Variant to accept the memthod called result.
223 * @return Result.
225 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::setSelection(long selectionIndex, long startOffset, long endOffset)
228 return CAccTextBase::setSelection(selectionIndex, startOffset,
229 endOffset);
233 * Get characters count.
234 * @param nCharacters Variant to accept the characters count.
235 * @return Result.
237 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_nCharacters(long * nCharacters)
240 return CAccTextBase::get_nCharacters(nCharacters);
243 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_newText( IA2TextSegment *newText)
245 return CAccTextBase::get_newText(newText);
248 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_oldText( IA2TextSegment *oldText)
250 return CAccTextBase::get_oldText(oldText);
254 * Scroll to special sub-string .
255 * @param startIndex Start index of sub string.
256 * @param endIndex End index of sub string.
257 * @return Result.
259 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::scrollSubstringToPoint(long startIndex, long endIndex,enum IA2CoordinateType coordinateType, long x, long y )
262 return CAccTextBase::scrollSubstringToPoint(startIndex, endIndex, coordinateType, x, y);
264 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::scrollSubstringTo(long startIndex, long endIndex,enum IA2ScrollType scrollType)
267 return CAccTextBase::scrollSubstringTo(startIndex, endIndex,scrollType);
271 * Get hyperlink count.
272 * @param hyperlinkCount Variant to accept hyperlink count.
273 * @return Result.
275 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_nHyperlinks(long *hyperlinkCount)
277 SolarMutexGuard g;
279 ENTER_PROTECTED_BLOCK
281 // #CHECK#
282 if(hyperlinkCount == nullptr)
283 return E_INVALIDARG;
284 // #CHECK XInterface#
285 if(!pHyperText.is())
287 return E_FAIL;
290 *hyperlinkCount = pHyperText->getHyperLinkCount();
291 return S_OK;
293 LEAVE_PROTECTED_BLOCK
297 * Get special hyperlink.
298 * @param index Special hyperlink index.
299 * @param hyperlink Variant to accept special hyperlink via index.
300 * @return Result.
302 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_hyperlink(long index,IAccessibleHyperlink **hyperlink)
304 SolarMutexGuard g;
306 ENTER_PROTECTED_BLOCK
308 // #CHECK#
309 if(hyperlink == nullptr)
310 return E_INVALIDARG;
311 // #CHECK XInterface#
312 if(!pHyperText.is())
314 return E_FAIL;
317 Reference<XAccessibleHyperlink> pRLink = pHyperText->getHyperLink(index);
318 if(!pRLink.is())
320 *hyperlink = nullptr;
321 return E_FAIL;
324 IAccessibleHyperlink* plink = nullptr;
325 HRESULT hr = createInstance<CAccHyperLink>(IID_IAccessibleHyperlink, &plink);
326 if( SUCCEEDED(hr) )
328 IUNOXWrapper* wrapper = nullptr;
329 plink->QueryInterface(IID_IUNOXWrapper, reinterpret_cast<void**>(&wrapper));
330 if(wrapper)
332 wrapper->put_XSubInterface(reinterpret_cast<hyper>(pRLink.get()));
333 wrapper->Release();
335 *hyperlink = plink;
336 return S_OK;
339 return E_FAIL;
341 LEAVE_PROTECTED_BLOCK
345 * Returns the index of the hyperlink that is associated with this character index.
346 * @param charIndex Special char index.
347 * @param hyperlinkIndex Variant to accept special hyperlink index.
348 * @return Result.
350 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::get_hyperlinkIndex(long charIndex, long *hyperlinkIndex)
352 SolarMutexGuard g;
354 ENTER_PROTECTED_BLOCK
356 // #CHECK#
357 if(hyperlinkIndex == nullptr)
358 return E_INVALIDARG;
359 // #CHECK XInterface#
360 if(!pHyperText.is())
362 return E_FAIL;
365 *hyperlinkIndex = pHyperText->getHyperLinkIndex(charIndex);
366 return S_OK;
368 LEAVE_PROTECTED_BLOCK
372 * Put UNO interface.
373 * @param pXInterface UNO interface.
374 * @return Result.
376 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHypertext::put_XInterface(hyper pXInterface)
378 // internal IUNOXWrapper - no mutex meeded
380 ENTER_PROTECTED_BLOCK
382 CAccTextBase::put_XInterface(pXInterface);
383 //special query.
384 if(pUNOInterface == nullptr)
385 return E_FAIL;
386 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
387 if( !pRContext.is() )
389 return E_FAIL;
391 Reference<XAccessibleHypertext> pRXI(pRContext,UNO_QUERY);
392 if( !pRXI.is() )
393 pHyperText = nullptr;
394 else
395 pHyperText = pRXI.get();
396 return S_OK;
398 LEAVE_PROTECTED_BLOCK
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */