Line data Source code
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 : #ifndef INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_EXTENDED_TEXTWINDOWACCESSIBILITY_HXX
21 : #define INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_EXTENDED_TEXTWINDOWACCESSIBILITY_HXX
22 :
23 : #include <toolkit/awt/vclxaccessiblecomponent.hxx>
24 : #include <svl/lstner.hxx>
25 : #include <vcl/textdata.hxx>
26 : #include <vcl/texteng.hxx>
27 : #include <vcl/textview.hxx>
28 : #include <vcl/txtattr.hxx>
29 : #include <com/sun/star/awt/FontWeight.hpp>
30 : #include <com/sun/star/lang/EventObject.hpp>
31 : #include <com/sun/star/uno/Reference.hxx>
32 : #include <com/sun/star/util/Color.hpp>
33 : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
34 : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
35 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
36 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
37 : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
38 : #include <com/sun/star/accessibility/XAccessible.hpp>
39 : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
40 : #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
41 : #include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp>
42 : #include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp>
43 : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
44 : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
45 : #include <toolkit/awt/vclxwindow.hxx>
46 : #include <cppuhelper/basemutex.hxx>
47 : #include <cppuhelper/compbase7.hxx>
48 : #include <comphelper/accessiblecontexthelper.hxx>
49 : #include <comphelper/accessibletexthelper.hxx>
50 : #include <rtl/ref.hxx>
51 :
52 : #include <svtools/svtools.hrc>
53 : #include <vcl/svapp.hxx>
54 : #include <unotools/accessiblerelationsethelper.hxx>
55 : #include <queue>
56 : #include <memory>
57 : #include <unordered_map>
58 :
59 : class TextEngine;
60 : class TextView;
61 :
62 : namespace accessibility
63 : {
64 :
65 : class Document;
66 :
67 : class SfxListenerGuard
68 : {
69 : public:
70 0 : inline SfxListenerGuard(::SfxListener & rListener):
71 0 : m_rListener(rListener), m_pNotifier(0) {}
72 :
73 0 : inline ~SfxListenerGuard() { endListening(); }
74 :
75 : // Not thread safe:
76 : void startListening(::SfxBroadcaster & rNotifier);
77 :
78 : // Not thread safe:
79 : void endListening();
80 :
81 : private:
82 : ::SfxListener & m_rListener;
83 : ::SfxBroadcaster * m_pNotifier;
84 : };
85 :
86 : class WindowListenerGuard
87 : {
88 : public:
89 0 : inline WindowListenerGuard(::Link<> const & rListener):
90 0 : m_aListener(rListener), m_pNotifier(0) {}
91 :
92 0 : inline ~WindowListenerGuard() { endListening(); }
93 :
94 : // Not thread safe:
95 : void startListening(vcl::Window & rNotifier);
96 :
97 : // Not thread safe:
98 : void endListening();
99 :
100 : private:
101 : ::Link<> m_aListener;
102 : VclPtr<vcl::Window> m_pNotifier;
103 : };
104 :
105 0 : class ParagraphInfo
106 : {
107 : public:
108 0 : inline ParagraphInfo(::sal_Int32 nHeight): m_nHeight(nHeight) {}
109 :
110 : inline
111 : css::uno::WeakReference< css::accessibility::XAccessible > const &
112 0 : getParagraph() const { return m_xParagraph; }
113 :
114 0 : inline ::sal_Int32 getHeight() const { return m_nHeight; }
115 :
116 0 : inline void setParagraph(
117 : css::uno::Reference< css::accessibility::XAccessible > const &
118 0 : rParagraph) { m_xParagraph = rParagraph; }
119 :
120 0 : inline void changeHeight(::sal_Int32 nHeight) { m_nHeight = nHeight; }
121 :
122 : private:
123 : css::uno::WeakReference< css::accessibility::XAccessible >
124 : m_xParagraph;
125 : ::sal_Int32 m_nHeight;
126 : };
127 :
128 : typedef ::std::vector< ParagraphInfo > Paragraphs;
129 :
130 : typedef ::cppu::WeakAggComponentImplHelper7<
131 : css::accessibility::XAccessible,
132 : css::accessibility::XAccessibleContext,
133 : css::accessibility::XAccessibleComponent,
134 : css::accessibility::XAccessibleEditableText,
135 : css::accessibility::XAccessibleMultiLineText,
136 : css::accessibility::XAccessibleTextAttributes,
137 : css::accessibility::XAccessibleEventBroadcaster > ParagraphBase;
138 :
139 : // The Paragraph's number is the absolute position within the text engine (from
140 : // 0 to N - 1), whereas the Paragraph's index is the position within the text
141 : // view/accessible parent (from 0 to M - 1). Paragraphs outside the currently
142 : // visible range have an index of -1.
143 0 : class Paragraph:
144 : private cppu::BaseMutex, public ParagraphBase, private ::comphelper::OCommonAccessibleText
145 : {
146 : public:
147 : Paragraph(::rtl::Reference< Document > const & rDocument,
148 : Paragraphs::size_type nNumber);
149 :
150 : // Not thread-safe.
151 0 : inline Paragraphs::size_type getNumber() const { return m_nNumber; }
152 :
153 : // Not thread-safe.
154 : void numberChanged(bool bIncremented);
155 :
156 : // Not thread-safe.
157 : void textChanged();
158 :
159 : // Thread-safe.
160 : void notifyEvent(::sal_Int16 nEventId, css::uno::Any const & rOldValue,
161 : css::uno::Any const & rNewValue);
162 :
163 : protected:
164 : // OCommonAccessibleText
165 : virtual void implGetParagraphBoundary( css::i18n::Boundary& rBoundary,
166 : ::sal_Int32 nIndex ) SAL_OVERRIDE;
167 : virtual void implGetLineBoundary( css::i18n::Boundary& rBoundary,
168 : ::sal_Int32 nIndex ) SAL_OVERRIDE;
169 :
170 : private:
171 : virtual css::uno::Reference< css::accessibility::XAccessibleContext >
172 : SAL_CALL getAccessibleContext() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 :
174 : virtual ::sal_Int32 SAL_CALL getAccessibleChildCount()
175 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 :
177 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
178 : getAccessibleChild(::sal_Int32 i)
179 : throw (css::lang::IndexOutOfBoundsException,
180 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 :
182 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
183 : getAccessibleParent() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 :
185 : virtual ::sal_Int32 SAL_CALL getAccessibleIndexInParent()
186 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 :
188 : virtual ::sal_Int16 SAL_CALL getAccessibleRole()
189 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 :
191 : virtual OUString SAL_CALL getAccessibleDescription()
192 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 :
194 : virtual OUString SAL_CALL getAccessibleName()
195 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 :
197 : virtual
198 : css::uno::Reference< css::accessibility::XAccessibleRelationSet >
199 : SAL_CALL getAccessibleRelationSet() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 :
201 : virtual
202 : css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL
203 : getAccessibleStateSet() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 :
205 : virtual css::lang::Locale SAL_CALL getLocale()
206 : throw (css::accessibility::IllegalAccessibleComponentStateException,
207 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 :
209 : virtual sal_Bool SAL_CALL containsPoint(css::awt::Point const & rPoint)
210 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 :
212 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
213 : getAccessibleAtPoint(css::awt::Point const & rPoint)
214 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 :
216 : virtual css::awt::Rectangle SAL_CALL getBounds()
217 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
218 :
219 : virtual css::awt::Point SAL_CALL getLocation()
220 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
221 :
222 : virtual css::awt::Point SAL_CALL getLocationOnScreen()
223 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
224 :
225 : virtual css::awt::Size SAL_CALL getSize()
226 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
227 :
228 : virtual void SAL_CALL grabFocus() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
229 :
230 : virtual css::util::Color SAL_CALL getForeground()
231 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
232 :
233 : virtual css::util::Color SAL_CALL getBackground()
234 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
235 :
236 : virtual ::sal_Int32 SAL_CALL getCaretPosition()
237 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
238 :
239 : virtual sal_Bool SAL_CALL setCaretPosition(::sal_Int32 nIndex)
240 : throw (css::lang::IndexOutOfBoundsException,
241 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
242 :
243 : virtual ::sal_Unicode SAL_CALL getCharacter(::sal_Int32 nIndex)
244 : throw (css::lang::IndexOutOfBoundsException,
245 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 :
247 : virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
248 : getCharacterAttributes(::sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& aRequestedAttributes )
249 : throw (css::lang::IndexOutOfBoundsException,
250 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
251 :
252 : virtual css::awt::Rectangle SAL_CALL
253 : getCharacterBounds(::sal_Int32 nIndex)
254 : throw (css::lang::IndexOutOfBoundsException,
255 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
256 :
257 : virtual ::sal_Int32 SAL_CALL getCharacterCount()
258 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
259 :
260 : virtual ::sal_Int32 SAL_CALL
261 : getIndexAtPoint(css::awt::Point const & rPoint)
262 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
263 :
264 : virtual OUString SAL_CALL getSelectedText()
265 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 :
267 : virtual ::sal_Int32 SAL_CALL getSelectionStart()
268 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
269 :
270 : virtual ::sal_Int32 SAL_CALL getSelectionEnd()
271 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
272 :
273 : virtual sal_Bool SAL_CALL setSelection(::sal_Int32 nStartIndex,
274 : ::sal_Int32 nEndIndex)
275 : throw (css::lang::IndexOutOfBoundsException,
276 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
277 :
278 : virtual OUString SAL_CALL getText()
279 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
280 :
281 : virtual OUString SAL_CALL getTextRange(::sal_Int32 nStartIndex,
282 : ::sal_Int32 nEndIndex)
283 : throw (css::lang::IndexOutOfBoundsException,
284 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
285 :
286 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
287 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
288 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
289 :
290 : virtual sal_Bool SAL_CALL copyText(::sal_Int32 nStartIndex,
291 : ::sal_Int32 nEndIndex)
292 : throw (css::lang::IndexOutOfBoundsException,
293 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
294 :
295 : virtual sal_Bool SAL_CALL cutText(::sal_Int32 nStartIndex,
296 : ::sal_Int32 nEndIndex)
297 : throw (css::lang::IndexOutOfBoundsException,
298 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 :
300 : virtual sal_Bool SAL_CALL pasteText(::sal_Int32 nIndex)
301 : throw (css::lang::IndexOutOfBoundsException,
302 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
303 :
304 : virtual sal_Bool SAL_CALL deleteText(::sal_Int32 nStartIndex,
305 : ::sal_Int32 nEndIndex)
306 : throw (css::lang::IndexOutOfBoundsException,
307 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
308 :
309 : virtual sal_Bool SAL_CALL insertText(OUString const & rText,
310 : ::sal_Int32 nIndex)
311 : throw (css::lang::IndexOutOfBoundsException,
312 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
313 :
314 : virtual sal_Bool SAL_CALL replaceText(
315 : ::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex,
316 : OUString const & rReplacement)
317 : throw (css::lang::IndexOutOfBoundsException,
318 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
319 :
320 : virtual sal_Bool SAL_CALL setAttributes(
321 : ::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex,
322 : css::uno::Sequence< css::beans::PropertyValue > const &
323 : rAttributeSet)
324 : throw (css::lang::IndexOutOfBoundsException,
325 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
326 :
327 : virtual sal_Bool SAL_CALL setText(OUString const & rText)
328 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
329 :
330 : virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
331 : getDefaultAttributes(const css::uno::Sequence< OUString >& RequestedAttributes)
332 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
333 :
334 : virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
335 : getRunAttributes(::sal_Int32 Index, const css::uno::Sequence< OUString >& RequestedAttributes)
336 : throw (css::lang::IndexOutOfBoundsException,
337 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
338 :
339 : virtual ::sal_Int32 SAL_CALL getLineNumberAtIndex( ::sal_Int32 nIndex )
340 : throw (::com::sun::star::lang::IndexOutOfBoundsException,
341 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
342 :
343 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtLineNumber( ::sal_Int32 nLineNo )
344 : throw (::com::sun::star::lang::IndexOutOfBoundsException,
345 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
346 :
347 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtLineWithCaret( )
348 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
349 :
350 : virtual ::sal_Int32 SAL_CALL getNumberOfLineWithCaret( )
351 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
352 :
353 : virtual void SAL_CALL addAccessibleEventListener(
354 : css::uno::Reference<
355 : css::accessibility::XAccessibleEventListener > const & rListener)
356 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
357 :
358 : virtual void SAL_CALL removeAccessibleEventListener(
359 : css::uno::Reference<
360 : css::accessibility::XAccessibleEventListener > const & rListener)
361 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
362 :
363 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
364 :
365 : virtual OUString implGetText() SAL_OVERRIDE;
366 :
367 : virtual css::lang::Locale implGetLocale() SAL_OVERRIDE;
368 :
369 : virtual void implGetSelection(::sal_Int32 & rStartIndex,
370 : ::sal_Int32 & rEndIndex) SAL_OVERRIDE;
371 :
372 : // Throws css::lang::DisposedException:
373 : void checkDisposed();
374 :
375 : ::rtl::Reference< Document > m_xDocument;
376 : Paragraphs::size_type m_nNumber;
377 :
378 : // ::cppu::OInterfaceContainerHelper m_aListeners;
379 : /// client id in the AccessibleEventNotifier queue
380 : sal_uInt32 m_nClientId;
381 :
382 : OUString m_aParagraphText;
383 : };
384 :
385 :
386 : typedef std::unordered_map< OUString,
387 : css::beans::PropertyValue,
388 : OUStringHash,
389 : ::std::equal_to< OUString > > tPropValMap;
390 :
391 0 : class Document: public ::VCLXAccessibleComponent, public ::SfxListener
392 : {
393 : public:
394 : Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine,
395 : ::TextView & rView);
396 :
397 : inline css::uno::Reference< css::accessibility::XAccessible >
398 0 : getAccessible() { return m_xAccessible; }
399 :
400 : // Must be called only after init has been called.
401 : css::lang::Locale retrieveLocale();
402 :
403 : // Must be called only after init has been called.
404 : // To make it possible for this method to be (indirectly) called from
405 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
406 : // still zero), pass a "Paragraph const *" instead of a
407 : // "::rtl::Reference< Paragraph > const &".
408 : ::sal_Int32 retrieveParagraphIndex(Paragraph const * pParagraph);
409 :
410 : // Must be called only after init has been called.
411 : // To make it possible for this method to be (indirectly) called from
412 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
413 : // still zero), pass a "Paragraph const *" instead of a
414 : // "::rtl::Reference< Paragraph > const &".
415 : ::sal_Int64 retrieveParagraphState(Paragraph const * pParagraph);
416 :
417 : // Must be called only after init has been called.
418 : // To make it possible for this method to be (indirectly) called from
419 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
420 : // still zero), pass a "Paragraph const &" instead of a
421 : // "::rtl::Reference< Paragraph > const &".
422 : css::awt::Rectangle
423 : retrieveParagraphBounds(Paragraph const * pParagraph, bool bAbsolute);
424 :
425 : // Must be called only after init has been called.
426 : // To make it possible for this method to be (indirectly) called from
427 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
428 : // still zero), pass a "Paragraph const &" instead of a
429 : // "::rtl::Reference< Paragraph > const &".
430 : OUString retrieveParagraphText(Paragraph const * pParagraph);
431 :
432 : // Must be called only after init has been called.
433 : // To make it possible for this method to be (indirectly) called from
434 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
435 : // still zero), pass a "Paragraph const &" instead of a
436 : // "::rtl::Reference< Paragraph > const &".
437 : void retrieveParagraphSelection(Paragraph const * pParagraph,
438 : ::sal_Int32 * pBegin, ::sal_Int32 * pEnd);
439 :
440 : // Must be called only after init has been called.
441 : // To make it possible for this method to be (indirectly) called from
442 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
443 : // still zero), pass a "Paragraph const *" instead of a
444 : // "::rtl::Reference< Paragraph > const &".
445 : ::sal_Int32 retrieveParagraphCaretPosition(Paragraph const * pParagraph);
446 :
447 : // Must be called only after init has been called.
448 : // To make it possible for this method to be (indirectly) called from
449 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
450 : // still zero), pass a "Paragraph const &" instead of a
451 : // "::rtl::Reference< Paragraph > const &".
452 : // Throws css::lang::IndexOutOfBoundsException.
453 : css::awt::Rectangle
454 : retrieveCharacterBounds(Paragraph const * pParagraph,
455 : ::sal_Int32 nIndex);
456 :
457 : // Must be called only after init has been called.
458 : // To make it possible for this method to be (indirectly) called from
459 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
460 : // still zero), pass a "Paragraph const &" instead of a
461 : // "::rtl::Reference< Paragraph > const &".
462 : ::sal_Int32 retrieveCharacterIndex(Paragraph const * pParagraph,
463 : css::awt::Point const & rPoint);
464 :
465 : // Must be called only after init has been called.
466 : // To make it possible for this method to be (indirectly) called from
467 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
468 : // still zero), pass a "Paragraph const &" instead of a
469 : // "::rtl::Reference< Paragraph > const &".
470 : // Throws css::lang::IndexOutOfBoundsException.
471 : css::uno::Sequence< css::beans::PropertyValue > retrieveCharacterAttributes(
472 : Paragraph const * pParagraph, ::sal_Int32 nIndex,
473 : const css::uno::Sequence< OUString >& aRequestedAttributes);
474 :
475 : // Must be called only after init has been called.
476 : // To make it possible for this method to be (indirectly) called from
477 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
478 : // still zero), pass a "Paragraph const &" instead of a
479 : // "::rtl::Reference< Paragraph > const &".
480 : css::uno::Sequence< css::beans::PropertyValue > retrieveDefaultAttributes(
481 : Paragraph const * pParagraph,
482 : const css::uno::Sequence< OUString >& RequestedAttributes);
483 :
484 : // Must be called only after init has been called.
485 : // To make it possible for this method to be (indirectly) called from
486 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
487 : // still zero), pass a "Paragraph const &" instead of a
488 : // "::rtl::Reference< Paragraph > const &".
489 : // Throws css::lang::IndexOutOfBoundsException.
490 : css::uno::Sequence< css::beans::PropertyValue > retrieveRunAttributes(
491 : Paragraph const * pParagraph, ::sal_Int32 Index,
492 : const css::uno::Sequence< OUString >& RequestedAttributes);
493 :
494 : // Must be called only after init has been called.
495 : // To make it possible for this method to be (indirectly) called from
496 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
497 : // still zero), pass a "Paragraph const &" instead of a
498 : // "::rtl::Reference< Paragraph > const &".
499 : void changeParagraphText(Paragraph * pParagraph,
500 : OUString const & rText);
501 :
502 : // Must be called only after init has been called.
503 : // To make it possible for this method to be (indirectly) called from
504 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
505 : // still zero), pass a "Paragraph const &" instead of a
506 : // "::rtl::Reference< Paragraph > const &".
507 : // Throws css::lang::IndexOutOfBoundsException.
508 : void changeParagraphText(Paragraph * pParagraph, ::sal_Int32 nBegin,
509 : ::sal_Int32 nEnd, bool bCut, bool bPaste,
510 : OUString const & rText);
511 :
512 : // Must be called only after init has been called.
513 : // To make it possible for this method to be (indirectly) called from
514 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
515 : // still zero), pass a "Paragraph const &" instead of a
516 : // "::rtl::Reference< Paragraph > const &".
517 : // Throws css::lang::IndexOutOfBoundsException.
518 : void copyParagraphText(Paragraph const * pParagraph,
519 : ::sal_Int32 nBegin, ::sal_Int32 nEnd);
520 :
521 : // Must be called only after init has been called.
522 : // To make it possible for this method to be (indirectly) called from
523 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
524 : // still zero), pass a "Paragraph const &" instead of a
525 : // "::rtl::Reference< Paragraph > const &".
526 : // Throws css::lang::IndexOutOfBoundsException.
527 : void changeParagraphAttributes(
528 : Paragraph * pParagraph, ::sal_Int32 nBegin, ::sal_Int32 nEnd,
529 : css::uno::Sequence< css::beans::PropertyValue > const &
530 : rAttributeSet);
531 :
532 : // Must be called only after init has been called.
533 : // To make it possible for this method to be (indirectly) called from
534 : // within Paragraph's constructor (i.e., when the Paragraph's ref count is
535 : // still zero), pass a "Paragraph const &" instead of a
536 : // "::rtl::Reference< Paragraph > const &".
537 : // Throws css::lang::IndexOutOfBoundsException.
538 : void changeParagraphSelection(Paragraph * pParagraph,
539 : ::sal_Int32 nBegin, ::sal_Int32 nEnd);
540 :
541 : css::i18n::Boundary
542 : retrieveParagraphLineBoundary( Paragraph const * pParagraph,
543 : ::sal_Int32 nIndex, ::sal_Int32 *pLineNo = NULL);
544 :
545 : css::i18n::Boundary
546 : retrieveParagraphBoundaryOfLine( Paragraph const * pParagraph,
547 : ::sal_Int32 nIndex );
548 :
549 : sal_Int32 retrieveParagraphLineWithCursor( Paragraph const * pParagraph );
550 :
551 : css::uno::Reference< css::accessibility::XAccessibleRelationSet >
552 : retrieveParagraphRelationSet( Paragraph const * pParagraph );
553 :
554 : private:
555 : virtual ::sal_Int32 SAL_CALL getAccessibleChildCount()
556 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
557 :
558 : virtual css::uno::Reference< css::accessibility::XAccessible >
559 : SAL_CALL getAccessibleChild(::sal_Int32 i)
560 : throw (css::lang::IndexOutOfBoundsException,
561 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
562 :
563 : virtual ::sal_Int16 SAL_CALL getAccessibleRole()
564 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
565 :
566 : virtual css::uno::Reference< css::accessibility::XAccessible >
567 : SAL_CALL getAccessibleAtPoint(css::awt::Point const & rPoint)
568 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
569 :
570 : virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) SAL_OVERRIDE;
571 : virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) SAL_OVERRIDE;
572 :
573 : // ??? Will be called with both the external (Solar) and internal mutex
574 : // locked:
575 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
576 :
577 : // ??? Will be called with the external (Solar) mutex locked.
578 : // init will already have been called.
579 : virtual void Notify(::SfxBroadcaster & rBC, ::SfxHint const & rHint) SAL_OVERRIDE;
580 :
581 : // Assuming that this will only be called with the external (Solar) mutex
582 : // locked.
583 : // init will already have been called.
584 : DECL_LINK(WindowEventHandler, VclSimpleEvent *);
585 :
586 : // Must be called with both the external (Solar) and internal mutex
587 : // locked.
588 : void init();
589 :
590 : // Must be called with both the external (Solar) and internal mutex
591 : // locked, and after init has been called:
592 : static ::rtl::Reference< Paragraph >
593 : getParagraph(Paragraphs::iterator const & rIt);
594 :
595 : // Must be called with both the external (Solar) and internal mutex
596 : // locked, and after init has been called.
597 : // Throws css::uno::RuntimeException.
598 : css::uno::Reference< css::accessibility::XAccessible >
599 : getAccessibleChild(Paragraphs::iterator const & rIt);
600 :
601 : // Must be called with both the external (Solar) and internal mutex
602 : // locked, and after init has been called:
603 : void determineVisibleRange();
604 :
605 : // Must be called with both the external (Solar) and internal mutex
606 : // locked, and after init has been called:
607 : void notifyVisibleRangeChanges(
608 : Paragraphs::iterator const & rOldVisibleBegin,
609 : Paragraphs::iterator const & rOldVisibleEnd,
610 : Paragraphs::iterator const & rInserted);
611 :
612 : // Must be called with both the external (Solar) and internal mutex
613 : // locked, and after init has been called:
614 : void changeParagraphText(::sal_uLong nNumber, ::sal_uInt16 nBegin, ::sal_uInt16 nEnd,
615 : bool bCut, bool bPaste,
616 : OUString const & rText);
617 :
618 : void
619 : handleParagraphNotifications();
620 :
621 : void handleSelectionChangeNotification();
622 :
623 : ::sal_Int32 getSelectionType(::sal_Int32 nNewFirstPara, ::sal_Int32 nNewFirstPos, ::sal_Int32 nNewLastPara, ::sal_Int32 nNewLastPos);
624 : void sendEvent(::sal_Int32 start, ::sal_Int32 end, ::sal_Int16 nEventId);
625 :
626 : void disposeParagraphs();
627 :
628 : static css::uno::Any mapFontColor(::Color const & rColor);
629 :
630 : static ::Color mapFontColor(css::uno::Any const & rColor);
631 :
632 : static css::uno::Any mapFontWeight(::FontWeight nWeight);
633 :
634 : static ::FontWeight mapFontWeight(css::uno::Any const & rWeight);
635 :
636 : static void retrieveDefaultAttributesImpl(
637 : Paragraph const * pParagraph,
638 : const css::uno::Sequence< OUString >& RequestedAttributes,
639 : tPropValMap& rDefAttrSeq);
640 :
641 : void retrieveRunAttributesImpl(
642 : Paragraph const * pParagraph, ::sal_Int32 Index,
643 : const css::uno::Sequence< OUString >& RequestedAttributes,
644 : tPropValMap& rRunAttrSeq);
645 :
646 : static css::uno::Sequence< css::beans::PropertyValue >
647 : convertHashMapToSequence(tPropValMap& rAttrSeq);
648 :
649 : css::uno::Reference< css::accessibility::XAccessible > m_xAccessible;
650 : ::TextEngine & m_rEngine;
651 : ::TextView & m_rView;
652 :
653 : SfxListenerGuard m_aEngineListener;
654 : WindowListenerGuard m_aViewListener;
655 :
656 : // All the following members have valid values only after calling init:
657 :
658 : std::unique_ptr< Paragraphs > m_xParagraphs;
659 :
660 : // m_nViewOffset is from the start of the document (0) to the start of the
661 : // current view, and m_nViewHeight is the height of the view:
662 : ::sal_Int32 m_nViewOffset;
663 : ::sal_Int32 m_nViewHeight;
664 :
665 : // m_aVisibleBegin points to the first Paragraph that is (partially)
666 : // contained in the view, and m_aVisibleEnd points past the last Paragraph
667 : // that is (partially) contained. If no Paragraphs are (partially) in the
668 : // view, both m_aVisibleBegin and m_aVisibleEnd are set to
669 : // m_xParagraphs->end(). These values are only changed by
670 : // determineVisibleRange.
671 : Paragraphs::iterator m_aVisibleBegin;
672 : Paragraphs::iterator m_aVisibleEnd;
673 :
674 : // m_nVisibleBeginOffset is from m_nViewOffset back to the start of the
675 : // Paragraph pointed to by m_aVisibleBegin (and always has a non-negative
676 : // value). If m_aVisibleBegin == m_xParagraphs->end(),
677 : // m_nVisibleBeginOffset is set to 0. These values are only changed by
678 : // determineVisibleRange.
679 : ::sal_Int32 m_nVisibleBeginOffset;
680 :
681 : // If no selection has yet been set, all the following four variables are
682 : // set to -1. m_nSelectionLastPara/Pos is also the cursor position.
683 : ::sal_Int32 m_nSelectionFirstPara;
684 : ::sal_Int32 m_nSelectionFirstPos;
685 : ::sal_Int32 m_nSelectionLastPara;
686 : ::sal_Int32 m_nSelectionLastPos;
687 :
688 : Paragraphs::iterator m_aFocused;
689 :
690 : ::std::queue< ::TextHint > m_aParagraphNotifications;
691 : bool m_bSelectionChangedNotification;
692 : };
693 :
694 : }
695 :
696 : #endif // INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_EXTENDED_TEXTWINDOWACCESSIBILITY_HXX
697 :
698 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|