summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-09-12 10:44:38 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-09-19 10:08:55 +0200
commitf6a60ce214117946eef222701023dca612bf0a2b (patch)
treee9369daef6b219ff8376dde4dd9b0b697e825530
parent6a26564ade2281d01fd2695f7fd021bba76dc12e (diff)
sw_redlinehide_2: view cursor movement, SwCursorShell::LeftRight()
Just put a loop in SwCursor::LeftRight() to repeat a movement if it didn't actually advance the text frame index; the SwContentNode::GoPrevious()/GoNext() take into account hidden text attributes from SwScriptInfo, so this ought to result in end positions that are neither hidden by attributes nor by redlines. This requires passing the layout to SwCursor. Change-Id: Ieb623840f6390fa6f1c78b7458ad8dc6523a2744
-rw-r--r--sw/inc/swcrsr.hxx10
-rw-r--r--sw/source/core/crsr/crsrsh.cxx3
-rw-r--r--sw/source/core/crsr/swcrsr.cxx52
3 files changed, 58 insertions, 7 deletions
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index ca6b18b325e9..41aba80df7e5 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -166,15 +166,16 @@ public:
bool ExpandToSentenceBorders();
virtual bool LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
- bool bAllowVisual, bool bSkipHidden, bool bInsertCursor );
+ bool bAllowVisual, bool bSkipHidden, bool bInsertCursor,
+ SwRootFrame const* pLayout);
bool UpDown( bool bUp, sal_uInt16 nCnt, Point const * pPt, long nUpDownX );
bool LeftRightMargin( bool bLeftMargin, bool bAPI );
bool IsAtLeftRightMargin( bool bLeftMargin, bool bAPI ) const;
bool SttEndDoc( bool bSttDoc );
bool GoPrevNextCell( bool bNext, sal_uInt16 nCnt );
- bool Left( sal_uInt16 nCnt ) { return LeftRight( true, nCnt, CRSR_SKIP_CHARS, false/*bAllowVisual*/, false/*bSkipHidden*/, false ); }
- bool Right( sal_uInt16 nCnt ) { return LeftRight( false, nCnt, CRSR_SKIP_CHARS, false/*bAllowVisual*/, false/*bSkipHidden*/, false ); }
+ bool Left( sal_uInt16 nCnt ) { return LeftRight( true, nCnt, CRSR_SKIP_CHARS, false/*bAllowVisual*/, false/*bSkipHidden*/, false, nullptr ); }
+ bool Right( sal_uInt16 nCnt ) { return LeftRight( false, nCnt, CRSR_SKIP_CHARS, false/*bAllowVisual*/, false/*bSkipHidden*/, false, nullptr ); }
bool GoNextCell( sal_uInt16 nCnt = 1 ) { return GoPrevNextCell( true, nCnt ); }
bool GoPrevCell( sal_uInt16 nCnt = 1 ) { return GoPrevNextCell( false, nCnt ); }
virtual bool GotoTable( const OUString& rName );
@@ -274,7 +275,8 @@ public:
virtual ~SwTableCursor() override;
virtual bool LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
- bool bAllowVisual, bool bSkipHidden, bool bInsertCursor ) override;
+ bool bAllowVisual, bool bSkipHidden, bool bInsertCursor,
+ SwRootFrame const*) override;
virtual bool GotoTable( const OUString& rName ) override;
void InsertBox( const SwTableBox& rTableBox );
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 6dc236921d9b..bc053b947a74 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -350,7 +350,8 @@ bool SwCursorShell::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
// reflected in the return value <bRet>.
const bool bResetOfInFrontOfLabel = SetInFrontOfLabel( false );
bRet = pShellCursor->LeftRight( bLeft, nCnt, nMode, bVisualAllowed,
- bSkipHidden, !IsOverwriteCursor() );
+ bSkipHidden, !IsOverwriteCursor(),
+ GetLayout());
if ( !bRet && bLeft && bResetOfInFrontOfLabel )
{
// undo reset of <bInFrontOfLabel> flag
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 1b74af2faa58..25118e6f9aa9 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -1559,7 +1559,8 @@ bool SwCursor::ExpandToSentenceBorders()
}
bool SwTableCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 /*nMode*/,
- bool /*bVisualAllowed*/, bool /*bSkipHidden*/, bool /*bInsertCursor*/ )
+ bool /*bVisualAllowed*/, bool /*bSkipHidden*/, bool /*bInsertCursor*/,
+ SwRootFrame const*)
{
return bLeft ? GoPrevCell( nCnt )
: GoNextCell( nCnt );
@@ -1621,7 +1622,8 @@ SwCursor::DoSetBidiLevelLeftRight(
}
bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
- bool bVisualAllowed,bool bSkipHidden, bool bInsertCursor )
+ bool bVisualAllowed,bool bSkipHidden, bool bInsertCursor,
+ SwRootFrame const*const pLayout)
{
// calculate cursor bidi level
SwNode& rNode = GetPoint()->nNode.GetNode();
@@ -1638,13 +1640,59 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
else
fnGo = CRSR_SKIP_CELLS == nMode ? GoInContentCells : GoInContent;
+ SwTextFrame const* pFrame(nullptr);
+ if (pLayout)
+ {
+ pFrame = static_cast<SwTextFrame*>(rNode.GetContentNode()->getLayoutFrame(pLayout));
+ if (pFrame)
+ {
+ while (pFrame->GetPrecede())
+ {
+ pFrame = static_cast<SwTextFrame const*>(pFrame->GetPrecede());
+ }
+ }
+ }
+
while( nCnt )
{
SwNodeIndex aOldNodeIdx( GetPoint()->nNode );
+ TextFrameIndex beforeIndex(-1);
+ if (pFrame)
+ {
+ beforeIndex = pFrame->MapModelToViewPos(*GetPoint());
+ }
+
if ( !Move( fnMove, fnGo ) )
break;
+ if (pFrame)
+ {
+ SwTextFrame const* pNewFrame(static_cast<SwTextFrame const*>(
+ GetPoint()->nNode.GetNode().GetContentNode()->getLayoutFrame(pLayout)));
+ if (pNewFrame)
+ {
+ while (pNewFrame->GetPrecede())
+ {
+ pNewFrame = static_cast<SwTextFrame const*>(pNewFrame->GetPrecede());
+ }
+ }
+ // sw_redlinehide: fully redline-deleted nodes don't have frames...
+ if (pFrame == pNewFrame || !pNewFrame)
+ {
+ if (!pNewFrame || beforeIndex == pFrame->MapModelToViewPos(*GetPoint()))
+ {
+ continue; // moving inside delete redline, doesn't count...
+ }
+ }
+ else
+ {
+ // assume iteration is stable & returns the same frame
+ assert(!pFrame->IsAnFollow(pNewFrame) && !pNewFrame->IsAnFollow(pFrame));
+ pFrame = pNewFrame;
+ }
+ }
+
// If we were located inside a covered cell but our position has been
// corrected, we check if the last move has moved the cursor to a
// different table cell. In this case we set the cursor to the stored