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

Generated by: LCOV version 1.11