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 <hintids.hxx>
30 : : #include <tools/bigint.hxx>
31 : : #include <svx/svdmodel.hxx>
32 : : #include <svx/svdpage.hxx>
33 : : #include <editeng/brshitem.hxx>
34 : : #include <editeng/keepitem.hxx>
35 : : #include <editeng/shaditem.hxx>
36 : : #include <editeng/ulspitem.hxx>
37 : : #include <editeng/lrspitem.hxx>
38 : : #include <editeng/boxitem.hxx>
39 : : #include <sfx2/printer.hxx>
40 : : #include <editeng/lspcitem.hxx>
41 : :
42 : : #include <fmtornt.hxx>
43 : : #include <fmtanchr.hxx>
44 : : #include <fmthdft.hxx>
45 : : #include <fmtcntnt.hxx>
46 : : #include <fmtfsize.hxx>
47 : : #include <fmtsrnd.hxx>
48 : : #include <docary.hxx>
49 : : #include <lineinfo.hxx>
50 : : #include <swmodule.hxx>
51 : : #include "pagefrm.hxx"
52 : : #include "colfrm.hxx"
53 : : #include "doc.hxx"
54 : : #include "fesh.hxx"
55 : : #include "viewimp.hxx"
56 : : #include "viewopt.hxx"
57 : : #include "pam.hxx"
58 : : #include "dflyobj.hxx"
59 : : #include "dcontact.hxx"
60 : : #include "frmtool.hxx"
61 : : #include "docsh.hxx"
62 : : #include "tabfrm.hxx"
63 : : #include "rowfrm.hxx"
64 : : #include "ftnfrm.hxx"
65 : : #include "txtfrm.hxx"
66 : : #include "notxtfrm.hxx"
67 : : #include "flyfrms.hxx"
68 : : #include "layact.hxx"
69 : : #include "pagedesc.hxx"
70 : : #include "section.hxx"
71 : : #include "sectfrm.hxx"
72 : : #include "node2lay.hxx"
73 : : #include "ndole.hxx"
74 : : #include "ndtxt.hxx"
75 : : #include "swtable.hxx"
76 : : #include "hints.hxx"
77 : : #include <layhelp.hxx>
78 : : #include <laycache.hxx>
79 : : #include <rootfrm.hxx>
80 : : #include "mdiexp.hxx"
81 : : #include "statstr.hrc"
82 : : #include <paratr.hxx>
83 : : #include <sortedobjs.hxx>
84 : : #include <objectformatter.hxx>
85 : : #include <switerator.hxx>
86 : :
87 : : // ftnfrm.cxx:
88 : : void lcl_RemoveFtns( SwFtnBossFrm* pBoss, sal_Bool bPageOnly, sal_Bool bEndNotes );
89 : :
90 : : using namespace ::com::sun::star;
91 : :
92 : :
93 : : sal_Bool bObjsDirect = sal_True;
94 : : sal_Bool bDontCreateObjects = sal_False;
95 : : sal_Bool bSetCompletePaintOnInvalidate = sal_False;
96 : :
97 : : sal_uInt8 StackHack::nCnt = 0;
98 : : sal_Bool StackHack::bLocked = sal_False;
99 : :
100 : :
101 : :
102 : : /*************************************************************************/
103 : :
104 : 40988 : SwFrmNotify::SwFrmNotify( SwFrm *pF ) :
105 : : pFrm( pF ),
106 : 40988 : aFrm( pF->Frm() ),
107 : 40988 : aPrt( pF->Prt() ),
108 : : bInvaKeep( sal_False ),
109 : 40988 : bValidSize( pF->GetValidSizeFlag() ),
110 : 81976 : mbFrmDeleted( false ) // #i49383#
111 : : {
112 [ + + ]: 40988 : if ( pF->IsTxtFrm() )
113 : : {
114 : 22553 : mnFlyAnchorOfst = ((SwTxtFrm*)pF)->GetBaseOfstForFly( sal_True );
115 : 22553 : mnFlyAnchorOfstNoWrap = ((SwTxtFrm*)pF)->GetBaseOfstForFly( sal_False );
116 : : }
117 : : else
118 : : {
119 : 18435 : mnFlyAnchorOfst = 0;
120 : 18435 : mnFlyAnchorOfstNoWrap = 0;
121 : : }
122 : :
123 : 40988 : bHadFollow = pF->IsCntntFrm() ?
124 : 23516 : (((SwCntntFrm*)pF)->GetFollow() ? sal_True : sal_False) :
125 [ + + + + ]: 64504 : sal_False;
126 : 40988 : }
127 : :
128 : : /*************************************************************************/
129 : :
130 : 40988 : SwFrmNotify::~SwFrmNotify()
131 : : {
132 : : // #i49383#
133 [ - + ]: 40988 : if ( mbFrmDeleted )
134 : : {
135 : 0 : return;
136 : : }
137 : :
138 [ + + ][ + - ]: 40988 : SWRECTFN( pFrm )
[ - + ][ - + ]
139 [ + - ][ + - ]: 40988 : const sal_Bool bAbsP = POS_DIFF( aFrm, pFrm->Frm() );
[ + + ][ + - ]
[ + - ][ + + ]
140 : : const sal_Bool bChgWidth =
141 [ + - ][ + - ]: 40988 : (aFrm.*fnRect->fnGetWidth)() != (pFrm->Frm().*fnRect->fnGetWidth)();
142 : : const sal_Bool bChgHeight =
143 [ + - ][ + - ]: 40988 : (aFrm.*fnRect->fnGetHeight)()!=(pFrm->Frm().*fnRect->fnGetHeight)();
144 : 40988 : const sal_Bool bChgFlyBasePos = pFrm->IsTxtFrm() &&
145 : 22553 : ( ( mnFlyAnchorOfst != ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( sal_True ) ) ||
146 [ - + ]: 63541 : ( mnFlyAnchorOfstNoWrap != ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( sal_False ) ) );
[ + + + - ]
147 : :
148 [ + + ][ + + ]: 40988 : if ( pFrm->IsFlowFrm() && !pFrm->IsInFtn() )
[ + + ]
149 : : {
150 : 24567 : SwFlowFrm *pFlow = SwFlowFrm::CastFlowFrm( pFrm );
151 : :
152 [ + + ]: 24567 : if ( !pFlow->IsFollow() )
153 : : {
154 [ + + ]: 22595 : if ( !pFrm->GetIndPrev() )
155 : : {
156 [ + + ]: 15715 : if ( bInvaKeep )
157 : : {
158 : 963 : SwFrm *pPre = pFrm->FindPrev();
159 [ + - ][ + + ]: 963 : if ( pPre && pPre->IsFlowFrm() )
[ + + ]
160 : : {
161 : : // 1. pPre wants to keep with me:
162 [ - + ][ # # ]: 57 : bool bInvalidPrePos = SwFlowFrm::CastFlowFrm( pPre )->IsKeep( *pPre->GetAttrSet() ) && pPre->GetIndPrev();
163 : :
164 : : // 2. pPre is a table and the last row wants to keep with me:
165 [ + - ][ - + ]: 57 : if ( !bInvalidPrePos && pPre->IsTabFrm() )
[ - + ]
166 : : {
167 : 0 : SwTabFrm* pPreTab = static_cast<SwTabFrm*>(pPre);
168 [ # # ]: 0 : if ( pPreTab->GetFmt()->GetDoc()->get(IDocumentSettingAccess::TABLE_ROW_KEEP) )
169 : : {
170 : 0 : SwRowFrm* pLastRow = static_cast<SwRowFrm*>(pPreTab->GetLastLower());
171 [ # # ][ # # ]: 0 : if ( pLastRow && pLastRow->ShouldRowKeepWithNext() )
[ # # ]
172 : 0 : bInvalidPrePos = true;
173 : : }
174 : : }
175 : :
176 [ - + ]: 57 : if ( bInvalidPrePos )
177 : 0 : pPre->InvalidatePos();
178 : : }
179 : : }
180 : : }
181 [ + + ]: 6880 : else if ( !pFlow->HasFollow() )
182 : : {
183 [ + - ]: 6284 : long nOldHeight = (aFrm.*fnRect->fnGetHeight)();
184 [ + - ]: 6284 : long nNewHeight = (pFrm->Frm().*fnRect->fnGetHeight)();
185 [ + + ][ + + ]: 6284 : if( (nOldHeight > nNewHeight) || (!nOldHeight && nNewHeight) )
[ + + ]
186 : 1302 : pFlow->CheckKeep();
187 : : }
188 : : }
189 : : }
190 : :
191 [ + + ]: 40988 : if ( bAbsP )
192 : : {
193 : 16924 : pFrm->SetCompletePaint();
194 : :
195 : 16924 : SwFrm* pNxt = pFrm->GetIndNext();
196 : : // #121888# - skip empty section frames
197 [ + + + + : 23492 : while ( pNxt &&
+ + ][ + + ]
198 : 6496 : pNxt->IsSctFrm() && !static_cast<SwSectionFrm*>(pNxt)->GetSection() )
199 : : {
200 : 72 : pNxt = pNxt->GetIndNext();
201 : : }
202 : :
203 [ + + ]: 16924 : if ( pNxt )
204 : 6224 : pNxt->InvalidatePos();
205 : : else
206 : : {
207 : : // #104100# - correct condition for setting retouche
208 : : // flag for vertical layout.
209 [ + + + + ]: 17056 : if( pFrm->IsRetoucheFrm() &&
[ + + ]
210 [ + - ][ + - ]: 6356 : (aFrm.*fnRect->fnTopDist)( (pFrm->Frm().*fnRect->fnGetTop)() ) > 0 )
211 : : {
212 : 1945 : pFrm->SetRetouche();
213 : : }
214 : :
215 : : // A fresh follow frame does not have to be invalidated, because
216 : : // it is already formatted:
217 [ + + ][ + + ]: 10700 : if ( bHadFollow || !pFrm->IsCntntFrm() || !((SwCntntFrm*)pFrm)->GetFollow() )
[ + + ][ + + ]
218 : : {
219 [ - + ][ # # ]: 10657 : if ( !pFrm->IsTabFrm() || !((SwTabFrm*)pFrm)->GetFollow() )
[ + - ]
220 : 10657 : pFrm->InvalidateNextPos();
221 : : }
222 : : }
223 : : }
224 : :
225 : : //Fuer Hintergrundgrafiken muss bei Groessenaenderungen ein Repaint her.
226 : : const sal_Bool bPrtWidth =
227 [ + - ][ + - ]: 40988 : (aPrt.*fnRect->fnGetWidth)() != (pFrm->Prt().*fnRect->fnGetWidth)();
228 : : const sal_Bool bPrtHeight =
229 [ + - ][ + - ]: 40988 : (aPrt.*fnRect->fnGetHeight)()!=(pFrm->Prt().*fnRect->fnGetHeight)();
230 [ + + ][ + + ]: 40988 : if ( bPrtWidth || bPrtHeight )
231 : : {
232 : 17146 : const SvxGraphicPosition ePos = pFrm->GetAttrSet()->GetBackground().GetGraphicPos();
233 [ + - ][ + + ]: 17146 : if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
234 : 17146 : pFrm->SetCompletePaint();
235 : : }
236 : : else
237 : : {
238 : : // #97597# - consider case that *only* margins between
239 : : // frame and printing area has changed. Then, frame has to be repainted,
240 : : // in order to force paint of the margin areas.
241 [ + + ][ + - ]: 23842 : if ( !bAbsP && (bChgWidth || bChgHeight) )
[ + + ]
242 : : {
243 : 18 : pFrm->SetCompletePaint();
244 : : }
245 : : }
246 : :
247 [ + - ][ + - ]: 40988 : const sal_Bool bPrtP = POS_DIFF( aPrt, pFrm->Prt() );
[ + + ][ + - ]
[ + - ][ + + ]
248 [ + + ][ + + ]: 40988 : if ( bAbsP || bPrtP || bChgWidth || bChgHeight ||
[ + + ][ + + ]
[ + + ][ + + ]
[ - + ]
249 : : bPrtWidth || bPrtHeight || bChgFlyBasePos )
250 : : {
251 [ + + ]: 22013 : if( pFrm->IsAccessibleFrm() )
252 : : {
253 : 17347 : SwRootFrm *pRootFrm = pFrm->getRootFrm();
254 [ + + + - ]: 17348 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
[ + + ][ + - ]
255 : 1 : pRootFrm->GetCurrShell() )
256 : : {
257 : 1 : pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( pFrm, aFrm );
258 : : }
259 : : }
260 : :
261 : : // Notification of anchored objects
262 [ + + ]: 22013 : if ( pFrm->GetDrawObjs() )
263 : : {
264 : 924 : const SwSortedObjs &rObjs = *pFrm->GetDrawObjs();
265 : 924 : SwPageFrm* pPageFrm = 0;
266 [ + + ]: 2144 : for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
267 : : {
268 : : // OD 2004-03-31 #i26791# - no general distinction between
269 : : // Writer fly frames and drawing objects
270 : 1220 : bool bNotify = false;
271 : 1220 : bool bNotifySize = false;
272 : 1220 : SwAnchoredObject* pObj = rObjs[i];
273 : 1220 : SwContact* pContact = ::GetUserCall( pObj->GetDrawObj() );
274 : : // #115759#
275 : 1220 : const bool bAnchoredAsChar = pContact->ObjAnchoredAsChar();
276 [ + + ]: 1220 : if ( !bAnchoredAsChar )
277 : : {
278 : : // Notify object, which aren't anchored as-character:
279 : :
280 : : // always notify objects, if frame position has changed
281 : : // or if the object is to-page|to-fly anchored.
282 [ + + + - : 182 : if ( bAbsP ||
- + ][ + + ]
283 : 19 : pContact->ObjAnchoredAtPage() ||
284 : 19 : pContact->ObjAnchoredAtFly() )
285 : : {
286 : 125 : bNotify = true;
287 : :
288 : : // assure that to-fly anchored Writer fly frames are
289 : : // registered at the correct page frame, if frame
290 : : // position has changed.
291 [ + - ]: 125 : if ( bAbsP && pContact->ObjAnchoredAtFly() &&
[ - + # # ]
[ - + ]
292 : 0 : pObj->ISA(SwFlyFrm) )
293 : : {
294 : : // determine to-fly anchored Writer fly frame
295 [ # # ]: 0 : SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
296 : : // determine page frame of to-fly anchored
297 : : // Writer fly frame
298 : 0 : SwPageFrm* pFlyPageFrm = pFlyFrm->FindPageFrm();
299 : : // determine page frame, if needed.
300 [ # # ]: 0 : if ( !pPageFrm )
301 : : {
302 : 0 : pPageFrm = pFrm->FindPageFrm();
303 : : }
304 [ # # ]: 0 : if ( pPageFrm != pFlyPageFrm )
305 : : {
306 : : OSL_ENSURE( pFlyPageFrm, "~SwFrmNotify: Fly from Nowhere" );
307 [ # # ]: 0 : if( pFlyPageFrm )
308 : 0 : pFlyPageFrm->MoveFly( pFlyFrm, pPageFrm );
309 : : else
310 : 0 : pPageFrm->AppendFlyToPage( pFlyFrm );
311 : : }
312 : : }
313 : : }
314 : : // otherwise the objects are notified in dependence to
315 : : // its positioning and alignment
316 : : else
317 : : {
318 : : const SwFmtVertOrient& rVert =
319 : 19 : pContact->GetFmt()->GetVertOrient();
320 [ - + ][ # # ]: 57 : if ( ( rVert.GetVertOrient() == text::VertOrientation::CENTER ||
[ + + ][ + -
+ - + + ]
321 : 19 : rVert.GetVertOrient() == text::VertOrientation::BOTTOM ||
322 : 19 : rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
323 : : ( bChgHeight || bPrtHeight ) )
324 : : {
325 : 2 : bNotify = true;
326 : : }
327 [ + + ]: 19 : if ( !bNotify )
328 : : {
329 : : const SwFmtHoriOrient& rHori =
330 : 17 : pContact->GetFmt()->GetHoriOrient();
331 [ + - ][ + - ]: 35 : if ( ( rHori.GetHoriOrient() != text::HoriOrientation::NONE ||
[ - + ][ - + ]
[ + + + -
+ - ]
332 : 9 : rHori.GetRelationOrient()== text::RelOrientation::PRINT_AREA ||
333 : 9 : rHori.GetRelationOrient()== text::RelOrientation::FRAME ) &&
334 : : ( bChgWidth || bPrtWidth || bChgFlyBasePos ) )
335 : : {
336 : 0 : bNotify = true;
337 : : }
338 : : }
339 : : }
340 : : }
341 [ + + ]: 1076 : else if ( bPrtWidth )
342 : : {
343 : : // Notify as-character anchored objects, if printing area
344 : : // width has changed.
345 : 468 : bNotify = true;
346 : 468 : bNotifySize = true;
347 : : }
348 : :
349 : : // perform notification via the corresponding invalidations
350 [ + + ]: 1220 : if ( bNotify )
351 : : {
352 [ + + ]: 595 : if ( pObj->ISA(SwFlyFrm) )
353 : : {
354 [ + - ]: 505 : SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
355 [ + + ]: 505 : if ( bNotifySize )
356 : 438 : pFlyFrm->_InvalidateSize();
357 : : // #115759# - no invalidation of
358 : : // position for as-character anchored objects.
359 [ + + ]: 505 : if ( !bAnchoredAsChar )
360 : : {
361 : 67 : pFlyFrm->_InvalidatePos();
362 : : }
363 : 505 : pFlyFrm->_Invalidate();
364 : : }
365 [ + - ]: 90 : else if ( pObj->ISA(SwAnchoredDrawObject) )
366 : : {
367 : : // #115759# - no invalidation of
368 : : // position for as-character anchored objects.
369 [ + + ]: 90 : if ( !bAnchoredAsChar )
370 : : {
371 : 60 : pObj->InvalidateObjPos();
372 : : }
373 : : }
374 : : else
375 : : {
376 : : OSL_FAIL( "<SwCntntNotify::~SwCntntNotify()> - unknown anchored object type. Please inform OD." );
377 : : }
378 : : }
379 : : }
380 : 22013 : }
381 : : }
382 [ + + ][ + + ]: 18975 : else if( pFrm->IsTxtFrm() && bValidSize != pFrm->GetValidSizeFlag() )
[ + + ]
383 : : {
384 : 11651 : SwRootFrm *pRootFrm = pFrm->getRootFrm();
385 [ - + # # ]: 11651 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
[ - + ][ + - ]
386 : 0 : pRootFrm->GetCurrShell() )
387 : : {
388 : 0 : pRootFrm->GetCurrShell()->Imp()->InvalidateAccessibleFrmContent( pFrm );
389 : : }
390 : : }
391 : :
392 : : // #i9046# Automatic frame width
393 : 40988 : SwFlyFrm* pFly = 0;
394 : : // #i35879# Do not trust the inf flags. pFrm does not
395 : : // necessarily have to have an upper!
396 [ + + ][ + + ]: 40988 : if ( !pFrm->IsFlyFrm() && 0 != ( pFly = pFrm->ImplFindFlyFrm() ) )
[ + + ]
397 : : {
398 : : // #i61999#
399 : : // no invalidation of columned Writer fly frames, because automatic
400 : : // width doesn't make sense for such Writer fly frames.
401 [ + - ][ + - ]: 1746 : if ( pFly->Lower() && !pFly->Lower()->IsColumnFrm() )
[ + - ]
402 : : {
403 : 1746 : const SwFmtFrmSize &rFrmSz = pFly->GetFmt()->GetFrmSize();
404 : :
405 : : // This could be optimized. Basically the fly frame only has to
406 : : // be invalidated, if the first line of pFrm (if pFrm is a content
407 : : // frame, for other frame types its the print area) has changed its
408 : : // size and pFrm was responsible for the current width of pFly. On
409 : : // the other hand, this is only rarely used and re-calculation of
410 : : // the fly frame does not cause too much trouble. So we keep it this
411 : : // way:
412 [ - + ]: 1746 : if ( ATT_FIX_SIZE != rFrmSz.GetWidthSizeType() )
413 : : {
414 : : // #i50668#, #i50998# - invalidation of position
415 : : // of as-character anchored fly frames not needed and can cause
416 : : // layout loops
417 [ # # ]: 0 : if ( !pFly->ISA(SwFlyInCntFrm) )
418 : : {
419 : 0 : pFly->InvalidatePos();
420 : : }
421 : 0 : pFly->InvalidateSize();
422 : : }
423 : : }
424 : : }
425 : 40988 : }
426 : :
427 : : /*************************************************************************/
428 : :
429 : 17472 : SwLayNotify::SwLayNotify( SwLayoutFrm *pLayFrm ) :
430 : : SwFrmNotify( pLayFrm ),
431 : 17472 : bLowersComplete( sal_False )
432 : : {
433 : 17472 : }
434 : :
435 : : /*************************************************************************/
436 : :
437 : : // OD 2004-05-11 #i28701# - local method to invalidate the position of all
438 : : // frames inclusive its floating screen objects, which are lowers of the given
439 : : // layout frame
440 : 166 : void lcl_InvalidatePosOfLowers( SwLayoutFrm& _rLayoutFrm )
441 : : {
442 [ - + ][ # # ]: 166 : if( _rLayoutFrm.IsFlyFrm() && _rLayoutFrm.GetDrawObjs() )
[ - + ]
443 : : {
444 : 0 : _rLayoutFrm.InvalidateObjs( true, false );
445 : : }
446 : :
447 : 166 : SwFrm* pLowerFrm = _rLayoutFrm.Lower();
448 [ + + ]: 362 : while ( pLowerFrm )
449 : : {
450 : 196 : pLowerFrm->InvalidatePos();
451 [ + + ]: 196 : if ( pLowerFrm->IsTxtFrm() )
452 : : {
453 : 186 : static_cast<SwTxtFrm*>(pLowerFrm)->Prepare( PREP_POS_CHGD );
454 : : }
455 [ - + ]: 10 : else if ( pLowerFrm->IsTabFrm() )
456 : : {
457 : 0 : pLowerFrm->InvalidatePrt();
458 : : }
459 : :
460 : 196 : pLowerFrm->InvalidateObjs( true, false );
461 : :
462 : 196 : pLowerFrm = pLowerFrm->GetNext();
463 : : };
464 : 166 : }
465 : :
466 : 17472 : SwLayNotify::~SwLayNotify()
467 : : {
468 : : // #i49383#
469 [ - + ]: 17472 : if ( mbFrmDeleted )
470 : : {
471 : : return;
472 : : }
473 : :
474 : 17472 : SwLayoutFrm *pLay = GetLay();
475 [ + + ][ + - ]: 17472 : SWRECTFN( pLay )
[ - + ][ - + ]
[ + - ]
476 : 17472 : sal_Bool bNotify = sal_False;
477 [ + + ]: 17472 : if ( pLay->Prt().SSize() != aPrt.SSize() )
478 : : {
479 [ + + ]: 8765 : if ( !IsLowersComplete() )
480 : : {
481 : : sal_Bool bInvaPercent;
482 : :
483 [ + + ]: 8757 : if ( pLay->IsRowFrm() )
484 : : {
485 : 555 : bInvaPercent = sal_True;
486 [ + - ][ + - ]: 555 : long nNew = (pLay->Prt().*fnRect->fnGetHeight)();
487 [ + - ][ + - ]: 555 : if( nNew != (aPrt.*fnRect->fnGetHeight)() )
[ + + ]
488 [ + - ]: 491 : ((SwRowFrm*)pLay)->AdjustCells( nNew, sal_True);
489 [ + - ][ + - ]: 1110 : if( (pLay->Prt().*fnRect->fnGetWidth)()
[ + + ]
490 [ + - ][ + - ]: 555 : != (aPrt.*fnRect->fnGetWidth)() )
491 [ + - ]: 541 : ((SwRowFrm*)pLay)->AdjustCells( 0, sal_False );
492 : : }
493 : : else
494 : : {
495 : : //Proportionale Anpassung der innenliegenden.
496 : : //1. Wenn der Formatierte kein Fly ist
497 : : //2. Wenn er keine Spalten enthaelt
498 : : //3. Wenn der Fly eine feste Hoehe hat und die Spalten in der
499 : : // Hoehe danebenliegen.
500 : : //4. niemals bei SectionFrms.
501 : : sal_Bool bLow;
502 [ + + ]: 8202 : if( pLay->IsFlyFrm() )
503 : : {
504 [ + - ]: 827 : if ( pLay->Lower() )
505 : : {
506 : 827 : bLow = !pLay->Lower()->IsColumnFrm() ||
507 [ # # ][ # # ]: 0 : (pLay->Lower()->Frm().*fnRect->fnGetHeight)()
508 [ # # ][ # # ]: 827 : != (pLay->Prt().*fnRect->fnGetHeight)();
[ # # ][ - + ]
509 : : }
510 : : else
511 : 0 : bLow = sal_False;
512 : : }
513 [ + + ]: 7375 : else if( pLay->IsSctFrm() )
514 : : {
515 [ + - ]: 71 : if ( pLay->Lower() )
516 : : {
517 [ + + ][ + + ]: 71 : if( pLay->Lower()->IsColumnFrm() && pLay->Lower()->GetNext() )
[ + + ]
518 : 6 : bLow = pLay->Lower()->Frm().Height() != pLay->Prt().Height();
519 : : else
520 : 65 : bLow = pLay->Prt().Width() != aPrt.Width();
521 : : }
522 : : else
523 : 0 : bLow = sal_False;
524 : : }
525 [ + + ][ + + ]: 7304 : else if( pLay->IsFooterFrm() && !pLay->HasFixSize() )
[ + + ]
526 : 26 : bLow = pLay->Prt().Width() != aPrt.Width();
527 : : else
528 : 7278 : bLow = sal_True;
529 : 8202 : bInvaPercent = bLow;
530 [ + + ]: 8202 : if ( bLow )
531 : : {
532 [ + - ]: 8151 : pLay->ChgLowersProp( aPrt.SSize() );
533 : : }
534 : : //Wenn die PrtArea gewachsen ist, so ist es moeglich, dass die
535 : : //Kette der Untergeordneten einen weiteren Frm aufnehmen kann,
536 : : //mithin muss also der 'moeglicherweise passende' Invalidiert werden.
537 : : //Das invalidieren lohnt nur, wenn es sich beim mir bzw. meinen
538 : : //Uppers um eine Moveable-Section handelt.
539 : : //Die PrtArea ist gewachsen, wenn die Breite oder die Hoehe groesser
540 : : //geworden ist.
541 [ + + + + ]: 24871 : if ( (pLay->Prt().Height() > aPrt.Height() ||
[ + + + + ]
[ + + ]
542 : 2375 : pLay->Prt().Width() > aPrt.Width()) &&
543 [ + - ]: 14294 : (pLay->IsMoveable() || pLay->IsFlyFrm()) )
544 : : {
545 : 1009 : SwFrm *pTmpFrm = pLay->Lower();
546 [ + + ][ + + ]: 1009 : if ( pTmpFrm && pTmpFrm->IsFlowFrm() )
[ + - ]
547 : : {
548 [ + + ]: 910 : while ( pTmpFrm->GetNext() )
549 : 76 : pTmpFrm = pTmpFrm->GetNext();
550 [ + - ]: 834 : pTmpFrm->InvalidateNextPos();
551 : : }
552 : : }
553 : : }
554 : 8757 : bNotify = sal_True;
555 : : //TEUER!! aber wie macht man es geschickter?
556 [ + + ]: 8757 : if( bInvaPercent )
557 [ + - ]: 8706 : pLay->InvaPercentLowers( pLay->Prt().Height() - aPrt.Height() );
558 : : }
559 [ + + ]: 8765 : if ( pLay->IsTabFrm() )
560 : : //Damit _nur_ der Shatten bei Groessenaenderungen gemalt wird.
561 : 197 : ((SwTabFrm*)pLay)->SetComplete();
562 : : else
563 : : {
564 : 8568 : const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
565 [ + + - + ]: 8640 : if( !( pSh && pSh->GetViewOptions()->getBrowseMode() ) ||
[ + + ][ + - ]
566 : 72 : !(pLay->GetType() & (FRM_BODY | FRM_PAGE)) )
567 : : //Damit die untergeordneten sauber retouchiert werden.
568 : : //Problembsp: Flys an den Henkeln packen und verkleinern.
569 : : //Nicht fuer Body und Page, sonst flackerts beim HTML-Laden.
570 : 8496 : pLay->SetCompletePaint();
571 : : }
572 : : }
573 : : //Lower benachrichtigen wenn sich die Position veraendert hat.
574 [ + - ][ + - ]: 17472 : const sal_Bool bPrtPos = POS_DIFF( aPrt, pLay->Prt() );
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + + ]
575 [ + + ][ + - ]: 17472 : const sal_Bool bPos = bPrtPos || POS_DIFF( aFrm, pLay->Frm() );
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
576 : 17472 : const sal_Bool bSize = pLay->Frm().SSize() != aFrm.SSize();
577 : :
578 [ + + ][ + - ]: 17472 : if ( bPos && pLay->Lower() && !IsLowersComplete() )
[ + + ][ + + ]
579 [ + - ]: 6585 : pLay->Lower()->InvalidatePos();
580 : :
581 [ + + ]: 17472 : if ( bPrtPos )
582 : 3752 : pLay->SetCompletePaint();
583 : :
584 : : //Nachfolger benachrichtigen wenn sich die SSize geaendert hat.
585 [ + + ]: 17472 : if ( bSize )
586 : : {
587 [ + + ]: 3850 : if( pLay->GetNext() )
588 : : {
589 [ + + ]: 2139 : if ( pLay->GetNext()->IsLayoutFrm() )
590 [ + - ]: 1896 : pLay->GetNext()->_InvalidatePos();
591 : : else
592 [ + - ]: 243 : pLay->GetNext()->InvalidatePos();
593 : : }
594 [ + + ]: 1711 : else if( pLay->IsSctFrm() )
595 [ + - ]: 25 : pLay->InvalidateNextPos();
596 : : }
597 [ + + + + ]: 49030 : if ( !IsLowersComplete() &&
[ + + ]
[ + + + + ]
[ + + ]
598 : 17464 : !(pLay->GetType()&(FRM_FLY|FRM_SECTION) &&
599 [ + + ][ + + ]: 3254 : pLay->Lower() && pLay->Lower()->IsColumnFrm()) &&
600 : 10840 : (bPos || bNotify) && !(pLay->GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
601 : : {
602 : : // #i44016# - force unlock of position of lower objects.
603 : : // #i43913# - no unlock of position of objects,
604 : : // if <pLay> is a cell frame, and its table frame resp. its parent table
605 : : // frame is locked.
606 : : // #i47458# - force unlock of position of lower objects,
607 : : // only if position of layout frame has changed.
608 : 8065 : bool bUnlockPosOfObjs( bPos );
609 [ + + ][ + + ]: 8065 : if ( bUnlockPosOfObjs && pLay->IsCellFrm() )
[ + + ]
610 : : {
611 [ + - ]: 3340 : SwTabFrm* pTabFrm( pLay->FindTabFrm() );
612 [ + - + + : 8386 : if ( pTabFrm &&
- + # # ]
[ + + ]
613 : 3340 : ( pTabFrm->IsJoinLocked() ||
614 : 1706 : ( pTabFrm->IsFollow() &&
615 [ # # ]: 0 : pTabFrm->FindMaster()->IsJoinLocked() ) ) )
616 : : {
617 : 1634 : bUnlockPosOfObjs = false;
618 : : }
619 : : }
620 : : // #i49383# - check for footnote frame, if unlock
621 : : // of position of lower objects is allowed.
622 [ + + ][ + + ]: 4725 : else if ( bUnlockPosOfObjs && pLay->IsFtnFrm() )
[ + + ]
623 : : {
624 : 166 : bUnlockPosOfObjs = static_cast<SwFtnFrm*>(pLay)->IsUnlockPosOfLowerObjs();
625 : : }
626 : : // #i51303# - no unlock of object positions for sections
627 [ + + ][ + + ]: 4559 : else if ( bUnlockPosOfObjs && pLay->IsSctFrm() )
[ + + ]
628 : : {
629 : 161 : bUnlockPosOfObjs = false;
630 : : }
631 [ + - ]: 8065 : pLay->NotifyLowerObjs( bUnlockPosOfObjs );
632 : : }
633 [ + + ][ + + ]: 17472 : if ( bPos && pLay->IsFtnFrm() && pLay->Lower() )
[ + - ][ + + ]
634 : : {
635 : : // OD 2004-05-11 #i28701#
636 [ + - ]: 166 : ::lcl_InvalidatePosOfLowers( *pLay );
637 : : }
638 [ + + ][ + + ]: 19046 : if( ( bPos || bSize ) && pLay->IsFlyFrm() && ((SwFlyFrm*)pLay)->GetAnchorFrm()
[ + + ][ + - ]
[ + - - + ]
[ - + ]
639 [ + - ]: 1574 : && ((SwFlyFrm*)pLay)->GetAnchorFrm()->IsFlyFrm() )
640 [ # # ][ # # ]: 17472 : ((SwFlyFrm*)pLay)->AnchorFrm()->InvalidateSize();
641 : 17472 : }
642 : :
643 : : /*************************************************************************/
644 : :
645 : 3002 : SwFlyNotify::SwFlyNotify( SwFlyFrm *pFlyFrm ) :
646 : : SwLayNotify( pFlyFrm ),
647 : : // #115759# - keep correct page frame - the page frame
648 : : // the Writer fly frame is currently registered at.
649 [ + - ]: 3002 : pOldPage( pFlyFrm->GetPageFrm() ),
650 [ + - ]: 6004 : aFrmAndSpace( pFlyFrm->GetObjRectWithSpaces() )
651 : : {
652 : 3002 : }
653 : :
654 : : /*************************************************************************/
655 : :
656 : 3002 : SwFlyNotify::~SwFlyNotify()
657 : : {
658 : : // #i49383#
659 [ - + ]: 3002 : if ( mbFrmDeleted )
660 : : {
661 : : return;
662 : : }
663 : :
664 : 3002 : SwFlyFrm *pFly = GetFly();
665 [ + + ]: 3002 : if ( pFly->IsNotifyBack() )
666 : : {
667 : 1314 : ViewShell *pSh = pFly->getRootFrm()->GetCurrShell();
668 [ + - ]: 1314 : SwViewImp *pImp = pSh ? pSh->Imp() : 0;
669 [ + - ][ + + ]: 1314 : if ( !pImp || !pImp->IsAction() || !pImp->GetLayAction().IsAgain() )
[ + - ][ + - ]
670 : : {
671 : : //Wenn in der LayAction das IsAgain gesetzt ist kann es sein,
672 : : //dass die alte Seite inzwischen vernichtet wurde!
673 [ + - ]: 1314 : ::Notify( pFly, pOldPage, aFrmAndSpace, &aPrt );
674 : : // #i35640# - additional notify anchor text frame,
675 : : // if Writer fly frame has changed its page
676 [ + - ][ + + ]: 2492 : if ( pFly->GetAnchorFrm()->IsTxtFrm() &&
[ - + ][ - + ]
677 [ + - ]: 1178 : pFly->GetPageFrm() != pOldPage )
678 : : {
679 [ # # ][ # # ]: 0 : pFly->AnchorFrm()->Prepare( PREP_FLY_LEAVE );
680 : : }
681 : : }
682 : 1314 : pFly->ResetNotifyBack();
683 : : }
684 : :
685 : : //Haben sich Groesse oder Position geaendert, so sollte die View
686 : : //das wissen.
687 [ + - ][ - + ]: 3002 : SWRECTFN( pFly )
[ # # ][ # # ]
[ - + ]
688 [ + - ][ + - ]: 3002 : const bool bPosChgd = POS_DIFF( aFrm, pFly->Frm() );
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + + ]
689 : 3002 : const bool bFrmChgd = pFly->Frm().SSize() != aFrm.SSize();
690 : 3002 : const bool bPrtChgd = aPrt != pFly->Prt();
691 [ + + ][ + + ]: 3002 : if ( bPosChgd || bFrmChgd || bPrtChgd )
[ + + ]
692 : : {
693 [ + - ]: 1580 : pFly->NotifyDrawObj();
694 : : }
695 [ + + ][ + + ]: 3002 : if ( bPosChgd && aFrm.Pos().X() != FAR_AWAY )
[ + + ]
696 : : {
697 : : // OD 2004-05-10 #i28701# - no direct move of lower Writer fly frames.
698 : : // reason: New positioning and alignment (e.g. to-paragraph anchored,
699 : : // but aligned at page) are introduced.
700 : : // <SwLayNotify::~SwLayNotify()> takes care of invalidation of lower
701 : : // floating screen objects by calling method <SwLayoutFrm::NotifyLowerObjs()>.
702 : :
703 [ + + ]: 763 : if ( pFly->IsFlyAtCntFrm() )
704 : : {
705 [ + - ][ + - ]: 22 : SwFrm *pNxt = pFly->AnchorFrm()->FindNext();
706 [ + + ]: 22 : if ( pNxt )
707 : : {
708 [ + - ]: 12 : pNxt->InvalidatePos();
709 : : }
710 : : }
711 : :
712 : : // #i26945# - notify anchor.
713 : : // Needed for negative positioned Writer fly frames
714 [ + - ][ + + ]: 763 : if ( pFly->GetAnchorFrm()->IsTxtFrm() )
715 : : {
716 [ + - ][ + - ]: 759 : pFly->AnchorFrm()->Prepare( PREP_FLY_LEAVE );
717 : : }
718 : : }
719 : :
720 : : // OD 2004-05-13 #i28701#
721 : : // #i45180# - no adjustment of layout process flags and
722 : : // further notifications/invalidations, if format is called by grow/shrink
723 [ + - ][ + + ]: 3050 : if ( pFly->ConsiderObjWrapInfluenceOnObjPos() &&
[ + - + - ]
[ + + ]
724 [ + - ][ + - ]: 24 : ( !pFly->ISA(SwFlyFreeFrm) ||
725 : 24 : !static_cast<SwFlyFreeFrm*>(pFly)->IsNoMoveOnCheckClip() ) )
726 : : {
727 : : // #i54138# - suppress restart of the layout process
728 : : // on changed frame height.
729 : : // Note: It doesn't seem to be necessary and can cause layout loops.
730 [ + + ]: 24 : if ( bPosChgd )
731 : : {
732 : : // indicate a restart of the layout process
733 [ + - ]: 6 : pFly->SetRestartLayoutProcess( true );
734 : : }
735 : : else
736 : : {
737 : : // lock position
738 : 18 : pFly->LockPosition();
739 : :
740 [ + - ][ + - ]: 18 : if ( !pFly->ConsiderForTextWrap() )
741 : : {
742 : : // indicate that object has to be considered for text wrap
743 [ + - ]: 18 : pFly->SetConsiderForTextWrap( true );
744 : : // invalidate 'background' in order to allow its 'background'
745 : : // to wrap around it.
746 : : pFly->NotifyBackground( pFly->GetPageFrm(),
747 [ + - ]: 18 : pFly->GetObjRectWithSpaces(),
748 [ + - ][ + - ]: 18 : PREP_FLY_ARRIVE );
749 : : // invalidate position of anchor frame in order to force
750 : : // a re-format of the anchor frame, which also causes a
751 : : // re-format of the invalid previous frames of the anchor frame.
752 [ + - ][ + - ]: 3002 : pFly->AnchorFrm()->InvalidatePos();
753 : : }
754 : : }
755 : : }
756 : 3002 : }
757 : :
758 : : /*************************************************************************/
759 : :
760 : 23516 : SwCntntNotify::SwCntntNotify( SwCntntFrm *pCntntFrm ) :
761 : : SwFrmNotify( pCntntFrm ),
762 : : // OD 08.01.2004 #i11859#
763 : : mbChkHeightOfLastLine( false ),
764 : : mnHeightOfLastLine( 0L ),
765 : : // OD 2004-02-26 #i25029#
766 : : mbInvalidatePrevPrtArea( false ),
767 : 23516 : mbBordersJoinedWithPrev( false )
768 : : {
769 : : // OD 08.01.2004 #i11859#
770 [ + + ]: 23516 : if ( pCntntFrm->IsTxtFrm() )
771 : : {
772 : 22553 : SwTxtFrm* pTxtFrm = static_cast<SwTxtFrm*>(pCntntFrm);
773 [ + - ][ + - ]: 22553 : if ( !pTxtFrm->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::OLD_LINE_SPACING) )
[ + + ]
774 : : {
775 [ + - ]: 22551 : const SwAttrSet* pSet = pTxtFrm->GetAttrSet();
776 [ + - ]: 22551 : const SvxLineSpacingItem &rSpace = pSet->GetLineSpacing();
777 [ + + ]: 22551 : if ( rSpace.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP )
778 : : {
779 : 399 : mbChkHeightOfLastLine = true;
780 : 399 : mnHeightOfLastLine = pTxtFrm->GetHeightOfLastLine();
781 : : }
782 : : }
783 : : }
784 : 23516 : }
785 : :
786 : : /*************************************************************************/
787 : :
788 : 23516 : SwCntntNotify::~SwCntntNotify()
789 : : {
790 : : // #i49383#
791 [ - + ]: 23516 : if ( mbFrmDeleted )
792 : : {
793 : : return;
794 : : }
795 : :
796 : 23516 : SwCntntFrm *pCnt = GetCnt();
797 [ + + ]: 23516 : if ( bSetCompletePaintOnInvalidate )
798 : 131 : pCnt->SetCompletePaint();
799 : :
800 [ + - ][ + + ]: 23516 : SWRECTFN( pCnt )
[ + - ][ - + ]
[ - + ]
801 [ + - ][ + + ]: 27105 : if ( pCnt->IsInTab() && ( POS_DIFF( pCnt->Frm(), aFrm ) ||
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ]
[ + + + + ]
[ + + ]
802 : 3589 : pCnt->Frm().SSize() != aFrm.SSize()))
803 : : {
804 : 2568 : SwLayoutFrm* pCell = pCnt->GetUpper();
805 [ + + ][ + - ]: 2572 : while( !pCell->IsCellFrm() && pCell->GetUpper() )
[ + + ]
806 : 4 : pCell = pCell->GetUpper();
807 : : OSL_ENSURE( pCell->IsCellFrm(), "Where's my cell?" );
808 [ + - ][ + - ]: 2568 : if ( text::VertOrientation::NONE != pCell->GetFmt()->GetVertOrient().GetVertOrient() )
[ + + ]
809 [ + - ]: 184 : pCell->InvalidatePrt(); //fuer vertikale Ausrichtung.
810 : : }
811 : :
812 : : // OD 2004-02-26 #i25029#
813 [ + + ][ + + : 23609 : if ( mbInvalidatePrevPrtArea && mbBordersJoinedWithPrev &&
+ - + - ]
[ + - ][ + + ]
814 : 31 : pCnt->IsTxtFrm() &&
815 [ + - ]: 62 : !pCnt->IsFollow() && !pCnt->GetIndPrev() )
816 : : {
817 : : // determine previous frame
818 [ + - ]: 31 : SwFrm* pPrevFrm = pCnt->FindPrev();
819 : : // skip empty section frames and hidden text frames
820 : : {
821 [ + - - + : 124 : while ( pPrevFrm &&
# # + - ]
[ - + ][ - + ]
822 : 31 : ( ( pPrevFrm->IsSctFrm() &&
823 : 0 : !static_cast<SwSectionFrm*>(pPrevFrm)->GetSection() ) ||
824 : 31 : ( pPrevFrm->IsTxtFrm() &&
825 [ + - ]: 31 : static_cast<SwTxtFrm*>(pPrevFrm)->IsHiddenNow() ) ) )
826 : : {
827 [ # # ]: 0 : pPrevFrm = pPrevFrm->FindPrev();
828 : : }
829 : : }
830 : :
831 : : // Invalidate printing area of found previous frame
832 [ + - ]: 31 : if ( pPrevFrm )
833 : : {
834 [ - + ]: 31 : if ( pPrevFrm->IsSctFrm() )
835 : : {
836 [ # # ][ # # ]: 0 : if ( pCnt->IsInSct() )
837 : : {
838 : : // Note: found previous frame is a section frame and
839 : : // <pCnt> is also inside a section.
840 : : // Thus due to <mbBordersJoinedWithPrev>,
841 : : // <pCnt> had joined its borders/shadow with the
842 : : // last content of the found section.
843 : : // Invalidate printing area of last content in found section.
844 : : SwFrm* pLstCntntOfSctFrm =
845 [ # # ]: 0 : static_cast<SwSectionFrm*>(pPrevFrm)->FindLastCntnt();
846 [ # # ]: 0 : if ( pLstCntntOfSctFrm )
847 : : {
848 [ # # ]: 0 : pLstCntntOfSctFrm->InvalidatePrt();
849 : : }
850 : : }
851 : : }
852 : : else
853 : : {
854 [ + - ]: 31 : pPrevFrm->InvalidatePrt();
855 : : }
856 : : }
857 : : }
858 : :
859 [ + - ][ + - ]: 23516 : sal_Bool bFirst = (aFrm.*fnRect->fnGetWidth)() == 0;
860 : :
861 [ + + ]: 23516 : if ( pCnt->IsNoTxtFrm() )
862 : : {
863 : : //Aktive PlugIn's oder OLE-Objekte sollten etwas von der Veraenderung
864 : : //mitbekommen, damit sie Ihr Window entsprechend verschieben.
865 : 963 : ViewShell *pSh = pCnt->getRootFrm()->GetCurrShell();
866 [ + - ]: 963 : if ( pSh )
867 : : {
868 : : SwOLENode *pNd;
869 [ + + ]: 1828 : if ( 0 != (pNd = pCnt->GetNode()->GetOLENode()) &&
[ - + # # ]
[ + + ]
870 [ + - ]: 865 : (pNd->GetOLEObj().IsOleRef() ||
871 : 0 : pNd->IsOLESizeInvalid()) )
872 : : {
873 : : const bool bNoTxtFrmPrtAreaChanged =
874 : 865 : ( aPrt.SSize().Width() != 0 &&
875 : 429 : aPrt.SSize().Height() != 0 ) &&
876 [ + + ]: 1294 : aPrt.SSize() != pCnt->Prt().SSize();
[ + + + - ]
877 : : OSL_ENSURE( pCnt->IsInFly(), "OLE not in FlyFrm" );
878 [ + - ]: 865 : SwFlyFrm *pFly = pCnt->FindFlyFrm();
879 [ + - ]: 865 : svt::EmbeddedObjectRef& xObj = pNd->GetOLEObj().GetObject();
880 : 865 : SwFEShell *pFESh = 0;
881 : 865 : ViewShell *pTmp = pSh;
882 [ - + ]: 865 : do
883 [ + - ][ + - ]: 865 : { if ( pTmp->ISA( SwCrsrShell ) )
[ + - ]
884 : : {
885 : 865 : pFESh = (SwFEShell*)pTmp;
886 : : // #108369#: Here used to be the condition if (!bFirst).
887 : : // I think this should mean "do not call CalcAndSetScale"
888 : : // if the frame is formatted for the first time.
889 : : // Unfortunately this is not valid anymore since the
890 : : // SwNoTxtFrm already gets a width during CalcLowerPreps.
891 : : // Nevertheless, the indention of !bFirst seemed to be
892 : : // to assure that the OLE objects have already been notified
893 : : // if necessary before calling CalcAndSetScale.
894 : : // So I replaced !bFirst by !IsOLESizeInvalid. There is
895 : : // one additional problem specific to the word import:
896 : : // The layout is calculated _before_ calling PrtOLENotify,
897 : : // and the OLE objects are not invalidated during import.
898 : : // Therefore I added the condition !IsUpdateExpFld,
899 : : // have a look at the occurrence of CalcLayout in
900 : : // uiview/view.cxx.
901 [ + - ][ + - ]: 1730 : if ( !pNd->IsOLESizeInvalid() &&
[ + - ]
902 [ + - ]: 865 : !pSh->GetDoc()->IsUpdateExpFld() )
903 : : pFESh->CalcAndSetScale( xObj,
904 : 865 : &pFly->Prt(), &pFly->Frm(),
905 [ + - ]: 865 : bNoTxtFrmPrtAreaChanged );
906 : : }
907 : 865 : pTmp = (ViewShell*)pTmp->GetNext();
908 : : } while ( pTmp != pSh );
909 : :
910 [ + - ][ - + ]: 865 : if ( pFESh && pNd->IsOLESizeInvalid() )
[ - + ]
911 : : {
912 : 0 : pNd->SetOLESizeInvalid( sal_False );
913 : : //TODO/LATER: needs OnDocumentPrinterChanged
914 : : //xObj->OnDocumentPrinterChanged( pNd->GetDoc()->getPrinter( false ) );
915 [ # # ]: 0 : pFESh->CalcAndSetScale( xObj );//Client erzeugen lassen.
916 : : }
917 : : }
918 : : //dito Animierte Grafiken
919 [ + - ][ + + ]: 963 : if ( Frm().HasArea() && ((SwNoTxtFrm*)pCnt)->HasAnimation() )
[ + - ][ - + ]
[ - + ]
920 : : {
921 [ # # ]: 0 : ((SwNoTxtFrm*)pCnt)->StopAnimation();
922 [ # # ]: 0 : pSh->InvalidateWindows( Frm() );
923 : : }
924 : : }
925 : : }
926 : :
927 [ + + ]: 23516 : if ( bFirst )
928 : : {
929 : 5098 : pCnt->SetRetouche(); //fix(13870)
930 : :
931 : 5098 : SwDoc *pDoc = pCnt->GetNode()->GetDoc();
932 [ + + ][ + - ]: 7023 : if ( !pDoc->GetSpzFrmFmts()->empty() &&
[ + + ][ + + ]
933 [ + - ][ + - ]: 1925 : !pDoc->IsLoaded() && !pDoc->IsNewDoc() )
934 : : {
935 : : //Der Frm wurde wahrscheinlich zum ersten mal formatiert.
936 : : //Wenn ein Filter Flys oder Zeichenobjekte einliest und diese
937 : : //Seitengebunden sind, hat er ein Problem, weil er i.d.R. die
938 : : //Seitennummer nicht kennt. Er weiss lediglich welches der Inhalt
939 : : //(CntntNode) an dieser Stelle ist.
940 : : //Die Filter stellen dazu das Ankerattribut der Objekte so ein, dass
941 : : //sie vom Typ zwar Seitengebunden sind, aber der Index des Ankers
942 : : //auf diesen CntntNode zeigt.
943 : : //Hier werden diese vorlauefigen Verbindungen aufgeloest.
944 : :
945 : 935 : const SwPageFrm *pPage = 0;
946 : 935 : SwNodeIndex *pIdx = 0;
947 : 935 : SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
948 : :
949 [ + + ]: 3641 : for ( sal_uInt16 i = 0; i < pTbl->size(); ++i )
950 : : {
951 [ + + ]: 2706 : if ( !pPage )
952 [ + - ]: 935 : pPage = pCnt->FindPageFrm();
953 : 2706 : SwFrmFmt *pFmt = (*pTbl)[i];
954 [ + - ]: 2706 : const SwFmtAnchor &rAnch = pFmt->GetAnchor();
955 : :
956 [ + + + + ]: 4954 : if ((FLY_AT_PAGE != rAnch.GetAnchorId()) &&
[ + + ]
957 : 2248 : (FLY_AT_PARA != rAnch.GetAnchorId()))
958 : : {
959 : 2024 : continue; //#60878# nicht etwa zeichengebundene.
960 : : }
961 : :
962 [ + - ][ + + ]: 682 : if ( rAnch.GetCntntAnchor() )
963 : : {
964 [ + + ]: 224 : if ( !pIdx )
965 : : {
966 [ + - ][ + - ]: 143 : pIdx = new SwNodeIndex( *pCnt->GetNode() );
967 : : }
968 [ + - ][ + + ]: 224 : if ( rAnch.GetCntntAnchor()->nNode == *pIdx )
969 : : {
970 [ - + ]: 72 : if (FLY_AT_PAGE == rAnch.GetAnchorId())
971 : : {
972 : : OSL_FAIL( "<SwCntntNotify::~SwCntntNotify()> - to page anchored object with content position. Please inform OD." );
973 [ # # ]: 0 : SwFmtAnchor aAnch( rAnch );
974 [ # # ]: 0 : aAnch.SetAnchor( 0 );
975 : 0 : aAnch.SetPageNum( pPage->GetPhyPageNum() );
976 [ # # ]: 0 : pFmt->SetFmtAttr( aAnch );
977 [ # # ]: 0 : if ( RES_DRAWFRMFMT != pFmt->Which() )
978 [ # # ][ # # ]: 0 : pFmt->MakeFrms();
979 : : }
980 : : }
981 : : }
982 : : }
983 [ + + ][ + - ]: 935 : delete pIdx;
984 : : }
985 : : }
986 : :
987 : : // OD 12.01.2004 #i11859# - invalidate printing area of following frame,
988 : : // if height of last line has changed.
989 [ + + ][ + + ]: 23516 : if ( pCnt->IsTxtFrm() && mbChkHeightOfLastLine )
[ + + ]
990 : : {
991 [ + + ]: 399 : if ( mnHeightOfLastLine != static_cast<SwTxtFrm*>(pCnt)->GetHeightOfLastLine() )
992 : : {
993 [ + - ]: 282 : pCnt->InvalidateNextPrtArea();
994 : : }
995 : : }
996 : :
997 : : // #i44049#
998 [ + + ][ + - ]: 23516 : if ( pCnt->IsTxtFrm() && POS_DIFF( aFrm, pCnt->Frm() ) )
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ][ + + ]
999 : : {
1000 [ + - ]: 7977 : pCnt->InvalidateObjs( true );
1001 : : }
1002 : :
1003 : : // #i43255# - move code to invalidate at-character
1004 : : // anchored objects due to a change of its anchor character from
1005 : : // method <SwTxtFrm::Format(..)>.
1006 [ + + ]: 23516 : if ( pCnt->IsTxtFrm() )
1007 : : {
1008 : 22553 : SwTxtFrm* pMasterFrm = pCnt->IsFollow()
1009 : 1967 : ? static_cast<SwTxtFrm*>(pCnt)->FindMaster()
1010 [ + - ][ + + ]: 22553 : : static_cast<SwTxtFrm*>(pCnt);
1011 [ + - ]: 45106 : if ( pMasterFrm && !pMasterFrm->IsFlyLock() &&
[ + - + + ]
[ + + ]
1012 : 22553 : pMasterFrm->GetDrawObjs() )
1013 : : {
1014 : 1247 : SwSortedObjs* pObjs = pMasterFrm->GetDrawObjs();
1015 [ + - ][ + + ]: 25332 : for ( sal_uInt32 i = 0; i < pObjs->Count(); ++i )
1016 : : {
1017 [ + - ]: 1816 : SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
1018 [ + - ][ + - ]: 1816 : if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
[ + + ]
1019 : : == FLY_AT_CHAR )
1020 : : {
1021 [ + - ]: 220 : pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrm->IsEmpty() );
1022 : : }
1023 : : }
1024 : : }
1025 : : }
1026 : 23516 : }
1027 : :
1028 : : /*************************************************************************/
1029 : :
1030 : 1525 : void AppendObjs( const SwFrmFmts *pTbl, sal_uLong nIndex,
1031 : : SwFrm *pFrm, SwPageFrm *pPage )
1032 : : {
1033 [ + + ]: 6879 : for ( sal_uInt16 i = 0; i < pTbl->size(); ++i )
1034 : : {
1035 : 5354 : SwFrmFmt *pFmt = (SwFrmFmt*)(*pTbl)[i];
1036 : 5354 : const SwFmtAnchor &rAnch = pFmt->GetAnchor();
1037 [ + + ]: 10229 : if ( rAnch.GetCntntAnchor() &&
[ + + + + ]
1038 : 4875 : (rAnch.GetCntntAnchor()->nNode.GetIndex() == nIndex) )
1039 : : {
1040 : 69 : const bool bFlyAtFly = rAnch.GetAnchorId() == FLY_AT_FLY; // LAYER_IMPL
1041 : : //Wird ein Rahmen oder ein SdrObject beschrieben?
1042 : 69 : const bool bSdrObj = RES_DRAWFRMFMT == pFmt->Which();
1043 : : // OD 23.06.2003 #108784# - append also drawing objects anchored
1044 : : // as character.
1045 : : const bool bDrawObjInCntnt = bSdrObj &&
1046 [ + + ][ + + ]: 69 : (rAnch.GetAnchorId() == FLY_AS_CHAR);
1047 : :
1048 [ + - + + : 165 : if( bFlyAtFly ||
+ + ][ + + ]
[ + + ]
1049 : 69 : (rAnch.GetAnchorId() == FLY_AT_PARA) ||
1050 : 27 : (rAnch.GetAnchorId() == FLY_AT_CHAR) ||
1051 : : bDrawObjInCntnt )
1052 : : {
1053 : 66 : SdrObject* pSdrObj = 0;
1054 [ + + ][ - + ]: 66 : if ( bSdrObj && 0 == (pSdrObj = pFmt->FindSdrObject()) )
[ - + ]
1055 : : {
1056 : : OSL_ENSURE( !bSdrObj, "DrawObject not found." );
1057 : 0 : pFmt->GetDoc()->DelFrmFmt( pFmt );
1058 : 0 : --i;
1059 : 0 : continue;
1060 : : }
1061 [ + + ]: 66 : if ( pSdrObj )
1062 : : {
1063 [ - + ]: 57 : if ( !pSdrObj->GetPage() )
1064 : : {
1065 : 0 : pFmt->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage(0)->
1066 : 0 : InsertObject(pSdrObj, pSdrObj->GetOrdNumDirect());
1067 : : }
1068 : :
1069 : : SwDrawContact* pNew =
1070 : 57 : static_cast<SwDrawContact*>(GetUserCall( pSdrObj ));
1071 [ + - ]: 57 : if ( !pNew->GetAnchorFrm() )
1072 : : {
1073 : 57 : pFrm->AppendDrawObj( *(pNew->GetAnchoredObj( 0L )) );
1074 : : }
1075 : : // OD 19.06.2003 #108784# - add 'virtual' drawing object,
1076 : : // if necessary. But control objects have to be excluded.
1077 [ # # # # : 0 : else if ( !::CheckControlLayer( pSdrObj ) &&
# # ][ # # ]
1078 : 0 : pNew->GetAnchorFrm() != pFrm &&
1079 : 0 : !pNew->GetDrawObjectByAnchorFrm( *pFrm ) )
1080 : : {
1081 : 0 : SwDrawVirtObj* pDrawVirtObj = pNew->AddVirtObj();
1082 : 0 : pFrm->AppendDrawObj( *(pNew->GetAnchoredObj( pDrawVirtObj )) );
1083 : :
1084 : : // for repaint, use new ActionChanged()
1085 : : // pDrawVirtObj->SendRepaintBroadcast();
1086 : 0 : pDrawVirtObj->ActionChanged();
1087 : : }
1088 : :
1089 : : }
1090 : : else
1091 : : {
1092 : : SwFlyFrm *pFly;
1093 [ - + ]: 9 : if( bFlyAtFly )
1094 [ # # ]: 0 : pFly = new SwFlyLayFrm( (SwFlyFrmFmt*)pFmt, pFrm, pFrm );
1095 : : else
1096 [ + - ]: 9 : pFly = new SwFlyAtCntFrm( (SwFlyFrmFmt*)pFmt, pFrm, pFrm );
1097 : 9 : pFly->Lock();
1098 : 9 : pFrm->AppendFly( pFly );
1099 : 9 : pFly->Unlock();
1100 [ + + ]: 9 : if ( pPage )
1101 : 3 : ::RegistFlys( pPage, pFly );
1102 : : }
1103 : : }
1104 : : }
1105 : : }
1106 : 1525 : }
1107 : :
1108 : 193 : bool lcl_ObjConnected( SwFrmFmt *pFmt, const SwFrm* pSib )
1109 : : {
1110 [ + - ]: 193 : SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt );
1111 [ + + ]: 193 : if ( RES_FLYFRMFMT == pFmt->Which() )
1112 : : {
1113 [ + - ]: 115 : const SwRootFrm* pRoot = pSib ? pSib->getRootFrm() : 0;
1114 : : const SwFlyFrm* pTmpFrm;
1115 [ + - ][ # # ]: 115 : for( pTmpFrm = aIter.First(); pTmpFrm; pTmpFrm = aIter.Next() )
[ + + ]
1116 : : {
1117 [ + - ][ + - ]: 67 : if(! pRoot || pRoot == pTmpFrm->getRootFrm() )
[ + - ]
1118 : 67 : return true;
1119 : : }
1120 : : }
1121 : : else
1122 : : {
1123 [ + - ]: 78 : SwDrawContact *pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
1124 [ + - ]: 78 : if ( pContact )
1125 [ + - ]: 78 : return pContact->GetAnchorFrm() != 0;
1126 : : }
1127 [ + - ]: 193 : return false;
1128 : : }
1129 : :
1130 : : /** helper method to determine, if a <SwFrmFmt>, which has an object connected,
1131 : : is located in header or footer.
1132 : :
1133 : : OD 23.06.2003 #108784#
1134 : :
1135 : : @author OD
1136 : : */
1137 : 58 : bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt )
1138 : : {
1139 : 58 : bool bRetVal = false;
1140 : :
1141 : 58 : const SwFmtAnchor& rAnch = _rFmt.GetAnchor();
1142 : :
1143 [ + - ]: 58 : if (rAnch.GetAnchorId() != FLY_AT_PAGE)
1144 : : {
1145 : 58 : bRetVal = _rFmt.GetDoc()->IsInHeaderFooter( rAnch.GetCntntAnchor()->nNode );
1146 : : }
1147 : :
1148 : 58 : return bRetVal;
1149 : : }
1150 : :
1151 : 1322 : void AppendAllObjs( const SwFrmFmts *pTbl, const SwFrm* pSib )
1152 : : {
1153 : : //Verbinden aller Objekte, die in der SpzTbl beschrieben sind mit dem
1154 : : //Layout.
1155 : : //Wenn sich nix mehr tut hoeren wir auf. Dann koennen noch Formate
1156 : : //uebrigbleiben, weil wir weder zeichengebunde Rahmen verbinden noch
1157 : : //Objecte die in zeichengebundenen verankert sind.
1158 : :
1159 [ + - ]: 1322 : SwFrmFmts aCpy( *pTbl );
1160 : :
1161 : 1322 : sal_uInt16 nOldCnt = USHRT_MAX;
1162 : :
1163 [ + + ][ + - ]: 1608 : while ( !aCpy.empty() && aCpy.size() != nOldCnt )
[ + + ]
1164 : : {
1165 : 286 : nOldCnt = aCpy.size();
1166 [ + + ]: 912 : for ( int i = 0; i < int(aCpy.size()); ++i )
1167 : : {
1168 : 626 : SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ sal_uInt16(i) ];
1169 [ + - ]: 626 : const SwFmtAnchor &rAnch = pFmt->GetAnchor();
1170 : 626 : sal_Bool bRemove = sal_False;
1171 [ + + + + ]: 1209 : if ((rAnch.GetAnchorId() == FLY_AT_PAGE) ||
[ + + ]
1172 : 583 : (rAnch.GetAnchorId() == FLY_AS_CHAR))
1173 : : {
1174 : : //Seitengebunde sind bereits verankert, zeichengebundene
1175 : : //will ich hier nicht.
1176 : 505 : bRemove = sal_True;
1177 : : }
1178 [ + - ][ + + ]: 179 : else if ( sal_False == (bRemove = ::lcl_ObjConnected( pFmt, pSib )) ||
[ + + ][ + + ]
1179 [ + - ]: 58 : ::lcl_InHeaderOrFooter( *pFmt ) )
1180 : : {
1181 : : // OD 23.06.2003 #108784# - correction: for objects in header
1182 : : // or footer create frames, in spite of the fact that an connected
1183 : : // objects already exists.
1184 : : //Fuer Flys und DrawObjs nur dann ein MakeFrms rufen wenn noch
1185 : : //keine abhaengigen Existieren, andernfalls, oder wenn das
1186 : : //MakeFrms keine abhaengigen erzeugt, entfernen.
1187 [ + - ]: 72 : pFmt->MakeFrms();
1188 [ + - ]: 72 : bRemove = ::lcl_ObjConnected( pFmt, pSib );
1189 : : }
1190 [ + - ]: 626 : if ( bRemove )
1191 : : {
1192 [ + - ][ + - ]: 626 : aCpy.erase( aCpy.begin() + i );
1193 : 626 : --i;
1194 : : }
1195 : : }
1196 : : }
1197 [ + - ]: 1322 : aCpy.clear();
1198 : 1322 : }
1199 : :
1200 : : /** local method to set 'working' position for newly inserted frames
1201 : :
1202 : : OD 12.08.2003 #i17969#
1203 : :
1204 : : @author OD
1205 : : */
1206 : 5399 : void lcl_SetPos( SwFrm& _rNewFrm,
1207 : : const SwLayoutFrm& _rLayFrm )
1208 : : {
1209 [ - + ][ # # ]: 5399 : SWRECTFN( (&_rLayFrm) )
[ # # ][ - + ]
1210 [ + - ][ + - ]: 5399 : (_rNewFrm.Frm().*fnRect->fnSetPos)( (_rLayFrm.Frm().*fnRect->fnGetPos)() );
[ + - ]
1211 : : // move position by one SwTwip in text flow direction in order to get
1212 : : // notifications for a new calculated position after its formatting.
1213 [ - + ]: 5399 : if ( bVert )
1214 : 0 : _rNewFrm.Frm().Pos().X() -= 1;
1215 : : else
1216 : 5399 : _rNewFrm.Frm().Pos().Y() += 1;
1217 : 5399 : }
1218 : :
1219 : 4065 : void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc,
1220 : : sal_uLong nIndex, sal_Bool bPages, sal_uLong nEndIndex,
1221 : : SwFrm *pPrv )
1222 : : {
1223 [ + - ]: 4065 : pDoc->BlockIdling();
1224 : 4065 : SwRootFrm* pLayout = pLay->getRootFrm();
1225 [ + - ]: 4065 : const sal_Bool bOldCallbackActionEnabled = pLayout ? pLayout->IsCallbackActionEnabled() : sal_False;
1226 [ + + ]: 4065 : if( bOldCallbackActionEnabled )
1227 : 1663 : pLayout->SetCallbackActionEnabled( sal_False );
1228 : :
1229 : : //Bei der Erzeugung des Layouts wird bPages mit sal_True uebergeben. Dann
1230 : : //werden schon mal alle x Absaetze neue Seiten angelegt. Bei umbruechen
1231 : : //und/oder Pagedescriptorwechseln werden gleich die entsprechenden Seiten
1232 : : //angelegt.
1233 : : //Vorteil ist, das einerseits schon eine annaehernd realistische Zahl von
1234 : : //Seiten angelegt wird, vor allem aber gibt es nicht mehr eine schier
1235 : : //lange Kette von Absaetzen teuer verschoben werden muss, bis sie sich auf
1236 : : //ertraegliches mass reduziert hat.
1237 : : //Wir gehen mal davon aus, da? 20 Absaetze auf eine Seite passen
1238 : : //Damit es in extremen Faellen nicht gar so heftig rechenen wir je nach
1239 : : //Node noch etwas drauf.
1240 : : //Wenn in der DocStatistik eine brauchebare Seitenzahl angegeben ist
1241 : : //(wird beim Schreiben gepflegt), so wird von dieser Seitenanzahl
1242 : : //ausgegengen.
1243 [ + + ][ + - ]: 4065 : const sal_Bool bStartPercent = bPages && !nEndIndex;
1244 : :
1245 [ + - ]: 4065 : SwPageFrm *pPage = pLay->FindPageFrm();
1246 : 4065 : const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
1247 : 4065 : SwFrm *pFrm = 0;
1248 : 4065 : sal_Bool bBreakAfter = sal_False;
1249 : :
1250 : 4065 : SwActualSection *pActualSection = 0;
1251 : : SwLayHelper *pPageMaker;
1252 : :
1253 : : //Wenn das Layout erzeugt wird (bPages == sal_True) steuern wir den Progress
1254 : : //an. Flys und DrawObjekte werden dann nicht gleich verbunden, dies
1255 : : //passiert erst am Ende der Funktion.
1256 [ + + ]: 4065 : if ( bPages )
1257 : : {
1258 : : // Attention: the SwLayHelper class uses references to the content-,
1259 : : // page-, layout-frame etc. and may change them!
1260 : : pPageMaker = new SwLayHelper( pDoc, pFrm, pPrv, pPage, pLay,
1261 [ + - ][ + - ]: 1318 : pActualSection, bBreakAfter, nIndex, 0 == nEndIndex );
1262 [ + - ]: 1318 : if( bStartPercent )
1263 : : {
1264 [ + - ]: 1318 : const sal_uLong nPageCount = pPageMaker->CalcPageCount();
1265 [ + + ]: 1318 : if( nPageCount )
1266 : 264 : bObjsDirect = sal_False;
1267 : : }
1268 : : }
1269 : : else
1270 : 2747 : pPageMaker = NULL;
1271 : :
1272 [ + - ][ + + : 4071 : if( pLay->IsInSct() &&
- + # # ]
[ + + ]
1273 : 6 : ( pLay->IsSctFrm() || pLay->GetUpper() ) ) // Hierdurch werden Frischlinge
1274 : : // abgefangen, deren Flags noch nicht ermittelt werden koennen,
1275 : : // so z.B. beim Einfuegen einer Tabelle
1276 : : {
1277 [ + - ]: 6 : SwSectionFrm* pSct = pLay->FindSctFrm();
1278 : : // Wenn Inhalt in eine Fussnote eingefuegt wird, die in einem spaltigen
1279 : : // Bereich liegt, so darf der spaltige Bereich nicht aufgebrochen werden.
1280 : : // Nur wenn im Innern der Fussnote ein Bereich liegt, ist dies ein
1281 : : // Kandidat fuer pActualSection.
1282 : : // Gleiches gilt fuer Bereiche in Tabellen, wenn innerhalb einer Tabelle
1283 : : // eingefuegt wird, duerfen nur Bereiche, die ebenfalls im Innern liegen,
1284 : : // aufgebrochen werden.
1285 [ + - ][ - + ]: 12 : if( ( !pLay->IsInFtn() || pSct->IsInFtn() ) &&
[ # # ][ # # ]
[ - + ][ # # ]
[ + - ]
1286 [ + - ][ # # ]: 6 : ( !pLay->IsInTab() || pSct->IsInTab() ) )
1287 : : {
1288 [ + - ][ + - ]: 6 : pActualSection = new SwActualSection( 0, pSct, 0 );
1289 : : OSL_ENSURE( !pLay->Lower() || !pLay->Lower()->IsColumnFrm(),
1290 : : "_InsertCnt: Wrong Call" );
1291 : : }
1292 : : }
1293 : :
1294 : : //If a section is "open", the pActualSection points to an SwActualSection.
1295 : : //If the page breaks, for "open" sections a follow will created.
1296 : : //For nested sections (which have, however, not a nested layout),
1297 : : //the SwActualSection class has a member, which points to an upper(section).
1298 : : //When the "inner" section finishs, the upper will used instead.
1299 : :
1300 : 6046 : while( sal_True )
1301 : : {
1302 [ + - ][ + - ]: 10111 : SwNode *pNd = pDoc->GetNodes()[nIndex];
1303 [ + + ]: 10111 : if ( pNd->IsCntntNode() )
1304 : : {
1305 [ + - ]: 5141 : SwCntntNode* pNode = (SwCntntNode*)pNd;
1306 [ + - ]: 9795 : pFrm = pNode->IsTxtNode() ? new SwTxtFrm( (SwTxtNode*)pNode, pLay ) :
1307 [ + - ][ + - ]: 9795 : pNode->MakeFrm( pLay );
[ + + ]
1308 [ + + ]: 5141 : if( pPageMaker )
1309 [ + - ]: 2364 : pPageMaker->CheckInsert( nIndex );
1310 : :
1311 [ + - ]: 5141 : pFrm->InsertBehind( pLay, pPrv );
1312 : : // #i27138#
1313 : : // notify accessibility paragraphs objects about changed
1314 : : // CONTENT_FLOWS_FROM/_TO relation.
1315 : : // Relation CONTENT_FLOWS_FROM for next paragraph will change
1316 : : // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1317 [ + + ]: 5141 : if ( pFrm->IsTxtFrm() )
1318 : : {
1319 : 4654 : ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1320 : : // no notification, if <ViewShell> is in construction
1321 [ + + ]: 7060 : if ( pViewShell && !pViewShell->IsInConstructor() &&
[ + - - + ]
[ - + ][ + - ]
1322 [ + - ]: 1203 : pViewShell->GetLayout() &&
1323 [ + - ]: 1203 : pViewShell->GetLayout()->IsAnyShellAccessible() )
1324 : : {
1325 : : pViewShell->InvalidateAccessibleParaFlowRelation(
1326 [ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1327 [ # # ][ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
[ # # ][ # # ]
1328 : : // #i68958#
1329 : : // The information flags of the text frame are validated
1330 : : // in methods <FindNextCnt(..)> and <FindPrevCnt(..)>.
1331 : : // The information flags have to be invalidated, because
1332 : : // it is possible, that the one of its upper frames
1333 : : // isn't inserted into the layout.
1334 : 0 : pFrm->InvalidateInfFlags();
1335 : : }
1336 : : }
1337 : : // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1338 : : // for setting position at newly inserted frame
1339 [ + - ]: 5141 : lcl_SetPos( *pFrm, *pLay );
1340 : 5141 : pPrv = pFrm;
1341 : :
1342 [ + + ][ + + ]: 5141 : if ( !pTbl->empty() && bObjsDirect && !bDontCreateObjects )
[ + - ][ + + ]
1343 [ + - ]: 962 : AppendObjs( pTbl, nIndex, pFrm, pPage );
1344 : : }
1345 [ + + ]: 4970 : else if ( pNd->IsTableNode() )
1346 : : { //Sollten wir auf eine Tabelle gestossen sein?
1347 : 102 : SwTableNode *pTblNode = (SwTableNode*)pNd;
1348 : :
1349 : : // #108116# loading may produce table structures that GCLines
1350 : : // needs to clean up. To keep table formulas correct, change
1351 : : // all table formulas to internal (BOXPTR) representation.
1352 [ + - ]: 102 : SwTableFmlUpdate aMsgHnt( &pTblNode->GetTable() );
1353 : 102 : aMsgHnt.eFlags = TBL_BOXPTR;
1354 [ + - ]: 102 : pDoc->UpdateTblFlds( &aMsgHnt );
1355 [ + - ]: 102 : pTblNode->GetTable().GCLines();
1356 : :
1357 [ + - ]: 102 : pFrm = pTblNode->MakeFrm( pLay );
1358 : :
1359 [ + + ]: 102 : if( pPageMaker )
1360 [ + - ]: 99 : pPageMaker->CheckInsert( nIndex );
1361 : :
1362 [ + - ]: 102 : pFrm->InsertBehind( pLay, pPrv );
1363 : : // #i27138#
1364 : : // notify accessibility paragraphs objects about changed
1365 : : // CONTENT_FLOWS_FROM/_TO relation.
1366 : : // Relation CONTENT_FLOWS_FROM for next paragraph will change
1367 : : // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1368 : : {
1369 : 102 : ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1370 : : // no notification, if <ViewShell> is in construction
1371 [ - + ]: 102 : if ( pViewShell && !pViewShell->IsInConstructor() &&
[ # # # # ]
[ - + ][ + - ]
1372 [ # # ]: 0 : pViewShell->GetLayout() &&
1373 [ # # ]: 0 : pViewShell->GetLayout()->IsAnyShellAccessible() )
1374 : : {
1375 : : pViewShell->InvalidateAccessibleParaFlowRelation(
1376 [ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1377 [ # # ][ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
[ # # ][ # # ]
1378 : : }
1379 : : }
1380 [ + + ][ + + ]: 102 : if ( bObjsDirect && !pTbl->empty() )
[ + + ]
1381 [ + - ]: 3 : ((SwTabFrm*)pFrm)->RegistFlys();
1382 : : // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1383 : : // for setting position at newly inserted frame
1384 [ + - ]: 102 : lcl_SetPos( *pFrm, *pLay );
1385 : :
1386 : 102 : pPrv = pFrm;
1387 : : //Index auf den Endnode der Tabellensection setzen.
1388 : 102 : nIndex = pTblNode->EndOfSectionIndex();
1389 : :
1390 : 102 : SwTabFrm* pTmpFrm = (SwTabFrm*)pFrm;
1391 [ + + ]: 204 : while ( pTmpFrm )
1392 : : {
1393 [ + - ]: 102 : pTmpFrm->CheckDirChange();
1394 [ - + ][ # # ]: 102 : pTmpFrm = pTmpFrm->IsFollow() ? pTmpFrm->FindMaster() : NULL;
1395 [ + - ]: 102 : }
1396 : :
1397 : : }
1398 [ + + ]: 4868 : else if ( pNd->IsSectionNode() )
1399 : : {
1400 : 120 : SwSectionNode *pNode = (SwSectionNode*)pNd;
1401 [ + - ][ - + ]: 120 : if( pNode->GetSection().CalcHiddenFlag() )
1402 : : // ist versteckt, ueberspringe den Bereich
1403 : 0 : nIndex = pNode->EndOfSectionIndex();
1404 : : else
1405 : : {
1406 [ + - ]: 120 : pFrm = pNode->MakeFrm( pLay );
1407 : : pActualSection = new SwActualSection( pActualSection,
1408 [ + - ][ + - ]: 120 : (SwSectionFrm*)pFrm, pNode );
1409 [ + + ]: 120 : if ( pActualSection->GetUpper() )
1410 : : {
1411 : : //Hinter den Upper einsetzen, beim EndNode wird der "Follow"
1412 : : //des Uppers erzeugt.
1413 : 36 : SwSectionFrm *pTmp = pActualSection->GetUpper()->GetSectionFrm();
1414 [ + - ]: 36 : pFrm->InsertBehind( pTmp->GetUpper(), pTmp );
1415 : : // OD 25.03.2003 #108339# - direct initialization of section
1416 : : // after insertion in the layout
1417 [ + - ]: 36 : static_cast<SwSectionFrm*>(pFrm)->Init();
1418 : : }
1419 : : else
1420 : : {
1421 [ + - ]: 84 : pFrm->InsertBehind( pLay, pPrv );
1422 : : // OD 25.03.2003 #108339# - direct initialization of section
1423 : : // after insertion in the layout
1424 [ + - ]: 84 : static_cast<SwSectionFrm*>(pFrm)->Init();
1425 : :
1426 : : // #i33963#
1427 : : // Do not trust the IsInFtn flag. If we are currently
1428 : : // building up a table, the upper of pPrv may be a cell
1429 : : // frame, but the cell frame does not have an upper yet.
1430 [ + + ][ + - ]: 84 : if( pPrv && 0 != pPrv->ImplFindFtnFrm() )
[ - + ][ - + ]
1431 : : {
1432 [ # # ]: 0 : if( pPrv->IsSctFrm() )
1433 [ # # ]: 0 : pPrv = ((SwSectionFrm*)pPrv)->ContainsCntnt();
1434 [ # # ][ # # ]: 0 : if( pPrv && pPrv->IsTxtFrm() )
[ # # ]
1435 [ # # ]: 0 : ((SwTxtFrm*)pPrv)->Prepare( PREP_QUOVADIS, 0, sal_False );
1436 : : }
1437 : : }
1438 : : // #i27138#
1439 : : // notify accessibility paragraphs objects about changed
1440 : : // CONTENT_FLOWS_FROM/_TO relation.
1441 : : // Relation CONTENT_FLOWS_FROM for next paragraph will change
1442 : : // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1443 : : {
1444 : 120 : ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1445 : : // no notification, if <ViewShell> is in construction
1446 [ + + ]: 220 : if ( pViewShell && !pViewShell->IsInConstructor() &&
[ + - - + ]
[ - + ][ + - ]
1447 [ + - ]: 50 : pViewShell->GetLayout() &&
1448 [ + - ]: 50 : pViewShell->GetLayout()->IsAnyShellAccessible() )
1449 : : {
1450 : : pViewShell->InvalidateAccessibleParaFlowRelation(
1451 [ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1452 [ # # ][ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
[ # # ][ # # ]
1453 : : }
1454 : : }
1455 [ + - ]: 120 : pFrm->CheckDirChange();
1456 : :
1457 : : // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1458 : : // for setting position at newly inserted frame
1459 [ + - ]: 120 : lcl_SetPos( *pFrm, *pLay );
1460 : :
1461 : : // OD 20.11.2002 #105405# - no page, no invalidate.
1462 [ + - ]: 120 : if ( pPage )
1463 : : {
1464 : : // OD 18.09.2002 #100522#
1465 : : // invalidate page in order to force format and paint of
1466 : : // inserted section frame
1467 [ + - ]: 120 : pFrm->InvalidatePage( pPage );
1468 : :
1469 : : // FME 10.11.2003 #112243#
1470 : : // Invalidate fly content flag:
1471 [ + - ][ - + ]: 120 : if ( pFrm->IsInFly() )
1472 : 0 : pPage->InvalidateFlyCntnt();
1473 : :
1474 : : // OD 14.11.2002 #104684# - invalidate page content in order to
1475 : : // force format and paint of section content.
1476 : 120 : pPage->InvalidateCntnt();
1477 : : }
1478 : :
1479 : 120 : pLay = (SwLayoutFrm*)pFrm;
1480 [ + + ][ + - ]: 120 : if ( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
[ + + ]
1481 [ + - ]: 10 : pLay = pLay->GetNextLayoutLeaf();
1482 : 120 : pPrv = 0;
1483 : : }
1484 : : }
1485 [ + + ][ + + ]: 4748 : else if ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode() )
[ + + ]
1486 : : {
1487 : : OSL_ENSURE( pActualSection, "Sectionende ohne Anfang?" );
1488 : : OSL_ENSURE( pActualSection->GetSectionNode() == pNd->StartOfSectionNode(),
1489 : : "Sectionende mit falschen Start Node?" );
1490 : :
1491 : : //Section schliessen, ggf. die umgebende Section wieder
1492 : : //aktivieren.
1493 : 120 : SwActualSection *pTmp = pActualSection->GetUpper();
1494 : 120 : delete pActualSection;
1495 [ + - ]: 120 : pLay = pLay->FindSctFrm();
1496 [ + + ]: 120 : if ( 0 != (pActualSection = pTmp) )
1497 : : {
1498 : : //Koennte noch sein, das der letzte SectionFrm leer geblieben
1499 : : //ist. Dann ist es jetzt an der Zeit ihn zu entfernen.
1500 [ + - ][ - + ]: 36 : if ( !pLay->ContainsCntnt() )
1501 : : {
1502 : 0 : SwFrm *pTmpFrm = pLay;
1503 : 0 : pLay = pTmpFrm->GetUpper();
1504 : 0 : pPrv = pTmpFrm->GetPrev();
1505 [ # # ]: 0 : pTmpFrm->Remove();
1506 [ # # ][ # # ]: 0 : delete pTmpFrm;
1507 : : }
1508 : : else
1509 : : {
1510 : 36 : pPrv = pLay;
1511 : 36 : pLay = pLay->GetUpper();
1512 : : }
1513 : :
1514 : : // new section frame
1515 [ + - ]: 36 : pFrm = pActualSection->GetSectionNode()->MakeFrm( pLay );
1516 [ + - ]: 36 : pFrm->InsertBehind( pLay, pPrv );
1517 [ + - ]: 36 : static_cast<SwSectionFrm*>(pFrm)->Init();
1518 : :
1519 : : // OD 12.08.2003 #i17969# - consider horizontal/vertical layout
1520 : : // for setting position at newly inserted frame
1521 [ + - ]: 36 : lcl_SetPos( *pFrm, *pLay );
1522 : :
1523 : 36 : SwSectionFrm* pOuterSectionFrm = pActualSection->GetSectionFrm();
1524 : :
1525 : : // a follow has to be appended to the new section frame
1526 : 36 : SwSectionFrm* pFollow = pOuterSectionFrm->GetFollow();
1527 [ - + ]: 36 : if ( pFollow )
1528 : : {
1529 [ # # ]: 0 : pOuterSectionFrm->SetFollow( NULL );
1530 [ # # ]: 0 : pOuterSectionFrm->InvalidateSize();
1531 [ # # ][ # # ]: 0 : ((SwSectionFrm*)pFrm)->SetFollow( pFollow );
1532 : : }
1533 : :
1534 : : // Wir wollen keine leeren Teile zuruecklassen
1535 [ + + ][ + - ]: 66 : if( ! pOuterSectionFrm->IsColLocked() &&
[ + + ]
1536 [ + - ]: 30 : ! pOuterSectionFrm->ContainsCntnt() )
1537 : : {
1538 [ + - ]: 30 : pOuterSectionFrm->DelEmpty( sal_True );
1539 [ + - ][ + - ]: 30 : delete pOuterSectionFrm;
1540 : : }
1541 : 36 : pActualSection->SetSectionFrm( (SwSectionFrm*)pFrm );
1542 : :
1543 : 36 : pLay = (SwLayoutFrm*)pFrm;
1544 [ # # ][ - + ]: 36 : if ( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
[ - + ]
1545 [ # # ]: 0 : pLay = pLay->GetNextLayoutLeaf();
1546 : 36 : pPrv = 0;
1547 : : }
1548 : : else
1549 : : {
1550 : : //Nix mehr mit Sections, es geht direkt hinter dem SectionFrame
1551 : : //weiter.
1552 : 84 : pPrv = pLay;
1553 : 84 : pLay = pLay->GetUpper();
1554 : : }
1555 : : }
1556 [ + + + - ]: 5239 : else if( pNd->IsStartNode() &&
[ + + ]
1557 : 611 : SwFlyStartNode == ((SwStartNode*)pNd)->GetStartNodeType() )
1558 : : {
1559 [ + - ][ + + ]: 611 : if ( !pTbl->empty() && bObjsDirect && !bDontCreateObjects )
[ + - ][ + + ]
1560 : : {
1561 [ + - ]: 563 : SwFlyFrm* pFly = pLay->FindFlyFrm();
1562 [ + - ]: 563 : if( pFly )
1563 [ + - ]: 563 : AppendObjs( pTbl, nIndex, pFly, pPage );
1564 : : }
1565 : : }
1566 : : else
1567 : : // Weder Cntnt noch Tabelle noch Section,
1568 : : // also muessen wir fertig sein.
1569 : 4017 : break;
1570 : :
1571 : 6094 : ++nIndex;
1572 : : // Der Endnode wird nicht mehr mitgenommen, es muss vom
1573 : : // Aufrufenden (Section/MakeFrms()) sichergestellt sein, dass das Ende
1574 : : // des Bereichs vor dem EndIndex liegt!
1575 [ + + ][ + + ]: 6094 : if ( nEndIndex && nIndex >= nEndIndex )
1576 : 48 : break;
1577 : : }
1578 : :
1579 [ + + ]: 4065 : if ( pActualSection )
1580 : : {
1581 : : //Kann passieren, dass noch eine leere (Follow-)Section uebrig geblieben ist.
1582 [ + - ][ + - ]: 6 : if ( !(pLay = pActualSection->GetSectionFrm())->ContainsCntnt() )
1583 : : {
1584 [ + - ]: 6 : pLay->Remove();
1585 [ + - ][ + - ]: 6 : delete pLay;
1586 : : }
1587 : 6 : delete pActualSection;
1588 : : }
1589 : :
1590 [ + + ]: 4065 : if ( bPages ) //Jetzt noch die Flys verbinden lassen.
1591 : : {
1592 [ + - ]: 1318 : if ( !bDontCreateObjects )
1593 [ + - ]: 1318 : AppendAllObjs( pTbl, pLayout );
1594 : 1318 : bObjsDirect = sal_True;
1595 : : }
1596 : :
1597 [ + + ]: 4065 : if( pPageMaker )
1598 : : {
1599 [ + - ]: 1318 : pPageMaker->CheckFlyCache( pPage );
1600 [ + - ][ + - ]: 1318 : delete pPageMaker;
1601 [ + + ]: 1318 : if( pDoc->GetLayoutCache() )
1602 : : {
1603 : : #ifdef DBG_UTIL
1604 : : pDoc->GetLayoutCache()->CompareLayout( *pDoc );
1605 : : #endif
1606 [ + - ]: 12 : pDoc->GetLayoutCache()->ClearImpl();
1607 : : }
1608 : : }
1609 : :
1610 [ + - ]: 4065 : pDoc->UnblockIdling();
1611 [ + + ]: 4065 : if( bOldCallbackActionEnabled )
1612 : 1663 : pLayout->SetCallbackActionEnabled( bOldCallbackActionEnabled );
1613 : 4065 : }
1614 : :
1615 : :
1616 : 49 : void MakeFrms( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
1617 : : const SwNodeIndex &rEndIdx )
1618 : : {
1619 : 49 : bObjsDirect = sal_False;
1620 : :
1621 [ + - ]: 49 : SwNodeIndex aTmp( rSttIdx );
1622 : 49 : sal_uLong nEndIdx = rEndIdx.GetIndex();
1623 [ + - ]: 49 : SwNode* pNd = pDoc->GetNodes().FindPrvNxtFrmNode( aTmp,
1624 [ + - ][ + - ]: 98 : pDoc->GetNodes()[ nEndIdx-1 ]);
[ + - ]
1625 [ + + ]: 49 : if ( pNd )
1626 : : {
1627 : 46 : sal_Bool bApres = aTmp < rSttIdx;
1628 [ + - ]: 46 : SwNode2Layout aNode2Layout( *pNd, rSttIdx.GetIndex() );
1629 : : SwFrm* pFrm;
1630 [ + - ][ + + ]: 92 : while( 0 != (pFrm = aNode2Layout.NextFrm()) )
1631 : : {
1632 : 46 : SwLayoutFrm *pUpper = pFrm->GetUpper();
1633 [ + - ]: 46 : SwFtnFrm* pFtnFrm = pUpper->FindFtnFrm();
1634 : : sal_Bool bOldLock, bOldFtn;
1635 [ + + ]: 46 : if( pFtnFrm )
1636 : : {
1637 : 4 : bOldFtn = pFtnFrm->IsColLocked();
1638 : 4 : pFtnFrm->ColLock();
1639 : : }
1640 : : else
1641 : 42 : bOldFtn = sal_True;
1642 [ + - ]: 46 : SwSectionFrm* pSct = pUpper->FindSctFrm();
1643 : : // Es sind innerhalb von Fussnoten nur die Bereiche interessant,
1644 : : // die in den Fussnoten liegen, nicht etwa die (spaltigen) Bereiche,
1645 : : // in denen die Fussnoten(Container) liegen.
1646 : : // #109767# Table frame is in section, insert section in cell frame.
1647 [ + + ][ - + ]: 46 : if( pSct && ((pFtnFrm && !pSct->IsInFtn()) || pUpper->IsCellFrm()) )
[ # # ][ # # ]
[ - + ][ - + ]
1648 : 0 : pSct = NULL;
1649 [ + + ]: 46 : if( pSct )
1650 : : { // damit der SectionFrm nicht zerstoert wird durch pTmp->MoveFwd()
1651 : 6 : bOldLock = pSct->IsColLocked();
1652 : 6 : pSct->ColLock();
1653 : : }
1654 : : else
1655 : 40 : bOldLock = sal_True;
1656 : :
1657 : : // Wenn pFrm sich nicht bewegen kann, koennen wir auch niemanden
1658 : : // auf die naechste Seite schieben. Innerhalb eines Rahmens auch
1659 : : // nicht ( in der 1. Spalte eines Rahmens waere pFrm Moveable()! )
1660 : : // Auch in spaltigen Bereichen in Tabellen waere pFrm Moveable.
1661 : 46 : sal_Bool bMoveNext = nEndIdx - rSttIdx.GetIndex() > 120;
1662 [ + - ][ + - ]: 92 : sal_Bool bAllowMove = !pFrm->IsInFly() && pFrm->IsMoveable() &&
1663 [ + - ][ + + ]: 92 : (!pFrm->IsInTab() || pFrm->IsTabFrm() );
[ + - ][ - + ]
[ # # ]
1664 [ - + ][ # # ]: 46 : if ( bMoveNext && bAllowMove )
1665 : : {
1666 : 0 : SwFrm *pMove = pFrm;
1667 : 0 : SwFrm *pPrev = pFrm->GetPrev();
1668 [ # # ]: 0 : SwFlowFrm *pTmp = SwFlowFrm::CastFlowFrm( pMove );
1669 : : OSL_ENSURE( pTmp, "Missing FlowFrm" );
1670 : :
1671 [ # # ]: 0 : if ( bApres )
1672 : : {
1673 : : // Wir wollen, dass der Rest der Seite leer ist, d.h.
1674 : : // der naechste muss auf die naechste Seite wandern.
1675 : : // Dieser kann auch in der naechsten Spalte stehen!
1676 : : OSL_ENSURE( !pTmp->HasFollow(), "Follows forbidden" );
1677 : 0 : pPrev = pFrm;
1678 : : // Wenn unser umgebender SectionFrm einen Next besitzt,
1679 : : // so soll dieser ebenfalls gemoved werden!
1680 [ # # ]: 0 : pMove = pFrm->GetIndNext();
1681 [ # # ]: 0 : SwColumnFrm* pCol = (SwColumnFrm*)pFrm->FindColFrm();
1682 [ # # ]: 0 : if( pCol )
1683 : 0 : pCol = (SwColumnFrm*)pCol->GetNext();
1684 [ # # ][ # # ]: 0 : do
[ # # ]
1685 : : {
1686 [ # # ][ # # ]: 0 : if( pCol && !pMove )
1687 : : { // Bisher haben wir keinen Nachfolger gefunden
1688 : : // jetzt gucken wir in die naechste Spalte
1689 [ # # ]: 0 : pMove = pCol->ContainsAny();
1690 [ # # ]: 0 : if( pCol->GetNext() )
1691 : 0 : pCol = (SwColumnFrm*)pCol->GetNext();
1692 [ # # ][ # # ]: 0 : else if( pCol->IsInSct() )
1693 : : { // Wenn es keine naechste Spalte gibt, wir aber
1694 : : // innerhalb eines spaltigen Bereichs sind,
1695 : : // koennte es noch ausserhalb des Bereich
1696 : : // (Seiten-)Spalten geben
1697 [ # # ][ # # ]: 0 : pCol = (SwColumnFrm*)pCol->FindSctFrm()->FindColFrm();
1698 [ # # ]: 0 : if( pCol )
1699 : 0 : pCol = (SwColumnFrm*)pCol->GetNext();
1700 : : }
1701 : : else
1702 : 0 : pCol = NULL;
1703 : : }
1704 : : // Falls hier verschrottete SectionFrms herumgammeln,
1705 : : // muessen diese uebersprungen werden.
1706 [ # # ]: 0 : while( pMove && pMove->IsSctFrm() &&
[ # # # # ]
[ # # ]
1707 : 0 : !((SwSectionFrm*)pMove)->GetSection() )
1708 : 0 : pMove = pMove->GetNext();
1709 : : } while( !pMove && pCol );
1710 : :
1711 [ # # ]: 0 : if( pMove )
1712 : : {
1713 [ # # ]: 0 : if ( pMove->IsCntntFrm() )
1714 [ # # ]: 0 : pTmp = (SwCntntFrm*)pMove;
1715 [ # # ]: 0 : else if ( pMove->IsTabFrm() )
1716 [ # # ]: 0 : pTmp = (SwTabFrm*)pMove;
1717 [ # # ]: 0 : else if ( pMove->IsSctFrm() )
1718 : : {
1719 [ # # ]: 0 : pMove = ((SwSectionFrm*)pMove)->ContainsAny();
1720 [ # # ]: 0 : if( pMove )
1721 [ # # ]: 0 : pTmp = SwFlowFrm::CastFlowFrm( pMove );
1722 : : else
1723 : 0 : pTmp = NULL;
1724 : : }
1725 : : }
1726 : : else
1727 : 0 : pTmp = 0;
1728 : : }
1729 : : else
1730 : : {
1731 : : OSL_ENSURE( !pTmp->IsFollow(), "Follows really forbidden" );
1732 : : // Bei Bereichen muss natuerlich der Inhalt auf die Reise
1733 : : // geschickt werden.
1734 [ # # ]: 0 : if( pMove->IsSctFrm() )
1735 : : {
1736 [ # # ]: 0 : while( pMove && pMove->IsSctFrm() &&
[ # # # # ]
[ # # ]
1737 : 0 : !((SwSectionFrm*)pMove)->GetSection() )
1738 : 0 : pMove = pMove->GetNext();
1739 [ # # ][ # # ]: 0 : if( pMove && pMove->IsSctFrm() )
[ # # ]
1740 [ # # ]: 0 : pMove = ((SwSectionFrm*)pMove)->ContainsAny();
1741 [ # # ]: 0 : if( pMove )
1742 [ # # ]: 0 : pTmp = SwFlowFrm::CastFlowFrm( pMove );
1743 : : else
1744 : 0 : pTmp = NULL;
1745 : : }
1746 : : }
1747 : :
1748 [ # # ]: 0 : if( pTmp )
1749 : : {
1750 : 0 : SwFrm* pOldUp = pTmp->GetFrm()->GetUpper();
1751 : : // MoveFwd==sal_True bedeutet, dass wir auf der gleichen
1752 : : // Seite geblieben sind, wir wollen aber die Seite wechseln,
1753 : : // sofern dies moeglich ist
1754 : 0 : sal_Bool bTmpOldLock = pTmp->IsJoinLocked();
1755 : 0 : pTmp->LockJoin();
1756 [ # # ][ # # ]: 0 : while( pTmp->MoveFwd( sal_True, sal_False, sal_True ) )
1757 : : {
1758 [ # # ]: 0 : if( pOldUp == pTmp->GetFrm()->GetUpper() )
1759 : 0 : break;
1760 : 0 : pOldUp = pTmp->GetFrm()->GetUpper();
1761 : : }
1762 [ # # ]: 0 : if( !bTmpOldLock )
1763 : 0 : pTmp->UnlockJoin();
1764 : : }
1765 : : ::_InsertCnt( pUpper, pDoc, rSttIdx.GetIndex(),
1766 [ # # ][ # # ]: 0 : pFrm->IsInDocBody(), nEndIdx, pPrev );
1767 : : }
1768 : : else
1769 : : {
1770 : : sal_Bool bSplit;
1771 [ + + ]: 46 : SwFrm* pPrv = bApres ? pFrm : pFrm->GetPrev();
1772 : : // Wenn in einen SectionFrm ein anderer eingefuegt wird,
1773 : : // muss dieser aufgebrochen werden
1774 [ + + ][ + - ]: 46 : if( pSct && rSttIdx.GetNode().IsSectionNode() )
[ + + ]
1775 : : {
1776 [ + - ]: 6 : bSplit = pSct->SplitSect( pFrm, bApres );
1777 : : // Wenn pSct nicht aufgespalten werden konnte
1778 [ - + ][ # # ]: 6 : if( !bSplit && !bApres )
1779 : : {
1780 : 0 : pUpper = pSct->GetUpper();
1781 : 0 : pPrv = pSct->GetPrev();
1782 : : }
1783 : : }
1784 : : else
1785 : 40 : bSplit = sal_False;
1786 : : ::_InsertCnt( pUpper, pDoc, rSttIdx.GetIndex(), sal_False,
1787 [ + - ]: 46 : nEndIdx, pPrv );
1788 : : // OD 23.06.2003 #108784# - correction: append objects doesn't
1789 : : // depend on value of <bAllowMove>
1790 [ + - ]: 46 : if( !bDontCreateObjects )
1791 : : {
1792 : 46 : const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
1793 [ + + ]: 46 : if( !pTbl->empty() )
1794 [ + - ]: 4 : AppendAllObjs( pTbl, pUpper );
1795 : : }
1796 : :
1797 : : // Wenn nichts eingefuegt wurde, z.B. ein ausgeblendeter Bereich,
1798 : : // muss das Splitten rueckgaengig gemacht werden
1799 [ + + ][ + - ]: 52 : if( bSplit && pSct && pSct->GetNext()
[ + - + - ]
[ + + ]
1800 : 6 : && pSct->GetNext()->IsSctFrm() )
1801 [ + - ]: 6 : pSct->MergeNext( (SwSectionFrm*)pSct->GetNext() );
1802 [ + - ][ - + ]: 46 : if( pFrm->IsInFly() )
1803 [ # # ][ # # ]: 0 : pFrm->FindFlyFrm()->_Invalidate();
1804 [ + - ][ + + ]: 46 : if( pFrm->IsInTab() )
1805 [ + - ]: 4 : pFrm->InvalidateSize();
1806 : : }
1807 : :
1808 [ + - ]: 46 : SwPageFrm *pPage = pUpper->FindPageFrm();
1809 [ + - ]: 46 : SwFrm::CheckPageDescs( pPage, sal_False );
1810 [ + + ]: 46 : if( !bOldFtn )
1811 : 4 : pFtnFrm->ColUnlock();
1812 [ + + ]: 46 : if( !bOldLock )
1813 : : {
1814 : 6 : pSct->ColUnlock();
1815 : : // Zum Beispiel beim Einfuegen von gelinkten Bereichen,
1816 : : // die wiederum Bereiche enthalten, kann pSct jetzt leer sein
1817 : : // und damit ruhig zerstoert werden.
1818 [ - + ][ + - ]: 6 : if( !pSct->ContainsCntnt() )
1819 : : {
1820 [ # # ]: 0 : pSct->DelEmpty( sal_True );
1821 [ # # ]: 0 : pUpper->getRootFrm()->RemoveFromList( pSct );
1822 [ # # ][ # # ]: 0 : delete pSct;
1823 : : }
1824 : : }
1825 [ + - ]: 46 : }
1826 : : }
1827 : :
1828 [ + - ]: 49 : bObjsDirect = sal_True;
1829 : 49 : }
1830 : :
1831 : :
1832 : : /*************************************************************************/
1833 : :
1834 : 13763 : SwBorderAttrs::SwBorderAttrs( const SwModify *pMod, const SwFrm *pConstructor ) :
1835 : : SwCacheObj( pMod ),
1836 : 13763 : rAttrSet( pConstructor->IsCntntFrm()
1837 : 8536 : ? ((SwCntntFrm*)pConstructor)->GetNode()->GetSwAttrSet()
1838 [ + - ]: 5227 : : ((SwLayoutFrm*)pConstructor)->GetFmt()->GetAttrSet() ),
1839 [ + - ]: 13763 : rUL ( rAttrSet.GetULSpace() ),
1840 : : // #i96772#
1841 : : // LRSpaceItem is copied due to the possibility that it is adjusted - see below
1842 [ + - ]: 13763 : rLR ( rAttrSet.GetLRSpace() ),
1843 [ + - ]: 13763 : rBox ( rAttrSet.GetBox() ),
1844 [ + - ]: 13763 : rShadow ( rAttrSet.GetShadow() ),
1845 [ + + + - ]: 68815 : aFrmSize( rAttrSet.GetFrmSize().GetSize() )
[ + - ][ + - ]
1846 : : {
1847 : : // #i96772#
1848 [ - + ]: 13763 : const SwTxtFrm* pTxtFrm = dynamic_cast<const SwTxtFrm*>(pConstructor);
1849 [ + + ]: 13763 : if ( pTxtFrm )
1850 : : {
1851 [ + - ]: 8043 : pTxtFrm->GetTxtNode()->ClearLRSpaceItemDueToListLevelIndents( rLR );
1852 : : }
1853 [ + + ]: 5720 : else if ( pConstructor->IsNoTxtFrm() )
1854 : : {
1855 [ + - ][ + - ]: 493 : rLR = SvxLRSpaceItem ( RES_LR_SPACE );
1856 : : }
1857 : :
1858 : : //Achtung: Die USHORTs fuer die gecache'ten Werte werden absichtlich
1859 : : //nicht initialisiert!
1860 : :
1861 : : //Muessen alle einmal berechnet werden:
1862 : : bTopLine = bBottomLine = bLeftLine = bRightLine =
1863 : 13763 : bTop = bBottom = bLine = sal_True;
1864 : :
1865 : 13763 : bCacheGetLine = bCachedGetTopLine = bCachedGetBottomLine = sal_False;
1866 : : // OD 21.05.2003 #108789# - init cache status for values <bJoinedWithPrev>
1867 : : // and <bJoinedWithNext>, which aren't initialized by default.
1868 : 13763 : bCachedJoinedWithPrev = sal_False;
1869 : 13763 : bCachedJoinedWithNext = sal_False;
1870 : :
1871 : 13763 : bBorderDist = 0 != (pConstructor->GetType() & (FRM_CELL));
1872 : 13763 : }
1873 : :
1874 [ + - ]: 13763 : SwBorderAttrs::~SwBorderAttrs()
1875 : : {
1876 : 13763 : ((SwModify*)pOwner)->SetInCache( sal_False );
1877 [ - + ]: 27526 : }
1878 : :
1879 : : /*************************************************************************
1880 : : |*
1881 : : |* SwBorderAttrs::CalcTop(), CalcBottom(), CalcLeft(), CalcRight()
1882 : : |*
1883 : : |* Beschreibung Die Calc-Methoden errechnen zusaetzlich zu den
1884 : : |* von den Attributen vorgegebenen Groessen einen Sicherheitsabstand.
1885 : : |* der Sicherheitsabstand wird nur einkalkuliert, wenn Umrandung und/oder
1886 : : |* Schatten im Spiel sind; er soll vermeiden, dass aufgrund der
1887 : : |* groben physikalischen Gegebenheiten Raender usw. uebermalt werden.
1888 : : |*
1889 : : |*************************************************************************/
1890 : :
1891 : 1581 : void SwBorderAttrs::_CalcTop()
1892 : : {
1893 : 1581 : nTop = CalcTopLine() + rUL.GetUpper();
1894 : 1581 : bTop = sal_False;
1895 : 1581 : }
1896 : :
1897 : 1581 : void SwBorderAttrs::_CalcBottom()
1898 : : {
1899 : 1581 : nBottom = CalcBottomLine() + rUL.GetLower();
1900 : 1581 : bBottom = sal_False;
1901 : 1581 : }
1902 : :
1903 : 41465 : long SwBorderAttrs::CalcRight( const SwFrm* pCaller ) const
1904 : : {
1905 : 41465 : long nRight=0;
1906 : :
1907 [ + + ][ + + ]: 41465 : if (!pCaller->IsTxtFrm() || !((SwTxtFrm*)pCaller)->GetTxtNode()->GetDoc()->get(IDocumentSettingAccess::INVERT_BORDER_SPACING)) {
[ + + ]
1908 : : // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
1909 : : // and right border are painted on the right respectively left.
1910 [ - + ][ # # ]: 39581 : if ( pCaller->IsCellFrm() && pCaller->IsRightToLeft() )
[ - + ]
1911 : 0 : nRight = CalcLeftLine();
1912 : : else
1913 : 39581 : nRight = CalcRightLine();
1914 : :
1915 : : }
1916 : : // for paragraphs, "left" is "before text" and "right" is "after text"
1917 [ + + ][ - + ]: 41465 : if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
[ - + ]
1918 : 0 : nRight += rLR.GetLeft();
1919 : : else
1920 : 41465 : nRight += rLR.GetRight();
1921 : :
1922 : : // correction: retrieve left margin for numbering in R2L-layout
1923 [ + + ][ - + ]: 41465 : if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
[ - + ]
1924 : : {
1925 : 0 : nRight += ((SwTxtFrm*)pCaller)->GetTxtNode()->GetLeftMarginWithNum();
1926 : : }
1927 : :
1928 : 41465 : return nRight;
1929 : : }
1930 : :
1931 : : /// Tries to detect if this paragraph has a floating table attached.
1932 : 6185 : bool lcl_hasTabFrm(const SwTxtFrm* pTxtFrm)
1933 : : {
1934 [ + + ]: 6185 : if (pTxtFrm->GetDrawObjs())
1935 : : {
1936 : 1848 : const SwSortedObjs* pSortedObjs = pTxtFrm->GetDrawObjs();
1937 [ + - ]: 1848 : if (pSortedObjs->Count() > 0)
1938 : : {
1939 : 1848 : SwAnchoredObject* pObject = (*pSortedObjs)[0];
1940 [ + + ]: 1848 : if (pObject->IsA(TYPE(SwFlyFrm)))
1941 : : {
1942 [ + - ]: 1725 : SwFlyFrm* pFly = (SwFlyFrm*)pObject;
1943 [ - + ]: 1725 : if (pFly->Lower()->IsTabFrm())
1944 : 0 : return true;
1945 : : }
1946 : : }
1947 : : }
1948 : 6185 : return false;
1949 : : }
1950 : :
1951 : 42822 : long SwBorderAttrs::CalcLeft( const SwFrm *pCaller ) const
1952 : : {
1953 : 42822 : long nLeft=0;
1954 : :
1955 [ + + ][ + + ]: 42822 : if (!pCaller->IsTxtFrm() || !((SwTxtFrm*)pCaller)->GetTxtNode()->GetDoc()->get(IDocumentSettingAccess::INVERT_BORDER_SPACING)) {
[ + + ]
1956 : : // OD 23.01.2003 #106895# - for cell frame in R2L text direction the left
1957 : : // and right border are painted on the right respectively left.
1958 [ - + ][ # # ]: 40938 : if ( pCaller->IsCellFrm() && pCaller->IsRightToLeft() )
[ - + ]
1959 : 0 : nLeft = CalcRightLine();
1960 : : else
1961 : 40938 : nLeft = CalcLeftLine();
1962 : : }
1963 : :
1964 : : // for paragraphs, "left" is "before text" and "right" is "after text"
1965 [ + + ][ - + ]: 42822 : if ( pCaller->IsTxtFrm() && pCaller->IsRightToLeft() )
[ - + ]
1966 : 0 : nLeft += rLR.GetRight();
1967 : : else
1968 : : {
1969 : 42822 : bool bIgnoreMargin = false;
1970 [ + + ]: 42822 : if (pCaller->IsTxtFrm())
1971 : : {
1972 : 38525 : const SwTxtFrm* pTxtFrm = (const SwTxtFrm*)pCaller;
1973 [ + + ]: 38525 : if (pTxtFrm->GetTxtNode()->GetDoc()->get(IDocumentSettingAccess::FLOATTABLE_NOMARGINS))
1974 : : {
1975 : : // If this is explicitly requested, ignore the margins next to the floating table.
1976 [ - + ]: 3757 : if (lcl_hasTabFrm(pTxtFrm))
1977 : 0 : bIgnoreMargin = true;
1978 : : // TODO here we only handle the first two paragraphs, would be nice to generalize this.
1979 [ + + ][ + + ]: 3757 : else if (pTxtFrm->FindPrev() && pTxtFrm->FindPrev()->IsTxtFrm() && lcl_hasTabFrm((const SwTxtFrm*)pTxtFrm->FindPrev()))
[ - + ][ - + ]
1980 : 0 : bIgnoreMargin = true;
1981 : : }
1982 : : }
1983 [ + - ]: 42822 : if (!bIgnoreMargin)
1984 : 42822 : nLeft += rLR.GetLeft();
1985 : : }
1986 : :
1987 : :
1988 : : // correction: do not retrieve left margin for numbering in R2L-layout
1989 : : // if ( pCaller->IsTxtFrm() )
1990 [ + + ][ + - ]: 42822 : if ( pCaller->IsTxtFrm() && !pCaller->IsRightToLeft() )
[ + + ]
1991 : : {
1992 : 38525 : nLeft += ((SwTxtFrm*)pCaller)->GetTxtNode()->GetLeftMarginWithNum();
1993 : : }
1994 : :
1995 : 42822 : return nLeft;
1996 : : }
1997 : :
1998 : : /*************************************************************************
1999 : : |*
2000 : : |* SwBorderAttrs::CalcTopLine(), CalcBottomLine(),
2001 : : |* CalcLeftLine(), CalcRightLine()
2002 : : |*
2003 : : |* Beschreibung Berechnung der Groessen fuer Umrandung und Schatten.
2004 : : |* Es kann auch ohne Linien ein Abstand erwuenscht sein,
2005 : : |* dieser wird dann nicht vom Attribut sondern hier
2006 : : |* beruecksichtigt (bBorderDist, z.B. fuer Zellen).
2007 : : |*
2008 : : |*************************************************************************/
2009 : :
2010 : 10556 : void SwBorderAttrs::_CalcTopLine()
2011 : : {
2012 : 0 : nTopLine = (bBorderDist && !rBox.GetTop())
2013 : 0 : ? rBox.GetDistance (BOX_LINE_TOP)
2014 [ - + # # ]: 10556 : : rBox.CalcLineSpace(BOX_LINE_TOP);
2015 : 10556 : nTopLine = nTopLine + rShadow.CalcShadowSpace(SHADOW_TOP);
2016 : 10556 : bTopLine = sal_False;
2017 : 10556 : }
2018 : :
2019 : 10556 : void SwBorderAttrs::_CalcBottomLine()
2020 : : {
2021 : 0 : nBottomLine = (bBorderDist && !rBox.GetBottom())
2022 : 0 : ? rBox.GetDistance (BOX_LINE_BOTTOM)
2023 [ - + # # ]: 10556 : : rBox.CalcLineSpace(BOX_LINE_BOTTOM);
2024 : 10556 : nBottomLine = nBottomLine + rShadow.CalcShadowSpace(SHADOW_BOTTOM);
2025 : 10556 : bBottomLine = sal_False;
2026 : 10556 : }
2027 : :
2028 : 10306 : void SwBorderAttrs::_CalcLeftLine()
2029 : : {
2030 : 0 : nLeftLine = (bBorderDist && !rBox.GetLeft())
2031 : 0 : ? rBox.GetDistance (BOX_LINE_LEFT)
2032 [ - + # # ]: 10306 : : rBox.CalcLineSpace(BOX_LINE_LEFT);
2033 : 10306 : nLeftLine = nLeftLine + rShadow.CalcShadowSpace(SHADOW_LEFT);
2034 : 10306 : bLeftLine = sal_False;
2035 : 10306 : }
2036 : :
2037 : 10306 : void SwBorderAttrs::_CalcRightLine()
2038 : : {
2039 : 0 : nRightLine = (bBorderDist && !rBox.GetRight())
2040 : 0 : ? rBox.GetDistance (BOX_LINE_RIGHT)
2041 [ - + # # ]: 10306 : : rBox.CalcLineSpace(BOX_LINE_RIGHT);
2042 : 10306 : nRightLine = nRightLine + rShadow.CalcShadowSpace(SHADOW_RIGHT);
2043 : 10306 : bRightLine = sal_False;
2044 : 10306 : }
2045 : :
2046 : : /*************************************************************************/
2047 : :
2048 : 6593 : void SwBorderAttrs::_IsLine()
2049 : : {
2050 : 13100 : bIsLine = rBox.GetTop() || rBox.GetBottom() ||
2051 [ + - ][ - + ]: 13100 : rBox.GetLeft()|| rBox.GetRight();
[ + + + + ]
2052 : 6593 : bLine = sal_False;
2053 : 6593 : }
2054 : :
2055 : : /*************************************************************************
2056 : : |*
2057 : : |* SwBorderAttrs::CmpLeftRightLine(), IsTopLine(), IsBottomLine()
2058 : : |*
2059 : : |* Die Umrandungen benachbarter Absaetze werden nach folgendem
2060 : : |* Algorithmus zusammengefasst:
2061 : : |*
2062 : : |* 1. Die Umrandung oben faellt weg, wenn der Vorgaenger dieselbe
2063 : : |* Umrandung oben aufweist und 3. Zutrifft.
2064 : : |* Zusaetzlich muss der Absatz mindestens rechts oder links oder
2065 : : |* unten eine Umrandung haben.
2066 : : |* 2. Die Umrandung unten faellt weg, wenn der Nachfolger dieselbe
2067 : : |* Umrandung untern aufweist und 3. Zustrifft.
2068 : : |* Zusaetzlich muss der Absatz mindestens rechts oder links oder
2069 : : |* oben eine Umrandung haben.
2070 : : |* 3. Die Umrandungen links und rechts vor Vorgaenger bzw. Nachfolger
2071 : : |* sind identisch.
2072 : : |*
2073 : : |*************************************************************************/
2074 : 47340 : inline int CmpLines( const editeng::SvxBorderLine *pL1, const editeng::SvxBorderLine *pL2 )
2075 : : {
2076 [ + + ][ + + ]: 47340 : return ( ((pL1 && pL2) && (*pL1 == *pL2)) || (!pL1 && !pL2) );
[ - + ][ + + ]
[ + + ]
2077 : : }
2078 : :
2079 : : // OD 21.05.2003 #108789# - change name of 1st parameter - "rAttrs" -> "rCmpAttrs"
2080 : : // OD 21.05.2003 #108789# - compare <CalcRight()> and <rCmpAttrs.CalcRight()>
2081 : : // instead of only the right LR-spacing, because R2L-layout has to be
2082 : : // considered.
2083 : 11793 : sal_Bool SwBorderAttrs::CmpLeftRight( const SwBorderAttrs &rCmpAttrs,
2084 : : const SwFrm *pCaller,
2085 : : const SwFrm *pCmp ) const
2086 : : {
2087 : 11793 : return ( CmpLines( rCmpAttrs.GetBox().GetLeft(), GetBox().GetLeft() ) &&
2088 : 11793 : CmpLines( rCmpAttrs.GetBox().GetRight(),GetBox().GetRight() ) &&
2089 : 11793 : CalcLeft( pCaller ) == rCmpAttrs.CalcLeft( pCmp ) &&
2090 : : // OD 21.05.2003 #108789# - compare <CalcRight> with <rCmpAttrs.CalcRight>.
2091 [ + - ][ + - : 35379 : CalcRight( pCaller ) == rCmpAttrs.CalcRight( pCmp ) );
+ - + + ]
2092 : : }
2093 : :
2094 : 11892 : sal_Bool SwBorderAttrs::_JoinWithCmp( const SwFrm& _rCallerFrm,
2095 : : const SwFrm& _rCmpFrm ) const
2096 : : {
2097 : 11892 : sal_Bool bReturnVal = sal_False;
2098 : :
2099 [ + - ]: 11892 : SwBorderAttrAccess aCmpAccess( SwFrm::GetCache(), &_rCmpFrm );
2100 [ + - ]: 11892 : const SwBorderAttrs &rCmpAttrs = *aCmpAccess.Get();
2101 [ + - ][ + - ]: 47439 : if ( rShadow == rCmpAttrs.GetShadow() &&
[ + + ][ + + ]
[ + + ][ + + ]
2102 [ + - ]: 11892 : CmpLines( rBox.GetTop(), rCmpAttrs.GetBox().GetTop() ) &&
2103 [ + - ]: 11862 : CmpLines( rBox.GetBottom(), rCmpAttrs.GetBox().GetBottom() ) &&
2104 [ + - ]: 11793 : CmpLeftRight( rCmpAttrs, &_rCallerFrm, &_rCmpFrm )
2105 : : )
2106 : : {
2107 : 11262 : bReturnVal = sal_True;
2108 : : }
2109 : :
2110 [ + - ]: 11892 : return bReturnVal;
2111 : : }
2112 : :
2113 : : // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2114 : : // previous frame. Calculated value saved in cached value <bJoinedWithPrev>
2115 : : // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrm>
2116 : 38831 : void SwBorderAttrs::_CalcJoinedWithPrev( const SwFrm& _rFrm,
2117 : : const SwFrm* _pPrevFrm )
2118 : : {
2119 : : // set default
2120 : 38831 : bJoinedWithPrev = sal_False;
2121 : :
2122 [ + + ]: 38831 : if ( _rFrm.IsTxtFrm() )
2123 : : {
2124 : : // text frame can potentially join with previous text frame, if
2125 : : // corresponding attribute set is set at previous text frame.
2126 : : // OD 2004-02-26 #i25029# - If parameter <_pPrevFrm> is set, take this
2127 : : // one as previous frame.
2128 [ + + ]: 37380 : const SwFrm* pPrevFrm = _pPrevFrm ? _pPrevFrm : _rFrm.GetPrev();
2129 : : // OD 2004-02-13 #i25029# - skip hidden text frames.
2130 [ + + ]: 46763 : while ( pPrevFrm && pPrevFrm->IsTxtFrm() &&
[ + + - + ]
[ - + ]
2131 : 9383 : static_cast<const SwTxtFrm*>(pPrevFrm)->IsHiddenNow() )
2132 : : {
2133 : 0 : pPrevFrm = pPrevFrm->GetPrev();
2134 : : }
2135 [ + + ]: 46763 : if ( pPrevFrm && pPrevFrm->IsTxtFrm() &&
[ + + + - ]
[ + + ]
2136 : 9383 : pPrevFrm->GetAttrSet()->GetParaConnectBorder().GetValue()
2137 : : )
2138 : : {
2139 : 9383 : bJoinedWithPrev = _JoinWithCmp( _rFrm, *(pPrevFrm) );
2140 : : }
2141 : : }
2142 : :
2143 : : // valid cache status, if demanded
2144 : : // OD 2004-02-26 #i25029# - Do not validate cache, if parameter <_pPrevFrm>
2145 : : // is set.
2146 [ + + ][ + - ]: 38831 : bCachedJoinedWithPrev = bCacheGetLine && !_pPrevFrm;
2147 : 38831 : }
2148 : :
2149 : : // OD 21.05.2003 #108789# - method to determine, if borders are joined with
2150 : : // next frame. Calculated value saved in cached value <bJoinedWithNext>
2151 : 15237 : void SwBorderAttrs::_CalcJoinedWithNext( const SwFrm& _rFrm )
2152 : : {
2153 : : // set default
2154 : 15237 : bJoinedWithNext = sal_False;
2155 : :
2156 [ + + ]: 15237 : if ( _rFrm.IsTxtFrm() )
2157 : : {
2158 : : // text frame can potentially join with next text frame, if
2159 : : // corresponding attribute set is set at current text frame.
2160 : : // OD 2004-02-13 #i25029# - get next frame, but skip hidden text frames.
2161 : 14721 : const SwFrm* pNextFrm = _rFrm.GetNext();
2162 [ + + ]: 17230 : while ( pNextFrm && pNextFrm->IsTxtFrm() &&
[ + + - + ]
[ - + ]
2163 : 2509 : static_cast<const SwTxtFrm*>(pNextFrm)->IsHiddenNow() )
2164 : : {
2165 : 0 : pNextFrm = pNextFrm->GetNext();
2166 : : }
2167 [ + + ]: 17230 : if ( pNextFrm && pNextFrm->IsTxtFrm() &&
[ + + + - ]
[ + + ]
2168 : 2509 : _rFrm.GetAttrSet()->GetParaConnectBorder().GetValue()
2169 : : )
2170 : : {
2171 : 2509 : bJoinedWithNext = _JoinWithCmp( _rFrm, *(pNextFrm) );
2172 : : }
2173 : : }
2174 : :
2175 : : // valid cache status, if demanded
2176 : 15237 : bCachedJoinedWithNext = bCacheGetLine;
2177 : 15237 : }
2178 : :
2179 : : // OD 21.05.2003 #108789# - accessor for cached values <bJoinedWithPrev>
2180 : : // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrm>, which is passed to
2181 : : // method <_CalcJoindWithPrev(..)>.
2182 : 38831 : sal_Bool SwBorderAttrs::JoinedWithPrev( const SwFrm& _rFrm,
2183 : : const SwFrm* _pPrevFrm ) const
2184 : : {
2185 [ - + ][ # # ]: 38831 : if ( !bCachedJoinedWithPrev || _pPrevFrm )
2186 : : {
2187 : : // OD 2004-02-26 #i25029# - pass <_pPrevFrm> as 2nd parameter
2188 : 38831 : const_cast<SwBorderAttrs*>(this)->_CalcJoinedWithPrev( _rFrm, _pPrevFrm );
2189 : : }
2190 : :
2191 : 38831 : return bJoinedWithPrev;
2192 : : }
2193 : :
2194 : 15237 : sal_Bool SwBorderAttrs::JoinedWithNext( const SwFrm& _rFrm ) const
2195 : : {
2196 [ + - ]: 15237 : if ( !bCachedJoinedWithNext )
2197 : : {
2198 : 15237 : const_cast<SwBorderAttrs*>(this)->_CalcJoinedWithNext( _rFrm );
2199 : : }
2200 : :
2201 : 15237 : return bJoinedWithNext;
2202 : : }
2203 : :
2204 : : // OD 2004-02-26 #i25029# - added 2nd parameter <_pPrevFrm>, which is passed to
2205 : : // method <JoinedWithPrev>
2206 : 18245 : void SwBorderAttrs::_GetTopLine( const SwFrm& _rFrm,
2207 : : const SwFrm* _pPrevFrm )
2208 : : {
2209 : 18245 : sal_uInt16 nRet = CalcTopLine();
2210 : :
2211 : : // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2212 : : // OD 2004-02-26 #i25029# - add 2nd parameter
2213 [ + + ]: 18245 : if ( JoinedWithPrev( _rFrm, _pPrevFrm ) )
2214 : : {
2215 : 3223 : nRet = 0;
2216 : : }
2217 : :
2218 : 18245 : bCachedGetTopLine = bCacheGetLine;
2219 : :
2220 : 18245 : nGetTopLine = nRet;
2221 : 18245 : }
2222 : :
2223 : 15237 : void SwBorderAttrs::_GetBottomLine( const SwFrm& _rFrm )
2224 : : {
2225 : 15237 : sal_uInt16 nRet = CalcBottomLine();
2226 : :
2227 : : // OD 21.05.2003 #108789# - use new method <JoinWithPrev()>
2228 [ + + ]: 15237 : if ( JoinedWithNext( _rFrm ) )
2229 : : {
2230 : 2278 : nRet = 0;
2231 : : }
2232 : :
2233 : 15237 : bCachedGetBottomLine = bCacheGetLine;
2234 : :
2235 : 15237 : nGetBottomLine = nRet;
2236 : 15237 : }
2237 : :
2238 : : /*************************************************************************/
2239 : :
2240 : 159135 : SwBorderAttrAccess::SwBorderAttrAccess( SwCache &rCach, const SwFrm *pFrm ) :
2241 : 159135 : SwCacheAccess( rCach, (pFrm->IsCntntFrm() ?
2242 : : (void*)((SwCntntFrm*)pFrm)->GetNode() :
2243 : 71318 : (void*)((SwLayoutFrm*)pFrm)->GetFmt()),
2244 : 159135 : (sal_Bool)(pFrm->IsCntntFrm() ?
2245 : 87817 : ((SwModify*)((SwCntntFrm*)pFrm)->GetNode())->IsInCache() :
2246 : 71318 : ((SwModify*)((SwLayoutFrm*)pFrm)->GetFmt())->IsInCache()) ),
2247 [ + + + + ]: 477405 : pConstructor( pFrm )
2248 : : {
2249 : 159135 : }
2250 : :
2251 : : /*************************************************************************/
2252 : :
2253 : 13763 : SwCacheObj *SwBorderAttrAccess::NewObj()
2254 : : {
2255 : 13763 : ((SwModify*)pOwner)->SetInCache( sal_True );
2256 [ + - ]: 13763 : return new SwBorderAttrs( (SwModify*)pOwner, pConstructor );
2257 : : }
2258 : :
2259 : 159135 : SwBorderAttrs *SwBorderAttrAccess::Get()
2260 : : {
2261 : 159135 : return (SwBorderAttrs*)SwCacheAccess::Get();
2262 : : }
2263 : :
2264 : : /*************************************************************************/
2265 : :
2266 : 1446 : SwOrderIter::SwOrderIter( const SwPageFrm *pPg, sal_Bool bFlys ) :
2267 : : pPage( pPg ),
2268 : : pCurrent( 0 ),
2269 : 1446 : bFlysOnly( bFlys )
2270 : : {
2271 : 1446 : }
2272 : :
2273 : : /*************************************************************************/
2274 : :
2275 : 0 : const SdrObject *SwOrderIter::Top()
2276 : : {
2277 : 0 : pCurrent = 0;
2278 [ # # ]: 0 : if ( pPage->GetSortedObjs() )
2279 : : {
2280 : 0 : const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2281 [ # # ]: 0 : if ( pObjs->Count() )
2282 : : {
2283 : 0 : sal_uInt32 nTopOrd = 0;
2284 : 0 : (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2285 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2286 : : {
2287 : 0 : const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2288 [ # # ][ # # ]: 0 : if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
[ # # ]
2289 : 0 : continue;
2290 : 0 : sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2291 [ # # ]: 0 : if ( nTmp >= nTopOrd )
2292 : : {
2293 : 0 : nTopOrd = nTmp;
2294 : 0 : pCurrent = pObj;
2295 : : }
2296 : : }
2297 : : }
2298 : : }
2299 : 0 : return pCurrent;
2300 : : }
2301 : :
2302 : : /*************************************************************************/
2303 : :
2304 : 124 : const SdrObject *SwOrderIter::Bottom()
2305 : : {
2306 : 124 : pCurrent = 0;
2307 [ + - ]: 124 : if ( pPage->GetSortedObjs() )
2308 : : {
2309 : 124 : sal_uInt32 nBotOrd = USHRT_MAX;
2310 : 124 : const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2311 [ + - ]: 124 : if ( pObjs->Count() )
2312 : : {
2313 : 124 : (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2314 [ + + ]: 318 : for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2315 : : {
2316 : 194 : const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2317 [ - + ][ - + ]: 194 : if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
[ + - ]
2318 : 0 : continue;
2319 : 194 : sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2320 [ + - ]: 194 : if ( nTmp < nBotOrd )
2321 : : {
2322 : 194 : nBotOrd = nTmp;
2323 : 194 : pCurrent = pObj;
2324 : : }
2325 : : }
2326 : : }
2327 : : }
2328 : 124 : return pCurrent;
2329 : : }
2330 : :
2331 : : /*************************************************************************/
2332 : :
2333 : 2138 : const SdrObject *SwOrderIter::Next()
2334 : : {
2335 [ + - ]: 2138 : const sal_uInt32 nCurOrd = pCurrent ? pCurrent->GetOrdNumDirect() : 0;
2336 : 2138 : pCurrent = 0;
2337 [ + - ]: 2138 : if ( pPage->GetSortedObjs() )
2338 : : {
2339 : 2138 : sal_uInt32 nOrd = USHRT_MAX;
2340 : 2138 : const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2341 [ + - ]: 2138 : if ( pObjs->Count() )
2342 : : {
2343 : 2138 : (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2344 [ + + ]: 5900 : for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2345 : : {
2346 : 3762 : const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2347 [ - + ][ - + ]: 3762 : if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
[ + - ]
2348 : 0 : continue;
2349 : 3762 : sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2350 [ + + ][ + + ]: 3762 : if ( nTmp > nCurOrd && nTmp < nOrd )
2351 : : {
2352 : 692 : nOrd = nTmp;
2353 : 692 : pCurrent = pObj;
2354 : : }
2355 : : }
2356 : : }
2357 : : }
2358 : 2138 : return pCurrent;
2359 : : }
2360 : :
2361 : : /*************************************************************************/
2362 : :
2363 : 0 : const SdrObject *SwOrderIter::Prev()
2364 : : {
2365 [ # # ]: 0 : const sal_uInt32 nCurOrd = pCurrent ? pCurrent->GetOrdNumDirect() : 0;
2366 : 0 : pCurrent = 0;
2367 [ # # ]: 0 : if ( pPage->GetSortedObjs() )
2368 : : {
2369 : 0 : const SwSortedObjs *pObjs = pPage->GetSortedObjs();
2370 [ # # ]: 0 : if ( pObjs->Count() )
2371 : : {
2372 : 0 : sal_uInt32 nOrd = 0;
2373 : 0 : (*pObjs)[0]->GetDrawObj()->GetOrdNum(); //Aktualisieren erzwingen!
2374 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2375 : : {
2376 : 0 : const SdrObject* pObj = (*pObjs)[i]->GetDrawObj();
2377 [ # # ][ # # ]: 0 : if ( bFlysOnly && !pObj->ISA(SwVirtFlyDrawObj) )
[ # # ]
2378 : 0 : continue;
2379 : 0 : sal_uInt32 nTmp = pObj->GetOrdNumDirect();
2380 [ # # ][ # # ]: 0 : if ( nTmp < nCurOrd && nTmp >= nOrd )
2381 : : {
2382 : 0 : nOrd = nTmp;
2383 : 0 : pCurrent = pObj;
2384 : : }
2385 : : }
2386 : : }
2387 : : }
2388 : 0 : return pCurrent;
2389 : : }
2390 : :
2391 : : /*************************************************************************/
2392 : :
2393 : : //Unterstruktur eines LayoutFrms fuer eine Aktion aufheben und wieder
2394 : : //restaurieren.
2395 : : //Neuer Algorithmus: Es ist unuetz jeden Nachbarn einzeln zu betrachten und
2396 : : //die Pointer sauber zu setzen (Upper, Nachbarn, usw.)
2397 : : //Es reicht vollkommen jeweils eine Einzelkette zu loesen, und mit dem
2398 : : //Letzen der Einzelkette nachzuschauen ob noch eine weitere Kette
2399 : : //angeheangt werden muss. Es brauchen nur die Pointer korrigiert werden,
2400 : : //die zur Verkettung notwendig sind. So koennen Beipspielsweise die Pointer
2401 : : //auf die Upper auf den alten Uppern stehenbleiben. Korrigiert werden die
2402 : : //Pointer dann im RestoreCntnt. Zwischenzeitlich ist sowieso jeder Zugriff
2403 : : //verboten.
2404 : : //Unterwegs werden die Flys bei der Seite abgemeldet.
2405 : :
2406 : : // #115759# - 'remove' also drawing object from page and
2407 : : // at-fly anchored objects from page
2408 : 0 : void lcl_RemoveObjsFromPage( SwFrm* _pFrm )
2409 : : {
2410 : : OSL_ENSURE( _pFrm->GetDrawObjs(), "Keine DrawObjs fuer lcl_RemoveFlysFromPage." );
2411 : 0 : SwSortedObjs &rObjs = *_pFrm->GetDrawObjs();
2412 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2413 : : {
2414 : 0 : SwAnchoredObject* pObj = rObjs[i];
2415 : : // #115759# - reset member, at which the anchored
2416 : : // object orients its vertical position
2417 : 0 : pObj->ClearVertPosOrientFrm();
2418 : : // #i43913#
2419 : 0 : pObj->ResetLayoutProcessBools();
2420 : : // #115759# - remove also lower objects of as-character
2421 : : // anchored Writer fly frames from page
2422 [ # # ]: 0 : if ( pObj->ISA(SwFlyFrm) )
2423 : : {
2424 [ # # ]: 0 : SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
2425 : :
2426 : : // #115759# - remove also direct lowers of Writer
2427 : : // fly frame from page
2428 [ # # ]: 0 : if ( pFlyFrm->GetDrawObjs() )
2429 : : {
2430 : 0 : ::lcl_RemoveObjsFromPage( pFlyFrm );
2431 : : }
2432 : :
2433 : 0 : SwCntntFrm* pCnt = pFlyFrm->ContainsCntnt();
2434 [ # # ]: 0 : while ( pCnt )
2435 : : {
2436 [ # # ]: 0 : if ( pCnt->GetDrawObjs() )
2437 : 0 : ::lcl_RemoveObjsFromPage( pCnt );
2438 : 0 : pCnt = pCnt->GetNextCntntFrm();
2439 : : }
2440 [ # # ]: 0 : if ( pFlyFrm->IsFlyFreeFrm() )
2441 : : {
2442 : : // #i28701# - use new method <GetPageFrm()>
2443 : 0 : pFlyFrm->GetPageFrm()->RemoveFlyFromPage( pFlyFrm );
2444 : : }
2445 : : }
2446 : : // #115759# - remove also drawing objects from page
2447 [ # # ]: 0 : else if ( pObj->ISA(SwAnchoredDrawObject) )
2448 : : {
2449 [ # # ]: 0 : if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR)
2450 : : {
2451 : : pObj->GetPageFrm()->RemoveDrawObjFromPage(
2452 : 0 : *(static_cast<SwAnchoredDrawObject*>(pObj)) );
2453 : : }
2454 : : }
2455 : : }
2456 : 0 : }
2457 : :
2458 : 82 : SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart )
2459 : : {
2460 [ + + ][ + + ]: 82 : if( pLay->IsSctFrm() && pLay->Lower() && pLay->Lower()->IsColumnFrm() )
[ + + ][ + + ]
2461 : 18 : lcl_RemoveFtns( (SwColumnFrm*)pLay->Lower(), sal_True, sal_True );
2462 : :
2463 : : SwFrm *pSav;
2464 [ + + ]: 82 : if ( 0 == (pSav = pLay->ContainsAny()) )
2465 : 46 : return 0;
2466 : :
2467 [ + + ][ - + ]: 36 : if( pSav->IsInFtn() && !pLay->IsInFtn() )
[ - + ]
2468 : : {
2469 [ # # ]: 0 : do
[ # # # # ]
2470 : 0 : pSav = pSav->FindNext();
2471 : 0 : while( pSav && pSav->IsInFtn() );
2472 [ # # ][ # # ]: 0 : if( !pSav || !pLay->IsAnLower( pSav ) )
[ # # ]
2473 : 0 : return NULL;
2474 : : }
2475 : :
2476 : : // Tables should be saved as a whole, expection:
2477 : : // The contents of a section or a cell inside a table should be saved
2478 [ + + ][ - + ]: 36 : if ( pSav->IsInTab() && !( ( pLay->IsSctFrm() || pLay->IsCellFrm() ) && pLay->IsInTab() ) )
[ # # ][ - + ]
[ - + ]
2479 [ # # ]: 0 : while ( !pSav->IsTabFrm() )
2480 : 0 : pSav = pSav->GetUpper();
2481 : :
2482 [ + - ]: 36 : if( pSav->IsInSct() )
2483 : : { // Jetzt wird der oberste Bereich gesucht, der innerhalb von pLay ist.
2484 : 36 : SwFrm* pSect = pLay->FindSctFrm();
2485 : 36 : SwFrm *pTmp = pSav;
2486 [ - + ]: 36 : do
2487 : : {
2488 : 36 : pSav = pTmp;
2489 [ + - ]: 36 : pTmp = pSav->GetUpper() ? pSav->GetUpper()->FindSctFrm() : NULL;
2490 : : } while ( pTmp != pSect );
2491 : : }
2492 : :
2493 : 36 : SwFrm *pFloat = pSav;
2494 [ + + ]: 36 : if( !pStart )
2495 : 30 : pStart = pSav;
2496 : 36 : sal_Bool bGo = pStart == pSav;
2497 [ - + ]: 36 : do
2498 : : {
2499 [ + + ]: 36 : if( bGo )
2500 : 30 : pFloat->GetUpper()->pLower = 0; //Die Teilkette ausklinken.
2501 : :
2502 : : //Das Ende der Teilkette suchen, unterwegs die Flys abmelden.
2503 [ + - ]: 6 : do
2504 : : {
2505 [ + + ]: 42 : if( bGo )
2506 : : {
2507 [ + - ]: 36 : if ( pFloat->IsCntntFrm() )
2508 : : {
2509 [ - + ]: 36 : if ( pFloat->GetDrawObjs() )
2510 : 0 : ::lcl_RemoveObjsFromPage( (SwCntntFrm*)pFloat );
2511 : : }
2512 [ # # ][ # # ]: 0 : else if ( pFloat->IsTabFrm() || pFloat->IsSctFrm() )
[ # # ]
2513 : : {
2514 : 0 : SwCntntFrm *pCnt = ((SwLayoutFrm*)pFloat)->ContainsCntnt();
2515 [ # # ]: 0 : if( pCnt )
2516 : : {
2517 [ # # ]: 0 : do
[ # # # # ]
2518 [ # # ]: 0 : { if ( pCnt->GetDrawObjs() )
2519 : 0 : ::lcl_RemoveObjsFromPage( pCnt );
2520 : 0 : pCnt = pCnt->GetNextCntntFrm();
2521 : 0 : } while ( pCnt && ((SwLayoutFrm*)pFloat)->IsAnLower( pCnt ) );
2522 : : }
2523 : : }
2524 : : else {
2525 : : OSL_ENSURE( !pFloat, "Neuer Float-Frame?" );
2526 : : }
2527 : : }
2528 [ + + ]: 42 : if ( pFloat->GetNext() )
2529 : : {
2530 [ - + ]: 6 : if( bGo )
2531 : 0 : pFloat->pUpper = NULL;
2532 : 6 : pFloat = pFloat->GetNext();
2533 [ + - ][ + - ]: 6 : if( !bGo && pFloat == pStart )
2534 : : {
2535 : 6 : bGo = sal_True;
2536 : 6 : pFloat->pPrev->pNext = NULL;
2537 : 6 : pFloat->pPrev = NULL;
2538 : : }
2539 : : }
2540 : : else
2541 : 36 : break;
2542 : :
2543 : : } while ( pFloat );
2544 : :
2545 : : //Die naechste Teilkette suchen und die Ketten miteinander verbinden.
2546 : 36 : SwFrm *pTmp = pFloat->FindNext();
2547 [ + - ]: 36 : if( bGo )
2548 : 36 : pFloat->pUpper = NULL;
2549 : :
2550 [ + + ]: 36 : if( !pLay->IsInFtn() )
2551 [ + - ][ - + ]: 34 : while( pTmp && pTmp->IsInFtn() )
[ - + ]
2552 : 0 : pTmp = pTmp->FindNext();
2553 : :
2554 [ + - ]: 36 : if ( !pLay->IsAnLower( pTmp ) )
2555 : 36 : pTmp = 0;
2556 : :
2557 [ - + ][ # # ]: 36 : if ( pTmp && bGo )
2558 : : {
2559 : 0 : pFloat->pNext = pTmp; //Die beiden Ketten verbinden.
2560 : 0 : pFloat->pNext->pPrev = pFloat;
2561 : : }
2562 : 36 : pFloat = pTmp;
2563 [ - + ][ # # ]: 36 : bGo = bGo || ( pStart == pFloat );
2564 : : } while ( pFloat );
2565 : :
2566 [ + - ]: 82 : return bGo ? pStart : NULL;
2567 : : }
2568 : :
2569 : : // #115759# - add also drawing objects to page and at-fly
2570 : : // anchored objects to page
2571 : 0 : void lcl_AddObjsToPage( SwFrm* _pFrm, SwPageFrm* _pPage )
2572 : : {
2573 : : OSL_ENSURE( _pFrm->GetDrawObjs(), "Keine DrawObjs fuer lcl_AddFlysToPage." );
2574 : 0 : SwSortedObjs &rObjs = *_pFrm->GetDrawObjs();
2575 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2576 : : {
2577 : 0 : SwAnchoredObject* pObj = rObjs[i];
2578 : :
2579 : : // #115759# - unlock position of anchored object
2580 : : // in order to get the object's position calculated.
2581 : 0 : pObj->UnlockPosition();
2582 : : // #115759# - add also lower objects of as-character
2583 : : // anchored Writer fly frames from page
2584 [ # # ]: 0 : if ( pObj->ISA(SwFlyFrm) )
2585 : : {
2586 [ # # ]: 0 : SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pObj);
2587 [ # # ]: 0 : if ( pObj->ISA(SwFlyFreeFrm) )
2588 : : {
2589 : 0 : _pPage->AppendFlyToPage( pFlyFrm );
2590 : : }
2591 : 0 : pFlyFrm->_InvalidatePos();
2592 : 0 : pFlyFrm->_InvalidateSize();
2593 : 0 : pFlyFrm->InvalidatePage( _pPage );
2594 : :
2595 : : // #115759# - add also at-fly anchored objects
2596 : : // to page
2597 [ # # ]: 0 : if ( pFlyFrm->GetDrawObjs() )
2598 : : {
2599 : 0 : ::lcl_AddObjsToPage( pFlyFrm, _pPage );
2600 : : }
2601 : :
2602 : 0 : SwCntntFrm *pCnt = pFlyFrm->ContainsCntnt();
2603 [ # # ]: 0 : while ( pCnt )
2604 : : {
2605 [ # # ]: 0 : if ( pCnt->GetDrawObjs() )
2606 : 0 : ::lcl_AddObjsToPage( pCnt, _pPage );
2607 : 0 : pCnt = pCnt->GetNextCntntFrm();
2608 : : }
2609 : : }
2610 : : // #115759# - remove also drawing objects from page
2611 [ # # ]: 0 : else if ( pObj->ISA(SwAnchoredDrawObject) )
2612 : : {
2613 [ # # ]: 0 : if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR)
2614 : : {
2615 : 0 : pObj->InvalidateObjPos();
2616 : : _pPage->AppendDrawObjToPage(
2617 : 0 : *(static_cast<SwAnchoredDrawObject*>(pObj)) );
2618 : : }
2619 : : }
2620 : : }
2621 : 0 : }
2622 : :
2623 : 36 : void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGrow )
2624 : : {
2625 : : OSL_ENSURE( pSav && pParent, "Kein Save oder Parent fuer Restore." );
2626 [ - + ][ # # ]: 36 : SWRECTFN( pParent )
[ # # ][ - + ]
2627 : :
2628 : : //Wenn es bereits FlowFrms unterhalb des neuen Parent gibt, so wird die
2629 : : //Kette, beginnend mit pSav, hinter dem letzten angehaengt.
2630 : : //Die Teile werden kurzerhand insertet und geeignet invalidiert.
2631 : : //Unterwegs werden die Flys der CntntFrms bei der Seite angemeldet.
2632 : :
2633 : 36 : SwPageFrm *pPage = pParent->FindPageFrm();
2634 : :
2635 [ + - ]: 36 : if ( pPage )
2636 : 36 : pPage->InvalidatePage( pPage ); //Invalides Layout anmelden.
2637 : :
2638 : : //Vorgaenger festellen und die Verbindung herstellen bzw. initialisieren.
2639 : 36 : pSav->pPrev = pSibling;
2640 : : SwFrm* pNxt;
2641 [ + + ]: 36 : if ( pSibling )
2642 : : {
2643 : 2 : pNxt = pSibling->pNext;
2644 : 2 : pSibling->pNext = pSav;
2645 : 2 : pSibling->_InvalidatePrt();
2646 : 2 : ((SwCntntFrm*)pSibling)->InvalidatePage( pPage );//Invaliden Cntnt anmelden.
2647 [ + - ]: 2 : if ( ((SwCntntFrm*)pSibling)->GetFollow() )
2648 : 2 : pSibling->Prepare( PREP_CLEAR, 0, sal_False );
2649 : : }
2650 : : else
2651 : 34 : { pNxt = pParent->pLower;
2652 : 34 : pParent->pLower = pSav;
2653 : 34 : pSav->pUpper = pParent; //Schon mal setzen, sonst ist fuer das
2654 : : //invalidate der Parent (z.B. ein Fly) nicht klar.
2655 : : //Invaliden Cntnt anmelden.
2656 [ + - ]: 34 : if ( pSav->IsCntntFrm() )
2657 : 34 : ((SwCntntFrm*)pSav)->InvalidatePage( pPage );
2658 : : else
2659 : : { // pSav koennte auch ein leerer SectFrm sein
2660 : 0 : SwCntntFrm* pCnt = pParent->ContainsCntnt();
2661 [ # # ]: 0 : if( pCnt )
2662 : 0 : pCnt->InvalidatePage( pPage );
2663 : : }
2664 : : }
2665 : :
2666 : : //Der Parent muss entsprechend gegrow'ed werden.
2667 : 36 : SwTwips nGrowVal = 0;
2668 : : SwFrm* pLast;
2669 [ - + ]: 36 : do
2670 : 36 : { pSav->pUpper = pParent;
2671 [ + - ]: 36 : nGrowVal += (pSav->Frm().*fnRect->fnGetHeight)();
2672 : 36 : pSav->_InvalidateAll();
2673 : :
2674 : : //Jetzt die Flys anmelden, fuer TxtFrms gleich geeignet invalidieren.
2675 [ + - ]: 36 : if ( pSav->IsCntntFrm() )
2676 : : {
2677 [ + - + + ]: 72 : if ( pSav->IsTxtFrm() &&
[ + + ]
2678 : 36 : ((SwTxtFrm*)pSav)->GetCacheIdx() != USHRT_MAX )
2679 : 22 : ((SwTxtFrm*)pSav)->Init(); //Ich bin sein Freund.
2680 : :
2681 [ + - ][ - + ]: 36 : if ( pPage && pSav->GetDrawObjs() )
[ - + ]
2682 : 0 : ::lcl_AddObjsToPage( (SwCntntFrm*)pSav, pPage );
2683 : : }
2684 : : else
2685 : 0 : { SwCntntFrm *pBlub = ((SwLayoutFrm*)pSav)->ContainsCntnt();
2686 [ # # ]: 0 : if( pBlub )
2687 : : {
2688 [ # # ]: 0 : do
[ # # # # ]
2689 [ # # ][ # # ]: 0 : { if ( pPage && pBlub->GetDrawObjs() )
[ # # ]
2690 : 0 : ::lcl_AddObjsToPage( pBlub, pPage );
2691 [ # # ]: 0 : if( pBlub->IsTxtFrm() && ((SwTxtFrm*)pBlub)->HasFtn() &&
[ # # # # ]
[ # # ]
2692 : 0 : ((SwTxtFrm*)pBlub)->GetCacheIdx() != USHRT_MAX )
2693 : 0 : ((SwTxtFrm*)pBlub)->Init(); //Ich bin sein Freund.
2694 : 0 : pBlub = pBlub->GetNextCntntFrm();
2695 : 0 : } while ( pBlub && ((SwLayoutFrm*)pSav)->IsAnLower( pBlub ));
2696 : : }
2697 : : }
2698 : 36 : pLast = pSav;
2699 : 36 : pSav = pSav->GetNext();
2700 : :
2701 : : } while ( pSav );
2702 : :
2703 [ + + ]: 36 : if( pNxt )
2704 : : {
2705 : 8 : pLast->pNext = pNxt;
2706 : 8 : pNxt->pPrev = pLast;
2707 : : }
2708 : :
2709 [ + - ]: 36 : if ( bGrow )
2710 : 36 : pParent->Grow( nGrowVal );
2711 : 36 : }
2712 : :
2713 : : /*************************************************************************
2714 : : |*
2715 : : |* SqRt() Berechnung der Quadratwurzel, damit die math.lib
2716 : : |* nicht auch noch dazugelinkt werden muss.
2717 : : |*
2718 : : |*************************************************************************/
2719 : :
2720 : 246 : sal_uLong SqRt( BigInt nX )
2721 : : {
2722 [ + - ]: 246 : BigInt nErg = 1;
2723 : :
2724 [ + - ][ + - ]: 246 : if ( !nX.IsNeg() )
2725 : : {
2726 [ + - ]: 246 : BigInt nOldErg = 1;
2727 [ + + ]: 1722 : for ( int i = 0; i <= 5; i++ )
2728 : : {
2729 [ + - ][ + - ]: 1476 : nErg = (nOldErg + (nX / nOldErg)) / BigInt(2);
[ + - ][ + - ]
[ + - ]
2730 [ + - ]: 1476 : nOldErg = nErg;
2731 : : }
2732 : : }
2733 [ + - ][ + - ]: 246 : return nErg >= BigInt(SAL_MAX_UINT32) ? ULONG_MAX : (sal_uLong)nErg;
[ + - ][ + - ]
2734 : : }
2735 : :
2736 : : /*************************************************************************/
2737 : :
2738 : 1389 : SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
2739 : : sal_Bool bOdd, bool bFirst, sal_Bool bInsertEmpty, sal_Bool bFtn,
2740 : : SwFrm *pSibling )
2741 : : {
2742 : : SwPageFrm *pRet;
2743 : 1389 : SwDoc *pDoc = ((SwLayoutFrm*)pUpper)->GetFmt()->GetDoc();
2744 : 1389 : SwFrmFmt *pFmt = 0;
2745 : : // rDesc can't know if the first page will be 'left' or 'right', so if
2746 : : // first is shared, let's ignore first here.
2747 [ + + ][ + + ]: 1389 : if (bFirst && !rDesc.IsFirstShared())
[ + + ]
2748 : 1270 : pFmt = rDesc.GetFirstFmt();
2749 : : else
2750 [ + + ]: 119 : pFmt = bOdd ? rDesc.GetRightFmt() : rDesc.GetLeftFmt();
2751 : : //Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben
2752 : : //eine Leerseite einfuegen.
2753 [ + + ]: 1389 : if ( !pFmt )
2754 : : {
2755 [ + - ]: 3 : pFmt = bOdd ? rDesc.GetLeftFmt() : rDesc.GetRightFmt();
2756 : : OSL_ENSURE( pFmt, "Descriptor without any format?!" );
2757 : 3 : bInsertEmpty = !bInsertEmpty;
2758 : : }
2759 [ + + ]: 1389 : if( bInsertEmpty )
2760 : : {
2761 : 0 : SwPageDesc *pTmpDesc = pSibling && pSibling->GetPrev() ?
2762 [ - + # # ]: 3 : ((SwPageFrm*)pSibling->GetPrev())->GetPageDesc() : &rDesc;
2763 [ + - ]: 3 : pRet = new SwPageFrm( pDoc->GetEmptyPageFmt(), pUpper, pTmpDesc );
2764 : 3 : pRet->Paste( pUpper, pSibling );
2765 : 3 : pRet->PreparePage( bFtn );
2766 : : }
2767 [ + - ]: 1389 : pRet = new SwPageFrm( pFmt, pUpper, &rDesc );
2768 : 1389 : pRet->Paste( pUpper, pSibling );
2769 : 1389 : pRet->PreparePage( bFtn );
2770 [ - + ]: 1389 : if ( pRet->GetNext() )
2771 : 0 : ((SwRootFrm*)pRet->GetUpper())->AssertPageFlys( pRet );
2772 : 1389 : return pRet;
2773 : : }
2774 : :
2775 : :
2776 : : /*************************************************************************
2777 : : |*
2778 : : |* RegistFlys(), Regist() Die beiden folgenden Methoden durchsuchen rekursiv
2779 : : |* eine Layoutstruktur und melden alle FlyFrms, die einen beliebigen Frm
2780 : : |* innerhalb der Struktur als Anker haben bei der Seite an.
2781 : : |*
2782 : : |*************************************************************************/
2783 : :
2784 : 9 : void lcl_Regist( SwPageFrm *pPage, const SwFrm *pAnch )
2785 : : {
2786 : 9 : SwSortedObjs *pObjs = (SwSortedObjs*)pAnch->GetDrawObjs();
2787 [ + + ]: 18 : for ( sal_uInt16 i = 0; i < pObjs->Count(); ++i )
2788 : : {
2789 : 9 : SwAnchoredObject* pObj = (*pObjs)[i];
2790 [ + + ]: 9 : if ( pObj->ISA(SwFlyFrm) )
2791 : : {
2792 [ + - ]: 6 : SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pObj);
2793 : : //Ggf. ummelden, nicht anmelden wenn bereits bekannt.
2794 : : // #i28701# - use new method <GetPageFrm()>
2795 : 6 : SwPageFrm *pPg = pFly->IsFlyFreeFrm()
2796 [ + - ]: 6 : ? pFly->GetPageFrm() : pFly->FindPageFrm();
2797 [ + - ]: 6 : if ( pPg != pPage )
2798 : : {
2799 [ - + ]: 6 : if ( pPg )
2800 : 0 : pPg->RemoveFlyFromPage( pFly );
2801 : 6 : pPage->AppendFlyToPage( pFly );
2802 : : }
2803 : 6 : ::RegistFlys( pPage, pFly );
2804 : : }
2805 : : else
2806 : : {
2807 : : // #i87493#
2808 [ + - ]: 3 : if ( pPage != pObj->GetPageFrm() )
2809 : : {
2810 : : // #i28701#
2811 [ - + ]: 3 : if ( pObj->GetPageFrm() )
2812 : 0 : pObj->GetPageFrm()->RemoveDrawObjFromPage( *pObj );
2813 : 3 : pPage->AppendDrawObjToPage( *pObj );
2814 : : }
2815 : : }
2816 : :
2817 : 9 : const SwFlyFrm* pFly = pAnch->FindFlyFrm();
2818 [ - + ][ - + : 9 : if ( pFly &&
# # # # ]
2819 : 0 : pObj->GetDrawObj()->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() &&
2820 : 0 : pObj->GetDrawObj()->GetPage() )
2821 : : {
2822 : 0 : pObj->DrawObj()->GetPage()->SetObjectOrdNum(
2823 : : pObj->GetDrawObj()->GetOrdNumDirect(),
2824 : 0 : pFly->GetVirtDrawObj()->GetOrdNumDirect() + 1 );
2825 : : }
2826 : : }
2827 : 9 : }
2828 : :
2829 : 4941 : void RegistFlys( SwPageFrm *pPage, const SwLayoutFrm *pLay )
2830 : : {
2831 [ - + ]: 4941 : if ( pLay->GetDrawObjs() )
2832 : 0 : ::lcl_Regist( pPage, pLay );
2833 : 4941 : const SwFrm *pFrm = pLay->Lower();
2834 [ + + ]: 9223 : while ( pFrm )
2835 : : {
2836 [ + + ]: 4282 : if ( pFrm->IsLayoutFrm() )
2837 : 2510 : ::RegistFlys( pPage, (const SwLayoutFrm*)pFrm );
2838 [ + + ]: 1772 : else if ( pFrm->GetDrawObjs() )
2839 : 9 : ::lcl_Regist( pPage, pFrm );
2840 : 4282 : pFrm = pFrm->GetNext();
2841 : : }
2842 : 4941 : }
2843 : :
2844 : : /*************************************************************************
2845 : : |*
2846 : : |* void Notify()
2847 : : |*
2848 : : |* Beschreibung Benachrichtigt den Hintergrund je nach der
2849 : : |* Veraenderung zwischen altem und neuem Rechteckt.
2850 : : |*
2851 : : |*************************************************************************/
2852 : :
2853 : 1482 : void Notify( SwFlyFrm *pFly, SwPageFrm *pOld, const SwRect &rOld,
2854 : : const SwRect* pOldPrt )
2855 : : {
2856 [ + - ]: 1482 : const SwRect aFrm( pFly->GetObjRectWithSpaces() );
2857 [ + + ]: 1482 : if ( rOld.Pos() != aFrm.Pos() )
2858 : : { //Positionsaenderung, alten und neuen Bereich invalidieren
2859 [ + - ]: 1210 : if ( rOld.HasArea() &&
[ + - + + ]
[ + + ]
2860 [ + - ][ + - ]: 605 : rOld.Left()+pFly->GetFmt()->GetLRSpace().GetLeft() < FAR_AWAY )
2861 : : {
2862 [ + - ]: 26 : pFly->NotifyBackground( pOld, rOld, PREP_FLY_LEAVE );
2863 : : }
2864 [ + - ][ + - ]: 605 : pFly->NotifyBackground( pFly->FindPageFrm(), aFrm, PREP_FLY_ARRIVE );
2865 : : }
2866 [ + + ]: 877 : else if ( rOld.SSize() != aFrm.SSize() )
2867 : : { //Groessenaenderung, den Bereich der Verlassen wurde bzw. jetzt
2868 : : //ueberdeckt wird invalidieren.
2869 : : //Der Einfachheit halber wird hier bewusst jeweils ein Twip
2870 : : //unnoetig invalidiert.
2871 : :
2872 : 248 : ViewShell *pSh = pFly->getRootFrm()->GetCurrShell();
2873 [ + - ][ + - ]: 248 : if( pSh && rOld.HasArea() )
[ + - ][ + - ]
2874 [ + - ]: 248 : pSh->InvalidateWindows( rOld );
2875 : :
2876 : : // #i51941# - consider case that fly frame isn't
2877 : : // registered at the old page <pOld>
2878 [ + - ]: 248 : SwPageFrm* pPageFrm = pFly->FindPageFrm();
2879 [ + + ]: 248 : if ( pOld != pPageFrm )
2880 : : {
2881 [ + - ]: 26 : pFly->NotifyBackground( pPageFrm, aFrm, PREP_FLY_ARRIVE );
2882 : : }
2883 : :
2884 [ - + ]: 248 : if ( rOld.Left() != aFrm.Left() )
2885 : : {
2886 : 0 : SwRect aTmp( rOld );
2887 [ # # ]: 0 : aTmp.Union( aFrm );
2888 : 0 : aTmp.Left( Min(aFrm.Left(), rOld.Left()) );
2889 : 0 : aTmp.Right( Max(aFrm.Left(), rOld.Left()) );
2890 [ # # ]: 0 : pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2891 : : }
2892 : 248 : SwTwips nOld = rOld.Right();
2893 : 248 : SwTwips nNew = aFrm.Right();
2894 [ + + ]: 248 : if ( nOld != nNew )
2895 : : {
2896 : 4 : SwRect aTmp( rOld );
2897 [ + - ]: 4 : aTmp.Union( aFrm );
2898 : 4 : aTmp.Left( Min(nNew, nOld) );
2899 : 4 : aTmp.Right( Max(nNew, nOld) );
2900 [ + - ]: 4 : pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2901 : : }
2902 [ - + ]: 248 : if ( rOld.Top() != aFrm.Top() )
2903 : : {
2904 : 0 : SwRect aTmp( rOld );
2905 [ # # ]: 0 : aTmp.Union( aFrm );
2906 : 0 : aTmp.Top( Min(aFrm.Top(), rOld.Top()) );
2907 : 0 : aTmp.Bottom( Max(aFrm.Top(), rOld.Top()) );
2908 [ # # ]: 0 : pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2909 : : }
2910 : 248 : nOld = rOld.Bottom();
2911 : 248 : nNew = aFrm.Bottom();
2912 [ + + ]: 248 : if ( nOld != nNew )
2913 : : {
2914 : 244 : SwRect aTmp( rOld );
2915 [ + - ]: 244 : aTmp.Union( aFrm );
2916 : 244 : aTmp.Top( Min(nNew, nOld) );
2917 : 244 : aTmp.Bottom( Max(nNew, nOld) );
2918 [ + - ]: 244 : pFly->NotifyBackground( pOld, aTmp, PREP_FLY_CHGD );
2919 : : }
2920 : : }
2921 [ + - ]: 637 : else if ( pOldPrt && *pOldPrt != pFly->Prt() &&
[ + + - + ]
[ - + ]
2922 [ + - ][ + - ]: 8 : pFly->GetFmt()->GetSurround().IsContour() )
2923 : : {
2924 : : // #i24097#
2925 [ # # ][ # # ]: 0 : pFly->NotifyBackground( pFly->FindPageFrm(), aFrm, PREP_FLY_ARRIVE );
2926 : : }
2927 : 1482 : }
2928 : :
2929 : : /*************************************************************************/
2930 : :
2931 : 1171 : void lcl_CheckFlowBack( SwFrm* pFrm, const SwRect &rRect )
2932 : : {
2933 : 1171 : SwTwips nBottom = rRect.Bottom();
2934 [ + + ]: 2790 : while( pFrm )
2935 : : {
2936 [ + + ]: 1619 : if( pFrm->IsLayoutFrm() )
2937 : : {
2938 [ + + ]: 983 : if( rRect.IsOver( pFrm->Frm() ) )
2939 : 781 : lcl_CheckFlowBack( ((SwLayoutFrm*)pFrm)->Lower(), rRect );
2940 : : }
2941 [ + + ][ + + ]: 636 : else if( !pFrm->GetNext() && nBottom > pFrm->Frm().Bottom() )
[ + + ]
2942 : : {
2943 [ + - ][ + + ]: 290 : if( pFrm->IsCntntFrm() && ((SwCntntFrm*)pFrm)->HasFollow() )
[ + + ]
2944 : 2 : pFrm->InvalidateSize();
2945 : : else
2946 : 288 : pFrm->InvalidateNextPos();
2947 : : }
2948 : 1619 : pFrm = pFrm->GetNext();
2949 : : }
2950 : 1171 : }
2951 : :
2952 : 4719 : void lcl_NotifyCntnt( const SdrObject *pThis, SwCntntFrm *pCnt,
2953 : : const SwRect &rRect, const PrepareHint eHint )
2954 : : {
2955 [ + + ]: 4719 : if ( pCnt->IsTxtFrm() )
2956 : : {
2957 : 4665 : SwRect aCntPrt( pCnt->Prt() );
2958 : 4665 : aCntPrt.Pos() += pCnt->Frm().Pos();
2959 [ + + ]: 4665 : if ( eHint == PREP_FLY_ATTR_CHG )
2960 : : {
2961 : : // #i35640# - use given rectangle <rRect> instead
2962 : : // of current bound rectangle
2963 [ + - ][ + + ]: 76 : if ( aCntPrt.IsOver( rRect ) )
2964 [ + - ]: 40 : pCnt->Prepare( PREP_FLY_ATTR_CHG );
2965 : : }
2966 : : // #i23129# - only invalidate, if the text frame
2967 : : // printing area overlaps with the given rectangle.
2968 [ + - ][ + + ]: 4589 : else if ( aCntPrt.IsOver( rRect ) )
2969 [ + - ][ + - ]: 573 : pCnt->Prepare( eHint, (void*)&aCntPrt._Intersection( rRect ) );
2970 [ + + ]: 4665 : if ( pCnt->GetDrawObjs() )
2971 : : {
2972 : 700 : const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
2973 [ + - ][ + + ]: 5938 : for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
2974 : : {
2975 [ + - ]: 1273 : SwAnchoredObject* pObj = rObjs[i];
2976 [ + - ][ + - ]: 1273 : if ( pObj->ISA(SwFlyFrm) )
[ + + ]
2977 : : {
2978 [ + - ]: 669 : SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pObj);
2979 [ + + ]: 669 : if ( pFly->IsFlyInCntFrm() )
2980 : : {
2981 [ + - ]: 32 : SwCntntFrm *pCntnt = pFly->ContainsCntnt();
2982 [ + + ]: 64 : while ( pCntnt )
2983 : : {
2984 [ + - ]: 32 : ::lcl_NotifyCntnt( pThis, pCntnt, rRect, eHint );
2985 [ + - ]: 32 : pCntnt = pCntnt->GetNextCntntFrm();
2986 : : }
2987 : : }
2988 : : }
2989 : : }
2990 : : }
2991 : : }
2992 : 4719 : }
2993 : :
2994 : 866 : void Notify_Background( const SdrObject* pObj,
2995 : : SwPageFrm* pPage,
2996 : : const SwRect& rRect,
2997 : : const PrepareHint eHint,
2998 : : const sal_Bool bInva )
2999 : : {
3000 : :
3001 : : //Wenn der Frm gerade erstmalig sinnvoll positioniert wurde, braucht der
3002 : : //alte Bereich nicht benachrichtigt werden.
3003 [ + + ][ + + ]: 866 : if ( eHint == PREP_FLY_LEAVE && rRect.Top() == FAR_AWAY )
[ + + ]
3004 : 866 : return;
3005 : :
3006 : : SwLayoutFrm* pArea;
3007 : 857 : SwFlyFrm *pFlyFrm = 0;
3008 : : SwFrm* pAnchor;
3009 [ + + ]: 857 : if( pObj->ISA(SwVirtFlyDrawObj) )
3010 : : {
3011 : 491 : pFlyFrm = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
3012 : 491 : pAnchor = pFlyFrm->AnchorFrm();
3013 : : }
3014 : : else
3015 : : {
3016 : 366 : pFlyFrm = NULL;
3017 : : pAnchor = const_cast<SwFrm*>(
3018 : 366 : GetUserCall(pObj)->GetAnchoredObj( pObj )->GetAnchorFrm() );
3019 : : }
3020 [ + + ][ - + ]: 857 : if( PREP_FLY_LEAVE != eHint && pAnchor->IsInFly() )
[ - + ]
3021 : 0 : pArea = pAnchor->FindFlyFrm();
3022 : : else
3023 : 857 : pArea = pPage;
3024 : 857 : SwCntntFrm *pCnt = 0;
3025 [ + - ]: 857 : if ( pArea )
3026 : : {
3027 [ + + ]: 857 : if( PREP_FLY_ARRIVE != eHint )
3028 : 390 : lcl_CheckFlowBack( pArea, rRect );
3029 : :
3030 : : //Es reagieren sowieso nur die auf den Anker folgenden auf den Fly, also
3031 : : //brauchen diese nicht abgeklappert werden.
3032 : : //Ausnahme sind ist natuerlich das LEAVE, denn der Fly koennte ja von
3033 : : //"oben" kommen.
3034 : : // Wenn der Anker auf der vorhergehenden Seite liegt, muss ebenfalls
3035 : : // die gesamte Seite abgearbeitet werden. (47722)
3036 : : // OD 2004-05-13 #i28701# - If the wrapping style has to be considered
3037 : : // on the object positioning, the complete area has to be processed,
3038 : : // because content frames before the anchor frame also have to consider
3039 : : // the object for the text wrapping.
3040 : : // #i3317# - The complete area has always been
3041 : : // processed.
3042 : : {
3043 : 857 : pCnt = pArea->ContainsCntnt();
3044 : : }
3045 : : }
3046 : 857 : SwFrm *pLastTab = 0;
3047 : :
3048 [ + + ][ + - ]: 5289 : while ( pCnt && pArea && pArea->IsAnLower( pCnt ) )
[ + + ][ + + ]
3049 : : {
3050 : 4432 : ::lcl_NotifyCntnt( pObj, pCnt, rRect, eHint );
3051 [ + + ]: 4432 : if ( pCnt->IsInTab() )
3052 : : {
3053 : 960 : SwLayoutFrm* pCell = pCnt->GetUpper();
3054 : : // #i40606# - use <GetLastBoundRect()>
3055 : : // instead of <GetCurrentBoundRect()>, because a recalculation
3056 : : // of the bounding rectangle isn't intended here.
3057 [ + + ][ + + ]: 3800 : if ( pCell->IsCellFrm() &&
[ + + ][ + - ]
3058 [ + - ][ + - ]: 1920 : ( pCell->Frm().IsOver( pObj->GetLastBoundRect() ) ||
[ + - ][ + - ]
[ # # ]
3059 [ + - ]: 920 : pCell->Frm().IsOver( rRect ) ) )
3060 : : {
3061 : 48 : const SwFmtVertOrient &rOri = pCell->GetFmt()->GetVertOrient();
3062 [ - + ]: 48 : if ( text::VertOrientation::NONE != rOri.GetVertOrient() )
3063 : 0 : pCell->InvalidatePrt();
3064 : : }
3065 : 960 : SwTabFrm *pTab = pCnt->FindTabFrm();
3066 [ + + ]: 960 : if ( pTab != pLastTab )
3067 : : {
3068 : 40 : pLastTab = pTab;
3069 : : // #i40606# - use <GetLastBoundRect()>
3070 : : // instead of <GetCurrentBoundRect()>, because a recalculation
3071 : : // of the bounding rectangle isn't intended here.
3072 [ + - ][ + - ]: 68 : if ( pTab->Frm().IsOver( pObj->GetLastBoundRect() ) ||
[ + - ][ + + ]
[ - + ][ + - ]
[ + + # # ]
3073 [ + - ]: 28 : pTab->Frm().IsOver( rRect ) )
3074 : : {
3075 [ + - ][ + - ]: 12 : if ( !pFlyFrm || !pFlyFrm->IsLowerOf( pTab ) )
[ + - ]
3076 : 12 : pTab->InvalidatePrt();
3077 : : }
3078 : : }
3079 : : }
3080 : 4432 : pCnt = pCnt->GetNextCntntFrm();
3081 : : }
3082 : : // #108745# Sorry, but this causes nothing but trouble. I remove these lines
3083 : : // taking the risk that the footer frame will have a wrong height
3084 : : // if( pPage->Lower() )
3085 : : // {
3086 : : // SwFrm* pFrm = pPage->Lower();
3087 : : // while( pFrm->GetNext() )
3088 : : // pFrm = pFrm->GetNext();
3089 : : // if( pFrm->IsFooterFrm() &&
3090 : : // ( ( pFrm->Frm().IsOver( pObj->GetBoundRect() ) ||
3091 : : // pFrm->Frm().IsOver( rRect ) ) ) )
3092 : : // pFrm->InvalidateSize();
3093 : : // }
3094 : : // #128702# - make code robust
3095 [ + - ][ + + ]: 857 : if ( pPage && pPage->GetSortedObjs() )
[ + + ]
3096 : : {
3097 : 853 : pObj->GetOrdNum();
3098 : 853 : const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
3099 [ + + ]: 2668 : for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
3100 : : {
3101 : 1815 : SwAnchoredObject* pAnchoredObj = rObjs[i];
3102 [ + + ]: 1815 : if ( pAnchoredObj->ISA(SwFlyFrm) )
3103 : : {
3104 [ + + ]: 901 : if( pAnchoredObj->GetDrawObj() == pObj )
3105 : 491 : continue;
3106 [ + - ]: 410 : SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3107 [ + + ]: 410 : if ( pFly->Frm().Top() == FAR_AWAY )
3108 : 96 : continue;
3109 : :
3110 [ + + + - : 798 : if ( !pFlyFrm ||
+ + ][ + + ]
3111 : 242 : (!pFly->IsLowerOf( pFlyFrm ) &&
3112 : 242 : pFly->GetVirtDrawObj()->GetOrdNumDirect() < pObj->GetOrdNumDirect()))
3113 : : {
3114 : 255 : pCnt = pFly->ContainsCntnt();
3115 [ + + ]: 510 : while ( pCnt )
3116 : : {
3117 : 255 : ::lcl_NotifyCntnt( pObj, pCnt, rRect, eHint );
3118 : 255 : pCnt = pCnt->GetNextCntntFrm();
3119 : : }
3120 : : }
3121 [ + + ]: 314 : if( pFly->IsFlyLayFrm() )
3122 : : {
3123 [ + - ][ - + : 80 : if( pFly->Lower() && pFly->Lower()->IsColumnFrm() &&
# # # # #
# # # ]
[ - + ]
3124 : 0 : pFly->Frm().Bottom() >= rRect.Top() &&
3125 : 0 : pFly->Frm().Top() <= rRect.Bottom() &&
3126 : 0 : pFly->Frm().Right() >= rRect.Left() &&
3127 : 0 : pFly->Frm().Left() <= rRect.Right() )
3128 : : {
3129 : 0 : pFly->InvalidateSize();
3130 : : }
3131 : : }
3132 : : //Flys, die ueber mir liegen muessen/mussten evtl.
3133 : : //ausweichen, wenn sie eine automatische Ausrichtung haben.
3134 : : //das ist unabhaengig von meinem Attribut, weil dies sich
3135 : : //gerade geaendert haben kann und eben deshalb
3136 : : //umformatiert wurde.
3137 [ + - + + ]: 515 : else if ( pFly->IsFlyAtCntFrm() &&
[ + + + - ]
[ + + ]
3138 : 234 : pObj->GetOrdNumDirect() <
3139 : 234 : pFly->GetVirtDrawObj()->GetOrdNumDirect() &&
3140 : 47 : pFlyFrm && !pFly->IsLowerOf( pFlyFrm ) )
3141 : : {
3142 : 47 : const SwFmtHoriOrient &rH = pFly->GetFmt()->GetHoriOrient();
3143 [ - + ][ + + : 61 : if ( text::HoriOrientation::NONE != rH.GetHoriOrient() &&
- + # # #
# # # #
# ]
3144 : 14 : text::HoriOrientation::CENTER != rH.GetHoriOrient() &&
3145 : 0 : ( !pFly->IsAutoPos() || text::RelOrientation::CHAR != rH.GetRelationOrient() ) &&
3146 : 0 : (pFly->Frm().Bottom() >= rRect.Top() &&
3147 : 0 : pFly->Frm().Top() <= rRect.Bottom()) )
3148 : 0 : pFly->InvalidatePos();
3149 : : }
3150 : : }
3151 : : }
3152 : : }
3153 [ + + ][ + - ]: 857 : if ( pFlyFrm && pAnchor->GetUpper() && pAnchor->IsInTab() )//MA_FLY_HEIGHT
[ - + ][ - + ]
3154 : 0 : pAnchor->GetUpper()->InvalidateSize();
3155 : :
3156 : : // #i82258# - make code robust
3157 : 857 : ViewShell* pSh = 0;
3158 [ + - ]: 1714 : if ( bInva && pPage &&
[ + - + + ]
[ + + ]
3159 : 857 : 0 != (pSh = pPage->getRootFrm()->GetCurrShell()) )
3160 : : {
3161 : 815 : pSh->InvalidateWindows( rRect );
3162 : : }
3163 : : }
3164 : :
3165 : : /*************************************************************************
3166 : : |*
3167 : : |* GetVirtualUpper() liefert bei absatzgebundenen Objekten den Upper
3168 : : |* des Ankers. Falls es sich dabei um verkettete Rahmen oder
3169 : : |* Fussnoten handelt, wird ggf. der "virtuelle" Upper ermittelt.
3170 : : |*
3171 : : |*************************************************************************/
3172 : :
3173 : 332 : const SwFrm* GetVirtualUpper( const SwFrm* pFrm, const Point& rPos )
3174 : : {
3175 [ + + ]: 332 : if( pFrm->IsTxtFrm() )
3176 : : {
3177 : 290 : pFrm = pFrm->GetUpper();
3178 [ + + ]: 290 : if( !pFrm->Frm().IsInside( rPos ) )
3179 : : {
3180 [ - + ]: 65 : if( pFrm->IsFtnFrm() )
3181 : : {
3182 : 0 : const SwFtnFrm* pTmp = ((SwFtnFrm*)pFrm)->GetFollow();
3183 [ # # ]: 0 : while( pTmp )
3184 : : {
3185 [ # # ]: 0 : if( pTmp->Frm().IsInside( rPos ) )
3186 : 0 : return pTmp;
3187 : 0 : pTmp = pTmp->GetFollow();
3188 : : }
3189 : : }
3190 : : else
3191 : : {
3192 : 65 : SwFlyFrm* pTmp = (SwFlyFrm*)pFrm->FindFlyFrm();
3193 [ - + ]: 65 : while( pTmp )
3194 : : {
3195 [ # # ]: 0 : if( pTmp->Frm().IsInside( rPos ) )
3196 : 0 : return pTmp;
3197 : 0 : pTmp = pTmp->GetNextLink();
3198 : : }
3199 : : }
3200 : : }
3201 : : }
3202 : 332 : return pFrm;
3203 : : }
3204 : :
3205 : : /*************************************************************************/
3206 : :
3207 : 259 : sal_Bool Is_Lower_Of( const SwFrm *pCurrFrm, const SdrObject* pObj )
3208 : : {
3209 : 259 : Point aPos;
3210 : : const SwFrm* pFrm;
3211 [ + - ][ + + ]: 259 : if( pObj->ISA(SwVirtFlyDrawObj) )
[ + - ]
3212 : : {
3213 : 250 : const SwFlyFrm* pFly = ( (SwVirtFlyDrawObj*)pObj )->GetFlyFrm();
3214 [ + - ]: 250 : pFrm = pFly->GetAnchorFrm();
3215 : 250 : aPos = pFly->Frm().Pos();
3216 : : }
3217 : : else
3218 : : {
3219 [ + - ][ + - ]: 9 : pFrm = ( (SwDrawContact*)GetUserCall(pObj) )->GetAnchorFrm(pObj);
3220 [ + - ]: 9 : aPos = pObj->GetCurrentBoundRect().TopLeft();
3221 : : }
3222 : : OSL_ENSURE( pFrm, "8-( Fly is lost in Space." );
3223 [ + - ]: 259 : pFrm = GetVirtualUpper( pFrm, aPos );
3224 [ + + ]: 766 : do
3225 [ - + ]: 766 : { if ( pFrm == pCurrFrm )
3226 : 0 : return sal_True;
3227 [ - + ]: 766 : if( pFrm->IsFlyFrm() )
3228 : : {
3229 : 0 : aPos = pFrm->Frm().Pos();
3230 [ # # ][ # # ]: 0 : pFrm = GetVirtualUpper( ((const SwFlyFrm*)pFrm)->GetAnchorFrm(), aPos );
3231 : : }
3232 : : else
3233 : 766 : pFrm = pFrm->GetUpper();
3234 : : } while ( pFrm );
3235 : 259 : return sal_False;
3236 : : }
3237 : :
3238 : 904 : const SwFrm *FindKontext( const SwFrm *pFrm, sal_uInt16 nAdditionalKontextTyp )
3239 : : {
3240 : : //Liefert die Umgebung des Frm in die kein Fly aus einer anderen
3241 : : //Umgebung hineinragen kann.
3242 : : const sal_uInt16 nTyp = FRM_ROOT | FRM_HEADER | FRM_FOOTER | FRM_FTNCONT |
3243 : : FRM_FTN | FRM_FLY |
3244 : : FRM_TAB | FRM_ROW | FRM_CELL |
3245 : 904 : nAdditionalKontextTyp;
3246 [ + - ]: 2593 : do
3247 [ + + ]: 3497 : { if ( pFrm->GetType() & nTyp )
3248 : 904 : break;
3249 : 2593 : pFrm = pFrm->GetUpper();
3250 : : } while( pFrm );
3251 : 904 : return pFrm;
3252 : : }
3253 : :
3254 : 100 : sal_Bool IsFrmInSameKontext( const SwFrm *pInnerFrm, const SwFrm *pFrm )
3255 : : {
3256 : 100 : const SwFrm *pKontext = FindKontext( pInnerFrm, 0 );
3257 : :
3258 : : const sal_uInt16 nTyp = FRM_ROOT | FRM_HEADER | FRM_FOOTER | FRM_FTNCONT |
3259 : : FRM_FTN | FRM_FLY |
3260 : 100 : FRM_TAB | FRM_ROW | FRM_CELL;
3261 [ + + ]: 297 : do
3262 [ + + ]: 394 : { if ( pFrm->GetType() & nTyp )
3263 : : {
3264 [ + + ]: 173 : if( pFrm == pKontext )
3265 : 73 : return sal_True;
3266 [ + + ]: 100 : if( pFrm->IsCellFrm() )
3267 : 24 : return sal_False;
3268 : : }
3269 [ + + ]: 297 : if( pFrm->IsFlyFrm() )
3270 : : {
3271 : 73 : Point aPos( pFrm->Frm().Pos() );
3272 [ + - ][ + - ]: 73 : pFrm = GetVirtualUpper( ((const SwFlyFrm*)pFrm)->GetAnchorFrm(), aPos );
3273 : : }
3274 : : else
3275 : 224 : pFrm = pFrm->GetUpper();
3276 : : } while( pFrm );
3277 : :
3278 : 100 : return sal_False;
3279 : : }
3280 : :
3281 : :
3282 : : //---------------------------------
3283 : :
3284 : 0 : SwTwips lcl_CalcCellRstHeight( SwLayoutFrm *pCell )
3285 : : {
3286 [ # # ][ # # ]: 0 : if ( pCell->Lower()->IsCntntFrm() || pCell->Lower()->IsSctFrm() )
[ # # ]
3287 : : {
3288 : 0 : SwFrm *pLow = pCell->Lower();
3289 : 0 : long nHeight = 0, nFlyAdd = 0;
3290 [ # # ]: 0 : do
3291 : : {
3292 : 0 : long nLow = pLow->Frm().Height();
3293 [ # # ][ # # ]: 0 : if( pLow->IsTxtFrm() && ((SwTxtFrm*)pLow)->IsUndersized() )
[ # # ]
3294 [ # # ]: 0 : nLow += ((SwTxtFrm*)pLow)->GetParHeight()-pLow->Prt().Height();
3295 [ # # ][ # # ]: 0 : else if( pLow->IsSctFrm() && ((SwSectionFrm*)pLow)->IsUndersized() )
[ # # ]
3296 [ # # ]: 0 : nLow += ((SwSectionFrm*)pLow)->Undersize();
3297 : 0 : nFlyAdd = Max( 0L, nFlyAdd - nLow );
3298 [ # # ]: 0 : nFlyAdd = Max( nFlyAdd, ::CalcHeightWidthFlys( pLow ) );
3299 : 0 : nHeight += nLow;
3300 : 0 : pLow = pLow->GetNext();
3301 : : } while ( pLow );
3302 [ # # ]: 0 : if ( nFlyAdd )
3303 : 0 : nHeight += nFlyAdd;
3304 : :
3305 : : //Der Border will natuerlich auch mitspielen, er kann leider nicht
3306 : : //aus PrtArea und Frm errechnet werden, da diese in beliebiger
3307 : : //Kombination ungueltig sein koennen.
3308 [ # # ]: 0 : SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCell );
3309 [ # # ]: 0 : const SwBorderAttrs &rAttrs = *aAccess.Get();
3310 [ # # ][ # # ]: 0 : nHeight += rAttrs.CalcTop() + rAttrs.CalcBottom();
3311 : :
3312 [ # # ]: 0 : return pCell->Frm().Height() - nHeight;
3313 : : }
3314 : : else
3315 : : {
3316 : 0 : long nRstHeight = 0;
3317 : 0 : SwFrm *pLow = pCell->Lower();
3318 [ # # ]: 0 : do
3319 : 0 : { nRstHeight += ::CalcRowRstHeight( (SwLayoutFrm*)pLow );
3320 : 0 : pLow = pLow->GetNext();
3321 : :
3322 : : } while ( pLow );
3323 : :
3324 : 0 : return nRstHeight;
3325 : : }
3326 : : }
3327 : :
3328 : 0 : SwTwips CalcRowRstHeight( SwLayoutFrm *pRow )
3329 : : {
3330 : 0 : SwTwips nRstHeight = LONG_MAX;
3331 : 0 : SwLayoutFrm *pLow = (SwLayoutFrm*)pRow->Lower();
3332 [ # # ]: 0 : while ( pLow )
3333 : : {
3334 : 0 : nRstHeight = Min( nRstHeight, ::lcl_CalcCellRstHeight( pLow ) );
3335 : 0 : pLow = (SwLayoutFrm*)pLow->GetNext();
3336 : : }
3337 : 0 : return nRstHeight;
3338 : : }
3339 : :
3340 : 227 : const SwFrm* FindPage( const SwRect &rRect, const SwFrm *pPage )
3341 : : {
3342 [ + + ]: 227 : if ( !rRect.IsOver( pPage->Frm() ) )
3343 : : {
3344 : 12 : const SwRootFrm* pRootFrm = static_cast<const SwRootFrm*>(pPage->GetUpper());
3345 [ + - ][ + - ]: 12 : const SwFrm* pTmpPage = pRootFrm ? pRootFrm->GetPageAtPos( rRect.TopLeft(), &rRect.SSize(), true ) : 0;
[ + - ][ # # ]
[ + - ]
3346 [ + - ]: 12 : if ( pTmpPage )
3347 : 12 : pPage = pTmpPage;
3348 : : }
3349 : :
3350 : 227 : return pPage;
3351 : : }
3352 : :
3353 : : #include <svl/smplhint.hxx>
3354 [ - + ]: 487508 : class SwFrmHolder : private SfxListener
3355 : : {
3356 : : SwFrm* pFrm;
3357 : : bool bSet;
3358 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
3359 : : public:
3360 : 487508 : SwFrmHolder() : pFrm(0), bSet(false) {}
3361 : : void SetFrm( SwFrm* pHold );
3362 : 0 : SwFrm* GetFrm() { return pFrm; }
3363 : : void Reset();
3364 : 235050 : bool IsSet() { return bSet; }
3365 : : };
3366 : :
3367 : 0 : void SwFrmHolder::SetFrm( SwFrm* pHold )
3368 : : {
3369 : 0 : bSet = true;
3370 : 0 : pFrm = pHold;
3371 : 0 : StartListening(*pHold);
3372 : 0 : }
3373 : :
3374 : 722558 : void SwFrmHolder::Reset()
3375 : : {
3376 [ - + ]: 722558 : if (pFrm)
3377 : 0 : EndListening(*pFrm);
3378 : 722558 : bSet = false;
3379 : 722558 : pFrm = 0;
3380 : 722558 : }
3381 : :
3382 : 0 : void SwFrmHolder::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3383 : : {
3384 [ # # ]: 0 : if ( rHint.IsA(TYPE(SfxSimpleHint)) )
3385 : : {
3386 [ # # ][ # # ]: 0 : if ( ( (SfxSimpleHint&) rHint ).GetId() == SFX_HINT_DYING && &rBC == pFrm )
[ # # ][ # # ]
3387 : 0 : pFrm = 0;
3388 : : }
3389 : 0 : }
3390 : :
3391 : 487508 : SwFrm* GetFrmOfModify( const SwRootFrm* pLayout, SwModify const& rMod, sal_uInt16 const nFrmType,
3392 : : const Point* pPoint, const SwPosition *pPos, const sal_Bool bCalcFrm )
3393 : : {
3394 : 487508 : SwFrm *pMinFrm = 0, *pTmpFrm;
3395 [ + - ]: 487508 : SwFrmHolder aHolder;
3396 : 487508 : SwRect aCalcRect;
3397 : 487508 : bool bClientIterChanged = false;
3398 : :
3399 [ + - ]: 487508 : SwIterator<SwFrm,SwModify> aIter( rMod );
3400 [ - + ]: 487508 : do {
3401 : 487508 : pMinFrm = 0;
3402 [ + - ]: 487508 : aHolder.Reset();
3403 : 487508 : sal_uInt64 nMinDist = 0;
3404 : 487508 : bClientIterChanged = false;
3405 : :
3406 [ + - ][ + - ]: 687369 : for( pTmpFrm = aIter.First(); pTmpFrm; pTmpFrm = aIter.Next() )
[ + + ]
3407 : : {
3408 [ + - ][ + + : 2201908 : if( pTmpFrm->GetType() & nFrmType &&
+ - + + +
+ ][ + + ]
3409 : 549857 : ( !pLayout || pLayout == pTmpFrm->getRootFrm() ) &&
3410 : 550840 : (!pTmpFrm->IsFlowFrm() ||
3411 [ + - ]: 550371 : !SwFlowFrm::CastFlowFrm( pTmpFrm )->IsFollow() ))
3412 : : {
3413 [ + + ]: 483686 : if( pPoint )
3414 : : {
3415 : : // watch for Frm being deleted
3416 [ - + ]: 235050 : if ( pMinFrm )
3417 [ # # ]: 0 : aHolder.SetFrm( pMinFrm );
3418 : : else
3419 [ + - ]: 235050 : aHolder.Reset();
3420 : :
3421 [ + + ]: 235050 : if( bCalcFrm )
3422 : : {
3423 : : // - format parent Writer
3424 : : // fly frame, if it isn't been formatted yet.
3425 : : // Note: The Writer fly frame could be the frame itself.
3426 [ + - ]: 6841 : SwFlyFrm* pFlyFrm( pTmpFrm->FindFlyFrm() );
3427 [ - + # # : 6841 : if ( pFlyFrm &&
# # ][ - + ]
3428 : 0 : pFlyFrm->Frm().Pos().X() == FAR_AWAY &&
3429 : 0 : pFlyFrm->Frm().Pos().Y() == FAR_AWAY )
3430 : : {
3431 [ # # ]: 0 : SwObjectFormatter::FormatObj( *pFlyFrm );
3432 : : }
3433 [ + - ]: 6841 : pTmpFrm->Calc();
3434 : : }
3435 : :
3436 : : // #127369#
3437 : : // aIter.IsChanged checks if the current pTmpFrm has been deleted while
3438 : : // it is the current iterator
3439 : : // FrmHolder watches for deletion of the current pMinFrm
3440 [ + - ][ - + ]: 235050 : if( aIter.IsChanged() || ( aHolder.IsSet() && !aHolder.GetFrm() ) )
[ # # ][ - + ]
3441 : : {
3442 : : // restart iteration
3443 : 0 : bClientIterChanged = true;
3444 : : break;
3445 : : }
3446 : :
3447 : : // bei Flys ggfs. ueber den Parent gehen wenn sie selbst
3448 : : // nocht nicht "formatiert" sind
3449 [ + + ][ + + ]: 235516 : if( !bCalcFrm && nFrmType & FRM_FLY &&
[ + - - +
# # ][ - + ]
3450 [ + - ]: 233 : ((SwFlyFrm*)pTmpFrm)->GetAnchorFrm() &&
3451 : 233 : FAR_AWAY == pTmpFrm->Frm().Pos().X() &&
3452 : 0 : FAR_AWAY == pTmpFrm->Frm().Pos().Y() )
3453 [ # # ]: 0 : aCalcRect = ((SwFlyFrm*)pTmpFrm)->GetAnchorFrm()->Frm();
3454 : : else
3455 : 235050 : aCalcRect = pTmpFrm->Frm();
3456 : :
3457 [ + - ][ + + ]: 235050 : if ( aCalcRect.IsInside( *pPoint ) )
3458 : : {
3459 : 102343 : pMinFrm = pTmpFrm;
3460 : : break;
3461 : : }
3462 : :
3463 : : // Point not in rectangle. Compare distances:
3464 [ + - ]: 132707 : const Point aCalcRectCenter = aCalcRect.Center();
3465 : 132707 : const Point aDiff = aCalcRectCenter - *pPoint;
3466 : 132707 : const sal_uInt64 nCurrentDist = aDiff.X() * aDiff.X() + aDiff.Y() * aDiff.Y(); // opt: no sqrt
3467 [ # # ][ - + ]: 132707 : if ( !pMinFrm || nCurrentDist < nMinDist )
3468 : : {
3469 : 132707 : pMinFrm = pTmpFrm;
3470 : 235050 : nMinDist = nCurrentDist;
3471 : : }
3472 : : }
3473 : : else
3474 : : {
3475 : : // Wenn kein pPoint angegeben ist, dann reichen
3476 : : // wir irgendeinen raus: den ersten!
3477 : 248636 : pMinFrm = pTmpFrm;
3478 : 248636 : break;
3479 : : }
3480 : : }
3481 : : }
3482 : : } while( bClientIterChanged );
3483 : :
3484 [ + + ][ + - ]: 487508 : if( pPos && pMinFrm && pMinFrm->IsTxtFrm() )
[ + - ][ + + ]
3485 [ + - ]: 163292 : return ((SwTxtFrm*)pMinFrm)->GetFrmAtPos( *pPos );
3486 : :
3487 [ + - ][ + - ]: 487508 : return pMinFrm;
3488 : : }
3489 : :
3490 : 87375 : sal_Bool IsExtraData( const SwDoc *pDoc )
3491 : : {
3492 : 87375 : const SwLineNumberInfo &rInf = pDoc->GetLineNumberInfo();
3493 : 87375 : return rInf.IsPaintLineNumbers() ||
3494 : 87354 : rInf.IsCountInFlys() ||
3495 : 87354 : ((sal_Int16)SW_MOD()->GetRedlineMarkPos() != text::HoriOrientation::NONE &&
3496 [ - + ][ + + : 262083 : !pDoc->GetRedlineTbl().empty());
+ - + - ]
3497 : : }
3498 : :
3499 : : // OD 22.09.2003 #110978#
3500 : 0 : const SwRect SwPageFrm::PrtWithoutHeaderAndFooter() const
3501 : : {
3502 : 0 : SwRect aPrtWithoutHeaderFooter( Prt() );
3503 : 0 : aPrtWithoutHeaderFooter.Pos() += Frm().Pos();
3504 : :
3505 : 0 : const SwFrm* pLowerFrm = Lower();
3506 [ # # ]: 0 : while ( pLowerFrm )
3507 : : {
3508 : : // Note: independent on text direction page header and page footer are
3509 : : // always at top respectively at bottom of the page frame.
3510 [ # # ]: 0 : if ( pLowerFrm->IsHeaderFrm() )
3511 : : {
3512 : 0 : aPrtWithoutHeaderFooter.Top( aPrtWithoutHeaderFooter.Top() +
3513 : 0 : pLowerFrm->Frm().Height() );
3514 : : }
3515 [ # # ]: 0 : if ( pLowerFrm->IsFooterFrm() )
3516 : : {
3517 : 0 : aPrtWithoutHeaderFooter.Bottom( aPrtWithoutHeaderFooter.Bottom() -
3518 : 0 : pLowerFrm->Frm().Height() );
3519 : : }
3520 : :
3521 : 0 : pLowerFrm = pLowerFrm->GetNext();
3522 : : }
3523 : :
3524 : 0 : return aPrtWithoutHeaderFooter;
3525 : : }
3526 : :
3527 : : /** method to determine the spacing values of a frame
3528 : :
3529 : : OD 2004-03-10 #i28701#
3530 : : OD 2009-08-28 #i102458#
3531 : : Add output parameter <obIsLineSpacingProportional>
3532 : :
3533 : : @author OD
3534 : : */
3535 : 5135 : void GetSpacingValuesOfFrm( const SwFrm& rFrm,
3536 : : SwTwips& onLowerSpacing,
3537 : : SwTwips& onLineSpacing,
3538 : : bool& obIsLineSpacingProportional )
3539 : : {
3540 [ - + ]: 5135 : if ( !rFrm.IsFlowFrm() )
3541 : : {
3542 : 0 : onLowerSpacing = 0;
3543 : 0 : onLineSpacing = 0;
3544 : : }
3545 : : else
3546 : : {
3547 : 5135 : const SvxULSpaceItem& rULSpace = rFrm.GetAttrSet()->GetULSpace();
3548 : 5135 : onLowerSpacing = rULSpace.GetLower();
3549 : :
3550 : 5135 : onLineSpacing = 0;
3551 : 5135 : obIsLineSpacingProportional = false;
3552 [ + + ]: 5135 : if ( rFrm.IsTxtFrm() )
3553 : : {
3554 : 4725 : onLineSpacing = static_cast<const SwTxtFrm&>(rFrm).GetLineSpace();
3555 : : obIsLineSpacingProportional =
3556 : : onLineSpacing != 0 &&
3557 [ + - ][ + + ]: 4725 : static_cast<const SwTxtFrm&>(rFrm).GetLineSpace( true ) == 0;
3558 : : }
3559 : :
3560 : : OSL_ENSURE( onLowerSpacing >= 0 && onLineSpacing >= 0,
3561 : : "<GetSpacingValuesOfFrm(..)> - spacing values aren't positive!" );
3562 : : }
3563 : 5135 : }
3564 : :
3565 : : /** method to get the content of the table cell, skipping content from nested tables
3566 : : */
3567 : 2 : const SwCntntFrm* GetCellCntnt( const SwLayoutFrm& rCell )
3568 : : {
3569 : 2 : const SwCntntFrm* pCntnt = rCell.ContainsCntnt();
3570 : 2 : const SwTabFrm* pTab = rCell.FindTabFrm();
3571 : :
3572 [ + - ][ + - ]: 2 : while ( pCntnt && rCell.IsAnLower( pCntnt ) )
[ + - ]
3573 : : {
3574 : 2 : const SwTabFrm* pTmpTab = pCntnt->FindTabFrm();
3575 [ - + ]: 2 : if ( pTmpTab != pTab )
3576 : : {
3577 : 0 : pCntnt = pTmpTab->FindLastCntnt();
3578 [ # # ]: 0 : if ( pCntnt )
3579 : :
3580 : 0 : pCntnt = pCntnt->FindNextCnt();
3581 : :
3582 : : }
3583 : : else
3584 : 2 : break;
3585 : : }
3586 : 2 : return pCntnt;
3587 : : }
3588 : :
3589 : : /** Can be used to check if a frame has been deleted
3590 : : */
3591 : 2 : bool SwDeletionChecker::HasBeenDeleted()
3592 : : {
3593 [ + - ][ - + ]: 2 : if ( !mpFrm || !mpRegIn )
3594 : 0 : return false;
3595 : :
3596 [ + - ]: 2 : SwIterator<SwFrm,SwModify> aIter(*mpRegIn);
3597 [ + - ]: 2 : SwFrm* pLast = aIter.First();
3598 [ + - ]: 2 : while ( pLast )
3599 : : {
3600 [ + - ]: 2 : if ( pLast == mpFrm )
3601 : 2 : return false;
3602 [ # # ]: 0 : pLast = aIter.Next();
3603 : : }
3604 : :
3605 [ + - ]: 2 : return true;
3606 : : }
3607 : :
3608 : :
3609 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|