LCOV - code coverage report
Current view: top level - sw/source/core/doc - lineinfo.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 59 76 77.6 %
Date: 2014-11-03 Functions: 10 11 90.9 %
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 "doc.hxx"
      21             : #include <IDocumentLayoutAccess.hxx>
      22             : #include <IDocumentStylePoolAccess.hxx>
      23             : #include <IDocumentState.hxx>
      24             : #include "lineinfo.hxx"
      25             : #include "charfmt.hxx"
      26             : #include "poolfmt.hxx"
      27             : #include "rootfrm.hxx"
      28             : #include "viewsh.hxx"
      29             : #include <set>
      30             : 
      31        2990 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
      32             : {
      33        2990 :     SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
      34        3012 :     if (  pTmpRoot &&
      35          38 :          (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
      36          18 :           rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
      37             :     {
      38           2 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
      39           2 :         pTmpRoot->StartAllAction();
      40             :         // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
      41             :         // is only (onny may only be) called by the formatting routines
      42             :         //pTmpRoot->InvalidateAllCntnt( INV_LINENUM | INV_SIZE );
      43           2 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_LINENUM | INV_SIZE));
      44           2 :          pTmpRoot->EndAllAction();
      45             :     }
      46        2990 :     *mpLineNumberInfo = rNew;
      47        2990 :     getIDocumentState().SetModified();
      48        2990 : }
      49             : 
      50      345241 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
      51             : {
      52      345241 :     return *mpLineNumberInfo;
      53             : }
      54             : 
      55        5052 : SwLineNumberInfo::SwLineNumberInfo() :
      56             :     nPosFromLeft( MM50 ),
      57             :     nCountBy( 5 ),
      58             :     nDividerCountBy( 3 ),
      59             :     ePos( LINENUMBER_POS_LEFT ),
      60             :     bPaintLineNumbers( false ),
      61             :     bCountBlankLines( true ),
      62             :     bCountInFlys( false ),
      63        5052 :     bRestartEachPage( false )
      64             : {
      65        5052 : }
      66             : 
      67        2990 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
      68        2990 :     aType( rCpy.GetNumType() ),
      69             :     aDivider( rCpy.GetDivider() ),
      70        2990 :     nPosFromLeft( rCpy.GetPosFromLeft() ),
      71        2990 :     nCountBy( rCpy.GetCountBy() ),
      72        2990 :     nDividerCountBy( rCpy.GetDividerCountBy() ),
      73        2990 :     ePos( rCpy.GetPos() ),
      74        2990 :     bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
      75        2990 :     bCountBlankLines( rCpy.IsCountBlankLines() ),
      76        2990 :     bCountInFlys( rCpy.IsCountInFlys() ),
      77       26910 :     bRestartEachPage( rCpy.IsRestartEachPage() )
      78             : {
      79        2990 :     if ( rCpy.GetRegisteredIn() )
      80          34 :         ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
      81        2990 : }
      82             : 
      83        2990 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
      84             : {
      85        2990 :     if ( rCpy.GetRegisteredIn() )
      86          38 :         ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
      87        2952 :     else if ( GetRegisteredIn() )
      88           0 :         GetRegisteredInNonConst()->Remove( this );
      89             : 
      90        2990 :     aType = rCpy.GetNumType();
      91        2990 :     aDivider = rCpy.GetDivider();
      92        2990 :     nPosFromLeft = rCpy.GetPosFromLeft();
      93        2990 :     nCountBy = rCpy.GetCountBy();
      94        2990 :     nDividerCountBy = rCpy.GetDividerCountBy();
      95        2990 :     ePos = rCpy.GetPos();
      96        2990 :     bPaintLineNumbers = rCpy.IsPaintLineNumbers();
      97        2990 :     bCountBlankLines = rCpy.IsCountBlankLines();
      98        2990 :     bCountInFlys = rCpy.IsCountInFlys();
      99        2990 :     bRestartEachPage = rCpy.IsRestartEachPage();
     100             : 
     101        2990 :     return *this;
     102             : }
     103             : 
     104           0 : bool SwLineNumberInfo::operator==( const SwLineNumberInfo& rInf ) const
     105             : {
     106           0 :     return  GetRegisteredIn() == rInf.GetRegisteredIn() &&
     107           0 :             aType.GetNumberingType() == rInf.GetNumType().GetNumberingType() &&
     108           0 :             aDivider == rInf.GetDivider() &&
     109           0 :             nPosFromLeft == rInf.GetPosFromLeft() &&
     110           0 :             nCountBy == rInf.GetCountBy() &&
     111           0 :             nDividerCountBy == rInf.GetDividerCountBy() &&
     112           0 :             ePos == rInf.GetPos() &&
     113           0 :             bPaintLineNumbers == rInf.IsPaintLineNumbers() &&
     114           0 :             bCountBlankLines == rInf.IsCountBlankLines() &&
     115           0 :             bCountInFlys == rInf.IsCountInFlys() &&
     116           0 :             bRestartEachPage == rInf.IsRestartEachPage();
     117             : }
     118             : 
     119         326 : SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const
     120             : {
     121         326 :     if ( !GetRegisteredIn() )
     122             :     {
     123          14 :         SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM );
     124          14 :         pFmt->Add( (SwClient*)this );
     125             :     }
     126         326 :     return (SwCharFmt*)GetRegisteredIn();
     127             : }
     128             : 
     129           4 : void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt )
     130             : {
     131             :     OSL_ENSURE( pChFmt, "SetCharFmt, 0 is not a valid pointer" );
     132           4 :     pChFmt->Add( this );
     133           4 : }
     134             : 
     135          36 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     136             : {
     137          36 :     CheckRegistration( pOld, pNew );
     138          36 :     SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc();
     139          36 :     SwRootFrm* pRoot = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
     140          36 :     if( pRoot )
     141             :     {
     142           0 :         pRoot->StartAllAction();
     143           0 :         std::set<SwRootFrm*> aAllLayouts = pDoc->GetAllLayouts();
     144           0 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllAddPaintRect));
     145             :         //pRoot->GetCurrShell()->AddPaintRect( pRoot->Frm() );
     146           0 :         pRoot->EndAllAction();
     147             :     }
     148         306 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10