diff options
author | Jim Raykowski <raykowj@gmail.com> | 2018-04-13 21:42:22 -0800 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-14 20:35:51 +0200 |
commit | f7d155e71dec5024f2d06dcf3697d1dcf505716a (patch) | |
tree | 979bd6ed35b243687b252731d59c61e567338da0 | |
parent | 9bb6ed114c1b23ecde1df02d954a3bb1abb17e49 (diff) |
tdf#115600 Display messages in Findbar for Table navigation
...and make Table navigation wrap
Change-Id: Iac645cb7db65517519cfb791ca1eb26f2567ee7c
Reviewed-on: https://gerrit.libreoffice.org/52865
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/svx/srchdlg.hxx | 3 | ||||
-rw-r--r-- | include/svx/strings.hrc | 1 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/trvltbl.cxx | 43 |
4 files changed, 44 insertions, 5 deletions
diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx index f655931008da..748ced9bdb58 100644 --- a/include/svx/srchdlg.hxx +++ b/include/svx/srchdlg.hxx @@ -88,7 +88,8 @@ enum class SearchLabel EndSheet, NotFound, StartWrapped, - EndWrapped + EndWrapped, + NavElementNotFound }; class SvxSearchDialog; diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 9593cf515623..c38e028bf76a 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1255,6 +1255,7 @@ #define RID_SVXSTR_SEARCH_END_WRAPPED NC_("RID_SVXSTR_SEARCH_END_WRAPPED", "Reached the end of the document, continued from the beginning") #define RID_SVXSTR_SEARCH_END_SHEET NC_("RID_SVXSTR_SEARCH_END_SHEET", "Reached the end of the sheet") #define RID_SVXSTR_SEARCH_NOT_FOUND NC_("RID_SVXSTR_SEARCH_NOT_FOUND", "Search key not found") +#define RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND NC_("RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND", "Navigation Element not found") #define RID_SVXSTR_SEARCH_START NC_("RID_SVXSTR_SEARCH_START", "Reached the beginning of the document") #define RID_SVXSTR_SEARCH_START_WRAPPED NC_("RID_SVXSTR_SEARCH_START_WRAPPED", "Reached the beginning of the document, continued from the end") diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 628d9c939e64..71f65c825506 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -2448,6 +2448,8 @@ void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL) sStr = SvxResId(RID_SVXSTR_SEARCH_END_SHEET); else if (rSL == SearchLabel::NotFound) sStr = SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND); + else if (rSL == SearchLabel::NavElementNotFound) + sStr = SvxResId(RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND); lcl_SetSearchLabelWindow(sStr); if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()-> diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 051dffe9be08..43a5f7e90be6 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -38,6 +38,7 @@ #include <cellfrm.hxx> #include <rowfrm.hxx> #include <IDocumentLayoutAccess.hxx> +#include <svx/srchdlg.hxx> /// set cursor into next/previous cell bool SwCursorShell::GoNextCell( bool bAppendLine ) @@ -480,6 +481,8 @@ static bool lcl_FindPrevCell( SwNodeIndex& rIdx, bool bInReadOnly ) bool GotoPrevTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable, bool bInReadOnly ) { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + SwNodeIndex aIdx( rCurrentCursor.GetPoint()->nNode ); SwTableNode* pTableNd = aIdx.GetNode().FindTableNode(); @@ -497,12 +500,27 @@ bool GotoPrevTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable aIdx.Assign( *pTableNd, - 1 ); } + SwNodeIndex aOldIdx = aIdx; + sal_uLong nLastNd = rCurrentCursor.GetDoc()->GetNodes().Count() - 1; do { while( aIdx.GetIndex() && nullptr == ( pTableNd = aIdx.GetNode().StartOfSectionNode()->GetTableNode()) ) + { --aIdx; + if ( aIdx == aOldIdx ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + } + + if ( !aIdx.GetIndex() ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped ); + aIdx = nLastNd; + continue; + } - if( pTableNd ) // any further table node? { if( &fnPosTable == &fnMoveForward ) // at the beginning? { @@ -535,7 +553,7 @@ bool GotoPrevTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable } return true; } - } while( pTableNd ); + } while( true ); return false; } @@ -543,18 +561,35 @@ bool GotoPrevTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable bool GotoNextTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable, bool bInReadOnly ) { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); + SwNodeIndex aIdx( rCurrentCursor.GetPoint()->nNode ); SwTableNode* pTableNd = aIdx.GetNode().FindTableNode(); if( pTableNd ) aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); + SwNodeIndex aOldIdx = aIdx; sal_uLong nLastNd = rCurrentCursor.GetDoc()->GetNodes().Count() - 1; do { while( aIdx.GetIndex() < nLastNd && nullptr == ( pTableNd = aIdx.GetNode().GetTableNode()) ) + { ++aIdx; - if( pTableNd ) // any further table node? + if ( aIdx == aOldIdx ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); + return false; + } + } + + if ( aIdx.GetIndex() == nLastNd ) + { + SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped ); + aIdx = 0; + continue; + } + { if( &fnPosTable == &fnMoveForward ) // at the beginning? { @@ -587,7 +622,7 @@ bool GotoNextTable( SwPaM& rCurrentCursor, SwMoveFnCollection const & fnPosTable } return true; } - } while( pTableNd ); + } while( true ); return false; } |