OSL_ENSURE( rCnt.GetContentIdx(), "No content for Header." );
// Have the objects created right now for header and footer bool bOld = bObjsDirect;
bObjsDirect = true;
SwNodeOffset nIndex = rCnt.GetContentIdx()->GetIndex();
::InsertCnt_( this, pFormat->GetDoc(), ++nIndex );
bObjsDirect = bOld;
}
void SwHeadFootFrame::FormatPrt(SwTwips & nUL, const SwBorderAttrs * pAttrs)
{ if (GetEatSpacing())
{ /* The minimal height of the print area is the minimal height of the
frame without the height needed for borders and shadow. */
SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
/* If the minimal height of the print area is negative, try to
compensate by overlapping */
SwTwips nOverlap = 0; if (nMinHeight < 0)
{
nOverlap = -nMinHeight;
nMinHeight = 0;
}
/* Calculate desired height of content. The minimal height has to be
adhered. */
SwTwips nHeight;
/* calculate real vertical space between frame and print area */ if (IsHeaderFrame())
nUL = pAttrs->CalcTop() + nSpace; else
nUL = pAttrs->CalcBottom() + nSpace;
/* set print area */
SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
aPrt.Left(pAttrs->CalcLeft(this));
if (IsHeaderFrame())
{
aPrt.Top(pAttrs->CalcTop());
} else
{
aPrt.Top(nSpace);
}
aPrt.Height(nNewHeight);
} else
{ // Set position
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
aPrt.Left( pAttrs->CalcLeft( this ) );
aPrt.Top ( pAttrs->CalcTop() );
// Set sizes - the sizes are given by the surrounding Frame, just // subtract the borders.
SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
aPrt.Width ( getFrameArea().Width() - nLR );
aPrt.Height( getFrameArea().Height()- nUL );
}
SwTwips nMaxHeight = LONG_MAX;
SwTwips nRemaining, nOldHeight; // #i64301# // use the position of the footer printing area to control invalidation // of the first footer content.
Point aOldFooterPrtPos;
do
{
nOldHeight = getFramePrintArea().Height();
SwFrame* pFrame = Lower(); // #i64301# if ( pFrame &&
aOldFooterPrtPos != ( getFrameArea().Pos() + getFramePrintArea().Pos() ) )
{
pFrame->InvalidatePos_();
aOldFooterPrtPos = getFrameArea().Pos() + getFramePrintArea().Pos();
} int nLoopControl = 0; while( pFrame )
{
pFrame->Calc(getRootFrame()->GetCurrShell()->GetOut()); // #i43771# - format also object anchored // at the frame // #i46941# - frame has to be valid. // Note: frame could be invalid after calling its format, // if it's locked
OSL_ENSURE( StackHack::IsLocked() || !pFrame->IsTextFrame() ||
pFrame->isFrameAreaDefinitionValid() || static_cast<SwTextFrame*>(pFrame)->IsJoinLocked(), "<SwHeadFootFrame::FormatSize(..)> - text frame invalid and not locked." );
if ( pFrame->IsTextFrame() && pFrame->isFrameAreaDefinitionValid() )
{ if ( !SwObjectFormatter::FormatObjsAtFrame( *pFrame,
*(pFrame->FindPageFrame()) ) )
{ if (nLoopControl++ < 20)
{ // restart format with first content
pFrame = Lower(); continue;
} else
SAL_WARN("sw", "SwHeadFootFrame::FormatSize: loop detection triggered");
}
}
pFrame = pFrame->GetNext();
}
nRemaining = 0;
pFrame = Lower();
while ( pFrame )
{
nRemaining += pFrame->getFrameArea().Height();
if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsUndersized() ) // This TextFrame would like to be a bit bigger
nRemaining += static_cast<SwTextFrame*>(pFrame)->GetParHeight()
- pFrame->getFramePrintArea().Height(); elseif( pFrame->IsSctFrame() && static_cast<SwSectionFrame*>(pFrame)->IsUndersized() )
nRemaining += static_cast<SwSectionFrame*>(pFrame)->Undersize();
pFrame = pFrame->GetNext();
} if ( nRemaining < nMinHeight )
nRemaining = nMinHeight;
/* If the frame is too small, eat less spacing thus letting the frame
grow more. */
SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
SwTwips nFrameTooSmall = nMinHeight - getFrameArea().Height();
if (nFrameTooSmall > 0)
nEat -= nFrameTooSmall;
/* No negative eating, not eating more than allowed. */ if (nEat < 0)
nEat = 0; elseif (nEat > nMaxEat)
nEat = nMaxEat;
// Notify fly frame, if header frame // grows. Consider, that 'normal' grow of layout frame already notifies // the fly frames. bool bNotifyFlys = false; if (nEat > 0)
{ if ( ! bTst)
{ if (! IsHeaderFrame())
{
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
aPrt.Top(aPrt.Top() - nEat);
aPrt.Height(aPrt.Height() - nEat);
}
SwTwips nMinHeight = lcl_GetFrameMinHeight(*this);
SwTwips nOldHeight = getFrameArea().Height();
SwTwips nRest = 0; // Amount to shrink by spitting out spacing
if ( nOldHeight >= nMinHeight )
{ /* If the frame's height is bigger than its minimum height, shrink theframetowardsitsminimumheight.Ifthisisnotsufficient toprovidetheshrinkingrequestedprovidetherestbyspitting
out spacing. */
SwTwips nBiggerThanMin = nOldHeight - nMinHeight;
if (nBiggerThanMin < nDist)
{
nRest = nDist - nBiggerThanMin;
} /* info: declaration of nRest -> else nRest = 0 */
} else /* The frame cannot shrink. Provide shrinking by spitting out
spacing. */
nRest = nDist;
// Notify fly frame, if header/footer frame shrinks. // Consider, that 'normal' shrink of layout frame already notifies the fly frames. bool bNotifyFlys = false; if (nRest > 0)
{
std::optional<SwBorderAttrAccess> oAccess(std::in_place, SwFrame::GetCache(), this);
OSL_ENSURE(oAccess, "no border attributes");
SwBorderAttrs * pAttrs = oAccess->Get();
/* minimal height of print area */
SwTwips nMinPrtHeight = nMinHeight
- pAttrs->CalcTop()
- pAttrs->CalcBottom();
if (nMinPrtHeight < 0)
nMinPrtHeight = 0;
/* assume all shrinking can be provided */
SwTwips nShrink = nRest;
/* The shrinking not providable by spitting out spacing has to be done
by the frame. */ if (nDist - nRest > 0)
{
SwTwips nShrinkAmount = SwLayoutFrame::ShrinkFrame( nDist - nRest, bTst, bInfo );
nResult += nShrinkAmount; if ( nShrinkAmount > 0 )
{
bNotifyFlys = false;
}
}
// Notify fly frames, if necessary. if ( ( nResult > 0 ) && bNotifyFlys )
{
NotifyLowerObjs();
}
}
if ( bOn && rH.IsActive() )
{ //Implant header, but remove first, if already present
OSL_ENSURE( rH.GetHeaderFormat(), "FrameFormat for Header not found." );
if ( pLay->GetFormat() == rH.GetHeaderFormat() ) return; // Header is already the correct one.
if ( pLay->IsHeaderFrame() )
{ SwLayoutFrame *pDel = pLay;
pLay = static_cast<SwLayoutFrame*>(pLay->GetNext());
::DelFlys(*pDel, *this);
pDel->Cut();
SwFrame::DestroyFrame(pDel);
}
OSL_ENSURE( pLay, "Where to with the Header?" );
SwHeaderFrame *pH = new SwHeaderFrame( const_cast<SwFrameFormat*>(rH.GetHeaderFormat()), this );
pH->Paste( this, pLay ); if ( GetUpper() )
::RegistFlys( this, pH );
} elseif (pLay->IsHeaderFrame())
{ // Remove header if present.
::DelFlys(*pLay, *this);
pLay->Cut();
SwFrame::DestroyFrame(pLay);
}
}
/// Creates or removes footer void SwPageFrame::PrepareFooter()
{
SwLayoutFrame *pLay = static_cast<SwLayoutFrame*>(Lower()); if ( !pLay ) return;
const SwFormatFooter &rF = static_cast<SwFrameFormat*>(GetDep())->GetFooter(); while ( pLay->GetNext() )
pLay = static_cast<SwLayoutFrame*>(pLay->GetNext());
if ( bOn && rF.IsActive() )
{ //Implant footer, but remove first, if already present
OSL_ENSURE( rF.GetFooterFormat(), "FrameFormat for Footer not found." );
if ( pLay->GetFormat() == rF.GetFooterFormat() ) return; // Footer is already the correct one.
if ( pLay->IsFooterFrame() )
{
::DelFlys(*pLay, *this);
pLay->Cut();
SwFrame::DestroyFrame(pLay);
}
SwFooterFrame *pF = new SwFooterFrame( const_cast<SwFrameFormat*>(rF.GetFooterFormat()), this );
pF->Paste( this ); if ( GetUpper() )
::RegistFlys( this, pF );
} elseif ( pLay->IsFooterFrame() )
{ // Remove footer if already present
::DelFlys(*pLay, *this);
SwViewShell *pShell; if ( pLay->GetPrev() && nullptr != (pShell = getRootFrame()->GetCurrShell()) &&
pShell->VisArea().HasArea() )
pShell->InvalidateWindows( pShell->VisArea() );
pLay->Cut();
SwFrame::DestroyFrame(pLay);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.