LCOV - code coverage report
Current view: top level - sw/source/core/access - accfrmobjmap.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 38 62 61.3 %
Date: 2014-04-11 Functions: 4 4 100.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             : #include <accfrmobjmap.hxx>
      21             : #include <accframe.hxx>
      22             : #include <accmap.hxx>
      23             : #include <acccontext.hxx>
      24             : 
      25             : #include <viewsh.hxx>
      26             : #include <doc.hxx>
      27             : #include <frmfmt.hxx>
      28             : #include <pagefrm.hxx>
      29             : #include <txtfrm.hxx>
      30             : #include <node.hxx>
      31             : #include <sortedobjs.hxx>
      32             : #include <anchoredobject.hxx>
      33             : 
      34             : #include <svx/svdobj.hxx>
      35             : 
      36             : using namespace sw::access;
      37             : 
      38           2 : SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
      39             :                                             const SwFrm& rFrm,
      40             :                                             SwAccessibleMap& rAccMap )
      41           2 :     : nHellId( rAccMap.GetShell()->GetDoc()->GetHellId() )
      42           4 :     , nControlsId( rAccMap.GetShell()->GetDoc()->GetControlsId() )
      43             : {
      44           2 :     const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrm ).IsVisibleChildrenOnly();
      45             : 
      46           2 :     sal_uInt32 nPos = 0;
      47           2 :     SwAccessibleChild aLower( rFrm.GetLower() );
      48           6 :     while( aLower.GetSwFrm() )
      49             :     {
      50           8 :         if ( !bVisibleChildrenOnly ||
      51           8 :              aLower.AlwaysIncludeAsChild() ||
      52           8 :              aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
      53             :         {
      54           2 :             insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower );
      55             :         }
      56             : 
      57           2 :         aLower = aLower.GetSwFrm()->GetNext();
      58             :     }
      59             : 
      60           2 :     if ( rFrm.IsPageFrm() )
      61             :     {
      62             :         OSL_ENSURE( bVisibleChildrenOnly, "page frame within tab frame???" );
      63             :         const SwPageFrm *pPgFrm =
      64           2 :             static_cast< const SwPageFrm * >( &rFrm );
      65           2 :         const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
      66           2 :         if ( pObjs )
      67             :         {
      68           4 :             for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
      69             :             {
      70           2 :                 aLower = (*pObjs)[i]->GetDrawObj();
      71           2 :                 if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) )
      72             :                 {
      73           2 :                     insert( aLower.GetDrawObject(), aLower );
      74             :                 }
      75             :             }
      76             :         }
      77             :     }
      78           0 :     else if( rFrm.IsTxtFrm() )
      79             :     {
      80           0 :         const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
      81           0 :         if ( pObjs )
      82             :         {
      83           0 :             for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
      84             :             {
      85           0 :                 aLower = (*pObjs)[i]->GetDrawObj();
      86           0 :                 if ( aLower.IsBoundAsChar() &&
      87           0 :                      ( !bVisibleChildrenOnly ||
      88           0 :                        aLower.AlwaysIncludeAsChild() ||
      89           0 :                        aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) )
      90             :                 {
      91           0 :                     insert( aLower.GetDrawObject(), aLower );
      92             :                 }
      93             :             }
      94             :         }
      95             : 
      96             :         {
      97             :             ::rtl::Reference < SwAccessibleContext > xAccImpl =
      98           0 :                                 rAccMap.GetContextImpl( &rFrm, sal_False );
      99           0 :             if( xAccImpl.is() )
     100             :             {
     101           0 :                 SwAccessibleContext* pAccImpl = xAccImpl.get();
     102           0 :                 if ( pAccImpl &&
     103           0 :                      pAccImpl->HasAdditionalAccessibleChildren() )
     104             :                 {
     105             :                     std::vector< Window* >* pAdditionalChildren =
     106           0 :                                                 new std::vector< Window* >();
     107           0 :                     pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren );
     108             : 
     109           0 :                     sal_Int32 nCounter( 0 );
     110           0 :                     for ( std::vector< Window* >::iterator aIter = pAdditionalChildren->begin();
     111           0 :                           aIter != pAdditionalChildren->end();
     112             :                           ++aIter )
     113             :                     {
     114           0 :                         aLower = (*aIter);
     115           0 :                         insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
     116             :                     }
     117             : 
     118           0 :                     delete pAdditionalChildren;
     119             :                 }
     120           0 :             }
     121             :         }
     122             :     }
     123           2 : }
     124             : 
     125           2 : ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
     126             :                                                 const sal_uInt32 nPos,
     127             :                                                 const SwAccessibleChildMapKey::LayerId eLayerId,
     128             :                                                 const SwAccessibleChild& rLower )
     129             : {
     130           2 :     SwAccessibleChildMapKey aKey( eLayerId, nPos );
     131           2 :     value_type aEntry( aKey, rLower );
     132           2 :     return _SwAccessibleChildMap::insert( aEntry );
     133             : }
     134             : 
     135           2 : ::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert(
     136             :                                                 const SdrObject *pObj,
     137             :                                                 const SwAccessibleChild& rLower )
     138             : {
     139           2 :     const SdrLayerID nLayer = pObj->GetLayer();
     140             :     SwAccessibleChildMapKey::LayerId eLayerId =
     141           2 :                     (nHellId == nLayer)
     142             :                     ? SwAccessibleChildMapKey::HELL
     143           2 :                     : ( (nControlsId == nLayer)
     144             :                         ? SwAccessibleChildMapKey::CONTROLS
     145           4 :                         : SwAccessibleChildMapKey::HEAVEN );
     146           2 :     SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() );
     147           2 :     value_type aEntry( aKey, rLower );
     148           2 :     return _SwAccessibleChildMap::insert( aEntry );
     149             : }
     150             : 
     151         147 : bool SwAccessibleChildMap::IsSortingRequired( const SwFrm& rFrm )
     152             : {
     153         172 :     return ( rFrm.IsPageFrm() &&
     154         294 :              static_cast< const SwPageFrm& >( rFrm ).GetSortedObjs() ) ||
     155         155 :            ( rFrm.IsTxtFrm() &&
     156         157 :              rFrm.GetDrawObjs() );
     157             : }
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10