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

New commits:
commit 673937056794da2fb96acb219d8c3dbf69a561a9
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: Wed Dec 29 10:40:31 2021 +0100

    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/+/123803
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127667
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index bbc711bee057..d2aae8fee013 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& rDoc,
 
     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& rDoc,
                 }
             }
         }
+        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, rDoc );
+        }
     }
     else
     {

Reply via email to