1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "AccHypertext.h"
23 #include "AccHyperLink.h"
24 #include "acccommon.h"
26 #include <vcl/svapp.hxx>
29 using namespace com::sun::star::accessibility
;
30 using namespace com::sun::star::uno
;
34 * Get special selection.
35 * @param startOffset Start selection offset.
36 * @param endOffset End selection offset.
37 * @param success Variant to accept the result of if the method call is successful.
40 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::addSelection(long startOffset
, long endOffset
)
43 return CAccTextBase::get_addSelection(startOffset
, endOffset
);
48 * Get special attributes.
49 * @param offset Offset.
50 * @param startOffset Variant to accept start offset.
51 * @param endOffset Variant to accept end offset.
52 * @param textAttributes Variant to accept attributes.
55 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_attributes(long offset
, long * startOffset
, long * endOffset
, BSTR
* textAttributes
)
58 return CAccTextBase::get_attributes(offset
, startOffset
, endOffset
, textAttributes
);
63 * @param offset Variant to accept caret offset.
66 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_caretOffset(long * offset
)
69 return CAccTextBase::get_caretOffset(offset
);
73 * Get character extents.
74 * @param offset Offset.
75 * @param x Variant to accept x position.
76 * @param y Variant to accept y position.
77 * @param width Variant to accept width.
78 * @param Height Variant to accept height.
81 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_characterExtents(long offset
, IA2CoordinateType coordType
, long * x
, long * y
, long * width
, long * height
)
84 return CAccTextBase::get_characterExtents(offset
, coordType
, x
, y
, width
, height
);
88 * Get selections count.
89 * @param nSelections Variant to accept selections count.
92 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_nSelections(long * nSelections
)
95 return CAccTextBase::get_nSelections(nSelections
);
99 * Get offset of some special point.
100 * @param x X position of one point.
101 * @param x Y position of one point.
102 * @param coordType Type.
103 * @param offset Variant to accept offset.
106 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_offsetAtPoint(long x
, long y
, IA2CoordinateType coordType
, long * offset
)
108 return CAccTextBase::get_offsetAtPoint(x
, y
, coordType
, offset
);
112 * Get selection range.
113 * @param selection selection count.
114 * @param startOffset Variant to accept the start offset of special selection.
115 * @param endOffset Variant to accept the end offset of special selection.
118 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_selection(long selection
, long * startOffset
, long * endOffset
)
121 return CAccTextBase::get_selection(selection
, startOffset
, endOffset
);
126 * @param startOffset Start position of special range.
127 * @param endOffset End position of special range.
128 * @param text Variant to accept the text of special range.
131 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_text(long startOffset
, long endOffset
, BSTR
* text
)
134 return CAccTextBase::get_text(startOffset
, endOffset
, text
);
138 * Get special text before some position.
139 * @param offset Special position.
140 * @param boundaryType Boundary type.
141 * @param startOffset Variant to accept the start offset.
142 * @param endOffset Variant to accept the end offset.
143 * @param text Variant to accept the special text.
146 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_textBeforeOffset(long offset
, IA2TextBoundaryType boundaryType
, long * startOffset
, long * endOffset
, BSTR
* text
)
149 return CAccTextBase::get_textBeforeOffset(offset
, boundaryType
,
150 startOffset
, endOffset
, text
);
154 * Get special text after some position.
155 * @param offset Special position.
156 * @param boundaryType Boundary type.
157 * @param startOffset Variant to accept the start offset.
158 * @param endOffset Variant to accept the end offset.
159 * @param text Variant to accept the special text.
162 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_textAfterOffset(long offset
, IA2TextBoundaryType boundaryType
, long * startOffset
, long * endOffset
, BSTR
* text
)
165 return CAccTextBase::get_textAfterOffset(offset
, boundaryType
,
166 startOffset
, endOffset
, text
);
170 * Get special text at some position.
171 * @param offset Special position.
172 * @param boundaryType Boundary type.
173 * @param startOffset Variant to accept the start offset.
174 * @param endOffset Variant to accept the end offset.
175 * @param text Variant to accept the special text.
178 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_textAtOffset(long offset
, IA2TextBoundaryType boundaryType
, long * startOffset
, long * endOffset
, BSTR
* text
)
181 return CAccTextBase::get_textAtOffset(offset
, boundaryType
,
182 startOffset
, endOffset
, text
);
187 * @param selectionIndex Special selection index
188 * @param success Variant to accept the method called result.
191 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::removeSelection(long selectionIndex
)
194 return CAccTextBase::removeSelection(selectionIndex
);
198 * Set caret position.
199 * @param offset Special position.
200 * @param success Variant to accept the method called result.
203 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::setCaretOffset(long offset
)
206 return CAccTextBase::setCaretOffset(offset
);
210 * Set special selection.
211 * @param selectionIndex Special selection index.
212 * @param startOffset start position.
213 * @param endOffset end position.
214 * @param success Variant to accept the method called result.
217 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::setSelection(long selectionIndex
, long startOffset
, long endOffset
)
220 return CAccTextBase::setSelection(selectionIndex
, startOffset
,
225 * Get characters count.
226 * @param nCharacters Variant to accept the characters count.
229 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_nCharacters(long * nCharacters
)
232 return CAccTextBase::get_nCharacters(nCharacters
);
235 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_newText( IA2TextSegment
*newText
)
237 return CAccTextBase::get_newText(newText
);
240 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_oldText( IA2TextSegment
*oldText
)
242 return CAccTextBase::get_oldText(oldText
);
246 * Scroll to special sub-string .
247 * @param startIndex Start index of sub string.
248 * @param endIndex End index of sub string.
251 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::scrollSubstringToPoint(long startIndex
, long endIndex
,enum IA2CoordinateType coordinateType
, long x
, long y
)
254 return CAccTextBase::scrollSubstringToPoint(startIndex
, endIndex
, coordinateType
, x
, y
);
256 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::scrollSubstringTo(long startIndex
, long endIndex
,enum IA2ScrollType scrollType
)
259 return CAccTextBase::scrollSubstringTo(startIndex
, endIndex
,scrollType
);
263 * Get hyperlink count.
264 * @param hyperlinkCount Variant to accept hyperlink count.
267 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_nHyperlinks(long *hyperlinkCount
)
273 if(hyperlinkCount
== nullptr)
281 *hyperlinkCount
= pHyperText
->getHyperLinkCount();
284 } catch(...) { return E_FAIL
; }
288 * Get special hyperlink.
289 * @param index Special hyperlink index.
290 * @param hyperlink Variant to accept special hyperlink via index.
293 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_hyperlink(long index
,IAccessibleHyperlink
**hyperlink
)
299 if(hyperlink
== nullptr)
307 Reference
<XAccessibleHyperlink
> pRLink
= pHyperText
->getHyperLink(index
);
310 *hyperlink
= nullptr;
314 IAccessibleHyperlink
* plink
= nullptr;
315 HRESULT hr
= createInstance
<CAccHyperLink
>(IID_IAccessibleHyperlink
, &plink
);
318 IUNOXWrapper
* wrapper
= nullptr;
319 plink
->QueryInterface(IID_IUNOXWrapper
, reinterpret_cast<void**>(&wrapper
));
322 wrapper
->put_XSubInterface(reinterpret_cast<hyper
>(pRLink
.get()));
331 } catch(...) { return E_FAIL
; }
335 * Returns the index of the hyperlink that is associated with this character index.
336 * @param charIndex Special char index.
337 * @param hyperlinkIndex Variant to accept special hyperlink index.
340 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_hyperlinkIndex(long charIndex
, long *hyperlinkIndex
)
346 if(hyperlinkIndex
== nullptr)
354 *hyperlinkIndex
= pHyperText
->getHyperLinkIndex(charIndex
);
357 } catch(...) { return E_FAIL
; }
362 * @param pXInterface UNO interface.
365 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::put_XInterface(hyper pXInterface
)
367 // internal IUNOXWrapper - no mutex meeded
371 CAccTextBase::put_XInterface(pXInterface
);
373 if(pUNOInterface
== nullptr)
375 Reference
<XAccessibleContext
> pRContext
= pUNOInterface
->getAccessibleContext();
376 if( !pRContext
.is() )
380 Reference
<XAccessibleHypertext
> pRXI(pRContext
,UNO_QUERY
);
382 pHyperText
= nullptr;
384 pHyperText
= pRXI
.get();
387 } catch(...) { return E_FAIL
; }
390 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */