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_TEXTWINDOWACCESSIBILITY_HXX
21 : #define INCLUDED_ACCESSIBILITY_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/compbase7.hxx>
47 : #include <comphelper/accessiblecontexthelper.hxx>
48 : #include <comphelper/accessibletexthelper.hxx>
49 : #include <rtl/ref.hxx>
50 :
51 : #include <memory>
52 : #include <queue>
53 : #include <boost/unordered_map.hpp>
54 :
55 : class TextEngine;
56 : class TextView;
57 :
58 : namespace accessibility
59 : {
60 :
61 : class Paragraph;
62 : class Document;
63 :
64 : class SfxListenerGuard
65 : {
66 : public:
67 0 : inline SfxListenerGuard(::SfxListener & rListener):
68 0 : m_rListener(rListener), m_pNotifier(0) {}
69 :
70 0 : inline ~SfxListenerGuard() { endListening(); }
71 :
72 : // Not thread safe:
73 : void startListening(::SfxBroadcaster & rNotifier);
74 :
75 : // Not thread safe:
76 : void endListening();
77 :
78 : private:
79 : ::SfxListener & m_rListener;
80 : ::SfxBroadcaster * m_pNotifier;
81 : };
82 :
83 : class WindowListenerGuard
84 : {
85 : public:
86 0 : inline WindowListenerGuard(::Link const & rListener):
87 0 : m_aListener(rListener), m_pNotifier(0) {}
88 :
89 0 : inline ~WindowListenerGuard() { endListening(); }
90 :
91 : // Not thread safe:
92 : void startListening(::Window & rNotifier);
93 :
94 : // Not thread safe:
95 : void endListening();
96 :
97 : private:
98 : ::Link m_aListener;
99 : ::Window * m_pNotifier;
100 : };
101 :
102 0 : class ParagraphInfo
103 : {
104 : public:
105 0 : inline ParagraphInfo(::sal_Int32 nHeight): m_nHeight(nHeight) {}
106 :
107 : inline
108 : css::uno::WeakReference< css::accessibility::XAccessible > const &
109 0 : getParagraph() const { return m_xParagraph; }
110 :
111 0 : inline ::sal_Int32 getHeight() const { return m_nHeight; }
112 :
113 0 : inline void setParagraph(
114 : css::uno::Reference< css::accessibility::XAccessible > const &
115 0 : rParagraph) { m_xParagraph = rParagraph; }
116 :
117 0 : inline void changeHeight(::sal_Int32 nHeight) { m_nHeight = nHeight; }
118 :
119 : private:
120 : css::uno::WeakReference< css::accessibility::XAccessible >
121 : m_xParagraph;
122 : ::sal_Int32 m_nHeight;
123 : };
124 :
125 : typedef ::std::vector< ParagraphInfo > Paragraphs;
126 :
127 : typedef ::cppu::WeakAggComponentImplHelper7<
128 : css::accessibility::XAccessible,
129 : css::accessibility::XAccessibleContext,
130 : css::accessibility::XAccessibleComponent,
131 : css::accessibility::XAccessibleEditableText,
132 : css::accessibility::XAccessibleMultiLineText,
133 : css::accessibility::XAccessibleTextAttributes,
134 : css::accessibility::XAccessibleEventBroadcaster > ParagraphBase;
135 :
136 : // The Paragraph's number is the absolute position within the text engine (from
137 : // 0 to N - 1), whereas the Paragraph's index is the position within the text
138 : // view/accessible parent (from 0 to M - 1). Paragraphs outside the currently
139 : // visible range have an index of -1.
140 0 : class ParagraphImpl:
141 : public ParagraphBase, private ::comphelper::OCommonAccessibleText
142 : {
143 : public:
144 : ParagraphImpl(::rtl::Reference< Document > const & rDocument,
145 : Paragraphs::size_type nNumber, ::osl::Mutex & rMutex);
146 :
147 : // Not thread-safe.
148 0 : inline Paragraphs::size_type getNumber() const { return m_nNumber; }
149 :
150 : // Not thread-safe.
151 : void numberChanged(bool bIncremented);
152 :
153 : // Not thread-safe.
154 : void textChanged();
155 :
156 : // Thread-safe.
157 : void notifyEvent(::sal_Int16 nEventId, css::uno::Any const & rOldValue,
158 : css::uno::Any const & rNewValue);
159 :
160 : protected:
161 : // OCommonAccessibleText
162 : virtual void implGetParagraphBoundary( css::i18n::Boundary& rBoundary,
163 : ::sal_Int32 nIndex );
164 : virtual void implGetLineBoundary( css::i18n::Boundary& rBoundary,
165 : ::sal_Int32 nIndex );
166 :
167 : private:
168 : virtual css::uno::Reference< css::accessibility::XAccessibleContext >
169 : SAL_CALL getAccessibleContext() throw (css::uno::RuntimeException);
170 :
171 : virtual ::sal_Int32 SAL_CALL getAccessibleChildCount()
172 : throw (css::uno::RuntimeException);
173 :
174 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
175 : getAccessibleChild(::sal_Int32 i)
176 : throw (css::lang::IndexOutOfBoundsException,
177 : css::uno::RuntimeException);
178 :
179 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
180 : getAccessibleParent() throw (css::uno::RuntimeException);
181 :
182 : virtual ::sal_Int32 SAL_CALL getAccessibleIndexInParent()
183 : throw (css::uno::RuntimeException);
184 :
185 : virtual ::sal_Int16 SAL_CALL getAccessibleRole()
186 : throw (css::uno::RuntimeException);
187 :
188 : virtual OUString SAL_CALL getAccessibleDescription()
189 : throw (css::uno::RuntimeException);
190 :
191 : virtual OUString SAL_CALL getAccessibleName()
192 : throw (css::uno::RuntimeException);
193 :
194 : virtual
195 : css::uno::Reference< css::accessibility::XAccessibleRelationSet >
196 : SAL_CALL getAccessibleRelationSet() throw (css::uno::RuntimeException);
197 :
198 : virtual
199 : css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL
200 : getAccessibleStateSet() throw (css::uno::RuntimeException);
201 :
202 : virtual css::lang::Locale SAL_CALL getLocale()
203 : throw (css::accessibility::IllegalAccessibleComponentStateException,
204 : css::uno::RuntimeException);
205 :
206 : virtual ::sal_Bool SAL_CALL containsPoint(css::awt::Point const & rPoint)
207 : throw (css::uno::RuntimeException);
208 :
209 : virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
210 : getAccessibleAtPoint(css::awt::Point const & rPoint)
211 : throw (css::uno::RuntimeException);
212 :
213 : virtual css::awt::Rectangle SAL_CALL getBounds()
214 : throw (css::uno::RuntimeException);
215 :
216 : virtual css::awt::Point SAL_CALL getLocation()
217 : throw (css::uno::RuntimeException);
218 :
219 : virtual css::awt::Point SAL_CALL getLocationOnScreen()
220 : throw (css::uno::RuntimeException);
221 :
222 : virtual css::awt::Size SAL_CALL getSize()
223 : throw (css::uno::RuntimeException);
224 :
225 : virtual void SAL_CALL grabFocus() throw (css::uno::RuntimeException);
226 :
227 : virtual css::uno::Any SAL_CALL getAccessibleKeyBinding()
228 : throw (css::uno::RuntimeException);
229 :
230 : virtual css::util::Color SAL_CALL getForeground()
231 : throw (css::uno::RuntimeException);
232 :
233 : virtual css::util::Color SAL_CALL getBackground()
234 : throw (css::uno::RuntimeException);
235 :
236 : virtual ::sal_Int32 SAL_CALL getCaretPosition()
237 : throw (css::uno::RuntimeException);
238 :
239 : virtual ::sal_Bool SAL_CALL setCaretPosition(::sal_Int32 nIndex)
240 : throw (css::lang::IndexOutOfBoundsException,
241 : css::uno::RuntimeException);
242 :
243 : virtual ::sal_Unicode SAL_CALL getCharacter(::sal_Int32 nIndex)
244 : throw (css::lang::IndexOutOfBoundsException,
245 : css::uno::RuntimeException);
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);
251 :
252 : virtual css::awt::Rectangle SAL_CALL
253 : getCharacterBounds(::sal_Int32 nIndex)
254 : throw (css::lang::IndexOutOfBoundsException,
255 : css::uno::RuntimeException);
256 :
257 : virtual ::sal_Int32 SAL_CALL getCharacterCount()
258 : throw (css::uno::RuntimeException);
259 :
260 : virtual ::sal_Int32 SAL_CALL
261 : getIndexAtPoint(css::awt::Point const & rPoint)
262 : throw (css::uno::RuntimeException);
263 :
264 : virtual OUString SAL_CALL getSelectedText()
265 : throw (css::uno::RuntimeException);
266 :
267 : virtual ::sal_Int32 SAL_CALL getSelectionStart()
268 : throw (css::uno::RuntimeException);
269 :
270 : virtual ::sal_Int32 SAL_CALL getSelectionEnd()
271 : throw (css::uno::RuntimeException);
272 :
273 : virtual ::sal_Bool SAL_CALL setSelection(::sal_Int32 nStartIndex,
274 : ::sal_Int32 nEndIndex)
275 : throw (css::lang::IndexOutOfBoundsException,
276 : css::uno::RuntimeException);
277 :
278 : virtual OUString SAL_CALL getText()
279 : throw (css::uno::RuntimeException);
280 :
281 : virtual OUString SAL_CALL getTextRange(::sal_Int32 nStartIndex,
282 : ::sal_Int32 nEndIndex)
283 : throw (css::lang::IndexOutOfBoundsException,
284 : css::uno::RuntimeException);
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);
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);
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);
289 :
290 : virtual ::sal_Bool SAL_CALL copyText(::sal_Int32 nStartIndex,
291 : ::sal_Int32 nEndIndex)
292 : throw (css::lang::IndexOutOfBoundsException,
293 : css::uno::RuntimeException);
294 :
295 : virtual ::sal_Bool SAL_CALL cutText(::sal_Int32 nStartIndex,
296 : ::sal_Int32 nEndIndex)
297 : throw (css::lang::IndexOutOfBoundsException,
298 : css::uno::RuntimeException);
299 :
300 : virtual ::sal_Bool SAL_CALL pasteText(::sal_Int32 nIndex)
301 : throw (css::lang::IndexOutOfBoundsException,
302 : css::uno::RuntimeException);
303 :
304 : virtual ::sal_Bool SAL_CALL deleteText(::sal_Int32 nStartIndex,
305 : ::sal_Int32 nEndIndex)
306 : throw (css::lang::IndexOutOfBoundsException,
307 : css::uno::RuntimeException);
308 :
309 : virtual ::sal_Bool SAL_CALL insertText(OUString const & rText,
310 : ::sal_Int32 nIndex)
311 : throw (css::lang::IndexOutOfBoundsException,
312 : css::uno::RuntimeException);
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);
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);
326 :
327 : virtual ::sal_Bool SAL_CALL setText(OUString const & rText)
328 : throw (css::uno::RuntimeException);
329 :
330 : virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
331 : getDefaultAttributes(const css::uno::Sequence< OUString >& RequestedAttributes)
332 : throw (css::uno::RuntimeException);
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);
338 :
339 : virtual ::sal_Int32 SAL_CALL getLineNumberAtIndex( ::sal_Int32 nIndex )
340 : throw (::com::sun::star::lang::IndexOutOfBoundsException,
341 : ::com::sun::star::uno::RuntimeException);
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);
346 :
347 : virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtLineWithCaret( )
348 : throw (::com::sun::star::uno::RuntimeException);
349 :
350 : virtual ::sal_Int32 SAL_CALL getNumberOfLineWithCaret( )
351 : throw (::com::sun::star::uno::RuntimeException);
352 :
353 : virtual void SAL_CALL addAccessibleEventListener(
354 : css::uno::Reference<
355 : css::accessibility::XAccessibleEventListener > const & rListener)
356 : throw (css::uno::RuntimeException);
357 :
358 : virtual void SAL_CALL removeAccessibleEventListener(
359 : css::uno::Reference<
360 : css::accessibility::XAccessibleEventListener > const & rListener)
361 : throw (css::uno::RuntimeException);
362 :
363 : virtual void SAL_CALL disposing();
364 :
365 : virtual OUString implGetText();
366 :
367 : virtual css::lang::Locale implGetLocale();
368 :
369 : virtual void implGetSelection(::sal_Int32 & rStartIndex,
370 : ::sal_Int32 & rEndIndex);
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 ::boost::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, bool bCompoundControlChild);
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 "ParagraphImpl const *" instead of a
407 : // "::rtl::Reference< ParagraphImpl > const &".
408 : ::sal_Int32 retrieveParagraphIndex(ParagraphImpl 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 "ParagraphImpl const *" instead of a
414 : // "::rtl::Reference< ParagraphImpl > const &".
415 : ::sal_Int64 retrieveParagraphState(ParagraphImpl 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 "ParagraphImpl const &" instead of a
421 : // "::rtl::Reference< ParagraphImpl > const &".
422 : css::awt::Rectangle
423 : retrieveParagraphBounds(ParagraphImpl 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 "ParagraphImpl const &" instead of a
429 : // "::rtl::Reference< ParagraphImpl > const &".
430 : OUString retrieveParagraphText(ParagraphImpl 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 "ParagraphImpl const &" instead of a
436 : // "::rtl::Reference< ParagraphImpl > const &".
437 : void retrieveParagraphSelection(ParagraphImpl 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 "ParagraphImpl const *" instead of a
444 : // "::rtl::Reference< ParagraphImpl > const &".
445 : ::sal_Int32 retrieveParagraphCaretPosition(ParagraphImpl 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 "ParagraphImpl const &" instead of a
451 : // "::rtl::Reference< ParagraphImpl > const &".
452 : // Throws css::lang::IndexOutOfBoundsException.
453 : css::awt::Rectangle
454 : retrieveCharacterBounds(ParagraphImpl 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 "ParagraphImpl const &" instead of a
461 : // "::rtl::Reference< ParagraphImpl > const &".
462 : ::sal_Int32 retrieveCharacterIndex(ParagraphImpl 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 "ParagraphImpl const &" instead of a
469 : // "::rtl::Reference< ParagraphImpl > const &".
470 : // Throws css::lang::IndexOutOfBoundsException.
471 : css::uno::Sequence< css::beans::PropertyValue > retrieveCharacterAttributes(
472 : ParagraphImpl 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 "ParagraphImpl const &" instead of a
479 : // "::rtl::Reference< ParagraphImpl > const &".
480 : css::uno::Sequence< css::beans::PropertyValue > retrieveDefaultAttributes(
481 : ParagraphImpl 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 "ParagraphImpl const &" instead of a
488 : // "::rtl::Reference< ParagraphImpl > const &".
489 : // Throws css::lang::IndexOutOfBoundsException.
490 : css::uno::Sequence< css::beans::PropertyValue > retrieveRunAttributes(
491 : ParagraphImpl 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 "ParagraphImpl const &" instead of a
498 : // "::rtl::Reference< ParagraphImpl > const &".
499 : void changeParagraphText(ParagraphImpl * 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 "ParagraphImpl const &" instead of a
506 : // "::rtl::Reference< ParagraphImpl > const &".
507 : // Throws css::lang::IndexOutOfBoundsException.
508 : void changeParagraphText(ParagraphImpl * 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 "ParagraphImpl const &" instead of a
516 : // "::rtl::Reference< ParagraphImpl > const &".
517 : // Throws css::lang::IndexOutOfBoundsException.
518 : void copyParagraphText(ParagraphImpl 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 "ParagraphImpl const &" instead of a
525 : // "::rtl::Reference< ParagraphImpl > const &".
526 : // Throws css::lang::IndexOutOfBoundsException.
527 : void changeParagraphAttributes(
528 : ParagraphImpl * 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 "ParagraphImpl const &" instead of a
536 : // "::rtl::Reference< ParagraphImpl > const &".
537 : // Throws css::lang::IndexOutOfBoundsException.
538 : void changeParagraphSelection(ParagraphImpl * pParagraph,
539 : ::sal_Int32 nBegin, ::sal_Int32 nEnd);
540 :
541 : css::i18n::Boundary
542 : retrieveParagraphLineBoundary( ParagraphImpl const * pParagraph,
543 : ::sal_Int32 nIndex, ::sal_Int32 *pLineNo = NULL);
544 :
545 : css::i18n::Boundary
546 : retrieveParagraphBoundaryOfLine( ParagraphImpl const * pParagraph,
547 : ::sal_Int32 nIndex );
548 :
549 : sal_Int32 retrieveParagraphLineWithCursor( ParagraphImpl const * pParagraph );
550 :
551 : css::uno::Reference< css::accessibility::XAccessibleRelationSet >
552 : retrieveParagraphRelationSet( ParagraphImpl const * pParagraph );
553 :
554 : protected:
555 : // window event listener from base class
556 : virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
557 :
558 : private:
559 : virtual ::sal_Int32 SAL_CALL getAccessibleChildCount()
560 : throw (css::uno::RuntimeException);
561 :
562 : virtual css::uno::Reference< css::accessibility::XAccessible >
563 : SAL_CALL getAccessibleChild(::sal_Int32 i)
564 : throw (css::lang::IndexOutOfBoundsException,
565 : css::uno::RuntimeException);
566 :
567 : virtual ::sal_Int16 SAL_CALL getAccessibleRole()
568 : throw (css::uno::RuntimeException);
569 :
570 : virtual css::uno::Reference< css::accessibility::XAccessible >
571 : SAL_CALL getAccessibleAtPoint(css::awt::Point const & rPoint)
572 : throw (css::uno::RuntimeException);
573 :
574 : // ??? Will be called with both the external (Solar) and internal mutex
575 : // locked:
576 : virtual void SAL_CALL disposing();
577 :
578 : // ??? Will be called with the external (Solar) mutex locked.
579 : // init will already have been called.
580 : virtual void Notify(::SfxBroadcaster & rBC, ::SfxHint const & rHint);
581 :
582 : // Assuming that this will only be called with the external (Solar) mutex
583 : // locked.
584 : // init will already have been called.
585 : DECL_LINK(WindowEventHandler, VclSimpleEvent *);
586 :
587 : // Must be called with both the external (Solar) and internal mutex
588 : // locked.
589 : void init();
590 :
591 : // Must be called with both the external (Solar) and internal mutex
592 : // locked, and after init has been called:
593 : ::rtl::Reference< ParagraphImpl >
594 : getParagraph(Paragraphs::iterator const & rIt);
595 :
596 : // Must be called with both the external (Solar) and internal mutex
597 : // locked, and after init has been called.
598 : // Throws css::uno::RuntimeException.
599 : css::uno::Reference< css::accessibility::XAccessible >
600 : getAccessibleChild(Paragraphs::iterator const & rIt);
601 :
602 : // Must be called with both the external (Solar) and internal mutex
603 : // locked, and after init has been called:
604 : void determineVisibleRange();
605 :
606 : // Must be called with both the external (Solar) and internal mutex
607 : // locked, and after init has been called:
608 : void notifyVisibleRangeChanges(
609 : Paragraphs::iterator const & rOldVisibleBegin,
610 : Paragraphs::iterator const & rOldVisibleEnd,
611 : Paragraphs::iterator const & rInserted);
612 :
613 : // Must be called with both the external (Solar) and internal mutex
614 : // locked, and after init has been called:
615 : void changeParagraphText(::sal_uLong nNumber, ::sal_uInt16 nBegin, ::sal_uInt16 nEnd,
616 : bool bCut, bool bPaste,
617 : OUString const & rText);
618 :
619 : void
620 : handleParagraphNotifications();
621 :
622 : void handleSelectionChangeNotification();
623 :
624 : void notifySelectionChange( sal_Int32 nFirst, sal_Int32 nLast );
625 :
626 : void justifySelection( TextPaM& rTextStart, TextPaM& rTextEnd );
627 :
628 : void disposeParagraphs();
629 :
630 : static css::uno::Any mapFontColor(::Color const & rColor);
631 :
632 : static ::Color mapFontColor(css::uno::Any const & rColor);
633 :
634 : static css::uno::Any mapFontWeight(::FontWeight nWeight);
635 :
636 : static ::FontWeight mapFontWeight(css::uno::Any const & rWeight);
637 :
638 : void retrieveDefaultAttributesImpl(
639 : ParagraphImpl const * pParagraph,
640 : const css::uno::Sequence< OUString >& RequestedAttributes,
641 : tPropValMap& rDefAttrSeq);
642 :
643 : void retrieveRunAttributesImpl(
644 : ParagraphImpl const * pParagraph, ::sal_Int32 Index,
645 : const css::uno::Sequence< OUString >& RequestedAttributes,
646 : tPropValMap& rRunAttrSeq);
647 :
648 : static css::uno::Sequence< css::beans::PropertyValue >
649 : convertHashMapToSequence(tPropValMap& rAttrSeq);
650 :
651 : css::uno::Reference< css::accessibility::XAccessible > m_xAccessible;
652 : ::TextEngine & m_rEngine;
653 : ::TextView & m_rView;
654 :
655 : SfxListenerGuard m_aEngineListener;
656 : WindowListenerGuard m_aViewListener;
657 :
658 : // All the following members have valid values only after calling init:
659 :
660 : ::std::auto_ptr< Paragraphs > m_xParagraphs;
661 :
662 : // m_nViewOffset is from the start of the document (0) to the start of the
663 : // current view, and m_nViewHeight is the height of the view:
664 : ::sal_Int32 m_nViewOffset;
665 : ::sal_Int32 m_nViewHeight;
666 :
667 : // m_aVisibleBegin points to the first Paragraph that is (partially)
668 : // contained in the view, and m_aVisibleEnd points past the last Paragraph
669 : // that is (partially) contained. If no Paragraphs are (partially) in the
670 : // view, both m_aVisibleBegin and m_aVisibleEnd are set to
671 : // m_xParagraphs->end(). These values are only changed by
672 : // determineVisibleRange.
673 : Paragraphs::iterator m_aVisibleBegin;
674 : Paragraphs::iterator m_aVisibleEnd;
675 :
676 : // m_nVisibleBeginOffset is from m_nViewOffset back to the start of the
677 : // Paragraph pointed to by m_aVisibleBegin (and always has a non-negative
678 : // value). If m_aVisibleBegin == m_xParagraphs->end(),
679 : // m_nVisibleBeginOffset is set to 0. These values are only changed by
680 : // determineVisibleRange.
681 : ::sal_Int32 m_nVisibleBeginOffset;
682 :
683 : // If no selection has yet been set, all the following four variables are
684 : // set to -1. m_nSelectionLastPara/Pos is also the cursor position.
685 : ::sal_Int32 m_nSelectionFirstPara;
686 : ::sal_Int32 m_nSelectionFirstPos;
687 : ::sal_Int32 m_nSelectionLastPara;
688 : ::sal_Int32 m_nSelectionLastPos;
689 :
690 : Paragraphs::iterator m_aFocused;
691 :
692 : ::std::queue< ::TextHint > m_aParagraphNotifications;
693 : bool m_bSelectionChangedNotification;
694 : bool m_bCompoundControlChild;
695 : };
696 :
697 : }
698 :
699 : #endif // INCLUDED_ACCESSIBILITY_TEXTWINDOWACCESSIBILITY_HXX
700 :
701 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|