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

Generated by: LCOV version 1.10