sc/source/ui/drawfunc/graphsh.cxx |   40 ++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

New commits:
commit 5557e1c3ffd40862dd243fde53d67b10417032b1
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Feb 12 17:10:02 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Feb 13 16:38:47 2026 +0100

    make calc Compress Graphic dialog async
    
    Change-Id: I69d00fbe654113a0dc33f4c4359fd63b0630da3b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199306
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/source/ui/drawfunc/graphsh.cxx 
b/sc/source/ui/drawfunc/graphsh.cxx
index 71420be473b7..cfd06d481596 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -106,13 +106,13 @@ void ScGraphicShell::ExecuteFilter( const SfxRequest& 
rReq )
 
     if( rMarkList.GetMarkCount() == 1 )
     {
-        SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+        rtl::Reference<SdrObject> xObj = rMarkList.GetMark( 0 
)->GetMarkedSdrObj();
 
-        if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj) )
+        if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>(xObj.get()) )
             if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap )
             {
                 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, 
pGraphicObj->GetGraphicObject(),
-                    [pView, pGraphicObj, pObj, rMarkList] (GraphicObject 
aFilterObj) -> void
+                    [pView, pGraphicObj, xObj, rMarkList] (GraphicObject 
aFilterObj) -> void
                     {
                         if( SdrPageView* pPageView = pView->GetSdrPageView() )
                         {
@@ -120,7 +120,7 @@ void ScGraphicShell::ExecuteFilter( const SfxRequest& rReq )
                             OUString aStr = rMarkList.GetMarkDescription() + " 
" + ScResId(SCSTR_UNDO_GRAFFILTER);
                             pView->BegUndo( aStr );
                             pFilteredObj->SetGraphicObject( aFilterObj );
-                            pView->ReplaceObjectAtView( pObj, *pPageView, 
pFilteredObj.get() );
+                            pView->ReplaceObjectAtView( xObj.get(), 
*pPageView, pFilteredObj.get() );
                             pView->EndUndo();
                         }
                     });
@@ -198,25 +198,29 @@ void ScGraphicShell::ExecuteCompressGraphic( 
SAL_UNUSED_PARAMETER SfxRequest& )
 
     if( rMarkList.GetMarkCount() == 1 )
     {
-        SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+        rtl::Reference<SdrObject> xObj = rMarkList.GetMark( 0 
)->GetMarkedSdrObj();
 
-        if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj) )
+        if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>(xObj.get()) )
+        {
             if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap )
             {
-                CompressGraphicsDialog dialog(GetViewData().GetDialogParent(), 
pGraphicObj, GetViewData().GetBindings());
-                if (dialog.run() == RET_OK)
-                {
-                    rtl::Reference<SdrGrafObj> pNewObject = 
dialog.GetCompressedSdrGrafObj();
-                    SdrPageView* pPageView = pView->GetSdrPageView();
-                    OUString aUndoString = rMarkList.GetMarkDescription() + " 
Compress";
-                    pView->BegUndo( aUndoString );
-                    pView->ReplaceObjectAtView( pObj, *pPageView, 
pNewObject.get() );
-                    pView->EndUndo();
-                }
+                auto xDialog = 
std::make_shared<CompressGraphicsDialog>(GetViewData().GetDialogParent(), 
pGraphicObj, GetViewData().GetBindings());
+                OUString aUndoString = rMarkList.GetMarkDescription() + " 
Compress";
+                weld::DialogController::runAsync(xDialog, [this, pView, xObj, 
xDialog, aUndoString](sal_uInt32 nResult) {
+                    if (nResult == RET_OK)
+                    {
+                        rtl::Reference<SdrGrafObj> pNewObject = 
xDialog->GetCompressedSdrGrafObj();
+                        SdrPageView* pPageView = pView->GetSdrPageView();
+                        pView->BegUndo( aUndoString );
+                        pView->ReplaceObjectAtView( xObj.get(), *pPageView, 
pNewObject.get() );
+                        pView->EndUndo();
+
+                        Invalidate();
+                    }
+                });
             }
+        }
     }
-
-    Invalidate();
 }
 
 void ScGraphicShell::GetCropGraphicState( SfxItemSet& rSet )

Reply via email to