diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-01-22 14:39:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-01-22 19:48:44 +0100 |
commit | 0edec422600cce2b042d5414443ad25ab515f351 (patch) | |
tree | a309ad8e9b77ca9eb1720e36c90fa5a082b563d0 | |
parent | dde1868544bf325a359bdf4336623ac65e6ff4e0 (diff) |
make object name dialog async
Change-Id: Icf81810297dc5767cedd051cf8ccdfbb101f35ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162395
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | chart2/source/controller/main/ShapeController.cxx | 23 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 2 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh5.cxx | 82 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwbassh.cxx | 33 | ||||
-rw-r--r-- | sw/source/uibase/shells/frmsh.cxx | 14 |
7 files changed, 105 insertions, 80 deletions
diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index 68483225b3bc..fe09d3e9af61 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -433,20 +433,25 @@ void ShapeController::executeDispatch_RenameObject() if ( !pSelectedObj ) return; - OUString aName = pSelectedObj->GetName(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - ScopedVclPtr< AbstractSvxObjectNameDialog > pDlg( - pFact->CreateSvxObjectNameDialog(pChartWindow, aName)); + VclPtr< AbstractSvxObjectNameDialog > pDlg( + pFact->CreateSvxObjectNameDialog(pChartWindow, pSelectedObj->GetName())); pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) ); - if ( pDlg->Execute() == RET_OK ) - { - aName = pDlg->GetName(); - if (pSelectedObj->GetName() != aName) + pDlg->StartExecuteAsync( + [pDlg, pSelectedObj] (sal_Int32 nResult)->void { - pSelectedObj->SetName( aName ); + if (nResult == RET_OK) + { + OUString aName = pDlg->GetName(); + if (pSelectedObj->GetName() != aName) + { + pSelectedObj->SetName( aName ); + } + } + pDlg->disposeOnce(); } - } + ); } void ShapeController::executeDispatch_ChangeZOrder( ChartCommandID nId ) diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 88da040aab34..dc61688e175e 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -121,7 +121,7 @@ IMPL_ABSTDLG_CLASS(AbstractSvxJSearchOptionsDialog) IMPL_ABSTDLG_CLASS(AbstractSvxMultiPathDialog) IMPL_ABSTDLG_CLASS(AbstractSvxNameDialog) IMPL_ABSTDLG_CLASS(AbstractSvxNewDictionaryDialog) -IMPL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog, SvxObjectNameDialog) IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectTitleDescDialog, SvxObjectTitleDescDialog) IMPL_ABSTDLG_CLASS(AbstractSvxPathSelectDialog) IMPL_ABSTDLG_CLASS(AbstractSvxPostItDialog) diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index c0cf846fb3f9..cb671b40bdf3 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -284,7 +284,7 @@ class SvxObjectNameDialog; class SvxObjectTitleDescDialog; // AbstractSvxObjectNameDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog,SvxObjectNameDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog,SvxObjectNameDialog) virtual OUString GetName() override; virtual void SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink) override; diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 2c0a1cf1f66d..896e7e42c783 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -509,58 +509,64 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) if(SC_LAYER_INTERN != pSelected->GetLayer()) { - OUString aName = pSelected->GetName(); + OUString aOldName = pSelected->GetName(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); vcl::Window* pWin = rViewData.GetActiveWin(); - ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aName)); + VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aOldName)); pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl)); - if(RET_OK == pDlg->Execute()) - { - ScDocShell* pDocSh = rViewData.GetDocShell(); - aName = pDlg->GetName(); - - if (aName != pSelected->GetName()) + pDlg->StartExecuteAsync( + [this, pDlg, pSelected] (sal_Int32 nResult)->void { - // handle name change - const SdrObjKind nObjType(pSelected->GetObjIdentifier()); - - if (SdrObjKind::Graphic == nObjType && aName.isEmpty()) + if (nResult == RET_OK) { - // graphics objects must have names - // (all graphics are supposed to be in the navigator) - ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer(); + ScDocShell* pDocSh = rViewData.GetDocShell(); + OUString aNewName = pDlg->GetName(); - if(pModel) + if (aNewName != pSelected->GetName()) { - aName = pModel->GetNewGraphicName(); + // handle name change + const SdrObjKind nObjType(pSelected->GetObjIdentifier()); + + if (SdrObjKind::Graphic == nObjType && aNewName.isEmpty()) + { + // graphics objects must have names + // (all graphics are supposed to be in the navigator) + ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer(); + + if(pModel) + { + aNewName = pModel->GetNewGraphicName(); + } + } + + // An undo action for renaming is missing in svdraw (99363). + // For OLE objects (which can be identified using the persist name), + // ScUndoRenameObject can be used until there is a common action for all objects. + if(SdrObjKind::OLE2 == nObjType) + { + const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName(); + + if(!aPersistName.isEmpty()) + { + pDocSh->GetUndoManager()->AddUndoAction( + std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aNewName)); + } + } + + // set new name + pSelected->SetName(aNewName); } - } - - // An undo action for renaming is missing in svdraw (99363). - // For OLE objects (which can be identified using the persist name), - // ScUndoRenameObject can be used until there is a common action for all objects. - if(SdrObjKind::OLE2 == nObjType) - { - const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName(); - if(!aPersistName.isEmpty()) - { - pDocSh->GetUndoManager()->AddUndoAction( - std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aName)); - } + // ChartListenerCollectionNeedsUpdate is needed for Navigator update + pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true ); + pDocSh->SetDrawModified(); } - - // set new name - pSelected->SetName(aName); + pDlg->disposeOnce(); } - - // ChartListenerCollectionNeedsUpdate is needed for Navigator update - pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true ); - pDocSh->SetDrawModified(); - } + ); } } break; diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 3237f808a601..8dbb3142e4c3 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2665,24 +2665,29 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) OUString aName(pSelected->GetName()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetFrameWeld(), aName)); + VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetFrameWeld(), aName)); pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl)); - if(RET_OK == pDlg->Execute()) - { - pSelected->SetName(pDlg->GetName()); + pDlg->StartExecuteAsync( + [this, pDlg, pSelected] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + { + pSelected->SetName(pDlg->GetName()); - SdPage* pPage = GetActualPage(); - if (pPage) - pPage->notifyObjectRenamed(pSelected); - } + SdPage* pPage = GetActualPage(); + if (pPage) + pPage->notifyObjectRenamed(pSelected); + } + pDlg->disposeOnce(); + SfxBindings& rBindings = GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_NAVIGATOR_STATE, true ); + rBindings.Invalidate( SID_CONTEXT ); + } + ); } - SfxBindings& rBindings = GetViewFrame()->GetBindings(); - rBindings.Invalidate( SID_NAVIGATOR_STATE, true ); - rBindings.Invalidate( SID_CONTEXT ); - Cancel(); rReq.Ignore(); break; diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx index 818c3dfb3209..979f63a14369 100644 --- a/sw/source/uibase/shells/drwbassh.cxx +++ b/sw/source/uibase/shells/drwbassh.cxx @@ -586,27 +586,32 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq) // #i68101# SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0); OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)"); - OUString aName(pSelected->GetName()); + OUString aOrigName(pSelected->GetName()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetView().GetFrameWeld(), aName)); + VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetView().GetFrameWeld(), aOrigName)); pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl)); - if(RET_OK == pDlg->Execute()) - { - const OUString aOrigName = aName; - aName = pDlg->GetName(); - pSelected->SetName(aName); - pSh->SetModified(); - - // update accessibility sidebar object name if we modify the object name on the navigator bar - if (!aName.isEmpty() && aOrigName != aName) + pDlg->StartExecuteAsync( + [pDlg, pSelected, pSh, aOrigName] (sal_Int32 nResult)->void { - if (SwNode* pSwNode = FindFrameFormat(pSelected)->GetAnchor().GetAnchorNode()) - pSwNode->resetAndQueueAccessibilityCheck(true); + if (nResult == RET_OK) + { + OUString aNewName = pDlg->GetName(); + pSelected->SetName(aNewName); + pSh->SetModified(); + + // update accessibility sidebar object name if we modify the object name on the navigator bar + if (!aNewName.isEmpty() && aOrigName != aNewName) + { + if (SwNode* pSwNode = FindFrameFormat(pSelected)->GetAnchor().GetAnchorNode()) + pSwNode->resetAndQueueAccessibilityCheck(true); + } + } + pDlg->disposeOnce(); } - } + ); } break; diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 6af4883d83e3..2e5d3313b635 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -675,13 +675,17 @@ void SwFrameShell::Execute(SfxRequest &rReq) { OUString aName(rSh.GetFlyName()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg( + VclPtr<AbstractSvxObjectNameDialog> pDlg( pFact->CreateSvxObjectNameDialog(GetView().GetFrameWeld(), aName)); - if ( pDlg->Execute() == RET_OK ) - { - rSh.SetFlyName(pDlg->GetName()); - } + pDlg->StartExecuteAsync( + [this, pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + GetShell().SetFlyName(pDlg->GetName()); + pDlg->disposeOnce(); + } + ); } } break; |