diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-10-26 14:39:23 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-15 15:10:03 +0100 |
commit | c50ed4176cb1addfd11c075b3bb3650f74e91685 (patch) | |
tree | 4df3055e9d7edb0f5ec6955bb1f0b1133ef88c34 | |
parent | 7f49659e68786948904bf71b65e8510878552d8c (diff) |
sw_redlinehide_3: adapt SwDoc::GotoNextNum()/GotoPrevNum()
... and callers in SwCursorShell / SwEditShell.
Change-Id: Iffe4ca7893b97df8bd07f25c9e0e1dc908011e3f
-rw-r--r-- | sw/inc/doc.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/crsr/crstrvl.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 61 | ||||
-rw-r--r-- | sw/source/core/edit/ednumber.cxx | 10 |
4 files changed, 62 insertions, 19 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 86a2508abbab..6e88b3465a59 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1065,9 +1065,11 @@ public: const OUString& rNewRule ); // Goto next/previous on same level. - static bool GotoNextNum( SwPosition&, bool bOverUpper = true, + static bool GotoNextNum( SwPosition&, SwRootFrame const* pLayout, + bool bOverUpper = true, sal_uInt8* pUpper = nullptr, sal_uInt8* pLower = nullptr ); - static bool GotoPrevNum( SwPosition&, bool bOverUpper = true ); + static bool GotoPrevNum( SwPosition&, SwRootFrame const* pLayout, + bool bOverUpper = true ); /** Searches for a text node with a numbering rule. diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 2bd8d284a6ed..2edd2711ff73 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -112,14 +112,14 @@ void SwCursorShell::MoveCursorToNum() /// go to next/previous point on the same level void SwCursorShell::GotoNextNum() { - if (!SwDoc::GotoNextNum( *m_pCurrentCursor->GetPoint() )) + if (!SwDoc::GotoNextNum(*m_pCurrentCursor->GetPoint(), GetLayout())) return; MoveCursorToNum(); } void SwCursorShell::GotoPrevNum() { - if (!SwDoc::GotoPrevNum( *m_pCurrentCursor->GetPoint() )) + if (!SwDoc::GotoPrevNum(*m_pCurrentCursor->GetPoint(), GetLayout())) return; MoveCursorToNum(); } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index dff89e3ebb3b..764b16eff5aa 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -42,6 +42,7 @@ #include <docary.hxx> #include <mvsave.hxx> #include <txtfrm.hxx> +#include <rootfrm.hxx> #include <pamtyp.hxx> #include <redline.hxx> #include <strings.hrc> @@ -1396,10 +1397,47 @@ static bool lcl_IsValidPrevNextNumNode( const SwNodeIndex& rIdx ) return bRet; } +static void +lcl_GotoPrevLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout) +{ + if (pLayout && pLayout->IsHideRedlines() + && rIndex.GetNode().IsTextNode() + && rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None) + { + rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pFirstNode; + } + --rIndex; + if (pLayout && rIndex.GetNode().IsTextNode()) + { + rIndex = *sw::GetParaPropsNode(*pLayout, *rIndex.GetNode().GetTextNode()); + } +} + +static void +lcl_GotoNextLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout) +{ + if (pLayout && pLayout->IsHideRedlines() + && rIndex.GetNode().IsTextNode() + && rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None) + { + rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pLastNode; + } + ++rIndex; + if (pLayout && rIndex.GetNode().IsTextNode()) + { + rIndex = *sw::GetParaPropsNode(*pLayout, *rIndex.GetNode().GetTextNode()); + } +} + static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, - bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower ) + bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower, + SwRootFrame const*const pLayout) { const SwTextNode* pNd = rPos.nNode.GetNode().GetTextNode(); + if (pNd && pLayout) + { + pNd = sw::GetParaPropsNode(*pLayout, *pNd); + } if( !pNd || nullptr == pNd->GetNumRule() ) return false; @@ -1411,7 +1449,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, // If NO_NUMLEVEL is switched on, we search the preceding Node with Numbering bool bError = false; do { - --aIdx; + lcl_GotoPrevLayoutTextFrame(aIdx, pLayout); if( aIdx.GetNode().IsTextNode() ) { pNd = aIdx.GetNode().GetTextNode(); @@ -1443,12 +1481,12 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, const SwTextNode* pLast; if( bNext ) { - ++aIdx; + lcl_GotoNextLayoutTextFrame(aIdx, pLayout); pLast = pNd; } else { - --aIdx; + lcl_GotoPrevLayoutTextFrame(aIdx, pLayout); pLast = nullptr; } @@ -1479,9 +1517,9 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, break; if( bNext ) - ++aIdx; + lcl_GotoNextLayoutTextFrame(aIdx, pLayout); else - --aIdx; + lcl_GotoPrevLayoutTextFrame(aIdx, pLayout); } if( !bRet && !bOverUpper && pLast ) // do not iterate over higher numbers, but still to the end @@ -1510,10 +1548,10 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, return bRet; } -bool SwDoc::GotoNextNum( SwPosition& rPos, bool bOverUpper, - sal_uInt8* pUpper, sal_uInt8* pLower ) +bool SwDoc::GotoNextNum(SwPosition& rPos, SwRootFrame const*const pLayout, + bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower) { - return ::lcl_GotoNextPrevNum( rPos, true, bOverUpper, pUpper, pLower ); + return ::lcl_GotoNextPrevNum(rPos, true, bOverUpper, pUpper, pLower, pLayout); } const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, @@ -1591,9 +1629,10 @@ const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, return pResult; } -bool SwDoc::GotoPrevNum( SwPosition& rPos, bool bOverUpper ) +bool SwDoc::GotoPrevNum(SwPosition& rPos, SwRootFrame const*const pLayout, + bool bOverUpper) { - return ::lcl_GotoNextPrevNum( rPos, false, bOverUpper, nullptr, nullptr ); + return ::lcl_GotoNextPrevNum(rPos, false, bOverUpper, nullptr, nullptr, pLayout); } bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown ) diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 18c3813b24fd..f6f201e1165a 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -430,7 +430,7 @@ void SwEditShell::GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower aCursor.SetMark(); if( pCursor->HasMark() ) *aCursor.GetPoint() = *pCursor->End(); - SwDoc::GotoNextNum( *aCursor.GetPoint(), false, &rUpper, &rLower ); + SwDoc::GotoNextNum(*aCursor.GetPoint(), GetLayout(), false, &rUpper, &rLower); } bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft ) @@ -447,7 +447,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft ) bool bRet = false; sal_uInt8 nUpperLevel, nLowerLevel; - if( SwDoc::GotoNextNum( *aCursor.GetPoint(), false, + if (SwDoc::GotoNextNum( *aCursor.GetPoint(), GetLayout(), false, &nUpperLevel, &nLowerLevel )) { if( bUpperLower ) @@ -459,7 +459,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft ) if( bUpperLeft ) // move up { SwPosition aPos( *aCursor.GetMark() ); - if( SwDoc::GotoPrevNum( aPos, false ) ) + if (SwDoc::GotoPrevNum( aPos, GetLayout(), false )) nOffset = aPos.nNode.GetIndex() - aCursor.GetMark()->nNode.GetIndex(); else @@ -475,7 +475,9 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft ) } else // move down { - const SwNumRule* pOrig = aCursor.GetNode(false).GetTextNode()->GetNumRule(); + assert(!aCursor.GetNode().IsTextNode() + || sw::IsParaPropsNode(*GetLayout(), *aCursor.GetNode().GetTextNode())); + const SwNumRule* pOrig = sw::GetParaPropsNode(*GetLayout(), *aCursor.GetNode(false).GetTextNode())->GetNumRule(); if( aCursor.GetNode().IsTextNode() && pOrig == aCursor.GetNode().GetTextNode()->GetNumRule() ) { |