Kaydet (Commit) 42b6b9a5 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

tdf#119126 forcepoint#76 avoid deleting footnote that would delete ...

... undeletable page

(cherry picked from commit 0005b330)

Conflicts:
	sw/qa/extras/layout/layout.cxx

Reviewed-on: https://gerrit.libreoffice.org/66393Tested-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 558f01a2)

Change-Id: I4622569eb9c757c6dcbdda32081ddc94e53db919
üst 70e2ca96
......@@ -841,7 +841,7 @@ public:
bool IsProtected() const;
bool IsColLocked() const { return mbColLocked; }
bool IsDeleteForbidden() const { return mbForbidDelete; }
virtual bool IsDeleteForbidden() const { return mbForbidDelete; }
/// this is the only way to delete a SwFrame instance
static void DestroyFrame(SwFrame *const pFrame);
......
......@@ -68,6 +68,7 @@ class SwFootnoteFrame: public SwLayoutFrame
public:
SwFootnoteFrame( SwFrameFormat*, SwFrame*, SwContentFrame*, SwTextFootnote* );
virtual bool IsDeleteForbidden() const override;
virtual void Cut() override;
virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
......
......@@ -245,6 +245,7 @@ void SwFrame::PrepareMake(vcl::RenderContext* pRenderContext)
StackHack aHack;
if ( GetUpper() )
{
SwFrameDeleteGuard aDeleteGuard(this);
if ( lcl_IsCalcUpperAllowed( *this ) )
GetUpper()->Calc(pRenderContext);
OSL_ENSURE( GetUpper(), ":-( Layout unstable (Upper gone)." );
......
......@@ -471,6 +471,27 @@ void SwFootnoteFrame::InvalidateNxtFootnoteCnts( SwPageFrame const *pPage )
}
}
bool SwFootnoteFrame::IsDeleteForbidden() const
{
if (SwLayoutFrame::IsDeleteForbidden())
return true;
// needs to be in sync with the ::Cut logic
const SwLayoutFrame *pUp = GetUpper();
if (pUp)
{
if (GetPrev())
return false;
// The last footnote takes its container along if it
// is deleted. Cut would put pUp->Lower() to the value
// of GetNext(), so if there is no GetNext then
// Cut would delete pUp. If that condition is true
// here then check if the container is delete-forbidden
return !GetNext() && pUp->IsDeleteForbidden();
}
return false;
}
void SwFootnoteFrame::Cut()
{
if ( GetNext() )
......@@ -496,7 +517,7 @@ void SwFootnoteFrame::Cut()
if ( pUp )
{
// The last footnote takes its container along
if ( !pUp->Lower() )
if (!pUp->Lower())
{
SwPageFrame *pPage = pUp->FindPageFrame();
if ( pPage )
......@@ -1587,7 +1608,8 @@ void SwFootnoteBossFrame::AppendFootnote( SwContentFrame *pRef, SwTextFootnote *
pNew->Calc(getRootFrame()->GetCurrShell()->GetOut());
// #i57914# - adjust fix #i49383#
if ( !bOldFootnoteFrameLocked && !pNew->GetLower() &&
!pNew->IsColLocked() && !pNew->IsBackMoveLocked() )
!pNew->IsColLocked() && !pNew->IsBackMoveLocked() &&
!pNew->IsDeleteForbidden() )
{
pNew->Cut();
SwFrame::DestroyFrame(pNew);
......@@ -2192,7 +2214,8 @@ void SwFootnoteBossFrame::RearrangeFootnotes( const SwTwips nDeadLine, const boo
if ( !bLock && bUnlockLastFootnoteFrame &&
!pLastFootnoteFrame->GetLower() &&
!pLastFootnoteFrame->IsColLocked() &&
!pLastFootnoteFrame->IsBackMoveLocked() )
!pLastFootnoteFrame->IsBackMoveLocked() &&
!pLastFootnoteFrame->IsDeleteForbidden() )
{
pLastFootnoteFrame->Cut();
SwFrame::DestroyFrame(pLastFootnoteFrame);
......
......@@ -861,6 +861,11 @@ bool SwTabFrame::RemoveFollowFlowLine()
// #140081# Make code robust.
if ( !pFollowFlowLine || !pLastLine )
return true;
if (pFollowFlowLine->IsDeleteForbidden())
{
SAL_WARN("sw.layout", "Cannot remove in-use Follow Flow Line");
return true;
}
// Move content
lcl_MoveRowContent( *pFollowFlowLine, *static_cast<SwRowFrame*>(pLastLine) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment