cui/source/dialogs/hltpbase.cxx  |    6 +++---
 cui/source/factory/dlgfact.cxx   |    4 ++--
 cui/source/factory/dlgfact.hxx   |    2 +-
 cui/source/inc/macroass.hxx      |    4 +++-
 cui/source/tabpages/macroass.cxx |   10 ++++++----
 include/svx/svxdlg.hxx           |    2 +-
 sc/source/ui/drawfunc/drawsh.cxx |    8 ++++----
 svx/source/dialog/imapwnd.cxx    |   10 +++++-----
 sw/source/ui/misc/glossary.cxx   |    8 ++++----
 9 files changed, 29 insertions(+), 25 deletions(-)

New commits:
commit 514d7384470434a0b0b119e369ff615e2a1499c9
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Aug 1 10:58:40 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Aug 1 13:10:07 2024 +0200

    tdf#161968 UI Assign macro to shape crashes CALC
    
    regression from
        commit f690e8218a74a0f7792407a1d46198883d2528ff
        Author: Noel Grandin <[email protected]>
        Date:   Tue Jan 23 13:24:29 2024 +0200
        make event config dialog async
    
    Change-Id: Ie68aeb1171831da3b457afd945ccaaa248e652af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171370
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index 9ac9be2baf8b..854c3aa6d3d7 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -334,12 +334,12 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, 
ClickScriptHdl_Impl, weld::Button&, voi
         aItem.SetMacroTable( *pMacroTbl );
 
     // create empty itemset for macro-dlg
-    SfxItemSetFixed<SID_ATTR_MACROITEM, SID_ATTR_MACROITEM> aItemSet( 
SfxGetpApp()->GetPool() );
-    aItemSet.Put ( aItem );
+    auto xItemSet = std::make_unique<SfxItemSetFixed<SID_ATTR_MACROITEM, 
SID_ATTR_MACROITEM>>( SfxGetpApp()->GetPool() );
+    xItemSet->Put( aItem );
 
     DisableClose( true );
 
-    SfxMacroAssignDlg aDlg(mpDialog->getDialog(), mxDocumentFrame, aItemSet);
+    SfxMacroAssignDlg aDlg(mpDialog->getDialog(), mxDocumentFrame, 
std::move(xItemSet));
 
     // add events
     SfxMacroTabPage *pMacroPage = aDlg.GetTabPage();
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index ffb2ee562c10..4e8a2dab3c5a 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1212,10 +1212,10 @@ VclPtr<SfxAbstractDialog> 
AbstractDialogFactory_Impl::CreateCharMapDialog(weld::
 }
 
 VclPtr<SfxAbstractDialog> 
AbstractDialogFactory_Impl::CreateEventConfigDialog(weld::Widget* pParent,
-                                                                              
const SfxItemSet& rAttr,
+                                                                              
std::unique_ptr<const SfxItemSet> xAttr,
                                                                               
const Reference< XFrame >& rDocumentFrame)
 {
-    return 
VclPtr<CuiAbstractSingleTabController_Impl>::Create(std::make_unique<SfxMacroAssignDlg>(pParent,
 rDocumentFrame, rAttr));
+    return 
VclPtr<CuiAbstractSingleTabController_Impl>::Create(std::make_unique<SfxMacroAssignDlg>(pParent,
 rDocumentFrame, std::move(xAttr)));
 }
 
 VclPtr<SfxAbstractDialog> 
AbstractDialogFactory_Impl::CreateSfxDialog(weld::Window* pParent,
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index ca11ec7427dc..b1c82104c7a0 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -444,7 +444,7 @@ public:
                                                              const SfxItemSet& 
rAttr,
                                                              const 
css::uno::Reference< css::frame::XFrame >& rFrame) override;
     virtual VclPtr<SfxAbstractDialog>    CreateEventConfigDialog(weld::Widget* 
pParent,
-                                                                 const 
SfxItemSet& rAttr,
+                                                                 
std::unique_ptr<const SfxItemSet> xAttr,
                                                                  const 
css::uno::Reference< css::frame::XFrame >& rFrame) override;
     virtual VclPtr<VclAbstractDialog>    CreateFrameDialog(weld::Window* 
pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame,
                                                            sal_uInt32 nResId, 
sal_uInt16 nPageId, const OUString& rParameter) override;
diff --git a/cui/source/inc/macroass.hxx b/cui/source/inc/macroass.hxx
index ba3c1de11717..3142cb4068ef 100644
--- a/cui/source/inc/macroass.hxx
+++ b/cui/source/inc/macroass.hxx
@@ -80,11 +80,13 @@ class SfxMacroAssignDlg : public 
SfxSingleTabDialogController
 public:
     SfxMacroAssignDlg(weld::Widget* pParent,
                       const css::uno::Reference< css::frame::XFrame >& 
rxDocumentFrame,
-                      const SfxItemSet& rSet);
+                      std::unique_ptr<const SfxItemSet> xSet);
     SfxMacroTabPage* GetTabPage()
     {
         return static_cast<SfxMacroTabPage*>(m_xSfxPage.get());
     }
+private:
+    std::unique_ptr<const SfxItemSet> mxItemSet;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx
index 9da8e8ce83fe..c0442e7fceaa 100644
--- a/cui/source/tabpages/macroass.cxx
+++ b/cui/source/tabpages/macroass.cxx
@@ -387,11 +387,13 @@ std::unique_ptr<SfxTabPage> 
SfxMacroTabPage::Create(weld::Container* pPage, weld
 }
 
 SfxMacroAssignDlg::SfxMacroAssignDlg(weld::Widget* pParent,
-    const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet)
-    : SfxSingleTabDialogController(pParent, 
&rSet,u"cui/ui/eventassigndialog.ui"_ustr,
-                                   u"EventAssignDialog"_ustr)
+    const Reference< XFrame >& rxDocumentFrame, std::unique_ptr<const 
SfxItemSet> xSet)
+    : SfxSingleTabDialogController(pParent, nullptr, 
u"cui/ui/eventassigndialog.ui"_ustr,
+                                   u"EventAssignDialog"_ustr),
+      mxItemSet(std::move(xSet))
 {
-    std::unique_ptr<SfxMacroTabPage> xPage = 
CreateSfxMacroTabPage(get_content_area(), this, rSet);
+    SetInputSet(mxItemSet.get());
+    std::unique_ptr<SfxMacroTabPage> xPage = 
CreateSfxMacroTabPage(get_content_area(), this, *mxItemSet);
     xPage->SetFrame(rxDocumentFrame);
     SetTabPage(std::move(xPage));
     GetTabPage()->LaunchFillGroup();
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index aa73fb57e5c2..b92adec13b3d 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -418,7 +418,7 @@ public:
                                                                         
sal_uInt32 nResId )=0;
     virtual VclPtr<SfxAbstractDialog>       CreateCharMapDialog(weld::Window* 
pParent, const SfxItemSet& rAttr,
                                                                 const 
css::uno::Reference<css::frame::XFrame>& rFrame) = 0;
-    virtual VclPtr<SfxAbstractDialog>       
CreateEventConfigDialog(weld::Widget* pParent, const SfxItemSet& rAttr,
+    virtual VclPtr<SfxAbstractDialog>       
CreateEventConfigDialog(weld::Widget* pParent, std::unique_ptr<const 
SfxItemSet> xAttr,
                                                                     const 
css::uno::Reference< css::frame::XFrame >& rFrame) = 0;
     virtual VclPtr<AbstractSvxPostItDialog>    
CreateSvxPostItDialog(weld::Widget* pParent, const SfxItemSet& rCoreSet, bool 
bPrevNext = false) = 0;
     virtual VclPtr<VclAbstractDialog>          
CreateSvxScriptOrgDialog(weld::Window* pParent, const OUString& rLanguage) 
override = 0;
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index bf85256afc42..c4006146827e 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -426,19 +426,19 @@ void ScDrawShell::ExecuteMacroAssign(SdrObject* pObj, 
weld::Window* pWin)
     }
 
     // create empty itemset for macro-dlg
-    SfxItemSetFixed<SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, 
SID_EVENTCONFIG> aItemSet(SfxGetpApp()->GetPool() );
-    aItemSet.Put ( aItem );
+    auto xItemSet = std::make_unique<SfxItemSetFixed<SID_ATTR_MACROITEM, 
SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG>>( SfxGetpApp()->GetPool() 
);
+    xItemSet->Put ( aItem );
 
     SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
     aNamesItem.AddEvent( ScResId(RID_SCSTR_ONCLICK), OUString(), 
SvMacroItemId::OnClick );
-    aItemSet.Put( aNamesItem );
+    xItemSet->Put( aNamesItem );
 
     css::uno::Reference < css::frame::XFrame > xFrame;
     if (GetViewShell())
         xFrame = GetViewShell()->GetViewFrame().GetFrame().GetFrameInterface();
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    VclPtr<SfxAbstractDialog> pMacroDlg(pFact->CreateEventConfigDialog( pWin, 
aItemSet, xFrame ));
+    VclPtr<SfxAbstractDialog> pMacroDlg(pFact->CreateEventConfigDialog( pWin, 
std::move(xItemSet), xFrame ));
     pMacroDlg->StartExecuteAsync(
         [this, pMacroDlg, pObj, pInfo] (sal_Int32 nResult) mutable -> void
         {
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 00acb4271876..4b2e947614f8 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -673,21 +673,21 @@ void IMapWindow::DoMacroAssign()
     if ( !pSdrObj )
         return;
 
-    SfxItemSetFixed<SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, 
SID_EVENTCONFIG>
-        aSet(*pIMapPool);
+    auto xSet = std::make_unique<SfxItemSetFixed<SID_ATTR_MACROITEM, 
SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG>>
+        (*pIMapPool);
 
     SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
     aNamesItem.AddEvent( u"MouseOver"_ustr, u""_ustr, 
SvMacroItemId::OnMouseOver );
     aNamesItem.AddEvent( u"MouseOut"_ustr, u""_ustr, SvMacroItemId::OnMouseOut 
);
-    aSet.Put( aNamesItem );
+    xSet->Put( aNamesItem );
 
     SvxMacroItem    aMacroItem(SID_ATTR_MACROITEM);
     IMapObject*     pIMapObj = GetIMapObj( pSdrObj );
     aMacroItem.SetMacroTable( pIMapObj->GetMacroTable() );
-    aSet.Put( aMacroItem );
+    xSet->Put( aMacroItem );
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    VclPtr<SfxAbstractDialog> 
pMacroDlg(pFact->CreateEventConfigDialog(GetDrawingArea(), aSet, 
mxDocumentFrame));
+    VclPtr<SfxAbstractDialog> 
pMacroDlg(pFact->CreateEventConfigDialog(GetDrawingArea(), std::move(xSet), 
mxDocumentFrame));
 
     pMacroDlg->StartExecuteAsync(
         [this, pMacroDlg, pIMapObj] (sal_Int32 nResult)->void
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 985c597efefa..85d6d52eb68b 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -633,7 +633,7 @@ IMPL_LINK(SwGlossaryDlg, MenuHdl, const OUString&, 
rItemIdent, void)
     }
     else if (rItemIdent == "macro")
     {
-        SfxItemSetFixed<RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, 
SID_EVENTCONFIG> aSet( m_pShell->GetAttrPool() );
+        auto xSet = std::make_unique<SfxItemSetFixed<RES_FRMMACRO, 
RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG>>( m_pShell->GetAttrPool() );
 
         SvxMacro aStart(OUString(), OUString(), STARBASIC);
         SvxMacro aEnd(OUString(), OUString(), STARBASIC);
@@ -645,11 +645,11 @@ IMPL_LINK(SwGlossaryDlg, MenuHdl, const OUString&, 
rItemIdent, void)
         if( aEnd.HasMacro() )
             aItem.SetMacro( SvMacroItemId::SwEndInsGlossary, aEnd );
 
-        aSet.Put( aItem );
-        aSet.Put( SwMacroAssignDlg::AddEvents( MACASSGN_AUTOTEXT ) );
+        xSet->Put( aItem );
+        xSet->Put( SwMacroAssignDlg::AddEvents( MACASSGN_AUTOTEXT ) );
 
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-        VclPtr<SfxAbstractDialog> 
pMacroDlg(pFact->CreateEventConfigDialog(m_xDialog.get(), aSet,
+        VclPtr<SfxAbstractDialog> 
pMacroDlg(pFact->CreateEventConfigDialog(m_xDialog.get(), std::move(xSet),
             m_pShell->GetView().GetViewFrame().GetFrame().GetFrameInterface() 
));
         if (pMacroDlg)
             pMacroDlg->StartExecuteAsync(

Reply via email to