LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterAccessibility.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 680 0.3 %
Date: 2014-04-11 Functions: 2 123 1.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10