LCOV - code coverage report
Current view: top level - sw/source/core/access - acccontext.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 16 68.8 %
Date: 2012-08-25 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _ACCBASE_HXX
      29                 :            : #define _ACCBASE_HXX
      30                 :            : #include <accframe.hxx>
      31                 :            : #include <accmap.hxx>
      32                 :            : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
      33                 :            : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
      34                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      35                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      36                 :            : #include <cppuhelper/implbase5.hxx>
      37                 :            : #include <cppuhelper/interfacecontainer.hxx>
      38                 :            : 
      39                 :            : class Window;
      40                 :            : class SwAccessibleMap;
      41                 :            : class SwCrsrShell;
      42                 :            : class SdrObject;
      43                 :            : class SwPaM;
      44                 :            : namespace utl {
      45                 :            :     class AccessibleStateSetHelper;
      46                 :            : }
      47                 :            : namespace accessibility {
      48                 :            :     class AccessibleShape;
      49                 :            : }
      50                 :            : 
      51                 :            : const sal_Char sAccessibleServiceName[] = "com.sun.star.accessibility.Accessible";
      52                 :            : 
      53                 :            : class SwAccessibleContext :
      54                 :            :     public ::cppu::WeakImplHelper5<
      55                 :            :                 ::com::sun::star::accessibility::XAccessible,
      56                 :            :                 ::com::sun::star::accessibility::XAccessibleContext,
      57                 :            :                 ::com::sun::star::accessibility::XAccessibleComponent,
      58                 :            :                 ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
      59                 :            :                 ::com::sun::star::lang::XServiceInfo
      60                 :            :                 >,
      61                 :            :     public SwAccessibleFrame
      62                 :            : {
      63                 :            :     // The implements for the XAccessibleSelection interface has been
      64                 :            :     // 'externalized' and wants access to the protected members like
      65                 :            :     // GetMap, GetChild, GetParent, and GetFrm.
      66                 :            :     friend class SwAccessibleSelectionHelper;
      67                 :            : 
      68                 :            : 
      69                 :            : protected:
      70                 :            : 
      71                 :            :     mutable ::osl::Mutex aListenerMutex;
      72                 :            :     mutable ::osl::Mutex aMutex;
      73                 :            : 
      74                 :            : private:
      75                 :            : 
      76                 :            :     ::rtl::OUString sName;  // immutable outside constructor
      77                 :            : 
      78                 :            :     // The parent if it has been retrieved. This is always an
      79                 :            :     // SwAccessibleContext. (protected by Mutex)
      80                 :            :     ::com::sun::star::uno::WeakReference <
      81                 :            :         ::com::sun::star::accessibility::XAccessible > xWeakParent;
      82                 :            : 
      83                 :            :     SwAccessibleMap *pMap;  // must be protected by solar mutex
      84                 :            : 
      85                 :            :     sal_uInt32 nClientId;   // client id in the AccessibleEventNotifier queue
      86                 :            :     sal_Int16 nRole;        // immutable outside constructor
      87                 :            : 
      88                 :            :     // The current states (protected by mutex)
      89                 :            :     sal_Bool bIsShowingState : 1;
      90                 :            :     sal_Bool bIsEditableState : 1;
      91                 :            :     sal_Bool bIsOpaqueState : 1;
      92                 :            :     sal_Bool bIsDefuncState : 1;
      93                 :            : 
      94                 :            :     // Are we currently disposing that object (protected by solar mutex)?
      95                 :            :     sal_Bool bDisposing : 1;
      96                 :            : 
      97                 :            :     // #i85634# - boolean, indicating if the accessible context is
      98                 :            :     // in general registered at the accessible map.
      99                 :            :     bool bRegisteredAtAccessibleMap;
     100                 :            : 
     101                 :            :     void InitStates();
     102                 :            : 
     103                 :            : protected:
     104                 :         79 :     void SetName( const ::rtl::OUString& rName ) { sName = rName; }
     105                 :         16 :     inline sal_Int16 GetRole() const
     106                 :            :     {
     107                 :         16 :         return nRole;
     108                 :            :     }
     109                 :            : 
     110                 :            :     void SetParent( SwAccessibleContext *pParent );
     111                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> GetWeakParent() const;
     112                 :            : 
     113                 :         68 :     sal_Bool IsDisposing() const { return bDisposing; }
     114                 :            : 
     115                 :            :     Window *GetWindow();
     116                 :      30449 :     SwAccessibleMap *GetMap() { return pMap; }
     117                 :         28 :     const SwAccessibleMap *GetMap() const { return pMap; }
     118                 :            : 
     119                 :            :     /** convenience method to get the SwViewShell through accessibility map */
     120                 :        406 :     inline ViewShell* GetShell()
     121                 :            :     {
     122                 :        406 :         return GetMap()->GetShell();
     123                 :            :     }
     124                 :            :     inline const ViewShell* GetShell() const
     125                 :            :     {
     126                 :            :         return GetMap()->GetShell();
     127                 :            :     }
     128                 :            : 
     129                 :            :     /** convenience method to get SwCrsrShell through accessibility map
     130                 :            :      * @returns SwCrsrShell, or NULL if none is found */
     131                 :            :     SwCrsrShell* GetCrsrShell();
     132                 :            :     const SwCrsrShell* GetCrsrShell() const;
     133                 :            : 
     134                 :            :     // Notify all children that the vis araea has changed.
     135                 :            :     // The SwFrm might belong to the current object or to any other child or
     136                 :            :     // grandchild.
     137                 :            :     void ChildrenScrolled( const SwFrm *pFrm, const SwRect& rOldVisArea );
     138                 :            : 
     139                 :            :     // The context's showing state changed. May only be called for context that
     140                 :            :     // exist even if they aren't visible.
     141                 :            :     void Scrolled( const SwRect& rOldVisArea );
     142                 :            : 
     143                 :            :     // A child has been moved while setting the vis area
     144                 :            :     void ScrolledWithin( const SwRect& rOldVisArea );
     145                 :            : 
     146                 :            :     // The has been added while setting the vis area
     147                 :            :     void ScrolledIn();
     148                 :            : 
     149                 :            :     // The context has to be removed while setting the vis area
     150                 :            :     void ScrolledOut( const SwRect& rOldVisArea );
     151                 :            : 
     152                 :            :     // Invalidate the states of all children of the specified SwFrm. The
     153                 :            :     // SwFrm might belong the the current object or to any child or grandchild!
     154                 :            :     // #i27301# - use new type definition for <_nStates>
     155                 :            :     void InvalidateChildrenStates( const SwFrm* _pFrm,
     156                 :            :                                    tAccessibleStates _nStates );
     157                 :            : 
     158                 :            :     // Dispose children of the specified SwFrm. The SwFrm might belong to
     159                 :            :     // the current object or to any other child or grandchild.
     160                 :            :     void DisposeChildren( const SwFrm *pFrm,
     161                 :            :                                        sal_Bool bRecursive );
     162                 :            : 
     163                 :            :     void DisposeShape( const SdrObject *pObj,
     164                 :            :                                 ::accessibility::AccessibleShape *pAccImpl );
     165                 :            :     void ScrolledInShape( const SdrObject *pObj,
     166                 :            :                                 ::accessibility::AccessibleShape *pAccImpl );
     167                 :            : 
     168                 :            :     virtual void _InvalidateContent( sal_Bool bVisibleDataFired );
     169                 :            : 
     170                 :            :     virtual void _InvalidateCursorPos();
     171                 :            :     virtual void _InvalidateFocus();
     172                 :            : 
     173                 :            : public:
     174                 :            : 
     175                 :            :     void FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventObject& rEvent );
     176                 :            : 
     177                 :            : protected:
     178                 :            : 
     179                 :            :     // broadcast visual data event
     180                 :            :     void FireVisibleDataEvent();
     181                 :            : 
     182                 :            :     // broadcast state change event
     183                 :            :     void FireStateChangedEvent( sal_Int16 nState, sal_Bool bNewState );
     184                 :            : 
     185                 :            :     // Set states for getAccessibleStateSet.
     186                 :            :     // This base class sets DEFUNC(0/1), EDITABLE(0/1), ENABLED(1),
     187                 :            :     // SHOWING(0/1), OPAQUE(0/1) and VISIBLE(1).
     188                 :            :     virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet );
     189                 :            : 
     190                 :            :      sal_Bool IsEditableState();
     191                 :            : 
     192                 :            :     virtual ::com::sun::star::awt::Rectangle SAL_CALL
     193                 :            :         getBoundsImpl(sal_Bool bRelative)
     194                 :            :         throw (::com::sun::star::uno::RuntimeException);
     195                 :            : 
     196                 :            :     // #i85634#
     197                 :          0 :     inline void NotRegisteredAtAccessibleMap()
     198                 :            :     {
     199                 :          0 :         bRegisteredAtAccessibleMap = false;
     200                 :          0 :     }
     201                 :            :     void RemoveFrmFromAccessibleMap();
     202                 :            : 
     203                 :            :     virtual ~SwAccessibleContext();
     204                 :            : 
     205                 :            : public:
     206                 :            : 
     207                 :            :     SwAccessibleContext( SwAccessibleMap *pMap, sal_Int16 nRole,
     208                 :            :                          const SwFrm *pFrm );
     209                 :            : 
     210                 :            :     //=====  XAccessible  =====================================================
     211                 :            : 
     212                 :            :     /// Return the XAccessibleContext.
     213                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
     214                 :            :         getAccessibleContext (void) throw (com::sun::star::uno::RuntimeException);
     215                 :            : 
     216                 :            :     //=====  XAccessibleContext  ==============================================
     217                 :            : 
     218                 :            :     /// Return the number of currently visible children.
     219                 :            :     virtual sal_Int32 SAL_CALL getAccessibleChildCount (void)
     220                 :            :         throw (::com::sun::star::uno::RuntimeException);
     221                 :            : 
     222                 :            :     /// Return the specified child or NULL if index is invalid.
     223                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
     224                 :            :         getAccessibleChild (sal_Int32 nIndex)
     225                 :            :         throw (::com::sun::star::uno::RuntimeException,
     226                 :            :                 ::com::sun::star::lang::IndexOutOfBoundsException);
     227                 :            : 
     228                 :            :     /// Return a reference to the parent.
     229                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
     230                 :            :         getAccessibleParent (void)
     231                 :            :         throw (::com::sun::star::uno::RuntimeException);
     232                 :            : 
     233                 :            :     /// Return this objects index among the parents children.
     234                 :            :     virtual sal_Int32 SAL_CALL
     235                 :            :         getAccessibleIndexInParent (void)
     236                 :            :         throw (::com::sun::star::uno::RuntimeException);
     237                 :            : 
     238                 :            :     /// Return this object's role.
     239                 :            :     virtual sal_Int16 SAL_CALL
     240                 :            :         getAccessibleRole (void)
     241                 :            :         throw (::com::sun::star::uno::RuntimeException);
     242                 :            : 
     243                 :            :     /// Return this object's description.
     244                 :            :     virtual ::rtl::OUString SAL_CALL
     245                 :            :         getAccessibleDescription (void)
     246                 :            :         throw (::com::sun::star::uno::RuntimeException);
     247                 :            : 
     248                 :            :     /// Return the object's current name.
     249                 :            :     virtual ::rtl::OUString SAL_CALL
     250                 :            :         getAccessibleName (void)
     251                 :            :         throw (::com::sun::star::uno::RuntimeException);
     252                 :            : 
     253                 :            :     /// Return NULL to indicate that an empty relation set.
     254                 :            :     virtual ::com::sun::star::uno::Reference<
     255                 :            :             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
     256                 :            :         getAccessibleRelationSet (void)
     257                 :            :         throw (::com::sun::star::uno::RuntimeException);
     258                 :            : 
     259                 :            :     /// Return the set of current states.
     260                 :            :     virtual ::com::sun::star::uno::Reference<
     261                 :            :             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
     262                 :            :         getAccessibleStateSet (void)
     263                 :            :         throw (::com::sun::star::uno::RuntimeException);
     264                 :            : 
     265                 :            :     /** Return the parents locale or throw exception if this object has no
     266                 :            :         parent yet/anymore.
     267                 :            :     */
     268                 :            :     virtual ::com::sun::star::lang::Locale SAL_CALL
     269                 :            :         getLocale (void)
     270                 :            :         throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
     271                 :            : 
     272                 :            :     //=====  XAccessibleEventBroadcaster  =====================================
     273                 :            : 
     274                 :            :     virtual void SAL_CALL addEventListener(
     275                 :            :             const ::com::sun::star::uno::Reference<
     276                 :            :                 ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
     277                 :            :         throw (::com::sun::star::uno::RuntimeException);
     278                 :            :     virtual void SAL_CALL removeEventListener(
     279                 :            :             const ::com::sun::star::uno::Reference<
     280                 :            :                 ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
     281                 :            :         throw (::com::sun::star::uno::RuntimeException);
     282                 :            : 
     283                 :            :     //=====  XAccessibleComponent  ============================================
     284                 :            :     virtual sal_Bool SAL_CALL containsPoint(
     285                 :            :             const ::com::sun::star::awt::Point& aPoint )
     286                 :            :         throw (::com::sun::star::uno::RuntimeException);
     287                 :            : 
     288                 :            :     virtual ::com::sun::star::uno::Reference<
     289                 :            :         ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(
     290                 :            :                 const ::com::sun::star::awt::Point& aPoint )
     291                 :            :         throw (::com::sun::star::uno::RuntimeException);
     292                 :            : 
     293                 :            :     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds()
     294                 :            :         throw (::com::sun::star::uno::RuntimeException);
     295                 :            : 
     296                 :            :     virtual ::com::sun::star::awt::Point SAL_CALL getLocation()
     297                 :            :         throw (::com::sun::star::uno::RuntimeException);
     298                 :            : 
     299                 :            :     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen()
     300                 :            :         throw (::com::sun::star::uno::RuntimeException);
     301                 :            : 
     302                 :            :     virtual ::com::sun::star::awt::Size SAL_CALL getSize()
     303                 :            :         throw (::com::sun::star::uno::RuntimeException);
     304                 :            : 
     305                 :            :     virtual void SAL_CALL grabFocus()
     306                 :            :         throw (::com::sun::star::uno::RuntimeException);
     307                 :            : 
     308                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding()
     309                 :            :         throw (::com::sun::star::uno::RuntimeException);
     310                 :            :     virtual sal_Int32 SAL_CALL getForeground()
     311                 :            :         throw (::com::sun::star::uno::RuntimeException);
     312                 :            :     virtual sal_Int32 SAL_CALL getBackground()
     313                 :            :         throw (::com::sun::star::uno::RuntimeException);
     314                 :            : 
     315                 :            : 
     316                 :            :     //=====  XServiceInfo  ====================================================
     317                 :            : 
     318                 :            :     /** Returns an identifier for the implementation of this object.
     319                 :            :     */
     320                 :            :     virtual ::rtl::OUString SAL_CALL
     321                 :            :         getImplementationName (void)
     322                 :            :         throw (::com::sun::star::uno::RuntimeException);
     323                 :            : 
     324                 :            :     /** Return whether the specified service is supported by this class.
     325                 :            :     */
     326                 :            :     virtual sal_Bool SAL_CALL
     327                 :            :         supportsService (const ::rtl::OUString& sServiceName)
     328                 :            :         throw (::com::sun::star::uno::RuntimeException);
     329                 :            : 
     330                 :            :     /** Returns a list of all supported services.  In this case that is just
     331                 :            :         the AccessibleContext service.
     332                 :            :     */
     333                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
     334                 :            :         getSupportedServiceNames (void)
     335                 :            :              throw (::com::sun::star::uno::RuntimeException);
     336                 :            : 
     337                 :            :     //====== thread safe C++ interface ========================================
     338                 :            : 
     339                 :            :     // The object is not visible an longer and should be destroyed
     340                 :            :     virtual void Dispose( sal_Bool bRecursive = sal_False );
     341                 :            : 
     342                 :            :     // The child object is not visible an longer and should be destroyed
     343                 :            :     virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrmOrObj, sal_Bool bRecursive );
     344                 :            : 
     345                 :            :     // The object has been moved by the layout
     346                 :            :     virtual void InvalidatePosOrSize( const SwRect& rFrm );
     347                 :            : 
     348                 :            :     // The vhild object has been moved by the layout
     349                 :            :     virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrmOrObj,
     350                 :            :                                            const SwRect& rFrm );
     351                 :            : 
     352                 :            :     // The content may have changed (but it hasn't tohave changed)
     353                 :            :     void InvalidateContent();
     354                 :            : 
     355                 :            :     // The caretPos has changed
     356                 :            :     void InvalidateCursorPos();
     357                 :            : 
     358                 :            :     // The Focus state has changed
     359                 :            :     void InvalidateFocus();
     360                 :            : 
     361                 :            :     // Check states
     362                 :            :     // #i27301# - use new type definition for <_nStates>
     363                 :            :     void InvalidateStates( tAccessibleStates _nStates );
     364                 :            : 
     365                 :            :     // the XAccessibleRelationSet may have changed
     366                 :            :     void InvalidateRelation( sal_uInt16 nType );
     367                 :            : 
     368                 :            :     void InvalidateTextSelection(); // #i27301# - text selection has changed
     369                 :            :     void InvalidateAttr(); // #i88069# - attributes has changed
     370                 :            : 
     371                 :            :     bool HasAdditionalAccessibleChildren();
     372                 :            : 
     373                 :            :     // #i88070# - get additional child by index
     374                 :            :     Window* GetAdditionalAccessibleChild( const sal_Int32 nIndex );
     375                 :            : 
     376                 :            :     // #i88070# - get all additional accessible children
     377                 :            :     void GetAdditionalAccessibleChildren( std::vector< Window* >* pChildren );
     378                 :            : 
     379                 :         16 :     const ::rtl::OUString& GetName() const { return sName; }
     380                 :            : 
     381                 :            :     virtual sal_Bool HasCursor();   // required by map to remember that object
     382                 :            : 
     383                 :            :     sal_Bool Select( SwPaM *pPaM, SdrObject *pObj, sal_Bool bAdd );
     384                 :         12 :     inline sal_Bool Select( SwPaM& rPaM )
     385                 :            :     {
     386                 :         12 :         return Select( &rPaM, 0, sal_False );
     387                 :            :     }
     388                 :          0 :     inline sal_Bool Select( SdrObject *pObj, sal_Bool bAdd )
     389                 :            :     {
     390                 :          0 :         return Select( 0, pObj, bAdd );
     391                 :            :     }
     392                 :            : 
     393                 :            :     static ::rtl::OUString GetResource( sal_uInt16 nResId,
     394                 :            :                                         const ::rtl::OUString *pArg1 = 0,
     395                 :            :                                         const ::rtl::OUString *pArg2 = 0 );
     396                 :            : 
     397                 :            : 
     398                 :            : };
     399                 :            : 
     400                 :            : // some heaviliy used exception support
     401                 :            : const sal_Char sDefunc[] = "object is defunctional";
     402                 :            : const sal_Char sMissingWindow[] = "window is missing";
     403                 :            : 
     404                 :            : #define THROW_RUNTIME_EXCEPTION( ifc, msg )                                 \
     405                 :            :     ::com::sun::star::uno::Reference < ifc > xThis( this );                 \
     406                 :            :     ::com::sun::star::uno::RuntimeException aExcept(                        \
     407                 :            :         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(msg) ), xThis );       \
     408                 :            :     throw aExcept;
     409                 :            : 
     410                 :            : #define CHECK_FOR_DEFUNC_THIS( ifc, ths )                                   \
     411                 :            :     if( !(GetFrm() && GetMap()) )                                           \
     412                 :            :     {                                                                       \
     413                 :            :         ::com::sun::star::uno::Reference < ifc > xThis( ths );              \
     414                 :            :         ::com::sun::star::lang::DisposedException aExcept(                  \
     415                 :            :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(sDefunc) ),        \
     416                 :            :             xThis );                                                        \
     417                 :            :         throw aExcept;                                                      \
     418                 :            :     }
     419                 :            : 
     420                 :            : #define CHECK_FOR_DEFUNC( ifc )                                             \
     421                 :            :     CHECK_FOR_DEFUNC_THIS( ifc, this )
     422                 :            : 
     423                 :            : #define CHECK_FOR_WINDOW( i, w )                                            \
     424                 :            :     if( !(w) )                                                              \
     425                 :            :     {                                                                       \
     426                 :            :         THROW_RUNTIME_EXCEPTION( i, sMissingWindow );                       \
     427                 :            :     }
     428                 :            : #endif
     429                 :            : 
     430                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10