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 : :
30 : : #include <ftnfrm.hxx>
31 : : #include <pagefrm.hxx>
32 : : #include <rootfrm.hxx>
33 : : #include <cntfrm.hxx>
34 : : #include <doc.hxx>
35 : : #include <node.hxx>
36 : : #include <dview.hxx>
37 : : #include <dcontact.hxx>
38 : : #include <dflyobj.hxx>
39 : : #include <flyfrm.hxx>
40 : : #include <txtfrm.hxx> // ClearPara()
41 : : #include <cellfrm.hxx>
42 : : #include <swtable.hxx>
43 : : #include <fmtfsize.hxx>
44 : : #include <ftnidx.hxx>
45 : : #include <txtftn.hxx>
46 : : #include <ndtxt.hxx>
47 : : #include <ndindex.hxx>
48 : : #include <frmtool.hxx>
49 : : #include <pagedesc.hxx>
50 : : #include <editeng/boxitem.hxx>
51 : : #include <editeng/shaditem.hxx>
52 : : #include <fmtclds.hxx>
53 : : #include <viewsh.hxx>
54 : : #include <viewimp.hxx>
55 : : #include <sortedobjs.hxx>
56 : : #include <hints.hxx>
57 : : #include <switerator.hxx>
58 : :
59 : : // No inline cause we need the function pointers
60 : 1499 : long SwFrm::GetTopMargin() const
61 : 1499 : { return Prt().Top(); }
62 : 87652 : long SwFrm::GetBottomMargin() const
63 : 87652 : { return Frm().Height() -Prt().Height() -Prt().Top(); }
64 : 342 : long SwFrm::GetLeftMargin() const
65 : 342 : { return Prt().Left(); }
66 : 144 : long SwFrm::GetRightMargin() const
67 : 144 : { return Frm().Width() - Prt().Width() - Prt().Left(); }
68 : 2683 : long SwFrm::GetPrtLeft() const
69 : 2683 : { return Frm().Left() + Prt().Left(); }
70 : 301593 : long SwFrm::GetPrtBottom() const
71 : 301593 : { return Frm().Top() + Prt().Height() + Prt().Top(); }
72 : 1690 : long SwFrm::GetPrtRight() const
73 : 1690 : { return Frm().Left() + Prt().Width() + Prt().Left(); }
74 : 24131 : long SwFrm::GetPrtTop() const
75 : 24131 : { return Frm().Top() + Prt().Top(); }
76 : :
77 : 0 : sal_Bool SwFrm::SetMinLeft( long nDeadline )
78 : : {
79 : 0 : SwTwips nDiff = nDeadline - Frm().Left();
80 [ # # ]: 0 : if( nDiff > 0 )
81 : : {
82 : 0 : Frm().Left( nDeadline );
83 : 0 : Prt().Width( Prt().Width() - nDiff );
84 : 0 : return sal_True;
85 : : }
86 : 0 : return sal_False;
87 : : }
88 : :
89 : 173 : sal_Bool SwFrm::SetMaxBottom( long nDeadline )
90 : : {
91 : 173 : SwTwips nDiff = Frm().Top() + Frm().Height() - nDeadline;
92 [ - + ]: 173 : if( nDiff > 0 )
93 : : {
94 : 0 : Frm().Height( Frm().Height() - nDiff );
95 : 0 : Prt().Height( Prt().Height() - nDiff );
96 : 0 : return sal_True;
97 : : }
98 : 173 : return sal_False;
99 : : }
100 : :
101 : 0 : sal_Bool SwFrm::SetMinTop( long nDeadline )
102 : : {
103 : 0 : SwTwips nDiff = nDeadline - Frm().Top();
104 [ # # ]: 0 : if( nDiff > 0 )
105 : : {
106 : 0 : Frm().Top( nDeadline );
107 : 0 : Prt().Height( Prt().Height() - nDiff );
108 : 0 : return sal_True;
109 : : }
110 : 0 : return sal_False;
111 : : }
112 : :
113 : 0 : sal_Bool SwFrm::SetMaxRight( long nDeadline )
114 : : {
115 : 0 : SwTwips nDiff = Frm().Left() + Frm().Width() - nDeadline;
116 [ # # ]: 0 : if( nDiff > 0 )
117 : : {
118 : 0 : Frm().Width( Frm().Width() - nDiff );
119 : 0 : Prt().Width( Prt().Width() - nDiff );
120 : 0 : return sal_True;
121 : : }
122 : 0 : return sal_False;
123 : : }
124 : :
125 : 73 : void SwFrm::MakeBelowPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
126 : : {
127 [ + + ]: 73 : if( pPrv )
128 : : {
129 : 36 : aFrm.Pos( pPrv->Frm().Pos() );
130 : 36 : aFrm.Pos().Y() += pPrv->Frm().Height();
131 : : }
132 : : else
133 : : {
134 : 37 : aFrm.Pos( pUp->Frm().Pos() );
135 : 37 : aFrm.Pos() += pUp->Prt().Pos();
136 : : }
137 [ + + ]: 73 : if( bNotify )
138 : 51 : aFrm.Pos().Y() += 1;
139 : 73 : }
140 : :
141 : 0 : void SwFrm::MakeUpperPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
142 : : {
143 [ # # ]: 0 : if( pPrv )
144 : : {
145 : 0 : aFrm.Pos( pPrv->Frm().Pos() );
146 : 0 : aFrm.Pos().Y() -= Frm().Height();
147 : : }
148 : : else
149 : : {
150 : 0 : aFrm.Pos( pUp->Frm().Pos() );
151 : 0 : aFrm.Pos() += pUp->Prt().Pos();
152 : 0 : aFrm.Pos().Y() += pUp->Prt().Height() - aFrm.Height();
153 : : }
154 [ # # ]: 0 : if( bNotify )
155 : 0 : aFrm.Pos().Y() -= 1;
156 : 0 : }
157 : :
158 : 0 : void SwFrm::MakeLeftPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
159 : : {
160 [ # # ]: 0 : if( pPrv )
161 : : {
162 : 0 : aFrm.Pos( pPrv->Frm().Pos() );
163 : 0 : aFrm.Pos().X() -= Frm().Width();
164 : : }
165 : : else
166 : : {
167 : 0 : aFrm.Pos( pUp->Frm().Pos() );
168 : 0 : aFrm.Pos() += pUp->Prt().Pos();
169 : 0 : aFrm.Pos().X() += pUp->Prt().Width() - aFrm.Width();
170 : : }
171 [ # # ]: 0 : if( bNotify )
172 : 0 : aFrm.Pos().X() -= 1;
173 : 0 : }
174 : :
175 : 0 : void SwFrm::MakeRightPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
176 : : {
177 [ # # ]: 0 : if( pPrv )
178 : : {
179 : 0 : aFrm.Pos( pPrv->Frm().Pos() );
180 : 0 : aFrm.Pos().X() += pPrv->Frm().Width();
181 : : }
182 : : else
183 : : {
184 : 0 : aFrm.Pos( pUp->Frm().Pos() );
185 : 0 : aFrm.Pos() += pUp->Prt().Pos();
186 : : }
187 [ # # ]: 0 : if( bNotify )
188 : 0 : aFrm.Pos().X() += 1;
189 : 0 : }
190 : :
191 : 8618 : void SwFrm::SetTopBottomMargins( long nTop, long nBot )
192 : : {
193 : 8618 : Prt().Top( nTop );
194 : 8618 : Prt().Height( Frm().Height() - nTop - nBot );
195 : 8618 : }
196 : :
197 : 0 : void SwFrm::SetBottomTopMargins( long nBot, long nTop )
198 : : {
199 : 0 : Prt().Top( nTop );
200 : 0 : Prt().Height( Frm().Height() - nTop - nBot );
201 : 0 : }
202 : :
203 : 23899 : void SwFrm::SetLeftRightMargins( long nLeft, long nRight)
204 : : {
205 : 23899 : Prt().Left( nLeft );
206 : 23899 : Prt().Width( Frm().Width() - nLeft - nRight );
207 : 23899 : }
208 : :
209 : 0 : void SwFrm::SetRightLeftMargins( long nRight, long nLeft)
210 : : {
211 : 0 : Prt().Left( nLeft );
212 : 0 : Prt().Width( Frm().Width() - nLeft - nRight );
213 : 0 : }
214 : :
215 : : const sal_uInt16 nMinVertCellHeight = 1135;
216 : :
217 : : /*--------------------------------------------------
218 : : * SwFrm::CheckDirChange(..)
219 : : * checks the layout direction and
220 : : * invalidates the lower frames rekursivly, if necessary.
221 : : * --------------------------------------------------*/
222 : :
223 : 639 : void SwFrm::CheckDirChange()
224 : : {
225 : 639 : sal_Bool bOldVert = GetVerticalFlag();
226 : 639 : sal_Bool bOldRev = IsReverse();
227 : 639 : sal_Bool bOldR2L = GetRightToLeftFlag();
228 : 639 : SetInvalidVert( sal_True );
229 : 639 : SetInvalidR2L( sal_True );
230 : 639 : sal_Bool bChg = bOldR2L != IsRightToLeft();
231 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
232 : 639 : sal_Bool bOldVertL2R = IsVertLR();
233 [ + - ][ + - ]: 639 : if( ( IsVertical() != bOldVert ) || bChg || IsReverse() != bOldRev || bOldVertL2R != IsVertLR() )
[ - + ][ + + ]
[ + + ]
234 : : {
235 : 12 : InvalidateAll();
236 [ + + ]: 12 : if( IsLayoutFrm() )
237 : : {
238 : : // set minimum row height for vertical cells in horizontal table:
239 [ - + ][ # # ]: 8 : if ( IsCellFrm() && GetUpper() )
[ - + ]
240 : : {
241 [ # # # # ]: 0 : if ( IsVertical() != GetUpper()->IsVertical() &&
[ # # ]
242 : 0 : ((SwCellFrm*)this)->GetTabBox()->getRowSpan() == 1 )
243 : : {
244 : 0 : SwTableLine* pLine = (SwTableLine*)((SwCellFrm*)this)->GetTabBox()->GetUpper();
245 : 0 : SwFrmFmt* pFrmFmt = pLine->GetFrmFmt();
246 [ # # ][ # # ]: 0 : SwFmtFrmSize aNew( pFrmFmt->GetFrmSize() );
247 [ # # ]: 0 : if ( ATT_FIX_SIZE != aNew.GetHeightSizeType() )
248 : 0 : aNew.SetHeightSizeType( ATT_MIN_SIZE );
249 [ # # ]: 0 : if ( aNew.GetHeight() < nMinVertCellHeight )
250 : 0 : aNew.SetHeight( nMinVertCellHeight );
251 : 0 : SwDoc* pDoc = pFrmFmt->GetDoc();
252 [ # # ][ # # ]: 0 : pDoc->SetAttr( aNew, *pLine->ClaimFrmFmt() );
[ # # ]
253 : : }
254 : : }
255 : :
256 : 8 : SwFrm* pFrm = ((SwLayoutFrm*)this)->Lower();
257 : 8 : const SwFmtCol* pCol = NULL;
258 : 8 : SwLayoutFrm* pBody = 0;
259 [ + - ]: 8 : if( pFrm )
260 : : {
261 [ + + ]: 8 : if( IsPageFrm() )
262 : : {
263 : : // If we're a page frame and we change our layout direction,
264 : : // we have to look for columns and rearrange them.
265 : 4 : pBody = ((SwPageFrm*)this)->FindBodyCont();
266 [ + - ][ - + ]: 4 : if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm())
[ - + ][ + - ]
267 : 0 : pCol = &((SwPageFrm*)this)->GetFmt()->GetCol();
268 : : }
269 [ - + ]: 4 : else if( pFrm->IsColumnFrm() )
270 : : {
271 : 0 : pBody = ((SwLayoutFrm*)this);
272 : 0 : const SwFrmFmt *pFmt = pBody->GetFmt();
273 [ # # ]: 0 : if( pFmt )
274 : 0 : pCol = &pFmt->GetCol();
275 : : }
276 : : }
277 [ + + ]: 16 : while( pFrm )
278 : : {
279 : 8 : pFrm->CheckDirChange();
280 : 8 : pFrm = pFrm->GetNext();
281 : : }
282 [ - + ]: 8 : if( pCol )
283 : 0 : pBody->AdjustColumns( pCol, sal_True );
284 : : }
285 [ + - ]: 4 : else if( IsTxtFrm() )
286 : 4 : ((SwTxtFrm*)this)->Prepare( PREP_CLEAR );
287 : :
288 : : // #i31698# - notify anchored objects also for page frames.
289 : : // Remove code above for special handling of page frames
290 [ - + ]: 12 : if ( GetDrawObjs() )
291 : : {
292 : 0 : const SwSortedObjs *pObjs = GetDrawObjs();
293 : 0 : sal_uInt32 nCnt = pObjs->Count();
294 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nCnt; ++i )
295 : : {
296 : 0 : SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
297 [ # # ]: 0 : if( pAnchoredObj->ISA(SwFlyFrm) )
298 [ # # ]: 0 : static_cast<SwFlyFrm*>(pAnchoredObj)->CheckDirChange();
299 : : else
300 : : {
301 : : // OD 2004-04-06 #i26791# - direct object
302 : : // positioning no longer needed. Instead
303 : : // invalidate
304 : 0 : pAnchoredObj->InvalidateObjPos();
305 : : }
306 : : // #i31698# - update layout direction of
307 : : // anchored object
308 : : {
309 : 0 : ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrmContainingAnchPos() );
310 : 0 : pAnchoredObj->UpdateLayoutDir();
311 : : }
312 : : }
313 : : }
314 : : }
315 : 639 : }
316 : :
317 : : /*--------------------------------------------------
318 : : * SwFrm::GetFrmAnchorPos(..)
319 : : * returns the position for anchors based on frame direction
320 : : * --------------------------------------------------*/
321 : : // OD 2004-03-10 #i11860# - consider lower space and line spacing of
322 : : // previous frame according to new option 'Use former object positioning'
323 : 77 : Point SwFrm::GetFrmAnchorPos( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
324 : : {
325 : 77 : Point aAnchor = Frm().Pos();
326 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
327 [ # # ][ - + ]: 77 : if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
[ - + ][ - + ]
328 : 0 : aAnchor.X() += Frm().Width();
329 : :
330 [ + + ]: 77 : if ( IsTxtFrm() )
331 : : {
332 : : SwTwips nBaseOfstForFly =
333 : 63 : ((SwTxtFrm*)this)->GetBaseOfstForFly( bIgnoreFlysAnchoredAtThisFrame );
334 [ - + ]: 63 : if ( IsVertical() )
335 : 0 : aAnchor.Y() += nBaseOfstForFly;
336 : : else
337 : 63 : aAnchor.X() += nBaseOfstForFly;
338 : :
339 : : // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
340 : : // is OFF, consider the lower space and the line spacing of the
341 : : // previous frame and the spacing considered for the page grid
342 : 63 : const SwTxtFrm* pThisTxtFrm = static_cast<const SwTxtFrm*>(this);
343 : : const SwTwips nUpperSpaceAmountConsideredForPrevFrmAndPageGrid =
344 : 63 : pThisTxtFrm->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
345 [ - + ]: 63 : if ( IsVertical() )
346 : : {
347 : 0 : aAnchor.X() -= nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
348 : : }
349 : : else
350 : : {
351 : 63 : aAnchor.Y() += nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
352 : : }
353 : : }
354 : :
355 : 77 : return aAnchor;
356 : : }
357 : :
358 : :
359 : : /*************************************************************************
360 : : |*
361 : : |* SwFrm::~SwFrm()
362 : : |*
363 : : |*************************************************************************/
364 : :
365 : 13156 : void SwFrm::Destroy()
366 : : {
367 : : // accessible objects for fly and cell frames have been already disposed
368 : : // by the destructors of the derived classes.
369 [ + + ][ + + ]: 13156 : if( IsAccessibleFrm() && !(IsFlyFrm() || IsCellFrm()) && GetDep() )
[ + + ][ + - ]
[ + + ]
370 : : {
371 : 7956 : SwRootFrm *pRootFrm = getRootFrm();
372 [ - + ][ - + ]: 7956 : if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
[ + - ]
373 : : {
374 : 0 : ViewShell *pVSh = pRootFrm->GetCurrShell();
375 [ # # ][ # # ]: 0 : if( pVSh && pVSh->Imp() )
[ # # ]
376 : : {
377 : : OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" );
378 : 0 : pVSh->Imp()->DisposeAccessibleFrm( this );
379 : : }
380 : : }
381 : : }
382 : :
383 [ + + ]: 13156 : if( pDrawObjs )
384 : : {
385 [ + + ]: 12 : for ( sal_uInt32 i = pDrawObjs->Count(); i; )
386 : : {
387 : 6 : SwAnchoredObject* pAnchoredObj = (*pDrawObjs)[--i];
388 [ + - ]: 6 : if ( pAnchoredObj->ISA(SwFlyFrm) )
389 [ + - ]: 6 : delete pAnchoredObj;
390 : : else
391 : : {
392 : 0 : SdrObject* pSdrObj = pAnchoredObj->DrawObj();
393 : : SwDrawContact* pContact =
394 : 0 : static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
395 : : OSL_ENSURE( pContact,
396 : : "<SwFrm::~SwFrm> - missing contact for drawing object" );
397 [ # # ]: 0 : if ( pContact )
398 : : {
399 : 0 : pContact->DisconnectObjFromLayout( pSdrObj );
400 : : }
401 : : }
402 : : }
403 [ - + ]: 6 : delete pDrawObjs;
404 : 6 : pDrawObjs = 0;
405 : : }
406 : 13156 : }
407 : :
408 [ + - ]: 13156 : SwFrm::~SwFrm()
409 : : {
410 [ + + ]: 13156 : if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
411 : : {
412 [ + - ]: 11925 : Destroy();
413 : : }
414 : :
415 : : #if OSL_DEBUG_LEVEL > 0
416 : : // JP 15.10.2001: for detection of access to deleted frames
417 : : pDrawObjs = (SwSortedObjs*)0x33333333;
418 : : #endif
419 [ - + ]: 13156 : }
420 : :
421 : : /*************************************************************************/
422 : :
423 : 290927 : const SwFrmFmt * SwLayoutFrm::GetFmt() const
424 : : {
425 : 290927 : return static_cast< const SwFlyFrmFmt * >( GetDep() );
426 : : }
427 : :
428 : 482615 : SwFrmFmt * SwLayoutFrm::GetFmt()
429 : : {
430 : 482615 : return static_cast< SwFlyFrmFmt * >( GetDep() );
431 : : }
432 : :
433 : :
434 : : /*************************************************************************
435 : : |*
436 : : |* SwLayoutFrm::SetFrmFmt()
437 : : |*
438 : : |*************************************************************************/
439 : :
440 : :
441 : 59 : void SwLayoutFrm::SetFrmFmt( SwFrmFmt *pNew )
442 : : {
443 [ + - ]: 59 : if ( pNew != GetFmt() )
444 : : {
445 [ + - ][ + - ]: 59 : SwFmtChg aOldFmt( GetFmt() );
446 [ + - ]: 59 : pNew->Add( this );
447 [ + - ]: 59 : SwFmtChg aNewFmt( pNew );
448 [ + - ][ + - ]: 59 : ModifyNotification( &aOldFmt, &aNewFmt );
[ + - ]
449 : : }
450 : 59 : }
451 : :
452 : : /*************************************************************************
453 : : |* SwCntntFrm::SwCntntFrm()
454 : : |*************************************************************************/
455 : 5786 : SwCntntFrm::SwCntntFrm( SwCntntNode * const pCntnt, SwFrm* pSib ) :
456 : : SwFrm( pCntnt, pSib ),
457 [ + - ]: 5786 : SwFlowFrm( (SwFrm&)*this )
458 : : {
459 : 5786 : }
460 : :
461 : : /*************************************************************************
462 : : |* SwCntntFrm::~SwCntntFrm()
463 : : |*************************************************************************/
464 [ + - ]: 5498 : SwCntntFrm::~SwCntntFrm()
465 : : {
466 : : SwCntntNode* pCNd;
467 [ + - ][ + - ]: 10996 : if( 0 != ( pCNd = PTR_CAST( SwCntntNode, GetRegisteredIn() )) &&
[ + - ][ + - ]
[ + - + - ]
[ + - ]
468 : 5498 : !pCNd->GetDoc()->IsInDtor() )
469 : : {
470 : : //Unregister from root if I'm still in turbo there.
471 : 5498 : SwRootFrm *pRoot = getRootFrm();
472 [ - + ][ - + ]: 5498 : if( pRoot && pRoot->GetTurbo() == this )
[ + - ]
473 : : {
474 : 0 : pRoot->DisallowTurbo();
475 : 0 : pRoot->ResetTurbo();
476 : : }
477 [ + + ][ + + ]: 5498 : if( IsTxtFrm() && ((SwTxtFrm*)this)->HasFtn() )
[ + + ]
478 : : {
479 : 32 : SwTxtNode *pTxtNd = ((SwTxtFrm*)this)->GetTxtNode();
480 : 32 : const SwFtnIdxs &rFtnIdxs = pCNd->GetDoc()->GetFtnIdxs();
481 : : sal_uInt16 nPos;
482 : 32 : sal_uLong nIndex = pCNd->GetIndex();
483 [ + - ][ + - ]: 32 : rFtnIdxs.SeekEntry( *pTxtNd, &nPos );
[ + - ]
484 : : SwTxtFtn* pTxtFtn;
485 [ + - ]: 32 : if( nPos < rFtnIdxs.size() )
486 : : {
487 [ - + ][ # # ]: 32 : while( nPos && pTxtNd == &(rFtnIdxs[ nPos ]->GetTxtNode()) )
[ # # ][ - + ]
488 : 0 : --nPos;
489 [ + - ][ + - ]: 32 : if( nPos || pTxtNd != &(rFtnIdxs[ nPos ]->GetTxtNode()) )
[ - + ][ - + ]
490 : 0 : ++nPos;
491 : : }
492 [ + + ]: 66 : while( nPos < rFtnIdxs.size() )
493 : : {
494 [ + - ]: 34 : pTxtFtn = rFtnIdxs[ nPos ];
495 [ - + ]: 34 : if( pTxtFtn->GetTxtNode().GetIndex() > nIndex )
496 : 0 : break;
497 [ + - ]: 34 : pTxtFtn->DelFrms( this );
498 : 34 : ++nPos;
499 : : }
500 : : }
501 : : }
502 [ - + ]: 5498 : }
503 : :
504 : 202 : void SwCntntFrm::RegisterToNode( SwCntntNode& rNode )
505 : : {
506 : 202 : rNode.Add( this );
507 : 202 : }
508 : :
509 : 1505 : void SwCntntFrm::DelFrms( const SwCntntNode& rNode )
510 : : {
511 [ + - ]: 1505 : SwIterator<SwCntntFrm,SwCntntNode> aIter( rNode );
512 [ + - ][ + - ]: 1665 : for( SwCntntFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
[ + + ]
513 : : {
514 : : // #i27138#
515 : : // notify accessibility paragraphs objects about changed
516 : : // CONTENT_FLOWS_FROM/_TO relation.
517 : : // Relation CONTENT_FLOWS_FROM for current next paragraph will change
518 : : // and relation CONTENT_FLOWS_TO for current previous paragraph will change.
519 [ + - ]: 160 : if ( pFrm->IsTxtFrm() )
520 : : {
521 : 160 : ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
522 [ + - ]: 320 : if ( pViewShell && pViewShell->GetLayout() &&
[ + - - + ]
[ - + ][ + - ]
523 [ + - ]: 160 : pViewShell->GetLayout()->IsAnyShellAccessible() )
524 : : {
525 : : pViewShell->InvalidateAccessibleParaFlowRelation(
526 [ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
527 [ # # ][ # # ]: 0 : dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
[ # # ][ # # ]
528 : : }
529 : : }
530 [ + + ]: 160 : if( pFrm->IsFollow() )
531 : : {
532 [ + - ]: 4 : SwCntntFrm* pMaster = (SwTxtFrm*)pFrm->FindMaster();
533 [ - + ][ + - ]: 4 : pMaster->SetFollow( pFrm->GetFollow() );
534 : : }
535 [ + - ]: 160 : pFrm->SetFollow( 0 );//So it doesn't get funny ideas.
536 : : //Otherwise it could be possible that a follow
537 : : //gets destroyed before its master. Following
538 : : //the now invalid pointer will then lead to an
539 : : //illegal memory access. The chain can be
540 : : //crushed here because we'll destroy all of it
541 : : //anyway.
542 : :
543 [ + - ][ + - ]: 164 : if( pFrm->GetUpper() && pFrm->IsInFtn() && !pFrm->GetIndNext() &&
[ + + ][ + - ]
[ + + ][ - + ]
[ - + ]
544 [ + - ]: 4 : !pFrm->GetIndPrev() )
545 : : {
546 [ # # ]: 0 : SwFtnFrm *pFtn = pFrm->FindFtnFrm();
547 : : OSL_ENSURE( pFtn, "You promised a FtnFrm?" );
548 : : SwCntntFrm* pCFrm;
549 [ # # ][ # # ]: 0 : if( !pFtn->GetFollow() && !pFtn->GetMaster() &&
[ # # ]
[ # # # # ]
[ # # ]
550 : 0 : 0 != ( pCFrm = pFtn->GetRefFromAttr()) && pCFrm->IsFollow() )
551 : : {
552 : : OSL_ENSURE( pCFrm->IsTxtFrm(), "NoTxtFrm has Footnote?" );
553 [ # # ][ # # ]: 0 : ((SwTxtFrm*)pCFrm->FindMaster())->Prepare( PREP_FTN_GONE );
554 : : }
555 : : }
556 [ + - ]: 160 : pFrm->Cut();
557 [ + - ][ + - ]: 160 : delete pFrm;
558 [ + - ]: 1505 : }
559 : 1505 : }
560 : :
561 : : /*************************************************************************
562 : : |*
563 : : |* SwLayoutFrm::~SwLayoutFrm
564 : : |*
565 : : |*************************************************************************/
566 : :
567 : 7658 : void SwLayoutFrm::Destroy()
568 : : {
569 : 7658 : SwFrm *pFrm = pLower;
570 : :
571 [ + + ][ + - ]: 7658 : if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
[ + + ]
572 : : {
573 [ + + ]: 11664 : while ( pFrm )
574 : : {
575 : : //First delete the Objs of the Frm because they can't unregister
576 : : //from the page after remove.
577 : : //We don't want to create an endless loop only because one couldn't
578 : : //unregister.
579 : :
580 : : sal_uInt32 nCnt;
581 [ + + ][ + - ]: 7513 : while ( pFrm->GetDrawObjs() && pFrm->GetDrawObjs()->Count() )
[ + + ]
582 : : {
583 : 1045 : nCnt = pFrm->GetDrawObjs()->Count();
584 : : // #i28701#
585 : 1045 : SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[0];
586 [ + + ]: 1045 : if ( pAnchoredObj->ISA(SwFlyFrm) )
587 [ + - ]: 497 : delete pAnchoredObj;
588 : : else
589 : : {
590 : 548 : SdrObject* pSdrObj = pAnchoredObj->DrawObj();
591 : : SwDrawContact* pContact =
592 : 548 : static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
593 : : OSL_ENSURE( pContact,
594 : : "<SwFrm::~SwFrm> - missing contact for drawing object" );
595 [ + - ]: 548 : if ( pContact )
596 : : {
597 : 548 : pContact->DisconnectObjFromLayout( pSdrObj );
598 : : }
599 : : }
600 [ + + - + ]: 1433 : if ( pFrm->GetDrawObjs() &&
[ - + ]
601 : 388 : nCnt == pFrm->GetDrawObjs()->Count() )
602 : : {
603 : 0 : pFrm->GetDrawObjs()->Remove( *pAnchoredObj );
604 : : }
605 : : }
606 : 6468 : pFrm->Remove();
607 [ + - ]: 6468 : delete pFrm;
608 : 6468 : pFrm = pLower;
609 : : }
610 : : //Delete the Flys, the last one also deletes the array.
611 : : sal_uInt32 nCnt;
612 [ - + ][ # # ]: 5196 : while ( GetDrawObjs() && GetDrawObjs()->Count() )
[ - + ]
613 : : {
614 : 0 : nCnt = GetDrawObjs()->Count();
615 : :
616 : : // #i28701#
617 : 0 : SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
618 [ # # ]: 0 : if ( pAnchoredObj->ISA(SwFlyFrm) )
619 [ # # ]: 0 : delete pAnchoredObj;
620 : : else
621 : : {
622 : 0 : SdrObject* pSdrObj = pAnchoredObj->DrawObj();
623 : : SwDrawContact* pContact =
624 : 0 : static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
625 : : OSL_ENSURE( pContact,
626 : : "<SwFrm::~SwFrm> - missing contact for drawing object" );
627 [ # # ]: 0 : if ( pContact )
628 : : {
629 : 0 : pContact->DisconnectObjFromLayout( pSdrObj );
630 : : }
631 : : }
632 [ # # ][ # # ]: 0 : if ( GetDrawObjs() && nCnt == GetDrawObjs()->Count() )
[ # # ]
633 : : {
634 : 0 : GetDrawObjs()->Remove( *pAnchoredObj );
635 : : }
636 : : }
637 : : }
638 : : else
639 : : {
640 [ + + ]: 6380 : while( pFrm )
641 : : {
642 : 3918 : SwFrm *pNxt = pFrm->GetNext();
643 [ + - ]: 3918 : delete pFrm;
644 : 3918 : pFrm = pNxt;
645 : : }
646 : : }
647 : 7658 : }
648 : :
649 : 7658 : SwLayoutFrm::~SwLayoutFrm()
650 : : {
651 [ + + ]: 7658 : if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
652 : : {
653 [ + - ]: 6427 : Destroy();
654 : : }
655 [ - + ]: 7658 : }
656 : :
657 : : /*************************************************************************
658 : : |*
659 : : |* SwFrm::PaintArea()
660 : : |*
661 : : |* The paintarea is the area, in which the content of a frame is allowed
662 : : |* to be displayed. This region could be larger than the printarea (Prt())
663 : : |* of the upper, it includes e.g. often the margin of the page.
664 : : |*
665 : : |*************************************************************************/
666 : :
667 : 160401 : const SwRect SwFrm::PaintArea() const
668 : : {
669 : : // NEW TABLES
670 : : // Cell frames may not leave their upper:
671 [ + + ]: 160401 : SwRect aRect = IsRowFrm() ? GetUpper()->Frm() : Frm();
672 : 160401 : const sal_Bool bVert = IsVertical();
673 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
674 [ - + ][ + + ]: 160401 : SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
675 [ + - ]: 160401 : long nRight = (aRect.*fnRect->fnGetRight)();
676 [ + - ]: 160401 : long nLeft = (aRect.*fnRect->fnGetLeft)();
677 : 160401 : const SwFrm* pTmp = this;
678 : 160401 : sal_Bool bLeft = sal_True;
679 : 160401 : sal_Bool bRight = sal_True;
680 : 160401 : long nRowSpan = 0;
681 [ + - ]: 509903 : while( pTmp )
682 : : {
683 [ + + ]: 547487 : if( pTmp->IsCellFrm() && pTmp->GetUpper() &&
[ + - - + ]
[ - + ]
684 : 37584 : pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
685 : 0 : nRowSpan = ((SwCellFrm*)pTmp)->GetTabBox()->getRowSpan();
686 [ + - ]: 509903 : long nTmpRight = (pTmp->Frm().*fnRect->fnGetRight)();
687 [ + - ]: 509903 : long nTmpLeft = (pTmp->Frm().*fnRect->fnGetLeft)();
688 [ - + ][ - + ]: 509903 : if( pTmp->IsRowFrm() && nRowSpan > 1 )
[ + + ]
689 : : {
690 : 0 : const SwFrm* pNxt = pTmp;
691 [ # # ][ # # ]: 0 : while( --nRowSpan > 0 && pNxt->GetNext() )
[ # # ]
692 : 0 : pNxt = pNxt->GetNext();
693 [ # # ]: 0 : if( pTmp->IsVertical() )
694 [ # # ]: 0 : nTmpLeft = (pNxt->Frm().*fnRect->fnGetLeft)();
695 : : else
696 [ # # ]: 0 : nTmpRight = (pNxt->Frm().*fnRect->fnGetRight)();
697 : : }
698 : : OSL_ENSURE( pTmp, "PaintArea lost in time and space" );
699 [ + + ][ + + : 1437443 : if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() ||
+ + + + -
+ ][ + + ]
700 : 661420 : pTmp->IsCellFrm() || pTmp->IsRowFrm() || //nobody leaves a table!
701 : 266120 : pTmp->IsRootFrm() )
702 : : {
703 [ + + ][ + + ]: 243783 : if( bLeft || nLeft < nTmpLeft )
704 : 160718 : nLeft = nTmpLeft;
705 [ + + ][ + + ]: 243783 : if( bRight || nTmpRight < nRight )
706 : 160707 : nRight = nTmpRight;
707 [ + + ][ + + ]: 243783 : if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() || pTmp->IsRootFrm() )
[ - + ][ + + ]
708 : 160401 : break;
709 : 83382 : bLeft = sal_False;
710 : 83382 : bRight = sal_False;
711 : : }
712 [ + + ]: 266120 : else if( pTmp->IsColumnFrm() ) // nobody enters neightbour columns
713 : : {
714 : 642 : sal_Bool bR2L = pTmp->IsRightToLeft();
715 : : // the first column has _no_ influence to the left range
716 [ + + ][ - + ]: 642 : if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
717 : : {
718 [ - + ][ # # ]: 40 : if( bLeft || nLeft < nTmpLeft )
719 : 40 : nLeft = nTmpLeft;
720 : 40 : bLeft = sal_False;
721 : : }
722 : : // the last column has _no_ influence to the right range
723 [ - + ][ + + ]: 642 : if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
724 : : {
725 [ - + ][ # # ]: 60 : if( bRight || nTmpRight < nRight )
726 : 60 : nRight = nTmpRight;
727 : 60 : bRight = sal_False;
728 : : }
729 : : }
730 [ + + ][ + + ]: 265478 : else if( bVert && pTmp->IsBodyFrm() )
[ + + ]
731 : : {
732 : : // Header and footer frames have always horizontal direction and
733 : : // limit the body frame.
734 : : // A previous frame of a body frame must be a header,
735 : : // the next frame of a body frame may be a footnotecontainer or
736 : : // a footer. The footnotecontainer has the same direction like
737 : : // the body frame.
738 [ - + ][ # # ]: 4 : if( pTmp->GetPrev() && ( bLeft || nLeft < nTmpLeft ) )
[ # # ][ - + ]
739 : : {
740 : 0 : nLeft = nTmpLeft;
741 : 0 : bLeft = sal_False;
742 : : }
743 [ - + # # : 4 : if( pTmp->GetNext() &&
# # ][ # # ]
[ # # ][ - + ]
744 : 0 : ( pTmp->GetNext()->IsFooterFrm() || pTmp->GetNext()->GetNext() )
745 : : && ( bRight || nTmpRight < nRight ) )
746 : : {
747 : 0 : nRight = nTmpRight;
748 : 0 : bRight = sal_False;
749 : : }
750 : : }
751 : 349502 : pTmp = pTmp->GetUpper();
752 : : }
753 [ + - ]: 160401 : (aRect.*fnRect->fnSetLeft)( nLeft );
754 [ + - ]: 160401 : (aRect.*fnRect->fnSetRight)( nRight );
755 : 160401 : return aRect;
756 : : }
757 : :
758 : : /*************************************************************************
759 : : |*
760 : : |* SwFrm::UnionFrm()
761 : : |*
762 : : |* The unionframe is the framearea (Frm()) of a frame expanded by the
763 : : |* printarea, if there's a negative margin at the left or right side.
764 : : |*
765 : : |*************************************************************************/
766 : :
767 : 41404 : const SwRect SwFrm::UnionFrm( sal_Bool bBorder ) const
768 : : {
769 : 41404 : sal_Bool bVert = IsVertical();
770 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
771 [ # # ][ - + ]: 41404 : SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
772 [ + - ]: 41404 : long nLeft = (Frm().*fnRect->fnGetLeft)();
773 [ + - ]: 41404 : long nWidth = (Frm().*fnRect->fnGetWidth)();
774 [ + - ]: 41404 : long nPrtLeft = (Prt().*fnRect->fnGetLeft)();
775 [ + - ]: 41404 : long nPrtWidth = (Prt().*fnRect->fnGetWidth)();
776 [ + + ]: 41404 : if( nPrtLeft + nPrtWidth > nWidth )
777 : 5 : nWidth = nPrtLeft + nPrtWidth;
778 [ - + ]: 41404 : if( nPrtLeft < 0 )
779 : : {
780 : 0 : nLeft += nPrtLeft;
781 : 0 : nWidth -= nPrtLeft;
782 : : }
783 : 41404 : SwTwips nRight = nLeft + nWidth;
784 : 41404 : long nAdd = 0;
785 [ + + ]: 41404 : if( bBorder )
786 : : {
787 [ + - ]: 30364 : SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
788 [ + - ]: 30364 : const SwBorderAttrs &rAttrs = *aAccess.Get();
789 : 30364 : const SvxBoxItem &rBox = rAttrs.GetBox();
790 [ - + ]: 30364 : if ( rBox.GetLeft() )
791 [ # # ]: 0 : nLeft -= rBox.CalcLineSpace( BOX_LINE_LEFT );
792 [ - + ]: 30364 : else if ( rAttrs.IsBorderDist() )
793 [ # # ]: 0 : nLeft -= rBox.GetDistance( BOX_LINE_LEFT ) + 1;
794 [ - + ]: 30364 : if ( rBox.GetRight() )
795 [ # # ]: 0 : nAdd += rBox.CalcLineSpace( BOX_LINE_RIGHT );
796 [ - + ]: 30364 : else if ( rAttrs.IsBorderDist() )
797 [ # # ]: 0 : nAdd += rBox.GetDistance( BOX_LINE_RIGHT ) + 1;
798 [ - + ]: 30364 : if( rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE )
799 : : {
800 : 0 : const SvxShadowItem &rShadow = rAttrs.GetShadow();
801 [ # # ]: 0 : nLeft -= rShadow.CalcShadowSpace( SHADOW_LEFT );
802 [ # # ]: 0 : nAdd += rShadow.CalcShadowSpace( SHADOW_RIGHT );
803 [ + - ]: 30364 : }
804 : : }
805 [ + + ][ + + ]: 41404 : if( IsTxtFrm() && ((SwTxtFrm*)this)->HasPara() )
[ + + ]
806 : : {
807 : 28224 : long nTmp = ((SwTxtFrm*)this)->HangingMargin();
808 [ - + ]: 28224 : if( nTmp > nAdd )
809 : 0 : nAdd = nTmp;
810 : : }
811 : 41404 : nWidth = nRight + nAdd - nLeft;
812 : 41404 : SwRect aRet( Frm() );
813 [ + - ]: 41404 : (aRet.*fnRect->fnSetPosX)( nLeft );
814 [ + - ]: 41404 : (aRet.*fnRect->fnSetWidth)( nWidth );
815 : 41404 : return aRet;
816 : : }
817 : :
818 : :
819 : :
820 : :
821 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|