Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "PresenterAccessibility.hxx"
30 : : #include "PresenterTextView.hxx"
31 : : #include "PresenterConfigurationAccess.hxx"
32 : : #include "PresenterNotesView.hxx"
33 : : #include "PresenterPaneBase.hxx"
34 : : #include "PresenterPaneContainer.hxx"
35 : : #include "PresenterPaneFactory.hxx"
36 : : #include "PresenterViewFactory.hxx"
37 : :
38 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39 : : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
40 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 : : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
42 : : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
43 : : #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
44 : : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
45 : : #include <com/sun/star/accessibility/XAccessibleText.hpp>
46 : : #include <com/sun/star/drawing/framework/ResourceId.hpp>
47 : : #include <com/sun/star/drawing/framework/XPane.hpp>
48 : : #include <com/sun/star/drawing/framework/XView.hpp>
49 : : #include <cppuhelper/compbase1.hxx>
50 : : #include <cppuhelper/compbase5.hxx>
51 : : #include <cppuhelper/implbase1.hxx>
52 : : #include <boost/bind.hpp>
53 : :
54 : : using namespace ::com::sun::star;
55 : : using namespace ::com::sun::star::accessibility;
56 : : using namespace ::com::sun::star::uno;
57 : : using namespace ::com::sun::star::drawing::framework;
58 : : using ::rtl::OUString;
59 : :
60 : : #define A2S(s) (::rtl::OUString(s))
61 : :
62 : : //===== PresenterAccessibleObject =============================================
63 : :
64 : : namespace sdext { namespace presenter {
65 : :
66 : : namespace {
67 : : typedef ::cppu::PartialWeakComponentImplHelper5 <
68 : : cssa::XAccessible,
69 : : cssa::XAccessibleContext,
70 : : cssa::XAccessibleComponent,
71 : : cssa::XAccessibleEventBroadcaster,
72 : : css::awt::XWindowListener
73 : : > PresenterAccessibleObjectInterfaceBase;
74 : : }
75 : :
76 : : class PresenterAccessible::AccessibleObject
77 : : : public ::cppu::BaseMutex,
78 : : public PresenterAccessibleObjectInterfaceBase
79 : : {
80 : : public:
81 : : AccessibleObject (
82 : : const css::lang::Locale aLocale,
83 : : const sal_Int16 nRole,
84 : : const ::rtl::OUString& rsName);
85 : : void LateInitialization (void);
86 : :
87 : : virtual ~AccessibleObject (void);
88 : :
89 : : virtual void SetWindow (
90 : : const cssu::Reference<css::awt::XWindow>& rxContentWindow,
91 : : const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
92 : : void SetAccessibleParent (const cssu::Reference<cssa::XAccessible>& rxAccessibleParent);
93 : :
94 : : virtual void SAL_CALL disposing (void);
95 : :
96 : : void NotifyCurrentSlideChange (const sal_Int32 nCurrentSlideIndex);
97 : :
98 : : void AddChild (const ::rtl::Reference<AccessibleObject>& rpChild);
99 : : void RemoveChild (const ::rtl::Reference<AccessibleObject>& rpChild);
100 : :
101 : : void SetIsFocused (const bool bIsFocused);
102 : : void SetAccessibleName (const ::rtl::OUString& rsName);
103 : :
104 : : void FireAccessibleEvent (
105 : : const sal_Int16 nEventId,
106 : : const cssu::Any& rOldValue,
107 : : const cssu::Any& rNewValue);
108 : :
109 : : void UpdateStateSet (void);
110 : :
111 : : //----- XComponent ---------------------------------------------------
112 : :
113 : 0 : virtual void SAL_CALL dispose()throw (cssu::RuntimeException)
114 : 0 : { WeakComponentImplHelperBase::dispose(); }
115 : 0 : virtual void SAL_CALL addEventListener(const cssu::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (cssu::RuntimeException)
116 : 0 : { WeakComponentImplHelperBase::addEventListener(xListener); }
117 : 0 : virtual void SAL_CALL removeEventListener(const cssu::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (cssu::RuntimeException)
118 : 0 : { WeakComponentImplHelperBase::removeEventListener(xListener); }
119 : :
120 : : //----- XAccessible -------------------------------------------------------
121 : :
122 : : virtual cssu::Reference<cssa::XAccessibleContext> SAL_CALL
123 : : getAccessibleContext (void)
124 : : throw (cssu::RuntimeException);
125 : :
126 : : //----- XAccessibleContext ----------------------------------------------
127 : :
128 : : virtual sal_Int32 SAL_CALL getAccessibleChildCount (void)
129 : : throw (cssu::RuntimeException);
130 : :
131 : : virtual cssu::Reference< cssa::XAccessible> SAL_CALL
132 : : getAccessibleChild (sal_Int32 nIndex)
133 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
134 : :
135 : : virtual cssu::Reference< cssa::XAccessible> SAL_CALL getAccessibleParent (void)
136 : : throw (cssu::RuntimeException);
137 : :
138 : : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void)
139 : : throw (cssu::RuntimeException);
140 : :
141 : : virtual sal_Int16 SAL_CALL getAccessibleRole (void)
142 : : throw (cssu::RuntimeException);
143 : :
144 : : virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void)
145 : : throw (cssu::RuntimeException);
146 : :
147 : : virtual ::rtl::OUString SAL_CALL getAccessibleName (void)
148 : : throw (cssu::RuntimeException);
149 : :
150 : : virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
151 : : getAccessibleRelationSet (void)
152 : : throw (cssu::RuntimeException);
153 : :
154 : : virtual cssu::Reference<cssa::XAccessibleStateSet> SAL_CALL
155 : : getAccessibleStateSet (void)
156 : : throw (cssu::RuntimeException);
157 : :
158 : : virtual css::lang::Locale SAL_CALL getLocale (void)
159 : : throw (cssu::RuntimeException,
160 : : cssa::IllegalAccessibleComponentStateException);
161 : :
162 : : //----- XAccessibleComponent --------------------------------------------
163 : :
164 : : virtual sal_Bool SAL_CALL containsPoint (
165 : : const css::awt::Point& aPoint)
166 : : throw (cssu::RuntimeException);
167 : :
168 : : virtual cssu::Reference<cssa::XAccessible> SAL_CALL
169 : : getAccessibleAtPoint (
170 : : const css::awt::Point& aPoint)
171 : : throw (cssu::RuntimeException);
172 : :
173 : : virtual css::awt::Rectangle SAL_CALL getBounds (void)
174 : : throw (cssu::RuntimeException);
175 : :
176 : : virtual css::awt::Point SAL_CALL getLocation (void)
177 : : throw (cssu::RuntimeException);
178 : :
179 : : virtual css::awt::Point SAL_CALL getLocationOnScreen (void)
180 : : throw (cssu::RuntimeException);
181 : :
182 : : virtual css::awt::Size SAL_CALL getSize (void)
183 : : throw (cssu::RuntimeException);
184 : :
185 : : virtual void SAL_CALL grabFocus (void)
186 : : throw (cssu::RuntimeException);
187 : :
188 : : virtual sal_Int32 SAL_CALL getForeground (void)
189 : : throw (cssu::RuntimeException);
190 : :
191 : : virtual sal_Int32 SAL_CALL getBackground (void)
192 : : throw (cssu::RuntimeException);
193 : :
194 : : //----- XAccessibleEventBroadcaster --------------------------------------
195 : :
196 : : virtual void SAL_CALL addEventListener (
197 : : const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
198 : : throw (cssu::RuntimeException);
199 : :
200 : : virtual void SAL_CALL removeEventListener (
201 : : const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
202 : : throw (cssu::RuntimeException);
203 : :
204 : : //----- XWindowListener ---------------------------------------------------
205 : :
206 : : virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
207 : : throw (cssu::RuntimeException);
208 : :
209 : : virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
210 : : throw (cssu::RuntimeException);
211 : :
212 : : virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
213 : : throw (cssu::RuntimeException);
214 : :
215 : : virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
216 : : throw (cssu::RuntimeException);
217 : :
218 : : //----- XEventListener ----------------------------------------------------
219 : :
220 : : virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
221 : : throw (cssu::RuntimeException);
222 : :
223 : : protected:
224 : : ::rtl::OUString msName;
225 : : cssu::Reference<css::awt::XWindow2> mxContentWindow;
226 : : cssu::Reference<css::awt::XWindow2> mxBorderWindow;
227 : : const css::lang::Locale maLocale;
228 : : const sal_Int16 mnRole;
229 : : sal_uInt32 mnStateSet;
230 : : bool mbIsFocused;
231 : : cssu::Reference<cssa::XAccessible> mxParentAccessible;
232 : : ::std::vector<rtl::Reference<AccessibleObject> > maChildren;
233 : : ::std::vector<Reference<XAccessibleEventListener> > maListeners;
234 : :
235 : : virtual awt::Point GetRelativeLocation (void);
236 : : virtual awt::Size GetSize (void);
237 : : virtual awt::Point GetAbsoluteParentLocation (void);
238 : :
239 : : virtual bool GetWindowState (const sal_Int16 nType) const;
240 : :
241 : : void UpdateState (const sal_Int16 aState, const bool bValue);
242 : :
243 : : sal_Bool IsDisposed (void) const;
244 : :
245 : : void ThrowIfDisposed (void) const
246 : : throw (css::lang::DisposedException);
247 : :
248 : : enum ExceptionType { ET_Runtime, ET_Disposed, ET_IndexOutOfBounds };
249 : : void ThrowException (const sal_Char* pMessage, const ExceptionType eExceptionType) const;
250 : : };
251 : :
252 : : //===== AccessibleStateSet ====================================================
253 : :
254 : : namespace {
255 : : typedef ::cppu::WeakComponentImplHelper1 <
256 : : cssa::XAccessibleStateSet
257 : : > AccessibleStateSetInterfaceBase;
258 : : }
259 : :
260 : : class AccessibleStateSet
261 : : : public ::cppu::BaseMutex,
262 : : public AccessibleStateSetInterfaceBase
263 : : {
264 : : public:
265 : : AccessibleStateSet (const sal_Int32 nStateSet);
266 : : virtual ~AccessibleStateSet (void);
267 : :
268 : : static sal_uInt32 GetStateMask (const sal_Int16 nType);
269 : :
270 : : //----- XAccessibleStateSet -----------------------------------------------
271 : :
272 : : virtual sal_Bool SAL_CALL isEmpty (void)
273 : : throw (cssu::RuntimeException);
274 : :
275 : : virtual sal_Bool SAL_CALL contains (sal_Int16 nState)
276 : : throw (cssu::RuntimeException);
277 : :
278 : : virtual sal_Bool SAL_CALL containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
279 : : throw (cssu::RuntimeException);
280 : :
281 : : virtual cssu::Sequence<sal_Int16> SAL_CALL getStates (void)
282 : : throw (cssu::RuntimeException);
283 : :
284 : : private:
285 : : const sal_Int32 mnStateSet;
286 : : };
287 : :
288 : : //===== AccessibleRelationSet =================================================
289 : :
290 : : namespace {
291 : : typedef ::cppu::WeakComponentImplHelper1 <
292 : : cssa::XAccessibleRelationSet
293 : : > AccessibleRelationSetInterfaceBase;
294 : : }
295 : :
296 : : class AccessibleRelationSet
297 : : : public ::cppu::BaseMutex,
298 : : public AccessibleRelationSetInterfaceBase
299 : : {
300 : : public:
301 : : AccessibleRelationSet (void);
302 : : virtual ~AccessibleRelationSet (void);
303 : :
304 : : void AddRelation (
305 : : const sal_Int16 nRelationType,
306 : : const Reference<XInterface>& rxObject);
307 : :
308 : : //----- XAccessibleRelationSet --------------------------------------------
309 : :
310 : : virtual sal_Int32 SAL_CALL getRelationCount (void)
311 : : throw (cssu::RuntimeException);
312 : :
313 : : virtual AccessibleRelation SAL_CALL getRelation (sal_Int32 nIndex)
314 : : throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException);
315 : :
316 : : virtual sal_Bool SAL_CALL containsRelation (sal_Int16 nRelationType)
317 : : throw (cssu::RuntimeException);
318 : :
319 : : virtual AccessibleRelation SAL_CALL getRelationByType (sal_Int16 nRelationType)
320 : : throw (cssu::RuntimeException);
321 : :
322 : : private:
323 : : ::std::vector<AccessibleRelation> maRelations;
324 : : };
325 : :
326 : : //===== PresenterAccessibleParagraph ==========================================
327 : :
328 : : namespace {
329 : : typedef ::cppu::ImplInheritanceHelper1 <
330 : : PresenterAccessible::AccessibleObject,
331 : : cssa::XAccessibleText
332 : : > PresenterAccessibleParagraphInterfaceBase;
333 : : }
334 : :
335 : : class PresenterAccessible::AccessibleParagraph
336 : : : public PresenterAccessibleParagraphInterfaceBase
337 : : {
338 : : public:
339 : : AccessibleParagraph (
340 : : const css::lang::Locale aLocale,
341 : : const sal_Int16 nRole,
342 : : const ::rtl::OUString& rsName,
343 : : const SharedPresenterTextParagraph& rpParagraph,
344 : : const sal_Int32 nParagraphIndex);
345 : :
346 : : virtual ~AccessibleParagraph (void);
347 : :
348 : : //----- XAccessibleContext ------------------------------------------------
349 : :
350 : : virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
351 : : getAccessibleRelationSet (void)
352 : : throw (cssu::RuntimeException);
353 : :
354 : : //----- XAccessibleText ---------------------------------------------------
355 : :
356 : : virtual sal_Int32 SAL_CALL getCaretPosition (void)
357 : : throw (cssu::RuntimeException);
358 : :
359 : : virtual sal_Bool SAL_CALL setCaretPosition (sal_Int32 nIndex)
360 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
361 : :
362 : : virtual sal_Unicode SAL_CALL getCharacter (sal_Int32 nIndex)
363 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
364 : :
365 : : virtual cssu::Sequence<css::beans::PropertyValue> SAL_CALL
366 : : getCharacterAttributes (
367 : : ::sal_Int32 nIndex,
368 : : const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
369 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
370 : :
371 : : virtual css::awt::Rectangle SAL_CALL getCharacterBounds (sal_Int32 nIndex)
372 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
373 : :
374 : : virtual sal_Int32 SAL_CALL getCharacterCount (void)
375 : : throw (cssu::RuntimeException);
376 : :
377 : : virtual sal_Int32 SAL_CALL getIndexAtPoint (const css::awt::Point& rPoint)
378 : : throw (cssu::RuntimeException);
379 : :
380 : : virtual ::rtl::OUString SAL_CALL getSelectedText (void)
381 : : throw (cssu::RuntimeException);
382 : :
383 : : virtual sal_Int32 SAL_CALL getSelectionStart (void)
384 : : throw (cssu::RuntimeException);
385 : :
386 : : virtual sal_Int32 SAL_CALL getSelectionEnd (void)
387 : : throw (cssu::RuntimeException);
388 : :
389 : : virtual sal_Bool SAL_CALL setSelection (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
390 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
391 : :
392 : : virtual ::rtl::OUString SAL_CALL getText (void)
393 : : throw (cssu::RuntimeException);
394 : :
395 : : virtual ::rtl::OUString SAL_CALL getTextRange (
396 : : sal_Int32 nStartIndex,
397 : : sal_Int32 nEndIndex)
398 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
399 : :
400 : : virtual cssa::TextSegment SAL_CALL getTextAtIndex (
401 : : sal_Int32 nIndex,
402 : : sal_Int16 nTextType)
403 : : throw (css::lang::IndexOutOfBoundsException,
404 : : css::lang::IllegalArgumentException,
405 : : cssu::RuntimeException);
406 : :
407 : : virtual cssa::TextSegment SAL_CALL getTextBeforeIndex (
408 : : sal_Int32 nIndex,
409 : : sal_Int16 nTextType)
410 : : throw (css::lang::IndexOutOfBoundsException,
411 : : css::lang::IllegalArgumentException,
412 : : cssu::RuntimeException);
413 : :
414 : : virtual cssa::TextSegment SAL_CALL getTextBehindIndex (
415 : : sal_Int32 nIndex,
416 : : sal_Int16 nTextType)
417 : : throw (css::lang::IndexOutOfBoundsException,
418 : : css::lang::IllegalArgumentException,
419 : : cssu::RuntimeException);
420 : :
421 : : virtual ::sal_Bool SAL_CALL copyText (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
422 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
423 : :
424 : : protected:
425 : : virtual awt::Point GetRelativeLocation (void);
426 : : virtual awt::Size GetSize (void);
427 : : virtual awt::Point GetAbsoluteParentLocation (void);
428 : : virtual bool GetWindowState (const sal_Int16 nType) const;
429 : :
430 : : private:
431 : : SharedPresenterTextParagraph mpParagraph;
432 : : const sal_Int32 mnParagraphIndex;
433 : : };
434 : :
435 : : //===== AccessibleConsole =====================================================
436 : :
437 : : class AccessibleConsole
438 : : {
439 : : public:
440 : 0 : static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
441 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
442 : : const lang::Locale aLocale)
443 : : {
444 : 0 : OUString sName (A2S("Presenter Console"));
445 : : PresenterConfigurationAccess aConfiguration (
446 : : rxContext,
447 : : OUString("/org.openoffice.Office.extension.PresenterScreen/"),
448 [ # # ]: 0 : PresenterConfigurationAccess::READ_ONLY);
449 : : aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Console/String"))
450 [ # # ]: 0 : >>= sName;
451 : :
452 : : rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
453 : : new PresenterAccessible::AccessibleObject(
454 [ # # ]: 0 : aLocale, AccessibleRole::PANEL, sName));
455 [ # # ]: 0 : pObject->LateInitialization();
456 [ # # ]: 0 : pObject->UpdateStateSet();
457 : :
458 [ # # ]: 0 : return pObject;
459 : : }
460 : : };
461 : :
462 : : //===== AccessiblePreview =====================================================
463 : :
464 : : class AccessiblePreview
465 : : {
466 : : public:
467 : 0 : static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
468 : : const Reference<css::uno::XComponentContext>& rxContext,
469 : : const lang::Locale aLocale,
470 : : const Reference<awt::XWindow>& rxContentWindow,
471 : : const Reference<awt::XWindow>& rxBorderWindow)
472 : : {
473 : 0 : OUString sName (A2S("Presenter Notes Window"));
474 : : {
475 : : PresenterConfigurationAccess aConfiguration (
476 : : rxContext,
477 : : OUString("/org.openoffice.Office.extension.PresenterScreen/"),
478 [ # # ]: 0 : PresenterConfigurationAccess::READ_ONLY);
479 : : aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Preview/String"))
480 [ # # ][ # # ]: 0 : >>= sName;
481 : : }
482 : :
483 : : rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
484 : : new PresenterAccessible::AccessibleObject(
485 : : aLocale,
486 : : AccessibleRole::LABEL,
487 [ # # ]: 0 : sName));
488 [ # # ]: 0 : pObject->LateInitialization();
489 [ # # ]: 0 : pObject->UpdateStateSet();
490 [ # # ]: 0 : pObject->SetWindow(rxContentWindow, rxBorderWindow);
491 : :
492 : 0 : return pObject;
493 : : }
494 : : };
495 : :
496 : : //===== AccessibleNotes =======================================================
497 : :
498 [ # # ][ # # ]: 0 : class AccessibleNotes : public PresenterAccessible::AccessibleObject
499 : : {
500 : : public:
501 : : AccessibleNotes (
502 : : const css::lang::Locale aLocale,
503 : : const sal_Int16 nRole,
504 : : const ::rtl::OUString& rsName);
505 : :
506 : : static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
507 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
508 : : const lang::Locale aLocale,
509 : : const Reference<awt::XWindow>& rxContentWindow,
510 : : const Reference<awt::XWindow>& rxBorderWindow,
511 : : const ::boost::shared_ptr<PresenterTextView>& rpTextView);
512 : :
513 : : void SetTextView (const ::boost::shared_ptr<PresenterTextView>& rpTextView);
514 : :
515 : : virtual void SetWindow (
516 : : const cssu::Reference<css::awt::XWindow>& rxContentWindow,
517 : : const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
518 : :
519 : : private:
520 : : ::boost::shared_ptr<PresenterTextView> mpTextView;
521 : :
522 : : void NotifyCaretChange (
523 : : const sal_Int32 nOldParagraphIndex,
524 : : const sal_Int32 nOldCharacterIndex,
525 : : const sal_Int32 nNewParagraphIndex,
526 : : const sal_Int32 nNewCharacterIndex);
527 : : void HandleTextChange (void);
528 : : };
529 : :
530 : : //===== AccessibleFocusManager ================================================
531 : :
532 : : /** A singleton class that makes sure that only one accessibility object in
533 : : the PresenterConsole hierarchy has the focus.
534 : : */
535 : 0 : class AccessibleFocusManager
536 : : {
537 : : public:
538 : : static ::boost::shared_ptr<AccessibleFocusManager> Instance (void);
539 : :
540 : : void AddFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
541 : : void RemoveFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
542 : :
543 : : void FocusObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
544 : :
545 : : private:
546 : : static ::boost::shared_ptr<AccessibleFocusManager> mpInstance;
547 : : ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > maFocusableObjects;
548 : :
549 : : AccessibleFocusManager (void);
550 : : };
551 : :
552 : : //===== PresenterAccessible ===================================================
553 : :
554 : 0 : PresenterAccessible::PresenterAccessible (
555 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
556 : : const ::rtl::Reference<PresenterController>& rpPresenterController,
557 : : const Reference<drawing::framework::XPane>& rxMainPane)
558 : : : PresenterAccessibleInterfaceBase(m_aMutex),
559 : : mxComponentContext(rxContext),
560 : : mpPresenterController(rpPresenterController),
561 [ # # ]: 0 : mxMainPaneId(rxMainPane.is() ? rxMainPane->getResourceId() : Reference<XResourceId>()),
562 : : mxMainPane(rxMainPane, UNO_QUERY),
563 : : mxMainWindow(),
564 : : mxPreviewContentWindow(),
565 : : mxPreviewBorderWindow(),
566 : : mxNotesContentWindow(),
567 : : mxNotesBorderWindow(),
568 : : mpAccessibleConsole(),
569 : : mpAccessiblePreview(),
570 : : mpAccessibleNotes(),
571 [ # # ][ # # ]: 0 : mxAccessibleParent()
[ # # ]
572 : : {
573 [ # # ]: 0 : if (mxMainPane.is())
574 [ # # ][ # # ]: 0 : mxMainPane->setAccessible(this);
[ # # ]
575 : 0 : }
576 : :
577 [ # # ]: 0 : PresenterAccessible::~PresenterAccessible (void)
578 : : {
579 [ # # ]: 0 : }
580 : :
581 : 0 : PresenterPaneContainer::SharedPaneDescriptor PresenterAccessible::GetPreviewPane (void) const
582 : : {
583 [ # # ]: 0 : PresenterPaneContainer::SharedPaneDescriptor pPreviewPane;
584 : :
585 [ # # ]: 0 : if ( ! mpPresenterController.is())
586 : : return pPreviewPane;
587 : :
588 [ # # ]: 0 : rtl::Reference<PresenterPaneContainer> pContainer (mpPresenterController->GetPaneContainer());
589 [ # # ]: 0 : if ( ! pContainer.is())
590 : : return pPreviewPane;
591 : :
592 [ # # ][ # # ]: 0 : pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
[ # # ]
593 : 0 : Reference<drawing::framework::XPane> xPreviewPane;
594 [ # # ]: 0 : if (pPreviewPane)
595 [ # # ][ # # ]: 0 : xPreviewPane = pPreviewPane->mxPane.get();
596 [ # # ]: 0 : if ( ! xPreviewPane.is())
597 : : {
598 [ # # ][ # # ]: 0 : pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msSlideSorterPaneURL);
[ # # ]
599 : : }
600 : 0 : return pPreviewPane;
601 : : }
602 : :
603 : 0 : void PresenterAccessible::UpdateAccessibilityHierarchy (void)
604 : : {
605 [ # # ]: 0 : if ( ! mpPresenterController.is())
606 : : return;
607 : :
608 : : Reference<drawing::framework::XConfigurationController> xConfigurationController(
609 [ # # ]: 0 : mpPresenterController->GetConfigurationController());
610 [ # # ]: 0 : if ( ! xConfigurationController.is())
611 : : return;
612 : :
613 : : rtl::Reference<PresenterPaneContainer> pPaneContainer (
614 [ # # ]: 0 : mpPresenterController->GetPaneContainer());
615 [ # # ]: 0 : if ( ! pPaneContainer.is())
616 : : return;
617 : :
618 [ # # ]: 0 : if ( ! mpAccessibleConsole.is())
619 : : return;
620 : :
621 : : // Get the preview pane (standard or notes view) or the slide overview
622 : : // pane.
623 [ # # ]: 0 : PresenterPaneContainer::SharedPaneDescriptor pPreviewPane(GetPreviewPane());
624 : 0 : Reference<drawing::framework::XPane> xPreviewPane;
625 [ # # ]: 0 : if (pPreviewPane)
626 [ # # ][ # # ]: 0 : xPreviewPane = pPreviewPane->mxPane.get();
627 : :
628 : : // Get the notes pane.
629 : : PresenterPaneContainer::SharedPaneDescriptor pNotesPane(
630 [ # # ]: 0 : pPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
631 : 0 : Reference<drawing::framework::XPane> xNotesPane;
632 [ # # ]: 0 : if (pNotesPane)
633 [ # # ][ # # ]: 0 : xNotesPane = pNotesPane->mxPane.get();
634 : :
635 : : // Get the notes view.
636 : 0 : Reference<drawing::framework::XView> xNotesView;
637 [ # # ]: 0 : if (pNotesPane)
638 [ # # ]: 0 : xNotesView = pNotesPane->mxView;
639 : : rtl::Reference<PresenterNotesView> pNotesView (
640 [ # # ][ # # ]: 0 : dynamic_cast<PresenterNotesView*>(xNotesView.get()));
641 : :
642 : : UpdateAccessibilityHierarchy(
643 : 0 : pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(),
644 : 0 : pPreviewPane ? pPreviewPane->mxBorderWindow : Reference<awt::XWindow>(),
645 : 0 : (pPreviewPane&&pPreviewPane->mxPane.is()) ? pPreviewPane->mxPane->GetTitle() : OUString(),
646 : 0 : pNotesPane ? pNotesPane->mxContentWindow : Reference<awt::XWindow>(),
647 : 0 : pNotesPane ? pNotesPane->mxBorderWindow : Reference<awt::XWindow>(),
648 : 0 : pNotesView.is()
649 : : ? pNotesView->GetTextView()
650 [ # # ]: 0 : : ::boost::shared_ptr<PresenterTextView>());
[ # # # # ]
[ # # ][ # #
# # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
651 : : }
652 : :
653 : 0 : void PresenterAccessible::UpdateAccessibilityHierarchy (
654 : : const Reference<awt::XWindow>& rxPreviewContentWindow,
655 : : const Reference<awt::XWindow>& rxPreviewBorderWindow,
656 : : const ::rtl::OUString& rsTitle,
657 : : const Reference<awt::XWindow>& rxNotesContentWindow,
658 : : const Reference<awt::XWindow>& rxNotesBorderWindow,
659 : : const ::boost::shared_ptr<PresenterTextView>& rpNotesTextView)
660 : : {
661 [ # # ]: 0 : if ( ! mpAccessibleConsole.is())
662 : 0 : return;
663 : :
664 [ # # ]: 0 : if (mxPreviewContentWindow != rxPreviewContentWindow)
665 : : {
666 [ # # ]: 0 : if (mpAccessiblePreview.is())
667 : : {
668 : 0 : mpAccessibleConsole->RemoveChild(mpAccessiblePreview);
669 : 0 : mpAccessiblePreview = NULL;
670 : : }
671 : :
672 : 0 : mxPreviewContentWindow = rxPreviewContentWindow;
673 : 0 : mxPreviewBorderWindow = rxPreviewBorderWindow;
674 : :
675 [ # # ]: 0 : if (mxPreviewContentWindow.is())
676 : : {
677 : : mpAccessiblePreview = AccessiblePreview::Create(
678 : : mxComponentContext,
679 : : lang::Locale(),
680 : : mxPreviewContentWindow,
681 [ # # ][ # # ]: 0 : mxPreviewBorderWindow);
682 : 0 : mpAccessibleConsole->AddChild(mpAccessiblePreview);
683 : 0 : mpAccessiblePreview->SetAccessibleName(rsTitle);
684 : : }
685 : : }
686 : :
687 [ # # ]: 0 : if (mxNotesContentWindow != rxNotesContentWindow)
688 : : {
689 [ # # ]: 0 : if (mpAccessibleNotes.is())
690 : : {
691 : 0 : mpAccessibleConsole->RemoveChild(mpAccessibleNotes);
692 : 0 : mpAccessibleNotes = NULL;
693 : : }
694 : :
695 : 0 : mxNotesContentWindow = rxNotesContentWindow;
696 : 0 : mxNotesBorderWindow = rxNotesBorderWindow;
697 : :
698 [ # # ]: 0 : if (mxNotesContentWindow.is())
699 : : {
700 : : mpAccessibleNotes = AccessibleNotes::Create(
701 : : mxComponentContext,
702 : : lang::Locale(),
703 : : mxNotesContentWindow,
704 : : mxNotesBorderWindow,
705 [ # # ][ # # ]: 0 : rpNotesTextView);
706 [ # # ]: 0 : mpAccessibleConsole->AddChild(mpAccessibleNotes.get());
707 : : }
708 : : }
709 : : }
710 : :
711 : 0 : void PresenterAccessible::NotifyCurrentSlideChange (
712 : : const sal_Int32 nCurrentSlideIndex,
713 : : const sal_Int32 nSlideCount)
714 : : {
715 : : (void)nCurrentSlideIndex;
716 : : (void)nSlideCount;
717 : :
718 [ # # ]: 0 : if (mpAccessiblePreview.is())
719 : : {
720 [ # # ]: 0 : PresenterPaneContainer::SharedPaneDescriptor pPreviewPane (GetPreviewPane());
721 : : mpAccessiblePreview->SetAccessibleName(
722 : 0 : (pPreviewPane&&pPreviewPane->mxPane.is()
723 : 0 : ? pPreviewPane->mxPane->GetTitle()
724 [ # # ][ # # ]: 0 : : rtl::OUString()));
[ # # # #
# # ]
725 : : }
726 : :
727 : : // Play some focus ping-pong to trigger AT tools.
728 : : //AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
729 [ # # ]: 0 : AccessibleFocusManager::Instance()->FocusObject(mpAccessiblePreview);
730 : 0 : }
731 : :
732 : 0 : void SAL_CALL PresenterAccessible::disposing (void)
733 : : {
734 : : UpdateAccessibilityHierarchy(
735 : : NULL,
736 : : NULL,
737 : : OUString(),
738 : : NULL,
739 : : NULL,
740 [ # # ][ # # ]: 0 : ::boost::shared_ptr<PresenterTextView>());
[ # # ][ # # ]
[ # # ]
741 : :
742 [ # # ]: 0 : if (mxMainWindow.is())
743 : : {
744 [ # # ]: 0 : mxMainWindow->removeFocusListener(this);
745 : :
746 [ # # ]: 0 : if (mxMainPane.is())
747 [ # # ]: 0 : mxMainPane->setAccessible(NULL);
748 : : }
749 : :
750 : 0 : mpAccessiblePreview = NULL;
751 : 0 : mpAccessibleNotes = NULL;
752 : 0 : mpAccessibleConsole = NULL;
753 : 0 : }
754 : :
755 : : //----- XAccessible -----------------------------------------------------------
756 : :
757 : 0 : Reference<XAccessibleContext> SAL_CALL PresenterAccessible::getAccessibleContext (void)
758 : : throw (cssu::RuntimeException)
759 : : {
760 [ # # ]: 0 : if ( ! mpAccessibleConsole.is())
761 : : {
762 [ # # ]: 0 : Reference<XPane> xMainPane (mxMainPane, UNO_QUERY);
763 [ # # ]: 0 : if (xMainPane.is())
764 : : {
765 [ # # ][ # # ]: 0 : mxMainWindow = Reference<awt::XWindow>(xMainPane->getWindow(), UNO_QUERY);
[ # # ][ # # ]
766 [ # # ][ # # ]: 0 : mxMainWindow->addFocusListener(this);
[ # # ]
767 : : }
768 : : mpAccessibleConsole = AccessibleConsole::Create(
769 [ # # ][ # # ]: 0 : mxComponentContext, css::lang::Locale());
770 [ # # ][ # # ]: 0 : mpAccessibleConsole->SetWindow(mxMainWindow, NULL);
771 [ # # ]: 0 : mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
772 [ # # ]: 0 : UpdateAccessibilityHierarchy();
773 [ # # ]: 0 : if (mpPresenterController.is())
774 [ # # ]: 0 : mpPresenterController->SetAccessibilityActiveState(true);
775 : : }
776 : 0 : return mpAccessibleConsole->getAccessibleContext();
777 : : }
778 : :
779 : : //----- XFocusListener ----------------------------------------------------
780 : :
781 : 0 : void SAL_CALL PresenterAccessible::focusGained (const css::awt::FocusEvent& rEvent)
782 : : throw (cssu::RuntimeException)
783 : : {
784 : : (void)rEvent;
785 : : SAL_INFO("sdext.presenter", OSL_THIS_FUNC << ": PresenterAccessible::focusGained at " << this
786 : : << " and window " << mxMainWindow.get());
787 [ # # ]: 0 : AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
788 : 0 : }
789 : :
790 : 0 : void SAL_CALL PresenterAccessible::focusLost (const css::awt::FocusEvent& rEvent)
791 : : throw (cssu::RuntimeException)
792 : : {
793 : : (void)rEvent;
794 : : SAL_INFO("sdext.presenter", OSL_THIS_FUNC << ": PresenterAccessible::focusLost at " << this);
795 [ # # ][ # # ]: 0 : AccessibleFocusManager::Instance()->FocusObject(NULL);
[ # # ]
796 : 0 : }
797 : :
798 : : //----- XEventListener ----------------------------------------------------
799 : :
800 : 0 : void SAL_CALL PresenterAccessible::disposing (const css::lang::EventObject& rEvent)
801 : : throw (cssu::RuntimeException)
802 : : {
803 [ # # ]: 0 : if (rEvent.Source == mxMainWindow)
804 : 0 : mxMainWindow = NULL;
805 : 0 : }
806 : :
807 : : //----- XInitialize -----------------------------------------------------------
808 : :
809 : 0 : void SAL_CALL PresenterAccessible::initialize (const cssu::Sequence<cssu::Any>& rArguments)
810 : : throw (cssu::RuntimeException)
811 : : {
812 [ # # ]: 0 : if (rArguments.getLength() >= 1)
813 : : {
814 [ # # ]: 0 : mxAccessibleParent = Reference<XAccessible>(rArguments[0], UNO_QUERY);
815 [ # # ]: 0 : if (mpAccessibleConsole.is())
816 : 0 : mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
817 : : }
818 : 0 : }
819 : :
820 : : //===== PresenterAccessible::AccessibleObject =========================================
821 : :
822 : 0 : PresenterAccessible::AccessibleObject::AccessibleObject (
823 : : const lang::Locale aLocale,
824 : : const sal_Int16 nRole,
825 : : const OUString& rsName)
826 : : : PresenterAccessibleObjectInterfaceBase(m_aMutex),
827 : : msName(rsName),
828 : : mxContentWindow(),
829 : : mxBorderWindow(),
830 : : maLocale(aLocale),
831 : : mnRole(nRole),
832 : : mnStateSet(0),
833 : : mbIsFocused(false),
834 : : mxParentAccessible(),
835 : : maChildren(),
836 [ # # ][ # # ]: 0 : maListeners()
837 : : {
838 : 0 : }
839 : :
840 : 0 : void PresenterAccessible::AccessibleObject::LateInitialization (void)
841 : : {
842 [ # # ][ # # ]: 0 : AccessibleFocusManager::Instance()->AddFocusableObject(this);
[ # # ]
843 : 0 : }
844 : :
845 [ # # ]: 0 : PresenterAccessible::AccessibleObject::~AccessibleObject (void)
846 : : {
847 [ # # ]: 0 : }
848 : :
849 : 0 : void PresenterAccessible::AccessibleObject::SetWindow (
850 : : const Reference<awt::XWindow>& rxContentWindow,
851 : : const Reference<awt::XWindow>& rxBorderWindow)
852 : : {
853 [ # # ]: 0 : Reference<awt::XWindow2> xContentWindow (rxContentWindow, UNO_QUERY);
854 : :
855 [ # # ][ # # ]: 0 : if (mxContentWindow.get() != xContentWindow.get())
[ # # ]
856 : : {
857 [ # # ]: 0 : if (mxContentWindow.is())
858 : : {
859 [ # # ][ # # ]: 0 : mxContentWindow->removeWindowListener(this);
[ # # ]
860 : : }
861 : :
862 [ # # ]: 0 : mxContentWindow = xContentWindow;
863 [ # # ][ # # ]: 0 : mxBorderWindow = Reference<awt::XWindow2>(rxBorderWindow, UNO_QUERY);
864 : :
865 [ # # ]: 0 : if (mxContentWindow.is())
866 : : {
867 [ # # ][ # # ]: 0 : mxContentWindow->addWindowListener(this);
[ # # ]
868 : : }
869 : :
870 [ # # ]: 0 : UpdateStateSet();
871 : 0 : }
872 : 0 : }
873 : :
874 : 0 : void PresenterAccessible::AccessibleObject::SetAccessibleParent (
875 : : const Reference<XAccessible>& rxAccessibleParent)
876 : : {
877 : 0 : mxParentAccessible = rxAccessibleParent;
878 : 0 : }
879 : :
880 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::disposing (void)
881 : : {
882 [ # # ][ # # ]: 0 : AccessibleFocusManager::Instance()->RemoveFocusableObject(this);
[ # # ]
883 [ # # ][ # # ]: 0 : SetWindow(NULL, NULL);
884 : 0 : }
885 : :
886 : : //----- XAccessible -------------------------------------------------------
887 : :
888 : : Reference<XAccessibleContext> SAL_CALL
889 : 0 : PresenterAccessible::AccessibleObject::getAccessibleContext (void)
890 : : throw (RuntimeException)
891 : : {
892 : 0 : ThrowIfDisposed();
893 : :
894 : 0 : return this;
895 : : }
896 : :
897 : : //----- XAccessibleContext ----------------------------------------------
898 : :
899 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getAccessibleChildCount (void)
900 : : throw (cssu::RuntimeException)
901 : : {
902 : 0 : ThrowIfDisposed();
903 : :
904 : 0 : const sal_Int32 nChildCount (maChildren.size());
905 : :
906 : 0 : return nChildCount;
907 : : }
908 : :
909 : : Reference<XAccessible> SAL_CALL
910 : 0 : PresenterAccessible::AccessibleObject::getAccessibleChild (sal_Int32 nIndex)
911 : : throw (lang::IndexOutOfBoundsException, RuntimeException)
912 : : {
913 : 0 : ThrowIfDisposed();
914 : :
915 [ # # ][ # # ]: 0 : if (nIndex<0 || nIndex>=sal_Int32(maChildren.size()))
[ # # ]
916 : 0 : ThrowException("invalid child index", ET_IndexOutOfBounds);
917 : :
918 [ # # ]: 0 : return Reference<XAccessible>(maChildren[nIndex].get());
919 : : }
920 : :
921 : : Reference<XAccessible> SAL_CALL
922 : 0 : PresenterAccessible::AccessibleObject::getAccessibleParent (void)
923 : : throw (RuntimeException)
924 : : {
925 : 0 : ThrowIfDisposed();
926 : :
927 : 0 : return mxParentAccessible;
928 : : }
929 : :
930 : : sal_Int32 SAL_CALL
931 : 0 : PresenterAccessible::AccessibleObject::getAccessibleIndexInParent (void)
932 : : throw (RuntimeException)
933 : : {
934 [ # # ]: 0 : ThrowIfDisposed();
935 : :
936 [ # # ]: 0 : const Reference<XAccessible> xThis (this);
937 [ # # ]: 0 : if (mxParentAccessible.is())
938 : : {
939 [ # # ][ # # ]: 0 : const Reference<XAccessibleContext> xContext (mxParentAccessible->getAccessibleContext());
940 [ # # ][ # # ]: 0 : for (sal_Int32 nIndex=0,nCount=xContext->getAccessibleChildCount();
[ # # ]
941 : : nIndex<nCount;
942 : : ++nIndex)
943 : : {
944 [ # # ][ # # ]: 0 : if (xContext->getAccessibleChild(nIndex) == xThis)
[ # # ][ # # ]
945 : 0 : return nIndex;
946 [ # # ]: 0 : }
947 : : }
948 : :
949 : 0 : return 0;
950 : : }
951 : :
952 : : sal_Int16 SAL_CALL
953 : 0 : PresenterAccessible::AccessibleObject::getAccessibleRole (void)
954 : : throw (RuntimeException)
955 : : {
956 : 0 : ThrowIfDisposed();
957 : :
958 : 0 : return mnRole;
959 : : }
960 : :
961 : : OUString SAL_CALL
962 : 0 : PresenterAccessible::AccessibleObject::getAccessibleDescription (void)
963 : : throw (RuntimeException)
964 : : {
965 : 0 : ThrowIfDisposed();
966 : :
967 : 0 : return msName;
968 : : }
969 : :
970 : : OUString SAL_CALL
971 : 0 : PresenterAccessible::AccessibleObject::getAccessibleName (void)
972 : : throw (cssu::RuntimeException)
973 : : {
974 : 0 : ThrowIfDisposed();
975 : :
976 : 0 : return msName;
977 : : }
978 : :
979 : : Reference<XAccessibleRelationSet> SAL_CALL
980 : 0 : PresenterAccessible::AccessibleObject::getAccessibleRelationSet (void)
981 : : throw (RuntimeException)
982 : : {
983 : 0 : ThrowIfDisposed();
984 : :
985 : 0 : return NULL;
986 : : }
987 : :
988 : : Reference<XAccessibleStateSet> SAL_CALL
989 : 0 : PresenterAccessible::AccessibleObject::getAccessibleStateSet (void)
990 : : throw (RuntimeException)
991 : : {
992 : 0 : ThrowIfDisposed();
993 : :
994 [ # # ][ # # ]: 0 : return Reference<XAccessibleStateSet>(new AccessibleStateSet(mnStateSet));
995 : : }
996 : :
997 : : lang::Locale SAL_CALL
998 : 0 : PresenterAccessible::AccessibleObject::getLocale (void)
999 : : throw (RuntimeException,
1000 : : IllegalAccessibleComponentStateException)
1001 : : {
1002 : 0 : ThrowIfDisposed();
1003 : :
1004 [ # # ]: 0 : if (mxParentAccessible.is())
1005 : : {
1006 [ # # ][ # # ]: 0 : Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1007 [ # # ]: 0 : if (xParentContext.is())
1008 [ # # ][ # # ]: 0 : return xParentContext->getLocale();
[ # # ]
1009 : : }
1010 : 0 : return maLocale;
1011 : : }
1012 : :
1013 : : //----- XAccessibleComponent ------------------------------------------------
1014 : :
1015 : 0 : sal_Bool SAL_CALL PresenterAccessible::AccessibleObject::containsPoint (
1016 : : const awt::Point& rPoint)
1017 : : throw (RuntimeException)
1018 : : {
1019 : 0 : ThrowIfDisposed();
1020 : :
1021 [ # # ]: 0 : if (mxContentWindow.is())
1022 : : {
1023 [ # # ]: 0 : const awt::Rectangle aBox (getBounds());
1024 : : return rPoint.X>=aBox.X
1025 : : && rPoint.Y>=aBox.Y
1026 : : && rPoint.X<aBox.X+aBox.Width
1027 [ # # ][ # # ]: 0 : && rPoint.Y<aBox.Y+aBox.Height;
[ # # ][ # # ]
1028 : : }
1029 : : else
1030 : 0 : return false;
1031 : : }
1032 : :
1033 : : Reference<XAccessible> SAL_CALL
1034 : 0 : PresenterAccessible::AccessibleObject::getAccessibleAtPoint (const awt::Point& rPoint)
1035 : : throw (RuntimeException)
1036 : : {
1037 : : (void)rPoint;
1038 : 0 : ThrowIfDisposed();
1039 : :
1040 : 0 : return Reference<XAccessible>();
1041 : : }
1042 : :
1043 : 0 : awt::Rectangle SAL_CALL PresenterAccessible::AccessibleObject::getBounds (void)
1044 : : throw (RuntimeException)
1045 : : {
1046 [ # # ]: 0 : ThrowIfDisposed();
1047 : :
1048 : 0 : awt::Rectangle aBox;
1049 : :
1050 [ # # ]: 0 : const awt::Point aLocation (GetRelativeLocation());
1051 [ # # ]: 0 : const awt::Size aSize (GetSize());
1052 : :
1053 : 0 : return awt::Rectangle (aLocation.X, aLocation.Y, aSize.Width, aSize.Height);
1054 : : }
1055 : :
1056 : 0 : awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocation (void)
1057 : : throw (RuntimeException)
1058 : : {
1059 : 0 : ThrowIfDisposed();
1060 : :
1061 : 0 : const awt::Point aLocation (GetRelativeLocation());
1062 : :
1063 : 0 : return aLocation;
1064 : : }
1065 : :
1066 : 0 : awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocationOnScreen (void)
1067 : : throw (RuntimeException)
1068 : : {
1069 [ # # ]: 0 : ThrowIfDisposed();
1070 : :
1071 [ # # ]: 0 : awt::Point aRelativeLocation (GetRelativeLocation());
1072 [ # # ]: 0 : awt::Point aParentLocationOnScreen (GetAbsoluteParentLocation());
1073 : :
1074 : : return awt::Point(
1075 : : aRelativeLocation.X + aParentLocationOnScreen.X,
1076 : 0 : aRelativeLocation.Y + aParentLocationOnScreen.Y);
1077 : : }
1078 : :
1079 : 0 : awt::Size SAL_CALL PresenterAccessible::AccessibleObject::getSize (void)
1080 : : throw (RuntimeException)
1081 : : {
1082 : 0 : ThrowIfDisposed();
1083 : :
1084 : 0 : const awt::Size aSize (GetSize());
1085 : :
1086 : 0 : return aSize;
1087 : : }
1088 : :
1089 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::grabFocus (void)
1090 : : throw (RuntimeException)
1091 : : {
1092 : 0 : ThrowIfDisposed();
1093 [ # # ]: 0 : if (mxBorderWindow.is())
1094 : 0 : mxBorderWindow->setFocus();
1095 [ # # ]: 0 : else if (mxContentWindow.is())
1096 : 0 : mxContentWindow->setFocus();
1097 : 0 : }
1098 : :
1099 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getForeground (void)
1100 : : throw (RuntimeException)
1101 : : {
1102 : 0 : ThrowIfDisposed();
1103 : :
1104 : 0 : return 0x00ffffff;
1105 : : }
1106 : :
1107 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getBackground (void)
1108 : : throw (RuntimeException)
1109 : : {
1110 : 0 : ThrowIfDisposed();
1111 : :
1112 : 0 : return 0x00000000;
1113 : : }
1114 : :
1115 : : //----- XAccessibleEventBroadcaster -------------------------------------------
1116 : :
1117 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::addEventListener (
1118 : : const Reference<XAccessibleEventListener>& rxListener)
1119 : : throw (RuntimeException)
1120 : : {
1121 [ # # ]: 0 : if (rxListener.is())
1122 : : {
1123 [ # # ]: 0 : const osl::MutexGuard aGuard(m_aMutex);
1124 : :
1125 [ # # ]: 0 : if (IsDisposed())
1126 : : {
1127 [ # # ]: 0 : uno::Reference<uno::XInterface> xThis (static_cast<XWeak*>(this), UNO_QUERY);
1128 [ # # ][ # # ]: 0 : rxListener->disposing (lang::EventObject(xThis));
[ # # ][ # # ]
1129 : : }
1130 : : else
1131 : : {
1132 [ # # ]: 0 : maListeners.push_back(rxListener);
1133 [ # # ]: 0 : }
1134 : : }
1135 : 0 : }
1136 : :
1137 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::removeEventListener (
1138 : : const Reference<XAccessibleEventListener>& rxListener)
1139 : : throw (RuntimeException)
1140 : : {
1141 : 0 : ThrowIfDisposed();
1142 [ # # ]: 0 : if (rxListener.is())
1143 : : {
1144 [ # # ]: 0 : const osl::MutexGuard aGuard(m_aMutex);
1145 : :
1146 [ # # ][ # # ]: 0 : maListeners.erase(std::remove(maListeners.begin(), maListeners.end(), rxListener));
[ # # ]
1147 : : }
1148 : 0 : }
1149 : :
1150 : : //----- XWindowListener ---------------------------------------------------
1151 : :
1152 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::windowResized (
1153 : : const css::awt::WindowEvent& rEvent)
1154 : : throw (cssu::RuntimeException)
1155 : : {
1156 : : (void)rEvent;
1157 : :
1158 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1159 : 0 : }
1160 : :
1161 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::windowMoved (
1162 : : const css::awt::WindowEvent& rEvent)
1163 : : throw (cssu::RuntimeException)
1164 : : {
1165 : : (void)rEvent;
1166 : :
1167 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1168 : 0 : }
1169 : :
1170 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::windowShown (
1171 : : const css::lang::EventObject& rEvent)
1172 : : throw (cssu::RuntimeException)
1173 : : {
1174 : : (void)rEvent;
1175 : 0 : UpdateStateSet();
1176 : 0 : }
1177 : :
1178 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::windowHidden (
1179 : : const css::lang::EventObject& rEvent)
1180 : : throw (cssu::RuntimeException)
1181 : : {
1182 : : (void)rEvent;
1183 : 0 : UpdateStateSet();
1184 : 0 : }
1185 : :
1186 : : //----- XEventListener --------------------------------------------------------
1187 : :
1188 : 0 : void SAL_CALL PresenterAccessible::AccessibleObject::disposing (const css::lang::EventObject& rEvent)
1189 : : throw (cssu::RuntimeException)
1190 : : {
1191 [ # # ]: 0 : if (rEvent.Source == mxContentWindow)
1192 : : {
1193 : 0 : mxContentWindow = NULL;
1194 : 0 : mxBorderWindow = NULL;
1195 : : }
1196 : : else
1197 : : {
1198 [ # # ][ # # ]: 0 : SetWindow(NULL, NULL);
1199 : : }
1200 : 0 : }
1201 : :
1202 : : //----- private ---------------------------------------------------------------
1203 : :
1204 : 0 : bool PresenterAccessible::AccessibleObject::GetWindowState (const sal_Int16 nType) const
1205 : : {
1206 [ # # # # : 0 : switch (nType)
# ]
1207 : : {
1208 : : case AccessibleStateType::ENABLED:
1209 [ # # ][ # # ]: 0 : return mxContentWindow.is() && mxContentWindow->isEnabled();
1210 : :
1211 : : case AccessibleStateType::FOCUSABLE:
1212 : 0 : return true;
1213 : :
1214 : : case AccessibleStateType::FOCUSED:
1215 : 0 : return mbIsFocused;
1216 : :
1217 : : case AccessibleStateType::SHOWING:
1218 [ # # ][ # # ]: 0 : return mxContentWindow.is() && mxContentWindow->isVisible();
1219 : :
1220 : : default:
1221 : 0 : return false;
1222 : : }
1223 : : }
1224 : :
1225 : 0 : void PresenterAccessible::AccessibleObject::UpdateStateSet (void)
1226 : : {
1227 : 0 : UpdateState(AccessibleStateType::FOCUSABLE, true);
1228 : 0 : UpdateState(AccessibleStateType::VISIBLE, true);
1229 : 0 : UpdateState(AccessibleStateType::ENABLED, true);
1230 : 0 : UpdateState(AccessibleStateType::MULTI_LINE, true);
1231 : 0 : UpdateState(AccessibleStateType::SENSITIVE, true);
1232 : :
1233 : 0 : UpdateState(AccessibleStateType::ENABLED, GetWindowState(AccessibleStateType::ENABLED));
1234 : 0 : UpdateState(AccessibleStateType::FOCUSED, GetWindowState(AccessibleStateType::FOCUSED));
1235 : 0 : UpdateState(AccessibleStateType::SHOWING, GetWindowState(AccessibleStateType::SHOWING));
1236 : : // UpdateState(AccessibleStateType::ACTIVE, GetWindowState(AccessibleStateType::ACTIVE));
1237 : 0 : }
1238 : :
1239 : 0 : void PresenterAccessible::AccessibleObject::UpdateState(
1240 : : const sal_Int16 nState,
1241 : : const bool bValue)
1242 : : {
1243 : 0 : const sal_uInt32 nStateMask (AccessibleStateSet::GetStateMask(nState));
1244 [ # # ]: 0 : if (((mnStateSet & nStateMask)!=0) != bValue)
1245 : : {
1246 [ # # ]: 0 : if (bValue)
1247 : : {
1248 : 0 : mnStateSet |= nStateMask;
1249 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), Any(nState));
1250 : : }
1251 : : else
1252 : : {
1253 : 0 : mnStateSet &= ~nStateMask;
1254 [ # # ][ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(nState), Any());
1255 : : }
1256 : : }
1257 : 0 : }
1258 : :
1259 : 0 : void PresenterAccessible::AccessibleObject::AddChild (
1260 : : const ::rtl::Reference<AccessibleObject>& rpChild)
1261 : : {
1262 : 0 : maChildren.push_back(rpChild);
1263 [ # # ]: 0 : rpChild->SetAccessibleParent(this);
1264 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1265 : 0 : }
1266 : :
1267 : 0 : void PresenterAccessible::AccessibleObject::RemoveChild (
1268 : : const ::rtl::Reference<AccessibleObject>& rpChild)
1269 : : {
1270 [ # # ]: 0 : rpChild->SetAccessibleParent(Reference<XAccessible>());
1271 : 0 : maChildren.erase(::std::find(maChildren.begin(), maChildren.end(), rpChild));
1272 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1273 : 0 : }
1274 : :
1275 : 0 : void PresenterAccessible::AccessibleObject::SetIsFocused (const bool bIsFocused)
1276 : : {
1277 [ # # ]: 0 : if (mbIsFocused != bIsFocused)
1278 : : {
1279 : 0 : mbIsFocused = bIsFocused;
1280 : 0 : UpdateStateSet();
1281 : : }
1282 : 0 : }
1283 : :
1284 : 0 : void PresenterAccessible::AccessibleObject::SetAccessibleName (const ::rtl::OUString& rsName)
1285 : : {
1286 [ # # ]: 0 : if (msName != rsName)
1287 : : {
1288 : 0 : const OUString sOldName(msName);
1289 : 0 : msName = rsName;
1290 [ # # ][ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::NAME_CHANGED, Any(sOldName), Any(msName));
[ # # ]
1291 : : }
1292 : 0 : }
1293 : :
1294 : 0 : void PresenterAccessible::AccessibleObject::FireAccessibleEvent (
1295 : : const sal_Int16 nEventId,
1296 : : const uno::Any& rOldValue,
1297 : : const uno::Any& rNewValue )
1298 : : {
1299 [ # # ]: 0 : AccessibleEventObject aEventObject;
1300 : :
1301 [ # # ][ # # ]: 0 : aEventObject.Source = Reference<XWeak>(this);
1302 : 0 : aEventObject.EventId = nEventId;
1303 : 0 : aEventObject.NewValue = rNewValue;
1304 : 0 : aEventObject.OldValue = rOldValue;
1305 : :
1306 [ # # ]: 0 : ::std::vector<Reference<XAccessibleEventListener> > aListenerCopy(maListeners);
1307 [ # # ][ # # ]: 0 : for (::std::vector<Reference<XAccessibleEventListener> >::const_iterator
1308 [ # # ]: 0 : iListener(aListenerCopy.begin()),
1309 [ # # ]: 0 : iEnd(aListenerCopy.end());
1310 : : iListener!=iEnd;
1311 : : ++iListener)
1312 : : {
1313 : : try
1314 : : {
1315 [ # # ][ # # ]: 0 : (*iListener)->notifyEvent(aEventObject);
1316 : : }
1317 [ # # # # : 0 : catch(lang::DisposedException&)
# ]
1318 : : {
1319 : : // Listener has been disposed and should have been removed
1320 : : // already.
1321 [ # # ]: 0 : removeEventListener(*iListener);
1322 : : }
1323 [ # # ]: 0 : catch(Exception&)
1324 : : {
1325 : : // Ignore all other exceptions and assume that they are
1326 : : // caused by a temporary problem.
1327 : : }
1328 [ # # ]: 0 : }
1329 : 0 : }
1330 : :
1331 : 0 : awt::Point PresenterAccessible::AccessibleObject::GetRelativeLocation (void)
1332 : : {
1333 : 0 : awt::Point aLocation;
1334 [ # # ]: 0 : if (mxContentWindow.is())
1335 : : {
1336 [ # # ][ # # ]: 0 : const awt::Rectangle aContentBox (mxContentWindow->getPosSize());
1337 : 0 : aLocation.X = aContentBox.X;
1338 : 0 : aLocation.Y = aContentBox.Y;
1339 [ # # ]: 0 : if (mxBorderWindow.is())
1340 : : {
1341 [ # # ][ # # ]: 0 : const awt::Rectangle aBorderBox (mxBorderWindow->getPosSize());
1342 : 0 : aLocation.X += aBorderBox.X;
1343 : 0 : aLocation.Y += aBorderBox.Y;
1344 : : }
1345 : : }
1346 : 0 : return aLocation;
1347 : : }
1348 : :
1349 : 0 : awt::Size PresenterAccessible::AccessibleObject::GetSize (void)
1350 : : {
1351 [ # # ]: 0 : if (mxContentWindow.is())
1352 : : {
1353 [ # # ][ # # ]: 0 : const awt::Rectangle aBox (mxContentWindow->getPosSize());
1354 : 0 : return awt::Size(aBox.Width, aBox.Height);
1355 : : }
1356 : : else
1357 : 0 : return awt::Size();
1358 : : }
1359 : :
1360 : 0 : awt::Point PresenterAccessible::AccessibleObject::GetAbsoluteParentLocation (void)
1361 : : {
1362 : 0 : Reference<XAccessibleComponent> xParentComponent;
1363 [ # # ]: 0 : if (mxParentAccessible.is())
1364 : : xParentComponent = Reference<XAccessibleComponent>(
1365 [ # # ][ # # ]: 0 : mxParentAccessible->getAccessibleContext(), UNO_QUERY);
[ # # ][ # # ]
1366 [ # # ]: 0 : if (xParentComponent.is())
1367 [ # # ][ # # ]: 0 : return xParentComponent->getLocationOnScreen();
1368 : : else
1369 : 0 : return awt::Point();
1370 : : }
1371 : :
1372 : 0 : sal_Bool PresenterAccessible::AccessibleObject::IsDisposed (void) const
1373 : : {
1374 [ # # ][ # # ]: 0 : return (rBHelper.bDisposed || rBHelper.bInDispose);
1375 : : }
1376 : :
1377 : 0 : void PresenterAccessible::AccessibleObject::ThrowIfDisposed (void) const
1378 : : throw (lang::DisposedException)
1379 : : {
1380 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
1381 : 0 : ThrowException("object has already been disposed", ET_Disposed);
1382 : 0 : }
1383 : :
1384 : 0 : void PresenterAccessible::AccessibleObject::ThrowException (
1385 : : const sal_Char* pMessage,
1386 : : const ExceptionType eExceptionType) const
1387 : : {
1388 : 0 : const OUString sMessage (OUString(A2S("PresenterAccessible: ")) + OUString::createFromAscii(pMessage));
1389 : : const Reference<XInterface> xObject (
1390 [ # # ]: 0 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1391 [ # # # ]: 0 : switch (eExceptionType)
1392 : : {
1393 : : default:
1394 : : case ET_Runtime:
1395 [ # # ]: 0 : throw RuntimeException(sMessage, xObject);
1396 : : case ET_Disposed:
1397 [ # # ]: 0 : throw lang::DisposedException(sMessage, xObject);
1398 : : case ET_IndexOutOfBounds:
1399 [ # # ]: 0 : throw lang::IndexOutOfBoundsException(sMessage, xObject);
1400 : 0 : }
1401 : : }
1402 : :
1403 : : //===== AccessibleStateSet ====================================================
1404 : :
1405 : 0 : AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet)
1406 : : : AccessibleStateSetInterfaceBase(m_aMutex),
1407 : 0 : mnStateSet (nStateSet)
1408 : : {
1409 : 0 : }
1410 : :
1411 [ # # ]: 0 : AccessibleStateSet::~AccessibleStateSet (void)
1412 : : {
1413 [ # # ]: 0 : }
1414 : :
1415 : 0 : sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState)
1416 : : {
1417 [ # # ][ # # ]: 0 : if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8))
1418 : : {
1419 [ # # ][ # # ]: 0 : throw RuntimeException(A2S("AccessibleStateSet::GetStateMask: invalid state"), NULL);
1420 : : }
1421 : :
1422 : 0 : return 1<<nState;
1423 : : }
1424 : :
1425 : : //----- XAccessibleStateSet ---------------------------------------------------
1426 : :
1427 : 0 : sal_Bool SAL_CALL AccessibleStateSet::isEmpty (void)
1428 : : throw (cssu::RuntimeException)
1429 : : {
1430 : 0 : return mnStateSet==0;
1431 : : }
1432 : :
1433 : 0 : sal_Bool SAL_CALL AccessibleStateSet::contains (sal_Int16 nState)
1434 : : throw (cssu::RuntimeException)
1435 : : {
1436 : 0 : return (mnStateSet & GetStateMask(nState)) != 0;
1437 : : }
1438 : :
1439 : 0 : sal_Bool SAL_CALL AccessibleStateSet::containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
1440 : : throw (cssu::RuntimeException)
1441 : : {
1442 [ # # ]: 0 : for (sal_Int32 nIndex=0,nCount=rStateSet.getLength(); nIndex<nCount; ++nIndex)
1443 : : {
1444 [ # # ]: 0 : if ((mnStateSet & GetStateMask(rStateSet[nIndex])) == 0)
1445 : 0 : return sal_False;
1446 : : }
1447 : 0 : return sal_True;
1448 : : }
1449 : :
1450 : 0 : cssu::Sequence<sal_Int16> SAL_CALL AccessibleStateSet::getStates (void)
1451 : : throw (cssu::RuntimeException)
1452 : : {
1453 [ # # ]: 0 : ::std::vector<sal_Int16> aStates;
1454 [ # # ]: 0 : aStates.reserve(sizeof(mnStateSet)*8);
1455 [ # # ]: 0 : for (sal_uInt16 nIndex=0; nIndex<sizeof(mnStateSet)*8; ++nIndex)
1456 [ # # ][ # # ]: 0 : if ((mnStateSet & GetStateMask(nIndex)) != 0)
1457 [ # # ]: 0 : aStates.push_back(nIndex);
1458 [ # # ][ # # ]: 0 : return Sequence<sal_Int16>(&aStates.front(), aStates.size());
1459 : : }
1460 : :
1461 : : //===== AccessibleRelationSet =================================================
1462 : :
1463 : 0 : AccessibleRelationSet::AccessibleRelationSet (void)
1464 : : : AccessibleRelationSetInterfaceBase(m_aMutex),
1465 [ # # ]: 0 : maRelations()
1466 : : {
1467 : 0 : }
1468 : :
1469 [ # # ]: 0 : AccessibleRelationSet::~AccessibleRelationSet (void)
1470 : : {
1471 [ # # ]: 0 : }
1472 : :
1473 : 0 : void AccessibleRelationSet::AddRelation (
1474 : : const sal_Int16 nRelationType,
1475 : : const Reference<XInterface>& rxObject)
1476 : : {
1477 : 0 : maRelations.resize(maRelations.size()+1);
1478 : 0 : maRelations.back().RelationType = nRelationType;
1479 : 0 : maRelations.back().TargetSet.realloc(1);
1480 : 0 : maRelations.back().TargetSet[0] = rxObject;
1481 : 0 : }
1482 : :
1483 : : //----- XAccessibleRelationSet ------------------------------------------------
1484 : :
1485 : 0 : sal_Int32 SAL_CALL AccessibleRelationSet::getRelationCount (void)
1486 : : throw (cssu::RuntimeException)
1487 : : {
1488 : 0 : return maRelations.size();
1489 : : }
1490 : :
1491 : 0 : AccessibleRelation SAL_CALL AccessibleRelationSet::getRelation (sal_Int32 nIndex)
1492 : : throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException)
1493 : : {
1494 [ # # ][ # # ]: 0 : if (nIndex<0 && sal_uInt32(nIndex)>=maRelations.size())
[ # # ]
1495 : 0 : return AccessibleRelation();
1496 : : else
1497 : 0 : return maRelations[nIndex];
1498 : : }
1499 : :
1500 : 0 : sal_Bool SAL_CALL AccessibleRelationSet::containsRelation (sal_Int16 nRelationType)
1501 : : throw (cssu::RuntimeException)
1502 : : {
1503 [ # # ][ # # ]: 0 : for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
[ # # ]
1504 : 0 : iRelation!=maRelations.end();
1505 : : ++iRelation)
1506 : : {
1507 [ # # ]: 0 : if (iRelation->RelationType == nRelationType)
1508 : 0 : return sal_True;
1509 : : }
1510 : 0 : return sal_False;
1511 : : }
1512 : :
1513 : 0 : AccessibleRelation SAL_CALL AccessibleRelationSet::getRelationByType (sal_Int16 nRelationType)
1514 : : throw (cssu::RuntimeException)
1515 : : {
1516 [ # # ][ # # ]: 0 : for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
[ # # ]
1517 : 0 : iRelation!=maRelations.end();
1518 : : ++iRelation)
1519 : : {
1520 [ # # ]: 0 : if (iRelation->RelationType == nRelationType)
1521 [ # # ]: 0 : return *iRelation;
1522 : : }
1523 : 0 : return AccessibleRelation();
1524 : : }
1525 : :
1526 : : //===== PresenterAccessible::AccessibleParagraph ==============================
1527 : :
1528 : 0 : PresenterAccessible::AccessibleParagraph::AccessibleParagraph (
1529 : : const lang::Locale aLocale,
1530 : : const sal_Int16 nRole,
1531 : : const OUString& rsName,
1532 : : const SharedPresenterTextParagraph& rpParagraph,
1533 : : const sal_Int32 nParagraphIndex)
1534 : : : PresenterAccessibleParagraphInterfaceBase(aLocale, nRole, rsName),
1535 : : mpParagraph(rpParagraph),
1536 [ # # ]: 0 : mnParagraphIndex(nParagraphIndex)
1537 : : {
1538 : 0 : }
1539 : :
1540 [ # # ]: 0 : PresenterAccessible::AccessibleParagraph::~AccessibleParagraph (void)
1541 : : {
1542 [ # # ]: 0 : }
1543 : :
1544 : : //----- XAccessibleContext ----------------------------------------------------
1545 : :
1546 : : Reference<XAccessibleRelationSet> SAL_CALL
1547 : 0 : PresenterAccessible::AccessibleParagraph::getAccessibleRelationSet (void)
1548 : : throw (RuntimeException)
1549 : : {
1550 [ # # ]: 0 : ThrowIfDisposed();
1551 : :
1552 [ # # ]: 0 : rtl::Reference<AccessibleRelationSet> pSet (new AccessibleRelationSet);
1553 : :
1554 [ # # ]: 0 : if (mxParentAccessible.is())
1555 : : {
1556 [ # # ][ # # ]: 0 : Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1557 [ # # ]: 0 : if (xParentContext.is())
1558 : : {
1559 [ # # ]: 0 : if (mnParagraphIndex>0)
1560 : : pSet->AddRelation(
1561 : : AccessibleRelationType::CONTENT_FLOWS_FROM,
1562 [ # # ][ # # ]: 0 : xParentContext->getAccessibleChild(mnParagraphIndex-1));
[ # # ]
1563 : :
1564 [ # # ][ # # ]: 0 : if (mnParagraphIndex<xParentContext->getAccessibleChildCount()-1)
[ # # ]
1565 : : pSet->AddRelation(
1566 : : AccessibleRelationType::CONTENT_FLOWS_TO,
1567 [ # # ][ # # ]: 0 : xParentContext->getAccessibleChild(mnParagraphIndex+1));
[ # # ]
1568 : 0 : }
1569 : : }
1570 : :
1571 [ # # ][ # # ]: 0 : return Reference<XAccessibleRelationSet>(pSet.get());
1572 : : }
1573 : :
1574 : : //----- XAccessibleText -------------------------------------------------------
1575 : :
1576 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCaretPosition (void)
1577 : : throw (cssu::RuntimeException)
1578 : : {
1579 : 0 : ThrowIfDisposed();
1580 : :
1581 : 0 : sal_Int32 nPosition (-1);
1582 [ # # ]: 0 : if (mpParagraph)
1583 : 0 : nPosition = mpParagraph->GetCaretPosition();
1584 : :
1585 : 0 : return nPosition;
1586 : : }
1587 : :
1588 : 0 : sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setCaretPosition (sal_Int32 nIndex)
1589 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1590 : : {
1591 : 0 : ThrowIfDisposed();
1592 : :
1593 [ # # ]: 0 : if (mpParagraph)
1594 : : {
1595 : 0 : mpParagraph->SetCaretPosition(nIndex);
1596 : 0 : return sal_True;
1597 : : }
1598 : : else
1599 : 0 : return sal_False;
1600 : : }
1601 : :
1602 : 0 : sal_Unicode SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacter (sal_Int32 nIndex)
1603 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1604 : : {
1605 : 0 : ThrowIfDisposed();
1606 : :
1607 [ # # ]: 0 : if (!mpParagraph)
1608 : 0 : ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1609 : 0 : return mpParagraph->GetCharacter(nIndex);
1610 : : }
1611 : :
1612 : : Sequence<css::beans::PropertyValue> SAL_CALL
1613 : 0 : PresenterAccessible::AccessibleParagraph::getCharacterAttributes (
1614 : : ::sal_Int32 nIndex,
1615 : : const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
1616 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1617 : : {
1618 : 0 : ThrowIfDisposed();
1619 : :
1620 : : #if OSL_DEBUG_LEVEL > 1
1621 : : OSL_TRACE("PresenterAccessible::AccessibleParagraph::getCharacterAttributes at %x,%d returns empty set\r",
1622 : : this,nIndex);
1623 : : for (sal_Int32 nAttributeIndex(0),nAttributeCount(rRequestedAttributes.getLength());
1624 : : nAttributeIndex<nAttributeCount;
1625 : : ++nAttributeIndex)
1626 : : {
1627 : : OSL_TRACE(" requested attribute %d is %s\r",
1628 : : nAttributeIndex,
1629 : : OUStringToOString(rRequestedAttributes[nAttributeIndex], RTL_TEXTENCODING_UTF8).getStr());
1630 : : }
1631 : : #endif
1632 : :
1633 : : // Character properties are not supported.
1634 : : (void)nIndex;
1635 : : (void)rRequestedAttributes;
1636 : 0 : return Sequence<css::beans::PropertyValue>();
1637 : : }
1638 : :
1639 : 0 : awt::Rectangle SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterBounds (
1640 : : sal_Int32 nIndex)
1641 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1642 : : {
1643 : 0 : ThrowIfDisposed();
1644 : :
1645 : 0 : awt::Rectangle aCharacterBox;
1646 [ # # ]: 0 : if (nIndex < 0)
1647 : : {
1648 : 0 : ThrowException("invalid text index", ET_IndexOutOfBounds);
1649 : : }
1650 [ # # ]: 0 : else if (mpParagraph)
1651 : : {
1652 [ # # ]: 0 : aCharacterBox = mpParagraph->GetCharacterBounds(nIndex, false);
1653 : : // Convert coordinates relative to the window origin into absolute
1654 : : // screen coordinates.
1655 [ # # ]: 0 : const awt::Point aWindowLocationOnScreen (getLocationOnScreen());
1656 : 0 : aCharacterBox.X += aWindowLocationOnScreen.X;
1657 : 0 : aCharacterBox.Y += aWindowLocationOnScreen.Y;
1658 : : }
1659 : : else
1660 : : {
1661 : 0 : ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1662 : : }
1663 : :
1664 : 0 : return aCharacterBox;
1665 : : }
1666 : :
1667 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterCount (void)
1668 : : throw (cssu::RuntimeException)
1669 : : {
1670 : 0 : ThrowIfDisposed();
1671 : :
1672 : 0 : sal_Int32 nCount (0);
1673 [ # # ]: 0 : if (mpParagraph)
1674 : 0 : nCount = mpParagraph->GetCharacterCount();
1675 : :
1676 : 0 : return nCount;
1677 : : }
1678 : :
1679 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getIndexAtPoint (
1680 : : const css::awt::Point& rPoint)
1681 : : throw (cssu::RuntimeException)
1682 : : {
1683 : 0 : ThrowIfDisposed();
1684 : :
1685 : 0 : sal_Int32 nIndex (-1);
1686 [ # # ]: 0 : if (mpParagraph)
1687 : 0 : nIndex = mpParagraph->GetIndexAtPoint(rPoint);
1688 : :
1689 : 0 : return nIndex;
1690 : : }
1691 : :
1692 : 0 : ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectedText (void)
1693 : : throw (cssu::RuntimeException)
1694 : : {
1695 : 0 : ThrowIfDisposed();
1696 : :
1697 : 0 : return getTextRange(getSelectionStart(), getSelectionEnd());
1698 : : }
1699 : :
1700 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionStart (void)
1701 : : throw (cssu::RuntimeException)
1702 : : {
1703 : 0 : ThrowIfDisposed();
1704 : :
1705 : 0 : return getCaretPosition();
1706 : : }
1707 : :
1708 : 0 : sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionEnd (void)
1709 : : throw (cssu::RuntimeException)
1710 : : {
1711 : 0 : ThrowIfDisposed();
1712 : :
1713 : 0 : return getCaretPosition();
1714 : : }
1715 : :
1716 : 0 : sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setSelection (
1717 : : sal_Int32 nStartIndex,
1718 : : sal_Int32 nEndIndex)
1719 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1720 : : {
1721 : : (void)nEndIndex;
1722 : 0 : ThrowIfDisposed();
1723 : :
1724 : 0 : return setCaretPosition(nStartIndex);
1725 : : }
1726 : :
1727 : 0 : ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getText (void)
1728 : : throw (cssu::RuntimeException)
1729 : : {
1730 : 0 : ThrowIfDisposed();
1731 : :
1732 : 0 : ::rtl::OUString sText;
1733 [ # # ]: 0 : if (mpParagraph)
1734 [ # # ]: 0 : sText = mpParagraph->GetText();
1735 : :
1736 : 0 : return sText;
1737 : : }
1738 : :
1739 : 0 : ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getTextRange (
1740 : : sal_Int32 nLocalStartIndex,
1741 : : sal_Int32 nLocalEndIndex)
1742 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1743 : : {
1744 : 0 : ThrowIfDisposed();
1745 : :
1746 : 0 : ::rtl::OUString sText;
1747 [ # # ]: 0 : if (mpParagraph)
1748 : : {
1749 : : const TextSegment aSegment (
1750 [ # # ]: 0 : mpParagraph->CreateTextSegment(nLocalStartIndex, nLocalEndIndex));
1751 : 0 : sText = aSegment.SegmentText;
1752 : : }
1753 : :
1754 : 0 : return sText;
1755 : : }
1756 : :
1757 : 0 : TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextAtIndex (
1758 : : sal_Int32 nLocalCharacterIndex,
1759 : : sal_Int16 nTextType)
1760 : : throw (css::lang::IndexOutOfBoundsException,
1761 : : css::lang::IllegalArgumentException,
1762 : : cssu::RuntimeException)
1763 : : {
1764 : 0 : ThrowIfDisposed();
1765 : :
1766 : 0 : TextSegment aSegment;
1767 [ # # ]: 0 : if (mpParagraph)
1768 [ # # ]: 0 : aSegment = mpParagraph->GetTextSegment(0, nLocalCharacterIndex, nTextType);
1769 : :
1770 : 0 : return aSegment;
1771 : : }
1772 : :
1773 : 0 : TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBeforeIndex (
1774 : : sal_Int32 nLocalCharacterIndex,
1775 : : sal_Int16 nTextType)
1776 : : throw (css::lang::IndexOutOfBoundsException,
1777 : : css::lang::IllegalArgumentException,
1778 : : cssu::RuntimeException)
1779 : : {
1780 : 0 : ThrowIfDisposed();
1781 : :
1782 : 0 : TextSegment aSegment;
1783 [ # # ]: 0 : if (mpParagraph)
1784 [ # # ]: 0 : aSegment = mpParagraph->GetTextSegment(-1, nLocalCharacterIndex, nTextType);
1785 : :
1786 : 0 : return aSegment;
1787 : : }
1788 : :
1789 : 0 : TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBehindIndex (
1790 : : sal_Int32 nLocalCharacterIndex,
1791 : : sal_Int16 nTextType)
1792 : : throw (css::lang::IndexOutOfBoundsException,
1793 : : css::lang::IllegalArgumentException,
1794 : : cssu::RuntimeException)
1795 : : {
1796 : 0 : ThrowIfDisposed();
1797 : :
1798 : 0 : TextSegment aSegment;
1799 [ # # ]: 0 : if (mpParagraph)
1800 [ # # ]: 0 : aSegment = mpParagraph->GetTextSegment(+1, nLocalCharacterIndex, nTextType);
1801 : :
1802 : 0 : return aSegment;
1803 : : }
1804 : :
1805 : 0 : sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::copyText (
1806 : : sal_Int32 nStartIndex,
1807 : : sal_Int32 nEndIndex)
1808 : : throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1809 : : {
1810 : 0 : ThrowIfDisposed();
1811 : :
1812 : : // Return false because copying to clipboard is not supported.
1813 : : // It IS supported in the notes view. There is no need to duplicate
1814 : : // this here.
1815 : : (void)nStartIndex;
1816 : : (void)nEndIndex;
1817 : 0 : return sal_False;
1818 : : }
1819 : :
1820 : : //----- protected -------------------------------------------------------------
1821 : :
1822 : 0 : awt::Point PresenterAccessible::AccessibleParagraph::GetRelativeLocation (void)
1823 : : {
1824 : 0 : awt::Point aLocation (AccessibleObject::GetRelativeLocation());
1825 [ # # ]: 0 : if (mpParagraph)
1826 : : {
1827 [ # # ]: 0 : const awt::Point aParagraphLocation (mpParagraph->GetRelativeLocation());
1828 : 0 : aLocation.X += aParagraphLocation.X;
1829 : 0 : aLocation.Y += aParagraphLocation.Y;
1830 : : }
1831 : :
1832 : 0 : return aLocation;
1833 : : }
1834 : :
1835 : 0 : awt::Size PresenterAccessible::AccessibleParagraph::GetSize (void)
1836 : : {
1837 [ # # ]: 0 : if (mpParagraph)
1838 : 0 : return mpParagraph->GetSize();
1839 : : else
1840 : 0 : return AccessibleObject::GetSize();
1841 : : }
1842 : :
1843 : 0 : awt::Point PresenterAccessible::AccessibleParagraph::GetAbsoluteParentLocation (void)
1844 : : {
1845 [ # # ]: 0 : if (mxParentAccessible.is())
1846 : : {
1847 : : Reference<XAccessibleContext> xParentContext(
1848 [ # # ][ # # ]: 0 : mxParentAccessible->getAccessibleContext(), UNO_QUERY);
[ # # ]
1849 [ # # ]: 0 : if (xParentContext.is())
1850 : : {
1851 : : Reference<XAccessibleComponent> xGrandParentComponent(
1852 [ # # ][ # # ]: 0 : xParentContext->getAccessibleParent(), UNO_QUERY);
[ # # ]
1853 [ # # ]: 0 : if (xGrandParentComponent.is())
1854 [ # # ][ # # ]: 0 : return xGrandParentComponent->getLocationOnScreen();
[ # # ]
1855 [ # # ]: 0 : }
1856 : : }
1857 : :
1858 : 0 : return awt::Point();
1859 : : }
1860 : :
1861 : 0 : bool PresenterAccessible::AccessibleParagraph::GetWindowState (const sal_Int16 nType) const
1862 : : {
1863 [ # # # ]: 0 : switch (nType)
1864 : : {
1865 : : case AccessibleStateType::EDITABLE:
1866 : 0 : return mpParagraph.get()!=NULL;
1867 : :
1868 : : case AccessibleStateType::ACTIVE:
1869 : 0 : return true;
1870 : :
1871 : : default:
1872 : 0 : return AccessibleObject::GetWindowState(nType);
1873 : : }
1874 : : }
1875 : :
1876 : : //===== AccessibleNotes =======================================================
1877 : :
1878 : 0 : AccessibleNotes::AccessibleNotes (
1879 : : const css::lang::Locale aLocale,
1880 : : const sal_Int16 nRole,
1881 : : const ::rtl::OUString& rsName)
1882 : : : AccessibleObject(aLocale,nRole,rsName),
1883 [ # # ][ # # ]: 0 : mpTextView()
1884 : : {
1885 : 0 : }
1886 : :
1887 : 0 : rtl::Reference<PresenterAccessible::AccessibleObject> AccessibleNotes::Create (
1888 : : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
1889 : : const lang::Locale aLocale,
1890 : : const Reference<awt::XWindow>& rxContentWindow,
1891 : : const Reference<awt::XWindow>& rxBorderWindow,
1892 : : const ::boost::shared_ptr<PresenterTextView>& rpTextView)
1893 : : {
1894 : 0 : OUString sName (A2S("Presenter Notes Text"));
1895 : : {
1896 : : PresenterConfigurationAccess aConfiguration (
1897 : : rxContext,
1898 : : OUString("/org.openoffice.Office.extension.PresenterScreen/"),
1899 [ # # ]: 0 : PresenterConfigurationAccess::READ_ONLY);
1900 : : aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Notes/String"))
1901 [ # # ][ # # ]: 0 : >>= sName;
1902 : : }
1903 : :
1904 : : rtl::Reference<AccessibleNotes> pObject (
1905 : : new AccessibleNotes(
1906 : : aLocale,
1907 : : AccessibleRole::PANEL,
1908 [ # # ]: 0 : sName));
1909 [ # # ]: 0 : pObject->LateInitialization();
1910 [ # # ]: 0 : pObject->SetTextView(rpTextView);
1911 [ # # ]: 0 : pObject->UpdateStateSet();
1912 [ # # ]: 0 : pObject->SetWindow(rxContentWindow, rxBorderWindow);
1913 : :
1914 : 0 : return rtl::Reference<PresenterAccessible::AccessibleObject>(pObject.get());
1915 : : }
1916 : :
1917 : 0 : void AccessibleNotes::SetTextView (
1918 : : const ::boost::shared_ptr<PresenterTextView>& rpTextView)
1919 : : {
1920 [ # # ]: 0 : ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > aChildren;
1921 : :
1922 : : // Release any listeners to the current text view.
1923 [ # # ]: 0 : if (mpTextView)
1924 : : {
1925 : : mpTextView->GetCaret()->SetCaretMotionBroadcaster(
1926 [ # # ][ # # ]: 0 : ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)>());
[ # # ][ # # ]
[ # # ]
1927 : : mpTextView->SetTextChangeBroadcaster(
1928 [ # # ][ # # ]: 0 : ::boost::function<void(void)>());
[ # # ]
1929 : : }
1930 : :
1931 [ # # ]: 0 : mpTextView = rpTextView;
1932 : :
1933 [ # # ]: 0 : if (mpTextView)
1934 : : {
1935 : : // Create a new set of children, one for each paragraph.
1936 [ # # ]: 0 : const sal_Int32 nParagraphCount (mpTextView->GetParagraphCount());
1937 [ # # ]: 0 : for (sal_Int32 nIndex=0; nIndex<nParagraphCount; ++nIndex)
1938 : : {
1939 : : rtl::Reference<PresenterAccessible::AccessibleParagraph> pParagraph (
1940 : : new PresenterAccessible::AccessibleParagraph(
1941 : : css::lang::Locale(),
1942 : : AccessibleRole::PARAGRAPH,
1943 : : A2S("Paragraph")+OUString::valueOf(nIndex),
1944 : : rpTextView->GetParagraph(nIndex),
1945 [ # # ][ # # ]: 0 : nIndex));
[ # # ]
1946 [ # # ]: 0 : pParagraph->LateInitialization();
1947 : 0 : pParagraph->SetWindow(
1948 : : Reference<awt::XWindow>(mxContentWindow, UNO_QUERY),
1949 [ # # ][ # # ]: 0 : Reference<awt::XWindow>(mxBorderWindow, UNO_QUERY));
[ # # ]
1950 [ # # ][ # # ]: 0 : pParagraph->SetAccessibleParent(this);
1951 : : aChildren.push_back(
1952 [ # # ]: 0 : rtl::Reference<PresenterAccessible::AccessibleObject>(pParagraph.get()));
1953 : 0 : }
1954 : 0 : maChildren.swap(aChildren);
1955 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1956 : :
1957 : : // Dispose the old children. (This will remove them from the focus
1958 : : // manager).
1959 [ # # ][ # # ]: 0 : for (std::vector<rtl::Reference<AccessibleObject> >::const_iterator
1960 [ # # ][ # # ]: 0 : iChild(aChildren.begin()), iEnd(aChildren.end());
1961 : : iChild!=iEnd;
1962 : : ++iChild)
1963 : : {
1964 [ # # ]: 0 : Reference<lang::XComponent> xComponent (static_cast<XWeak*>(iChild->get()), UNO_QUERY);
1965 [ # # ]: 0 : if (xComponent.is())
1966 [ # # ][ # # ]: 0 : xComponent->dispose();
1967 : 0 : }
1968 : :
1969 : : // This class acts as a controller of who broadcasts caret motion
1970 : : // events and handles text changes. Register the corresponding
1971 : : // listeners here.
1972 : : mpTextView->GetCaret()->SetCaretMotionBroadcaster(
1973 [ # # ][ # # ]: 0 : ::boost::bind(&AccessibleNotes::NotifyCaretChange, this, _1, _2, _3, _4));
[ # # ][ # # ]
[ # # ][ # # ]
1974 : : mpTextView->SetTextChangeBroadcaster(
1975 [ # # ][ # # ]: 0 : ::boost::bind(&AccessibleNotes::HandleTextChange, this));
[ # # ][ # # ]
1976 : 0 : }
1977 : 0 : }
1978 : :
1979 : 0 : void AccessibleNotes::SetWindow (
1980 : : const cssu::Reference<css::awt::XWindow>& rxContentWindow,
1981 : : const cssu::Reference<css::awt::XWindow>& rxBorderWindow)
1982 : : {
1983 : 0 : AccessibleObject::SetWindow(rxContentWindow, rxBorderWindow);
1984 : :
1985 : : // Set the windows at the children as well, so that every paragraph can
1986 : : // setup its geometry.
1987 [ # # ][ # # ]: 0 : for (::std::vector<rtl::Reference<AccessibleObject> >::const_iterator
1988 [ # # ]: 0 : iChild(maChildren.begin()),
1989 [ # # ]: 0 : iEnd(maChildren.end());
1990 : : iChild!=iEnd;
1991 : : ++iChild)
1992 : : {
1993 [ # # ]: 0 : (*iChild)->SetWindow(rxContentWindow, rxBorderWindow);
1994 : : }
1995 : 0 : }
1996 : :
1997 : 0 : void AccessibleNotes::NotifyCaretChange (
1998 : : const sal_Int32 nOldParagraphIndex,
1999 : : const sal_Int32 nOldCharacterIndex,
2000 : : const sal_Int32 nNewParagraphIndex,
2001 : : const sal_Int32 nNewCharacterIndex)
2002 : : {
2003 : : AccessibleFocusManager::Instance()->FocusObject(
2004 : : nNewParagraphIndex >= 0
2005 : 0 : ? maChildren[nNewParagraphIndex]
2006 [ # # ][ # # ]: 0 : : this);
[ # # ][ # # ]
2007 : :
2008 [ # # ]: 0 : if (nOldParagraphIndex != nNewParagraphIndex)
2009 : : {
2010 : : // Moved caret from one paragraph to another (or showed or
2011 : : // hid the caret). Move focuse from one accessible
2012 : : // paragraph to another.
2013 [ # # ]: 0 : if (nOldParagraphIndex >= 0)
2014 : : {
2015 : 0 : maChildren[nOldParagraphIndex]->FireAccessibleEvent(
2016 : : AccessibleEventId::CARET_CHANGED,
2017 : : Any(nOldCharacterIndex),
2018 [ # # ]: 0 : Any(sal_Int32(-1)));
[ # # # # ]
2019 : : }
2020 [ # # ]: 0 : if (nNewParagraphIndex >= 0)
2021 : : {
2022 : 0 : maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2023 : : AccessibleEventId::CARET_CHANGED,
2024 : : Any(sal_Int32(-1)),
2025 [ # # # # ]: 0 : Any(nNewCharacterIndex));
2026 : : }
2027 : : }
2028 [ # # ]: 0 : else if (nNewParagraphIndex >= 0)
2029 : : {
2030 : : // Caret moved inside one paragraph.
2031 : 0 : maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2032 : : AccessibleEventId::CARET_CHANGED,
2033 : : Any(nOldCharacterIndex),
2034 [ # # # # ]: 0 : Any(nNewCharacterIndex));
2035 : : }
2036 : 0 : }
2037 : :
2038 : 0 : void AccessibleNotes::HandleTextChange (void)
2039 : : {
2040 : 0 : SetTextView(mpTextView);
2041 : 0 : }
2042 : :
2043 : : //===== AccessibleFocusManager ================================================
2044 : :
2045 : 8 : ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::mpInstance;
2046 : :
2047 : 0 : ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::Instance (void)
2048 : : {
2049 [ # # ]: 0 : if ( ! mpInstance)
2050 : : {
2051 [ # # ]: 0 : mpInstance.reset(new AccessibleFocusManager());
2052 : : }
2053 : 0 : return mpInstance;
2054 : : }
2055 : :
2056 : 0 : AccessibleFocusManager::AccessibleFocusManager (void)
2057 : 0 : : maFocusableObjects()
2058 : : {
2059 : 0 : }
2060 : :
2061 : 0 : void AccessibleFocusManager::AddFocusableObject (
2062 : : const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2063 : : {
2064 : : OSL_ASSERT(rpObject.is());
2065 : : OSL_ASSERT(::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject)==maFocusableObjects.end());
2066 : :
2067 : 0 : maFocusableObjects.push_back(rpObject);
2068 : 0 : }
2069 : :
2070 : 0 : void AccessibleFocusManager::RemoveFocusableObject (
2071 : : const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2072 : : {
2073 : : ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::iterator iObject (
2074 [ # # ]: 0 : ::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject));
2075 : :
2076 [ # # ][ # # ]: 0 : if (iObject != maFocusableObjects.end())
2077 [ # # ]: 0 : maFocusableObjects.erase(iObject);
2078 : : else
2079 : : {
2080 : : OSL_ASSERT(iObject!=maFocusableObjects.end());
2081 : : }
2082 : 0 : }
2083 : :
2084 : 0 : void AccessibleFocusManager::FocusObject (
2085 : : const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2086 : : {
2087 : : // Remove the focus of any of the other focusable objects.
2088 [ # # ][ # # ]: 0 : for (::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::const_iterator
2089 [ # # ]: 0 : iObject (maFocusableObjects.begin()),
2090 [ # # ]: 0 : iEnd (maFocusableObjects.end());
2091 : : iObject != iEnd;
2092 : : ++iObject)
2093 : : {
2094 [ # # ]: 0 : if (*iObject!=rpObject)
2095 [ # # ]: 0 : (*iObject)->SetIsFocused(false);
2096 : : }
2097 : :
2098 [ # # ]: 0 : if (rpObject.is())
2099 : 0 : rpObject->SetIsFocused(true);
2100 : 0 : }
2101 : :
2102 [ + - ][ + - ]: 24 : } } // end of namespace ::sd::presenter
2103 : :
2104 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|