1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include "stdafx.h"
23 #include "UAccCOM2.h"
24 #include "AccHypertext.h"
25
26 #include "act.hxx"
27
28 using namespace com::sun::star::accessibility;
29 using namespace com::sun::star::uno;
30
31 /////////////////////////////////////////////////////////////////////////////
32 //
33 /**
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.
38 * @return Result.
39 */
addSelection(long startOffset,long endOffset)40 STDMETHODIMP CAccHypertext::addSelection(long startOffset, long endOffset)
41 {
42
43 return CAccTextBase::get_addSelection(startOffset, endOffset);
44 }
45
46
47 /**
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.
53 * @return Result.
54 */
get_attributes(long offset,long * startOffset,long * endOffset,BSTR * textAttributes)55 STDMETHODIMP CAccHypertext::get_attributes(long offset, long * startOffset, long * endOffset, BSTR * textAttributes)
56 {
57
58 return CAccTextBase::get_attributes(offset, startOffset, endOffset, textAttributes);
59 }
60
61 /**
62 * Get caret position.
63 * @param offset Variant to accept caret offset.
64 * @return Result.
65 */
get_caretOffset(long * offset)66 STDMETHODIMP CAccHypertext::get_caretOffset(long * offset)
67 {
68
69 return CAccTextBase::get_caretOffset(offset);
70 }
71
72 /**
73 * Get character count.
74 * @param nCharacters Variant to accept character count.
75 * @return Result.
76 */
get_characterCount(long * nCharacters)77 STDMETHODIMP CAccHypertext::get_characterCount(long * nCharacters)
78 {
79
80 return CAccTextBase::get_characterCount(nCharacters);
81 }
82
83 /**
84 * Get character extents.
85 * @param offset Offset.
86 * @param x Variant to accpet x position.
87 * @param y Variant to accpet y position.
88 * @param width Variant to accpet width.
89 * @param Height Variant to accpet height.
90 * @return Result.
91 */
get_characterExtents(long offset,IA2CoordinateType coordType,long * x,long * y,long * width,long * height)92 STDMETHODIMP CAccHypertext::get_characterExtents(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height)
93 {
94
95 return CAccTextBase::get_characterExtents(offset, coordType, x, y, width, height);
96 }
97
98 /**
99 * Get slections count.
100 * @param nSelections Variant to accpet slections count.
101 * @return Result.
102 */
get_nSelections(long * nSelections)103 STDMETHODIMP CAccHypertext::get_nSelections(long * nSelections)
104 {
105
106 return CAccTextBase::get_nSelections(nSelections);
107 }
108
109 /**
110 * Get offset of some special point.
111 * @param x X position of one point.
112 * @param x Y position of one point.
113 * @param coordType Type.
114 * @param offset Variant to accept offset.
115 * @return Result.
116 */
get_offsetAtPoint(long x,long y,IA2CoordinateType coordType,long * offset)117 STDMETHODIMP CAccHypertext::get_offsetAtPoint(long x, long y, IA2CoordinateType coordType, long * offset)
118 {
119 return CAccTextBase::get_offsetAtPoint(x, y, coordType, offset);
120 }
121
122 /**
123 * Get selection range.
124 * @param selection selection count.
125 * @param startOffset Variant to accept the start offset of special selection.
126 * @param endOffset Variant to accept the end offset of special selection.
127 * @return Result.
128 */
get_selection(long selection,long * startOffset,long * endOffset)129 STDMETHODIMP CAccHypertext::get_selection(long selection, long * startOffset, long * endOffset)
130 {
131
132 return CAccTextBase::get_selection(selection, startOffset, endOffset);
133 }
134
135 /**
136 * Get special text.
137 * @param startOffset Start position of special range.
138 * @param endOffset End position of special range.
139 * @param text Variant to accept the text of special range.
140 * @return Result.
141 */
get_text(long startOffset,long endOffset,BSTR * text)142 STDMETHODIMP CAccHypertext::get_text(long startOffset, long endOffset, BSTR * text)
143 {
144
145 return CAccTextBase::get_text(startOffset, endOffset, text);
146 }
147
148 /**
149 * Get special text before some position.
150 * @param offset Special position.
151 * @param boundaryType Boundary type.
152 * @param startOffset Variant to accept the start offset.
153 * @param endOffset Variant to accept the end offset.
154 * @param text Variant to accept the special text.
155 * @return Result.
156 */
get_textBeforeOffset(long offset,IA2TextBoundaryType boundaryType,long * startOffset,long * endOffset,BSTR * text)157 STDMETHODIMP CAccHypertext::get_textBeforeOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
158 {
159
160 return CAccTextBase::get_textBeforeOffset(offset, boundaryType,
161 startOffset, endOffset, text);
162 }
163
164 /**
165 * Get special text after some position.
166 * @param offset Special position.
167 * @param boundaryType Boundary type.
168 * @param startOffset Variant to accept the start offset.
169 * @param endOffset Variant to accept the end offset.
170 * @param text Variant to accept the special text.
171 * @return Result.
172 */
get_textAfterOffset(long offset,IA2TextBoundaryType boundaryType,long * startOffset,long * endOffset,BSTR * text)173 STDMETHODIMP CAccHypertext::get_textAfterOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
174 {
175
176 return CAccTextBase::get_textAfterOffset(offset, boundaryType,
177 startOffset, endOffset, text);
178 }
179
180 /**
181 * Get special text at some position.
182 * @param offset Special position.
183 * @param boundaryType Boundary type.
184 * @param startOffset Variant to accept the start offset.
185 * @param endOffset Variant to accept the end offset.
186 * @param text Variant to accept the special text.
187 * @return Result.
188 */
get_textAtOffset(long offset,IA2TextBoundaryType boundaryType,long * startOffset,long * endOffset,BSTR * text)189 STDMETHODIMP CAccHypertext::get_textAtOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text)
190 {
191
192 return CAccTextBase::get_textAtOffset(offset, boundaryType,
193 startOffset, endOffset, text);
194 }
195
196 /**
197 * Remove selection.
198 * @param selectionIndex Special selection index
199 * @param success Variant to accept the memthod called result.
200 * @return Result.
201 */
removeSelection(long selectionIndex)202 STDMETHODIMP CAccHypertext::removeSelection(long selectionIndex)
203 {
204
205 return CAccTextBase::removeSelection(selectionIndex);
206 }
207
208 /**
209 * Set caret position.
210 * @param offset Special position.
211 * @param success Variant to accept the memthod called result.
212 * @return Result.
213 */
setCaretOffset(long offset)214 STDMETHODIMP CAccHypertext::setCaretOffset(long offset)
215 {
216
217 return CAccTextBase::setCaretOffset(offset);
218 }
219
220 /**
221 * Set special selection.
222 * @param selectionIndex Special selection index.
223 * @param startOffset start position.
224 * @param endOffset end position.
225 * @param success Variant to accept the memthod called result.
226 * @return Result.
227 */
setSelection(long selectionIndex,long startOffset,long endOffset)228 STDMETHODIMP CAccHypertext::setSelection(long selectionIndex, long startOffset, long endOffset)
229 {
230
231 return CAccTextBase::setSelection(selectionIndex, startOffset,
232 endOffset);
233 }
234
235 /**
236 * Get characters count.
237 * @param nCharacters Variant to accept the characters count.
238 * @return Result.
239 */
get_nCharacters(long * nCharacters)240 STDMETHODIMP CAccHypertext::get_nCharacters(long * nCharacters)
241 {
242
243 return CAccTextBase::get_nCharacters(nCharacters);
244 }
245
get_newText(IA2TextSegment * newText)246 STDMETHODIMP CAccHypertext::get_newText( IA2TextSegment *newText)
247 {
248 return CAccTextBase::get_newText(newText);
249 }
250
get_oldText(IA2TextSegment * oldText)251 STDMETHODIMP CAccHypertext::get_oldText( IA2TextSegment *oldText)
252 {
253 return CAccTextBase::get_oldText(oldText);
254 }
255
256 /**
257 * Scroll to special sub-string .
258 * @param startIndex Start index of sub string.
259 * @param endIndex End index of sub string.
260 * @return Result.
261 */
scrollSubstringToPoint(long startIndex,long endIndex,enum IA2CoordinateType coordinateType,long x,long y)262 STDMETHODIMP CAccHypertext::scrollSubstringToPoint(long startIndex, long endIndex,enum IA2CoordinateType coordinateType, long x, long y )
263 {
264
265 return CAccTextBase::scrollSubstringToPoint(startIndex, endIndex, coordinateType, x, y);
266 }
scrollSubstringTo(long startIndex,long endIndex,enum IA2ScrollType scrollType)267 STDMETHODIMP CAccHypertext::scrollSubstringTo(long startIndex, long endIndex,enum IA2ScrollType scrollType)
268 {
269
270 return CAccTextBase::scrollSubstringTo(startIndex, endIndex,scrollType);
271 }
272
273 /**
274 * Get hyperlink count.
275 * @param hyperlinkCount Variant to accpet hyperlink count.
276 * @return Result.
277 */
get_nHyperlinks(long * hyperlinkCount)278 STDMETHODIMP CAccHypertext::get_nHyperlinks(long *hyperlinkCount)
279 {
280
281 CHECK_ENABLE_INF
282
283 ENTER_PROTECTED_BLOCK
284
285 // #CHECK#
286 if(hyperlinkCount == NULL)
287 return E_INVALIDARG;
288 // #CHECK XInterface#
289 if(!pHyperText.is())
290 {
291 return E_FAIL;
292 }
293
294 *hyperlinkCount = pHyperText->getHyperLinkCount();
295 return S_OK;
296
297 LEAVE_PROTECTED_BLOCK
298 }
299
300 /**
301 * Get special hyperlink.
302 * @param index Special hyperlink index.
303 * @param hyperlink Variant to accept special hyperlink via index.
304 * @return Result.
305 */
get_hyperlink(long index,IAccessibleHyperlink ** hyperlink)306 STDMETHODIMP CAccHypertext::get_hyperlink(long index,IAccessibleHyperlink **hyperlink)
307 {
308
309 CHECK_ENABLE_INF
310
311 ENTER_PROTECTED_BLOCK
312
313 // #CHECK#
314 if(hyperlink == NULL)
315 return E_INVALIDARG;
316 // #CHECK XInterface#
317 if(!pHyperText.is())
318 {
319 return E_FAIL;
320 }
321
322 Reference<XAccessibleHyperlink> pRLink = pHyperText->getHyperLink(index);
323 if(!pRLink.is())
324 {
325 *hyperlink = NULL;
326 return E_FAIL;
327 }
328
329 IAccessibleHyperlink* plink = NULL;
330 ActivateActContext();
331 HRESULT hr = CoCreateInstance( CLSID_AccHyperLink, NULL, CLSCTX_SERVER ,
332 IID_IAccessibleHyperlink,
333 (void **)&plink);
334 DeactivateActContext();
335 if( SUCCEEDED(hr) )
336 {
337 IUNOXWrapper* wrapper = NULL;
338 plink->QueryInterface(IID_IUNOXWrapper, (void**)&wrapper);
339 if(wrapper)
340 {
341 wrapper->put_XSubInterface((long)pRLink.get()/*pXI*/);
342 wrapper->Release();
343 }
344 *hyperlink = plink;
345 return S_OK;
346 }
347
348 return E_FAIL;
349
350 LEAVE_PROTECTED_BLOCK
351 }
352
353 /**
354 * Returns the index of the hyperlink that is associated with this character index.
355 * @param charIndex Special char index.
356 * @param hyperlinkIndex Variant to accept special hyperlink index.
357 * @return Result.
358 */
get_hyperlinkIndex(long charIndex,long * hyperlinkIndex)359 STDMETHODIMP CAccHypertext::get_hyperlinkIndex(long charIndex, long *hyperlinkIndex)
360 {
361
362 CHECK_ENABLE_INF
363
364 ENTER_PROTECTED_BLOCK
365
366 // #CHECK#
367 if(hyperlinkIndex == NULL)
368 return E_INVALIDARG;
369 // #CHECK XInterface#
370 if(!pHyperText.is())
371 {
372 return E_FAIL;
373 }
374
375 *hyperlinkIndex = pHyperText->getHyperLinkIndex(charIndex);
376 return S_OK;
377
378 LEAVE_PROTECTED_BLOCK
379 }
380
381 /**
382 * Put UNO interface.
383 * @param pXInterface UNO interface.
384 * @return Result.
385 */
put_XInterface(long pXInterface)386 STDMETHODIMP CAccHypertext::put_XInterface(long pXInterface)
387 {
388
389
390 ENTER_PROTECTED_BLOCK
391
392 CAccTextBase::put_XInterface(pXInterface);
393 //special query.
394 if(pUNOInterface == NULL)
395 return E_FAIL;
396 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
397 if( !pRContext.is() )
398 {
399 return E_FAIL;
400 }
401 Reference<XAccessibleHypertext> pRXI(pRContext,UNO_QUERY);
402 if( !pRXI.is() )
403 pHyperText = NULL;
404 else
405 pHyperText = pRXI.get();
406 return S_OK;
407
408 LEAVE_PROTECTED_BLOCK
409 }
410