summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-05-30 16:05:19 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-06-08 19:40:29 +0200
commitc2cae0e8624eea930911418d9563174e39493c51 (patch)
tree002f3bb65169e071c3c15e43c2b9874004dd85a5
parent03fb5a1e09106674cb5ff00dc9a8b2600a32ba43 (diff)
sw_redlinehide: SwTextFrame::HideAndShowObjects()
Let it get the SwTextNode from the fly's anchor position, instead of from SwTextFrame. Change-Id: I833db32b2d7dd689c04fe93d75910364b6b91a3c
-rw-r--r--sw/inc/anchoredobject.hxx3
-rw-r--r--sw/source/core/text/txtfrm.cxx27
2 files changed, 18 insertions, 12 deletions
diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index a44c4e23bcb2..a433133c8840 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -23,6 +23,7 @@
#include "swrect.hxx"
#include <libxml/xmlwriter.h>
+struct SwPosition;
class SdrObject;
class SwFrame;
class SwLayoutFrame;
@@ -160,7 +161,7 @@ class SW_DLLPUBLIC SwAnchoredObject
// object positioning
friend bool sw_HideObj( const SwTextFrame& _rFrame,
const RndStdIds _eAnchorType,
- const sal_Int32 _nObjAnchorPos,
+ SwPosition const& rAnchorPos,
SwAnchoredObject* _pAnchoredObj );
protected:
SwAnchoredObject();
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index f405b30bc5ff..b3794b17e12a 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1055,7 +1055,7 @@ void SwTextFrame::HideFootnotes(TextFrameIndex const nStart, TextFrameIndex cons
*/
bool sw_HideObj( const SwTextFrame& _rFrame,
const RndStdIds _eAnchorType,
- const sal_Int32 _nObjAnchorPos,
+ SwPosition const& rAnchorPos,
SwAnchoredObject* _pAnchoredObj )
{
bool bRet( true );
@@ -1069,13 +1069,16 @@ bool sw_HideObj( const SwTextFrame& _rFrame,
pIDSA->get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
_rFrame.IsInDocBody() && !_rFrame.FindNextCnt() )
{
- const OUString &rStr = _rFrame.GetTextNode()->GetText();
- const sal_Unicode cAnchorChar = _nObjAnchorPos < rStr.getLength() ? rStr[_nObjAnchorPos] : 0;
+ SwTextNode const& rNode(*rAnchorPos.nNode.GetNode().GetTextNode());
+ assert(_rFrame.GetMergedPara() || &rNode == _rFrame.GetRegisteredIn()); // simple consistency check
+ sal_Int32 const nObjAnchorPos(rAnchorPos.nContent.GetIndex());
+ const sal_Unicode cAnchorChar = nObjAnchorPos < rNode.Len()
+ ? rNode.GetText()[nObjAnchorPos]
+ : 0;
if (cAnchorChar == CH_TXTATR_BREAKWORD)
{
const SwTextAttr* const pHint(
- _rFrame.GetTextNode()->GetTextAttrForCharAt(_nObjAnchorPos,
- RES_TXTATR_FLYCNT) );
+ rNode.GetTextAttrForCharAt(nObjAnchorPos, RES_TXTATR_FLYCNT));
if ( pHint )
{
const SwFrameFormat* pFrameFormat =
@@ -1126,9 +1129,8 @@ void SwTextFrame::HideAndShowObjects()
SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
// under certain conditions
const RndStdIds eAnchorType( pContact->GetAnchorId() );
- const sal_Int32 nObjAnchorPos = pContact->GetContentAnchorIndex().GetIndex();
if ((eAnchorType != RndStdIds::FLY_AT_CHAR) ||
- sw_HideObj( *this, eAnchorType, nObjAnchorPos,
+ sw_HideObj(*this, eAnchorType, pContact->GetContentAnchor(),
i ))
{
pContact->MoveObjToInvisibleLayer( pObj );
@@ -1139,7 +1141,6 @@ void SwTextFrame::HideAndShowObjects()
{
// paragraph is visible, but can contain hidden text portion.
// first we check if objects are allowed to be hidden:
- const SwTextNode& rNode = *GetTextNode();
const SwViewShell* pVsh = getRootFrame()->GetCurrShell();
const bool bShouldBeHidden = !pVsh || !pVsh->GetWin() ||
!pVsh->GetViewOptions()->IsShowHiddenChar();
@@ -1163,12 +1164,16 @@ void SwTextFrame::HideAndShowObjects()
{
sal_Int32 nHiddenStart;
sal_Int32 nHiddenEnd;
- const sal_Int32 nObjAnchorPos = pContact->GetContentAnchorIndex().GetIndex();
- SwScriptInfo::GetBoundsOfHiddenRange( rNode, nObjAnchorPos, nHiddenStart, nHiddenEnd );
+ const SwPosition& rAnchor = pContact->GetContentAnchor();
+ SwScriptInfo::GetBoundsOfHiddenRange(
+ *rAnchor.nNode.GetNode().GetTextNode(),
+ rAnchor.nContent.GetIndex(), nHiddenStart, nHiddenEnd);
// Under certain conditions
if ( nHiddenStart != COMPLETE_STRING && bShouldBeHidden &&
- sw_HideObj( *this, eAnchorType, nObjAnchorPos, i ) )
+ sw_HideObj(*this, eAnchorType, rAnchor, i))
+ {
pContact->MoveObjToInvisibleLayer( pObj );
+ }
else
pContact->MoveObjToVisibleLayer( pObj );
}