sw/source/core/crsr/trvlreg.cxx | 48 ++++++++++++++++++++++++++++++++++---- sw/source/uibase/wrtsh/wrtsh3.cxx | 37 +++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 6 deletions(-)
New commits: commit 7a30e0d63d37eeb7b5c1e30791de17a51ddd0652 Author: Jim Raykowski <rayk...@gmail.com> Date: Sat Apr 21 23:09:15 2018 -0800 tdf#115600 Display messages in FindBar for Section navigation ...and make Section navigation wrap Change-Id: I3af8ba9ac1b3177f5aaf54628976c14a63a1685e Reviewed-on: https://gerrit.libreoffice.org/53275 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/sw/source/core/crsr/trvlreg.cxx b/sw/source/core/crsr/trvlreg.cxx index d5255047cd26..ecec0f16ee85 100644 --- a/sw/source/core/crsr/trvlreg.cxx +++ b/sw/source/core/crsr/trvlreg.cxx @@ -26,21 +26,39 @@ #include "callnk.hxx" #include <pamtyp.hxx> #include <section.hxx> +#include <svx/srchdlg.hxx> bool GotoPrevRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegion, bool bInReadOnly ) { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); SwNodeIndex aIdx( rCurrentCursor.GetPoint()->nNode ); SwSectionNode* pNd = aIdx.GetNode().FindSectionNode(); if( pNd ) aIdx.Assign( *pNd, - 1 ); + SwNodeIndex aOldIdx = aIdx; + sal_uLong nLastNd = rCurrentCursor.GetDoc()->GetNodes().Count() - 1; do { while( aIdx.GetIndex() && nullptr == ( pNd = aIdx.GetNode().StartOfSectionNode()->GetSectionNode()) ) + { --aIdx; + if ( aIdx == aOldIdx ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + } - if( pNd ) // is there another section node? + if ( !aIdx.GetIndex() ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped ); + aIdx = nLastNd; + continue; + } + + assert( pNd ); // coverity, should never be nullptr { if( pNd->GetSection().IsHiddenFlag() || ( !bInReadOnly && @@ -48,6 +66,7 @@ bool GotoPrevRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi { // skip protected or hidden ones aIdx.Assign( *pNd, - 1 ); + continue; } else if( &fnPosRegion == &fnMoveForward ) { @@ -76,25 +95,43 @@ bool GotoPrevRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi rCurrentCursor.GetPoint()->nNode = aIdx; return true; } - } while( pNd ); + } while( true ); + + // the flow is such that it is not possible to get here return false; } bool GotoNextRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegion, bool bInReadOnly ) { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); SwNodeIndex aIdx( rCurrentCursor.GetPoint()->nNode ); SwSectionNode* pNd = aIdx.GetNode().FindSectionNode(); if( pNd ) aIdx.Assign( *pNd->EndOfSectionNode(), - 1 ); + SwNodeIndex aOldIdx = aIdx; sal_uLong nEndCount = aIdx.GetNode().GetNodes().Count()-1; do { while( aIdx.GetIndex() < nEndCount && nullptr == ( pNd = aIdx.GetNode().GetSectionNode()) ) + { ++aIdx; + if ( aIdx == aOldIdx ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + } - if( pNd ) // is there another section node? + if ( aIdx.GetIndex() == nEndCount ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped ); + aIdx = 0; + continue; + } + + assert( pNd ); // coverity, should never be nullptr { if( pNd->GetSection().IsHiddenFlag() || ( !bInReadOnly && @@ -102,6 +139,7 @@ bool GotoNextRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi { // skip protected or hidden ones aIdx.Assign( *pNd->EndOfSectionNode(), +1 ); + continue; } else if( &fnPosRegion == &fnMoveForward ) { @@ -130,7 +168,9 @@ bool GotoNextRegion( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosRegi rCurrentCursor.GetPoint()->nNode = aIdx; return true; } - } while( pNd ); + } while( true ); + + // the flow is such that it is not possible to get here return false; } commit 3659520e3324779b6bf7c0f5a5b3f3072e8a875a Author: Jim Raykowski <rayk...@gmail.com> Date: Sun Apr 22 23:58:22 2018 -0800 tdf#115600 Display messages in FindBar for Bookmark navigation ...and make Bookmark navigation wrap Change-Id: I3cba18e37c4887ad68d358c10ebb9c9ff592f6ad Reviewed-on: https://gerrit.libreoffice.org/53370 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx index 337e005470d6..7fcd2f56aaab 100644 --- a/sw/source/uibase/wrtsh/wrtsh3.cxx +++ b/sw/source/uibase/wrtsh/wrtsh3.cxx @@ -25,6 +25,7 @@ #include <svx/svdview.hxx> #include <svx/fmglob.hxx> #include <svx/svdouno.hxx> +#include <svx/srchdlg.hxx> #include <com/sun/star/form/FormButtonType.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <sfx2/htmlmode.hxx> @@ -140,12 +141,44 @@ void SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark ) bool SwWrtShell::GoNextBookmark() { - return MoveBookMark( BOOKMARK_NEXT ); + if ( !getIDocumentMarkAccess()->getBookmarksCount() ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + LockView( true ); + bool bRet = MoveBookMark( BOOKMARK_NEXT ); + if ( !bRet ) + { + MoveBookMark( BOOKMARK_INDEX, getIDocumentMarkAccess()->getBookmarksBegin()->get() ); + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped ); + } + else + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + LockView( false ); + ShowCursor(); + return true; } bool SwWrtShell::GoPrevBookmark() { - return MoveBookMark( BOOKMARK_PREV ); + if ( !getIDocumentMarkAccess()->getBookmarksCount() ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + LockView( true ); + bool bRet = MoveBookMark( BOOKMARK_PREV ); + if ( !bRet ) + { + MoveBookMark( BOOKMARK_INDEX, ( getIDocumentMarkAccess()->getBookmarksEnd() - 1 )->get() ); + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped ); + } + else + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + LockView( false ); + ShowCursor(); + return true; } void SwWrtShell::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits