From 15faeb4f9f111f7ea8d04fd64b3d065971cd4570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 22 Jan 2015 17:03:22 +0000 Subject: [PATCH] Resolves: fdo#87760 if we can't anchor at hidden text then... anchor to the page instead Change-Id: Ib7931fdd1c70e809ec442aeac125879980e20ec9 --- sw/source/core/frmedt/feshview.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 6923a71296ee..b75bdae064c0 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1585,12 +1585,20 @@ bool SwFEShell::ImpEndCreate() GetLayout()->GetCrsrOfst( &aPos, aPoint, &aState ); // do not set in ReadnOnly-content - if( aPos.nNode.GetNode().IsProtect() ) + if (aPos.nNode.GetNode().IsProtect()) + { // then only page bound. Or should we // search the next not-readonly position? bAtPage = true; + } - pAnch = aPos.nNode.GetNode().GetCntntNode()->getLayoutFrm( GetLayout(), &aPoint, 0, false ); + SwCntntNode* pCNode = aPos.nNode.GetNode().GetCntntNode(); + pAnch = pCNode ? pCNode->getLayoutFrm( GetLayout(), &aPoint, 0, false ) : NULL; + if (!pAnch) + { + // Hidden content. Anchor to the page instead + bAtPage = true; + } if( !bAtPage ) { @@ -1636,7 +1644,7 @@ bool SwFEShell::ImpEndCreate() if( bAtPage ) { - pPage = pAnch->FindPageFrm(); + pPage = pAnch ? pAnch->FindPageFrm() : GetLayout()->GetPageAtPos(aPoint); aAnch.SetType( FLY_AT_PAGE ); aAnch.SetPageNum( pPage->GetPhyPageNum() );