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 .
21 #include "AccHypertext.h"
22 #include "AccHyperLink.h"
23 #include "acccommon.h"
26 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
31 #pragma clang diagnostic pop
34 #include <vcl/svapp.hxx>
37 using namespace com::sun::star::accessibility
;
38 using namespace com::sun::star::uno
;
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.
48 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::addSelection(long startOffset
, long endOffset
)
51 return CAccTextBase::get_addSelection(startOffset
, endOffset
);
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.
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
);
71 * @param offset Variant to accept caret offset.
74 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_caretOffset(long * offset
)
77 return CAccTextBase::get_caretOffset(offset
);
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.
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
);
96 * Get selections count.
97 * @param nSelections Variant to accept selections count.
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.
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.
126 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_selection(long selection
, long * startOffset
, long * endOffset
)
129 return CAccTextBase::get_selection(selection
, startOffset
, endOffset
);
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.
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.
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.
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.
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
);
195 * @param selectionIndex Special selection index
196 * @param success Variant to accept the memthod called 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.
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.
225 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::setSelection(long selectionIndex
, long startOffset
, long endOffset
)
228 return CAccTextBase::setSelection(selectionIndex
, startOffset
,
233 * Get characters count.
234 * @param nCharacters Variant to accept the characters count.
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.
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.
275 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_nHyperlinks(long *hyperlinkCount
)
279 ENTER_PROTECTED_BLOCK
282 if(hyperlinkCount
== nullptr)
284 // #CHECK XInterface#
290 *hyperlinkCount
= pHyperText
->getHyperLinkCount();
293 LEAVE_PROTECTED_BLOCK
297 * Get special hyperlink.
298 * @param index Special hyperlink index.
299 * @param hyperlink Variant to accept special hyperlink via index.
302 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_hyperlink(long index
,IAccessibleHyperlink
**hyperlink
)
306 ENTER_PROTECTED_BLOCK
309 if(hyperlink
== nullptr)
311 // #CHECK XInterface#
317 Reference
<XAccessibleHyperlink
> pRLink
= pHyperText
->getHyperLink(index
);
320 *hyperlink
= nullptr;
324 IAccessibleHyperlink
* plink
= nullptr;
325 HRESULT hr
= createInstance
<CAccHyperLink
>(IID_IAccessibleHyperlink
, &plink
);
328 IUNOXWrapper
* wrapper
= nullptr;
329 plink
->QueryInterface(IID_IUNOXWrapper
, reinterpret_cast<void**>(&wrapper
));
332 wrapper
->put_XSubInterface(reinterpret_cast<hyper
>(pRLink
.get()));
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.
350 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccHypertext::get_hyperlinkIndex(long charIndex
, long *hyperlinkIndex
)
354 ENTER_PROTECTED_BLOCK
357 if(hyperlinkIndex
== nullptr)
359 // #CHECK XInterface#
365 *hyperlinkIndex
= pHyperText
->getHyperLinkIndex(charIndex
);
368 LEAVE_PROTECTED_BLOCK
373 * @param pXInterface UNO interface.
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
);
384 if(pUNOInterface
== nullptr)
386 Reference
<XAccessibleContext
> pRContext
= pUNOInterface
->getAccessibleContext();
387 if( !pRContext
.is() )
391 Reference
<XAccessibleHypertext
> pRXI(pRContext
,UNO_QUERY
);
393 pHyperText
= nullptr;
395 pHyperText
= pRXI
.get();
398 LEAVE_PROTECTED_BLOCK
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */