LCOV - code coverage report
Current view: top level - sw/source/core/doc - lineinfo.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 59 76 77.6 %
Date: 2015-06-13 12:38:46 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        2752 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
      32             : {
      33        2752 :     SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
      34        2763 :     if (  pTmpRoot &&
      35          19 :          (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
      36           9 :           rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
      37             :     {
      38           1 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
      39           1 :         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->InvalidateAllContent( INV_LINENUM | INV_SIZE );
      43           1 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllContent), INV_LINENUM | INV_SIZE));
      44           1 :          pTmpRoot->EndAllAction();
      45             :     }
      46        2752 :     *mpLineNumberInfo = rNew;
      47        2752 :     getIDocumentState().SetModified();
      48        2752 : }
      49             : 
      50    26972963 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
      51             : {
      52    26972963 :     return *mpLineNumberInfo;
      53             : }
      54             : 
      55        2958 : 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        2958 :     bRestartEachPage( false )
      64             : {
      65        2958 : }
      66             : 
      67        2752 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
      68        2752 :     aType( rCpy.GetNumType() ),
      69             :     aDivider( rCpy.GetDivider() ),
      70        2752 :     nPosFromLeft( rCpy.GetPosFromLeft() ),
      71        2752 :     nCountBy( rCpy.GetCountBy() ),
      72        2752 :     nDividerCountBy( rCpy.GetDividerCountBy() ),
      73        2752 :     ePos( rCpy.GetPos() ),
      74        2752 :     bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
      75        2752 :     bCountBlankLines( rCpy.IsCountBlankLines() ),
      76        2752 :     bCountInFlys( rCpy.IsCountInFlys() ),
      77       24768 :     bRestartEachPage( rCpy.IsRestartEachPage() )
      78             : {
      79        2752 :     if ( rCpy.GetRegisteredIn() )
      80          26 :         const_cast<SwModify*>(rCpy.GetRegisteredIn())->Add( this );
      81        2752 : }
      82             : 
      83        2752 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
      84             : {
      85        2752 :     if ( rCpy.GetRegisteredIn() )
      86          29 :         const_cast<SwModify*>(rCpy.GetRegisteredIn())->Add( this );
      87        2723 :     else if ( GetRegisteredIn() )
      88           0 :         GetRegisteredInNonConst()->Remove( this );
      89             : 
      90        2752 :     aType = rCpy.GetNumType();
      91        2752 :     aDivider = rCpy.GetDivider();
      92        2752 :     nPosFromLeft = rCpy.GetPosFromLeft();
      93        2752 :     nCountBy = rCpy.GetCountBy();
      94        2752 :     nDividerCountBy = rCpy.GetDividerCountBy();
      95        2752 :     ePos = rCpy.GetPos();
      96        2752 :     bPaintLineNumbers = rCpy.IsPaintLineNumbers();
      97        2752 :     bCountBlankLines = rCpy.IsCountBlankLines();
      98        2752 :     bCountInFlys = rCpy.IsCountInFlys();
      99        2752 :     bRestartEachPage = rCpy.IsRestartEachPage();
     100             : 
     101        2752 :     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         238 : SwCharFormat* SwLineNumberInfo::GetCharFormat( IDocumentStylePoolAccess& rIDSPA ) const
     120             : {
     121         238 :     if ( !GetRegisteredIn() )
     122             :     {
     123           9 :         SwCharFormat* pFormat = rIDSPA.GetCharFormatFromPool( RES_POOLCHR_LINENUM );
     124           9 :         pFormat->Add( const_cast<SwClient*>(static_cast<SwClient const *>(this)) );
     125             :     }
     126         238 :     return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn()));
     127             : }
     128             : 
     129           3 : void SwLineNumberInfo::SetCharFormat( SwCharFormat *pChFormat )
     130             : {
     131             :     OSL_ENSURE( pChFormat, "SetCharFormat, 0 is not a valid pointer" );
     132           3 :     pChFormat->Add( this );
     133           3 : }
     134             : 
     135          24 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     136             : {
     137          24 :     CheckRegistration( pOld, pNew );
     138          24 :     SwDoc *pDoc = static_cast<SwCharFormat*>(GetRegisteredIn())->GetDoc();
     139          24 :     SwRootFrm* pRoot = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
     140          24 :     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         201 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11