Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <ftnidx.hxx>
30 : : #include <rootfrm.hxx>
31 : : #include <txtftn.hxx>
32 : : #include <fmtftn.hxx>
33 : : #include <pam.hxx>
34 : : #include <pagedesc.hxx>
35 : : #include <charfmt.hxx>
36 : : #include <UndoAttribute.hxx>
37 : : #include <hints.hxx>
38 : : #include <rolbck.hxx>
39 : : #include <doc.hxx>
40 : : #include <IDocumentUndoRedo.hxx>
41 : : #include <ndtxt.hxx>
42 : : #include <poolfmt.hxx>
43 : : #include <ftninfo.hxx>
44 : :
45 : : /*********************** SwFtnInfo ***************************/
46 : :
47 : 80 : SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo)
48 : : {
49 [ + + ]: 80 : if( rInfo.GetFtnTxtColl() )
50 : 30 : rInfo.GetFtnTxtColl()->Add(this);
51 [ - + ]: 50 : else if ( GetRegisteredIn())
52 : 0 : GetRegisteredInNonConst()->Remove(this);
53 : :
54 [ + + ]: 80 : if ( rInfo.aPageDescDep.GetRegisteredIn() )
55 : 55 : ((SwModify*)rInfo.aPageDescDep.GetRegisteredIn())->Add( &aPageDescDep );
56 [ - + ]: 25 : else if ( aPageDescDep.GetRegisteredIn() )
57 : 0 : ((SwModify*)aPageDescDep.GetRegisteredIn())->Remove( &aPageDescDep );
58 : :
59 [ + + ]: 80 : if ( rInfo.aCharFmtDep.GetRegisteredIn() )
60 : 77 : ((SwModify*)rInfo.aCharFmtDep.GetRegisteredIn())->Add( &aCharFmtDep );
61 [ - + ]: 3 : else if ( aCharFmtDep.GetRegisteredIn() )
62 : 0 : ((SwModify*)aCharFmtDep.GetRegisteredIn())->Remove( &aCharFmtDep );
63 : :
64 [ + + ]: 80 : if ( rInfo.aAnchorCharFmtDep.GetRegisteredIn() )
65 : 51 : ((SwModify*)rInfo.aAnchorCharFmtDep.GetRegisteredIn())->Add(
66 : 51 : &aAnchorCharFmtDep );
67 [ - + ]: 29 : else if( aAnchorCharFmtDep.GetRegisteredIn() )
68 : 0 : ((SwModify*)aAnchorCharFmtDep.GetRegisteredIn())->Remove(
69 : 0 : &aAnchorCharFmtDep );
70 : :
71 : 80 : aFmt = rInfo.aFmt;
72 : 80 : nFtnOffset = rInfo.nFtnOffset;
73 : 80 : m_bEndNote = rInfo.m_bEndNote;
74 : 80 : sPrefix = rInfo.sPrefix;
75 : 80 : sSuffix = rInfo.sSuffix;
76 : 80 : return *this;
77 : : }
78 : :
79 : :
80 : 1446 : sal_Bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const
81 : : {
82 : 1446 : return aPageDescDep.GetRegisteredIn() ==
83 : 1446 : rInfo.aPageDescDep.GetRegisteredIn() &&
84 : 1439 : aCharFmtDep.GetRegisteredIn() ==
85 : 1439 : rInfo.aCharFmtDep.GetRegisteredIn() &&
86 : 1425 : aAnchorCharFmtDep.GetRegisteredIn() ==
87 : 1425 : rInfo.aAnchorCharFmtDep.GetRegisteredIn() &&
88 : 1419 : GetFtnTxtColl() == rInfo.GetFtnTxtColl() &&
89 : 1412 : aFmt.GetNumberingType() == rInfo.aFmt.GetNumberingType() &&
90 : : nFtnOffset == rInfo.nFtnOffset &&
91 : : m_bEndNote == rInfo.m_bEndNote &&
92 : 1398 : sPrefix == rInfo.sPrefix &&
93 [ + + ]: 8539 : sSuffix == rInfo.sSuffix;
[ + - + + ]
[ + + ][ + +
+ + + + +
+ + + ]
94 : : }
95 : :
96 : :
97 : 1493 : SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) :
98 : 1493 : SwClient( rInfo.GetFtnTxtColl() ),
99 : : aPageDescDep( this, 0 ),
100 : : aCharFmtDep( this, 0 ),
101 : : aAnchorCharFmtDep( this, 0 ),
102 : : sPrefix( rInfo.sPrefix ),
103 : : sSuffix( rInfo.sSuffix ),
104 : : m_bEndNote( true ),
105 : : aFmt( rInfo.aFmt ),
106 [ + - ][ + - ]: 1493 : nFtnOffset( rInfo.nFtnOffset )
[ + - ][ + - ]
107 : : {
108 [ + + ]: 1493 : if( rInfo.aPageDescDep.GetRegisteredIn() )
109 [ + - ]: 119 : ((SwModify*)rInfo.aPageDescDep.GetRegisteredIn())->Add( &aPageDescDep );
110 : :
111 [ + + ]: 1493 : if( rInfo.aCharFmtDep.GetRegisteredIn() )
112 [ + - ]: 161 : ((SwModify*)rInfo.aCharFmtDep.GetRegisteredIn())->Add( &aCharFmtDep );
113 : :
114 [ + + ]: 1493 : if( rInfo.aAnchorCharFmtDep.GetRegisteredIn() )
115 : 117 : ((SwModify*)rInfo.aAnchorCharFmtDep.GetRegisteredIn())->Add(
116 [ + - ]: 117 : &aAnchorCharFmtDep );
117 : 1493 : }
118 : :
119 : 3101 : SwEndNoteInfo::SwEndNoteInfo(SwTxtFmtColl *pFmt) :
120 : : SwClient(pFmt),
121 : : aPageDescDep( this, 0 ),
122 : : aCharFmtDep( this, 0 ),
123 : : aAnchorCharFmtDep( this, 0 ),
124 : : m_bEndNote( true ),
125 [ + - ][ + - ]: 3101 : nFtnOffset( 0 )
[ + - ][ + - ]
126 : : {
127 : 3101 : aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER);
128 : 3101 : }
129 : :
130 : 78 : SwPageDesc *SwEndNoteInfo::GetPageDesc( SwDoc &rDoc ) const
131 : : {
132 [ + + ]: 78 : if ( !aPageDescDep.GetRegisteredIn() )
133 : : {
134 : : SwPageDesc *pDesc = rDoc.GetPageDescFromPool( static_cast<sal_uInt16>(
135 [ + - ]: 26 : m_bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) );
136 : 26 : pDesc->Add( &((SwClient&)aPageDescDep) );
137 : : }
138 : :
139 : 78 : return (SwPageDesc*)( aPageDescDep.GetRegisteredIn() );
140 : : }
141 : :
142 : 46 : bool SwEndNoteInfo::KnowsPageDesc() const
143 : : {
144 : 46 : return (aPageDescDep.GetRegisteredIn() != 0);
145 : : }
146 : :
147 : 1986 : bool SwEndNoteInfo::DependsOn( const SwPageDesc* pDesc ) const
148 : : {
149 : 1986 : return ( aPageDescDep.GetRegisteredIn() == pDesc );
150 : : }
151 : :
152 : 12 : void SwEndNoteInfo::ChgPageDesc( SwPageDesc *pDesc )
153 : : {
154 : 12 : pDesc->Add( &((SwClient&)aPageDescDep) );
155 : 12 : }
156 : :
157 : 7 : void SwEndNoteInfo::SetFtnTxtColl(SwTxtFmtColl& rFmt)
158 : : {
159 : 7 : rFmt.Add(this);
160 : 7 : }
161 : :
162 : 306 : SwCharFmt* SwEndNoteInfo::GetCharFmt(SwDoc &rDoc) const
163 : : {
164 [ + + ]: 306 : if ( !aCharFmtDep.GetRegisteredIn() )
165 : : {
166 : : SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>(
167 [ + + ]: 70 : m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) );
168 : 70 : pFmt->Add( &((SwClient&)aCharFmtDep) );
169 : : }
170 : 306 : return (SwCharFmt*)aCharFmtDep.GetRegisteredIn();
171 : : }
172 : :
173 : 14 : void SwEndNoteInfo::SetCharFmt( SwCharFmt* pChFmt )
174 : : {
175 : : OSL_ENSURE(pChFmt, "no CharFmt?");
176 : 14 : pChFmt->Add( &((SwClient&)aCharFmtDep) );
177 : 14 : }
178 : :
179 : 428 : SwCharFmt* SwEndNoteInfo::GetAnchorCharFmt(SwDoc &rDoc) const
180 : : {
181 [ + + ]: 428 : if( !aAnchorCharFmtDep.GetRegisteredIn() )
182 : : {
183 : : SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>(
184 [ + + ]: 32 : m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) );
185 : 32 : pFmt->Add( &((SwClient&)aAnchorCharFmtDep) );
186 : : }
187 : 428 : return (SwCharFmt*)aAnchorCharFmtDep.GetRegisteredIn();
188 : : }
189 : :
190 : 6 : void SwEndNoteInfo::SetAnchorCharFmt( SwCharFmt* pChFmt )
191 : : {
192 : : OSL_ENSURE(pChFmt, "no CharFmt?");
193 : 6 : pChFmt->Add( &((SwClient&)aAnchorCharFmtDep) );
194 : 6 : }
195 : :
196 : 294 : void SwEndNoteInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
197 : : {
198 [ + - ][ # # ]: 294 : sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
199 : :
200 [ + + ][ + - ]: 294 : if( RES_ATTRSET_CHG == nWhich ||
201 : : RES_FMT_CHG == nWhich )
202 : : {
203 : : SwDoc* pDoc;
204 [ + - ]: 294 : if( aCharFmtDep.GetRegisteredIn() )
205 : 294 : pDoc = ((SwCharFmt*)aCharFmtDep.GetRegisteredIn())->GetDoc();
206 : : else
207 : 0 : pDoc = ((SwCharFmt*)aAnchorCharFmtDep.GetRegisteredIn())->GetDoc();
208 : 294 : SwFtnIdxs& rFtnIdxs = pDoc->GetFtnIdxs();
209 [ + + ]: 488 : for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.size(); ++nPos )
210 : : {
211 : 194 : SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
212 : 194 : const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
213 [ + - ]: 194 : if ( rFtn.IsEndNote() == m_bEndNote )
214 : : {
215 : 194 : pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
216 : : }
217 : 294 : }
218 : : }
219 : : else
220 : 0 : CheckRegistration( pOld, pNew );
221 : 294 : }
222 : :
223 : 52 : SwFtnInfo& SwFtnInfo::operator=(const SwFtnInfo& rInfo)
224 : : {
225 : 52 : SwEndNoteInfo::operator=(rInfo);
226 : 52 : aQuoVadis = rInfo.aQuoVadis;
227 : 52 : aErgoSum = rInfo.aErgoSum;
228 : 52 : ePos = rInfo.ePos;
229 : 52 : eNum = rInfo.eNum;
230 : 52 : return *this;
231 : : }
232 : :
233 : :
234 : 925 : sal_Bool SwFtnInfo::operator==( const SwFtnInfo& rInfo ) const
235 : : {
236 : : return ePos == rInfo.ePos &&
237 : : eNum == rInfo.eNum &&
238 : 915 : SwEndNoteInfo::operator==(rInfo) &&
239 : 880 : aQuoVadis == rInfo.aQuoVadis &&
240 [ + + ][ + + : 2720 : aErgoSum == rInfo.aErgoSum;
+ + + + ]
[ + + ]
241 : : }
242 : :
243 : :
244 : 948 : SwFtnInfo::SwFtnInfo(const SwFtnInfo& rInfo) :
245 : : SwEndNoteInfo( rInfo ),
246 : : aQuoVadis( rInfo.aQuoVadis ),
247 : : aErgoSum( rInfo.aErgoSum ),
248 : : ePos( rInfo.ePos ),
249 [ + - ][ + - ]: 948 : eNum( rInfo.eNum )
250 : : {
251 : 948 : m_bEndNote = false;
252 : 948 : }
253 : :
254 : 1552 : SwFtnInfo::SwFtnInfo(SwTxtFmtColl *pFmt) :
255 : : SwEndNoteInfo( pFmt ),
256 : : ePos( FTNPOS_PAGE ),
257 [ + - ][ + - ]: 1552 : eNum( FTNNUM_DOC )
258 : : {
259 : 1552 : aFmt.SetNumberingType(SVX_NUM_ARABIC);
260 : 1552 : m_bEndNote = false;
261 : 1552 : }
262 : :
263 : : /*********************** SwDoc ***************************/
264 : :
265 : :
266 : 925 : void SwDoc::SetFtnInfo(const SwFtnInfo& rInfo)
267 : : {
268 : 925 : SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
269 [ + + ]: 925 : if( !(GetFtnInfo() == rInfo) )
270 : : {
271 : 49 : const SwFtnInfo &rOld = GetFtnInfo();
272 : :
273 [ + + ]: 49 : if (GetIDocumentUndoRedo().DoesUndo())
274 : : {
275 [ + - ]: 26 : GetIDocumentUndoRedo().AppendUndo( new SwUndoFootNoteInfo(rOld) );
276 : : }
277 : :
278 : 49 : sal_Bool bFtnPos = rInfo.ePos != rOld.ePos;
279 : : sal_Bool bFtnDesc = rOld.ePos == FTNPOS_CHAPTER &&
280 [ - + ][ # # ]: 49 : rInfo.GetPageDesc( *this ) != rOld.GetPageDesc( *this );
281 : 49 : sal_Bool bExtra = rInfo.aQuoVadis != rOld.aQuoVadis ||
282 : 47 : rInfo.aErgoSum != rOld.aErgoSum ||
283 : 45 : rInfo.aFmt.GetNumberingType() != rOld.aFmt.GetNumberingType() ||
284 : 43 : rInfo.GetPrefix() != rOld.GetPrefix() ||
285 [ + + ][ + + : 184 : rInfo.GetSuffix() != rOld.GetSuffix();
+ + + + +
+ ]
286 : 49 : SwCharFmt *pOldChrFmt = rOld.GetCharFmt( *this ),
287 : 49 : *pNewChrFmt = rInfo.GetCharFmt( *this );
288 : 49 : sal_Bool bFtnChrFmts = pOldChrFmt != pNewChrFmt;
289 : :
290 : 49 : *pFtnInfo = rInfo;
291 : :
292 [ + + ]: 49 : if (pTmpRoot)
293 : : {
294 [ + - ]: 26 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080304
295 [ + + ]: 26 : if ( bFtnPos )
296 : : //pTmpRoot->RemoveFtns();
297 [ + - ][ + - ]: 2 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllRemoveFtns));//swmod 080305
298 : : else
299 : : {
300 : : //pTmpRoot->UpdateFtnNums();
301 [ + - ][ + - ]: 24 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::UpdateFtnNums));//swmod 080304
302 [ - + ]: 24 : if ( bFtnDesc )
303 : : //pTmpRoot->CheckFtnPageDescs( FALSE );
304 [ # # ][ # # ]: 0 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), sal_False));//swmod 080304
[ # # ]
305 [ + + ]: 24 : if ( bExtra )
306 : : {
307 : : // For messages regarding ErgoSum etc. we save the extra code and use the
308 : : // available methods.
309 : 14 : SwFtnIdxs& rFtnIdxs = GetFtnIdxs();
310 [ + + ]: 24 : for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.size(); ++nPos )
311 : : {
312 [ + - ]: 10 : SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
313 : 10 : const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
314 [ + - ]: 10 : if ( !rFtn.IsEndNote() )
315 [ + - ]: 10 : pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
316 : : }
317 : : }
318 : 26 : }
319 : : } //swmod 080219
320 [ + + ]: 49 : if( FTNNUM_PAGE != rInfo.eNum )
321 : 43 : GetFtnIdxs().UpdateAllFtn();
322 [ - + ]: 6 : else if( bFtnChrFmts )
323 : : {
324 [ # # ]: 0 : SwFmtChg aOld( pOldChrFmt );
325 [ # # ]: 0 : SwFmtChg aNew( pNewChrFmt );
326 [ # # ][ # # ]: 0 : pFtnInfo->ModifyNotification( &aOld, &aNew );
[ # # ]
327 : : }
328 : :
329 : : // #i81002# no update during loading
330 [ + + ]: 49 : if ( !IsInReading() )
331 : : {
332 : 26 : UpdateRefFlds(NULL);
333 : : }
334 : 49 : SetModified();
335 : : }
336 : 925 : }
337 : :
338 : 531 : void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
339 : : {
340 : 531 : SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
341 [ + + ]: 531 : if( !(GetEndNoteInfo() == rInfo) )
342 : : {
343 [ + + ]: 28 : if(GetIDocumentUndoRedo().DoesUndo())
344 : : {
345 [ + - ]: 14 : SwUndo *const pUndo( new SwUndoEndNoteInfo( GetEndNoteInfo() ) );
346 : 14 : GetIDocumentUndoRedo().AppendUndo(pUndo);
347 : : }
348 : :
349 : 28 : sal_Bool bNumChg = rInfo.nFtnOffset != GetEndNoteInfo().nFtnOffset;
350 : : // this seems to be an optimization: UpdateAllFtn() is only called
351 : : // if the offset changes; if the offset is the same,
352 : : // but type/prefix/suffix changes, just set new numbers.
353 : : bool const bExtra = !bNumChg &&
354 : 26 : ( (rInfo.aFmt.GetNumberingType() !=
355 : 26 : GetEndNoteInfo().aFmt.GetNumberingType())
356 : 18 : || (rInfo.GetPrefix() != GetEndNoteInfo().GetPrefix())
357 : 16 : || (rInfo.GetSuffix() != GetEndNoteInfo().GetSuffix())
358 [ + + + + : 88 : );
+ + + + ]
359 : 28 : sal_Bool bFtnDesc = rInfo.GetPageDesc( *this ) !=
360 : 28 : GetEndNoteInfo().GetPageDesc( *this );
361 : 28 : SwCharFmt *pOldChrFmt = GetEndNoteInfo().GetCharFmt( *this ),
362 : 28 : *pNewChrFmt = rInfo.GetCharFmt( *this );
363 : 28 : sal_Bool bFtnChrFmts = pOldChrFmt != pNewChrFmt;
364 : :
365 : 28 : *pEndNoteInfo = rInfo;
366 : :
367 [ + + ]: 28 : if ( pTmpRoot )
368 : : {
369 [ + + ]: 14 : if ( bFtnDesc )
370 : : //pTmpRoot->CheckFtnPageDescs( TRUE );
371 : : {
372 [ + - ]: 2 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
373 [ + - ][ + - ]: 2 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), sal_True));//swmod 080304
[ + - ]
374 : : }
375 [ + + ]: 14 : if ( bExtra )
376 : : {
377 : : // For messages regarding ErgoSum etc. we save the extra code and use the
378 : : // available methods.
379 : 6 : SwFtnIdxs& rFtnIdxs = GetFtnIdxs();
380 [ + + ]: 12 : for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.size(); ++nPos )
381 : : {
382 : 6 : SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
383 : 6 : const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
384 [ + - ]: 6 : if ( rFtn.IsEndNote() )
385 : 6 : pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
386 : : }
387 : : }
388 : : } //swmod 080219
389 [ + + ]: 28 : if( bNumChg )
390 : 2 : GetFtnIdxs().UpdateAllFtn();
391 [ + + ]: 26 : else if( bFtnChrFmts )
392 : : {
393 [ + - ]: 2 : SwFmtChg aOld( pOldChrFmt );
394 [ + - ]: 2 : SwFmtChg aNew( pNewChrFmt );
395 [ + - ][ + - ]: 2 : pEndNoteInfo->ModifyNotification( &aOld, &aNew );
[ + - ]
396 : : }
397 : :
398 : : // #i81002# no update during loading
399 [ + + ]: 28 : if ( !IsInReading() )
400 : : {
401 : 14 : UpdateRefFlds(NULL);
402 : : }
403 : 28 : SetModified();
404 : : }
405 : 531 : }
406 : :
407 : :
408 : 4 : bool SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr,
409 : : sal_uInt16 nNumber, bool bIsEndNote )
410 : : {
411 : 4 : SwFtnIdxs& rFtnArr = GetFtnIdxs();
412 [ + - ]: 4 : SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
413 : :
414 [ + - ][ + - ]: 4 : const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
415 : 4 : const sal_uLong nSttNd = pStt->nNode.GetIndex();
416 : 4 : const xub_StrLen nSttCnt = pStt->nContent.GetIndex();
417 : 4 : const sal_uLong nEndNd = pEnd->nNode.GetIndex();
418 : 4 : const xub_StrLen nEndCnt = pEnd->nContent.GetIndex();
419 : :
420 : : sal_uInt16 nPos;
421 [ + - ]: 4 : rFtnArr.SeekEntry( pStt->nNode, &nPos );
422 : :
423 : 4 : SwUndoChangeFootNote* pUndo = 0;
424 [ + - ][ + - ]: 4 : if (GetIDocumentUndoRedo().DoesUndo())
[ + - ]
425 : : {
426 [ + - ][ + - ]: 4 : GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
427 [ + - ][ + - ]: 4 : pUndo = new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote );
428 : : }
429 : :
430 : : SwTxtFtn* pTxtFtn;
431 : : sal_uLong nIdx;
432 : 4 : sal_Bool bChg = sal_False;
433 : 4 : sal_Bool bTypeChgd = sal_False;
434 : 4 : sal_uInt16 n = nPos; // save
435 [ + + + - ]: 16 : while( nPos < rFtnArr.size() &&
[ + - + - ]
[ + + ]
436 [ + - ]: 4 : (( nIdx = _SwTxtFtn_GetIndex((pTxtFtn = rFtnArr[ nPos++ ] )))
437 : : < nEndNd || ( nIdx == nEndNd &&
438 : 4 : nEndCnt >= *pTxtFtn->GetStart() )) )
439 [ + - ]: 8 : if( nIdx > nSttNd || ( nIdx == nSttNd &&
[ + - + - ]
[ + - ]
440 : 4 : nSttCnt <= *pTxtFtn->GetStart() ) )
441 : : {
442 : 4 : const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
443 [ - + # # ]: 4 : if( rFtn.GetNumStr() != rNumStr ||
[ + - ][ + - ]
444 : 0 : rFtn.IsEndNote() != bIsEndNote )
445 : : {
446 : 4 : bChg = sal_True;
447 [ + - ]: 4 : if ( pUndo )
448 : : {
449 [ + - ]: 4 : pUndo->GetHistory().Add( *pTxtFtn );
450 : : }
451 : :
452 [ + - ]: 4 : pTxtFtn->SetNumber( nNumber, &rNumStr );
453 [ - + ]: 4 : if( rFtn.IsEndNote() != bIsEndNote )
454 : : {
455 [ # # ]: 0 : ((SwFmtFtn&)rFtn).SetEndNote( bIsEndNote );
456 : 0 : bTypeChgd = sal_True;
457 [ # # ]: 0 : pTxtFtn->CheckCondColl();
458 : : //#i11339# dispose UNO wrapper when a footnote is changed to an endnote or vice versa
459 [ # # ]: 0 : SwPtrMsgPoolItem aMsgHint( RES_FOOTNOTE_DELETED, (void*)&pTxtFtn->GetAttr() );
460 [ # # ][ # # ]: 0 : GetUnoCallBack()->ModifyNotification( &aMsgHint, &aMsgHint );
[ # # ]
461 : : }
462 : : }
463 : : }
464 : :
465 : 4 : nPos = n; // There are more in the front!
466 [ - + # # ]: 4 : while( nPos &&
[ # # # # ]
[ - + ]
467 [ # # ]: 0 : (( nIdx = _SwTxtFtn_GetIndex((pTxtFtn = rFtnArr[ --nPos ] )))
468 : : > nSttNd || ( nIdx == nSttNd &&
469 : 0 : nSttCnt <= *pTxtFtn->GetStart() )) )
470 [ # # ]: 0 : if( nIdx < nEndNd || ( nIdx == nEndNd &&
[ # # # # ]
[ # # ]
471 : 0 : nEndCnt >= *pTxtFtn->GetStart() ) )
472 : : {
473 : 0 : const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
474 [ # # # # ]: 0 : if( rFtn.GetNumStr() != rNumStr ||
[ # # ][ # # ]
475 : 0 : rFtn.IsEndNote() != bIsEndNote )
476 : : {
477 : 0 : bChg = sal_True;
478 [ # # ]: 0 : if ( pUndo )
479 : : {
480 [ # # ]: 0 : pUndo->GetHistory().Add( *pTxtFtn );
481 : : }
482 : :
483 [ # # ]: 0 : pTxtFtn->SetNumber( nNumber, &rNumStr );
484 [ # # ]: 0 : if( rFtn.IsEndNote() != bIsEndNote )
485 : : {
486 [ # # ]: 0 : ((SwFmtFtn&)rFtn).SetEndNote( bIsEndNote );
487 : 0 : bTypeChgd = sal_True;
488 [ # # ]: 0 : pTxtFtn->CheckCondColl();
489 : : }
490 : : }
491 : : }
492 : :
493 : : // Who needs to be triggered?
494 [ + - ]: 4 : if( bChg )
495 : : {
496 [ + - ]: 4 : if( pUndo )
497 : : {
498 [ + - ][ + - ]: 4 : GetIDocumentUndoRedo().AppendUndo(pUndo);
499 : : }
500 : :
501 [ - + ]: 4 : if ( bTypeChgd )
502 [ # # ]: 0 : rFtnArr.UpdateAllFtn();
503 [ + - ]: 4 : if( FTNNUM_PAGE != GetFtnInfo().eNum )
504 : : {
505 [ + - ]: 4 : if ( !bTypeChgd )
506 [ + - ]: 4 : rFtnArr.UpdateAllFtn();
507 : : }
508 [ # # ]: 0 : else if( pTmpRoot )
509 : : //
510 : : {
511 [ # # ]: 0 : std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
512 [ # # ][ # # ]: 0 : std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::UpdateFtnNums));
513 : : } //swmod 080304pTmpRoot->UpdateFtnNums(); //swmod 080219
514 [ + - ]: 4 : SetModified();
515 : : }
516 : : else
517 [ # # ][ # # ]: 0 : delete pUndo;
518 : 4 : return bChg;
519 : : }
520 : :
521 : :
522 : :
523 : :
524 : :
525 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|