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 0 : void SwDoc::SetLineNumberInfo( const SwLineNumberInfo &rNew )
29 : {
30 0 : SwRootFrm* pTmpRoot = GetCurrentLayout();
31 0 : if ( pTmpRoot &&
32 0 : (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
33 0 : rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
34 : {
35 0 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
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));
41 0 : pTmpRoot->EndAllAction();
42 : }
43 0 : *mpLineNumberInfo = rNew;
44 0 : SetModified();
45 0 : }
46 :
47 0 : const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
48 : {
49 0 : return *mpLineNumberInfo;
50 : }
51 :
52 0 : 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 0 : bRestartEachPage( sal_False )
61 : {
62 0 : }
63 :
64 0 : SwLineNumberInfo::SwLineNumberInfo(const SwLineNumberInfo &rCpy ) : SwClient(),
65 0 : aType( rCpy.GetNumType() ),
66 : aDivider( rCpy.GetDivider() ),
67 0 : nPosFromLeft( rCpy.GetPosFromLeft() ),
68 0 : nCountBy( rCpy.GetCountBy() ),
69 0 : nDividerCountBy( rCpy.GetDividerCountBy() ),
70 0 : ePos( rCpy.GetPos() ),
71 0 : bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
72 0 : bCountBlankLines( rCpy.IsCountBlankLines() ),
73 0 : bCountInFlys( rCpy.IsCountInFlys() ),
74 0 : bRestartEachPage( rCpy.IsRestartEachPage() )
75 : {
76 0 : if ( rCpy.GetRegisteredIn() )
77 0 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
78 0 : }
79 :
80 0 : SwLineNumberInfo& SwLineNumberInfo::operator=(const SwLineNumberInfo &rCpy)
81 : {
82 0 : if ( rCpy.GetRegisteredIn() )
83 0 : ((SwModify*)rCpy.GetRegisteredIn())->Add( this );
84 0 : else if ( GetRegisteredIn() )
85 0 : GetRegisteredInNonConst()->Remove( this );
86 :
87 0 : aType = rCpy.GetNumType();
88 0 : aDivider = rCpy.GetDivider();
89 0 : nPosFromLeft = rCpy.GetPosFromLeft();
90 0 : nCountBy = rCpy.GetCountBy();
91 0 : nDividerCountBy = rCpy.GetDividerCountBy();
92 0 : ePos = rCpy.GetPos();
93 0 : bPaintLineNumbers = rCpy.IsPaintLineNumbers();
94 0 : bCountBlankLines = rCpy.IsCountBlankLines();
95 0 : bCountInFlys = rCpy.IsCountInFlys();
96 0 : bRestartEachPage = rCpy.IsRestartEachPage();
97 :
98 0 : 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 0 : SwCharFmt* SwLineNumberInfo::GetCharFmt( IDocumentStylePoolAccess& rIDSPA ) const
117 : {
118 0 : if ( !GetRegisteredIn() )
119 : {
120 0 : SwCharFmt* pFmt = rIDSPA.GetCharFmtFromPool( RES_POOLCHR_LINENUM );
121 0 : pFmt->Add( (SwClient*)this );
122 : }
123 0 : return (SwCharFmt*)GetRegisteredIn();
124 : }
125 :
126 0 : void SwLineNumberInfo::SetCharFmt( SwCharFmt *pChFmt )
127 : {
128 : OSL_ENSURE( pChFmt, "SetCharFmt, 0 is not a valid pointer" );
129 0 : pChFmt->Add( this );
130 0 : }
131 :
132 0 : void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
133 : {
134 0 : CheckRegistration( pOld, pNew );
135 0 : SwDoc *pDoc = ((SwCharFmt*)GetRegisteredIn())->GetDoc();
136 0 : SwRootFrm* pRoot = pDoc->GetCurrentLayout();
137 0 : 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 0 : }
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|