summaryrefslogtreecommitdiffstats
path: root/sw/source/core/layout
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx4
-rw-r--r--sw/source/core/layout/anchoredobject.cxx11
-rw-r--r--sw/source/core/layout/calcmove.cxx38
-rw-r--r--sw/source/core/layout/flowfrm.cxx5
-rw-r--r--sw/source/core/layout/fly.cxx4
-rw-r--r--sw/source/core/layout/flylay.cxx41
-rw-r--r--sw/source/core/layout/frmtool.cxx40
-rw-r--r--sw/source/core/layout/layact.cxx4
-rw-r--r--sw/source/core/layout/pagechg.cxx25
-rw-r--r--sw/source/core/layout/trvlfrm.cxx39
10 files changed, 139 insertions, 72 deletions
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 5a9e1245af..fe01bbc3b3 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -266,6 +266,8 @@ void SwAnchoredDrawObject::MakeObjPos()
SwDrawContact* pDrawContact =
static_cast<SwDrawContact*>(::GetUserCall( GetDrawObj() ));
+ if (!pDrawContact)
+ return;
// --> #i28749# - if anchored drawing object hasn't been yet
// positioned, convert its positioning attributes, if its positioning
@@ -849,6 +851,8 @@ void SwAnchoredDrawObject::SetPositioningAttr()
{
SwDrawContact* pDrawContact =
static_cast<SwDrawContact*>(GetUserCall( GetDrawObj() ));
+ if (!pDrawContact)
+ return;
SwFrameFormat* pObjFormat = GetFrameFormat();
if ( !pDrawContact->ObjAnchoredAsChar() )
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index a74438afb3..43c5baa396 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -44,10 +44,13 @@ SwObjPositioningInProgress::SwObjPositioningInProgress( SdrObject& _rSdrObj ) :
// --> #i52904#
mbOldObjPositioningInProgress( false )
{
- mpAnchoredObj = ::GetUserCall( &_rSdrObj )->GetAnchoredObj( &_rSdrObj );
- // --> #i52904#
- mbOldObjPositioningInProgress = mpAnchoredObj->IsPositioningInProgress();
- mpAnchoredObj->SetPositioningInProgress( true );
+ if (SwContact* pContact = ::GetUserCall( &_rSdrObj ))
+ {
+ mpAnchoredObj = pContact->GetAnchoredObj( &_rSdrObj );
+ // --> #i52904#
+ mbOldObjPositioningInProgress = mpAnchoredObj->IsPositioningInProgress();
+ mpAnchoredObj->SetPositioningInProgress( true );
+ }
}
SwObjPositioningInProgress::SwObjPositioningInProgress( SwAnchoredObject& _rAnchoredObj ) :
mpAnchoredObj( &_rAnchoredObj ),
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index e13fdf0121..f358d74af0 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -1076,6 +1076,44 @@ bool SwFrame::IsCollapse() const
return pTextFrame->GetText().isEmpty() && pTextNode && pTextNode->IsCollapse();
}
+bool SwFrame::IsCollapseUpper() const
+{
+ const SwTextFrame* pTextFrame = DynCastTextFrame();
+ if (!pTextFrame)
+ {
+ return false;
+ }
+
+ const SwDoc& rDoc = pTextFrame->GetDoc();
+ const IDocumentSettingAccess& rIDSA = rDoc.getIDocumentSettingAccess();
+ if (!rIDSA.get(DocumentSettingId::TAB_OVER_SPACING) || rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN))
+ {
+ // Writer or Word Word <= 2010 style: upper margin is never ignored.
+ return false;
+ }
+
+ if (IsInFly())
+ {
+ // Not in a page's body.
+ return false;
+ }
+
+ // Word >= 2013 style: when we're at the top of the page's body, but not on the first page, then
+ // ignore the upper margin for paragraphs.
+ if (GetPrev() || !GetUpper() || !GetUpper()->IsBodyFrame())
+ {
+ return false;
+ }
+
+ const SwPageFrame* pPageFrame = FindPageFrame();
+ if (!pPageFrame || !pPageFrame->GetPrev())
+ {
+ return false;
+ }
+
+ return true;
+}
+
void SwContentFrame::MakePrtArea( const SwBorderAttrs &rAttrs )
{
if ( isFramePrintAreaValid() )
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 88158161c5..37fd20b323 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1658,6 +1658,11 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
CastFlowFrame( pOwn )->HasParaSpaceAtPages( m_rThis.IsSctFrame() ) )
{
nUpper = pAttrs->GetULSpace().GetUpper();
+
+ if (m_rThis.IsCollapseUpper())
+ {
+ nUpper = 0;
+ }
}
}
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index db50a42de0..b454bd9591 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2528,8 +2528,8 @@ void SwFrame::AppendDrawObj( SwAnchoredObject& _rNewObj )
assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
// perform disconnect from layout, if 'master' drawing object is appended
// to a new frame.
- static_cast<SwDrawContact*>(::GetUserCall( _rNewObj.GetDrawObj() ))->
- DisconnectFromLayout( false );
+ if (SwDrawContact* pContact = static_cast<SwDrawContact*>(::GetUserCall( _rNewObj.GetDrawObj() )))
+ pContact->DisconnectFromLayout( false );
assert(!m_pDrawObjs || m_pDrawObjs->is_sorted());
}
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 7ac95d65e0..b0ef08a01f 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -1430,27 +1430,30 @@ bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove )
}
tools::Long nHeight = (9*aRectFnSet.GetHeight(rRect))/10;
tools::Long nTop;
- const SwFormat *pFormat = GetUserCall(pSdrObj)->GetFormat();
- const SvxULSpaceItem &rUL = pFormat->GetULSpace();
- if( bMove )
+ if (const SwContact* pContact = ::GetUserCall( pSdrObj ))
{
- nTop = aRectFnSet.IsVert() ? static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().X() :
- static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().Y();
- nTop = aRectFnSet.YInc( nTop, -nHeight );
- tools::Long nWidth = aRectFnSet.GetWidth(pFly->getFrameArea());
- aRectFnSet.SetLeftAndWidth( rRect, aRectFnSet.IsVert() ?
- static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().Y() :
- static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().X(), nWidth );
- nHeight = 2*nHeight - rUL.GetLower() - rUL.GetUpper();
- }
- else
- {
- nTop = aRectFnSet.YInc( aRectFnSet.GetBottom(pFly->getFrameArea()),
- rUL.GetLower() - nHeight );
- nHeight = 2*nHeight - aRectFnSet.GetHeight(pFly->getFrameArea())
- - rUL.GetLower() - rUL.GetUpper();
+ const SwFormat *pFormat = pContact->GetFormat();
+ const SvxULSpaceItem &rUL = pFormat->GetULSpace();
+ if( bMove )
+ {
+ nTop = aRectFnSet.IsVert() ? static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().X() :
+ static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().Y();
+ nTop = aRectFnSet.YInc( nTop, -nHeight );
+ tools::Long nWidth = aRectFnSet.GetWidth(pFly->getFrameArea());
+ aRectFnSet.SetLeftAndWidth( rRect, aRectFnSet.IsVert() ?
+ static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().Y() :
+ static_cast<const SwFlyInContentFrame*>(pFly)->GetRefPoint().X(), nWidth );
+ nHeight = 2*nHeight - rUL.GetLower() - rUL.GetUpper();
+ }
+ else
+ {
+ nTop = aRectFnSet.YInc( aRectFnSet.GetBottom(pFly->getFrameArea()),
+ rUL.GetLower() - nHeight );
+ nHeight = 2*nHeight - aRectFnSet.GetHeight(pFly->getFrameArea())
+ - rUL.GetLower() - rUL.GetUpper();
+ }
+ aRectFnSet.SetTopAndHeight( rRect, nTop, nHeight );
}
- aRectFnSet.SetTopAndHeight( rRect, nTop, nHeight );
}
}
else
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index baf632d6eb..38667bd5c4 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -297,6 +297,8 @@ void SwFrameNotify::ImplDestroy()
bool bNotify = false;
bool bNotifySize = false;
SwContact* pContact = ::GetUserCall( pObj->GetDrawObj() );
+ if (!pContact)
+ continue;
const bool bAnchoredAsChar = pContact->ObjAnchoredAsChar();
if ( !bAnchoredAsChar )
{
@@ -1067,22 +1069,23 @@ void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *c
InsertObject(pSdrObj, pSdrObj->GetOrdNumDirect());
}
- SwDrawContact* pNew =
- static_cast<SwDrawContact*>(GetUserCall( pSdrObj ));
- if ( !pNew->GetAnchorFrame() )
- {
- pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( nullptr )) );
- }
- // OD 19.06.2003 #108784# - add 'virtual' drawing object,
- // if necessary. But control objects have to be excluded.
- else if ( !::CheckControlLayer( pSdrObj ) &&
- pNew->GetAnchorFrame() != pFrame &&
- !pNew->GetDrawObjectByAnchorFrame( *pFrame ) )
+ if (SwDrawContact* pNew = static_cast<SwDrawContact*>(GetUserCall( pSdrObj )))
{
- SwDrawVirtObj* pDrawVirtObj = pNew->AddVirtObj(*pFrame);
- pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( pDrawVirtObj )) );
+ if ( !pNew->GetAnchorFrame() )
+ {
+ pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( nullptr )) );
+ }
+ // OD 19.06.2003 #108784# - add 'virtual' drawing object,
+ // if necessary. But control objects have to be excluded.
+ else if ( !::CheckControlLayer( pSdrObj ) &&
+ pNew->GetAnchorFrame() != pFrame &&
+ !pNew->GetDrawObjectByAnchorFrame( *pFrame ) )
+ {
+ SwDrawVirtObj* pDrawVirtObj = pNew->AddVirtObj(*pFrame);
+ pFrame->AppendDrawObj( *(pNew->GetAnchoredObj( pDrawVirtObj )) );
- pDrawVirtObj->ActionChanged();
+ pDrawVirtObj->ActionChanged();
+ }
}
}
else
@@ -3598,8 +3601,13 @@ bool Is_Lower_Of(const SwFrame *pCurrFrame, const SdrObject* pObj)
}
else
{
- pFrame = static_cast<SwDrawContact*>(GetUserCall(pObj))->GetAnchorFrame(pObj);
- aPos = pObj->GetCurrentBoundRect().TopLeft();
+ if (SwDrawContact* pC = static_cast<SwDrawContact*>(GetUserCall(pObj)))
+ {
+ pFrame = pC->GetAnchorFrame(pObj);
+ aPos = pObj->GetCurrentBoundRect().TopLeft();
+ }
+ else
+ return false;
}
OSL_ENSURE( pFrame, "8-( Fly is lost in Space." );
pFrame = GetVirtualUpper( pFrame, aPos );
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 1a0a1260a1..ad437f9852 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1439,9 +1439,9 @@ bool SwLayAction::FormatLayout( OutputDevice *pRenderContext, SwLayoutFrame *pLa
PopFormatLayout();
}
}
- else if (pLay->IsSctFrame() && pLow->IsTextFrame() && pLow == pLay->GetLastLower())
+ else if (pLay->IsSctFrame() && pLay->GetNext() && pLay->GetNext()->IsSctFrame() && pLow->IsTextFrame() && pLow == pLay->GetLastLower())
{
- // else: only calc the last text lower of sections
+ // else: only calc the last text lower of sections, followed by sections
pLow->OptCalc();
}
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index f8c029ea12..2575c98278 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -56,6 +56,7 @@
#include <tabfrm.hxx>
#include <txtfrm.hxx>
#include <notxtfrm.hxx>
+#include <sectfrm.hxx>
#include <layact.hxx>
#include <flyfrms.hxx>
#include <htmltbl.hxx>
@@ -445,22 +446,21 @@ static void lcl_MakeObjs(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, SwP
if ( bSdrObj )
{
// OD 23.06.2003 #108784# - consider 'virtual' drawing objects
- SwDrawContact *pContact =
- static_cast<SwDrawContact*>(::GetUserCall(pSdrObj));
- if ( auto pDrawVirtObj = dynamic_cast<SwDrawVirtObj *>( pSdrObj ) )
+ if (SwDrawContact *pContact =
+ static_cast<SwDrawContact*>(::GetUserCall(pSdrObj)))
{
- if ( pContact )
+ if ( auto pDrawVirtObj = dynamic_cast<SwDrawVirtObj *>( pSdrObj ) )
{
pDrawVirtObj->RemoveFromWriterLayout();
pDrawVirtObj->RemoveFromDrawingPage();
pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pDrawVirtObj )) );
}
- }
- else
- {
- if ( pContact->GetAnchorFrame() )
- pContact->DisconnectFromLayout( false );
- pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pSdrObj )) );
+ else
+ {
+ if ( pContact->GetAnchorFrame() )
+ pContact->DisconnectFromLayout( false );
+ pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pSdrObj )) );
+ }
}
}
else
@@ -790,8 +790,11 @@ SwPageDesc *SwPageFrame::FindPageDesc()
}
SwContentFrame* pFirstContent = FindFirstBodyContent();
- while (pFirstContent && pFirstContent->IsHiddenNow())
+ while (pFirstContent && pFirstContent->IsInSct()
+ && pFirstContent->FindSctFrame()->IsHiddenNow())
+ {
pFirstContent = pFirstContent->GetNextContentFrame();
+ }
SwFrame* pFlow = pFirstContent;
if ( pFlow && pFlow->IsInTab() )
pFlow = pFlow->FindTabFrame();
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 89a5f03302..0e3d135706 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -70,26 +70,29 @@ namespace {
{
const SwVirtFlyDrawObj* pObj =
static_cast<const SwVirtFlyDrawObj*>(aIter());
- const SwAnchoredObject* pAnchoredObj = GetUserCall( aIter() )->GetAnchoredObj( aIter() );
- const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat();
- const SwFormatSurround& rSurround = pObjFormat->GetSurround();
- const SvxOpaqueItem& rOpaque = pObjFormat->GetOpaque();
- bool bInBackground = ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH ) && !rOpaque.GetValue();
-
- bool bBackgroundMatches = bInBackground == bSearchBackground;
-
- const SwFlyFrame* pFly = pObj ? pObj->GetFlyFrame() : nullptr;
- if ( pFly && bBackgroundMatches &&
- ( ( pCMS && pCMS->m_bSetInReadOnly ) ||
- !pFly->IsProtected() ) &&
- pFly->GetModelPositionForViewPoint( pPos, aPoint, pCMS ) )
+ if (const SwContact* pContact = ::GetUserCall( aIter() ))
{
- bRet = true;
- break;
- }
+ const SwAnchoredObject* pAnchoredObj = pContact->GetAnchoredObj( aIter() );
+ const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat();
+ const SwFormatSurround& rSurround = pObjFormat->GetSurround();
+ const SvxOpaqueItem& rOpaque = pObjFormat->GetOpaque();
+ bool bInBackground = ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH ) && !rOpaque.GetValue();
+
+ bool bBackgroundMatches = bInBackground == bSearchBackground;
+
+ const SwFlyFrame* pFly = pObj ? pObj->GetFlyFrame() : nullptr;
+ if ( pFly && bBackgroundMatches &&
+ ( ( pCMS && pCMS->m_bSetInReadOnly ) ||
+ !pFly->IsProtected() ) &&
+ pFly->GetModelPositionForViewPoint( pPos, aPoint, pCMS ) )
+ {
+ bRet = true;
+ break;
+ }
- if ( pCMS && pCMS->m_bStop )
- return false;
+ if ( pCMS && pCMS->m_bStop )
+ return false;
+ }
aIter.Prev();
}
return bRet;