LCOV - code coverage report
Current view: top level - sw/source/core/text - txtcache.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 55 56 98.2 %
Date: 2014-11-03 Functions: 13 13 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 "txtcache.hxx"
      21             : #include "txtfrm.hxx"
      22             : #include "porlay.hxx"
      23             : 
      24       44639 : SwTxtLine::SwTxtLine( SwTxtFrm *pFrm, SwParaPortion *pNew ) :
      25             :     SwCacheObj( (void*)pFrm ),
      26       44639 :     pLine( pNew )
      27             : {
      28       44639 : }
      29             : 
      30      133917 : SwTxtLine::~SwTxtLine()
      31             : {
      32       44639 :     delete pLine;
      33       89278 : }
      34             : 
      35       42285 : SwCacheObj *SwTxtLineAccess::NewObj()
      36             : {
      37       42285 :     return new SwTxtLine( (SwTxtFrm*)pOwner );
      38             : }
      39             : 
      40      208827 : SwParaPortion *SwTxtLineAccess::GetPara()
      41             : {
      42             :     SwTxtLine *pRet;
      43      208827 :     if ( pObj )
      44      166542 :         pRet = (SwTxtLine*)pObj;
      45             :     else
      46             :     {
      47       42285 :         pRet = (SwTxtLine*)Get();
      48       42285 :         ((SwTxtFrm*)pOwner)->SetCacheIdx( pRet->GetCachePos() );
      49             :     }
      50      208827 :     if ( !pRet->GetPara() )
      51       71043 :         pRet->SetPara( new SwParaPortion );
      52      208827 :     return pRet->GetPara();
      53             : }
      54             : 
      55      206265 : SwTxtLineAccess::SwTxtLineAccess( const SwTxtFrm *pOwn ) :
      56      206265 :     SwCacheAccess( *SwTxtFrm::GetTxtCache(), pOwn, pOwn->GetCacheIdx() )
      57             : {
      58      206265 : }
      59             : 
      60       99689 : bool SwTxtLineAccess::IsAvailable() const
      61             : {
      62       99689 :     return pObj && ((SwTxtLine*)pObj)->GetPara();
      63             : }
      64             : 
      65      688100 : bool SwTxtFrm::_HasPara() const
      66             : {
      67             :     SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
      68      688100 :                                             Get( this, GetCacheIdx(), false );
      69      688100 :     if ( pTxtLine )
      70             :     {
      71      687266 :         if ( pTxtLine->GetPara() )
      72      634438 :             return true;
      73             :     }
      74             :     else
      75         834 :         ((SwTxtFrm*)this)->nCacheIdx = USHRT_MAX;
      76             : 
      77       53662 :     return false;
      78             : }
      79             : 
      80     1424769 : SwParaPortion *SwTxtFrm::GetPara()
      81             : {
      82     1424769 :     if ( GetCacheIdx() != USHRT_MAX )
      83             :     {   SwTxtLine *pLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
      84     1225416 :                                         Get( this, GetCacheIdx(), false );
      85     1225416 :         if ( pLine )
      86     1225314 :             return pLine->GetPara();
      87             :         else
      88         102 :             nCacheIdx = USHRT_MAX;
      89             :     }
      90      199455 :     return 0;
      91             : }
      92             : 
      93       95786 : void SwTxtFrm::ClearPara()
      94             : {
      95             :     OSL_ENSURE( !IsLocked(), "+SwTxtFrm::ClearPara: this is locked." );
      96       95786 :     if ( !IsLocked() && GetCacheIdx() != USHRT_MAX )
      97             :     {
      98             :         SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
      99       73765 :                                         Get( this, GetCacheIdx(), false );
     100       73765 :         if ( pTxtLine )
     101             :         {
     102       64539 :             delete pTxtLine->GetPara();
     103       64539 :             pTxtLine->SetPara( 0 );
     104             :         }
     105             :         else
     106        9226 :             nCacheIdx = USHRT_MAX;
     107             :     }
     108       95786 : }
     109             : 
     110       11120 : void SwTxtFrm::SetPara( SwParaPortion *pNew, bool bDelete )
     111             : {
     112       11120 :     if ( GetCacheIdx() != USHRT_MAX )
     113             :     {
     114             :         // Only change the information, the CacheObj stays there
     115             :         SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
     116        8766 :                                         Get( this, GetCacheIdx(), false );
     117        8766 :         if ( pTxtLine )
     118             :         {
     119        8766 :             if( bDelete )
     120        5562 :                 delete pTxtLine->GetPara();
     121        8766 :             pTxtLine->SetPara( pNew );
     122             :         }
     123             :         else
     124             :         {
     125             :             OSL_ENSURE( !pNew, "+SetPara: Losing SwParaPortion" );
     126           0 :             nCacheIdx = USHRT_MAX;
     127             :         }
     128             :     }
     129        2354 :     else if ( pNew )
     130             :     {   // Insert a new one
     131        2354 :         SwTxtLine *pTxtLine = new SwTxtLine( this, pNew );
     132        2354 :         if ( SwTxtFrm::GetTxtCache()->Insert( pTxtLine ) )
     133        2354 :             nCacheIdx = pTxtLine->GetCachePos();
     134             :         else
     135             :         {
     136             :             OSL_FAIL( "+SetPara: InsertCache failed." );
     137             :         }
     138             :     }
     139       11390 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10