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 : #include "doc.hxx"
21 : #include "lineinfo.hxx"
22 : #include "charfmt.hxx"
23 : #include "poolfmt.hxx"
24 : #include "rootfrm.hxx"
25 : #include "viewsh.hxx"
26 : #include <set>
27 :
28 1116 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
29 : {
30 1116 : SwRootFrm* pTmpRoot = GetCurrentLayout();
31 1127 : if ( pTmpRoot &&
32 19 : (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
33 9 : rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
34 : {
35 1 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
36 1 : 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 1 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_LINENUM | INV_SIZE));
41 1 : pTmpRoot->EndAllAction();
42 : }
43 1116 : *mpLineNumberInfo = rNew;
44 1116 : SetModified();
45 1116 : }
46 :
47 127382 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
48 : {
49 127382 : return *mpLineNumberInfo;
50 : }
51 :
52 1852 : 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 1852 : bRestartEachPage( sal_False )
61 : {
62 1852 : }
63 :
64 1116 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
65 1116 : aType( rCpy.GetNumType() ),
66 : aDivider( rCpy.GetDivider() ),
67 1116 : nPosFromLeft( rCpy.GetPosFromLeft() ),
68 1116 : nCountBy( rCpy.GetCountBy() ),
69 1116 : nDividerCountBy( rCpy.GetDividerCountBy() ),
70 1116 : ePos( rCpy.GetPos() ),
71 1116 : bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
72 1116 : bCountBlankLines( rCpy.IsCountBlankLines() ),
73 1116 : bCountInFlys( rCpy.IsCountInFlys() ),
74 10044 : bRestartEachPage( rCpy.IsRestartEachPage() )
75 : {
76 1116 : if ( rCpy.GetRegisteredIn() )
77 8 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
78 1116 : }
79 :
80 1116 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
81 : {
82 1116 : if ( rCpy.GetRegisteredIn() )
83 9 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
84 1107 : else if ( GetRegisteredIn() )
85 0 : GetRegisteredInNonConst()->Remove( this );
86 :
87 1116 : aType = rCpy.GetNumType();
88 1116 : aDivider = rCpy.GetDivider();
89 1116 : nPosFromLeft = rCpy.GetPosFromLeft();
90 1116 : nCountBy = rCpy.GetCountBy();
91 1116 : nDividerCountBy = rCpy.GetDividerCountBy();
92 1116 : ePos = rCpy.GetPos();
93 1116 : bPaintLineNumbers = rCpy.IsPaintLineNumbers();
94 1116 : bCountBlankLines = rCpy.IsCountBlankLines();
95 1116 : bCountInFlys = rCpy.IsCountInFlys();
96 1116 : bRestartEachPage = rCpy.IsRestartEachPage();
97 :
98 1116 : 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 101 : SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const
117 : {
118 101 : if ( !GetRegisteredIn() )
119 : {
120 7 : SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM );
121 7 : pFmt->Add( (SwClient*)this );
122 : }
123 101 : return (SwCharFmt*)GetRegisteredIn();
124 : }
125 :
126 1 : void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt )
127 : {
128 : OSL_ENSURE( pChFmt, "SetCharFmt, 0 is not a valid pointer" );
129 1 : pChFmt->Add( this );
130 1 : }
131 :
132 16 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
133 : {
134 16 : CheckRegistration( pOld, pNew );
135 16 : SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc();
136 16 : SwRootFrm* pRoot = pDoc->GetCurrentLayout();
137 16 : if( pRoot )
138 : {
139 0 : pRoot->StartAllAction();
140 0 : std::set<SwRootFrm*> aAllLayouts = pDoc->GetAllLayouts();
141 0 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllAddPaintRect));
142 : //pRoot->GetCurrShell()->AddPaintRect( pRoot->Frm() );
143 0 : pRoot->EndAllAction();
144 : }
145 16 : }
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|