Kaydet (Commit) def855d0 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 46125c6d
......@@ -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 );
......
......@@ -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
......
......@@ -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
......
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