chart2/source/controller/main/ChartController_Window.cxx |    4 
 sc/source/ui/app/inputhdl.cxx                            |    5 
 sc/source/ui/view/cellsh1.cxx                            |  151 ++++++++-------
 3 files changed, 91 insertions(+), 69 deletions(-)

New commits:
commit 4b33e878a446b0bcdb1d5f882a05a256967eea54
Author:     codewithvk <vivek.jav...@collabora.com>
AuthorDate: Sun Dec 10 23:30:47 2023 +0530
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Jan 10 10:49:23 2024 +0100

    Make format condition, chart delete and pivot table error async
    
    todo:
    Make executeDlg_ObjectProperties_withoutUndoGuard dialogs to async.
    
    Signed-off-by: codewithvk <vivek.jav...@collabora.com>
    Change-Id: I9927c1008d34370b9394aaf653afb575f69f2d45
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160557
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161703
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index 1bdb1f2ed48a..1b2b3654c201 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1602,10 +1602,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& 
rKEvt )
         bReturn = executeDispatch_Delete();
         if( ! bReturn )
         {
-            std::unique_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(),
+            std::shared_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(),
                                                           
VclMessageType::Info, VclButtonsType::Ok,
                                                           
SchResId(STR_ACTION_NOTPOSSIBLE)));
-            xInfoBox->run();
+            xInfoBox->runAsync(xInfoBox, [] (int) {});
         }
     }
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 35e4eec23ebc..4907b6b50c05 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -170,6 +170,49 @@ void SetTabNoAndCursor( const ScViewData& rViewData, 
std::u16string_view rCellId
     }
 }
 
+void HandleConditionalFormat(sal_uInt32 nIndex, bool bCondFormatDlg, bool 
bContainsCondFormat,
+                             const sal_uInt16 nSlot, SfxViewShell* 
pTabViewShell)
+{
+    condformat::dialog::ScCondFormatDialogType eType = 
condformat::dialog::NONE;
+    switch (nSlot)
+    {
+        case SID_OPENDLG_CONDFRMT:
+        case SID_OPENDLG_CURRENTCONDFRMT:
+            eType = condformat::dialog::CONDITION;
+            break;
+        case SID_OPENDLG_COLORSCALE:
+            eType = condformat::dialog::COLORSCALE;
+            break;
+        case SID_OPENDLG_DATABAR:
+            eType = condformat::dialog::DATABAR;
+            break;
+        case SID_OPENDLG_ICONSET:
+            eType = condformat::dialog::ICONSET;
+            break;
+        case SID_OPENDLG_CONDDATE:
+            eType = condformat::dialog::DATE;
+            break;
+        default:
+            assert(false);
+            break;
+    }
+
+    if (bCondFormatDlg || !bContainsCondFormat)
+    {
+        // Put the xml string parameter to initialize the
+        // Conditional Format Dialog.
+        ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false); // Change here
+        aDlgItem.SetDialogType(eType);
+        pTabViewShell->GetPool().DirectPutItemInPool(aDlgItem);
+
+        sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
+        SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
+        SfxChildWindow* pWnd = rViewFrm.GetChildWindow(nId);
+
+        SC_MOD()->SetRefDialog(nId, pWnd == nullptr);
+    }
+}
+
 void InsertCells(ScTabViewShell* pTabViewShell, SfxRequest &rReq, InsCellCmd 
eCmd)
 {
     if (eCmd!=INS_NONE)
@@ -2156,7 +2199,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 }
 
                 // try to find an existing conditional format
-                const ScConditionalFormat* pCondFormat = nullptr;
                 const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), 
aPos.Row(), aPos.Tab());
                 ScConditionalFormatList* pList = 
rDoc.GetCondFormList(aPos.Tab());
                 const ScCondFormatIndexes& rCondFormats = 
pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
@@ -2168,7 +2210,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     for (const auto& rCondFormat : rCondFormats)
                     {
                         // check if at least one existing conditional format 
has the same range
-                        pCondFormat = pList->GetFormat(rCondFormat);
+                        const ScConditionalFormat* pCondFormat = 
pList->GetFormat(rCondFormat);
                         if(!pCondFormat)
                             continue;
 
@@ -2345,78 +2387,57 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 // or should create a new overlapping conditional format
                 if(bContainsCondFormat && !bCondFormatDlg && 
bContainsExistingCondFormat)
                 {
-                    std::unique_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+                    std::shared_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
                                                                    
VclMessageType::Question, VclButtonsType::YesNo,
                                                                    
ScResId(STR_EDIT_EXISTING_COND_FORMATS), pTabViewShell));
                     xQueryBox->set_default_response(RET_YES);
-                    bool bEditExisting = xQueryBox->run() == RET_YES;
-                    if (bEditExisting)
-                    {
-                        // differentiate between ranges where one conditional 
format is defined
-                        // and several formats are defined
-                        // if we have only one => open the cond format dlg to 
edit it
-                        // otherwise open the manage cond format dlg
-                        if (rCondFormats.size() == 1)
+                    xQueryBox->runAsync(xQueryBox, [this, nIndex, nSlot, aPos, 
pTabViewShell] (int nResult) {
+                        sal_uInt32 nNewIndex = nIndex;
+                        bool bNewCondFormatDlg = false;
+
+                        // use fresh data
+                        ScDocument& rInnerDoc = GetViewData().GetDocument();
+                        const ScPatternAttr* pInnerPattern = 
rInnerDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
+                        ScConditionalFormatList* pInnerList = 
rInnerDoc.GetCondFormList(aPos.Tab());
+                        const ScCondFormatIndexes& rInnerCondFormats = 
pInnerPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
+                        bool bInnerContainsCondFormat = 
!rInnerCondFormats.empty();
+
+                        bool bEditExisting = nResult == RET_YES;
+                        if (bEditExisting)
                         {
-                            pCondFormat = pList->GetFormat(rCondFormats[0]);
-                            assert(pCondFormat);
-                            nIndex = pCondFormat->GetKey();
-                            bCondFormatDlg = true;
+                            // differentiate between ranges where one 
conditional format is defined
+                            // and several formats are defined
+                            // if we have only one => open the cond format dlg 
to edit it
+                            // otherwise open the manage cond format dlg
+                            if (rInnerCondFormats.size() == 1)
+                            {
+                                const ScConditionalFormat* pCondFormat = 
pInnerList->GetFormat(rInnerCondFormats[0]);
+                                assert(pCondFormat);
+                                nNewIndex = pCondFormat->GetKey();
+                                bNewCondFormatDlg = true;
+                            }
+                            else
+                            {
+                                // Queue message to open Conditional Format 
Manager Dialog.
+                                GetViewData().GetDispatcher().Execute(
+                                    SID_OPENDLG_CONDFRMT_MANAGER, 
SfxCallMode::ASYNCHRON);
+                                return;
+                            }
                         }
                         else
                         {
-                            // Queue message to open Conditional Format 
Manager Dialog.
-                            GetViewData().GetDispatcher().Execute( 
SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON );
-                            break;
+                            // define an overlapping conditional format
+                            
assert(pInnerList->GetFormat(rInnerCondFormats[0]));
+                            bNewCondFormatDlg = true;
                         }
-                    }
-                    else
-                    {
-                        // define an overlapping conditional format
-                        pCondFormat = pList->GetFormat(rCondFormats[0]);
-                        assert(pCondFormat);
-                        bCondFormatDlg = true;
-                    }
-                }
 
-                condformat::dialog::ScCondFormatDialogType eType = 
condformat::dialog::NONE;
-                switch(nSlot)
-                {
-                    case SID_OPENDLG_CONDFRMT:
-                    case SID_OPENDLG_CURRENTCONDFRMT:
-                        eType = condformat::dialog::CONDITION;
-                        break;
-                    case SID_OPENDLG_COLORSCALE:
-                        eType = condformat::dialog::COLORSCALE;
-                        break;
-                    case SID_OPENDLG_DATABAR:
-                        eType = condformat::dialog::DATABAR;
-                        break;
-                    case SID_OPENDLG_ICONSET:
-                        eType = condformat::dialog::ICONSET;
-                        break;
-                    case SID_OPENDLG_CONDDATE:
-                        eType = condformat::dialog::DATE;
-                        break;
-                    default:
-                        assert(false);
-                        break;
+                        HandleConditionalFormat(nNewIndex, bNewCondFormatDlg, 
bInnerContainsCondFormat,
+                            nSlot, pTabViewShell);
+                    });
                 }
-
-
-                if(bCondFormatDlg || !bContainsCondFormat)
+                else
                 {
-                    // Put the xml string parameter to initialize the
-                    // Conditional Format Dialog.
-                    ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
-                    aDlgItem.SetDialogType(eType);
-                    pTabViewShell->GetPool().DirectPutItemInPool(aDlgItem);
-
-                    sal_uInt16      nId      = 
ScCondFormatDlgWrapper::GetChildWindowId();
-                    SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
-                    SfxChildWindow* pWnd     = rViewFrm.GetChildWindow( nId );
-
-                    pScMod->SetRefDialog( nId, pWnd == nullptr );
+                    HandleConditionalFormat(nIndex, bCondFormatDlg, 
bContainsCondFormat, nSlot, pTabViewShell);
                 }
             }
             break;
@@ -3275,10 +3296,10 @@ void ErrorOrRunPivotLayoutDialog(TranslateId 
pSrcErrorId,
     if (pSrcErrorId)
     {
         // Error occurred during data creation.  Launch an error and bail out.
-        std::unique_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+        std::shared_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
                                                     VclMessageType::Info, 
VclButtonsType::Ok,
                                                     ScResId(pSrcErrorId)));
-        xInfoBox->run();
+        xInfoBox->runAsync(xInfoBox, [] (int) {});
         return;
     }
 
commit e80842b37ed8b3e76dce68719ac0dfbeaefd567c
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Jan 10 08:45:18 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Jan 10 10:49:11 2024 +0100

    cid#1583748 Dereference after null check
    
    since:
    
    commit 20502992b862e5a83140b6d2b19722cdc652eeab
    Date:   Mon Dec 4 14:08:09 2023 +0000
    
        calc: Add option to keep edit mode on enter/tab
    
    Change-Id: Ic338602945fb77cebf771fe3d0ad2e4e94fc0318
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161874
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 0074d9439bad..f6dc87260605 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3814,9 +3814,10 @@ bool ScInputHandler::KeyInput( const KeyEvent& rKEvt, 
bool bStartEdit /* = false
 
         ScModule* pScMod = SC_MOD();
         const ScInputOptions& rOpt = pScMod->GetInputOptions();
+        const bool bKit = comphelper::LibreOfficeKit::isActive();
 
-        if ( (rOpt.GetMoveKeepEdit() && 
!comphelper::LibreOfficeKit::isActive())
-             || (pActiveViewSh->GetMoveKeepEdit() && 
comphelper::LibreOfficeKit::isActive()) )
+        if ( (rOpt.GetMoveKeepEdit() && !bKit)
+             || (pActiveViewSh && pActiveViewSh->GetMoveKeepEdit() && bKit) )
             pScMod->SetInputMode( SC_INPUT_TABLE );
 
         return true;

Reply via email to