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