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 :
21 : #include "doc.hxx"
22 : #include "lineinfo.hxx"
23 : #include "charfmt.hxx"
24 : #include "poolfmt.hxx"
25 : #include "rootfrm.hxx"
26 : #include "viewsh.hxx"
27 : #include <set>
28 153 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
29 : {
30 153 : SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
31 153 : if ( pTmpRoot &&
32 0 : (rNew.IsCountBlankLines() != pLineNumberInfo->IsCountBlankLines() ||
33 0 : rNew.IsRestartEachPage() != pLineNumberInfo->IsRestartEachPage()) )
34 : {
35 0 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080225
36 0 : pTmpRoot->StartAllAction();
37 : // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
38 : // is only (onny may only be) called by the formatting routines
39 : //pTmpRoot->InvalidateAllCntnt( INV_LINENUM | INV_SIZE );
40 0 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_LINENUM | INV_SIZE));//swmod 080226
41 0 : pTmpRoot->EndAllAction();
42 : } //swmod 080219
43 153 : *pLineNumberInfo = rNew;
44 153 : SetModified();
45 153 : }
46 :
47 4904 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
48 : {
49 4904 : return *pLineNumberInfo;
50 : }
51 :
52 276 : SwLineNumberInfo::SwLineNumberInfo() :
53 : nPosFromLeft( MM50 ),
54 : nCountBy( 5 ),
55 : nDividerCountBy( 3 ),
56 : ePos( LINENUMBER_POS_LEFT ),
57 : bPaintLineNumbers( sal_False ),
58 : bCountBlankLines( sal_True ),
59 : bCountInFlys( sal_False ),
60 276 : bRestartEachPage( sal_False )
61 : {
62 276 : }
63 :
64 153 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
65 153 : aType( rCpy.GetNumType() ),
66 153 : aDivider( rCpy.GetDivider() ),
67 153 : nPosFromLeft( rCpy.GetPosFromLeft() ),
68 153 : nCountBy( rCpy.GetCountBy() ),
69 153 : nDividerCountBy( rCpy.GetDividerCountBy() ),
70 153 : ePos( rCpy.GetPos() ),
71 153 : bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
72 153 : bCountBlankLines( rCpy.IsCountBlankLines() ),
73 153 : bCountInFlys( rCpy.IsCountInFlys() ),
74 1530 : bRestartEachPage( rCpy.IsRestartEachPage() )
75 : {
76 153 : if ( rCpy.GetRegisteredIn() )
77 0 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
78 153 : }
79 :
80 153 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
81 : {
82 153 : if ( rCpy.GetRegisteredIn() )
83 0 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
84 153 : else if ( GetRegisteredIn() )
85 0 : GetRegisteredInNonConst()->Remove( this );
86 :
87 153 : aType = rCpy.GetNumType();
88 153 : aDivider = rCpy.GetDivider();
89 153 : nPosFromLeft = rCpy.GetPosFromLeft();
90 153 : nCountBy = rCpy.GetCountBy();
91 153 : nDividerCountBy = rCpy.GetDividerCountBy();
92 153 : ePos = rCpy.GetPos();
93 153 : bPaintLineNumbers = rCpy.IsPaintLineNumbers();
94 153 : bCountBlankLines = rCpy.IsCountBlankLines();
95 153 : bCountInFlys = rCpy.IsCountInFlys();
96 153 : bRestartEachPage = rCpy.IsRestartEachPage();
97 :
98 153 : return *this;
99 : }
100 :
101 0 : bool SwLineNumberInfo::operator==( const SwLineNumberInfo& rInf ) const
102 : {
103 0 : return GetRegisteredIn() == rInf.GetRegisteredIn() &&
104 0 : aType.GetNumberingType() == rInf.GetNumType().GetNumberingType() &&
105 0 : aDivider == rInf.GetDivider() &&
106 0 : nPosFromLeft == rInf.GetPosFromLeft() &&
107 0 : nCountBy == rInf.GetCountBy() &&
108 0 : nDividerCountBy == rInf.GetDividerCountBy() &&
109 0 : ePos == rInf.GetPos() &&
110 0 : bPaintLineNumbers == rInf.IsPaintLineNumbers() &&
111 0 : bCountBlankLines == rInf.IsCountBlankLines() &&
112 0 : bCountInFlys == rInf.IsCountInFlys() &&
113 0 : bRestartEachPage == rInf.IsRestartEachPage();
114 : }
115 :
116 :
117 0 : SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const
118 : {
119 0 : if ( !GetRegisteredIn() )
120 : {
121 0 : SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM );
122 0 : pFmt->Add( (SwClient*)this );
123 : }
124 0 : return (SwCharFmt*)GetRegisteredIn();
125 : }
126 :
127 0 : void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt )
128 : {
129 : OSL_ENSURE( pChFmt, "SetCharFmt, 0 is not a valid pointer" );
130 0 : pChFmt->Add( this );
131 0 : }
132 :
133 0 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
134 : {
135 0 : CheckRegistration( pOld, pNew );
136 0 : SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc();
137 0 : SwRootFrm* pRoot = pDoc->GetCurrentLayout();
138 0 : if( pRoot )
139 : {
140 0 : pRoot->StartAllAction();
141 0 : std::set<SwRootFrm*> aAllLayouts = pDoc->GetAllLayouts();
142 0 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllAddPaintRect));//swmod 080305
143 : //pRoot->GetCurrShell()->AddPaintRect( pRoot->Frm() );
144 0 : pRoot->EndAllAction();
145 : }
146 0 : }
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|