LibreOffice Module sw (master)  1
ssfrm.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <pagefrm.hxx>
21 #include <rootfrm.hxx>
22 #include <dcontact.hxx>
23 #include <flyfrm.hxx>
24 #include <txtfrm.hxx>
25 #include <cellfrm.hxx>
26 #include <swtable.hxx>
27 #include <fmtfsize.hxx>
28 #include <editeng/boxitem.hxx>
29 #include <editeng/shaditem.hxx>
31 #include <fmtclds.hxx>
32 #include <viewimp.hxx>
33 #include <sortedobjs.hxx>
34 #include <hints.hxx>
35 #include <frmtool.hxx>
36 #include <ndtxt.hxx>
37 
38  // No inline cause we need the function pointers
40  { return getFramePrintArea().Top(); }
44  { return getFramePrintArea().Left(); }
47 long SwFrame::GetPrtLeft() const
48  { return getFrameArea().Left() + getFramePrintArea().Left(); }
50  { return getFrameArea().Top() + getFramePrintArea().Height() + getFramePrintArea().Top(); }
53 long SwFrame::GetPrtTop() const
54  { return getFrameArea().Top() + getFramePrintArea().Top(); }
55 
56 bool SwFrame::SetMinLeft( long nDeadline )
57 {
58  SwTwips nDiff = nDeadline - getFrameArea().Left();
59  if( nDiff > 0 )
60  {
62  aFrm.Left( nDeadline );
63 
65  aPrt.Width( aPrt.Width() - nDiff );
66 
67  return true;
68  }
69  return false;
70 }
71 
72 bool SwFrame::SetMaxBottom( long nDeadline )
73 {
74  SwTwips nDiff = getFrameArea().Top() + getFrameArea().Height() - nDeadline;
75  if( nDiff > 0 )
76  {
78  aFrm.Height( aFrm.Height() - nDiff );
79 
81  aPrt.Height( aPrt.Height() - nDiff );
82 
83  return true;
84  }
85  return false;
86 }
87 
88 bool SwFrame::SetMaxRight( long nDeadline )
89 {
90  SwTwips nDiff = getFrameArea().Left() + getFrameArea().Width() - nDeadline;
91  if( nDiff > 0 )
92  {
94  aFrm.Width( aFrm.Width() - nDiff );
95 
97  aPrt.Width( aPrt.Width() - nDiff );
98 
99  return true;
100  }
101  return false;
102 }
103 
104 void SwFrame::MakeBelowPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
105 {
107 
108  if( pPrv )
109  {
110  aFrm.Pos( pPrv->getFrameArea().Pos() );
111  aFrm.Pos().AdjustY(pPrv->getFrameArea().Height() );
112  }
113  else
114  {
115  aFrm.Pos( pUp->getFrameArea().Pos() );
116  aFrm.Pos() += pUp->getFramePrintArea().Pos();
117  }
118 
119  if( bNotify )
120  {
121  aFrm.Pos().AdjustY(1 );
122  }
123 }
124 
125 void SwFrame::MakeLeftPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
126 {
128 
129  if( pPrv )
130  {
131  aFrm.Pos( pPrv->getFrameArea().Pos() );
132  aFrm.Pos().AdjustX( -(aFrm.Width()) );
133  }
134  else
135  {
136  aFrm.Pos( pUp->getFrameArea().Pos() );
137  aFrm.Pos() += pUp->getFramePrintArea().Pos();
138  aFrm.Pos().AdjustX(pUp->getFramePrintArea().Width() - aFrm.Width() );
139  }
140 
141  if( bNotify )
142  {
143  aFrm.Pos().AdjustX( -1 );
144  }
145 }
146 
147 void SwFrame::MakeRightPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
148 {
150 
151  if( pPrv )
152  {
153  aFrm.Pos( pPrv->getFrameArea().Pos() );
154  aFrm.Pos().AdjustX(pPrv->getFrameArea().Width() );
155  }
156  else
157  {
158  aFrm.Pos( pUp->getFrameArea().Pos() );
159  aFrm.Pos() += pUp->getFramePrintArea().Pos();
160  }
161 
162  if( bNotify )
163  {
164  aFrm.Pos().AdjustX(1 );
165  }
166 }
167 
168 void SwFrame::SetTopBottomMargins( long nTop, long nBot )
169 {
171  aPrt.Top( nTop );
172  aPrt.Height( getFrameArea().Height() - nTop - nBot );
173 }
174 
175 void SwFrame::SetLeftRightMargins( long nLeft, long nRight)
176 {
178  aPrt.Left( nLeft );
179  aPrt.Width( getFrameArea().Width() - nLeft - nRight );
180 }
181 
182 void SwFrame::SetRightLeftMargins( long nRight, long nLeft)
183 {
185  aPrt.Left( nLeft );
186  aPrt.Width( getFrameArea().Width() - nLeft - nRight );
187 }
188 
191 {
192  bool bOldVert = mbVertical;
193  bool bOldR2L = mbRightToLeft;
194  SetInvalidVert( true );
195  mbInvalidR2L = true;
196  bool bChg = bOldR2L != IsRightToLeft();
197  bool bOldVertL2R = IsVertLR();
198  if( ( IsVertical() != bOldVert ) || bChg || bOldVertL2R != IsVertLR() )
199  {
200  InvalidateAll();
201  if( IsLayoutFrame() )
202  {
203  // set minimum row height for vertical cells in horizontal table:
204  if ( IsCellFrame() && GetUpper() )
205  {
206  if ( IsVertical() != GetUpper()->IsVertical() &&
207  static_cast<SwCellFrame*>(this)->GetTabBox()->getRowSpan() == 1 )
208  {
209  enum {
210  MIN_VERT_CELL_HEIGHT = 1135
211  };
212 
213  SwTableLine* pLine = const_cast<SwTableLine*>(static_cast<SwCellFrame*>(this)->GetTabBox()->GetUpper());
214  SwFrameFormat* pFrameFormat = pLine->GetFrameFormat();
215  SwFormatFrameSize aNew( pFrameFormat->GetFrameSize() );
216  if ( ATT_FIX_SIZE != aNew.GetHeightSizeType() )
218  if ( aNew.GetHeight() < MIN_VERT_CELL_HEIGHT )
219  aNew.SetHeight( MIN_VERT_CELL_HEIGHT );
220  SwDoc* pDoc = pFrameFormat->GetDoc();
221  pDoc->SetAttr( aNew, *pLine->ClaimFrameFormat() );
222  }
223  }
224 
225  SwFrame* pFrame = static_cast<SwLayoutFrame*>(this)->Lower();
226  const SwFormatCol* pCol = nullptr;
227  SwLayoutFrame* pBody = nullptr;
228  if( pFrame )
229  {
230  if( IsPageFrame() )
231  {
232  // If we're a page frame and we change our layout direction,
233  // we have to look for columns and rearrange them.
234  pBody = static_cast<SwPageFrame*>(this)->FindBodyCont();
235  if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame())
236  pCol = &static_cast<SwPageFrame*>(this)->GetFormat()->GetCol();
237  }
238  else if( pFrame->IsColumnFrame() )
239  {
240  pBody = static_cast<SwLayoutFrame*>(this);
241  const SwFrameFormat *pFormat = pBody->GetFormat();
242  if( pFormat )
243  pCol = &pFormat->GetCol();
244  }
245  }
246  while( pFrame )
247  {
248  pFrame->CheckDirChange();
249  pFrame = pFrame->GetNext();
250  }
251  if( pCol )
252  pBody->AdjustColumns( pCol, true );
253  }
254  else if( IsTextFrame() )
255  static_cast<SwTextFrame*>(this)->Prepare();
256 
257  // #i31698# - notify anchored objects also for page frames.
258  // Remove code above for special handling of page frames
259  if ( GetDrawObjs() )
260  {
261  const SwSortedObjs *pObjs = GetDrawObjs();
262  const size_t nCnt = pObjs->size();
263  for ( size_t i = 0; i < nCnt; ++i )
264  {
265  SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
266  if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
267  static_cast<SwFlyFrame*>(pAnchoredObj)->CheckDirChange();
268  else
269  {
270  // OD 2004-04-06 #i26791# - direct object
271  // positioning no longer needed. Instead
272  // invalidate
273  pAnchoredObj->InvalidateObjPos();
274  }
275  // #i31698# - update layout direction of
276  // anchored object
277  {
278  ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrameContainingAnchPos() );
279  pAnchoredObj->UpdateLayoutDir();
280  }
281  }
282  }
283  }
284 }
285 
287 // OD 2004-03-10 #i11860# - consider lower space and line spacing of
288 // previous frame according to new option 'Use former object positioning'
289 Point SwFrame::GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const
290 {
291  Point aAnchor = getFrameArea().Pos();
292 
293  if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
294  aAnchor.AdjustX(getFrameArea().Width() );
295 
296  if ( IsTextFrame() )
297  {
298  SwTwips nBaseOfstForFly =
299  static_cast<const SwTextFrame*>(this)->GetBaseOfstForFly( bIgnoreFlysAnchoredAtThisFrame );
300  if ( IsVertical() )
301  aAnchor.AdjustY(nBaseOfstForFly );
302  else
303  aAnchor.AdjustX(nBaseOfstForFly );
304 
305  // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
306  // is OFF, consider the lower space and the line spacing of the
307  // previous frame and the spacing considered for the page grid
308  const SwTextFrame* pThisTextFrame = static_cast<const SwTextFrame*>(this);
309  const SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid =
311  if ( IsVertical() )
312  {
313  aAnchor.AdjustX( -nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
314  }
315  else
316  {
317  aAnchor.AdjustY(nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
318  }
319  }
320 
321  return aAnchor;
322 }
323 
325 {
326  mbInDtor = true;
327 
328  // accessible objects for fly and cell frames have been already disposed
329  // by the destructors of the derived classes.
330  if (IsAccessibleFrame() && !(IsFlyFrame() || IsCellFrame())
331  && (GetDep() || IsTextFrame())) // sw_redlinehide: text frame may not have Dep!
332  {
333  assert(!IsTextFrame() || GetDep() || static_cast<SwTextFrame*>(this)->GetMergedPara());
334  SwRootFrame *pRootFrame = getRootFrame();
335  if( pRootFrame && pRootFrame->IsAnyShellAccessible() )
336  {
337  SwViewShell *pVSh = pRootFrame->GetCurrShell();
338  if( pVSh && pVSh->Imp() )
339  {
340  OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" );
341  pVSh->Imp()->DisposeAccessibleFrame( this );
342  }
343  }
344  }
345 
346  if (m_pDrawObjs)
347  {
348  for (size_t i = m_pDrawObjs->size(); i; )
349  {
350  SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
351  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
352  {
353  SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
354  }
355  else
356  {
357  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
358  SwDrawContact* pContact =
359  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
360  OSL_ENSURE( pContact,
361  "<SwFrame::~SwFrame> - missing contact for drawing object" );
362  if ( pContact )
363  {
364  pContact->DisconnectObjFromLayout( pSdrObj );
365  }
366  }
367  }
368  m_pDrawObjs.reset();
369  }
370 }
371 
373 {
374  assert(m_isInDestroy); // check that only DestroySwFrame does "delete"
375  assert(!IsDeleteForbidden()); // check that it's not deleted while deletes are forbidden
376 #if OSL_DEBUG_LEVEL > 0
377  // JP 15.10.2001: for detection of access to deleted frames
378  mpRoot = reinterpret_cast<SwRootFrame*>(0x33333333);
379 #endif
380 }
381 
382 void SwFrame::DestroyFrame(SwFrame *const pFrame)
383 {
384  if (pFrame)
385  {
386  pFrame->m_isInDestroy = true;
387  pFrame->DestroyImpl();
388  assert(pFrame->mbInDtor); // check that nobody forgot to call base class
389  delete pFrame;
390  }
391 }
392 
394 {
395  return static_cast< const SwFrameFormat * >( GetDep() );
396 }
397 
399 {
400  return static_cast< SwFrameFormat * >( GetDep() );
401 }
402 
404 {
405  if ( pNew != GetFormat() )
406  {
407  SwFormatChg aOldFormat( GetFormat() );
408  pNew->Add( this );
409  SwFormatChg aNewFormat( pNew );
410  ModifyNotification( &aOldFormat, &aNewFormat );
411  }
412 }
413 
415  SwFrame( pContent, pSib ),
416  SwFlowFrame( static_cast<SwFrame&>(*this) )
417 {
418  assert(!getRootFrame()->IsHideRedlines() || pContent->IsCreateFrameWhenHidingRedlines());
419 }
420 
422 {
423  const SwContentNode* pCNd(dynamic_cast<SwContentNode*>(GetDep()));
424  if (nullptr == pCNd && IsTextFrame())
425  {
426  pCNd = static_cast<SwTextFrame*>(this)->GetTextNodeFirst();
427  }
428  // IsInDtor shouldn't be happening with ViewShell owning layout
429  assert(nullptr == pCNd || !pCNd->GetDoc()->IsInDtor());
430  if (nullptr != pCNd && !pCNd->GetDoc()->IsInDtor())
431  {
432  //Unregister from root if I'm still in turbo there.
433  SwRootFrame *pRoot = getRootFrame();
434  if( pRoot && pRoot->GetTurbo() == this )
435  {
436  pRoot->DisallowTurbo();
437  pRoot->ResetTurbo();
438  }
439  }
440 
442 }
443 
445 {
446 }
447 
448 void SwTextFrame::RegisterToNode(SwTextNode & rNode, bool const isForceNodeAsFirst)
449 {
450  if (isForceNodeAsFirst && m_pMergedPara)
451  { // nothing registered here, in particular no redlines
452  assert(m_pMergedPara->pFirstNode->GetIndex() + 1 == rNode.GetIndex());
455  }
456  assert(&rNode != GetDep());
457  assert(!m_pMergedPara
458  || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())
459  || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex()));
460  SwTextNode & rFirstNode(
461  (!isForceNodeAsFirst && m_pMergedPara && m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())
462  ? *m_pMergedPara->pFirstNode
463  : rNode);
464  // sw_redlinehide: use New here, because the only caller also calls lcl_ChangeFootnoteRef
466  if (!m_pMergedPara)
467  {
468  rNode.Add(this);
469  }
470 }
471 
472 //Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete
473 //it in e.g. SwSectionFrame::MergeNext etc because we will need it
474 //again after the SwFrameDeleteGuard dtor
476  : m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ? pFrame : nullptr)
477 {
478  if (m_pForbidFrame)
479  {
481  }
482 }
483 
485 {
486  if (m_pForbidFrame)
487  {
488  const bool bLogicErrorThrown = !m_pForbidFrame->IsDeleteForbidden();
489  if (bLogicErrorThrown)
490  {
491  // see testForcepoint80
493  return;
494  }
496  }
497 }
498 
500 {
501  while (!m_VertPosOrientFramesFor.empty())
502  {
504  pObj->ClearVertPosOrientFrame();
505  }
506 
507  assert(m_VertPosOrientFramesFor.empty());
508 
509  SwFrame *pFrame = m_pLower;
510 
511  if( GetFormat() && !GetFormat()->GetDoc()->IsInDtor() )
512  {
513  bool bFatalError = false;
514  while ( pFrame )
515  {
516  //First delete the Objs of the Frame because they can't unregister
517  //from the page after remove.
518  //We don't want to create an endless loop only because one couldn't
519  //unregister.
520 
521  while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
522  {
523  const size_t nCnt = pFrame->GetDrawObjs()->size();
524  // #i28701#
525  SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[0];
526  if (SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
527  {
528  SwFrame::DestroyFrame(pFlyFrame);
529  assert(!pFrame->GetDrawObjs() || nCnt > pFrame->GetDrawObjs()->size());
530  }
531  else
532  {
533  pAnchoredObj->ClearTmpConsiderWrapInfluence();
534  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
535  SwDrawContact* pContact =
536  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
537  OSL_ENSURE( pContact,
538  "<SwFrame::~SwFrame> - missing contact for drawing object" );
539  if ( pContact )
540  {
541  pContact->DisconnectObjFromLayout( pSdrObj );
542  }
543 
544  if ( pFrame->GetDrawObjs() &&
545  nCnt == pFrame->GetDrawObjs()->size() )
546  {
547  pFrame->GetDrawObjs()->Remove( *pAnchoredObj );
548  }
549  }
550  }
551  pFrame->RemoveFromLayout();
552  // see testForcepoint80
553  if (pFrame->IsDeleteForbidden())
554  {
555  pFrame->AllowDelete();
556  bFatalError = true;
557  }
558  else
559  SwFrame::DestroyFrame(pFrame);
560  pFrame = m_pLower;
561  }
562 
563  if (bFatalError)
564  throw std::logic_error("DeleteForbidden");
565 
566  //Delete the Flys, the last one also deletes the array.
567  while ( GetDrawObjs() && GetDrawObjs()->size() )
568  {
569  const size_t nCnt = GetDrawObjs()->size();
570 
571  // #i28701#
572  SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
573  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
574  {
575  SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
576  assert(!GetDrawObjs() || nCnt > GetDrawObjs()->size());
577  }
578  else
579  {
580  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
581  SwDrawContact* pContact =
582  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
583  OSL_ENSURE( pContact,
584  "<SwFrame::~SwFrame> - missing contact for drawing object" );
585  if ( pContact )
586  {
587  pContact->DisconnectObjFromLayout( pSdrObj );
588  }
589 
590  if ( GetDrawObjs() && nCnt == GetDrawObjs()->size() )
591  {
592  GetDrawObjs()->Remove( *pAnchoredObj );
593  }
594  }
595  }
596  }
597  else
598  {
599  while( pFrame )
600  {
601  SwFrame *pNxt = pFrame->GetNext();
602  SwFrame::DestroyFrame(pFrame);
603  pFrame = pNxt;
604  }
605  }
606 
608 }
609 
611 {
612 }
613 
620 {
621  // NEW TABLES
622  // Cell frames may not leave their upper:
623  SwRect aRect = IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
624  const bool bVert = IsVertical();
625  SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
626  long nRight = (aRect.*fnRect->fnGetRight)();
627  long nLeft = (aRect.*fnRect->fnGetLeft)();
628  const SwFrame* pTmp = this;
629  bool bLeft = true;
630  bool bRight = true;
631  long nRowSpan = 0;
632  while( pTmp )
633  {
634  if( pTmp->IsCellFrame() && pTmp->GetUpper() &&
635  pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
636  nRowSpan = static_cast<const SwCellFrame*>(pTmp)->GetTabBox()->getRowSpan();
637  long nTmpRight = (pTmp->getFrameArea().*fnRect->fnGetRight)();
638  long nTmpLeft = (pTmp->getFrameArea().*fnRect->fnGetLeft)();
639  if( pTmp->IsRowFrame() && nRowSpan > 1 )
640  {
641  const SwFrame* pNxt = pTmp;
642  while( --nRowSpan > 0 && pNxt->GetNext() )
643  pNxt = pNxt->GetNext();
644  if( pTmp->IsVertical() )
645  nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
646  else
647  nTmpRight = (pNxt->getFrameArea().*fnRect->fnGetRight)();
648  }
649  OSL_ENSURE( pTmp, "GetPaintArea lost in time and space" );
650  if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() ||
651  pTmp->IsCellFrame() || pTmp->IsRowFrame() || //nobody leaves a table!
652  pTmp->IsRootFrame() )
653  {
654  if( bLeft || nLeft < nTmpLeft )
655  nLeft = nTmpLeft;
656  if( bRight || nTmpRight < nRight )
657  nRight = nTmpRight;
658  if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() || pTmp->IsRootFrame() )
659  break;
660  bLeft = false;
661  bRight = false;
662  }
663  else if( pTmp->IsColumnFrame() ) // nobody enters neighbour columns
664  {
665  bool bR2L = pTmp->IsRightToLeft();
666  // the first column has _no_ influence to the left range
667  if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
668  {
669  if( bLeft || nLeft < nTmpLeft )
670  nLeft = nTmpLeft;
671  bLeft = false;
672  }
673  // the last column has _no_ influence to the right range
674  if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
675  {
676  if( bRight || nTmpRight < nRight )
677  nRight = nTmpRight;
678  bRight = false;
679  }
680  }
681  else if( bVert && pTmp->IsBodyFrame() )
682  {
683  // Header and footer frames have always horizontal direction and
684  // limit the body frame.
685  // A previous frame of a body frame must be a header,
686  // the next frame of a body frame may be a footnotecontainer or
687  // a footer. The footnotecontainer has the same direction like
688  // the body frame.
689  if( pTmp->GetPrev() && ( bLeft || nLeft < nTmpLeft ) )
690  {
691  nLeft = nTmpLeft;
692  bLeft = false;
693  }
694  if( pTmp->GetNext() &&
695  ( pTmp->GetNext()->IsFooterFrame() || pTmp->GetNext()->GetNext() )
696  && ( bRight || nTmpRight < nRight ) )
697  {
698  nRight = nTmpRight;
699  bRight = false;
700  }
701  }
702  pTmp = pTmp->GetUpper();
703  }
704  (aRect.*fnRect->fnSetLeft)( nLeft );
705  (aRect.*fnRect->fnSetRight)( nRight );
706  return aRect;
707 }
708 
713 const SwRect SwFrame::UnionFrame( bool bBorder ) const
714 {
715  bool bVert = IsVertical();
716  SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
717  long nLeft = (getFrameArea().*fnRect->fnGetLeft)();
718  long nWidth = (getFrameArea().*fnRect->fnGetWidth)();
719  long nPrtLeft = (getFramePrintArea().*fnRect->fnGetLeft)();
720  long nPrtWidth = (getFramePrintArea().*fnRect->fnGetWidth)();
721  SwRectFnSet aRectFnSet(this);
722  if (aRectFnSet.XInc(nPrtLeft, nPrtWidth) > nWidth)
723  nWidth = nPrtLeft + nPrtWidth;
724  if( nPrtLeft < 0 )
725  {
726  nLeft += nPrtLeft;
727  nWidth -= nPrtLeft;
728  }
729  SwTwips nRight = aRectFnSet.XInc(nLeft, nWidth);
730  long nAdd = 0;
731  if( bBorder )
732  {
733  SwBorderAttrAccess aAccess( SwFrame::GetCache(), this );
734  const SwBorderAttrs &rAttrs = *aAccess.Get();
735  const SvxBoxItem &rBox = rAttrs.GetBox();
736  if ( rBox.GetLeft() )
737  nLeft -= rBox.CalcLineSpace( SvxBoxItemLine::LEFT );
738  else
739  nLeft -= rBox.GetDistance( SvxBoxItemLine::LEFT ) + 1;
740  if ( rBox.GetRight() )
741  nAdd += rBox.CalcLineSpace( SvxBoxItemLine::RIGHT );
742  else
743  nAdd += rBox.GetDistance( SvxBoxItemLine::RIGHT ) + 1;
744  if( rAttrs.GetShadow().GetLocation() != SvxShadowLocation::NONE )
745  {
746  const SvxShadowItem &rShadow = rAttrs.GetShadow();
747  nLeft -= rShadow.CalcShadowSpace( SvxShadowItemSide::LEFT );
748  nAdd += rShadow.CalcShadowSpace( SvxShadowItemSide::RIGHT );
749  }
750  }
751  if( IsTextFrame() && static_cast<const SwTextFrame*>(this)->HasPara() )
752  {
753  long nTmp = static_cast<const SwTextFrame*>(this)->HangingMargin();
754  if( nTmp > nAdd )
755  nAdd = nTmp;
756  }
757  nWidth = aRectFnSet.XDiff(aRectFnSet.XInc(nRight, nAdd), nLeft);
758  SwRect aRet( getFrameArea() );
759  (aRet.*fnRect->fnSetLeft)(nLeft);
760  (aRet.*fnRect->fnSetWidth)( nWidth );
761  return aRet;
762 }
763 
764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
long GetPrtLeft() const
Definition: ssfrm.cxx:47
sal_uLong GetIndex() const
Definition: node.hxx:282
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
bool IsRootFrame() const
Definition: frame.hxx:1150
SwRootFrame * mpRoot
Definition: frame.hxx:317
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:384
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
long AdjustX(long nHorzMove)
virtual void UpdateLayoutDir()
method update layout direction the layout direction, the anchored object is assigned to ...
void MakeLeftPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:125
SwModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:457
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
static SwCache & GetCache()
Definition: frame.hxx:500
const SwRect UnionFrame(bool bBorder=false) const
|* The unionframe is the framearea (getFrameArea()) of a frame expanded by the |* printarea...
Definition: ssfrm.cxx:713
Definition: doc.hxx:185
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1482
void Height(long nNew)
Definition: swrect.hxx:189
const SvxShadowItem & GetShadow() const
Definition: frmtool.hxx:363
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
long SwTwips
Definition: swtypes.hxx:49
SwRectGet fnGetWidth
Definition: frame.hxx:1256
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
void Pos(const Point &rNew)
Definition: swrect.hxx:167
SwContentFrame(SwContentNode *const, SwFrame *)
Definition: ssfrm.cxx:414
bool IsCellFrame() const
Definition: frame.hxx:1202
void SetRightLeftMargins(long, long)
Definition: ssfrm.cxx:182
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const editeng::SvxBorderLine * GetRight() const
bool mbInDtor
Definition: frame.hxx:397
Frame cannot be moved in Var-direction.
Definition: fmtfsize.hxx:38
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
void RegisterToNode(SwTextNode &, bool isForceNodeAsFirst=false)
Definition: ssfrm.cxx:448
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:190
bool IsVertLRBT() const
Definition: frame.hxx:959
SwRectGet fnGetRight
Definition: frame.hxx:1255
bool IsFlyFrame() const
Definition: frame.hxx:1186
wrapper class for the positioning of Writer fly frames and drawing objects
void SetTopBottomMargins(long, long)
Definition: ssfrm.cxx:168
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
void Top(const long nTop)
Definition: swrect.hxx:202
SvxShadowLocation GetLocation() const
virtual ~SwFrame() override
Definition: ssfrm.cxx:372
const SwRect & getFrameArea() const
Definition: frame.hxx:175
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
Definition: redlnitr.cxx:54
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:478
bool IsTextFrame() const
Definition: frame.hxx:1210
SwRectFn fnRectVertL2R
Definition: newfrm.cxx:290
virtual void DestroyImpl() override
Definition: ssfrm.cxx:499
SdrObject * DrawObj()
SwRectFn fnRectHori
Definition: newfrm.cxx:288
const SwRect GetPaintArea() const
|* The paintarea is the area, in which the content of a frame is allowed |* to be displayed...
Definition: ssfrm.cxx:619
virtual void DestroyImpl()
Definition: ssfrm.cxx:324
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
bool IsColumnFrame() const
Definition: frame.hxx:1158
bool SetMaxRight(long)
Definition: ssfrm.cxx:88
SwRectFn fnRectVertL2RB2T
Definition: newfrm.cxx:291
void ResetTurbo()
Definition: rootfrm.hxx:346
void SetInvalidVert(bool bNew)
Definition: frame.hxx:608
void MakeBelowPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:104
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
Style of a layout element.
Definition: frmfmt.hxx:57
const editeng::SvxBorderLine * GetLeft() const
long XInc(long n1, long n2) const
Definition: frame.hxx:1385
std::vector< SwAnchoredObject * > m_VertPosOrientFramesFor
Definition: layfrm.hxx:53
long AdjustY(long nVertMove)
void SetFrameFormat(SwFrameFormat *)
Definition: ssfrm.cxx:403
long XDiff(long n1, long n2) const
Definition: frame.hxx:1383
void Remove(SwAnchoredObject &_rAnchoredObj)
Definition: sortedobjs.cxx:227
size_t size() const
Definition: sortedobjs.cxx:42
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:863
SwFrame * m_pLower
Definition: layfrm.hxx:52
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
const SwFrame * Lower() const
Definition: layfrm.hxx:100
int i
bool m_isInDestroy
Definition: frame.hxx:426
void AllowDelete()
Definition: frame.hxx:904
SwDoc * GetDoc()
Definition: node.hxx:702
bool mbInvalidR2L
Definition: frame.hxx:398
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
const SvxBoxItem & GetBox() const
Definition: frmtool.hxx:362
bool mbVertical
Definition: frame.hxx:403
long GetPrtTop() const
Definition: ssfrm.cxx:53
virtual ~SwLayoutFrame() override
Definition: ssfrm.cxx:610
bool IsRowFrame() const
Definition: frame.hxx:1198
void ClearVertPosOrientFrame()
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1646
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:366
SwFrame * GetPrev()
Definition: frame.hxx:655
size
long GetTopMargin() const
Definition: ssfrm.cxx:39
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
SwFrameDeleteGuard(SwFrame *pFrame)
Definition: ssfrm.cxx:475
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
A page of the document layout.
Definition: pagefrm.hxx:40
void MakeRightPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:147
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
SwRectSet fnSetLeft
Definition: frame.hxx:1263
SwBorderAttrs * Get()
Definition: frmtool.cxx:2377
long GetBottomMargin() const
Definition: ssfrm.cxx:41
SwRectGet fnGetLeft
Definition: frame.hxx:1254
long GetPrtRight() const
Definition: ssfrm.cxx:51
bool IsLayoutFrame() const
Definition: frame.hxx:1146
void Left(const long nLeft)
Definition: swrect.hxx:193
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwFrame * m_pForbidFrame
Definition: frame.hxx:1235
const SwContentFrame * GetTurbo()
Definition: rootfrm.hxx:347
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
bool IsVertLR() const
Definition: frame.hxx:955
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
long GetRightMargin() const
Definition: ssfrm.cxx:45
void Width(long nNew)
Definition: swrect.hxx:185
void DisconnectObjFromLayout(SdrObject *_pDrawObj)
disconnect for a dedicated drawing object - could be 'master' or 'virtual'.
Definition: dcontact.cxx:1668
void ClearTmpConsiderWrapInfluence()
bool IsRightToLeft() const
Definition: frame.hxx:963
std::unique_ptr< sw::MergedPara > m_pMergedPara
redline merge data
Definition: txtfrm.hxx:187
bool IsCreateFrameWhenHidingRedlines()
Definition: node.hxx:93
SwFrame * GetLower()
Definition: findfrm.cxx:169
bool IsPageFrame() const
Definition: frame.hxx:1154
SwRectSet fnSetWidth
Definition: frame.hxx:1265
void SetLeftRightMargins(long, long)
Definition: ssfrm.cxx:175
bool SetMaxBottom(long)
Definition: ssfrm.cxx:72
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
sal_uInt16 CalcLineSpace(SvxBoxItemLine nLine, bool bEvenIfNoLine=false) const
void DisallowTurbo() const
Definition: rootfrm.hxx:342
void setContextWritingMode(SdrObject *pObj, SwFrame const *pAnchor)
Definition: dcontact.cxx:107
bool mbRightToLeft
Definition: frame.hxx:400
bool IsVertical() const
Definition: frame.hxx:949
virtual ~SwContentFrame() override
Definition: ssfrm.cxx:444
bool IsInDtor() const
Definition: doc.hxx:398
bool IsAccessibleFrame() const
Definition: frame.hxx:1226
SwRectSet fnSetRight
Definition: frame.hxx:1264
void InvalidateAll()
Definition: frame.hxx:1031
void AdjustColumns(const SwFormatCol *pCol, bool bAdjustAttributes)
Definition: colfrm.cxx:294
void ForbidDelete()
Definition: frame.hxx:903
SwRectFn fnRectVert
Definition: newfrm.cxx:289
virtual bool Prepare(const PrepareHint ePrep=PREP_CLEAR, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:587
long GetLeftMargin() const
Definition: ssfrm.cxx:43
bool IsBodyFrame() const
Definition: frame.hxx:1182
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
class for collecting anchored objects
Definition: sortedobjs.hxx:48
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
Definition: ssfrm.cxx:289
static constexpr size_type npos
Definition: docary.hxx:331
SdrObjUserCall * GetUserCall() const
std::unique_ptr< SwSortedObjs > m_pDrawObjs
Definition: frame.hxx:394
bool IsFooterFrame() const
Definition: frame.hxx:1170
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
long GetPrtBottom() const
Definition: ssfrm.cxx:49
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
bool SetMinLeft(long)
Definition: ssfrm.cxx:56
virtual void DestroyImpl() override
Definition: ssfrm.cxx:421
void DisposeAccessibleFrame(const SwFrame *pFrame, bool bRecursive=false)
Definition: viewimp.hxx:279
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
SwFrame * GetNext()
Definition: frame.hxx:654