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