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