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 <IDocumentMarkAccess.hxx>
32 #include <fmtclds.hxx>
33 #include <viewimp.hxx>
34 #include <sortedobjs.hxx>
35 #include <hints.hxx>
36 #include <frmtool.hxx>
37 #include <ndtxt.hxx>
38 #include <osl/diagnose.h>
39 
40  // No inline cause we need the function pointers
42  { return getFramePrintArea().Top(); }
46  { return getFramePrintArea().Left(); }
50  { return getFrameArea().Left() + getFramePrintArea().Left(); }
52  { return getFrameArea().Top() + getFramePrintArea().Height() + getFramePrintArea().Top(); }
56  { return getFrameArea().Top() + getFramePrintArea().Top(); }
57 
59 {
60  SwTwips nDiff = nDeadline - getFrameArea().Left();
61  if( nDiff > 0 )
62  {
64  aFrm.Left( nDeadline );
65 
67  aPrt.Width( aPrt.Width() - nDiff );
68 
69  return true;
70  }
71  return false;
72 }
73 
75 {
76  SwTwips nDiff = getFrameArea().Top() + getFrameArea().Height() - nDeadline;
77  if( nDiff > 0 )
78  {
80  aFrm.Height( aFrm.Height() - nDiff );
81 
83  aPrt.Height( aPrt.Height() - nDiff );
84 
85  return true;
86  }
87  return false;
88 }
89 
91 {
92  SwTwips nDiff = getFrameArea().Left() + getFrameArea().Width() - nDeadline;
93  if( nDiff > 0 )
94  {
96  aFrm.Width( aFrm.Width() - nDiff );
97 
99  aPrt.Width( aPrt.Width() - nDiff );
100 
101  return true;
102  }
103  return false;
104 }
105 
106 void SwFrame::MakeBelowPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
107 {
109 
110  if( pPrv )
111  {
112  aFrm.Pos( pPrv->getFrameArea().Pos() );
113  aFrm.Pos().AdjustY(pPrv->getFrameArea().Height() );
114  }
115  else
116  {
117  aFrm.Pos( pUp->getFrameArea().Pos() );
118  aFrm.Pos() += pUp->getFramePrintArea().Pos();
119  }
120 
121  if( bNotify )
122  {
123  aFrm.Pos().AdjustY(1 );
124  }
125 }
126 
127 void SwFrame::MakeLeftPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
128 {
130 
131  if( pPrv )
132  {
133  aFrm.Pos( pPrv->getFrameArea().Pos() );
134  aFrm.Pos().AdjustX( -(aFrm.Width()) );
135  }
136  else
137  {
138  aFrm.Pos( pUp->getFrameArea().Pos() );
139  aFrm.Pos() += pUp->getFramePrintArea().Pos();
140  aFrm.Pos().AdjustX(pUp->getFramePrintArea().Width() - aFrm.Width() );
141  }
142 
143  if( bNotify )
144  {
145  aFrm.Pos().AdjustX( -1 );
146  }
147 }
148 
149 void SwFrame::MakeRightPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
150 {
152 
153  if( pPrv )
154  {
155  aFrm.Pos( pPrv->getFrameArea().Pos() );
156  aFrm.Pos().AdjustX(pPrv->getFrameArea().Width() );
157  }
158  else
159  {
160  aFrm.Pos( pUp->getFrameArea().Pos() );
161  aFrm.Pos() += pUp->getFramePrintArea().Pos();
162  }
163 
164  if( bNotify )
165  {
166  aFrm.Pos().AdjustX(1 );
167  }
168 }
169 
171 {
173  aPrt.Top( nTop );
174  aPrt.Height( getFrameArea().Height() - nTop - nBot );
175 }
176 
178 {
180  aPrt.Left( nLeft );
181  aPrt.Width( getFrameArea().Width() - nLeft - nRight );
182 }
183 
185 {
187  aPrt.Left( nLeft );
188  aPrt.Width( getFrameArea().Width() - nLeft - nRight );
189 }
190 
193 {
194  bool bOldVert = mbVertical;
195  bool bOldR2L = mbRightToLeft;
196  SetInvalidVert( true );
197  mbInvalidR2L = true;
198  bool bChg = bOldR2L != IsRightToLeft();
199  bool bOldVertL2R = IsVertLR();
200  if( !(( IsVertical() != bOldVert ) || bChg || bOldVertL2R != IsVertLR()) )
201  return;
202 
203  InvalidateAll();
204  if( IsLayoutFrame() )
205  {
206  // set minimum row height for vertical cells in horizontal table:
207  if ( IsCellFrame() && GetUpper() )
208  {
209  if ( IsVertical() != GetUpper()->IsVertical() &&
210  static_cast<SwCellFrame*>(this)->GetTabBox()->getRowSpan() == 1 )
211  {
212  enum {
213  MIN_VERT_CELL_HEIGHT = 1135
214  };
215 
216  SwTableLine* pLine = const_cast<SwTableLine*>(static_cast<SwCellFrame*>(this)->GetTabBox()->GetUpper());
217  SwFrameFormat* pFrameFormat = pLine->GetFrameFormat();
218  SwFormatFrameSize aNew( pFrameFormat->GetFrameSize() );
219  if ( SwFrameSize::Fixed != aNew.GetHeightSizeType() )
221  if ( aNew.GetHeight() < MIN_VERT_CELL_HEIGHT )
222  aNew.SetHeight( MIN_VERT_CELL_HEIGHT );
223  SwDoc* pDoc = pFrameFormat->GetDoc();
224  pDoc->SetAttr( aNew, *pLine->ClaimFrameFormat() );
225  }
226  }
227 
228  SwFrame* pFrame = static_cast<SwLayoutFrame*>(this)->Lower();
229  const SwFormatCol* pCol = nullptr;
230  SwLayoutFrame* pBody = nullptr;
231  if( pFrame )
232  {
233  if( IsPageFrame() )
234  {
235  // If we're a page frame and we change our layout direction,
236  // we have to look for columns and rearrange them.
237  pBody = static_cast<SwPageFrame*>(this)->FindBodyCont();
238  if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame())
239  pCol = &static_cast<SwPageFrame*>(this)->GetFormat()->GetCol();
240  }
241  else if( pFrame->IsColumnFrame() )
242  {
243  pBody = static_cast<SwLayoutFrame*>(this);
244  const SwFrameFormat *pFormat = pBody->GetFormat();
245  if( pFormat )
246  pCol = &pFormat->GetCol();
247  }
248  }
249  while( pFrame )
250  {
251  pFrame->CheckDirChange();
252  pFrame = pFrame->GetNext();
253  }
254  if( pCol )
255  pBody->AdjustColumns( pCol, true );
256  }
257  else if( IsTextFrame() )
258  static_cast<SwTextFrame*>(this)->Prepare();
259 
260  // #i31698# - notify anchored objects also for page frames.
261  // Remove code above for special handling of page frames
262  if ( !GetDrawObjs() )
263  return;
264 
265  const SwSortedObjs *pObjs = GetDrawObjs();
266  const size_t nCnt = pObjs->size();
267  for ( size_t i = 0; i < nCnt; ++i )
268  {
269  SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
270  if( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
271  pFlyFrame->CheckDirChange();
272  else
273  {
274  // OD 2004-04-06 #i26791# - direct object
275  // positioning no longer needed. Instead
276  // invalidate
277  pAnchoredObj->InvalidateObjPos();
278  }
279  // #i31698# - update layout direction of
280  // anchored object
281  {
282  ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrameContainingAnchPos() );
283  pAnchoredObj->UpdateLayoutDir();
284  }
285  }
286 }
287 
289 // OD 2004-03-10 #i11860# - consider lower space and line spacing of
290 // previous frame according to new option 'Use former object positioning'
291 Point SwFrame::GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const
292 {
293  Point aAnchor = getFrameArea().Pos();
294 
295  if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
296  aAnchor.AdjustX(getFrameArea().Width() );
297 
298  if ( IsTextFrame() )
299  {
300  SwTwips nBaseOfstForFly =
301  static_cast<const SwTextFrame*>(this)->GetBaseOffsetForFly( bIgnoreFlysAnchoredAtThisFrame );
302  if ( IsVertical() )
303  aAnchor.AdjustY(nBaseOfstForFly );
304  else
305  aAnchor.AdjustX(nBaseOfstForFly );
306 
307  // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
308  // is OFF, consider the lower space and the line spacing of the
309  // previous frame and the spacing considered for the page grid
310  const SwTextFrame* pThisTextFrame = static_cast<const SwTextFrame*>(this);
311  const SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid =
313  if ( IsVertical() )
314  {
315  aAnchor.AdjustX( -nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
316  }
317  else
318  {
319  aAnchor.AdjustY(nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
320  }
321  }
322 
323  return aAnchor;
324 }
325 
327 {
328  mbInDtor = true;
329 
330  // accessible objects for fly and cell frames have been already disposed
331  // by the destructors of the derived classes.
332  if (IsAccessibleFrame() && !(IsFlyFrame() || IsCellFrame())
333  && (GetDep() || IsTextFrame())) // sw_redlinehide: text frame may not have Dep!
334  {
335  assert(!IsTextFrame() || GetDep() || static_cast<SwTextFrame*>(this)->GetMergedPara());
336  SwRootFrame *pRootFrame = getRootFrame();
337  if( pRootFrame && pRootFrame->IsAnyShellAccessible() )
338  {
339  SwViewShell *pVSh = pRootFrame->GetCurrShell();
340  if( pVSh && pVSh->Imp() )
341  {
342  OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" );
343  pVSh->Imp()->DisposeAccessibleFrame( this );
344  }
345  }
346  }
347 
348  if (!m_pDrawObjs)
349  return;
350 
351  for (size_t i = m_pDrawObjs->size(); i; )
352  {
353  SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
354  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
355  {
356  SwFrame::DestroyFrame(pFlyFrame);
357  }
358  else
359  {
360  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
361  SwDrawContact* pContact =
362  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
363  OSL_ENSURE( pContact,
364  "<SwFrame::~SwFrame> - missing contact for drawing object" );
365  if ( pContact )
366  {
367  pContact->DisconnectObjFromLayout( pSdrObj );
368  }
369  }
370  }
371  m_pDrawObjs.reset();
372 }
373 
375 {
376  assert(m_isInDestroy); // check that only DestroySwFrame does "delete"
377  assert(!IsDeleteForbidden()); // check that it's not deleted while deletes are forbidden
378 #if OSL_DEBUG_LEVEL > 0
379  // JP 15.10.2001: for detection of access to deleted frames
380  mpRoot = reinterpret_cast<SwRootFrame*>(0x33333333);
381 #endif
382 }
383 
384 void SwFrame::DestroyFrame(SwFrame *const pFrame)
385 {
386  if (pFrame)
387  {
388  pFrame->m_isInDestroy = true;
389  pFrame->DestroyImpl();
390  assert(pFrame->mbInDtor); // check that nobody forgot to call base class
391  delete pFrame;
392  }
393 }
394 
396 {
397  return static_cast< const SwFrameFormat * >( GetDep() );
398 }
399 
401 {
402  return static_cast< SwFrameFormat * >( GetDep() );
403 }
404 
406 {
407  if(pNew == GetFormat())
408  return;
409  const SwFormatChg aOldFormat(GetFormat());
410  pNew->Add(this);
411  const SwFormatChg aNewFormat(pNew);
412  SwClientNotify(*pNew, sw::LegacyModifyHint(&aOldFormat, &aNewFormat));
413 }
414 
416  SwFrame( pContent, pSib ),
417  SwFlowFrame( static_cast<SwFrame&>(*this) )
418 {
419  assert(!getRootFrame()->HasMergedParas() || pContent->IsCreateFrameWhenHidingRedlines());
420 }
421 
423 {
424  const SwContentNode* pCNd(dynamic_cast<SwContentNode*>(GetDep()));
425  if (nullptr == pCNd && IsTextFrame())
426  {
427  pCNd = static_cast<SwTextFrame*>(this)->GetTextNodeFirst();
428  }
429  // IsInDtor shouldn't be happening with ViewShell owning layout
430  assert(nullptr == pCNd || !pCNd->GetDoc().IsInDtor());
431  if (nullptr != pCNd && !pCNd->GetDoc().IsInDtor())
432  {
433  //Unregister from root if I'm still in turbo there.
434  SwRootFrame *pRoot = getRootFrame();
435  if( pRoot && pRoot->GetTurbo() == this )
436  {
437  pRoot->DisallowTurbo();
438  pRoot->ResetTurbo();
439  }
440  }
441 
443 }
444 
446 {
447 }
448 
449 void SwTextFrame::RegisterToNode(SwTextNode & rNode, bool const isForceNodeAsFirst)
450 {
451  if (isForceNodeAsFirst && m_pMergedPara)
452  { // nothing registered here, in particular no delete redlines (insert
453  // redline might end on empty node where delete rl starts, should be ok)
454  assert(m_pMergedPara->pFirstNode->GetIndex() + 1 == rNode.GetIndex());
456  *m_pMergedPara->pFirstNode, RedlineType::Delete) == SwRedlineTable::npos);
457  assert(std::find_if(
460  [this](::sw::mark::IMark const*const pMark) {
461  return pMark->GetMarkStart().nNode == *m_pMergedPara->pFirstNode
462  && pMark->GetMarkEnd().nNode != *m_pMergedPara->pFirstNode;
463  }) == rNode.GetDoc().getIDocumentMarkAccess()->getFieldmarksEnd());
464  }
465  assert(&rNode != GetDep());
467  || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())
468  || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex()));
469  SwTextNode & rFirstNode(
470  (!isForceNodeAsFirst && m_pMergedPara && m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())
471  ? *m_pMergedPara->pFirstNode
472  : rNode);
473  // sw_redlinehide: use New here, because the only caller also calls lcl_ChangeFootnoteRef
475  if (!m_pMergedPara)
476  {
477  rNode.Add(this);
478  }
479 }
480 
482 {
483  while (!m_VertPosOrientFramesFor.empty())
484  {
486  pObj->ClearVertPosOrientFrame();
487  }
488 
490 
491  SwFrame *pFrame = m_pLower;
492 
493  if( GetFormat() && !GetFormat()->GetDoc()->IsInDtor() )
494  {
495  while ( pFrame )
496  {
497  //First delete the Objs of the Frame because they can't unregister
498  //from the page after remove.
499  //We don't want to create an endless loop only because one couldn't
500  //unregister.
501 
502  while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
503  {
504  const size_t nCnt = pFrame->GetDrawObjs()->size();
505  // #i28701#
506  SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[0];
507  if (SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
508  {
509  SwFrame::DestroyFrame(pFlyFrame);
510  assert(!pFrame->GetDrawObjs() || nCnt > pFrame->GetDrawObjs()->size());
511  }
512  else
513  {
514  pAnchoredObj->ClearTmpConsiderWrapInfluence();
515  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
516  SwDrawContact* pContact =
517  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
518  OSL_ENSURE( pContact,
519  "<SwFrame::~SwFrame> - missing contact for drawing object" );
520  if ( pContact )
521  {
522  pContact->DisconnectObjFromLayout( pSdrObj );
523  }
524 
525  if ( pFrame->GetDrawObjs() &&
526  nCnt == pFrame->GetDrawObjs()->size() )
527  {
528  pFrame->GetDrawObjs()->Remove( *pAnchoredObj );
529  }
530  }
531  }
532  pFrame->RemoveFromLayout();
533  SwFrame::DestroyFrame(pFrame);
534  pFrame = m_pLower;
535  }
536  //Delete the Flys, the last one also deletes the array.
537  while ( GetDrawObjs() && GetDrawObjs()->size() )
538  {
539  const size_t nCnt = GetDrawObjs()->size();
540 
541  // #i28701#
542  SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
543  if ( auto pFlyFrame = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
544  {
545  SwFrame::DestroyFrame(pFlyFrame);
546  assert(!GetDrawObjs() || nCnt > GetDrawObjs()->size());
547  }
548  else
549  {
550  SdrObject* pSdrObj = pAnchoredObj->DrawObj();
551  SwDrawContact* pContact =
552  static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
553  OSL_ENSURE( pContact,
554  "<SwFrame::~SwFrame> - missing contact for drawing object" );
555  if ( pContact )
556  {
557  pContact->DisconnectObjFromLayout( pSdrObj );
558  }
559 
560  if ( GetDrawObjs() && nCnt == GetDrawObjs()->size() )
561  {
562  GetDrawObjs()->Remove( *pAnchoredObj );
563  }
564  }
565  }
566  }
567  else
568  {
569  while( pFrame )
570  {
571  SwFrame *pNxt = pFrame->GetNext();
572  SwFrame::DestroyFrame(pFrame);
573  pFrame = pNxt;
574  }
575  }
576 
578 }
579 
581 {
582 }
583 
590 {
591  // NEW TABLES
592  // Cell frames may not leave their upper:
593  SwRect aRect = IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
594  const bool bVert = IsVertical();
595  SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
596  SwRectFnSet aRectFnSet(this);
597  tools::Long nRight = (aRect.*fnRect->fnGetRight)();
598  tools::Long nLeft = (aRect.*fnRect->fnGetLeft)();
599  const SwFrame* pTmp = this;
600  bool bLeft = true;
601  bool bRight = true;
602  tools::Long nRowSpan = 0;
603  while( pTmp )
604  {
605  if( pTmp->IsCellFrame() && pTmp->GetUpper() &&
606  pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
607  nRowSpan = static_cast<const SwCellFrame*>(pTmp)->GetTabBox()->getRowSpan();
608  tools::Long nTmpRight = (pTmp->getFrameArea().*fnRect->fnGetRight)();
609  tools::Long nTmpLeft = (pTmp->getFrameArea().*fnRect->fnGetLeft)();
610  if( pTmp->IsRowFrame() && nRowSpan > 1 )
611  {
612  const SwFrame* pNxt = pTmp;
613  while( --nRowSpan > 0 && pNxt->GetNext() )
614  pNxt = pNxt->GetNext();
615  if( pTmp->IsVertical() )
616  nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
617  else
618  {
619  // pTmp is a row frame, but it's not vertical.
620  if (IsVertLRBT())
621  {
622  // This frame cell is OK to expand towards the physical down direction.
623  // Physical down is left.
624  nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
625  }
626  else
627  {
628  nTmpRight = (pNxt->getFrameArea().*fnRect->fnGetRight)();
629  }
630  }
631  }
632  OSL_ENSURE( pTmp, "GetPaintArea lost in time and space" );
633  if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() ||
634  pTmp->IsCellFrame() || pTmp->IsRowFrame() || //nobody leaves a table!
635  pTmp->IsRootFrame() )
636  {
637  // BTLR is OK to expand towards the physical down direction. Physical down is left.
638  if( bLeft || (aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 && !IsVertLRBT()) )
639  nLeft = nTmpLeft;
640  if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
641  nRight = nTmpRight;
642  if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() || pTmp->IsRootFrame() )
643  break;
644  bLeft = false;
645  bRight = false;
646  }
647  else if( pTmp->IsColumnFrame() ) // nobody enters neighbour columns
648  {
649  bool bR2L = pTmp->IsRightToLeft();
650  // the first column has _no_ influence to the left range
651  if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
652  {
653  if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
654  nLeft = nTmpLeft;
655  bLeft = false;
656  }
657  // the last column has _no_ influence to the right range
658  if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
659  {
660  if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
661  nRight = nTmpRight;
662  bRight = false;
663  }
664  }
665  else if( bVert && pTmp->IsBodyFrame() )
666  {
667  // Header and footer frames have always horizontal direction and
668  // limit the body frame.
669  // A previous frame of a body frame must be a header,
670  // the next frame of a body frame may be a footnotecontainer or
671  // a footer. The footnotecontainer has the same direction like
672  // the body frame.
673  if( pTmp->GetPrev() && ( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 ) )
674  {
675  nLeft = nTmpLeft;
676  bLeft = false;
677  }
678  if( pTmp->GetNext() &&
679  ( pTmp->GetNext()->IsFooterFrame() || pTmp->GetNext()->GetNext() )
680  && ( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 ) )
681  {
682  nRight = nTmpRight;
683  bRight = false;
684  }
685  }
686  pTmp = pTmp->GetUpper();
687  }
688  (aRect.*fnRect->fnSetLeft)( nLeft );
689  (aRect.*fnRect->fnSetRight)( nRight );
690  return aRect;
691 }
692 
697 SwRect SwFrame::UnionFrame( bool bBorder ) const
698 {
699  bool bVert = IsVertical();
700  SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
701  tools::Long nLeft = (getFrameArea().*fnRect->fnGetLeft)();
702  tools::Long nWidth = (getFrameArea().*fnRect->fnGetWidth)();
703  tools::Long nPrtLeft = (getFramePrintArea().*fnRect->fnGetLeft)();
704  tools::Long nPrtWidth = (getFramePrintArea().*fnRect->fnGetWidth)();
705  SwRectFnSet aRectFnSet(this);
706  if (aRectFnSet.XInc(nPrtLeft, nPrtWidth) > nWidth)
707  nWidth = nPrtLeft + nPrtWidth;
708  if( nPrtLeft < 0 )
709  {
710  nLeft += nPrtLeft;
711  nWidth -= nPrtLeft;
712  }
713  SwTwips nRight = aRectFnSet.XInc(nLeft, nWidth);
714  tools::Long nAdd = 0;
715  if( bBorder )
716  {
717  SwBorderAttrAccess aAccess( SwFrame::GetCache(), this );
718  const SwBorderAttrs &rAttrs = *aAccess.Get();
719  const SvxBoxItem &rBox = rAttrs.GetBox();
720  if ( rBox.GetLeft() )
721  nLeft -= rBox.CalcLineSpace( SvxBoxItemLine::LEFT );
722  else
723  nLeft -= rBox.GetDistance( SvxBoxItemLine::LEFT ) + 1;
724  if ( rBox.GetRight() )
725  nAdd += rBox.CalcLineSpace( SvxBoxItemLine::RIGHT );
726  else
727  nAdd += rBox.GetDistance( SvxBoxItemLine::RIGHT ) + 1;
728  if( rAttrs.GetShadow().GetLocation() != SvxShadowLocation::NONE )
729  {
730  const SvxShadowItem &rShadow = rAttrs.GetShadow();
731  nLeft -= rShadow.CalcShadowSpace( SvxShadowItemSide::LEFT );
732  nAdd += rShadow.CalcShadowSpace( SvxShadowItemSide::RIGHT );
733  }
734  }
735  if( IsTextFrame() && static_cast<const SwTextFrame*>(this)->HasPara() )
736  {
737  tools::Long nTmp = static_cast<const SwTextFrame*>(this)->HangingMargin();
738  if( nTmp > nAdd )
739  nAdd = nTmp;
740  }
741  nWidth = aRectFnSet.XDiff(aRectFnSet.XInc(nRight, nAdd), nLeft);
742  SwRect aRet( getFrameArea() );
743  (aRet.*fnRect->fnSetLeft)(nLeft);
744  (aRet.*fnRect->fnSetWidth)( nWidth );
745  return aRet;
746 }
747 
748 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:313
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:158
sal_uLong GetIndex() const
Definition: node.hxx:291
void Add(SwClient *pDepend)
Definition: calbck.cxx:170
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:563
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
bool IsRootFrame() const
Definition: frame.hxx:1170
SwRootFrame * mpRoot
Definition: frame.hxx:335
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:386
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:599
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:127
long Long
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
static SwCache & GetCache()
Definition: frame.hxx:520
tools::Long XInc(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1420
Definition: doc.hxx:187
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1466
const SvxShadowItem & GetShadow() const
Definition: frmtool.hxx:387
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
SwTableLine is one table row in the document model.
Definition: swtable.hxx:351
bool SetMaxBottom(tools::Long)
Definition: ssfrm.cxx:74
SwRectGet fnGetWidth
Definition: frame.hxx:1291
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:384
void Pos(const Point &rNew)
Definition: swrect.hxx:169
SwContentFrame(SwContentNode *const, SwFrame *)
Definition: ssfrm.cxx:415
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1794
bool IsCellFrame() const
Definition: frame.hxx:1222
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const editeng::SvxBorderLine * GetRight() const
bool mbInDtor
Definition: frame.hxx:415
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
Value in Var-direction gives minimum (can be exceeded but not be less).
void RegisterToNode(SwTextNode &, bool isForceNodeAsFirst=false)
Definition: ssfrm.cxx:449
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:192
bool IsVertLRBT() const
Definition: frame.hxx:979
SwRectGet fnGetRight
Definition: frame.hxx:1290
tools::Long GetPrtBottom() const
Definition: ssfrm.cxx:51
SwRect GetPaintArea() const
|* The paintarea is the area, in which the content of a frame is allowed |* to be displayed...
Definition: ssfrm.cxx:589
bool IsFlyFrame() const
Definition: frame.hxx:1206
wrapper class for the positioning of Writer fly frames and drawing objects
SvxShadowLocation GetLocation() const
virtual ~SwFrame() override
Definition: ssfrm.cxx:374
const SwRect & getFrameArea() const
Definition: frame.hxx:178
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
Definition: redlnitr.cxx:205
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:451
bool IsTextFrame() const
Definition: frame.hxx:1230
virtual const_iterator_t getFieldmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of fieldmarks.
SwRectFn fnRectVertL2R
Definition: newfrm.cxx:288
void Width(tools::Long nNew)
Definition: swrect.hxx:187
virtual void DestroyImpl() override
Definition: ssfrm.cxx:481
SdrObject * DrawObj()
tools::Long GetPrtLeft() const
Definition: ssfrm.cxx:49
SwRectFn fnRectHori
Definition: newfrm.cxx:286
virtual void DestroyImpl()
Definition: ssfrm.cxx:326
bool IsColumnFrame() const
Definition: frame.hxx:1178
SwRectFn fnRectVertL2RB2T
Definition: newfrm.cxx:289
void ResetTurbo()
Definition: rootfrm.hxx:348
tools::Long XDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1418
void SetInvalidVert(bool bNew)
Definition: frame.hxx:628
void MakeBelowPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:106
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
Style of a layout element.
Definition: frmfmt.hxx:58
const editeng::SvxBorderLine * GetLeft() const
sw::BroadcastingModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:475
int i
std::vector< SwAnchoredObject * > m_VertPosOrientFramesFor
Definition: layfrm.hxx:54
tools::Long GetPrtTop() const
Definition: ssfrm.cxx:55
SwDoc & GetDoc()
Definition: node.hxx:212
void SetFrameFormat(SwFrameFormat *)
Definition: ssfrm.cxx:405
void Remove(SwAnchoredObject &_rAnchoredObj)
Definition: sortedobjs.cxx:229
size_t size() const
Definition: sortedobjs.cxx:43
tools::Long GetPrtRight() const
Definition: ssfrm.cxx:53
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:883
SwFrame * m_pLower
Definition: layfrm.hxx:53
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
const SwFrame * Lower() const
Definition: layfrm.hxx:101
bool m_isInDestroy
Definition: frame.hxx:444
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:476
bool mbInvalidR2L
Definition: frame.hxx:416
SwLayoutFrame * GetUpper()
Definition: frame.hxx:676
const SvxBoxItem & GetBox() const
Definition: frmtool.hxx:386
bool mbVertical
Definition: frame.hxx:421
virtual ~SwLayoutFrame() override
Definition: ssfrm.cxx:580
bool IsRowFrame() const
Definition: frame.hxx:1218
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:1725
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:373
SwFrame * GetPrev()
Definition: frame.hxx:675
size
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
tools::Long GetBottomMargin() const
Definition: ssfrm.cxx:43
SwRect UnionFrame(bool bBorder=false) const
|* The unionframe is the framearea (getFrameArea()) of a frame expanded by the |* printarea...
Definition: ssfrm.cxx:697
A page of the document layout.
Definition: pagefrm.hxx:57
void MakeRightPos(const SwFrame *, const SwFrame *, bool)
Definition: ssfrm.cxx:149
SwFrame * GetAnchorFrameContainingAnchPos()
determine anchor frame containing the anchor position
Frame cannot be moved in Var-direction.
SwRectSet fnSetLeft
Definition: frame.hxx:1298
tools::Long SwTwips
Definition: swtypes.hxx:49
bool SetMinLeft(tools::Long)
Definition: ssfrm.cxx:58
SwBorderAttrs * Get()
Definition: frmtool.cxx:2611
SwRectGet fnGetLeft
Definition: frame.hxx:1289
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
bool IsLayoutFrame() const
Definition: frame.hxx:1166
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void SetTopBottomMargins(tools::Long, tools::Long)
Definition: ssfrm.cxx:170
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
bool IsVertLR() const
Definition: frame.hxx:975
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
tools::Long GetRightMargin() const
Definition: ssfrm.cxx:47
void SetRightLeftMargins(tools::Long, tools::Long)
Definition: ssfrm.cxx:184
void DisconnectObjFromLayout(SdrObject *_pDrawObj)
disconnect for a dedicated drawing object - could be 'master' or 'virtual'.
Definition: dcontact.cxx:1713
void ClearTmpConsiderWrapInfluence()
bool IsRightToLeft() const
Definition: frame.hxx:983
std::unique_ptr< sw::MergedPara > m_pMergedPara
redline merge data
Definition: txtfrm.hxx:196
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
SwFrame * GetLower()
Definition: findfrm.cxx:170
bool IsPageFrame() const
Definition: frame.hxx:1174
SwRectSet fnSetWidth
Definition: frame.hxx:1300
bool SetMaxRight(tools::Long)
Definition: ssfrm.cxx:90
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
tools::Long GetTopMargin() const
Definition: ssfrm.cxx:41
sal_uInt16 CalcLineSpace(SvxBoxItemLine nLine, bool bEvenIfNoLine=false) const
const SwContentFrame * GetTurbo() const
Definition: rootfrm.hxx:349
void DisallowTurbo() const
Definition: rootfrm.hxx:344
void setContextWritingMode(SdrObject *pObj, SwFrame const *pAnchor)
Definition: dcontact.cxx:102
bool mbRightToLeft
Definition: frame.hxx:418
bool IsVertical() const
Definition: frame.hxx:969
virtual ~SwContentFrame() override
Definition: ssfrm.cxx:445
bool IsInDtor() const
Definition: doc.hxx:403
bool IsAccessibleFrame() const
Definition: frame.hxx:1246
SwRectSet fnSetRight
Definition: frame.hxx:1299
void InvalidateAll()
Definition: frame.hxx:1051
void AdjustColumns(const SwFormatCol *pCol, bool bAdjustAttributes)
Definition: colfrm.cxx:298
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
SwRectFn fnRectVert
Definition: newfrm.cxx:287
tools::Long GetLeftMargin() const
Definition: ssfrm.cxx:45
bool IsBodyFrame() const
Definition: frame.hxx:1202
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:206
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:291
static constexpr size_type npos
Definition: docary.hxx:229
void Height(tools::Long nNew)
Definition: swrect.hxx:191
SdrObjUserCall * GetUserCall() const
std::unique_ptr< SwSortedObjs > m_pDrawObjs
Definition: frame.hxx:412
void SetLeftRightMargins(tools::Long, tools::Long)
Definition: ssfrm.cxx:177
bool IsFooterFrame() const
Definition: frame.hxx:1190
SwRootFrame * getRootFrame()
Definition: frame.hxx:677
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
virtual void DestroyImpl() override
Definition: ssfrm.cxx:422
bool IsCreateFrameWhenHidingRedlines() const
Definition: node.hxx:94
void DisposeAccessibleFrame(const SwFrame *pFrame, bool bRecursive=false)
Definition: viewimp.hxx:277
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:395
SwFrame * GetNext()
Definition: frame.hxx:674