1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 28 29 #include "doc.hxx" 30 #include "lineinfo.hxx" 31 #include "charfmt.hxx" 32 #include "poolfmt.hxx" 33 #include "rootfrm.hxx" 34 #include "viewsh.hxx" 35 #include <set> 36 void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew ) 37 { 38 SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219 39 if ( pTmpRoot && 40 (rNew.IsCountBlankLines() != pLineNumberInfo->IsCountBlankLines() || 41 rNew.IsRestartEachPage() != pLineNumberInfo->IsRestartEachPage()) ) 42 { 43 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080225 44 pTmpRoot->StartAllAction(); 45 // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines() 46 // is only (onny may only be) called by the formatting routines 47 //pTmpRoot->InvalidateAllCntnt( INV_LINENUM | INV_SIZE ); 48 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_LINENUM | INV_SIZE));//swmod 080226 49 pTmpRoot->EndAllAction(); 50 } //swmod 080219 51 *pLineNumberInfo = rNew; 52 SetModified(); 53 } 54 55 const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const 56 { 57 return *pLineNumberInfo; 58 } 59 60 SwLineNumberInfo::SwLineNumberInfo() : 61 nPosFromLeft( MM50 ), 62 nCountBy( 5 ), 63 nDividerCountBy( 3 ), 64 ePos( LINENUMBER_POS_LEFT ), 65 bPaintLineNumbers( sal_False ), 66 bCountBlankLines( sal_True ), 67 bCountInFlys( sal_False ), 68 bRestartEachPage( sal_False ) 69 { 70 } 71 72 SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(), 73 aType( rCpy.GetNumType() ), 74 aDivider( rCpy.GetDivider() ), 75 nPosFromLeft( rCpy.GetPosFromLeft() ), 76 nCountBy( rCpy.GetCountBy() ), 77 nDividerCountBy( rCpy.GetDividerCountBy() ), 78 ePos( rCpy.GetPos() ), 79 bPaintLineNumbers( rCpy.IsPaintLineNumbers() ), 80 bCountBlankLines( rCpy.IsCountBlankLines() ), 81 bCountInFlys( rCpy.IsCountInFlys() ), 82 bRestartEachPage( rCpy.IsRestartEachPage() ) 83 { 84 if ( rCpy.GetRegisteredIn() ) 85 ((SwModify*)rCpy.GetRegisteredIn())->Add( this ); 86 } 87 88 SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy) 89 { 90 if ( rCpy.GetRegisteredIn() ) 91 ((SwModify*)rCpy.GetRegisteredIn())->Add( this ); 92 else if ( GetRegisteredIn() ) 93 GetRegisteredInNonConst()->Remove( this ); 94 95 aType = rCpy.GetNumType(); 96 aDivider = rCpy.GetDivider(); 97 nPosFromLeft = rCpy.GetPosFromLeft(); 98 nCountBy = rCpy.GetCountBy(); 99 nDividerCountBy = rCpy.GetDividerCountBy(); 100 ePos = rCpy.GetPos(); 101 bPaintLineNumbers = rCpy.IsPaintLineNumbers(); 102 bCountBlankLines = rCpy.IsCountBlankLines(); 103 bCountInFlys = rCpy.IsCountInFlys(); 104 bRestartEachPage = rCpy.IsRestartEachPage(); 105 106 return *this; 107 } 108 109 sal_Bool SwLineNumberInfo::operator==( const SwLineNumberInfo& rInf ) const 110 { 111 return GetRegisteredIn() == rInf.GetRegisteredIn() && 112 aType.GetNumberingType() == rInf.GetNumType().GetNumberingType() && 113 aDivider == rInf.GetDivider() && 114 nPosFromLeft == rInf.GetPosFromLeft() && 115 nCountBy == rInf.GetCountBy() && 116 nDividerCountBy == rInf.GetDividerCountBy() && 117 ePos == rInf.GetPos() && 118 bPaintLineNumbers == rInf.IsPaintLineNumbers() && 119 bCountBlankLines == rInf.IsCountBlankLines() && 120 bCountInFlys == rInf.IsCountInFlys() && 121 bRestartEachPage == rInf.IsRestartEachPage(); 122 } 123 124 125 SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const 126 { 127 if ( !GetRegisteredIn() ) 128 { 129 SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM ); 130 pFmt->Add( (SwClient*)this ); 131 } 132 return (SwCharFmt*)GetRegisteredIn(); 133 } 134 135 void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt ) 136 { 137 ASSERT( pChFmt, "SetCharFmt, 0 is not a valid pointer" ); 138 pChFmt->Add( this ); 139 } 140 141 void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) 142 { 143 CheckRegistration( pOld, pNew ); 144 SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc(); 145 SwRootFrm* pRoot = pDoc->GetCurrentLayout(); 146 if( pRoot ) 147 { 148 pRoot->StartAllAction(); 149 std::set<SwRootFrm*> aAllLayouts = pDoc->GetAllLayouts(); 150 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllAddPaintRect));//swmod 080305 151 //pRoot->GetCurrShell()->AddPaintRect( pRoot->Frm() ); 152 pRoot->EndAllAction(); 153 } 154 } 155 156