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 <raykowj@gmail.com>
(cherry picked from commit 5df0289f6af5aa7142017b56a8e17c134d54fe41)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130644
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 0e99426..265a400 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 8d986a6..d1c3ca2 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 != m_nMoveType)
        m_pEditWin->GrabFocus();
    delete pbNext;
}