diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-10-25 11:06:38 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-10 19:47:00 +0100 |
commit | 6e0173164145c1580e257692c1f553d499433426 (patch) | |
tree | 51a890849cd9aa574fee95f8e8cc67e9cbffadc0 /sw | |
parent | f39484d7f2647db12bd85c43a467a6d3d1e3acb5 (diff) |
sw_redlinehide_3: adapt GotoOutline for SwCursrShell
Adapt SwDoc::GotoOutline(), SwCursorShell::GotoNextOutline(),
SwCursorShell::GotoPrevOutline() to skip over outline nodes that are
merged away in the layout.
Change-Id: Id6f6bb93177753ed21a438c89dc6d90098e11455
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/crstrvl.cxx | 82 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentLinksAdministrationManager.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 18 |
4 files changed, 76 insertions, 28 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 93f90e0fc2a8..6f11d6bc8bff 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1007,7 +1007,7 @@ public: /// Outline - move up / move down. bool MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset); - bool GotoOutline( SwPosition& rPos, const OUString& rName ) const; + bool GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const* = nullptr) const; /** Accept changes of outline styles for OutlineRule. @param bResetIndentAttrs Optional parameter - default value false: diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 956efc128f1a..5f0d28946218 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1001,7 +1001,8 @@ bool SwCursorShell::GotoOutline( const OUString& rName ) SwCursorSaveState aSaveState( *pCursor ); bool bRet = false; - if( mxDoc->GotoOutline( *pCursor->GetPoint(), rName ) && !pCursor->IsSelOvr() ) + if (mxDoc->GotoOutline(*pCursor->GetPoint(), rName, GetLayout()) + && !pCursor->IsSelOvr()) { UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY); bRet = true; @@ -1023,18 +1024,45 @@ bool SwCursorShell::GotoNextOutline() SwCursor* pCursor = getShellCursor( true ); SwNode* pNd = &(pCursor->GetNode()); SwOutlineNodes::size_type nPos; - if( rNds.GetOutLineNds().Seek_Entry( pNd, &nPos )) - ++nPos; + bool bUseFirst = !rNds.GetOutLineNds().Seek_Entry( pNd, &nPos ); + SwOutlineNodes::size_type const nStartPos(nPos); + + do + { + if (nPos == rNds.GetOutLineNds().size()) + { + nPos = 0; + } + else if (!bUseFirst) + { + ++nPos; + } + + if (bUseFirst) + { + bUseFirst = false; + } + else + { + if (nPos == nStartPos) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + } - if( nPos == rNds.GetOutLineNds().size() ) + pNd = rNds.GetOutLineNds()[ nPos ]; + } + while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode())); + + if (nPos < nStartPos) { - nPos = 0; SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped ); } else + { SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); - - pNd = rNds.GetOutLineNds()[ nPos ]; + } SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // watch Cursor-Moves @@ -1064,20 +1092,38 @@ bool SwCursorShell::GotoPrevOutline() SwOutlineNodes::size_type nPos; bool bRet = false; (void)rNds.GetOutLineNds().Seek_Entry(pNd, &nPos); - if ( nPos == 0 ) - { - nPos = rNds.GetOutLineNds().size(); - SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped ); - } - else - SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + SwOutlineNodes::size_type const nStartPos(nPos); - if (nPos) + do { - --nPos; // before + if (nPos == 0) + { + nPos = rNds.GetOutLineNds().size() - 1; + } + else + { + --nPos; // before + } + if (nPos == nStartPos) + { + pNd = nullptr; + break; + } pNd = rNds.GetOutLineNds()[ nPos ]; + } + while (!sw::IsParaPropsNode(*GetLayout(), *pNd->GetTextNode())); + if (pNd) + { + if (nStartPos < nPos) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped ); + } + else + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + } SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // watch Cursor-Moves SwCursorSaveState aSaveState( *pCursor ); @@ -1088,6 +1134,10 @@ bool SwCursorShell::GotoPrevOutline() if( bRet ) UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY); } + else + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + } return bRet; } diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index c30eeb382382..577db70611ff 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -502,7 +502,7 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, else if( sCmp == "outline" ) { SwPosition aPos( SwNodeIndex( m_rDoc.GetNodes() )); - if( m_rDoc.GotoOutline( aPos, sName )) + if (m_rDoc.GotoOutline(aPos, sName, nullptr)) { SwNode* pNd = &aPos.nNode.GetNode(); const int nLvl = pNd->GetTextNode()->GetAttrOutlineLevel()-1; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 28d5cd766aea..635dee7a9d0d 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -586,7 +586,8 @@ static SwTextNode* lcl_FindOutlineName( const SwOutlineNodes& rOutlNds, const OU return pSavedNode; } -static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& rName ) +static SwTextNode* lcl_FindOutlineNum(const SwOutlineNodes& rOutlNds, + OUString& rName, SwRootFrame const*const pLayout) { // Valid numbers are (always just offsets!): // ([Number]+\.)+ (as a regular expression!) @@ -647,9 +648,9 @@ static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& // #i51089#, #i68289# // Assure, that text node has the correct numbering level. Otherwise, // its number vector will not fit to the searched level. - if ( pNd->GetNum() && pNd->GetActualListLevel() == nLevel - 1 ) + if (pNd->GetNum(pLayout) && pNd->GetActualListLevel() == nLevel - 1) { - const SwNodeNum & rNdNum = *(pNd->GetNum()); + const SwNodeNum & rNdNum = *(pNd->GetNum(pLayout)); SwNumberTree::tNumberVector aLevelVal = rNdNum.GetNumberVector(); // now compare with the one searched for bool bEqual = true; @@ -680,17 +681,14 @@ static SwTextNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& return nullptr; } -// Add this bullet point: - -// A Name can contain a Number and/or the Text. - +// rName can contain a Number and/or the Text. // First, we try to find the correct Entry via the Number. -// If it exists, we compare the Text, to see if it's the right one. +// If it exists, we compare the Text to see if it's the right one. // If that's not the case, we search again via the Text. If it is // found, we got the right entry. Or else we use the one found by // searching for the Number. // If we don't have a Number, we search via the Text only. -bool SwDoc::GotoOutline( SwPosition& rPos, const OUString& rName ) const +bool SwDoc::GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const*const pLayout) const { if( !rName.isEmpty() ) { @@ -698,7 +696,7 @@ bool SwDoc::GotoOutline( SwPosition& rPos, const OUString& rName ) const // 1. step: via the Number: OUString sName( rName ); - SwTextNode* pNd = ::lcl_FindOutlineNum( rOutlNds, sName ); + SwTextNode* pNd = ::lcl_FindOutlineNum(rOutlNds, sName, pLayout); if ( pNd ) { OUString sExpandedText = pNd->GetExpandText(); |