LCOV - code coverage report
Current view: top level - sw/source/core/doc - lineinfo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 77 75.3 %
Date: 2012-08-25 Functions: 8 9 88.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 72 34.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "doc.hxx"
      31                 :            : #include "lineinfo.hxx"
      32                 :            : #include "charfmt.hxx"
      33                 :            : #include "poolfmt.hxx"
      34                 :            : #include "rootfrm.hxx"
      35                 :            : #include "viewsh.hxx"
      36                 :            : #include <set>
      37                 :        587 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
      38                 :            : {
      39                 :        587 :     SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
      40 [ +  + ][ +  +  :        625 :     if (  pTmpRoot &&
             +  +  -  + ]
      41                 :         20 :          (rNew.IsCountBlankLines() != pLineNumberInfo->IsCountBlankLines() ||
      42                 :         18 :           rNew.IsRestartEachPage() != pLineNumberInfo->IsRestartEachPage()) )
      43                 :            :     {
      44         [ +  - ]:          2 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080225
      45         [ +  - ]:          2 :         pTmpRoot->StartAllAction();
      46                 :            :         // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
      47                 :            :         // is only (onny may only be) called by the formatting routines
      48                 :            :         //pTmpRoot->InvalidateAllCntnt( INV_LINENUM | INV_SIZE );
      49 [ +  - ][ +  - ]:          2 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_LINENUM | INV_SIZE));//swmod 080226
                 [ +  - ]
      50         [ +  - ]:          2 :          pTmpRoot->EndAllAction();
      51                 :            :     }   //swmod 080219
      52                 :        587 :     *pLineNumberInfo = rNew;
      53                 :        587 :     SetModified();
      54                 :        587 : }
      55                 :            : 
      56                 :     114654 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
      57                 :            : {
      58                 :     114654 :     return *pLineNumberInfo;
      59                 :            : }
      60                 :            : 
      61                 :       1549 : SwLineNumberInfo::SwLineNumberInfo() :
      62                 :            :     nPosFromLeft( MM50 ),
      63                 :            :     nCountBy( 5 ),
      64                 :            :     nDividerCountBy( 3 ),
      65                 :            :     ePos( LINENUMBER_POS_LEFT ),
      66                 :            :     bPaintLineNumbers( sal_False ),
      67                 :            :     bCountBlankLines( sal_True ),
      68                 :            :     bCountInFlys( sal_False ),
      69 [ +  - ][ +  - ]:       1549 :     bRestartEachPage( sal_False )
      70                 :            : {
      71                 :       1549 : }
      72                 :            : 
      73                 :        587 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
      74                 :        587 :     aType( rCpy.GetNumType() ),
      75                 :        587 :     aDivider( rCpy.GetDivider() ),
      76                 :        587 :     nPosFromLeft( rCpy.GetPosFromLeft() ),
      77                 :        587 :     nCountBy( rCpy.GetCountBy() ),
      78                 :        587 :     nDividerCountBy( rCpy.GetDividerCountBy() ),
      79                 :        587 :     ePos( rCpy.GetPos() ),
      80                 :        587 :     bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
      81                 :        587 :     bCountBlankLines( rCpy.IsCountBlankLines() ),
      82                 :        587 :     bCountInFlys( rCpy.IsCountInFlys() ),
      83   [ +  -  +  - ]:       2348 :     bRestartEachPage( rCpy.IsRestartEachPage() )
      84                 :            : {
      85         [ +  + ]:        587 :     if ( rCpy.GetRegisteredIn() )
      86         [ +  - ]:         16 :         ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
      87                 :        587 : }
      88                 :            : 
      89                 :        587 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
      90                 :            : {
      91         [ +  + ]:        587 :     if ( rCpy.GetRegisteredIn() )
      92                 :         18 :         ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
      93         [ -  + ]:        569 :     else if ( GetRegisteredIn() )
      94                 :          0 :         GetRegisteredInNonConst()->Remove( this );
      95                 :            : 
      96                 :        587 :     aType = rCpy.GetNumType();
      97                 :        587 :     aDivider = rCpy.GetDivider();
      98                 :        587 :     nPosFromLeft = rCpy.GetPosFromLeft();
      99                 :        587 :     nCountBy = rCpy.GetCountBy();
     100                 :        587 :     nDividerCountBy = rCpy.GetDividerCountBy();
     101                 :        587 :     ePos = rCpy.GetPos();
     102                 :        587 :     bPaintLineNumbers = rCpy.IsPaintLineNumbers();
     103                 :        587 :     bCountBlankLines = rCpy.IsCountBlankLines();
     104                 :        587 :     bCountInFlys = rCpy.IsCountInFlys();
     105                 :        587 :     bRestartEachPage = rCpy.IsRestartEachPage();
     106                 :            : 
     107                 :        587 :     return *this;
     108                 :            : }
     109                 :            : 
     110                 :          0 : sal_Bool SwLineNumberInfo::operator==( const SwLineNumberInfo& rInf ) const
     111                 :            : {
     112                 :          0 :     return  GetRegisteredIn() == rInf.GetRegisteredIn() &&
     113                 :          0 :             aType.GetNumberingType() == rInf.GetNumType().GetNumberingType() &&
     114                 :          0 :             aDivider == rInf.GetDivider() &&
     115                 :          0 :             nPosFromLeft == rInf.GetPosFromLeft() &&
     116                 :          0 :             nCountBy == rInf.GetCountBy() &&
     117                 :          0 :             nDividerCountBy == rInf.GetDividerCountBy() &&
     118                 :          0 :             ePos == rInf.GetPos() &&
     119                 :          0 :             bPaintLineNumbers == rInf.IsPaintLineNumbers() &&
     120                 :          0 :             bCountBlankLines == rInf.IsCountBlankLines() &&
     121                 :          0 :             bCountInFlys == rInf.IsCountInFlys() &&
     122 [ #  # ][ #  #  :          0 :             bRestartEachPage == rInf.IsRestartEachPage();
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     123                 :            : }
     124                 :            : 
     125                 :            : 
     126                 :         34 : SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const
     127                 :            : {
     128         [ -  + ]:         34 :     if ( !GetRegisteredIn() )
     129                 :            :     {
     130                 :          0 :         SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM );
     131                 :          0 :         pFmt->Add( (SwClient*)this );
     132                 :            :     }
     133                 :         34 :     return (SwCharFmt*)GetRegisteredIn();
     134                 :            : }
     135                 :            : 
     136                 :          2 : void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt )
     137                 :            : {
     138                 :            :     OSL_ENSURE( pChFmt, "SetCharFmt, 0 is not a valid pointer" );
     139                 :          2 :     pChFmt->Add( this );
     140                 :          2 : }
     141                 :            : 
     142                 :          4 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     143                 :            : {
     144                 :          4 :     CheckRegistration( pOld, pNew );
     145                 :          4 :     SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc();
     146                 :          4 :     SwRootFrm* pRoot = pDoc->GetCurrentLayout();
     147         [ -  + ]:          4 :     if( pRoot )
     148                 :            :     {
     149         [ #  # ]:          0 :         pRoot->StartAllAction();
     150         [ #  # ]:          0 :         std::set<SwRootFrm*> aAllLayouts = pDoc->GetAllLayouts();
     151 [ #  # ][ #  # ]:          0 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllAddPaintRect));//swmod 080305
     152                 :            :         //pRoot->GetCurrShell()->AddPaintRect( pRoot->Frm() );
     153         [ #  # ]:          0 :         pRoot->EndAllAction();
     154                 :            :     }
     155                 :          4 : }
     156                 :            : 
     157                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10