LCOV - code coverage report
Current view: top level - sw/source/core/access - accfrmobjslist.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 75 69.3 %
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 <accfrmobjslist.hxx>
      21             : #include <accmap.hxx>
      22             : #include <acccontext.hxx>
      23             : 
      24             : #include <pagefrm.hxx>
      25             : #include <sortedobjs.hxx>
      26             : #include <anchoredobject.hxx>
      27             : 
      28             : using namespace ::sw::access;
      29             : 
      30         755 : SwAccessibleChildSList_const_iterator::SwAccessibleChildSList_const_iterator(
      31             :     const SwAccessibleChildSList& rLst,
      32             :     SwAccessibleMap& rAccMap )
      33             :     : rList( rLst ),
      34         755 :       aCurr( rList.GetFrm().GetLower() ),
      35        1510 :       nNextObj( 0 )
      36             : {
      37         755 :     if( !aCurr.GetSwFrm() )
      38             :     {
      39         149 :         const SwFrm& rFrm = rList.GetFrm();
      40         149 :         if( rFrm.IsPageFrm() )
      41             :         {
      42           0 :             const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
      43           0 :             const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
      44           0 :             if( pObjs && pObjs->size() )
      45             :             {
      46           0 :                 aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
      47             :             }
      48             :         }
      49         149 :         else if( rFrm.IsTextFrm() )
      50             :         {
      51         116 :             const SwSortedObjs *pObjs = rFrm.GetDrawObjs();
      52         116 :             if ( pObjs && pObjs->size() )
      53             :             {
      54          11 :                 aCurr = (*pObjs)[nNextObj++]->GetDrawObj();
      55          33 :                 while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
      56             :                 {
      57          11 :                     aCurr = (nNextObj < pObjs->size())
      58           0 :                             ? (*pObjs)[nNextObj++]->GetDrawObj()
      59          11 :                             : static_cast< const SdrObject *>( 0 );
      60             :                 }
      61             :             }
      62         116 :             if ( !aCurr.IsValid() )
      63             :             {
      64             :                 ::rtl::Reference < SwAccessibleContext > xAccImpl =
      65         116 :                                     rAccMap.GetContextImpl( &rFrm, false );
      66         116 :                 if( xAccImpl.is() )
      67             :                 {
      68          99 :                     SwAccessibleContext* pAccImpl = xAccImpl.get();
      69          99 :                     aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( 0 ) );
      70          99 :                     ++nNextObj;
      71         116 :                 }
      72             :             }
      73             :         }
      74             :     }
      75             : 
      76         755 :     if( rList.IsVisibleChildrenOnly() )
      77             :     {
      78             :         // Find the first visible
      79        1570 :         while( aCurr.IsValid() &&
      80        1112 :                !aCurr.AlwaysIncludeAsChild() &&
      81        1040 :                !aCurr.GetBox( rAccMap ).IsOver( rList.GetVisArea() ) )
      82             :         {
      83           0 :             next();
      84             :         }
      85             :     }
      86         755 : }
      87             : 
      88         867 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next()
      89             : {
      90         867 :     bool bNextTaken( true );
      91         867 :     if( aCurr.GetDrawObject() || aCurr.GetWindow() )
      92             :     {
      93          11 :         bNextTaken = false;
      94             :     }
      95         856 :     else if( aCurr.GetSwFrm() )
      96             :     {
      97         856 :         aCurr = aCurr.GetSwFrm()->GetNext();
      98         856 :         if( !aCurr.GetSwFrm() )
      99             :         {
     100         585 :             bNextTaken = false;
     101             :         }
     102             :     }
     103             : 
     104         867 :     if( !bNextTaken )
     105             :     {
     106         596 :         const SwFrm& rFrm = rList.GetFrm();
     107         596 :         if( rFrm.IsPageFrm() )
     108             :         {
     109         124 :             const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm );
     110         124 :             const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs();
     111         135 :             aCurr = ( pObjs && nNextObj < pObjs->size() )
     112          11 :                     ? (*pObjs)[nNextObj++]->GetDrawObj()
     113         124 :                     : static_cast< const SdrObject *>( 0 );
     114             :         }
     115         472 :         else if( rFrm.IsTextFrm() )
     116             :         {
     117           0 :             const SwSortedObjs* pObjs = rFrm.GetDrawObjs();
     118           0 :             const size_t nObjsCount = pObjs ? pObjs->size() : 0;
     119           0 :             aCurr = ( pObjs && nNextObj < nObjsCount )
     120           0 :                     ? (*pObjs)[nNextObj++]->GetDrawObj()
     121           0 :                     : static_cast< const SdrObject *>( 0 );
     122           0 :             while( aCurr.IsValid() && !aCurr.IsBoundAsChar() )
     123             :             {
     124           0 :                 aCurr = ( nNextObj < nObjsCount )
     125           0 :                         ? (*pObjs)[nNextObj++]->GetDrawObj()
     126           0 :                         : static_cast< const SdrObject *>( 0 );
     127             :             }
     128           0 :             if ( !aCurr.IsValid() )
     129             :             {
     130             :                 ::rtl::Reference < SwAccessibleContext > xAccImpl =
     131           0 :                                     rList.GetAccMap().GetContextImpl( &rFrm, false );
     132           0 :                 if( xAccImpl.is() )
     133             :                 {
     134           0 :                     SwAccessibleContext* pAccImpl = xAccImpl.get();
     135           0 :                     aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( nNextObj - nObjsCount ) );
     136           0 :                     ++nNextObj;
     137           0 :                 }
     138             :             }
     139             :         }
     140             :     }
     141             : 
     142         867 :     return *this;
     143             : }
     144             : 
     145         297 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next_visible()
     146             : {
     147         297 :     next();
     148        1485 :     while( aCurr.IsValid() &&
     149         722 :            !aCurr.AlwaysIncludeAsChild() &&
     150         489 :            !aCurr.GetBox( rList.GetAccMap() ).IsOver( rList.GetVisArea() ) )
     151             :     {
     152           0 :         next();
     153             :     }
     154             : 
     155         297 :     return *this;
     156             : }
     157             : 
     158         867 : SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::operator++()
     159             : {
     160         867 :     return rList.IsVisibleChildrenOnly() ? next_visible() : next();
     161         177 : }
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11