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