LCOV - code coverage report
Current view: top level - sw/source/core/layout - swselectionlist.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 25 4.0 %
Date: 2014-11-03 Functions: 2 5 40.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 <swselectionlist.hxx>
      21             : #include <flyfrm.hxx>
      22             : #include <ftnfrm.hxx>
      23             : 
      24             : /** This class is used as parameter for functions to create a rectangular text selection
      25             : */
      26             : 
      27             : namespace {
      28             : 
      29             :     /** Find the context of a given frame
      30             : 
      31             :         A context is the environment where text is allowed to flow.
      32             :         The context is represented by
      33             :         - the SwRootFrm if the frame is part of a page body
      34             :         - the SwHeaderFrm if the frame is part of a page header
      35             :         - the SwFooterFrm if the frame is part of a page footer
      36             :         - the (master) SwFtnFrm if the frame is part of footnote
      37             :         - the (first) SwFlyFrm if the frame is part of a (linked) fly frame
      38             : 
      39             :         @param pFrm
      40             :         the given frame
      41             : 
      42             :         @return the context of the frame, represented by a SwFrm*
      43             :     */
      44           0 :     const SwFrm* getContext( const SwFrm* pFrm )
      45             :     {
      46           0 :         while( pFrm )
      47             :         {
      48           0 :             if( pFrm->IsRootFrm() || pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() )
      49           0 :                 break;
      50           0 :             if( pFrm->IsFlyFrm() )
      51             :             {
      52           0 :                 const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>( pFrm );
      53           0 :                 while( pFly->GetPrevLink() )
      54           0 :                     pFly = pFly->GetPrevLink();
      55           0 :                 break;
      56             :             }
      57           0 :             if( pFrm->IsFtnFrm() )
      58             :             {
      59           0 :                 const SwFtnFrm* pFtn = static_cast<const SwFtnFrm*>( pFrm );
      60           0 :                 while( pFtn->GetMaster() )
      61           0 :                     pFtn = pFtn->GetMaster();
      62           0 :                 break;
      63             :             }
      64           0 :             pFrm = pFrm->GetUpper();
      65             :         }
      66           0 :         return pFrm;
      67             :     }
      68             : }
      69             : 
      70           0 : SwSelectionList::SwSelectionList( const SwFrm* pInitCxt ) :
      71           0 :     pContext( getContext( pInitCxt ) )
      72             : {
      73           0 : }
      74             : 
      75           0 : bool SwSelectionList::checkContext( const SwFrm* pCheck )
      76             : {
      77           0 :     pCheck = getContext( pCheck );
      78           0 :     if( !pContext )
      79           0 :         pContext = pCheck;
      80           0 :     return pContext == pCheck;
      81         270 : }
      82             : 
      83             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10