1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: lineinfo.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
37 #include "lineinfo.hxx"
38 #include "charfmt.hxx"
39 #include "poolfmt.hxx"
40 #include "rootfrm.hxx"
43 void SwDoc::SetLineNumberInfo( const SwLineNumberInfo
&rNew
)
46 (rNew
.IsCountBlankLines() != pLineNumberInfo
->IsCountBlankLines() ||
47 rNew
.IsRestartEachPage() != pLineNumberInfo
->IsRestartEachPage()) )
49 GetRootFrm()->StartAllAction();
50 // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
51 // is only (onny may only be) called by the formatting routines
52 GetRootFrm()->InvalidateAllCntnt( INV_LINENUM
| INV_SIZE
);
53 GetRootFrm()->EndAllAction();
55 *pLineNumberInfo
= rNew
;
59 const SwLineNumberInfo
& SwDoc::GetLineNumberInfo() const
61 return *pLineNumberInfo
;
64 SwLineNumberInfo::SwLineNumberInfo() :
68 ePos( LINENUMBER_POS_LEFT
),
69 bPaintLineNumbers( FALSE
),
70 bCountBlankLines( TRUE
),
71 bCountInFlys( FALSE
),
72 bRestartEachPage( FALSE
)
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() )
88 if ( rCpy
.GetRegisteredIn() )
89 ((SwModify
*)rCpy
.GetRegisteredIn())->Add( this );
92 SwLineNumberInfo
& SwLineNumberInfo::operator=(const SwLineNumberInfo
&rCpy
)
94 if ( rCpy
.GetRegisteredIn() )
95 ((SwModify
*)rCpy
.GetRegisteredIn())->Add( this );
96 else if ( GetRegisteredIn() )
97 pRegisteredIn
->Remove( this );
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();
113 BOOL
SwLineNumberInfo::operator==( const SwLineNumberInfo
& rInf
) const
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();
129 SwCharFmt
* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess
& rIDSPA
) const
131 if ( !GetRegisteredIn() )
133 SwCharFmt
* pFmt
= rIDSPA
.GetCharFmtFromPool( RES_POOLCHR_LINENUM
);
134 pFmt
->Add( (SwClient
*)this );
136 return (SwCharFmt
*)GetRegisteredIn();
139 void SwLineNumberInfo::SetCharFmt( SwCharFmt
*pChFmt
)
141 ASSERT( pChFmt
, "SetCharFmt, 0 is not a valid pointer" );
145 void SwLineNumberInfo::Modify( SfxPoolItem
* pOld
, SfxPoolItem
* pNew
)
147 SwClient::Modify( pOld
, pNew
);
148 SwDoc
*pDoc
= ((SwCharFmt
*)GetRegisteredIn())->GetDoc();
149 SwRootFrm
* pRoot
= pDoc
->GetRootFrm();
150 if( pRoot
&& pRoot
->GetCurrShell() )
152 pRoot
->StartAllAction();
153 pRoot
->GetCurrShell()->AddPaintRect( pRoot
->Frm() );
154 pRoot
->EndAllAction();