LCOV - code coverage report
Current view: top level - sw/source/core/text - txtcache.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 55 56 98.2 %
Date: 2015-06-13 12:38:46 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       26040 : SwTextLine::SwTextLine( SwTextFrm *pFrm, SwParaPortion *pNew ) :
      25             :     SwCacheObj( static_cast<void*>(pFrm) ),
      26       26040 :     pLine( pNew )
      27             : {
      28       26040 : }
      29             : 
      30       78120 : SwTextLine::~SwTextLine()
      31             : {
      32       26040 :     delete pLine;
      33       52080 : }
      34             : 
      35       23334 : SwCacheObj *SwTextLineAccess::NewObj()
      36             : {
      37       23334 :     return new SwTextLine( const_cast<SwTextFrm *>(static_cast<SwTextFrm const *>(pOwner)) );
      38             : }
      39             : 
      40      112391 : SwParaPortion *SwTextLineAccess::GetPara()
      41             : {
      42             :     SwTextLine *pRet;
      43      112391 :     if ( pObj )
      44       89057 :         pRet = static_cast<SwTextLine*>(pObj);
      45             :     else
      46             :     {
      47       23334 :         pRet = static_cast<SwTextLine*>(Get());
      48       23334 :         const_cast<SwTextFrm *>(static_cast<SwTextFrm const *>(pOwner))->SetCacheIdx( pRet->GetCachePos() );
      49             :     }
      50      112391 :     if ( !pRet->GetPara() )
      51       38908 :         pRet->SetPara( new SwParaPortion );
      52      112391 :     return pRet->GetPara();
      53             : }
      54             : 
      55      109656 : SwTextLineAccess::SwTextLineAccess( const SwTextFrm *pOwn ) :
      56      109656 :     SwCacheAccess( *SwTextFrm::GetTextCache(), pOwn, pOwn->GetCacheIdx() )
      57             : {
      58      109656 : }
      59             : 
      60       55642 : bool SwTextLineAccess::IsAvailable() const
      61             : {
      62       55642 :     return pObj && static_cast<SwTextLine*>(pObj)->GetPara();
      63             : }
      64             : 
      65      392066 : bool SwTextFrm::_HasPara() const
      66             : {
      67             :     SwTextLine *pTextLine = static_cast<SwTextLine*>(SwTextFrm::GetTextCache()->
      68      392066 :                                             Get( this, GetCacheIdx(), false ));
      69      392066 :     if ( pTextLine )
      70             :     {
      71      391631 :         if ( pTextLine->GetPara() )
      72      365085 :             return true;
      73             :     }
      74             :     else
      75         435 :         const_cast<SwTextFrm*>(this)->nCacheIdx = USHRT_MAX;
      76             : 
      77       26981 :     return false;
      78             : }
      79             : 
      80      827365 : SwParaPortion *SwTextFrm::GetPara()
      81             : {
      82      827365 :     if ( GetCacheIdx() != USHRT_MAX )
      83             :     {
      84             :         SwTextLine *pLine = static_cast<SwTextLine*>(SwTextFrm::GetTextCache()->
      85      716974 :                                         Get( this, GetCacheIdx(), false ));
      86      716974 :         if ( pLine )
      87      716955 :             return pLine->GetPara();
      88             :         else
      89          19 :             nCacheIdx = USHRT_MAX;
      90             :     }
      91      110410 :     return 0;
      92             : }
      93             : 
      94       51544 : void SwTextFrm::ClearPara()
      95             : {
      96             :     OSL_ENSURE( !IsLocked(), "+SwTextFrm::ClearPara: this is locked." );
      97       51544 :     if ( !IsLocked() && GetCacheIdx() != USHRT_MAX )
      98             :     {
      99             :         SwTextLine *pTextLine = static_cast<SwTextLine*>(SwTextFrm::GetTextCache()->
     100       39833 :                                         Get( this, GetCacheIdx(), false ));
     101       39833 :         if ( pTextLine )
     102             :         {
     103       34511 :             delete pTextLine->GetPara();
     104       34511 :             pTextLine->SetPara( 0 );
     105             :         }
     106             :         else
     107        5322 :             nCacheIdx = USHRT_MAX;
     108             :     }
     109       51544 : }
     110             : 
     111        8274 : void SwTextFrm::SetPara( SwParaPortion *pNew, bool bDelete )
     112             : {
     113        8274 :     if ( GetCacheIdx() != USHRT_MAX )
     114             :     {
     115             :         // Only change the information, the CacheObj stays there
     116             :         SwTextLine *pTextLine = static_cast<SwTextLine*>(SwTextFrm::GetTextCache()->
     117        5568 :                                         Get( this, GetCacheIdx(), false ));
     118        5568 :         if ( pTextLine )
     119             :         {
     120        5568 :             if( bDelete )
     121        4138 :                 delete pTextLine->GetPara();
     122        5568 :             pTextLine->SetPara( pNew );
     123             :         }
     124             :         else
     125             :         {
     126             :             OSL_ENSURE( !pNew, "+SetPara: Losing SwParaPortion" );
     127           0 :             nCacheIdx = USHRT_MAX;
     128             :         }
     129             :     }
     130        2706 :     else if ( pNew )
     131             :     {   // Insert a new one
     132        2706 :         SwTextLine *pTextLine = new SwTextLine( this, pNew );
     133        2706 :         if ( SwTextFrm::GetTextCache()->Insert( pTextLine ) )
     134        2706 :             nCacheIdx = pTextLine->GetCachePos();
     135             :         else
     136             :         {
     137             :             OSL_FAIL( "+SetPara: InsertCache failed." );
     138             :         }
     139             :     }
     140        8451 : }
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11