sw/sdi/swriter.sdi                  |    1 
 sw/source/uibase/uiview/viewmdi.cxx |   57 +++++++++++++++++++++---------------
 2 files changed, 34 insertions(+), 24 deletions(-)

New commits:
commit 5df0289f6af5aa7142017b56a8e17c134d54fe41
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Fri Feb 25 00:31:29 2022 -0900
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sun Feb 27 05:08:38 2022 +0100

    tdf#147565 Make navigate by comments skip hidden comments
    
    Change-Id: I80f55146529505e5b6146db8cc324971fbc475e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130518
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 0e994261c28c..265a4000c5a0 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -2494,7 +2494,6 @@ SfxVoidItem InsertAnnotation FN_POSTIT
     Container = FALSE,
     RecordAbsolute = FALSE,
     RecordPerSet;
-    Asynchron;
 
     AccelConfig = TRUE,
     MenuConfig = TRUE,
diff --git a/sw/source/uibase/uiview/viewmdi.cxx 
b/sw/source/uibase/uiview/viewmdi.cxx
index b85c05eb1af8..9acb7f8f7bd0 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -530,38 +530,48 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
         {
             if (m_pPostItMgr->HasNotes())
             {
-                rSh.EnterStdMode();
-                sw::annotation::SwAnnotationWin* pPostIt = 
m_pPostItMgr->GetActiveSidebarWin();
-                if (pPostIt)
-                    m_pPostItMgr->SetActiveSidebarWin(nullptr);
+                m_pPostItMgr->AssureStdModeAtShell();
+                m_pPostItMgr->SetActiveSidebarWin(nullptr);
+                GetEditWin().GrabFocus();
+                SwShellCursor* pCursor = rSh.GetCursor_();
+                SwCursorSaveState aSaveState(*pCursor);
                 SwFieldType* pFieldType = rSh.GetFieldType(0, 
SwFieldIds::Postit);
+                bool bWrapped = false;
+                bool bFound = false;
                 rSh.StartAction();
-                if (!rSh.MoveFieldType(pFieldType, bNext))
+                while (!bFound)
                 {
-                    // no postits found in the move direction
-                    // wrap and try again
-                    SwShellCursor* pCursor = rSh.GetCursor_();
-                    SwCursorSaveState aSaveState(*pCursor);
-                    rSh.SttEndDoc(bNext);
-                    if (rSh.MoveFieldType(pFieldType, bNext))
+                    if (!rSh.MoveFieldType(pFieldType, bNext))
                     {
-                        GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
-                        SvxSearchDialogWrapper::SetSearchLabel(bNext ? 
SearchLabel::EndWrapped :
-                                                                       
SearchLabel::StartWrapped);
+                        if (bWrapped)
+                            break;
+                        bWrapped = true;
+                        rSh.SttEndDoc(bNext);
+                        continue;
                     }
-                    else
+                    do
                     {
-                        // no visible postits
-                        pCursor->RestoreSavePos();
-                        
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
-                    }
+                        auto pAnnotationWin = m_pPostItMgr->GetAnnotationWin(
+                                    rSh.GetPostItFieldAtCursor());
+                        if (pAnnotationWin && pAnnotationWin->IsVisible())
+                            bFound = true;
+                    } while (!bFound && rSh.MoveFieldType(pFieldType, bNext));
                 }
-                else
+                if (!bFound)
                 {
-                    GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
-                    SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty 
);
+                    pCursor->RestoreSavePos();
+                    
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
                 }
                 rSh.EndAction();
+                if (bFound)
+                {
+                    GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+                    if (bWrapped)
+                        SvxSearchDialogWrapper::SetSearchLabel(bNext ? 
SearchLabel::EndWrapped :
+                                                                       
SearchLabel::StartWrapped);
+                    else
+                        
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty);
+                }
             }
             else
                 
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
@@ -597,7 +607,8 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
             bNext ? rSh.GetNavigationMgr().goForward() : 
rSh.GetNavigationMgr().goBack();
             break;
     }
-    m_pEditWin->GrabFocus();
+    if (NID_POSTIT != s_nMoveType)
+        m_pEditWin->GrabFocus();
     delete pbNext;
 }
 

Reply via email to