LCOV - code coverage report
Current view: top level - accessibility/inc/accessibility/extended - AccessibleBrowseBox.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 36 0.0 %
Date: 2014-04-11 Functions: 0 10 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             : 
      20             : 
      21             : #ifndef ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOX_HXX
      22             : #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOX_HXX
      23             : 
      24             : #include <accessibility/extended/AccessibleBrowseBoxBase.hxx>
      25             : #include <boost/scoped_ptr.hpp>
      26             : #include <cppuhelper/weakref.hxx>
      27             : #include <svtools/accessibletableprovider.hxx>
      28             : 
      29             : 
      30             : 
      31             : namespace accessibility {
      32             : 
      33             :     class AccessibleBrowseBoxImpl;
      34             :     class AccessibleBrowseBoxTable;
      35             : 
      36             : 
      37             : 
      38             : /** This class represents the complete accessible BrowseBox object. */
      39             : class AccessibleBrowseBox : public AccessibleBrowseBoxBase
      40             : {
      41             :     friend class AccessibleBrowseBoxAccess;
      42             : 
      43             : protected:
      44             :     AccessibleBrowseBox(
      45             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
      46             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator,
      47             :         ::svt::IAccessibleTableProvider& _rBrowseBox
      48             :     );
      49             : 
      50             :     virtual ~AccessibleBrowseBox();
      51             : 
      52             :     /** sets the XAccessible which created the context
      53             : 
      54             :         <p>To be called only once, and only if in the ctor NULL was passed.</p>
      55             :     */
      56             :     void    setCreator(
      57             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator
      58             :     );
      59             : 
      60             :     /** Cleans up members. */
      61             :     using AccessibleBrowseBoxBase::disposing;
      62             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      63             : 
      64             : protected:
      65             :     // XAccessibleContext -----------------------------------------------------
      66             : 
      67             :     /** @return  The count of visible children. */
      68             :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
      69             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      70             : 
      71             :     /** @return  The XAccessible interface of the specified child. */
      72             :     virtual ::com::sun::star::uno::Reference<
      73             :         ::com::sun::star::accessibility::XAccessible > SAL_CALL
      74             :     getAccessibleChild( sal_Int32 nChildIndex )
      75             :         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
      76             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      77             : 
      78             :     /** @return  The role of this object (a table). */
      79             : //    virtual sal_Int16 SAL_CALL getAccessibleRole()
      80             : //        throw ( ::com::sun::star::uno::RuntimeException );
      81             : 
      82             :     // XAccessibleComponent ---------------------------------------------------
      83             : 
      84             :     /** @return
      85             :             The accessible child rendered under the given point.
      86             :     */
      87             :     virtual ::com::sun::star::uno::Reference<
      88             :         ::com::sun::star::accessibility::XAccessible > SAL_CALL
      89             :     getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )
      90             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      91             : 
      92             :     /** Grabs the focus to the BrowseBox. */
      93             :     virtual void SAL_CALL grabFocus()
      94             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      95             : 
      96             :     // XServiceInfo -----------------------------------------------------------
      97             : 
      98             :     /** @return
      99             :             The name of this class.
     100             :     */
     101             :     virtual OUString SAL_CALL getImplementationName()
     102             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     103             : 
     104             : public:
     105             :     // helper functions
     106             :     /** commitHeaderBarEvent commit the event at all listeners of the column/row header bar
     107             :         @param nEventId
     108             :             the event id
     109             :         @param rNewValue
     110             :             the new value
     111             :         @param rOldValue
     112             :             the old value
     113             :     */
     114             :     void commitHeaderBarEvent(sal_Int16 nEventId,
     115             :             const ::com::sun::star::uno::Any& rNewValue,
     116             :             const ::com::sun::star::uno::Any& rOldValue,sal_Bool _bColumnHeaderBar = sal_True);
     117             : 
     118             :     // helper functions
     119             :     /** commitTableEvent commit the event at all listeners of the table
     120             :         @param nEventId
     121             :             the event id
     122             :         @param rNewValue
     123             :             the new value
     124             :         @param rOldValue
     125             :             the old value
     126             :     */
     127             :     void commitTableEvent(sal_Int16 nEventId,
     128             :             const ::com::sun::star::uno::Any& rNewValue,
     129             :             const ::com::sun::star::uno::Any& rOldValue);
     130             : 
     131             :     /** returns the accessible object for the row or the column header bar
     132             :     */
     133             :     inline ::com::sun::star::uno::Reference<
     134             :         ::com::sun::star::accessibility::XAccessible >
     135           0 :         getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType )
     136             :         {
     137           0 :             return implGetHeaderBar(_eObjType);
     138             :         }
     139             : 
     140             :     /** returns the accessible object for the table representation
     141             :     */
     142             :     inline ::com::sun::star::uno::Reference<
     143             :         ::com::sun::star::accessibility::XAccessible >
     144           0 :         getTable( )
     145             :         {
     146           0 :             return implGetTable();
     147             :         }
     148             : 
     149             : protected:
     150             :     // internal virtual methods -----------------------------------------------
     151             : 
     152             :     /** @attention  This method requires locked mutex's and a living object.
     153             :         @return  The bounding box (VCL rect.) relative to the parent window. */
     154             :     virtual Rectangle implGetBoundingBox() SAL_OVERRIDE;
     155             :     /** @attention  This method requires locked mutex's and a living object.
     156             :         @return  The bounding box (VCL rect.) in screen coordinates. */
     157             :     virtual Rectangle implGetBoundingBoxOnScreen() SAL_OVERRIDE;
     158             : 
     159             :     // internal helper methods ------------------------------------------------
     160             : 
     161             :     /** This method creates (once) and returns the accessible data table child.
     162             :         @attention  This method requires locked mutex's and a living object.
     163             :         @return  The XAccessible interface of the data table. */
     164             :     virtual ::com::sun::star::uno::Reference<
     165             :         ::com::sun::star::accessibility::XAccessible > implGetTable();
     166             : 
     167             :     /** This method creates (once) and returns the specified header bar.
     168             :         @attention  This method requires locked mutex's and a living object.
     169             :         @return  The XAccessible interface of the header bar. */
     170             :     ::com::sun::star::uno::Reference<
     171             :         ::com::sun::star::accessibility::XAccessible >
     172             :         implGetHeaderBar( ::svt::AccessibleBrowseBoxObjType eObjType );
     173             : 
     174             :     /** This method returns one of the children that are always present:
     175             :         Data table, row and column header bar or corner control.
     176             :         @attention  This method requires locked mutex's and a living object.
     177             :         @return  The XAccessible interface of the specified child. */
     178             :     ::com::sun::star::uno::Reference<
     179             :         ::com::sun::star::accessibility::XAccessible >
     180             :     implGetFixedChild( sal_Int32 nChildIndex );
     181             : 
     182             :     /** This method creates and returns an accessible table.
     183             :         @return  An AccessibleBrowseBoxTable. */
     184             :     virtual AccessibleBrowseBoxTable*   createAccessibleTable();
     185             : 
     186             : private:
     187             :     // members ----------------------------------------------------------------
     188             :     boost::scoped_ptr< AccessibleBrowseBoxImpl > m_pImpl;
     189             : };
     190             : 
     191             : 
     192             : /** the XAccessible which creates/returns an AccessibleBrowseBox
     193             : 
     194             :     <p>The instance holds its XAccessibleContext with a hard reference, while
     195             :     the contxt holds this instance weak.</p>
     196             : */
     197             : typedef ::cppu::WeakImplHelper1 <   ::com::sun::star::accessibility::XAccessible
     198             :                                 >   AccessibleBrowseBoxAccess_Base;
     199             : 
     200             : class AccessibleBrowseBoxAccess :public AccessibleBrowseBoxAccess_Base
     201             :                                 ,public ::svt::IAccessibleBrowseBox
     202             : {
     203             : private:
     204             :     ::osl::Mutex                m_aMutex;
     205             :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     206             :                                         m_xParent;
     207             :     ::svt::IAccessibleTableProvider&    m_rBrowseBox;
     208             : 
     209             :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     210             :                                 m_xContext;
     211             :     AccessibleBrowseBox*        m_pContext;
     212             :                                     // note that this pointer is valid as long as m_xContext is valid!
     213             : 
     214             : public:
     215             :     AccessibleBrowseBoxAccess(
     216             :         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
     217             :         ::svt::IAccessibleTableProvider& _rBrowseBox
     218             :     );
     219             : 
     220             :     /// checks whether the accessible context is still alive
     221             :     bool                            isContextAlive() const;
     222             : 
     223             :     /// returns the AccessibleContext belonging to this Accessible
     224           0 :     inline AccessibleBrowseBox*            getContext()         { return m_pContext; }
     225             :     inline const AccessibleBrowseBox*      getContext() const   { return m_pContext; }
     226             : 
     227             : protected:
     228             :     virtual ~AccessibleBrowseBoxAccess();
     229             : 
     230             :     // XAccessible
     231             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     232             :         SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     233             : 
     234             :     // IAccessibleBrowseBox
     235             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     236           0 :         getMyself() SAL_OVERRIDE
     237             :     {
     238           0 :         return this;
     239             :     }
     240             :     void dispose() SAL_OVERRIDE;
     241           0 :     virtual bool isAlive() const SAL_OVERRIDE
     242             :     {
     243           0 :         return isContextAlive();
     244             :     }
     245             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     246           0 :         getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) SAL_OVERRIDE
     247             :     {
     248           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
     249           0 :         AccessibleBrowseBox* pContext( getContext() );
     250           0 :         if ( pContext )
     251           0 :             xAccessible = pContext->getHeaderBar( _eObjType );
     252           0 :         return xAccessible;
     253             :     }
     254             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     255           0 :         getTable() SAL_OVERRIDE
     256             :     {
     257           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
     258           0 :         AccessibleBrowseBox* pContext( getContext() );
     259           0 :         if ( pContext )
     260           0 :             xAccessible = pContext->getTable();
     261           0 :         return xAccessible;
     262             :     }
     263           0 :     virtual void commitHeaderBarEvent( sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
     264             :         const ::com::sun::star::uno::Any& rOldValue, bool _bColumnHeaderBar ) SAL_OVERRIDE
     265             :     {
     266           0 :         AccessibleBrowseBox* pContext( getContext() );
     267           0 :         if ( pContext )
     268           0 :             pContext->commitHeaderBarEvent( nEventId, rNewValue, rOldValue, _bColumnHeaderBar );
     269           0 :     }
     270           0 :     virtual void commitTableEvent( sal_Int16 nEventId,
     271             :         const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) SAL_OVERRIDE
     272             :     {
     273           0 :         AccessibleBrowseBox* pContext( getContext() );
     274           0 :         if ( pContext )
     275           0 :             pContext->commitTableEvent( nEventId, rNewValue, rOldValue );
     276           0 :     }
     277           0 :     virtual void commitEvent( sal_Int16 nEventId,
     278             :         const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) SAL_OVERRIDE
     279             :     {
     280           0 :         AccessibleBrowseBox* pContext( getContext() );
     281           0 :         if ( pContext )
     282           0 :             pContext->commitEvent( nEventId, rNewValue, rOldValue );
     283           0 :     }
     284             : 
     285             : private:
     286             :     AccessibleBrowseBoxAccess();                                                // never implemented
     287             :     AccessibleBrowseBoxAccess( const AccessibleBrowseBoxAccess& );              // never implemented
     288             :     AccessibleBrowseBoxAccess& operator=( const AccessibleBrowseBoxAccess& );   // never implemented
     289             : };
     290             : 
     291             : 
     292             : } // namespace accessibility
     293             : 
     294             : 
     295             : 
     296             : #endif
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10