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

Generated by: LCOV version 1.10