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