sc/source/ui/inc/tabvwsh.hxx   |    4 ++
 sc/source/ui/view/tabvwsha.cxx |   75 +++++++++++++++++++++++++++--------------
 2 files changed, 55 insertions(+), 24 deletions(-)

New commits:
commit 491a0a302adafb0c44a943e217c86d81dff73a22
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Feb 9 14:36:34 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Feb 28 19:37:40 2026 +0100

    make new style by example async
    
    Change-Id: I9b82bc24b53cd558a8bfe5fa2c1deaac010ca21c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199002
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200117
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200305
    Tested-by: Jenkins

diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 7cd938523e3f..4024ef519f7a 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -1050,6 +1050,13 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
         case SID_STYLE_SHOW:
         case SID_STYLE_NEW_BY_EXAMPLE:
             {
+                auto lambda = [pStylePool, nSlotId, xOldData, xNewData, 
eFamily, this](SfxRequest& rRequest, const OUString& rStyleName)
+                {
+                    SfxStyleSheetBase* pApplyStyleSheet = 
pStylePool->Find(rStyleName, eFamily);
+                    xOldData->InitFromStyle(pApplyStyleSheet);
+                    ExecuteApplyStyle(rRequest, pStylePool, pApplyStyleSheet, 
nSlotId, rStyleName, xOldData, xNewData, eFamily);
+                };
+
                 const SfxPoolItem* pNameItem;
                 if (pArgs && SfxItemState::SET == pArgs->GetItemState(nSlotId, 
true, &pNameItem))
                     aStyleName = static_cast<const 
SfxStringItem*>(pNameItem)->GetValue();
@@ -1058,15 +1065,21 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                     weld::Window* pDialogParent = rReq.GetFrameWeld();
                     if (!pDialogParent)
                         pDialogParent = GetFrameWeld();
+
                     SfxNewStyleDlg aDlg(pDialogParent, *pStylePool, eFamily);
-                    if (aDlg.run() != RET_OK)
-                        return;
-                    aStyleName = aDlg.GetName();
+                    auto xDlg = 
std::make_shared<SfxNewStyleDlg>(pDialogParent, *pStylePool, eFamily);
+                    auto xRequest = std::make_shared<SfxRequest>(rReq);
+                    rReq.Ignore();
+                    weld::GenericDialogController::runAsync(xDlg,[xDlg, 
xRequest, lambda](sal_Int32 nResult){
+                        if (nResult == RET_OK) {
+                            lambda(*xRequest, xDlg->GetName());
+                        }
+                    });
+                    return;
                 }
 
-                pStyleSheet = pStylePool->Find( aStyleName, eFamily );
-
-                xOldData->InitFromStyle( pStyleSheet );
+                lambda(rReq, aStyleName);
+                return;
             }
             break;
 
commit 6847a878bf36713f458d99c5436a18e5a86b264f
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Feb 9 14:20:38 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Feb 28 19:37:25 2026 +0100

    split ScTabViewShell::ExecStyle
    
    to form a ScTabViewShell::ExecuteApplyStyle
    
    Change-Id: Idd7d71c415c8f315e8fcff7359bd2444c05258bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199001
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200118
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200681

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 92c81efdc3e3..3421ba23b5b1 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -502,6 +502,10 @@ private:
     void ExecuteSetTableBackgroundCol( SfxRequest& rReq );
     void ExecuteTableBackgroundDialog( const VclPtr<AbstractScTabBgColorDlg>& 
pDlg, const std::shared_ptr<SfxRequest>& xReq, Color aOldTabBgColor, sal_uInt16 
nSlot );
     bool DoTableBackgroundDialog( sal_Int32 nResult, const 
VclPtr<AbstractScTabBgColorDlg>& pDlg, const std::shared_ptr<SfxRequest>& xReq, 
Color aOldTabBgColor, sal_uInt16 nSlot );
+    void ExecuteApplyStyle(SfxRequest& rReq, SfxStyleSheetBasePool* 
pStylePool, SfxStyleSheetBase* pStyleSheet,
+                           sal_uInt16 nSlotId, const OUString& aStyleName,
+                           const std::shared_ptr<ScStyleSaveData>& rOldData,
+                           const std::shared_ptr<ScStyleSaveData>& rNewData, 
SfxStyleFamily eFamily);
     void ExecuteStyleEdit(SfxRequest& rReq, SfxStyleSheetBase* pStyleSheet, 
sal_uInt16 nRetMask, sal_uInt16 nSlotId,
                             bool bAddUndo, bool bUndo,
                             const std::shared_ptr<ScStyleSaveData>& rOldData,
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index d32d5433b7fc..7cd938523e3f 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -969,24 +969,14 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
         return;
     }
 
-    SfxBindings&        rBindings   = GetViewData().GetBindings();
-    const SCTAB         nCurTab     = GetViewData().CurrentTabForData();
     ScDocShell*         pDocSh      = GetViewData().GetDocShell();
     ScDocument&         rDoc        = pDocSh->GetDocument();
-    ScMarkData&         rMark       = GetViewData().GetMarkData();
     ScModule*           pScMod      = ScModule::get();
-    SdrObject*          pEditObject = GetDrawView()->GetTextEditObject();
-    OutlinerView*       pOLV        = GetDrawView()->GetTextEditOutlinerView();
-    ESelection          aSelection  = pOLV ? pOLV->GetSelection() : 
ESelection();
     OUString            aRefName;
-    bool                bUndo       = rDoc.IsUndoEnabled();
 
     SfxStyleSheetBasePool*  pStylePool  = rDoc.GetStyleSheetPool();
     SfxStyleSheetBase*      pStyleSheet = nullptr;
 
-    bool bStyleToMarked = false;
-    bool bListAction = false;
-    bool bAddUndo = false;          // add ScUndoModifyStyle (style modified)
     auto xOldData = std::make_shared<ScStyleSaveData>();       // for undo/redo
     auto xNewData = std::make_shared<ScStyleSaveData>();
 
@@ -1007,7 +997,6 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
     }
 
     OUString                aStyleName;
-    sal_uInt16              nRetMask = 0xffff;
 
     switch ( nSlotId )
     {
@@ -1126,6 +1115,31 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
             break;
     }
 
+    ExecuteApplyStyle(rReq, pStylePool, pStyleSheet, nSlotId, aStyleName, 
xOldData, xNewData, eFamily);
+}
+
+void ScTabViewShell::ExecuteApplyStyle(SfxRequest& rReq, 
SfxStyleSheetBasePool* pStylePool, SfxStyleSheetBase* pStyleSheet,
+                                       sal_uInt16 nSlotId, const OUString& 
aStyleName,
+                                       const std::shared_ptr<ScStyleSaveData>& 
rOldData,
+                                       const std::shared_ptr<ScStyleSaveData>& 
rNewData, SfxStyleFamily eFamily)
+{
+    SfxBindings&        rBindings   = GetViewData().GetBindings();
+    const SCTAB         nCurTab     = GetViewData().CurrentTabForData();
+    ScDocShell*         pDocSh      = GetViewData().GetDocShell();
+    ScDocument&         rDoc        = pDocSh->GetDocument();
+    ScMarkData&         rMark       = GetViewData().GetMarkData();
+    ScModule*           pScMod      = ScModule::get();
+    SdrObject*          pEditObject = GetDrawView()->GetTextEditObject();
+    OutlinerView*       pOLV        = GetDrawView()->GetTextEditOutlinerView();
+    ESelection          aSelection  = pOLV ? pOLV->GetSelection() : 
ESelection();
+    bool                bUndo       = rDoc.IsUndoEnabled();
+
+    bool bStyleToMarked = false;
+    bool bListAction = false;
+    bool bAddUndo = false;          // add ScUndoModifyStyle (style modified)
+
+    sal_uInt16 nRetMask = 0xffff;
+
     // set new style for paintbrush format mode
     if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
         static_cast<ScStyleSheetPool*>(pStylePool)->SetActualStyleSheet( 
pStyleSheet );
@@ -1261,7 +1275,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
 
                         if ( pStyleSheet )
                         {
-                            xOldData->InitFromStyle( pStyleSheet );
+                            rOldData->InitFromStyle( pStyleSheet );
 
                             if ( bUndo )
                             {
@@ -1279,7 +1293,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                         }
                     }
 
-                    xNewData->InitFromStyle( pStyleSheet );
+                    rNewData->InitFromStyle( pStyleSheet );
                     bAddUndo = true;
                     rReq.Done();
                 }
@@ -1390,7 +1404,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                         if ( bUsed )
                             ScPrintFunc( *pDocSh, GetPrinter(true), nInTab 
).UpdatePages();
 
-                        xNewData->InitFromStyle( pStyleSheet );
+                        rNewData->InitFromStyle( pStyleSheet );
                         bAddUndo = true;
                         rReq.Done();
                         nRetMask = sal_uInt16(true);
@@ -1467,7 +1481,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                     else
                     {
                         pStyleSheet = GetDrawView()->GetStyleSheet();
-                        xOldData->InitFromStyle( pStyleSheet );
+                        rOldData->InitFromStyle( pStyleSheet );
                     }
 
                     if ( bUndo )
@@ -1484,7 +1498,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                     pStyleSet->Put(aCoreSet);
                     
static_cast<SfxStyleSheet*>(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged));
 
-                    xNewData->InitFromStyle( pStyleSheet );
+                    rNewData->InitFromStyle( pStyleSheet );
                     bAddUndo = true;
 
                     //  call SetStyleSheet after adding the ScUndoModifyStyle
@@ -1508,13 +1522,13 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
         if (pStyleSheet)
         {
             ExecuteStyleEdit(rReq, pStyleSheet, nRetMask, nSlotId, bAddUndo, 
bUndo,
-                    xOldData, xNewData, eFamily, bStyleToMarked, bListAction, 
pEditObject, aSelection);
+                    rOldData, rNewData, eFamily, bStyleToMarked, bListAction, 
pEditObject, aSelection);
             return; // skip calling ExecuteStyleEditPost because we invoked an 
async dialog
         }
     }
 
     ExecuteStyleEditPost(rReq, pStyleSheet, nSlotId, nRetMask, bAddUndo, bUndo,
-            eFamily, *xOldData, *xNewData, bStyleToMarked, bListAction, 
pEditObject, aSelection);
+            eFamily, *rOldData, *rNewData, bStyleToMarked, bListAction, 
pEditObject, aSelection);
 }
 
 void ScTabViewShell::ExecuteStyleEdit(SfxRequest& rReq, SfxStyleSheetBase* 
pStyleSheet, sal_uInt16 nRetMask,

Reply via email to