summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2018-04-21 23:09:15 -0800
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-04-26 16:16:10 +0200
commit7a30e0d63d37eeb7b5c1e30791de17a51ddd0652 (patch)
tree66a563115a57c31abcf6843f756035f2bb48a4c6
parent3659520e3324779b6bf7c0f5a5b3f3072e8a875a (diff)
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 <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--sw/source/core/crsr/trvlreg.cxx48
1 files changed, 44 insertions, 4 deletions
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;
}