LCOV - code coverage report
Current view: top level - chart2/source/controller/inc - AccessibleBase.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 3 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 0.0 %
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             : #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_INC_ACCESSIBLEBASE_HXX
      20             : #define INCLUDED_CHART2_SOURCE_CONTROLLER_INC_ACCESSIBLEBASE_HXX
      21             : 
      22             : #include "ObjectIdentifier.hxx"
      23             : 
      24             : #include <com/sun/star/chart2/XChartDocument.hpp>
      25             : #include <com/sun/star/accessibility/XAccessible.hpp>
      26             : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
      27             : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
      28             : #include <com/sun/star/lang/XServiceInfo.hpp>
      29             : #include <com/sun/star/document/XEventListener.hpp>
      30             : #include <com/sun/star/lang/XEventListener.hpp>
      31             : #include <com/sun/star/lang/DisposedException.hpp>
      32             : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
      33             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      34             : #include <comphelper/accessibleeventnotifier.hxx>
      35             : #include <cppuhelper/compbase6.hxx>
      36             : #include <cppuhelper/interfacecontainer.hxx>
      37             : #include <unotools/accessiblestatesethelper.hxx>
      38             : 
      39             : #include <vector>
      40             : #include <map>
      41             : #include <boost/shared_ptr.hpp>
      42             : 
      43             : #include "MutexContainer.hxx"
      44             : 
      45             : class SdrView;
      46             : 
      47             : namespace accessibility
      48             : {
      49             : class IAccessibleViewForwarder;
      50             : }
      51             : 
      52             : namespace chart
      53             : {
      54             : 
      55             : class AccessibleBase;
      56             : class ObjectHierarchy;
      57             : 
      58             : typedef ObjectIdentifier AccessibleUniqueId;
      59             : 
      60           0 : struct AccessibleElementInfo
      61             : {
      62             :     AccessibleUniqueId m_aOID;
      63             : 
      64             :     ::com::sun::star::uno::WeakReference<
      65             :             ::com::sun::star::chart2::XChartDocument > m_xChartDocument;
      66             :     ::com::sun::star::uno::WeakReference<
      67             :             ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier;
      68             :     ::com::sun::star::uno::WeakReference<
      69             :             ::com::sun::star::uno::XInterface >   m_xView;
      70             :     ::com::sun::star::uno::WeakReference<
      71             :             ::com::sun::star::awt::XWindow >      m_xWindow;
      72             : 
      73             :     ::boost::shared_ptr< ObjectHierarchy > m_spObjectHierarchy;
      74             : 
      75             :     AccessibleBase * m_pParent;
      76             :     SdrView* m_pSdrView;
      77             :     ::accessibility::IAccessibleViewForwarder* m_pViewForwarder;
      78             : };
      79             : 
      80             : namespace impl
      81             : {
      82             : typedef ::cppu::WeakComponentImplHelper6<
      83             :         ::com::sun::star::accessibility::XAccessible,
      84             :         ::com::sun::star::accessibility::XAccessibleContext,
      85             :         ::com::sun::star::accessibility::XAccessibleComponent,
      86             :         ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
      87             :         ::com::sun::star::lang::XServiceInfo,
      88             :         ::com::sun::star::lang::XEventListener
      89             :         > AccessibleBase_Base;
      90             : }
      91             : 
      92             : /** Base class for all Chart Accessibility objects
      93             :  */
      94             : class AccessibleBase :
      95             :     public MutexContainer,
      96             :     public impl::AccessibleBase_Base
      97             : {
      98             : public:
      99             :     enum EventType
     100             :     {
     101             :         OBJECT_CHANGE,
     102             :         GOT_SELECTION,
     103             :         LOST_SELECTION,
     104             :         PROPERTY_CHANGE
     105             :     };
     106             : 
     107             :     AccessibleBase( const AccessibleElementInfo & rAccInfo,
     108             :                     bool bMayHaveChildren,
     109             :                     bool bAlwaysTransparent = false );
     110             :     virtual ~AccessibleBase();
     111             : 
     112             : protected:
     113             :     // for all calls to protected methods it is assumed that the mutex is locked
     114             :     // unless calls outside via UNO, e.g. event notification, are done
     115             : 
     116             :     /** @param bThrowException if true, a DisposedException is thrown if the
     117             :                object is already disposed
     118             :         @return true, if the component is already disposed and bThrowException is false,
     119             :                 false otherwise
     120             :      */
     121             :     bool             CheckDisposeState( bool bThrowException = true ) const throw (::com::sun::star::lang::DisposedException);
     122             : 
     123             :     /** Events coming from the core have to be processed in this methods.  The
     124             :         default implementation returns false, which indicates that the object is
     125             :         not interested in the event.  To react on events you have to implement
     126             :         this method in derived classes.
     127             : 
     128             :         The default implementation iterates over all children and forwards the
     129             :         event until the first child returns true.
     130             : 
     131             :         @param nObjId contains the object id of chart objects.  If the object is
     132             :                 no chart object, the event is not broadcast.
     133             :         @return If an object is the addressee of the event it should return
     134             :                 true, false otherwise.
     135             :      */
     136             :     bool     NotifyEvent( EventType eType, const AccessibleUniqueId & rId );
     137             : 
     138             :     /** Adds a state to the set.
     139             :     */
     140             :     void             AddState( sal_Int16 aState ) throw (::com::sun::star::uno::RuntimeException);
     141             : 
     142             :     /** Removes a state from the set if the set contains the state, otherwise
     143             :         nothing is done.
     144             :     */
     145             :     void             RemoveState( sal_Int16 aState ) throw (::com::sun::star::uno::RuntimeException);
     146             : 
     147             :     /** has to be overridden by derived classes that support child elements.
     148             :         With this method a rescan is initiated that should result in a correct
     149             :         list of children.
     150             : 
     151             :         This method is called when access to any methods concerning children is
     152             :         invoked for the first time.
     153             :      */
     154             :     bool UpdateChildren();
     155             : 
     156             :     /** Is called by UpdateChildren.  This method is only called if an update is
     157             :         really necessary.
     158             :      */
     159             :     virtual bool ImplUpdateChildren();
     160             : 
     161             :     /** adds a child to the end of the internal vector of children.  As a
     162             :         result, the child-count increases by one, but all existing children keep
     163             :         their indices.
     164             : 
     165             :         Important: as the implementation is needed, this should remain the only
     166             :         method for adding children (i.e. there mustn't be an AddChild( Reference<
     167             :         XAccessible > ) or the like).
     168             :      */
     169             :     void         AddChild( AccessibleBase* pChild );
     170             : 
     171             :     /** removes a child from the internal vector.  All children with index
     172             :         greater than the index of the removed element get an index one less than
     173             :         before.
     174             :      */
     175             :     void         RemoveChildByOId( const ObjectIdentifier& rOId );
     176             : 
     177             :     /** Retrieve the pixel coordinates of logical coordinates (0,0) of the
     178             :         current logic coordinate system.  This can be used for
     179             :         getLocationOnScreen, if the coordinates of an object are not relative to
     180             :         its direct parent, but a parent higher up in hierarchy.
     181             : 
     182             :         @return the (x,y) pixel coordinates of the upper left corner
     183             :      */
     184             :     virtual ::com::sun::star::awt::Point   GetUpperLeftOnScreen() const;
     185             : 
     186             :     /** This method creates an AccessibleEventObject and sends it to all
     187             :         listeners that are currently listening to this object
     188             : 
     189             :         If bSendGlobally is true, the event is also broadcast via
     190             :         vcl::unohelper::NotifyAccessibleStateEventGlobally()
     191             :      */
     192             :     void         BroadcastAccEvent( sal_Int16 nId,
     193             :                                     const ::com::sun::star::uno::Any & rNew,
     194             :                                     const ::com::sun::star::uno::Any & rOld,
     195             :                                     bool bSendGlobally = false ) const;
     196             : 
     197             :     /** Removes all children from the internal lists and broadcasts child remove
     198             :         events.
     199             : 
     200             :         This method cares about mutex locking, and thus should be called without
     201             :         the mutex locked.
     202             :      */
     203             :     void KillAllChildren();
     204             : 
     205             :     /** Is called from getAccessibleChild(). Before this method is called, an
     206             :         update of children is done if necessary.
     207             :      */
     208             :     virtual ::com::sun::star::uno::Reference<
     209             :             ::com::sun::star::accessibility::XAccessible >
     210             :         ImplGetAccessibleChildById( sal_Int32 i ) const
     211             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     212             :                ::com::sun::star::uno::RuntimeException);
     213             : 
     214             :     /** Is called from getAccessibleChildCount(). Before this method is called,
     215             :         an update of children is done if necessary.
     216             :      */
     217             :     virtual sal_Int32 ImplGetAccessibleChildCount() const
     218             :         throw (::com::sun::star::uno::RuntimeException);
     219             : 
     220           0 :     AccessibleElementInfo GetInfo() const { return m_aAccInfo;}
     221             :     void SetInfo( const AccessibleElementInfo & rNewInfo );
     222           0 :     AccessibleUniqueId GetId() const { return m_aAccInfo.m_aOID;}
     223             : 
     224             :     // ________ WeakComponentImplHelper (XComponent::dispose) ________
     225             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     226             : 
     227             :     // ________ XAccessible ________
     228             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext()
     229             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     230             : 
     231             :     // ________ XAccessibleContext ________
     232             :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
     233             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     234             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
     235             :         getAccessibleChild( sal_Int32 i )
     236             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     237             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     238             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
     239             :         getAccessibleParent()
     240             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     241             :     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
     242             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     243             :     /// @return AccessibleRole.SHAPE
     244             :     virtual sal_Int16 SAL_CALL getAccessibleRole()
     245             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     246             :     // has to be implemented by derived classes
     247             : //     virtual OUString SAL_CALL getAccessibleName()
     248             : //         throw (::com::sun::star::uno::RuntimeException);
     249             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL
     250             :         getAccessibleRelationSet()
     251             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     252             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
     253             :         getAccessibleStateSet()
     254             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     255             :     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale()
     256             :         throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException,
     257             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     258             :     // has to be implemented by derived classes
     259             : //     virtual OUString SAL_CALL getAccessibleDescription()
     260             : //         throw (::com::sun::star::uno::RuntimeException);
     261             : 
     262             :     // ________ XAccessibleComponent ________
     263             :     virtual sal_Bool SAL_CALL containsPoint(
     264             :         const ::com::sun::star::awt::Point& aPoint )
     265             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     266             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
     267             :         getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint )
     268             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     269             :     // has to be defined in derived classes
     270             :     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds()
     271             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     272             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocation()
     273             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     274             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen()
     275             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     276             :     virtual ::com::sun::star::awt::Size SAL_CALL getSize()
     277             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     278             :     virtual void SAL_CALL grabFocus()
     279             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     280             :     virtual sal_Int32 SAL_CALL getForeground()
     281             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     282             :     virtual sal_Int32 SAL_CALL getBackground()
     283             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     284             : 
     285             :     // ________ XServiceInfo ________
     286             :     virtual OUString SAL_CALL getImplementationName()
     287             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     288             :     virtual sal_Bool SAL_CALL supportsService(
     289             :         const OUString& ServiceName )
     290             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     291             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
     292             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     293             : 
     294             :     // ________ XEventListener ________
     295             :     virtual void SAL_CALL disposing(
     296             :         const ::com::sun::star::lang::EventObject& Source )
     297             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     298             : 
     299             :     // ________ XAccessibleEventBroadcaster ________
     300             :     virtual void SAL_CALL addAccessibleEventListener(
     301             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
     302             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     303             :     virtual void SAL_CALL removeAccessibleEventListener(
     304             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
     305             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     306             : 
     307             : private:
     308             :     enum eColorType
     309             :     {
     310             :         ACC_BASE_FOREGROUND,
     311             :         ACC_BASE_BACKGROUND
     312             :     };
     313             :     sal_Int32 getColor( eColorType eColType );
     314             : 
     315             : private:
     316             :     typedef ::com::sun::star::uno::Reference<
     317             :             ::com::sun::star::accessibility::XAccessible > tAccessible;
     318             :     /** type of the vector containing the accessible children
     319             :      */
     320             :     typedef ::std::vector< tAccessible > ChildListVectorType;
     321             :     /** type of the hash containing a vector index for every AccessibleUniqueId
     322             :         of the object in the child list
     323             :      */
     324             :     typedef ::std::map< ObjectIdentifier, tAccessible > ChildOIDMap;
     325             : 
     326             :     bool                                  m_bIsDisposed;
     327             :     const bool                            m_bMayHaveChildren;
     328             :     bool                                  m_bChildrenInitialized;
     329             :     ChildListVectorType                   m_aChildList;
     330             : 
     331             :     ChildOIDMap                           m_aChildOIDMap;
     332             : 
     333             :     ::comphelper::AccessibleEventNotifier::TClientId      m_nEventNotifierId;
     334             : 
     335             :     /** Implementation helper for getAccessibleStateSet()
     336             : 
     337             :         Note: This member must come before m_aStateSet!
     338             :      */
     339             :     ::utl::AccessibleStateSetHelper *     m_pStateSetHelper;
     340             :     /** this is returned in getAccessibleStateSet().
     341             : 
     342             :         The implementation is an ::utl::AccessibleStateSetHelper.  To access
     343             :         implementation methods use m_pStateSetHelper.
     344             : 
     345             :         Note: Keeping this reference ensures, that the helper object is only
     346             :               destroyed after this object has been disposed().
     347             :      */
     348             :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet >
     349             :         m_aStateSet;
     350             : 
     351             :     AccessibleElementInfo  m_aAccInfo;
     352             :     const bool             m_bAlwaysTransparent;
     353             :     /** denotes if the state-set is initialized.  On initialization the selected
     354             :         state is checked.
     355             : 
     356             :         This variable is monitored by the solar mutex!
     357             : 
     358             :         Note: declared volatile to enable double-check-locking
     359             :      */
     360             :     volatile bool          m_bStateSetInitialized;
     361             : };
     362             : 
     363             : }  // namespace chart
     364             : 
     365             : #endif
     366             : 
     367             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11