1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_wasm_strip.h>
22 #include <pagefrm.hxx>
23 #include <rootfrm.hxx>
24 #include <dcontact.hxx>
28 #include <cellfrm.hxx>
29 #include <swtable.hxx>
30 #include <fmtfsize.hxx>
31 #include <editeng/boxitem.hxx>
32 #include <editeng/shaditem.hxx>
33 #include <IDocumentRedlineAccess.hxx>
34 #include <IDocumentMarkAccess.hxx>
35 #include <fmtclds.hxx>
36 #include <viewimp.hxx>
37 #include <sortedobjs.hxx>
39 #include <frmtool.hxx>
41 #include <osl/diagnose.h>
43 // No inline cause we need the function pointers
44 tools::Long
SwFrame::GetTopMargin() const
45 { return getFramePrintArea().Top(); }
46 tools::Long
SwFrame::GetBottomMargin() const
47 { return getFrameArea().Height() -getFramePrintArea().Height() -getFramePrintArea().Top(); }
48 tools::Long
SwFrame::GetLeftMargin() const
49 { return getFramePrintArea().Left(); }
50 tools::Long
SwFrame::GetRightMargin() const
51 { return getFrameArea().Width() - getFramePrintArea().Width() - getFramePrintArea().Left(); }
52 tools::Long
SwFrame::GetPrtLeft() const
53 { return getFrameArea().Left() + getFramePrintArea().Left(); }
54 tools::Long
SwFrame::GetPrtBottom() const
55 { return getFrameArea().Top() + getFramePrintArea().Height() + getFramePrintArea().Top(); }
56 tools::Long
SwFrame::GetPrtRight() const
57 { return getFrameArea().Left() + getFramePrintArea().Width() + getFramePrintArea().Left(); }
58 tools::Long
SwFrame::GetPrtTop() const
59 { return getFrameArea().Top() + getFramePrintArea().Top(); }
61 bool SwFrame::SetMinLeft( tools::Long nDeadline
)
63 SwTwips nDiff
= nDeadline
- getFrameArea().Left();
66 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
67 aFrm
.Left( nDeadline
);
69 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
70 aPrt
.Width( aPrt
.Width() - nDiff
);
77 bool SwFrame::SetMaxBottom( tools::Long nDeadline
)
79 SwTwips nDiff
= getFrameArea().Top() + getFrameArea().Height() - nDeadline
;
82 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
83 aFrm
.Height( aFrm
.Height() - nDiff
);
85 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
86 aPrt
.Height( aPrt
.Height() - nDiff
);
93 bool SwFrame::SetMaxRight( tools::Long nDeadline
)
95 SwTwips nDiff
= getFrameArea().Left() + getFrameArea().Width() - nDeadline
;
98 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
99 aFrm
.Width( aFrm
.Width() - nDiff
);
101 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
102 aPrt
.Width( aPrt
.Width() - nDiff
);
109 void SwFrame::MakeBelowPos( const SwFrame
* pUp
, const SwFrame
* pPrv
, bool bNotify
)
111 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
115 aFrm
.Pos( pPrv
->getFrameArea().Pos() );
116 aFrm
.Pos().AdjustY(pPrv
->getFrameArea().Height() );
120 aFrm
.Pos( pUp
->getFrameArea().Pos() );
121 aFrm
.Pos() += pUp
->getFramePrintArea().Pos();
126 aFrm
.Pos().AdjustY(1 );
130 void SwFrame::MakeLeftPos( const SwFrame
* pUp
, const SwFrame
* pPrv
, bool bNotify
)
132 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
136 aFrm
.Pos( pPrv
->getFrameArea().Pos() );
137 aFrm
.Pos().AdjustX( -(aFrm
.Width()) );
141 aFrm
.Pos( pUp
->getFrameArea().Pos() );
142 aFrm
.Pos() += pUp
->getFramePrintArea().Pos();
143 aFrm
.Pos().AdjustX(pUp
->getFramePrintArea().Width() - aFrm
.Width() );
148 aFrm
.Pos().AdjustX( -1 );
152 void SwFrame::MakeRightPos( const SwFrame
* pUp
, const SwFrame
* pPrv
, bool bNotify
)
154 SwFrameAreaDefinition::FrameAreaWriteAccess
aFrm(*this);
158 aFrm
.Pos( pPrv
->getFrameArea().Pos() );
159 aFrm
.Pos().AdjustX(pPrv
->getFrameArea().Width() );
163 aFrm
.Pos( pUp
->getFrameArea().Pos() );
164 aFrm
.Pos() += pUp
->getFramePrintArea().Pos();
169 aFrm
.Pos().AdjustX(1 );
173 void SwFrame::SetTopBottomMargins( tools::Long nTop
, tools::Long nBot
)
175 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
177 aPrt
.Height( getFrameArea().Height() - nTop
- nBot
);
180 void SwFrame::SetLeftRightMargins( tools::Long nLeft
, tools::Long nRight
)
182 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
184 aPrt
.Width( getFrameArea().Width() - nLeft
- nRight
);
187 void SwFrame::SetRightLeftMargins( tools::Long nRight
, tools::Long nLeft
)
189 SwFrameAreaDefinition::FramePrintAreaWriteAccess
aPrt(*this);
191 aPrt
.Width( getFrameArea().Width() - nLeft
- nRight
);
194 /// checks the layout direction and invalidates the lower frames recursively, if necessary.
195 void SwFrame::CheckDirChange()
197 bool bOldVert
= mbVertical
;
198 bool bOldR2L
= mbRightToLeft
;
199 SetInvalidVert( true );
201 bool bChg
= bOldR2L
!= IsRightToLeft();
202 bool bOldVertL2R
= IsVertLR();
203 if( !(( IsVertical() != bOldVert
) || bChg
|| bOldVertL2R
!= IsVertLR()) )
207 if( IsLayoutFrame() )
209 // set minimum row height for vertical cells in horizontal table:
210 if ( IsCellFrame() && GetUpper() )
212 if ( IsVertical() != GetUpper()->IsVertical() &&
213 static_cast<SwCellFrame
*>(this)->GetTabBox()->getRowSpan() == 1 )
216 MIN_VERT_CELL_HEIGHT
= 1135
219 SwTableLine
* pLine
= const_cast<SwTableLine
*>(static_cast<SwCellFrame
*>(this)->GetTabBox()->GetUpper());
220 SwFrameFormat
* pFrameFormat
= pLine
->GetFrameFormat();
221 SwFormatFrameSize
aNew( pFrameFormat
->GetFrameSize() );
222 if ( SwFrameSize::Fixed
!= aNew
.GetHeightSizeType() )
223 aNew
.SetHeightSizeType( SwFrameSize::Minimum
);
224 if ( aNew
.GetHeight() < MIN_VERT_CELL_HEIGHT
)
225 aNew
.SetHeight( MIN_VERT_CELL_HEIGHT
);
226 SwDoc
* pDoc
= pFrameFormat
->GetDoc();
227 pDoc
->SetAttr( aNew
, *pLine
->ClaimFrameFormat() );
231 SwFrame
* pFrame
= static_cast<SwLayoutFrame
*>(this)->Lower();
232 const SwFormatCol
* pCol
= nullptr;
233 SwLayoutFrame
* pBody
= nullptr;
238 // If we're a page frame and we change our layout direction,
239 // we have to look for columns and rearrange them.
240 pBody
= static_cast<SwPageFrame
*>(this)->FindBodyCont();
241 if(pBody
&& pBody
->Lower() && pBody
->Lower()->IsColumnFrame())
242 pCol
= &static_cast<SwPageFrame
*>(this)->GetFormat()->GetCol();
244 else if( pFrame
->IsColumnFrame() )
246 pBody
= static_cast<SwLayoutFrame
*>(this);
247 const SwFrameFormat
*pFormat
= pBody
->GetFormat();
249 pCol
= &pFormat
->GetCol();
254 pFrame
->CheckDirChange();
255 pFrame
= pFrame
->GetNext();
258 pBody
->AdjustColumns( pCol
, true );
260 else if( IsTextFrame() )
261 static_cast<SwTextFrame
*>(this)->Prepare();
263 // #i31698# - notify anchored objects also for page frames.
264 // Remove code above for special handling of page frames
265 if ( !GetDrawObjs() )
268 const SwSortedObjs
*pObjs
= GetDrawObjs();
269 const size_t nCnt
= pObjs
->size();
270 for ( size_t i
= 0; i
< nCnt
; ++i
)
272 SwAnchoredObject
* pAnchoredObj
= (*pObjs
)[i
];
273 if( auto pFlyFrame
= pAnchoredObj
->DynCastFlyFrame() )
274 pFlyFrame
->CheckDirChange();
277 // OD 2004-04-06 #i26791# - direct object
278 // positioning no longer needed. Instead
280 pAnchoredObj
->InvalidateObjPos();
282 // #i31698# - update layout direction of
285 ::setContextWritingMode( pAnchoredObj
->DrawObj(), pAnchoredObj
->GetAnchorFrameContainingAnchPos() );
286 pAnchoredObj
->UpdateLayoutDir();
291 /// returns the position for anchors based on frame direction
292 // OD 2004-03-10 #i11860# - consider lower space and line spacing of
293 // previous frame according to new option 'Use former object positioning'
294 Point
SwFrame::GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame
) const
296 Point aAnchor
= getFrameArea().Pos();
298 if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
299 aAnchor
.AdjustX(getFrameArea().Width() );
303 SwTwips nBaseOfstForFly
=
304 static_cast<const SwTextFrame
*>(this)->GetBaseOffsetForFly( bIgnoreFlysAnchoredAtThisFrame
);
306 aAnchor
.AdjustY(nBaseOfstForFly
);
308 aAnchor
.AdjustX(nBaseOfstForFly
);
310 // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
311 // is OFF, consider the lower space and the line spacing of the
312 // previous frame and the spacing considered for the page grid
313 const SwTextFrame
* pThisTextFrame
= static_cast<const SwTextFrame
*>(this);
314 const SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid
=
315 pThisTextFrame
->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
318 aAnchor
.AdjustX( -nUpperSpaceAmountConsideredForPrevFrameAndPageGrid
);
322 aAnchor
.AdjustY(nUpperSpaceAmountConsideredForPrevFrameAndPageGrid
);
329 void SwFrame::DestroyImpl()
333 // accessible objects for fly and cell frames have been already disposed
334 // by the destructors of the derived classes.
335 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
336 if (IsAccessibleFrame() && !(IsFlyFrame() || IsCellFrame())
337 && (GetDep() || IsTextFrame())) // sw_redlinehide: text frame may not have Dep!
339 assert(!IsTextFrame() || GetDep() || static_cast<SwTextFrame
*>(this)->GetMergedPara());
340 const bool bInDocDtor
= IsTabFrame() && static_cast<SwTabFrame
*>(this)->GetFormat()->GetDoc()->IsInDtor();
341 SwRootFrame
*pRootFrame
= getRootFrame();
342 if( !bInDocDtor
&& pRootFrame
&& pRootFrame
->IsAnyShellAccessible() )
344 SwViewShell
*pVSh
= pRootFrame
->GetCurrShell();
345 if( pVSh
&& pVSh
->Imp() )
347 OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" );
348 pVSh
->Imp()->DisposeAccessibleFrame( this );
357 for (size_t i
= m_pDrawObjs
->size(); i
; )
359 SwAnchoredObject
* pAnchoredObj
= (*m_pDrawObjs
)[--i
];
360 if ( auto pFlyFrame
= pAnchoredObj
->DynCastFlyFrame() )
362 SwFrame::DestroyFrame(pFlyFrame
);
366 SdrObject
* pSdrObj
= pAnchoredObj
->DrawObj();
367 SwDrawContact
* pContact
=
368 static_cast<SwDrawContact
*>(pSdrObj
->GetUserCall());
369 OSL_ENSURE( pContact
,
370 "<SwFrame::~SwFrame> - missing contact for drawing object" );
373 pContact
->DisconnectObjFromLayout( pSdrObj
);
382 assert(m_isInDestroy
); // check that only DestroySwFrame does "delete"
383 assert(!IsDeleteForbidden()); // check that it's not deleted while deletes are forbidden
384 #if OSL_DEBUG_LEVEL > 0
385 // JP 15.10.2001: for detection of access to deleted frames
386 mpRoot
= reinterpret_cast<SwRootFrame
*>(0x33333333);
390 void SwFrame::DestroyFrame(SwFrame
*const pFrame
)
394 pFrame
->m_isInDestroy
= true;
395 pFrame
->DestroyImpl();
396 assert(pFrame
->mbInDtor
); // check that nobody forgot to call base class
401 const SwFrameFormat
* SwLayoutFrame::GetFormat() const
403 return static_cast< const SwFrameFormat
* >( GetDep() );
406 SwFrameFormat
* SwLayoutFrame::GetFormat()
408 return static_cast< SwFrameFormat
* >( GetDep() );
411 void SwLayoutFrame::SetFrameFormat(SwFrameFormat
* pNew
)
413 if(pNew
== GetFormat())
415 const SwFormatChg
aOldFormat(GetFormat());
417 const SwFormatChg
aNewFormat(pNew
);
418 SwClientNotify(*pNew
, sw::LegacyModifyHint(&aOldFormat
, &aNewFormat
));
421 SwContentFrame::SwContentFrame( SwContentNode
* const pContent
, SwFrame
* pSib
) :
422 SwFrame( pContent
, pSib
),
423 SwFlowFrame( static_cast<SwFrame
&>(*this) )
425 assert(!getRootFrame()->HasMergedParas() || pContent
->IsCreateFrameWhenHidingRedlines());
428 void SwContentFrame::DestroyImpl()
430 const SwContentNode
* pCNd(dynamic_cast<SwContentNode
*>(GetDep()));
431 if (nullptr == pCNd
&& IsTextFrame())
433 pCNd
= static_cast<SwTextFrame
*>(this)->GetTextNodeFirst();
435 // IsInDtor shouldn't be happening with ViewShell owning layout
436 assert(nullptr == pCNd
|| !pCNd
->GetDoc().IsInDtor());
437 if (nullptr != pCNd
&& !pCNd
->GetDoc().IsInDtor())
439 //Unregister from root if I'm still in turbo there.
440 SwRootFrame
*pRoot
= getRootFrame();
441 if( pRoot
&& pRoot
->GetTurbo() == this )
443 pRoot
->DisallowTurbo();
448 SwFrame::DestroyImpl();
451 SwContentFrame::~SwContentFrame()
455 void SwTextFrame::RegisterToNode(SwTextNode
& rNode
, bool const isForceNodeAsFirst
)
457 if (isForceNodeAsFirst
&& m_pMergedPara
)
458 { // nothing registered here, in particular no delete redlines (insert
459 // redline might end on empty node where delete rl starts, should be ok)
460 assert(m_pMergedPara
->pFirstNode
->GetIndex() + 1 == rNode
.GetIndex());
461 assert(rNode
.GetDoc().getIDocumentRedlineAccess().GetRedlinePos(
462 *m_pMergedPara
->pFirstNode
, RedlineType::Delete
) == SwRedlineTable::npos
);
464 rNode
.GetDoc().getIDocumentMarkAccess()->getFieldmarksBegin(),
465 rNode
.GetDoc().getIDocumentMarkAccess()->getFieldmarksEnd(),
466 [this](::sw::mark::IMark
const*const pMark
) {
467 return pMark
->GetMarkStart().GetNode() == *m_pMergedPara
->pFirstNode
468 && pMark
->GetMarkEnd().GetNode() != *m_pMergedPara
->pFirstNode
;
469 }) == rNode
.GetDoc().getIDocumentMarkAccess()->getFieldmarksEnd());
471 assert(&rNode
!= GetDep());
472 assert(!m_pMergedPara
473 || (m_pMergedPara
->pFirstNode
->GetIndex() < rNode
.GetIndex())
474 || (rNode
.GetIndex() + 1 == m_pMergedPara
->pFirstNode
->GetIndex()));
475 SwTextNode
& rFirstNode(
476 (!isForceNodeAsFirst
&& m_pMergedPara
&& m_pMergedPara
->pFirstNode
->GetIndex() < rNode
.GetIndex())
477 ? *m_pMergedPara
->pFirstNode
479 // sw_redlinehide: use New here, because the only caller also calls lcl_ChangeFootnoteRef
480 m_pMergedPara
= sw::CheckParaRedlineMerge(*this, rFirstNode
, sw::FrameMode::New
);
487 void SwLayoutFrame::DestroyImpl()
489 while (!m_VertPosOrientFramesFor
.empty())
491 SwAnchoredObject
*pObj
= *m_VertPosOrientFramesFor
.begin();
492 pObj
->ClearVertPosOrientFrame();
495 assert(m_VertPosOrientFramesFor
.empty());
497 SwFrame
*pFrame
= m_pLower
;
499 if( GetFormat() && !GetFormat()->GetDoc()->IsInDtor() )
503 //First delete the Objs of the Frame because they can't unregister
504 //from the page after remove.
505 //We don't want to create an endless loop only because one couldn't
508 while ( pFrame
->GetDrawObjs() && pFrame
->GetDrawObjs()->size() )
510 const size_t nCnt
= pFrame
->GetDrawObjs()->size();
512 SwAnchoredObject
* pAnchoredObj
= (*pFrame
->GetDrawObjs())[0];
513 if (SwFlyFrame
* pFlyFrame
= pAnchoredObj
->DynCastFlyFrame())
515 SwFrame::DestroyFrame(pFlyFrame
);
516 assert(!pFrame
->GetDrawObjs() || nCnt
> pFrame
->GetDrawObjs()->size());
520 pAnchoredObj
->ClearTmpConsiderWrapInfluence();
521 SdrObject
* pSdrObj
= pAnchoredObj
->DrawObj();
522 SwDrawContact
* pContact
=
523 static_cast<SwDrawContact
*>(pSdrObj
->GetUserCall());
524 OSL_ENSURE( pContact
,
525 "<SwFrame::~SwFrame> - missing contact for drawing object" );
528 pContact
->DisconnectObjFromLayout( pSdrObj
);
531 if ( pFrame
->GetDrawObjs() &&
532 nCnt
== pFrame
->GetDrawObjs()->size() )
534 pFrame
->GetDrawObjs()->Remove( *pAnchoredObj
);
538 pFrame
->RemoveFromLayout();
539 SwFrame::DestroyFrame(pFrame
);
542 //Delete the Flys, the last one also deletes the array.
543 while ( GetDrawObjs() && GetDrawObjs()->size() )
545 const size_t nCnt
= GetDrawObjs()->size();
548 SwAnchoredObject
* pAnchoredObj
= (*GetDrawObjs())[0];
549 if ( auto pFlyFrame
= pAnchoredObj
->DynCastFlyFrame() )
551 SwFrame::DestroyFrame(pFlyFrame
);
552 assert(!GetDrawObjs() || nCnt
> GetDrawObjs()->size());
556 SdrObject
* pSdrObj
= pAnchoredObj
->DrawObj();
557 SwDrawContact
* pContact
=
558 static_cast<SwDrawContact
*>(pSdrObj
->GetUserCall());
559 OSL_ENSURE( pContact
,
560 "<SwFrame::~SwFrame> - missing contact for drawing object" );
563 pContact
->DisconnectObjFromLayout( pSdrObj
);
566 if ( GetDrawObjs() && nCnt
== GetDrawObjs()->size() )
568 GetDrawObjs()->Remove( *pAnchoredObj
);
577 SwFrame
*pNxt
= pFrame
->GetNext();
578 SwFrame::DestroyFrame(pFrame
);
583 SwFrame::DestroyImpl();
586 SwLayoutFrame::~SwLayoutFrame()
591 |* The paintarea is the area, in which the content of a frame is allowed
592 |* to be displayed. This region could be larger than the printarea (getFramePrintArea())
593 |* of the upper, it includes e.g. often the margin of the page.
595 SwRect
SwFrame::GetPaintArea() const
598 // Cell frames may not leave their upper:
599 SwRect aRect
= IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
600 const bool bVert
= IsVertical();
601 SwRectFn fnRect
= bVert
? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T
: fnRectVertL2R
) : fnRectVert
) : fnRectHori
;
602 SwRectFnSet
aRectFnSet(this);
603 tools::Long nRight
= (aRect
.*fnRect
->fnGetRight
)();
604 tools::Long nLeft
= (aRect
.*fnRect
->fnGetLeft
)();
605 const SwFrame
* pTmp
= this;
608 tools::Long nRowSpan
= 0;
611 if( pTmp
->IsCellFrame() && pTmp
->GetUpper() &&
612 pTmp
->GetUpper()->IsVertical() != pTmp
->IsVertical() )
613 nRowSpan
= static_cast<const SwCellFrame
*>(pTmp
)->GetTabBox()->getRowSpan();
614 tools::Long nTmpRight
= (pTmp
->getFrameArea().*fnRect
->fnGetRight
)();
615 tools::Long nTmpLeft
= (pTmp
->getFrameArea().*fnRect
->fnGetLeft
)();
616 if( pTmp
->IsRowFrame() && nRowSpan
> 1 )
618 const SwFrame
* pNxt
= pTmp
;
619 while( --nRowSpan
> 0 && pNxt
->GetNext() )
620 pNxt
= pNxt
->GetNext();
621 if( pTmp
->IsVertical() )
622 nTmpLeft
= (pNxt
->getFrameArea().*fnRect
->fnGetLeft
)();
625 // pTmp is a row frame, but it's not vertical.
628 // This frame cell is OK to expand towards the physical down direction.
629 // Physical down is left.
630 nTmpLeft
= (pNxt
->getFrameArea().*fnRect
->fnGetLeft
)();
634 nTmpRight
= (pNxt
->getFrameArea().*fnRect
->fnGetRight
)();
638 OSL_ENSURE( pTmp
, "GetPaintArea lost in time and space" );
639 if( pTmp
->IsPageFrame() || pTmp
->IsFlyFrame() ||
640 pTmp
->IsCellFrame() || pTmp
->IsRowFrame() || //nobody leaves a table!
641 pTmp
->IsRootFrame() )
643 // BTLR is OK to expand towards the physical down direction. Physical down is left.
644 if( bLeft
|| (aRectFnSet
.XDiff(nTmpLeft
, nLeft
) > 0 && !IsVertLRBT()) )
646 if( bRight
|| aRectFnSet
.XDiff(nRight
, nTmpRight
) > 0 )
648 if( pTmp
->IsPageFrame() || pTmp
->IsFlyFrame() || pTmp
->IsRootFrame() )
653 else if( pTmp
->IsColumnFrame() ) // nobody enters neighbour columns
655 bool bR2L
= pTmp
->IsRightToLeft();
656 // the first column has _no_ influence to the left range
657 if( bR2L
? pTmp
->GetNext() : pTmp
->GetPrev() )
659 if( bLeft
|| aRectFnSet
.XDiff(nTmpLeft
, nLeft
) > 0 )
663 // the last column has _no_ influence to the right range
664 if( bR2L
? pTmp
->GetPrev() : pTmp
->GetNext() )
666 if( bRight
|| aRectFnSet
.XDiff(nRight
, nTmpRight
) > 0 )
671 else if( bVert
&& pTmp
->IsBodyFrame() )
673 // Header and footer frames have always horizontal direction and
674 // limit the body frame.
675 // A previous frame of a body frame must be a header,
676 // the next frame of a body frame may be a footnotecontainer or
677 // a footer. The footnotecontainer has the same direction like
679 if( pTmp
->GetPrev() && ( bLeft
|| aRectFnSet
.XDiff(nTmpLeft
, nLeft
) > 0 ) )
684 if( pTmp
->GetNext() &&
685 ( pTmp
->GetNext()->IsFooterFrame() || pTmp
->GetNext()->GetNext() )
686 && ( bRight
|| aRectFnSet
.XDiff(nRight
, nTmpRight
) > 0 ) )
692 pTmp
= pTmp
->GetUpper();
694 (aRect
.*fnRect
->fnSetLeft
)( nLeft
);
695 (aRect
.*fnRect
->fnSetRight
)( nRight
);
700 |* The unionframe is the framearea (getFrameArea()) of a frame expanded by the
701 |* printarea, if there's a negative margin at the left or right side.
703 SwRect
SwFrame::UnionFrame( bool bBorder
) const
705 bool bVert
= IsVertical();
706 SwRectFn fnRect
= bVert
? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T
: fnRectVertL2R
) : fnRectVert
) : fnRectHori
;
707 tools::Long nLeft
= (getFrameArea().*fnRect
->fnGetLeft
)();
708 tools::Long nWidth
= (getFrameArea().*fnRect
->fnGetWidth
)();
709 tools::Long nPrtLeft
= (getFramePrintArea().*fnRect
->fnGetLeft
)();
710 tools::Long nPrtWidth
= (getFramePrintArea().*fnRect
->fnGetWidth
)();
711 SwRectFnSet
aRectFnSet(this);
712 if (aRectFnSet
.XInc(nPrtLeft
, nPrtWidth
) > nWidth
)
713 nWidth
= nPrtLeft
+ nPrtWidth
;
719 SwTwips nRight
= aRectFnSet
.XInc(nLeft
, nWidth
);
720 tools::Long nAdd
= 0;
723 SwBorderAttrAccess
aAccess( SwFrame::GetCache(), this );
724 const SwBorderAttrs
&rAttrs
= *aAccess
.Get();
725 const SvxBoxItem
&rBox
= rAttrs
.GetBox();
726 if ( rBox
.GetLeft() )
727 nLeft
-= rBox
.CalcLineSpace( SvxBoxItemLine::LEFT
);
729 nLeft
-= rBox
.GetDistance( SvxBoxItemLine::LEFT
) + 1;
730 if ( rBox
.GetRight() )
731 nAdd
+= rBox
.CalcLineSpace( SvxBoxItemLine::RIGHT
);
733 nAdd
+= rBox
.GetDistance( SvxBoxItemLine::RIGHT
) + 1;
734 if( rAttrs
.GetShadow().GetLocation() != SvxShadowLocation::NONE
)
736 const SvxShadowItem
&rShadow
= rAttrs
.GetShadow();
737 nLeft
-= rShadow
.CalcShadowSpace( SvxShadowItemSide::LEFT
);
738 nAdd
+= rShadow
.CalcShadowSpace( SvxShadowItemSide::RIGHT
);
741 if( IsTextFrame() && static_cast<const SwTextFrame
*>(this)->HasPara() )
743 tools::Long nTmp
= static_cast<const SwTextFrame
*>(this)->HangingMargin();
747 nWidth
= aRectFnSet
.XDiff(aRectFnSet
.XInc(nRight
, nAdd
), nLeft
);
748 SwRect
aRet( getFrameArea() );
749 (aRet
.*fnRect
->fnSetLeft
)(nLeft
);
750 (aRet
.*fnRect
->fnSetWidth
)( nWidth
);
754 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */