LCOV - code coverage report
Current view: top level - sw/source/core/text - txtcache.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 56 0.0 %
Date: 2014-04-14 Functions: 0 11 0.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             : /*************************************************************************
      25             : |*
      26             : |*  SwTxtLine::SwTxtLine(), ~SwTxtLine()
      27             : |*
      28             : |*************************************************************************/
      29             : 
      30           0 : SwTxtLine::SwTxtLine( SwTxtFrm *pFrm, SwParaPortion *pNew ) :
      31             :     SwCacheObj( (void*)pFrm ),
      32           0 :     pLine( pNew )
      33             : {
      34           0 : }
      35             : 
      36           0 : SwTxtLine::~SwTxtLine()
      37             : {
      38           0 :     delete pLine;
      39           0 : }
      40             : 
      41             : /*************************************************************************
      42             : |*
      43             : |*  SwTxtLineAccess::NewObj()
      44             : |*
      45             : |*************************************************************************/
      46             : 
      47           0 : SwCacheObj *SwTxtLineAccess::NewObj()
      48             : {
      49           0 :     return new SwTxtLine( (SwTxtFrm*)pOwner );
      50             : }
      51             : 
      52             : /*************************************************************************
      53             : |*
      54             : |*  SwTxtLineAccess::GetPara()
      55             : |*
      56             : |*************************************************************************/
      57             : 
      58           0 : SwParaPortion *SwTxtLineAccess::GetPara()
      59             : {
      60             :     SwTxtLine *pRet;
      61           0 :     if ( pObj )
      62           0 :         pRet = (SwTxtLine*)pObj;
      63             :     else
      64             :     {
      65           0 :         pRet = (SwTxtLine*)Get();
      66           0 :         ((SwTxtFrm*)pOwner)->SetCacheIdx( pRet->GetCachePos() );
      67             :     }
      68           0 :     if ( !pRet->GetPara() )
      69           0 :         pRet->SetPara( new SwParaPortion );
      70           0 :     return pRet->GetPara();
      71             : }
      72             : 
      73             : /*************************************************************************
      74             : |*
      75             : |*  SwTxtLineAccess::SwTxtLineAccess()
      76             : |*
      77             : |*************************************************************************/
      78             : 
      79           0 : SwTxtLineAccess::SwTxtLineAccess( const SwTxtFrm *pOwn ) :
      80           0 :     SwCacheAccess( *SwTxtFrm::GetTxtCache(), pOwn, pOwn->GetCacheIdx() )
      81             : {
      82           0 : }
      83             : 
      84             : /*************************************************************************
      85             : |*
      86             : |*  SwTxtLineAccess::IsAvailable
      87             : |*
      88             : |*************************************************************************/
      89             : 
      90           0 : bool SwTxtLineAccess::IsAvailable() const
      91             : {
      92           0 :     return pObj && ((SwTxtLine*)pObj)->GetPara();
      93             : }
      94             : 
      95             : /*************************************************************************
      96             : |*
      97             : |*  SwTxtFrm::HasPara()
      98             : |*
      99             : |*************************************************************************/
     100             : 
     101           0 : bool SwTxtFrm::_HasPara() const
     102             : {
     103             :     SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
     104           0 :                                             Get( this, GetCacheIdx(), false );
     105           0 :     if ( pTxtLine )
     106             :     {
     107           0 :         if ( pTxtLine->GetPara() )
     108           0 :             return true;
     109             :     }
     110             :     else
     111           0 :         ((SwTxtFrm*)this)->nCacheIdx = MSHRT_MAX;
     112             : 
     113           0 :     return false;
     114             : }
     115             : 
     116             : /*************************************************************************
     117             : |*
     118             : |*  SwTxtFrm::GetPara()
     119             : |*
     120             : |*************************************************************************/
     121             : 
     122           0 : SwParaPortion *SwTxtFrm::GetPara()
     123             : {
     124           0 :     if ( GetCacheIdx() != MSHRT_MAX )
     125             :     {   SwTxtLine *pLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
     126           0 :                                         Get( this, GetCacheIdx(), false );
     127           0 :         if ( pLine )
     128           0 :             return pLine->GetPara();
     129             :         else
     130           0 :             nCacheIdx = MSHRT_MAX;
     131             :     }
     132           0 :     return 0;
     133             : }
     134             : 
     135             : /*************************************************************************
     136             : |*
     137             : |*  SwTxtFrm::ClearPara()
     138             : |*
     139             : |*************************************************************************/
     140             : 
     141           0 : void SwTxtFrm::ClearPara()
     142             : {
     143             :     OSL_ENSURE( !IsLocked(), "+SwTxtFrm::ClearPara: this is locked." );
     144           0 :     if ( !IsLocked() && GetCacheIdx() != MSHRT_MAX )
     145             :     {
     146             :         SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
     147           0 :                                         Get( this, GetCacheIdx(), false );
     148           0 :         if ( pTxtLine )
     149             :         {
     150           0 :             delete pTxtLine->GetPara();
     151           0 :             pTxtLine->SetPara( 0 );
     152             :         }
     153             :         else
     154           0 :             nCacheIdx = MSHRT_MAX;
     155             :     }
     156           0 : }
     157             : 
     158             : /*************************************************************************
     159             : |*
     160             : |*  SwTxtFrm::SetPara()
     161             : |*
     162             : |*************************************************************************/
     163             : 
     164           0 : void SwTxtFrm::SetPara( SwParaPortion *pNew, bool bDelete )
     165             : {
     166           0 :     if ( GetCacheIdx() != MSHRT_MAX )
     167             :     {
     168             :         // Only change the information, the CacheObj stays there
     169             :         SwTxtLine *pTxtLine = (SwTxtLine*)SwTxtFrm::GetTxtCache()->
     170           0 :                                         Get( this, GetCacheIdx(), false );
     171           0 :         if ( pTxtLine )
     172             :         {
     173           0 :             if( bDelete )
     174           0 :                 delete pTxtLine->GetPara();
     175           0 :             pTxtLine->SetPara( pNew );
     176             :         }
     177             :         else
     178             :         {
     179             :             OSL_ENSURE( !pNew, "+SetPara: Losing SwParaPortion" );
     180           0 :             nCacheIdx = MSHRT_MAX;
     181             :         }
     182             :     }
     183           0 :     else if ( pNew )
     184             :     {   // Insert a new one
     185           0 :         SwTxtLine *pTxtLine = new SwTxtLine( this, pNew );
     186           0 :         if ( SwTxtFrm::GetTxtCache()->Insert( pTxtLine ) )
     187           0 :             nCacheIdx = pTxtLine->GetCachePos();
     188             :         else
     189             :         {
     190             :             OSL_FAIL( "+SetPara: InsertCache failed." );
     191             :         }
     192             :     }
     193           0 : }
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10