LCOV - code coverage report
Current view: top level - sw/source/ui/docvw - SidebarWinAcc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 74 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 2008 by Sun Microsystems, Inc.
       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                 :            : 
      29                 :            : #include <SidebarWinAcc.hxx>
      30                 :            : 
      31                 :            : #include <SidebarWin.hxx>
      32                 :            : #include <viewsh.hxx>
      33                 :            : #include <accmap.hxx>
      34                 :            : #include <toolkit/awt/vclxaccessiblecomponent.hxx>
      35                 :            : 
      36                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      37                 :            : 
      38                 :            : namespace css = ::com::sun::star;
      39                 :            : 
      40                 :            : namespace sw { namespace sidebarwindows {
      41                 :            : 
      42                 :            : // =============================================================================
      43                 :            : // declaration and implementation of accessible context for <SidebarWinAccessible> instance
      44                 :            : // =============================================================================
      45                 :            : class SidebarWinAccessibleContext : public VCLXAccessibleComponent
      46                 :            : {
      47                 :            :     public:
      48                 :          0 :         explicit SidebarWinAccessibleContext( SwSidebarWin& rSidebarWin,
      49                 :            :                                               ViewShell& rViewShell,
      50                 :            :                                               const SwFrm* pAnchorFrm )
      51                 :            :             : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() )
      52                 :            :             , mrViewShell( rViewShell )
      53                 :            :             , mpAnchorFrm( pAnchorFrm )
      54         [ #  # ]:          0 :             , maMutex()
      55                 :            :         {
      56         [ #  # ]:          0 :             rSidebarWin.SetAccessibleRole( css::accessibility::AccessibleRole::COMMENT );
      57                 :          0 :         }
      58                 :            : 
      59                 :          0 :         virtual ~SidebarWinAccessibleContext()
      60 [ #  # ][ #  # ]:          0 :         {}
      61                 :            : 
      62                 :          0 :         void ChangeAnchor( const SwFrm* pAnchorFrm )
      63                 :            :         {
      64         [ #  # ]:          0 :             osl::MutexGuard aGuard(maMutex);
      65                 :            : 
      66         [ #  # ]:          0 :             mpAnchorFrm = pAnchorFrm;
      67                 :          0 :         }
      68                 :            : 
      69                 :            :         virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
      70                 :          0 :             getAccessibleParent() throw (css::uno::RuntimeException)
      71                 :            :         {
      72         [ #  # ]:          0 :             osl::MutexGuard aGuard(maMutex);
      73                 :            : 
      74                 :          0 :             css::uno::Reference< css::accessibility::XAccessible > xAccParent;
      75                 :            : 
      76 [ #  # ][ #  # ]:          0 :             if ( mpAnchorFrm &&
                 [ #  # ]
      77         [ #  # ]:          0 :                  mrViewShell.GetAccessibleMap() )
      78                 :            :             {
      79 [ #  # ][ #  # ]:          0 :                 xAccParent = mrViewShell.GetAccessibleMap()->GetContext( mpAnchorFrm, sal_False );
                 [ #  # ]
      80                 :            :             }
      81                 :            : 
      82         [ #  # ]:          0 :             return xAccParent;
      83                 :            :         }
      84                 :            : 
      85                 :          0 :         virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (css::uno::RuntimeException)
      86                 :            :         {
      87         [ #  # ]:          0 :             osl::MutexGuard aGuard(maMutex);
      88                 :            : 
      89                 :          0 :             sal_Int32 nIndex( -1 );
      90                 :            : 
      91 [ #  # ][ #  # ]:          0 :             if ( mpAnchorFrm && GetWindow() &&
         [ #  # ][ #  # ]
                 [ #  # ]
      92         [ #  # ]:          0 :                  mrViewShell.GetAccessibleMap() )
      93                 :            :             {
      94                 :            :                 nIndex = mrViewShell.GetAccessibleMap()->GetChildIndex( *mpAnchorFrm,
      95 [ #  # ][ #  # ]:          0 :                                                                         *GetWindow() );
                 [ #  # ]
      96                 :            :             }
      97                 :            : 
      98         [ #  # ]:          0 :             return nIndex;
      99                 :            :         }
     100                 :            : 
     101                 :            :     private:
     102                 :            :         ViewShell& mrViewShell;
     103                 :            :         const SwFrm* mpAnchorFrm;
     104                 :            : 
     105                 :            :         ::osl::Mutex maMutex;
     106                 :            : };
     107                 :            : 
     108                 :            : // =============================================================================
     109                 :            : // implementaion of accessible for <SwSidebarWin> instance
     110                 :            : // =============================================================================
     111                 :          0 : SidebarWinAccessible::SidebarWinAccessible( SwSidebarWin& rSidebarWin,
     112                 :            :                                             ViewShell& rViewShell,
     113                 :            :                                             const SwSidebarItem& rSidebarItem )
     114                 :            :     : VCLXWindow()
     115                 :            :     , mrSidebarWin( rSidebarWin )
     116                 :            :     , mrViewShell( rViewShell )
     117                 :            :     , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm )
     118                 :          0 :     , bAccContextCreated( false )
     119                 :            : {
     120         [ #  # ]:          0 :     SetWindow( &mrSidebarWin );
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : SidebarWinAccessible::~SidebarWinAccessible()
     124                 :            : {
     125         [ #  # ]:          0 : }
     126                 :            : 
     127                 :          0 : void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& rSidebarItem )
     128                 :            : {
     129         [ #  # ]:          0 :     if ( bAccContextCreated )
     130                 :            :     {
     131                 :            :         css::uno::Reference< css::accessibility::XAccessibleContext > xAcc
     132         [ #  # ]:          0 :                                                     = getAccessibleContext();
     133         [ #  # ]:          0 :         if ( xAcc.is() )
     134                 :            :         {
     135                 :            :             SidebarWinAccessibleContext* pAccContext =
     136 [ #  # ][ #  # ]:          0 :                         dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get());
     137         [ #  # ]:          0 :             if ( pAccContext )
     138                 :            :             {
     139         [ #  # ]:          0 :                 pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrm );
     140                 :            :             }
     141                 :          0 :         }
     142                 :            :     }
     143                 :          0 : }
     144                 :            : 
     145                 :          0 : css::uno::Reference< css::accessibility::XAccessibleContext > SidebarWinAccessible::CreateAccessibleContext()
     146                 :            : {
     147                 :            :     SidebarWinAccessibleContext* pAccContext =
     148                 :            :                                 new SidebarWinAccessibleContext( mrSidebarWin,
     149                 :            :                                                                  mrViewShell,
     150         [ #  # ]:          0 :                                                                  mpAnchorFrm );
     151         [ #  # ]:          0 :     css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
     152                 :          0 :     bAccContextCreated = true;
     153                 :          0 :     return xAcc;
     154                 :            : }
     155                 :            : 
     156                 :            : } } // end of namespace sw::sidebarwindows
     157                 :            : 
     158                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10