sc/source/ui/app/scmod.cxx |   32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

New commits:
commit 010f734a55ad3b5f8b49fbddc60e7a755b2398d4
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Oct 19 11:09:32 2021 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Oct 22 11:17:32 2021 +0200

    lok: fix formula mode after reference dialog was used
    
    m_nCurRefDlgId is a global variable which can be used by many views.
    It should be deglobalized in LOK case in the furture.
    
    For now let's fallback when we didn't get child window for
    remembered value of m_nCurRefDlgId. It fixes following case:
    
    1. opened pivot table dialog and in destination section selected
       "selection", selected a range, closed dialog
    2. tried to type formula in the cell and point any cell to add
       reference
    
    before this patch formula mode was closed, after it adds correctly
    the selected range to the formula
    
    Change-Id: I4d6756f08207f78a6033865203905bc2fed59fb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123813
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>

diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index fe71ab45b6b3..599e6e9a99b3 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1563,6 +1563,14 @@ bool ScModule::IsModalMode(SfxObjectShell* pDocSh)
                     !( pRefDlg->IsRefInputMode() && 
pRefDlg->IsDocAllowed(pDocSh) );
             }
         }
+        else if ( pDocSh && comphelper::LibreOfficeKit::isActive() )
+        {
+            // m_nCurRefDlgId is not deglobalized so it can be set by other 
view
+            // in LOK case when no ChildWindow for this view was detected -> 
fallback
+            ScInputHandler* pHdl = GetInputHdl();
+            if ( pHdl )
+                bIsModal = pHdl->IsModalMode(pDocSh);
+        }
     }
     else if (pDocSh)
     {
@@ -1644,6 +1652,14 @@ bool ScModule::IsFormulaMode()
                 bIsFormula = pChildWnd->IsVisible() && pRefDlg && 
pRefDlg->IsRefInputMode();
             }
         }
+        else if ( comphelper::LibreOfficeKit::isActive() )
+        {
+            // m_nCurRefDlgId is not deglobalized so it can be set by other 
view
+            // in LOK case when no ChildWindow for this view was detected -> 
fallback
+            ScInputHandler* pHdl = GetInputHdl();
+            if ( pHdl )
+                bIsFormula = pHdl->IsFormulaMode();
+        }
     }
     else
     {
@@ -1679,7 +1695,13 @@ void ScModule::SetReference( const ScRange& rRef, 
ScDocument* pDoc,
 
     if( m_nCurRefDlgId )
     {
-        SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId 
);
+        SfxChildWindow* pChildWnd = nullptr;
+
+        if ( comphelper::LibreOfficeKit::isActive() )
+            pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId );
+        else
+            pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId );
+
         OSL_ENSURE( pChildWnd, "NoChildWin" );
         if ( pChildWnd )
         {
@@ -1705,6 +1727,14 @@ void ScModule::SetReference( const ScRange& rRef, 
ScDocument* pDoc,
                 }
             }
         }
+        else if ( comphelper::LibreOfficeKit::isActive() )
+        {
+            // m_nCurRefDlgId is not deglobalized so it can be set by other 
view
+            // in LOK case when no ChildWindow for this view was detected -> 
fallback
+            ScInputHandler* pHdl = GetInputHdl();
+            if (pHdl)
+                pHdl->SetReference( aNew, pDoc );
+        }
     }
     else
     {

Reply via email to