[Libreoffice-commits] core.git: cui/source cui/uiconfig include/sfx2 include/svx sc/source sd/source sfx2/source sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 22 21:10:58 UTC 2019


 cui/source/customize/cfgutil.cxx       |  153 +++++++++++++++++----------------
 cui/source/customize/macropg.cxx       |   17 +--
 cui/source/factory/dlgfact.cxx         |   19 +---
 cui/source/factory/dlgfact.hxx         |   19 ++--
 cui/source/inc/cfgutil.hxx             |   40 ++++----
 cui/uiconfig/ui/macroselectordialog.ui |  122 +++++++++++++++++++++-----
 include/sfx2/app.hxx                   |    2 
 include/sfx2/sfxdlg.hxx                |    7 -
 include/svx/svxdlg.hxx                 |    7 -
 sc/source/ui/dbgui/validate.cxx        |    2 
 sd/source/ui/dlg/tpaction.cxx          |    2 
 sfx2/source/appl/app.cxx               |    5 -
 sfx2/source/appl/appserv.cxx           |   26 +----
 sw/source/ui/fldui/fldfunc.cxx         |    2 
 sw/source/uibase/fldui/fldmgr.cxx      |    4 
 sw/source/uibase/inc/fldmgr.hxx        |    3 
 16 files changed, 251 insertions(+), 179 deletions(-)

New commits:
commit 6e65d9184a5525f303f75fa0dd1cfc8a401f5bc6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 22 16:41:32 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 22 22:10:25 2019 +0100

    weld SvxScriptSelectorDialog
    
    Change-Id: I885acfcdfd9544d7f4eb0e602a7acf0215cb9d92
    Reviewed-on: https://gerrit.libreoffice.org/68220
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 012b46818e55..c00d17e5fb31 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -327,6 +327,31 @@ OUString SfxConfigFunctionListBox::GetHelpText( bool bConsiderParent )
     return OUString();
 }
 
+OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent )
+{
+    int nSelected = m_xTreeView->get_selected_index();
+    if (nSelected != -1)
+    {
+        SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(nSelected).toInt64());
+        if (pData)
+        {
+            if ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
+            {
+                if (bConsiderParent)
+                    return Application::GetHelp()->GetHelpText(pData->sCommand, m_xTreeView.get());
+                else
+                    return Application::GetHelp()->GetHelpText(pData->sCommand, static_cast<weld::Widget*>(nullptr));
+            }
+            else if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
+            {
+                return pData->sHelpText;
+            }
+        }
+    }
+    return OUString();
+}
+
+
 OUString SfxConfigFunctionListBox::GetCurCommand()
 {
     SvTreeListEntry *pEntry = FirstSelected();
@@ -505,6 +530,10 @@ void SfxConfigGroupListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
     pStylesInfo = pStyles;
 }
 
+void CuiConfigGroupListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
+{
+    m_pStylesInfo = pStyles;
+}
 
 void SfxConfigGroupListBox::InitModule()
 {
@@ -1782,48 +1811,47 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, weld::TreeIter&, rIter, bool)
  */
 
 SvxScriptSelectorDialog::SvxScriptSelectorDialog(
-    vcl::Window* pParent, bool bShowSlots, const css::uno::Reference< css::frame::XFrame >& xFrame)
-    : ModalDialog(pParent, "MacroSelectorDialog", "cui/ui/macroselectordialog.ui")
+    weld::Window* pParent, bool bShowSlots, const css::uno::Reference< css::frame::XFrame >& xFrame)
+    : GenericDialogController(pParent, "cui/ui/macroselectordialog.ui", "MacroSelectorDialog")
     , m_bShowSlots(bShowSlots)
+    , m_xDialogDescription(m_xBuilder->weld_label(bShowSlots ? "helptoolbar" : "helpmacro"))
+    , m_xCategories(new CuiConfigGroupListBox(m_xBuilder->weld_tree_view("categories")))
+    , m_xCommands(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("commands")))
+    , m_xLibraryFT(m_xBuilder->weld_label("libraryft"))
+    , m_xCategoryFT(m_xBuilder->weld_label("categoryft"))
+    , m_xMacronameFT(m_xBuilder->weld_label("macronameft"))
+    , m_xCommandsFT(m_xBuilder->weld_label("commandsft"))
+    , m_xOKButton(m_xBuilder->weld_button(bShowSlots ? "add" : "ok"))
+    , m_xCancelButton(m_xBuilder->weld_button(bShowSlots ? "close" : "cancel"))
+    , m_xDescriptionText(m_xBuilder->weld_text_view("description"))
 {
-    get<FixedText>("libraryft")->Show(!m_bShowSlots);
-    get<FixedText>("categoryft")->Show(m_bShowSlots);
-    get<FixedText>("macronameft")->Show(!m_bShowSlots);
-    get<FixedText>("commandsft")->Show(m_bShowSlots);
-    get(m_pDescriptionText, "description");
-    get(m_pCommands, "commands");
     if (m_bShowSlots)
     {
         // If we are showing Slot API commands update labels in the UI
-        SetText(CuiResId(RID_SVXSTR_SELECTOR_ADD_COMMANDS));
-        get(m_pCancelButton, "close");
-        get(m_pDialogDescription, "helptoolbar");
-        get(m_pOKButton, "add");
+        m_xDialog->set_title(CuiResId(RID_SVXSTR_SELECTOR_ADD_COMMANDS));
     }
-    else
-    {
-        get(m_pCancelButton, "cancel");
-        get(m_pDialogDescription, "helpmacro");
-        get(m_pOKButton, "ok");
-    }
-    m_pCancelButton->Show();
-    m_pDialogDescription->Show();
-    m_pOKButton->Show();
+    m_xCancelButton->show();
+    m_xDialogDescription->show();
+    m_xOKButton->show();
+
+    m_xLibraryFT->show(!m_bShowSlots);
+    m_xCategoryFT->show(m_bShowSlots);
+    m_xMacronameFT->show(!m_bShowSlots);
+    m_xCommandsFT->show(m_bShowSlots);
 
-    get(m_pCategories, "categories");
     const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
-    m_pCategories->SetFunctionListBox(m_pCommands);
-    m_pCategories->Init(comphelper::getProcessComponentContext(), xFrame, aModuleName, bShowSlots);
+    m_xCategories->SetFunctionListBox(m_xCommands.get());
+    m_xCategories->Init(comphelper::getProcessComponentContext(), xFrame, aModuleName, bShowSlots);
 
-    m_pCategories->SetSelectHdl(
+    m_xCategories->connect_changed(
             LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
-    m_pCommands->SetSelectHdl( LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
-    m_pCommands->SetDoubleClickHdl( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) );
+    m_xCommands->connect_changed( LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
+    m_xCommands->connect_row_activated( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) );
 
-    m_pOKButton->SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
-    m_pCancelButton->SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
+    m_xOKButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
+    m_xCancelButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
 
-    m_sDefaultDesc = m_pDescriptionText->GetText();
+    m_sDefaultDesc = m_xDescriptionText->get_text();
 
     // Support style commands
     uno::Reference<frame::XController> xController;
@@ -1834,41 +1862,28 @@ SvxScriptSelectorDialog::SvxScriptSelectorDialog(
         xModel = xController->getModel();
 
     m_aStylesInfo.init(aModuleName, xModel);
-    m_pCategories->SetStylesInfo(&m_aStylesInfo);
+    m_xCategories->SetStylesInfo(&m_aStylesInfo);
 
     UpdateUI();
 }
 
 SvxScriptSelectorDialog::~SvxScriptSelectorDialog()
 {
-    disposeOnce();
 }
 
-void SvxScriptSelectorDialog::dispose()
+IMPL_LINK(SvxScriptSelectorDialog, SelectHdl, weld::TreeView&, rCtrl, void)
 {
-    m_pDialogDescription.clear();
-    m_pCategories.clear();
-    m_pCommands.clear();
-    m_pOKButton.clear();
-    m_pCancelButton.clear();
-    m_pDescriptionText.clear();
-    ModalDialog::dispose();
-}
-
-IMPL_LINK( SvxScriptSelectorDialog, SelectHdl, SvTreeListBox*, pCtrl, void )
-{
-    if (pCtrl == m_pCategories)
+    if (&rCtrl == &m_xCategories->get_widget())
     {
-        m_pCategories->GroupSelected();
+        m_xCategories->GroupSelected();
     }
     UpdateUI();
 }
 
-IMPL_LINK_NOARG( SvxScriptSelectorDialog, FunctionDoubleClickHdl, SvTreeListBox*, bool )
+IMPL_LINK_NOARG(SvxScriptSelectorDialog, FunctionDoubleClickHdl, weld::TreeView&, void)
 {
-    if (m_pOKButton->IsEnabled())
-        ClickHdl(m_pOKButton);
-    return false;
+    if (m_xOKButton->get_sensitive())
+        ClickHdl(*m_xOKButton);
 }
 
 // Check if command is selected and enable the OK button accordingly
@@ -1879,42 +1894,38 @@ SvxScriptSelectorDialog::UpdateUI()
     OUString url = GetScriptURL();
     if ( !url.isEmpty() )
     {
-        OUString sMessage = m_pCommands->GetHelpText();
-        m_pDescriptionText->SetText(sMessage.isEmpty() ? m_sDefaultDesc : sMessage);
+        OUString sMessage = m_xCommands->GetHelpText();
+        m_xDescriptionText->set_text(sMessage.isEmpty() ? m_sDefaultDesc : sMessage);
 
-        m_pOKButton->Enable();
+        m_xOKButton->set_sensitive(true);
     }
     else
     {
-        m_pDescriptionText->SetText(m_sDefaultDesc);
-        m_pOKButton->Enable( false );
+        m_xDescriptionText->set_text(m_sDefaultDesc);
+        m_xOKButton->set_sensitive(false);
     }
 }
 
-IMPL_LINK( SvxScriptSelectorDialog, ClickHdl, Button *, pButton, void )
+IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void)
 {
-    if (pButton == m_pCancelButton)
+    if (&rButton == m_xCancelButton.get())
     {
-        EndDialog();
+        m_xDialog->response(RET_CANCEL);
     }
-    else if (pButton == m_pOKButton)
+    else if (&rButton == m_xOKButton.get())
     {
         // If we are displaying Slot API commands then this the dialog is being
         // run from Tools/Configure and we should not close it
         if ( !m_bShowSlots )
         {
-            EndDialog( RET_OK );
+            m_xDialog->response(RET_OK);
         }
         else
         {
             // Select the next entry in the list if possible
-            SvTreeListEntry* current = m_pCommands->FirstSelected();
-            SvTreeListEntry* next = current->NextSibling();
-
-            if ( next != nullptr )
-            {
-                m_pCommands->Select( next );
-            }
+            std::unique_ptr<weld::TreeIter> xIter = m_xCommands->make_iterator();
+            if (m_xCommands->get_selected(xIter.get()) && m_xCommands->iter_next_sibling(*xIter))
+                m_xCommands->select(*xIter);
         }
     }
 }
@@ -1922,7 +1933,7 @@ IMPL_LINK( SvxScriptSelectorDialog, ClickHdl, Button *, pButton, void )
 void
 SvxScriptSelectorDialog::SetRunLabel()
 {
-    m_pOKButton->SetText(CuiResId(RID_SVXSTR_SELECTOR_RUN));
+    m_xOKButton->set_label(CuiResId(RID_SVXSTR_SELECTOR_RUN));
 }
 
 OUString
@@ -1930,10 +1941,10 @@ SvxScriptSelectorDialog::GetScriptURL() const
 {
     OUString result;
 
-    SvTreeListEntry *pEntry = const_cast< SvxScriptSelectorDialog* >( this )->m_pCommands->FirstSelected();
-    if ( pEntry )
+    std::unique_ptr<weld::TreeIter> xIter = m_xCommands->make_iterator();
+    if (m_xCommands->get_selected(xIter.get()))
     {
-        SfxGroupInfo_Impl *pData = static_cast<SfxGroupInfo_Impl*>(pEntry->GetUserData());
+        SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter).toInt64());
         if  (   ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
             ||  ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
             ||  ( pData->nKind == SfxCfgKind::GROUP_STYLES )
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index bb3786e09d99..189a44cb2c8d 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -645,17 +645,14 @@ void SvxMacroTabPage_::GenericHandler_Impl( SvxMacroTabPage_* pThis, PushButton*
     else if( bAssEnabled )
     {
         // assign pressed
-        ScopedVclPtrInstance< SvxScriptSelectorDialog > pDlg( pThis, false, pThis->GetFrame() );
-        if( pDlg )
+        SvxScriptSelectorDialog aDlg(pThis->GetDialogFrameWeld(), false, pThis->GetFrame());
+        short ret = aDlg.run();
+        if ( ret )
         {
-            short ret = pDlg->Execute();
-            if ( ret )
-            {
-                sEventType = "Script";
-                sEventURL = pDlg->GetScriptURL();
-                if(!pThis->bAppEvents)
-                    pThis->bDocModified = true;
-            }
+            sEventType = "Script";
+            sEventURL = aDlg.GetScriptURL();
+            if(!pThis->bAppEvents)
+                pThis->bDocModified = true;
         }
     }
 
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 75a6075f3caa..f1258eaecd57 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -144,7 +144,10 @@ short AbstractTitleDialog_Impl::Execute()
     return m_xDlg->run();
 }
 
-IMPL_ABSTDLG_BASE(AbstractScriptSelectorDialog_Impl);
+short AbstractScriptSelectorDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 
 short AbstractGalleryIdDialog_Impl::Execute()
 {
@@ -1093,24 +1096,20 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateScriptErrorDialog(co
     return VclPtr<SvxScriptErrorDialog>::Create(rException);
 }
 
-VclPtr<AbstractScriptSelectorDialog> AbstractDialogFactory_Impl::CreateScriptSelectorDialog(
-    vcl::Window* pParent, const Reference< frame::XFrame >& _rxFrame )
+VclPtr<AbstractScriptSelectorDialog> AbstractDialogFactory_Impl::CreateScriptSelectorDialog(weld::Window* pParent,
+        const Reference<frame::XFrame>& rxFrame)
 {
-    VclPtrInstance<SvxScriptSelectorDialog> pDlg(pParent, false/*bShowSlots*/, _rxFrame);
-    return VclPtr<AbstractScriptSelectorDialog_Impl>::Create(pDlg);
+    return VclPtr<AbstractScriptSelectorDialog_Impl>::Create(std::make_unique<SvxScriptSelectorDialog>(pParent, false/*bShowSlots*/, rxFrame));
 }
 
 OUString AbstractScriptSelectorDialog_Impl::GetScriptURL() const
 {
-    if (pDlg)
-        return pDlg->GetScriptURL();
-    return OUString();
+    return m_xDlg->GetScriptURL();
 }
 
 void AbstractScriptSelectorDialog_Impl::SetRunLabel()
 {
-    if (pDlg)
-        pDlg->SetRunLabel();
+    m_xDlg->SetRunLabel();
 }
 
 VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxScriptOrgDialog(weld::Window* pParent,
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 57c38cfd7ad0..b7fe341fd084 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -282,11 +282,15 @@ public:
 class SvxScriptSelectorDialog;
 class AbstractScriptSelectorDialog_Impl : public AbstractScriptSelectorDialog
 {
-    DECL_ABSTDLG_BASE(
-        AbstractScriptSelectorDialog_Impl, SvxScriptSelectorDialog)
-
+protected:
+    std::unique_ptr<SvxScriptSelectorDialog> m_xDlg;
+public:
+    explicit AbstractScriptSelectorDialog_Impl(std::unique_ptr<SvxScriptSelectorDialog> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
     virtual OUString GetScriptURL() const override;
-
     virtual void SetRunLabel() override;
 };
 
@@ -838,11 +842,8 @@ public:
     virtual DialogGetRanges             GetDialogGetRangesFunc() override;
     virtual VclPtr<VclAbstractDialog>   CreateSvxScriptOrgDialog(weld::Window* pParent, const OUString& rLanguage) override;
 
-    virtual VclPtr<AbstractScriptSelectorDialog>
-        CreateScriptSelectorDialog(
-            vcl::Window* pParent,
-            const css::uno::Reference< css::frame::XFrame >& _rxFrame
-        ) override;
+    virtual VclPtr<AbstractScriptSelectorDialog> CreateScriptSelectorDialog(weld::Window* pParent,
+            const css::uno::Reference< css::frame::XFrame >& rxFrame) override;
 
     virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog(const css::uno::Any& rException) override;
 
diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx
index 7557a30073a4..ed1ccd100f94 100644
--- a/cui/source/inc/cfgutil.hxx
+++ b/cui/source/inc/cfgutil.hxx
@@ -148,7 +148,10 @@ public:
     bool get_iter_first(weld::TreeIter& rIter) const { return m_xTreeView->get_iter_first(rIter); }
     // set iter to point to next node, depth first, then sibling
     bool iter_next(weld::TreeIter& rIter) const { return m_xTreeView->iter_next(rIter); }
+    bool iter_next_sibling(weld::TreeIter& rIter) const { return m_xTreeView->iter_next_sibling(rIter); }
     OUString get_text(const weld::TreeIter& rIter) const { return m_xTreeView->get_text(rIter); }
+    OUString get_id(const weld::TreeIter& rIter) const { return m_xTreeView->get_id(rIter); }
+    bool get_selected(weld::TreeIter* pIter) const { return m_xTreeView->get_selected(pIter); }
     void scroll_to_row(const weld::TreeIter& rIter) { return m_xTreeView->scroll_to_row(rIter); }
     void select(const weld::TreeIter& rIter) { m_xTreeView->select(rIter); }
 
@@ -156,6 +159,7 @@ public:
 
     void          ClearAll();
     OUString      GetSelectedScriptURI();
+    OUString      GetHelpText( bool bConsiderParent = true );
 };
 
 struct SvxConfigGroupBoxResource_Impl;
@@ -250,6 +254,7 @@ public:
     CuiConfigGroupListBox(std::unique_ptr<weld::TreeView> xTreeView);
     void set_sensitive(bool bSensitive) { m_xTreeView->set_sensitive(bSensitive); }
     void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xTreeView->connect_changed(rLink); }
+    const weld::TreeView& get_widget() const { return *m_xTreeView; }
     ~CuiConfigGroupListBox();
     void                ClearAll();
 
@@ -260,35 +265,36 @@ public:
     void                SetFunctionListBox( CuiConfigFunctionListBox *pBox )
                         { m_pFunctionListBox = pBox; }
     void                GroupSelected();
+    void                SetStylesInfo(SfxStylesInfo_Impl* pStyles);
 };
 
-class SvxScriptSelectorDialog : public ModalDialog
+class SvxScriptSelectorDialog : public weld::GenericDialogController
 {
-    VclPtr<FixedText>                      m_pDialogDescription;
-    VclPtr<SfxConfigGroupListBox>          m_pCategories;
-    VclPtr<SfxConfigFunctionListBox>       m_pCommands;
-    VclPtr<PushButton>                     m_pOKButton;
-    VclPtr<PushButton>                     m_pCancelButton;
-    VclPtr<VclMultiLineEdit>               m_pDescriptionText;
     OUString                               m_sDefaultDesc;
     SfxStylesInfo_Impl                     m_aStylesInfo;
     bool                                   m_bShowSlots;
 
-    DECL_LINK( ClickHdl, Button *, void );
-    DECL_LINK( SelectHdl, SvTreeListBox*, void );
-    DECL_LINK( FunctionDoubleClickHdl, SvTreeListBox*, bool );
+    std::unique_ptr<weld::Label> m_xDialogDescription;
+    std::unique_ptr<CuiConfigGroupListBox> m_xCategories;
+    std::unique_ptr<CuiConfigFunctionListBox> m_xCommands;
+    std::unique_ptr<weld::Label> m_xLibraryFT;
+    std::unique_ptr<weld::Label> m_xCategoryFT;
+    std::unique_ptr<weld::Label> m_xMacronameFT;
+    std::unique_ptr<weld::Label> m_xCommandsFT;
+    std::unique_ptr<weld::Button> m_xOKButton;
+    std::unique_ptr<weld::Button> m_xCancelButton;
+    std::unique_ptr<weld::TextView> m_xDescriptionText;
+
+    DECL_LINK(ClickHdl, weld::Button&, void);
+    DECL_LINK(SelectHdl, weld::TreeView&, void);
+    DECL_LINK(FunctionDoubleClickHdl, weld::TreeView&, void);
 
     void                            UpdateUI();
 
 public:
-
-    SvxScriptSelectorDialog (
-        vcl::Window* pParent,
-        bool bShowSlots,
-        const css::uno::Reference< css::frame::XFrame >& xFrame
-    );
+    SvxScriptSelectorDialog(weld::Window* pParent, bool bShowSlots,
+                            const css::uno::Reference< css::frame::XFrame >& xFrame);
     virtual ~SvxScriptSelectorDialog() override;
-    virtual void dispose() override;
 
     OUString    GetScriptURL() const;
     void        SetRunLabel();
diff --git a/cui/uiconfig/ui/macroselectordialog.ui b/cui/uiconfig/ui/macroselectordialog.ui
index c4a030c57845..edc9fad32d9e 100644
--- a/cui/uiconfig/ui/macroselectordialog.ui
+++ b/cui/uiconfig/ui/macroselectordialog.ui
@@ -1,30 +1,53 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name expander -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="MacroSelectorDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="macroselectordialog|MacroSelectorDialog">Macro Selector</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="layout_style">start</property>
+            <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="ok">
-                <property name="label">gtk-ok</property>
+              <object class="GtkButton" id="add">
+                <property name="label" translatable="yes" context="macroselectordialog|add">Add</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="no_show_all">True</property>
-                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -33,13 +56,14 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="add">
-                <property name="label" translatable="yes" context="macroselectordialog|add">Add</property>
+              <object class="GtkButton" id="ok">
+                <property name="label">gtk-ok</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="no_show_all">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -87,6 +111,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">4</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -110,10 +135,10 @@
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
                 <property name="hexpand">True</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="macroselectordialog|helpmacro">Select the library that contains the macro you want. Then select the macro under 'Macro name'.</property>
                 <property name="wrap">True</property>
                 <property name="max_width_chars">60</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -126,10 +151,10 @@
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
                 <property name="hexpand">True</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="macroselectordialog|helptoolbar">To add a command to a toolbar, select the category and then the command. Then drag the command to the Commands list of the Toolbars tab page in the Customize dialog.</property>
                 <property name="wrap">True</property>
                 <property name="max_width_chars">60</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -159,15 +184,46 @@
                         <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <object class="cuilo-SfxConfigGroupListBox" id="categories:border">
-                            <property name="width_request">280</property>
-                            <property name="height_request">300</property>
+                          <object class="GtkScrolledWindow">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="hexpand">True</property>
                             <property name="vexpand">True</property>
-                            <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="SfxConfigGroupListBox-selection1"/>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <object class="GtkTreeView" id="categories">
+                                <property name="width_request">-1</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="vexpand">True</property>
+                                <property name="model">liststore1</property>
+                                <property name="headers_visible">False</property>
+                                <property name="search_column">1</property>
+                                <property name="show_expanders">True</property>
+                                <property name="enable_tree_lines">True</property>
+                                <child internal-child="selection">
+                                  <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
+                                      <attributes>
+                                        <attribute name="pixbuf">0</attribute>
+                                      </attributes>
+                                    </child>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                      <attributes>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
                             </child>
                           </object>
                         </child>
@@ -231,15 +287,37 @@
                         <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <object class="cuilo-SfxConfigFunctionListBox" id="commands:border">
-                            <property name="width_request">280</property>
-                            <property name="height_request">300</property>
+                          <object class="GtkScrolledWindow">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="hexpand">True</property>
                             <property name="vexpand">True</property>
-                            <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="SfxConfigFunctionListBox-selection1"/>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <object class="GtkTreeView" id="commands">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="vexpand">True</property>
+                                <property name="model">liststore2</property>
+                                <property name="headers_visible">False</property>
+                                <property name="search_column">0</property>
+                                <property name="show_expanders">False</property>
+                                <child internal-child="selection">
+                                  <object class="GtkTreeSelection" id="Tree List-selection1"/>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                                      <attributes>
+                                        <attribute name="text">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
                             </child>
                           </object>
                         </child>
@@ -320,7 +398,7 @@
                         <property name="vexpand">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkTextView" id="description:border">
+                          <object class="GtkTextView" id="description">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="hexpand">True</property>
@@ -361,8 +439,8 @@
       </object>
     </child>
     <action-widgets>
+      <action-widget response="101">add</action-widget>
       <action-widget response="-5">ok</action-widget>
-      <action-widget response="0">add</action-widget>
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-7">close</action-widget>
       <action-widget response="-11">help</action-widget>
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index 27653aed3e98..2cbab66b9ec4 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -162,7 +162,7 @@ public:
 
     // Basic/Scripting
     static bool                 IsXScriptURL( const OUString& rScriptURL );
-    static OUString             ChooseScript();
+    static OUString             ChooseScript(weld::Window *pParent);
     static void                 MacroOrganizer( sal_Int16 nTabId );
     static ErrCode              CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
     static ErrCode              CallAppBasic( const OUString& i_macroName )
diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx
index 7eceac3f0ff3..48b6b965b64d 100644
--- a/include/sfx2/sfxdlg.hxx
+++ b/include/sfx2/sfxdlg.hxx
@@ -142,11 +142,8 @@ public:
     virtual VclPtr<SfxAbstractLinksDialog>    CreateLinksDialog(weld::Window* pParent, sfx2::LinkManager* pMgr, bool bHTML=false, sfx2::SvBaseLink* p=nullptr) = 0;
     virtual VclPtr<VclAbstractDialog>         CreateSvxScriptOrgDialog(weld::Window* pParent,  const OUString& rLanguage) = 0;
 
-    virtual VclPtr<AbstractScriptSelectorDialog>
-        CreateScriptSelectorDialog(
-            vcl::Window* pParent,
-            const css::uno::Reference< css::frame::XFrame >& _rxFrame
-        ) = 0;
+    virtual VclPtr<AbstractScriptSelectorDialog> CreateScriptSelectorDialog(weld::Window* pParent,
+            const css::uno::Reference< css::frame::XFrame >& rxFrame) = 0;
 
     virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog( const css::uno::Any& rException ) = 0;
 
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 59f0fa51908e..b1b67ca33f2d 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -432,11 +432,8 @@ public:
 
     virtual DialogGetRanges                    GetDialogGetRangesFunc() = 0;
 
-    virtual VclPtr<AbstractScriptSelectorDialog>
-        CreateScriptSelectorDialog(
-            vcl::Window* pParent,
-            const css::uno::Reference< css::frame::XFrame >& _rxFrame
-        ) override = 0;
+    virtual VclPtr<AbstractScriptSelectorDialog> CreateScriptSelectorDialog(weld::Window* pParent,
+            const css::uno::Reference< css::frame::XFrame >& rxFrame) override = 0;
 
     virtual VclPtr<VclAbstractDialog> CreateScriptErrorDialog(const css::uno::Any& rException) override = 0;
 
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index 591acbb3e3f9..d9d3f10ab920 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -830,7 +830,7 @@ IMPL_LINK_NOARG(ScTPValidationError, ClickSearchHdl, weld::Button&, void)
 {
     // Use static SfxApplication method to bring up selector dialog for
     // choosing a script
-    OUString aScriptURL = SfxApplication::ChooseScript();
+    OUString aScriptURL = SfxApplication::ChooseScript(GetDialogFrameWeld());
 
     if ( !aScriptURL.isEmpty() )
     {
diff --git a/sd/source/ui/dlg/tpaction.cxx b/sd/source/ui/dlg/tpaction.cxx
index c6c2bb06471d..f4d79c7997f6 100644
--- a/sd/source/ui/dlg/tpaction.cxx
+++ b/sd/source/ui/dlg/tpaction.cxx
@@ -424,7 +424,7 @@ void SdTPAction::OpenFileDialog()
         else if (bMacro)
         {
             // choose macro dialog
-            OUString aScriptURL = SfxApplication::ChooseScript();
+            OUString aScriptURL = SfxApplication::ChooseScript(GetFrameWeld());
 
             if ( !aScriptURL.isEmpty() )
             {
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index ff66aad976c2..9afc9d873835 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -490,7 +490,7 @@ bool SfxApplication::IsXScriptURL( const OUString& rScriptURL )
 }
 
 OUString
-SfxApplication::ChooseScript()
+SfxApplication::ChooseScript(weld::Window *pParent)
 {
     OUString aScriptURL;
 
@@ -502,8 +502,7 @@ SfxApplication::ChooseScript()
     const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : nullptr;
     uno::Reference< frame::XFrame > xFrame( pFrame ? pFrame->GetFrameInterface() : uno::Reference< frame::XFrame >() );
 
-    ScopedVclPtr<AbstractScriptSelectorDialog> pDlg(
-        pFact->CreateScriptSelectorDialog( nullptr, xFrame ));
+    ScopedVclPtr<AbstractScriptSelectorDialog> pDlg(pFact->CreateScriptSelectorDialog(pParent, xFrame));
 
     SAL_INFO( "sfx.appl", "done, now exec it");
 
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index e6033326bcbb..d08edda9b1b7 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -1273,25 +1273,12 @@ static OUString ChooseMacro(weld::Window* pParent, const Reference<XModel>& rxLi
 namespace
 {
 #if HAVE_FEATURE_SCRIPTING
-    vcl::Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, vcl::Window* _pFallback )
+    weld::Window* lcl_getDialogParent(const Reference<XFrame>& rxFrame)
     {
-        if ( !_rxFrame.is() )
-            return _pFallback;
-
-        try
-        {
-            Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
-            VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
-            OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
-
-            if ( pWindow )
-                return pWindow->GetSystemWindow();
-        }
-        catch( const Exception& )
-        {
-            DBG_UNHANDLED_EXCEPTION("sfx.appl");
-        }
-        return _pFallback;
+        Reference<awt::XWindow> xContainerWindow;
+        if (rxFrame.is())
+            xContainerWindow = rxFrame->getContainerWindow();
+        return Application::GetFrameWeld(xContainerWindow);
     }
 
     SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell const * i_pBasicIDE )
@@ -1529,8 +1516,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
 
             do  // artificial loop for flow control
             {
-                ScopedVclPtr<AbstractScriptSelectorDialog> pDlg(pFact->CreateScriptSelectorDialog(
-                    lcl_getDialogParent( xFrame, GetTopWindow() ), xFrame ));
+                ScopedVclPtr<AbstractScriptSelectorDialog> pDlg(pFact->CreateScriptSelectorDialog(lcl_getDialogParent(xFrame), xFrame));
                 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
                 if ( !pDlg )
                     break;
diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index d617524a1502..92bcf82a5a52 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -547,7 +547,7 @@ void SwFieldFuncPage::UpdateSubType()
 // call MacroBrowser, fill Listbox with Macros
 IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, Button *, void)
 {
-    if (GetFieldMgr().ChooseMacro())
+    if (GetFieldMgr().ChooseMacro(GetDialogFrameWeld()))
         UpdateSubType();
 }
 
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 64c93b7f1a07..cb94e102aa88 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1782,12 +1782,12 @@ void SwFieldType::GetFieldName_()
     }
 }
 
-bool SwFieldMgr::ChooseMacro()
+bool SwFieldMgr::ChooseMacro(weld::Window* pDialogParent)
 {
     bool bRet = false;
 
     // choose script dialog
-    OUString aScriptURL = SfxApplication::ChooseScript();
+    OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
 
     // the script selector dialog returns a valid script URL
     if ( !aScriptURL.isEmpty() )
diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx
index 2e6ba24ebeaf..46612d031f4c 100644
--- a/sw/source/uibase/inc/fldmgr.hxx
+++ b/sw/source/uibase/inc/fldmgr.hxx
@@ -44,6 +44,7 @@ class SbModule;
 class SvxMacroItem;
 class SvNumberFormatter;
 namespace vcl { class Window; }
+namespace weld { class Window; }
 enum class SwFieldIds : sal_uInt16;
 
 // the groups of fields
@@ -137,7 +138,7 @@ public:
 
     void            InsertFieldType(SwFieldType const & rType);
 
-    bool            ChooseMacro();
+    bool            ChooseMacro(weld::Window* pDialogParent);
     void            SetMacroPath(const OUString& rPath);
     const OUString& GetMacroPath() const         { return m_sMacroPath; }
     const OUString& GetMacroName() const         { return m_sMacroName; }


More information about the Libreoffice-commits mailing list