LCOV - code coverage report
Current view: top level - sc/source/ui/inc - AccessibleContextBase.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 3 33.3 %
Date: 2014-11-03 Functions: 1 3 33.3 %
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             : #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
      21             : #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
      22             : 
      23             : #include <com/sun/star/accessibility/XAccessible.hpp>
      24             : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
      25             : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
      26             : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
      27             : #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
      28             : #include <com/sun/star/lang/DisposedException.hpp>
      29             : #include <com/sun/star/uno/Reference.hxx>
      30             : #include <cppuhelper/weak.hxx>
      31             : #include <com/sun/star/lang/XServiceInfo.hpp>
      32             : #include <com/sun/star/lang/XTypeProvider.hpp>
      33             : #include <com/sun/star/lang/XServiceName.hpp>
      34             : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      35             : #include <osl/mutex.hxx>
      36             : #include <cppuhelper/interfacecontainer.h>
      37             : 
      38             : #include <svl/lstner.hxx>
      39             : #include <cppuhelper/compbase5.hxx>
      40             : #include <cppuhelper/implbase1.hxx>
      41             : #include <comphelper/servicehelper.hxx>
      42             : #include <comphelper/broadcasthelper.hxx>
      43             : 
      44             : class Rectangle;
      45             : 
      46             : /** @descr
      47             :         This base class provides an implementation of the
      48             :         <code>AccessibleContext</code> service.
      49             : */
      50             : 
      51             : typedef cppu::WeakAggComponentImplHelper5<
      52             :                 ::com::sun::star::accessibility::XAccessible,
      53             :                 ::com::sun::star::accessibility::XAccessibleComponent,
      54             :                 ::com::sun::star::accessibility::XAccessibleContext,
      55             :                 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
      56             :                 ::com::sun::star::lang::XServiceInfo
      57             :                 > ScAccessibleContextBaseWeakImpl;
      58             : 
      59             : typedef cppu::ImplHelper1<
      60             :                 ::com::sun::star::accessibility::XAccessibleEventListener
      61             :                 > ScAccessibleContextBaseImplEvent;
      62             : 
      63             : class ScAccessibleContextBase
      64             :     :   public comphelper::OBaseMutex,
      65             :         public ScAccessibleContextBaseWeakImpl,
      66             :         public ScAccessibleContextBaseImplEvent,
      67             :         public SfxListener
      68             : {
      69             : public:
      70             :     //=====  internal  ========================================================
      71             :     ScAccessibleContextBase(
      72             :         const ::com::sun::star::uno::Reference<
      73             :         ::com::sun::star::accessibility::XAccessible>& rxParent,
      74             :         const sal_Int16 aRole);
      75             : 
      76             :     virtual void Init();
      77             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      78             : protected:
      79             :     virtual ~ScAccessibleContextBase(void);
      80             : public:
      81             : 
      82             :     virtual bool SAL_CALL isShowing(  )
      83             :         throw (::com::sun::star::uno::RuntimeException);
      84             : 
      85             :     virtual bool SAL_CALL isVisible()
      86             :         throw (::com::sun::star::uno::RuntimeException, std::exception);
      87             : 
      88             :     ///=====  SfxListener  =====================================================
      89             : 
      90             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
      91             : 
      92             :     ///=====  XInterface  =====================================================
      93             : 
      94             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
      95             :         ::com::sun::star::uno::Type const & rType )
      96             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
      99             : 
     100             :     virtual void SAL_CALL release() throw () SAL_OVERRIDE;
     101             : 
     102             :     ///=====  XAccessible  =====================================================
     103             : 
     104             :     /// Return the XAccessibleContext.
     105             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
     106             :         getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             : 
     108             :     ///=====  XAccessibleComponent  ============================================
     109             : 
     110             :     virtual sal_Bool SAL_CALL containsPoint(
     111             :         const ::com::sun::star::awt::Point& rPoint )
     112             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             : 
     114             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     115             :         SAL_CALL getAccessibleAtPoint(
     116             :         const ::com::sun::star::awt::Point& rPoint )
     117             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     118             : 
     119             :     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  )
     120             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             : 
     122             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  )
     123             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     124             : 
     125             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  )
     126             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             : 
     128             :     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  )
     129             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :     virtual void SAL_CALL grabFocus(  )
     132             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             : 
     134             :     virtual sal_Int32 SAL_CALL getForeground(  )
     135             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             : 
     137             :     virtual sal_Int32 SAL_CALL getBackground(  )
     138             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             : 
     140             :     ///=====  XAccessibleContext  ==============================================
     141             : 
     142             :     /// Return the number of currently visible children.
     143             :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
     144             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             : 
     146             :     /// Return the specified child or NULL if index is invalid.
     147             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
     148             :         getAccessibleChild(sal_Int32 nIndex)
     149             :         throw (::com::sun::star::uno::RuntimeException,
     150             :                ::com::sun::star::lang::IndexOutOfBoundsException,
     151             :                std::exception) SAL_OVERRIDE;
     152             : 
     153             :     /// Return a reference to the parent.
     154             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
     155             :         getAccessibleParent(void)
     156             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             : 
     158             :     /// Return this objects index among the parents children.
     159             :     virtual sal_Int32 SAL_CALL
     160             :         getAccessibleIndexInParent(void)
     161             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             : 
     163             :     /// Return this object's role.
     164             :     virtual sal_Int16 SAL_CALL
     165             :         getAccessibleRole(void)
     166             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : 
     168             :     /// Return this object's description.
     169             :     virtual OUString SAL_CALL
     170             :         getAccessibleDescription(void)
     171             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             : 
     173             :     /// Return the object's current name.
     174             :     virtual OUString SAL_CALL
     175             :         getAccessibleName(void)
     176             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             : 
     178             :     /// Return NULL to indicate that an empty relation set.
     179             :     virtual ::com::sun::star::uno::Reference<
     180             :             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
     181             :         getAccessibleRelationSet()
     182             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     183             : 
     184             :     /// Return the set of current states.
     185             :     virtual ::com::sun::star::uno::Reference<
     186             :             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
     187             :         getAccessibleStateSet(void)
     188             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     189             : 
     190             :     /** Return the parents locale or throw exception if this object has no
     191             :         parent yet/anymore.
     192             :     */
     193             :     virtual ::com::sun::star::lang::Locale SAL_CALL
     194             :         getLocale(void)
     195             :         throw (::com::sun::star::uno::RuntimeException,
     196             :             ::com::sun::star::accessibility::IllegalAccessibleComponentStateException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :     ///=====  XAccessibleEventBroadcaster  =====================================
     199             : 
     200             :     /** Add listener that is informed of future changes of name,
     201             :           description and so on events.
     202             :     */
     203             :     virtual void SAL_CALL
     204             :         addAccessibleEventListener(
     205             :             const ::com::sun::star::uno::Reference<
     206             :                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
     207             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     208             : 
     209             :     //  Remove an existing event listener.
     210             :     virtual void SAL_CALL
     211             :         removeAccessibleEventListener(
     212             :             const ::com::sun::star::uno::Reference<
     213             :                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
     214             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     215             : 
     216             :     ///=====  XAccessibleEventListener  ========================================
     217             : 
     218             :     virtual void SAL_CALL
     219             :         disposing( const ::com::sun::star::lang::EventObject& Source )
     220             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     221             : 
     222             :     virtual void SAL_CALL
     223             :         notifyEvent(
     224             :         const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
     225             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     226             : 
     227             :     ///=====  XServiceInfo  ====================================================
     228             : 
     229             :     /** Returns an identifier for the implementation of this object.
     230             :     */
     231             :     virtual OUString SAL_CALL
     232             :         getImplementationName(void)
     233             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     234             : 
     235             :     /** Return whether the specified service is supported by this class.
     236             :     */
     237             :     virtual sal_Bool SAL_CALL
     238             :         supportsService(const OUString& sServiceName)
     239             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     240             : 
     241             :     /** Returns a list of all supported services.  In this case that is just
     242             :         the AccessibleContext and Accessible service.
     243             :     */
     244             :     virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL
     245             :         getSupportedServiceNames(void)
     246             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     247             : 
     248             :     ///=====  XTypeProvider  ===================================================
     249             : 
     250             :      /// returns the possible types
     251             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
     252             :         getTypes()
     253             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     254             : 
     255             :     /** Returns a implementation id.
     256             :     */
     257             :     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
     258             :         getImplementationId(void)
     259             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     260             : 
     261             : protected:
     262             :     /// Return this object's description.
     263             :     virtual OUString SAL_CALL
     264             :         createAccessibleDescription(void)
     265             :         throw (::com::sun::star::uno::RuntimeException);
     266             : 
     267             :     /// Return the object's current name.
     268             :     virtual OUString SAL_CALL
     269             :         createAccessibleName(void)
     270             :         throw (::com::sun::star::uno::RuntimeException,
     271             :                std::exception);
     272             : 
     273             :     /// Return the object's current bounding box relative to the desktop.
     274             :     virtual Rectangle GetBoundingBoxOnScreen() const
     275             :         throw (::com::sun::star::uno::RuntimeException, std::exception);
     276             : 
     277             :     /// Return the object's current bounding box relative to the parent object.
     278             :     virtual Rectangle GetBoundingBox() const
     279             :         throw (::com::sun::star::uno::RuntimeException, std::exception);
     280             : 
     281             : public:
     282             :     /// Calls all Listener to tell they the change.
     283             :     void
     284             :         CommitChange(const com::sun::star::accessibility::AccessibleEventObject& rEvent) const;
     285             : 
     286             : protected:
     287             :     /// Calls all FocusListener to tell they that the focus is gained.
     288             :     void CommitFocusGained() const;
     289             : 
     290             :     /// Calls all FocusListener to tell they that the focus is lost.
     291             :     void CommitFocusLost() const;
     292             : 
     293         938 :     bool IsDefunc() const { return rBHelper.bDisposed; }
     294             : 
     295             :     virtual void IsObjectValid() const
     296             :         throw (::com::sun::star::lang::DisposedException);
     297             : 
     298             :     /// Use this method to set initial Name without notification
     299           0 :     void SetName(const OUString& rName) { msName = rName; }
     300             :     /// Use this method to set initial Description without notification
     301           0 :     void SetDescription(const OUString& rDesc) { msDescription = rDesc; }
     302             : 
     303             :     /// Reference to the parent object.
     304             :     ::com::sun::star::uno::Reference<
     305             :          ::com::sun::star::accessibility::XAccessible> mxParent;
     306             : 
     307             : private:
     308             :     /** Description of this object.  This is not a constant because it can
     309             :         be set from the outside.  Furthermore, it changes according the the
     310             :         draw page's display mode.
     311             :     */
     312             :     OUString msDescription;
     313             : 
     314             :     /** Name of this object.  It changes according the draw page's
     315             :         display mode.
     316             :     */
     317             :     OUString msName;
     318             : 
     319             :     /// client id in the AccessibleEventNotifier queue
     320             :     sal_uInt32 mnClientId;
     321             : 
     322             :     /** This is the role of this object.
     323             :     */
     324             :     sal_Int16 maRole;
     325             : };
     326             : 
     327             : #endif
     328             : 
     329             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10