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