summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-01-22 14:39:00 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2024-05-09 08:47:13 +0200
commit71a99887adaa404adbf156e5894fe520b755248c (patch)
tree494fb6dfde59f2730730b0e755ce99847d762c51
parent4fe480d314ceb100f4679626fee3d60dd82a6bc6 (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167361 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--chart2/source/controller/main/ShapeController.cxx26
-rw-r--r--cui/source/factory/dlgfact.cxx8
-rw-r--r--cui/source/factory/dlgfact.hxx6
-rw-r--r--include/svx/svxdlg.hxx2
-rw-r--r--sc/source/ui/drawfunc/drawsh5.cxx85
-rw-r--r--sd/source/ui/view/drviews2.cxx30
-rw-r--r--sd/source/ui/view/drviewsc.cxx3
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx36
-rw-r--r--sw/source/uibase/shells/frmsh.cxx15
9 files changed, 115 insertions, 96 deletions
diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx
index 115229de0e57..359488c24c76 100644
--- a/chart2/source/controller/main/ShapeController.cxx
+++ b/chart2/source/controller/main/ShapeController.cxx
@@ -217,8 +217,7 @@ void ShapeController::describeSupportedFeatures()
IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
{
- OUString aName;
- rDialog.GetName( aName );
+ OUString aName = rDialog.GetName();
if ( !aName.isEmpty() )
{
@@ -431,20 +430,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 )
- {
- pDlg->GetName(aName);
- 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 c53e3432a2a4..62d50eb96d85 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -122,8 +122,8 @@ IMPL_ABSTDLG_CLASS(AbstractSvxJSearchOptionsDialog)
IMPL_ABSTDLG_CLASS(AbstractSvxMultiPathDialog)
IMPL_ABSTDLG_CLASS(AbstractSvxNameDialog)
IMPL_ABSTDLG_CLASS(AbstractSvxNewDictionaryDialog)
-IMPL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog)
-IMPL_ABSTDLG_CLASS(AbstractSvxObjectTitleDescDialog)
+IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog, SvxObjectNameDialog)
+IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectTitleDescDialog, SvxObjectTitleDescDialog)
IMPL_ABSTDLG_CLASS(AbstractSvxPathSelectDialog)
IMPL_ABSTDLG_CLASS(AbstractSvxPostItDialog)
IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxSearchSimilarityDialog,SvxSearchSimilarityDialog)
@@ -595,9 +595,9 @@ IMPL_LINK_NOARG(AbstractSvxNameDialog_Impl, CheckNameTooltipHdl, SvxNameDialog&,
return aCheckNameTooltipHdl.Call(*this);
}
-void AbstractSvxObjectNameDialog_Impl::GetName(OUString& rName)
+OUString AbstractSvxObjectNameDialog_Impl::GetName()
{
- rName = m_xDlg->GetName();
+ return m_xDlg->GetName();
}
void AbstractSvxObjectNameDialog_Impl::SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 02ba9a1b0f9d..3ffba25bebae 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -285,8 +285,8 @@ class SvxObjectNameDialog;
class SvxObjectTitleDescDialog;
// AbstractSvxObjectNameDialog_Impl
-DECL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog,SvxObjectNameDialog)
- virtual void GetName(OUString& rName) override ;
+DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog,SvxObjectNameDialog)
+ virtual OUString GetName() override;
virtual void SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink) override;
private:
@@ -295,7 +295,7 @@ private:
};
// AbstractSvxObjectTitleDescDialog_Impl
-DECL_ABSTDLG_CLASS(AbstractSvxObjectTitleDescDialog,SvxObjectTitleDescDialog)
+DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectTitleDescDialog,SvxObjectTitleDescDialog)
virtual void GetTitle(OUString& rName) override;
virtual void GetDescription(OUString& rName) override;
virtual void IsDecorative(bool & rIsDecorative) override;
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 2e6c7d672fc6..6c9017688b62 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -175,7 +175,7 @@ class AbstractSvxObjectNameDialog :public VclAbstractDialog
protected:
virtual ~AbstractSvxObjectNameDialog() override = default;
public:
- virtual void GetName(OUString& rName) = 0;
+ virtual OUString GetName() = 0;
virtual void SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink) = 0;
};
diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx
index 7c39afc2de0d..0ff2cf6fc468 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();
- pDlg->GetName(aName);
-
- 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;
@@ -647,8 +653,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
{
- OUString aName;
- rDialog.GetName( aName );
+ OUString aName = rDialog.GetName();
ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
if ( !aName.isEmpty() && pModel )
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 0847df373f44..e327a9e0e949 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2662,25 +2662,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())
- {
- pDlg->GetName(aName);
- pSelected->SetName(aName);
+ 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/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx
index 6be86e63cb8d..46ecb31d639b 100644
--- a/sd/source/ui/view/drviewsc.cxx
+++ b/sd/source/ui/view/drviewsc.cxx
@@ -62,8 +62,7 @@ void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
{
- OUString aName;
- rDialog.GetName( aName );
+ OUString aName = rDialog.GetName();
return aName.isEmpty() || ( GetDoc() && !GetDoc()->GetObj( aName ) );
}
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index 225584160752..de5351d9f4bc 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -596,27 +596,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;
- pDlg->GetName(aName);
- 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;
@@ -727,8 +732,7 @@ IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxObjectNameDialog&
OSL_ENSURE(rMarkList.GetMarkCount() == 1, "wrong draw selection");
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
const OUString sCurrentName = pObj->GetName();
- OUString sNewName;
- rNameDialog.GetName(sNewName);
+ OUString sNewName = rNameDialog.GetName();
bool bRet = false;
if (sNewName.isEmpty() || sCurrentName == sNewName)
bRet = true;
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx
index ac5ee0d80835..fc41058cd62e 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -675,14 +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 )
- {
- pDlg->GetName(aName);
- rSh.SetFlyName(aName);
- }
+ pDlg->StartExecuteAsync(
+ [this, pDlg] (sal_Int32 nResult)->void
+ {
+ if (nResult == RET_OK)
+ GetShell().SetFlyName(pDlg->GetName());
+ pDlg->disposeOnce();
+ }
+ );
}
}
break;