sw/source/uibase/uiview/viewmdi.cxx |   36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

New commits:
commit eb06eea67bb8955b0d71762bcf94eebf7adb7419
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sun Dec 27 12:26:20 2020 -0900
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Wed Jan 20 03:11:41 2021 +0100

    Don't move to postit if not visible
    
    Rework navigation move handler postit move to do correct wrap movement
    when positits at the begining and ending of the document are not
    visible.
    
    Change-Id: Ie246462d23c8f1e2e06929933f4d71197c2bde83
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108390
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/uiview/viewmdi.cxx 
b/sw/source/uibase/uiview/viewmdi.cxx
index 541a0ba210c3..69bd97623606 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -502,25 +502,43 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
 
         case NID_POSTIT:
         {
-            if ( m_pPostItMgr->HasNotes() )
+            if (m_pPostItMgr->HasNotes())
             {
                 rSh.EnterStdMode();
-                sw::annotation::SwAnnotationWin* pPostIt = 
GetPostItMgr()->GetActiveSidebarWin();
+                sw::annotation::SwAnnotationWin* pPostIt = 
m_pPostItMgr->GetActiveSidebarWin();
                 if (pPostIt)
-                    GetPostItMgr()->SetActiveSidebarWin(nullptr);
+                    m_pPostItMgr->SetActiveSidebarWin(nullptr);
                 SwFieldType* pFieldType = rSh.GetFieldType(0, 
SwFieldIds::Postit);
-                if ( !rSh.MoveFieldType( pFieldType, bNext ) )
+                rSh.StartAction();
+                if (!rSh.MoveFieldType(pFieldType, bNext))
                 {
-                    bNext ? (*(m_pPostItMgr->begin()))->mpPostIt->GotoPos() :
-                        (*(m_pPostItMgr->end()-1))->mpPostIt->GotoPos();
-                    SvxSearchDialogWrapper::SetSearchLabel( bNext ? 
SearchLabel::EndWrapped : SearchLabel::StartWrapped );
+                    // 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))
+                    {
+                        GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+                        SvxSearchDialogWrapper::SetSearchLabel(bNext ? 
SearchLabel::EndWrapped :
+                                                                       
SearchLabel::StartWrapped);
+                    }
+                    else
+                    {
+                        // no visible postits
+                        pCursor->RestoreSavePos();
+                        
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
+                    }
                 }
                 else
+                {
+                    GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
                     SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty 
);
-                GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+                }
+                rSh.EndAction();
             }
             else
-                SvxSearchDialogWrapper::SetSearchLabel( 
SearchLabel::NavElementNotFound );
+                
SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::NavElementNotFound);
         }
         break;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to