desktop/source/lib/init.cxx         |    1 +
 sd/source/ui/unoidl/unomodel.cxx    |    2 ++
 sd/source/ui/view/ViewShellBase.cxx |   17 +++++++++++++++++
 3 files changed, 20 insertions(+)

New commits:
commit 95e9c210ef8380b0909c6ba596e3023bafef4083
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Nov 5 14:55:33 2024 +0000
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Nov 5 17:00:59 2024 +0100

    switching PageKind without switching EditMode retains current page
    
    i.e. ChangeEditMode doesn't do anything if the EditMode is unchanged
    but the PageKind was switched from Notes to Standard. So the same
    page of the other mode is still selected. An explicit SwitchPage
    is required to change the page from the other mode.
    
    This results in the reported mode of "2", but rendering actually still
    rendering as if in "mode 0", so a request to render a 'standard' page
    returns an image of the currently still-selected 'notes' page, which
    confusingly can be cached and not shown until served as a reply to a
    later request of the 'standard' page.
    
    See DrawViewShell::ReadFrameViewData and other places for more
    of this pattern.
    
    Change-Id: Ie8aa8f93f45189fd6f9c37c4077fa2b547ca4815
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176084
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Gökay ŞATIR <gokaysa...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 33c69a580a25..39c6ab4002ff 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4334,6 +4334,7 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis,
     // TODO: we could be clever and e.g. set to 0 when we change to/from
     // embedded object mode, and not when changing between slide/notes/combined
     // modes?
+    // TODO: Also now see ViewShellBase::setEditMode for a similar case
     if ( nCurrentPart < pDoc->getParts() )
     {
         pDoc->setPart( nCurrentPart );
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index f02b697dfccb..b38da6630023 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -3803,6 +3803,8 @@ void SdXImpressDocument::setPartMode( int nPartMode )
         break;
     }
     pViewSh->SetPageKind( aPageKind );
+    //TODO do the same as setEditMode and then can probably remove the TODOs
+    //from doc_setPartMode
 }
 
 int SdXImpressDocument::getEditMode()
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index f2ddb55b66d8..4dbf0f20653a 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -1024,6 +1024,10 @@ void ViewShellBase::setEditMode(int nMode)
 
     if (DrawViewShell* pDrawViewShell = 
dynamic_cast<DrawViewShell*>(pViewShell))
     {
+        EditMode eOrigEditMode = pDrawViewShell->GetEditMode();
+        PageKind eOrigPageKind = pDrawViewShell->GetPageKind();
+        sal_uInt16 nSelectedPage = pDrawViewShell->GetCurPagePos();
+
         switch ( nMode )
         {
         case 0:
@@ -1039,6 +1043,19 @@ void ViewShellBase::setEditMode(int nMode)
             pDrawViewShell->ChangeEditMode(EditMode::Page, false);
             break;
         }
+
+        /*
+           If the EditMode is unchanged, then ChangeEditMode was typically a
+           no-op, and an additional explicit SwitchPage is required to reselect
+           the equivalent page from the other mode, otherwise a switch from
+           e.g. Notes to Standard will still render the still selected Note
+           page.
+        */
+        if (eOrigEditMode == pDrawViewShell->GetEditMode() &&
+            eOrigPageKind != pDrawViewShell->GetPageKind())
+        {
+            pDrawViewShell->SwitchPage(nSelectedPage);
+        }
     }
 }
 

Reply via email to