[Libreoffice-commits] core.git: extras/source include/sfx2 include/vcl sd/source sfx2/source sfx2/uiconfig sw/source vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Wed Mar 7 20:19:11 UTC 2018


 extras/source/glade/libreoffice-catalog.xml.in |    3 
 include/sfx2/new.hxx                           |   52 ++-
 include/vcl/weld.hxx                           |   30 ++
 sd/source/ui/dlg/sdpreslt.cxx                  |   11 
 sfx2/source/doc/new.cxx                        |  354 +++++++++----------------
 sfx2/source/inc/preview.hxx                    |   26 -
 sfx2/uiconfig/ui/loadtemplatedialog.ui         |  129 ++++++---
 sw/source/ui/dbui/mmdocselectpage.cxx          |    6 
 sw/source/uibase/app/docsh2.cxx                |   11 
 vcl/source/app/salvtables.cxx                  |   58 +++-
 vcl/unx/gtk3/gtk3gtkinst.cxx                   |   59 ++++
 11 files changed, 417 insertions(+), 322 deletions(-)

New commits:
commit 82925b574209d3971c05b9bd98a317683dd583a5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 6 12:25:35 2018 +0000

    weld SfxNewFileDialog
    
    Change-Id: I28b1aff90407bce7d04f10eed6a227c0970f9c0a
    Reviewed-on: https://gerrit.libreoffice.org/50878
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 3f7c5a71dc9c..c0a89747cb8a 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -247,9 +247,6 @@
     <glade-widget-class title="Token Window" name="swuilo-SwTokenWindow"
                         generic-name="Token Window" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
-    <glade-widget-class title="Template Preview Window" name="sfxlo-SfxPreviewWin"
-                        generic-name="Template Preview Window" parent="GtkDrawingArea"
-                        icon-name="widget-gtk-drawingarea"/>
     <glade-widget-class title="Template Local View" name="sfxlo-TemplateLocalView"
                         generic-name="Template Local View" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
diff --git a/include/sfx2/new.hxx b/include/sfx2/new.hxx
index 200a15e186bb..91539cb7a048 100644
--- a/include/sfx2/new.hxx
+++ b/include/sfx2/new.hxx
@@ -22,18 +22,17 @@
 #include <memory>
 #include <sal/config.h>
 #include <sfx2/dllapi.h>
+#include <sfx2/objsh.hxx>
 
-#include <vcl/button.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/fixed.hxx>
-#include <sfx2/basedlgs.hxx>
+#include <vcl/idle.hxx>
+#include <vcl/weld.hxx>
+#include <sfx2/doctempl.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
 
 class SfxObjectShellLock;
 class SfxObjectShell;
-
+class SfxPreviewWin_Impl;
 
 enum class SfxNewFileDialogMode {
     NONE, Preview, LoadTemplate
@@ -55,19 +54,42 @@ namespace o3tl
 
 #define RET_TEMPLATE_LOAD       100
 
-class SfxNewFileDialog_Impl;
-class SFX2_DLLPUBLIC SfxNewFileDialog : public SfxModalDialog
+class SFX2_DLLPUBLIC SfxNewFileDialog
 {
-    friend class SfxNewFileDialog_Impl;
-
 private:
-    std::unique_ptr< SfxNewFileDialog_Impl > pImpl;
+    std::unique_ptr<weld::Builder> m_xBuilder;
+    std::unique_ptr<weld::Dialog> m_xDialog;
+    std::unique_ptr<weld::TreeView> m_xRegionLb;
+    std::unique_ptr<weld::TreeView> m_xTemplateLb;
+    std::unique_ptr<weld::CheckButton> m_xTextStyleCB;
+    std::unique_ptr<weld::CheckButton> m_xFrameStyleCB;
+    std::unique_ptr<weld::CheckButton> m_xPageStyleCB;
+    std::unique_ptr<weld::CheckButton> m_xNumStyleCB;
+    std::unique_ptr<weld::CheckButton> m_xMergeStyleCB;
+    std::unique_ptr<weld::Button> m_xLoadFilePB;
+    std::unique_ptr<weld::Expander> m_xMoreBt;
+    std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewWin;
+    std::unique_ptr<weld::Label> m_xAltTitleFt;
+    Idle m_aPrevIdle;
+    OUString m_sLoadTemplate;
+
+    SfxNewFileDialogMode m_nFlags;
+    SfxDocumentTemplates m_aTemplates;
+    SfxObjectShellLock m_xDocShell;
+
+    DECL_LINK( Update, Timer *, void );
+
+    DECL_LINK(RegionSelect, weld::TreeView&, void);
+    DECL_LINK(TemplateSelect, weld::TreeView&, void);
+    DECL_LINK(DoubleClick, weld::TreeView&, void);
+    DECL_LINK(Expand, weld::Expander&, void);
+    sal_uInt16  GetSelectedTemplatePos() const;
 
 public:
-
-    SfxNewFileDialog(vcl::Window *pParent, SfxNewFileDialogMode nFlags);
-    virtual ~SfxNewFileDialog() override;
-    virtual void dispose() override;
+    SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags);
+    void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
+    short run() { return m_xDialog->run(); }
+    ~SfxNewFileDialog();
 
     // Returns false, when '- No -' is set as Template
     // Template names can only be obtained when IsTemplate() returns true.
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 9a46a191e7a0..b861b848e84c 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -99,10 +99,25 @@ protected:
 public:
     virtual void set_title(const OUString& rTitle) = 0;
     virtual OUString get_title() const = 0;
+    virtual void set_busy_cursor(bool bBusy) = 0;
 
     void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; }
 };
 
+class VCL_DLLPUBLIC WaitObject
+{
+private:
+    weld::Window* m_pWindow;
+
+public:
+    WaitObject(weld::Window* pWindow)
+        : m_pWindow(pWindow)
+    {
+        m_pWindow->set_busy_cursor(true);
+    }
+    ~WaitObject() { m_pWindow->set_busy_cursor(false); }
+};
+
 class VCL_DLLPUBLIC Dialog : virtual public Window
 {
 public:
@@ -455,6 +470,20 @@ public:
     virtual void set_selection(const Selection&) = 0;
 };
 
+class VCL_DLLPUBLIC Expander : virtual public Container
+{
+protected:
+    Link<Expander&, void> m_aExpandedHdl;
+
+    void signal_expanded() { m_aExpandedHdl.Call(*this); }
+
+public:
+    virtual bool get_expanded() const = 0;
+    virtual void set_expanded(bool bExpand) = 0;
+
+    void connect_expanded(const Link<Expander&, void>& rLink) { m_aExpandedHdl = rLink; }
+};
+
 class VCL_DLLPUBLIC DrawingArea : virtual public Widget
 {
 protected:
@@ -500,6 +529,7 @@ public:
     virtual TreeView* weld_tree_view(const OString& id, bool bTakeOwnership = false) = 0;
     virtual Label* weld_label(const OString& id, bool bTakeOwnership = false) = 0;
     virtual TextView* weld_text_view(const OString& id, bool bTakeOwnership = false) = 0;
+    virtual Expander* weld_expander(const OString& id, bool bTakeOwnership = false) = 0;
     virtual Entry* weld_entry(const OString& id, bool bTakeOwnership = false) = 0;
     virtual DrawingArea* weld_drawing_area(const OString& id, bool bTakeOwnership = false) = 0;
     virtual ~Builder() {}
diff --git a/sd/source/ui/dlg/sdpreslt.cxx b/sd/source/ui/dlg/sdpreslt.cxx
index 28c06f6e4982..7853e84c501e 100644
--- a/sd/source/ui/dlg/sdpreslt.cxx
+++ b/sd/source/ui/dlg/sdpreslt.cxx
@@ -179,13 +179,13 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLayoutHdl, ValueSet*, void)
  */
 IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
 {
-    VclPtrInstance< SfxNewFileDialog > pDlg(this, SfxNewFileDialogMode::Preview);
-    pDlg->SetText(SdResId(STR_LOAD_PRESENTATION_LAYOUT));
+    SfxNewFileDialog aDlg(GetFrameWeld(), SfxNewFileDialogMode::Preview);
+    aDlg.set_title(SdResId(STR_LOAD_PRESENTATION_LAYOUT));
 
     if(!IsReallyVisible())
         return;
 
-    sal_uInt16 nResult = pDlg->Execute();
+    sal_uInt16 nResult = aDlg.run();
     // Inserted update to force repaint
     Update();
 
@@ -195,9 +195,9 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
     {
         case RET_OK:
         {
-            if (pDlg->IsTemplate())
+            if (aDlg.IsTemplate())
             {
-                maName = pDlg->GetTemplateFileName();
+                maName = aDlg.GetTemplateFileName();
             }
             else
             {
@@ -210,7 +210,6 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, Button*, void)
         default:
             bCancel = true;
     }
-    pDlg.reset();
 
     if( !bCancel )
     {
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx
index 67c6b73a31da..2a50c964bc71 100644
--- a/sfx2/source/doc/new.cxx
+++ b/sfx2/source/doc/new.cxx
@@ -39,31 +39,28 @@
 #include <sfx2/docfile.hxx>
 #include <preview.hxx>
 #include <sfx2/printer.hxx>
+#include <unotools/viewoptions.hxx>
 #include <vcl/waitobj.hxx>
 
-void SfxPreviewBase_Impl::SetObjectShell(SfxObjectShell const * pObj)
+void SfxPreviewWin_Impl::SetObjectShell(SfxObjectShell const * pObj)
 {
     std::shared_ptr<GDIMetaFile> xFile = pObj
         ? pObj->GetPreviewMetaFile()
         : std::shared_ptr<GDIMetaFile>();
     xMetaFile = xFile;
-    Invalidate();
+    m_xDrawingArea->queue_draw();
 }
 
-SfxPreviewBase_Impl::SfxPreviewBase_Impl(vcl::Window* pParent, WinBits nStyle)
-    : Window(pParent, nStyle)
-    , xMetaFile()
+SfxPreviewWin_Impl::SfxPreviewWin_Impl(weld::DrawingArea* pDrawingArea)
+    : m_xDrawingArea(pDrawingArea)
 {
+    m_xDrawingArea->connect_size_allocate(LINK(this, SfxPreviewWin_Impl, DoResize));
+    m_xDrawingArea->connect_draw(LINK(this, SfxPreviewWin_Impl, DoPaint));
 }
 
-void SfxPreviewBase_Impl::Resize()
+IMPL_LINK_NOARG(SfxPreviewWin_Impl, DoResize, const Size&, void)
 {
-    Invalidate();
-}
-
-Size SfxPreviewBase_Impl::GetOptimalSize() const
-{
-    return LogicToPixel(Size(127, 129), MapMode(MapUnit::MapAppFont));
+    m_xDrawingArea->queue_draw();
 }
 
 void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile)
@@ -108,84 +105,31 @@ void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFil
     }
 }
 
-void SfxPreviewWin_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
+IMPL_LINK(SfxPreviewWin_Impl, DoPaint, vcl::RenderContext&, rRenderContext, void)
 {
     ImpPaint(rRenderContext, xMetaFile.get());
 }
 
-extern "C" SAL_DLLPUBLIC_EXPORT void makeSfxPreviewWin(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
+IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void)
 {
-    rRet = VclPtr<SfxPreviewWin_Impl>::Create(pParent, 0);
-}
-
-class SfxNewFileDialog_Impl
-{
-    VclPtr<ListBox>  m_pRegionLb;
-    VclPtr<ListBox>  m_pTemplateLb;
-
-    VclPtr<SfxPreviewWin_Impl> m_pPreviewWin;
-
-    VclPtr<CheckBox> m_pTextStyleCB;
-    VclPtr<CheckBox> m_pFrameStyleCB;
-    VclPtr<CheckBox> m_pPageStyleCB;
-    VclPtr<CheckBox> m_pNumStyleCB;
-    VclPtr<CheckBox> m_pMergeStyleCB;
-    VclPtr<PushButton> m_pLoadFilePB;
-
-    VclPtr<VclExpander> m_pMoreBt;
-    Idle aPrevIdle;
-    OUString aNone;
-    OUString sLoadTemplate;
-
-    SfxNewFileDialogMode nFlags;
-    SfxDocumentTemplates aTemplates;
-    SfxObjectShellLock xDocShell;
-    VclPtr<SfxNewFileDialog> pAntiImpl;
-
-    DECL_LINK( Update, Timer *, void );
-
-    DECL_LINK(RegionSelect, ListBox&, void);
-    DECL_LINK(TemplateSelect, ListBox&, void);
-    DECL_LINK(DoubleClick, ListBox&, void);
-    DECL_LINK(Expand, VclExpander&, void);
-    DECL_LINK(LoadFile, Button*, void);
-    sal_uInt16  GetSelectedTemplatePos() const;
-
-public:
-
-    SfxNewFileDialog_Impl(SfxNewFileDialog* pAntiImplP, SfxNewFileDialogMode nFlags);
-    ~SfxNewFileDialog_Impl();
-
-    // Returns sal_False if '- No -' is set as a template
-    // Template name can only be obtained if IsTemplate() is TRUE
-    bool IsTemplate() const;
-    OUString GetTemplateFileName() const;
-
-    SfxTemplateFlags GetTemplateFlags() const;
-    void             SetTemplateFlags(SfxTemplateFlags nSet);
-};
-
-IMPL_LINK_NOARG(SfxNewFileDialog_Impl, Update, Timer*, void)
-{
-    if (xDocShell.Is())
+    if (m_xDocShell.Is())
     {
-        if (xDocShell->GetProgress())
+        if (m_xDocShell->GetProgress())
             return;
-        xDocShell.Clear();
+        m_xDocShell.Clear();
     }
 
     const sal_uInt16 nEntry = GetSelectedTemplatePos();
     if (!nEntry)
     {
-        m_pPreviewWin->Invalidate();
-        m_pPreviewWin->SetObjectShell( nullptr);
+        m_xPreviewWin->queue_draw();
+        m_xPreviewWin->SetObjectShell(nullptr);
         return;
     }
 
-    if (m_pMoreBt->get_expanded() && (nFlags == SfxNewFileDialogMode::Preview))
+    if (m_xMoreBt->get_expanded() && (m_nFlags == SfxNewFileDialogMode::Preview))
     {
-
-        OUString aFileName = aTemplates.GetPath(m_pRegionLb->GetSelectedEntryPos(), nEntry - 1);
+        OUString aFileName = m_aTemplates.GetPath(m_xRegionLb->get_selected_index(), nEntry - 1);
         INetURLObject aTestObj(aFileName);
         if (aTestObj.GetProtocol() == INetProtocol::NotValid)
         {
@@ -204,254 +148,212 @@ IMPL_LINK_NOARG(SfxNewFileDialog_Impl, Update, Timer*, void)
                 // ??? HasName() MM
                 if (INetURLObject( pTmp->GetMedium()->GetName() ) == aObj)
                 {
-                    xDocShell = pTmp;
+                    m_xDocShell = pTmp;
                     break;
                 }
         }
 
-        if (!xDocShell.Is())
+        if (!m_xDocShell.Is())
         {
-            SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, pAntiImpl->GetFrameWeld());
+            SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, m_xDialog.get());
             SfxApplication *pSfxApp = SfxGetpApp();
             SfxItemSet* pSet = new SfxAllItemSet(pSfxApp->GetPool());
             pSet->Put(SfxBoolItem(SID_TEMPLATE, true));
             pSet->Put(SfxBoolItem(SID_PREVIEW, true));
-            ErrCode lErr = pSfxApp->LoadTemplate(xDocShell, aFileName, pSet);
+            ErrCode lErr = pSfxApp->LoadTemplate(m_xDocShell, aFileName, pSet);
             if (lErr)
                 ErrorHandler::HandleError(lErr);
-            if (!xDocShell.Is())
+            if (!m_xDocShell.Is())
             {
-                m_pPreviewWin->SetObjectShell(nullptr);
+                m_xPreviewWin->SetObjectShell(nullptr);
                 return;
             }
         }
 
-        m_pPreviewWin->SetObjectShell(xDocShell);
+        m_xPreviewWin->SetObjectShell(m_xDocShell);
     }
 }
 
-IMPL_LINK( SfxNewFileDialog_Impl, RegionSelect, ListBox&, rBox, void )
+IMPL_LINK( SfxNewFileDialog, RegionSelect, weld::TreeView&, rBox, void )
 {
-    if (xDocShell.Is() && xDocShell->GetProgress())
+    if (m_xDocShell.Is() && m_xDocShell->GetProgress())
         return;
 
-    const sal_uInt16 nRegion = rBox.GetSelectedEntryPos();
-    const sal_uInt16 nCount = aTemplates.GetRegionCount()? aTemplates.GetCount(nRegion): 0;
-    m_pTemplateLb->SetUpdateMode(false);
-    m_pTemplateLb->Clear();
-    OUString aSel = m_pRegionLb->GetSelectedEntry();
+    const sal_uInt16 nRegion = rBox.get_selected_index();
+    const sal_uInt16 nCount = m_aTemplates.GetRegionCount() ? m_aTemplates.GetCount(nRegion): 0;
+    m_xTemplateLb->freeze();
+    m_xTemplateLb->clear();
+    OUString aSel = m_xRegionLb->get_selected();
     sal_Int32 nc = aSel.indexOf('(');
     if (nc != -1 && nc != 0)
         aSel = aSel.replaceAt(nc-1, 1, "");
     if ( aSel.compareToIgnoreAsciiCase( SfxResId(STR_STANDARD) ) == 0 )
-        m_pTemplateLb->InsertEntry(aNone);
+        m_xTemplateLb->append(SfxResId(STR_NONE));
     for (sal_uInt16 i = 0; i < nCount; ++i)
-        m_pTemplateLb->InsertEntry(aTemplates.GetName(nRegion, i));
-    m_pTemplateLb->SelectEntryPos(0);
-    m_pTemplateLb->SetUpdateMode(true);
-    m_pTemplateLb->Invalidate();
-    m_pTemplateLb->Update();
-    TemplateSelect(*m_pTemplateLb);
+        m_xTemplateLb->append(m_aTemplates.GetName(nRegion, i));
+    m_xTemplateLb->thaw();
+    m_xTemplateLb->select(0);
 }
 
-IMPL_LINK_NOARG(SfxNewFileDialog_Impl, Expand, VclExpander&, void)
+IMPL_LINK_NOARG(SfxNewFileDialog, Expand, weld::Expander&, void)
 {
-    TemplateSelect(*m_pTemplateLb);
+    TemplateSelect(*m_xTemplateLb);
 }
 
-IMPL_LINK_NOARG(SfxNewFileDialog_Impl, TemplateSelect, ListBox&, void)
+IMPL_LINK_NOARG(SfxNewFileDialog, TemplateSelect, weld::TreeView&, void)
 {
     // Still loading
-    if ( xDocShell && xDocShell->GetProgress() )
+    if (m_xDocShell && m_xDocShell->GetProgress())
         return;
 
-    if (!m_pMoreBt->get_expanded())
+    if (!m_xMoreBt->get_expanded())
+    {
         // Dialog is not opened
         return;
+    }
 
-    aPrevIdle.Start();
+    m_aPrevIdle.Start();
 }
 
-IMPL_LINK_NOARG( SfxNewFileDialog_Impl, DoubleClick, ListBox&, void )
+IMPL_LINK_NOARG( SfxNewFileDialog, DoubleClick, weld::TreeView&, void )
 {
     // Still loading
-    if ( !xDocShell.Is() || !xDocShell->GetProgress() )
-        pAntiImpl->EndDialog(RET_OK);
+    if (!m_xDocShell.Is() || !m_xDocShell->GetProgress())
+        m_xDialog->response(RET_OK);
 }
 
-IMPL_LINK_NOARG(SfxNewFileDialog_Impl, LoadFile, Button*, void)
+sal_uInt16  SfxNewFileDialog::GetSelectedTemplatePos() const
 {
-    pAntiImpl->EndDialog(RET_TEMPLATE_LOAD);
-}
-
-sal_uInt16  SfxNewFileDialog_Impl::GetSelectedTemplatePos() const
-{
-    sal_uInt16 nEntry = m_pTemplateLb->GetSelectedEntryPos();
-    OUString aSel = m_pRegionLb->GetSelectedEntry();
+    int nEntry = m_xTemplateLb->get_selected_index();
+    if (nEntry == -1)
+        return 0;
+    OUString aSel = m_xRegionLb->get_selected();
     sal_Int32 nc = aSel.indexOf('(');
     if (nc != -1 && nc != 0)
         aSel = aSel.replaceAt(nc-1, 1, "");
     if ( aSel.compareToIgnoreAsciiCase(SfxResId(STR_STANDARD)) != 0 )
         nEntry++;
-    if (!m_pTemplateLb->GetSelectedEntryCount())
-        nEntry = 0;
     return nEntry;
 }
 
-bool SfxNewFileDialog_Impl::IsTemplate() const
-{
-    return GetSelectedTemplatePos()!=0;
-
-}
-
-OUString SfxNewFileDialog_Impl::GetTemplateFileName() const
-{
-    if(!IsTemplate() || !aTemplates.GetRegionCount())
-        return OUString();
-    return aTemplates.GetPath(m_pRegionLb->GetSelectedEntryPos(),
-                              GetSelectedTemplatePos()-1);
-}
-
-SfxTemplateFlags  SfxNewFileDialog_Impl::GetTemplateFlags()const
+SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags)
+    : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/loadtemplatedialog.ui"))
+    , m_xDialog(m_xBuilder->weld_dialog("LoadTemplateDialog"))
+    , m_xRegionLb(m_xBuilder->weld_tree_view("categories"))
+    , m_xTemplateLb(m_xBuilder->weld_tree_view("templates"))
+    , m_xTextStyleCB(m_xBuilder->weld_check_button("text"))
+    , m_xFrameStyleCB(m_xBuilder->weld_check_button("frame"))
+    , m_xPageStyleCB(m_xBuilder->weld_check_button("pages"))
+    , m_xNumStyleCB(m_xBuilder->weld_check_button("numbering"))
+    , m_xMergeStyleCB(m_xBuilder->weld_check_button("overwrite"))
+    , m_xLoadFilePB(m_xBuilder->weld_button("fromfile"))
+    , m_xMoreBt(m_xBuilder->weld_expander("expander"))
+    , m_xPreviewWin(new SfxPreviewWin_Impl(m_xBuilder->weld_drawing_area("image")))
+    , m_xAltTitleFt(m_xBuilder->weld_label("alttitle"))
+    , m_sLoadTemplate(m_xAltTitleFt->get_label())
+    , m_nFlags(nFlags)
 {
-    SfxTemplateFlags nRet = m_pTextStyleCB->IsChecked() ? SfxTemplateFlags::LOAD_TEXT_STYLES : SfxTemplateFlags::NONE;
-    if(m_pFrameStyleCB->IsChecked())
-        nRet |= SfxTemplateFlags::LOAD_FRAME_STYLES;
-    if(m_pPageStyleCB->IsChecked())
-        nRet |= SfxTemplateFlags::LOAD_PAGE_STYLES;
-    if(m_pNumStyleCB->IsChecked())
-        nRet |= SfxTemplateFlags::LOAD_NUM_STYLES;
-    if(m_pMergeStyleCB->IsChecked())
-        nRet |= SfxTemplateFlags::MERGE_STYLES;
-    return nRet;
-}
-
-void    SfxNewFileDialog_Impl::SetTemplateFlags(SfxTemplateFlags nSet)
-{
-    m_pTextStyleCB->Check(  bool(nSet & SfxTemplateFlags::LOAD_TEXT_STYLES ));
-    m_pFrameStyleCB->Check( bool(nSet & SfxTemplateFlags::LOAD_FRAME_STYLES));
-    m_pPageStyleCB->Check(  bool(nSet & SfxTemplateFlags::LOAD_PAGE_STYLES ));
-    m_pNumStyleCB->Check(   bool(nSet & SfxTemplateFlags::LOAD_NUM_STYLES  ));
-    m_pMergeStyleCB->Check( bool(nSet & SfxTemplateFlags::MERGE_STYLES     ));
-}
-
-
-SfxNewFileDialog_Impl::SfxNewFileDialog_Impl(
-    SfxNewFileDialog* pAntiImplP, SfxNewFileDialogMode nFl)
-    : aNone(SfxResId(STR_NONE))
-    , nFlags(nFl)
-    , pAntiImpl(pAntiImplP)
-{
-    pAntiImplP->get(m_pRegionLb, "categories");
-    pAntiImplP->get(m_pTemplateLb, "templates");
-
-    Size aSize(m_pRegionLb->LogicToPixel(Size(127, 72), MapMode(MapUnit::MapAppFont)));
-    m_pRegionLb->set_width_request(aSize.Width());
-    m_pRegionLb->set_height_request(aSize.Height());
-    m_pTemplateLb->set_width_request(aSize.Width());
-    m_pTemplateLb->set_height_request(aSize.Height());
-
-    pAntiImplP->get(m_pTextStyleCB, "text");
-    pAntiImplP->get(m_pFrameStyleCB, "frame");
-    pAntiImplP->get(m_pPageStyleCB, "pages");
-    pAntiImplP->get(m_pNumStyleCB, "numbering");
-    pAntiImplP->get(m_pMergeStyleCB, "overwrite");
-    pAntiImplP->get(m_pMoreBt, "expander");
-    pAntiImplP->get(m_pPreviewWin, "image");
-    pAntiImplP->get(m_pLoadFilePB, "fromfile");
-    sLoadTemplate = pAntiImplP->get<FixedText>("alttitle")->GetText();
+    const int nWidth = m_xRegionLb->get_approximate_char_width() * 32;
+    const int nHeight = m_xRegionLb->get_height_rows(8);
+    m_xRegionLb->set_size_request(nWidth, nHeight);
+    m_xTemplateLb->set_size_request(nWidth, nHeight);
+    m_xPreviewWin->set_size_request(nWidth, nWidth);
 
     if (nFlags == SfxNewFileDialogMode::NONE)
-        m_pMoreBt->Hide();
+        m_xMoreBt->hide();
     else if(SfxNewFileDialogMode::LoadTemplate == nFlags)
     {
-        m_pLoadFilePB->SetClickHdl(LINK(this, SfxNewFileDialog_Impl, LoadFile));
-        m_pLoadFilePB->Show();
-        m_pTextStyleCB->Show();
-        m_pFrameStyleCB->Show();
-        m_pPageStyleCB->Show();
-        m_pNumStyleCB->Show();
-        m_pMergeStyleCB->Show();
-        m_pMoreBt->Hide();
-        m_pTextStyleCB->Check();
-        pAntiImplP->SetText(sLoadTemplate);
+        m_xLoadFilePB->show();
+        m_xTextStyleCB->show();
+        m_xFrameStyleCB->show();
+        m_xPageStyleCB->show();
+        m_xNumStyleCB->show();
+        m_xMergeStyleCB->show();
+        m_xMoreBt->hide();
+        m_xTextStyleCB->set_active(true);
+        m_xDialog->set_title(m_sLoadTemplate);
     }
     else
     {
-        m_pMoreBt->SetExpandedHdl(LINK(this, SfxNewFileDialog_Impl, Expand));
-        m_pPreviewWin->Show();
+        m_xMoreBt->connect_expanded(LINK(this, SfxNewFileDialog, Expand));
+        m_xPreviewWin->show();
     }
 
-    OUString &rExtra = pAntiImplP->GetExtraData();
-    bool bExpand = !rExtra.isEmpty() && rExtra[0] == 'Y';
-    m_pMoreBt->set_expanded(bExpand && (nFlags != SfxNewFileDialogMode::NONE));
+    OUString sExtraData;
+    SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+    if (aDlgOpt.Exists())
+    {
+        css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem");
+        aUserItem >>= sExtraData;
+    }
 
-    m_pTemplateLb->SetSelectHdl(LINK(this, SfxNewFileDialog_Impl, TemplateSelect));
-    m_pTemplateLb->SetDoubleClickHdl(LINK(this, SfxNewFileDialog_Impl, DoubleClick));
+    bool bExpand = !sExtraData.isEmpty() && sExtraData[0] == 'Y';
+    m_xMoreBt->set_expanded(bExpand && (nFlags != SfxNewFileDialogMode::NONE));
+
+    m_xTemplateLb->connect_changed(LINK(this, SfxNewFileDialog, TemplateSelect));
+    m_xTemplateLb->connect_row_activated(LINK(this, SfxNewFileDialog, DoubleClick));
 
     // update the template configuration if necessary
     {
-        WaitObject aWaitCursor( pAntiImplP->GetParent() );
-        aTemplates.Update();
+        weld::WaitObject aWaitCursor(m_xDialog.get());
+        m_aTemplates.Update();
     }
     // fill the list boxes
-    const sal_uInt16 nCount = aTemplates.GetRegionCount();
+    const sal_uInt16 nCount = m_aTemplates.GetRegionCount();
     if (nCount)
     {
         for(sal_uInt16 i = 0; i < nCount; ++i)
-            m_pRegionLb->InsertEntry(aTemplates.GetFullRegionName(i));
-        m_pRegionLb->SetSelectHdl(LINK(this, SfxNewFileDialog_Impl, RegionSelect));
+            m_xRegionLb->append(m_aTemplates.GetFullRegionName(i));
+        m_xRegionLb->connect_changed(LINK(this, SfxNewFileDialog, RegionSelect));
     }
 
-    aPrevIdle.SetPriority( TaskPriority::LOWEST );
-    aPrevIdle.SetInvokeHandler( LINK( this, SfxNewFileDialog_Impl, Update));
+    m_aPrevIdle.SetPriority( TaskPriority::LOWEST );
+    m_aPrevIdle.SetInvokeHandler( LINK( this, SfxNewFileDialog, Update));
 
-    m_pRegionLb->SelectEntryPos(0);
-    RegionSelect(*m_pRegionLb);
-}
-
-SfxNewFileDialog_Impl::~SfxNewFileDialog_Impl()
-{
-    OUString &rExtra = pAntiImpl->GetExtraData();
-    rExtra = m_pMoreBt->get_expanded() ? OUString("Y") : OUString("N");
-}
-
-SfxNewFileDialog::SfxNewFileDialog(vcl::Window *pParent, SfxNewFileDialogMode nFlags)
-    : SfxModalDialog(pParent, "LoadTemplateDialog",
-        "sfx/ui/loadtemplatedialog.ui"),
-      pImpl( new SfxNewFileDialog_Impl(this, nFlags) )
-{
+    m_xRegionLb->select(0);
+    RegionSelect(*m_xRegionLb);
 }
 
 SfxNewFileDialog::~SfxNewFileDialog()
 {
-    disposeOnce();
-}
-
-void SfxNewFileDialog::dispose()
-{
-    pImpl.reset();
-    SfxModalDialog::dispose();
+    SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+    aDlgOpt.SetUserItem("UserItem", css::uno::makeAny(m_xMoreBt->get_expanded() ? OUString("Y") : OUString("N")));
 }
 
 bool SfxNewFileDialog::IsTemplate() const
 {
-    return pImpl->IsTemplate();
+    return GetSelectedTemplatePos()!=0;
 }
 
 OUString SfxNewFileDialog::GetTemplateFileName() const
 {
-    return pImpl->GetTemplateFileName();
+    if (!IsTemplate() || !m_aTemplates.GetRegionCount())
+        return OUString();
+    return m_aTemplates.GetPath(m_xRegionLb->get_selected_index(),
+                              GetSelectedTemplatePos()-1);
 }
 
 SfxTemplateFlags SfxNewFileDialog::GetTemplateFlags()const
 {
-    return pImpl->GetTemplateFlags();
+    SfxTemplateFlags nRet = m_xTextStyleCB->get_active() ? SfxTemplateFlags::LOAD_TEXT_STYLES : SfxTemplateFlags::NONE;
+    if(m_xFrameStyleCB->get_active())
+        nRet |= SfxTemplateFlags::LOAD_FRAME_STYLES;
+    if(m_xPageStyleCB->get_active())
+        nRet |= SfxTemplateFlags::LOAD_PAGE_STYLES;
+    if(m_xNumStyleCB->get_active())
+        nRet |= SfxTemplateFlags::LOAD_NUM_STYLES;
+    if(m_xMergeStyleCB->get_active())
+        nRet |= SfxTemplateFlags::MERGE_STYLES;
+    return nRet;
 }
 
 void SfxNewFileDialog::SetTemplateFlags(SfxTemplateFlags nSet)
 {
-    pImpl->SetTemplateFlags(nSet);
+    m_xTextStyleCB->set_active(  bool(nSet & SfxTemplateFlags::LOAD_TEXT_STYLES ));
+    m_xFrameStyleCB->set_active( bool(nSet & SfxTemplateFlags::LOAD_FRAME_STYLES));
+    m_xPageStyleCB->set_active(  bool(nSet & SfxTemplateFlags::LOAD_PAGE_STYLES ));
+    m_xNumStyleCB->set_active(   bool(nSet & SfxTemplateFlags::LOAD_NUM_STYLES  ));
+    m_xMergeStyleCB->set_active( bool(nSet & SfxTemplateFlags::MERGE_STYLES     ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/preview.hxx b/sfx2/source/inc/preview.hxx
index 890d9b2298df..3a747db969f2 100644
--- a/sfx2/source/inc/preview.hxx
+++ b/sfx2/source/inc/preview.hxx
@@ -19,32 +19,24 @@
 #ifndef INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX
 #define INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX
 
-#include <sfx2/doctempl.hxx>
-#include <sfx2/basedlgs.hxx>
+#include <tools/link.hxx>
 
 class SfxObjectShell;
 class GDIMetaFile;
 
-class SfxPreviewBase_Impl : public vcl::Window
+class SfxPreviewWin_Impl
 {
 protected:
     std::shared_ptr<GDIMetaFile> xMetaFile;
+    std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
 public:
-    SfxPreviewBase_Impl(vcl::Window* pParent, WinBits nStyle);
+    SfxPreviewWin_Impl(weld::DrawingArea* pArea);
     void            SetObjectShell( SfxObjectShell const * pObj );
-    virtual void    Resize() override;
-    virtual Size    GetOptimalSize() const override;
-};
-
-class SfxPreviewWin_Impl: public SfxPreviewBase_Impl
-{
-protected:
-    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
-public:
-    SfxPreviewWin_Impl(vcl::Window* pParent, WinBits nStyle)
-        : SfxPreviewBase_Impl(pParent, nStyle)
-    {}
-
+    DECL_LINK(DoPaint, vcl::RenderContext&, void);
+    DECL_LINK(DoResize, const Size& rSize, void);
+    void queue_draw() { m_xDrawingArea->queue_draw(); }
+    void show() { m_xDrawingArea->show(); }
+    void set_size_request(int nWidth, int nHeight) { m_xDrawingArea->set_size_request(nWidth, nHeight); }
     static void ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile);
 };
 
diff --git a/sfx2/uiconfig/ui/loadtemplatedialog.ui b/sfx2/uiconfig/ui/loadtemplatedialog.ui
index 38ea3f9fb9d4..e33497f2f6d6 100644
--- a/sfx2/uiconfig/ui/loadtemplatedialog.ui
+++ b/sfx2/uiconfig/ui/loadtemplatedialog.ui
@@ -1,8 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.20.2 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
-  <!-- interface-requires LibreOffice 1.0 -->
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="LoadTemplateDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -20,14 +31,12 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="ok">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
+              <object class="GtkButton" id="fromfile">
+                <property name="label" translatable="yes" context="loadtemplatedialog|fromfile">From File...</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="use_stock">True</property>
+                <property name="no_show_all">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -51,11 +60,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="help">
-                <property name="label">gtk-help</property>
+              <object class="GtkButton" id="ok">
+                <property name="label">gtk-ok</property>
                 <property name="visible">True</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="use_stock">True</property>
               </object>
@@ -66,12 +76,13 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="fromfile">
-                <property name="label" translatable="yes" context="loadtemplatedialog|fromfile">From File...</property>
+              <object class="GtkButton" id="help">
+                <property name="label">gtk-help</property>
+                <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="no_show_all">True</property>
-                <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -111,11 +122,36 @@
                     <property name="top_padding">6</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <object class="GtkTreeView" id="categories:border">
+                      <object class="GtkScrolledWindow">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection1"/>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="categories">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="model">liststore1</property>
+                            <property name="headers_visible">False</property>
+                            <property name="headers_clickable">False</property>
+                            <property name="enable_search">False</property>
+                            <property name="show_expanders">False</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="treeview-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>
@@ -135,8 +171,6 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -155,11 +189,36 @@
                     <property name="top_padding">6</property>
                     <property name="left_padding">12</property>
                     <child>
-                      <object class="GtkTreeView" id="templates:border">
+                      <object class="GtkScrolledWindow">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection3"/>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="templates">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="model">liststore2</property>
+                            <property name="headers_visible">False</property>
+                            <property name="headers_clickable">False</property>
+                            <property name="enable_search">False</property>
+                            <property name="show_expanders">False</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="treeview-selection2"/>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
                         </child>
                       </object>
                     </child>
@@ -179,8 +238,6 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -203,8 +260,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -220,8 +275,6 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -237,8 +290,6 @@
                   <packing>
                     <property name="left_attach">2</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -254,8 +305,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -271,8 +320,6 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -283,7 +330,6 @@
                 <property name="left_attach">0</property>
                 <property name="top_attach">1</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -296,20 +342,20 @@
                 <property name="left_attach">0</property>
                 <property name="top_attach">3</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkExpander" id="expander">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="resize_toplevel">True</property>
                 <child>
                   <object class="GtkGrid" id="previewgrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="margin_top">6</property>
                     <child>
-                      <object class="sfxlo-SfxPreviewWin" id="image">
+                      <object class="GtkDrawingArea" id="image">
                         <property name="can_focus">False</property>
                         <property name="no_show_all">True</property>
                         <property name="halign">start</property>
@@ -318,8 +364,6 @@
                       <packing>
                         <property name="left_attach">0</property>
                         <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
                       </packing>
                     </child>
                   </object>
@@ -337,7 +381,6 @@
                 <property name="left_attach">0</property>
                 <property name="top_attach">2</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
           </object>
@@ -350,9 +393,13 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="-5">ok</action-widget>
+      <action-widget response="100">fromfile</action-widget>
       <action-widget response="-6">cancel</action-widget>
+      <action-widget response="-5">ok</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx
index 5f1c0ffc1314..b869e40cd5c7 100644
--- a/sw/source/ui/dbui/mmdocselectpage.cxx
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -123,12 +123,12 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, Button*, pButton, void)
     if(bTemplate)
     {
         m_pLoadTemplateRB->Check();
-        VclPtrInstance< SfxNewFileDialog > pNewFileDlg(this, SfxNewFileDialogMode::NONE);
-        sal_uInt16 nRet = pNewFileDlg->Execute();
+        SfxNewFileDialog aNewFileDlg(GetFrameWeld(), SfxNewFileDialogMode::NONE);
+        sal_uInt16 nRet = aNewFileDlg.run();
         if(RET_TEMPLATE_LOAD == nRet)
             bTemplate = false;
         else if(RET_CANCEL != nRet)
-            m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
+            m_sLoadTemplateName = aNewFileDlg.GetTemplateFileName();
     }
     else
         m_pLoadDocRB->Check();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 65b718c52f67..3f72351acd3d 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -500,11 +500,10 @@ void SwDocShell::Execute(SfxRequest& rReq)
                 if ( aFileName.isEmpty() )
                 {
                     SvtPathOptions aPathOpt;
-                    ScopedVclPtr<SfxNewFileDialog> pNewFileDlg(
-                        VclPtr<SfxNewFileDialog>::Create(&GetView()->GetViewFrame()->GetWindow(), SfxNewFileDialogMode::LoadTemplate));
-                    pNewFileDlg->SetTemplateFlags(nFlags);
+                    SfxNewFileDialog aNewFileDlg(GetView()->GetViewFrame()->GetWindow().GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate);
+                    aNewFileDlg.SetTemplateFlags(nFlags);
 
-                    nRet = pNewFileDlg->Execute();
+                    nRet = aNewFileDlg.run();
                     if(RET_TEMPLATE_LOAD == nRet)
                     {
                         FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE,
@@ -560,10 +559,10 @@ void SwDocShell::Execute(SfxRequest& rReq)
                     }
                     else if( RET_OK == nRet)
                     {
-                        aFileName = pNewFileDlg->GetTemplateFileName();
+                        aFileName = aNewFileDlg.GetTemplateFileName();
                     }
 
-                    nFlags = pNewFileDlg->GetTemplateFlags();
+                    nFlags = aNewFileDlg.GetTemplateFlags();
                     rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
                     rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, static_cast<long>(nFlags) ) );
                 }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 02626e61b2d2..b01cff2f25b9 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -399,6 +399,14 @@ public:
         return false;
     }
 
+    virtual void set_busy_cursor(bool bBusy) override
+    {
+        if (bBusy)
+            m_xWindow->EnterWait();
+        else
+            m_xWindow->LeaveWait();
+    }
+
     virtual ~SalInstanceWindow() override
     {
         clear_child_help(m_xWindow);
@@ -861,12 +869,12 @@ public:
 
     virtual void select(int pos) override
     {
+        assert(m_xTreeView->IsUpdateMode() && "don't select when frozen");
         if (pos == -1)
-        {
             m_xTreeView->SetNoSelection();
-            return;
-        }
-        m_xTreeView->SelectEntryPos(pos);
+        else
+            m_xTreeView->SelectEntryPos(pos);
+        m_xTreeView->Select();
     }
 
     virtual OUString get_selected() override
@@ -1063,6 +1071,42 @@ public:
     }
 };
 
+class SalInstanceExpander : public SalInstanceContainer, public virtual weld::Expander
+{
+private:
+    VclPtr<VclExpander> m_xExpander;
+
+    DECL_LINK(ExpandedHdl, VclExpander&, void);
+
+public:
+    SalInstanceExpander(VclExpander* pExpander, bool bTakeOwnership)
+        : SalInstanceContainer(pExpander, bTakeOwnership)
+        , m_xExpander(pExpander)
+    {
+        m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl));
+    }
+
+    virtual bool get_expanded() const override
+    {
+        return m_xExpander->get_expanded();
+    }
+
+    virtual void set_expanded(bool bExpand) override
+    {
+        m_xExpander->set_expanded(bExpand);
+    }
+
+    virtual ~SalInstanceExpander() override
+    {
+        m_xExpander->SetExpandedHdl(Link<VclExpander&, void>());
+    }
+};
+
+IMPL_LINK_NOARG(SalInstanceExpander, ExpandedHdl, VclExpander&, void)
+{
+    signal_expanded();
+}
+
 class SalInstanceDrawingArea : public SalInstanceWidget, public virtual weld::DrawingArea
 {
 private:
@@ -1365,6 +1409,12 @@ public:
         return pTextView ? new SalInstanceTextView(pTextView, bTakeOwnership) : nullptr;
     }
 
+    virtual weld::Expander* weld_expander(const OString &id, bool bTakeOwnership) override
+    {
+        VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
+        return pExpander ? new SalInstanceExpander(pExpander, bTakeOwnership) : nullptr;
+    }
+
     virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override
     {
         VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id);
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index b3071c9a4ee4..ef8060662269 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1404,6 +1404,17 @@ public:
         const gchar* pStr = gtk_window_get_title(m_pWindow);
         return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
     }
+
+    virtual void set_busy_cursor(bool bBusy) override
+    {
+        gtk_widget_realize(m_pWidget);
+        GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
+        GdkCursor *pCursor = bBusy ? gdk_cursor_new_from_name(pDisplay, "progress") : nullptr;
+        gdk_window_set_cursor(gtk_widget_get_window(m_pWidget), pCursor);
+        gdk_display_flush(pDisplay);
+        if (pCursor)
+            g_object_unref(pCursor);
+    }
 };
 
 namespace
@@ -2027,6 +2038,7 @@ public:
 
     virtual void select(int pos) override
     {
+        assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen");
         if (pos != -1)
         {
             GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
@@ -2406,7 +2418,7 @@ public:
     GtkInstanceComboBoxText(GtkComboBoxText* pComboBoxText, bool bTakeOwnership)
         : GtkInstanceContainer(GTK_CONTAINER(pComboBoxText), bTakeOwnership)
         , m_pComboBoxText(pComboBoxText)
-        , m_nSignalId(g_signal_connect(pComboBoxText, "changed", G_CALLBACK(signalChanged), this))
+        , m_nSignalId(g_signal_connect(m_pComboBoxText, "changed", G_CALLBACK(signalChanged), this))
     {
     }
 
@@ -2527,6 +2539,42 @@ public:
     }
 };
 
+class GtkInstanceExpander : public GtkInstanceContainer, public virtual weld::Expander
+{
+private:
+    GtkExpander* m_pExpander;
+    gulong m_nSignalId;
+
+    static void signalExpanded(GtkExpander*, GParamSpec *, gpointer widget)
+    {
+        GtkInstanceExpander* pThis = static_cast<GtkInstanceExpander*>(widget);
+        pThis->signal_expanded();
+    }
+
+public:
+    GtkInstanceExpander(GtkExpander* pExpander, bool bTakeOwnership)
+        : GtkInstanceContainer(GTK_CONTAINER(pExpander), bTakeOwnership)
+        , m_pExpander(pExpander)
+        , m_nSignalId(g_signal_connect(m_pExpander, "notify::expanded", G_CALLBACK(signalExpanded), this))
+    {
+    }
+
+    virtual bool get_expanded() const override
+    {
+        return gtk_expander_get_expanded(m_pExpander);
+    }
+
+    virtual void set_expanded(bool bExpand) override
+    {
+        gtk_expander_set_expanded(m_pExpander, bExpand);
+    }
+
+    virtual ~GtkInstanceExpander() override
+    {
+        g_signal_handler_disconnect(m_pExpander, m_nSignalId);
+    }
+};
+
 namespace
 {
     gboolean signalTooltipQuery(GtkWidget* pWidget, gint /*x*/, gint /*y*/,
@@ -2810,6 +2858,15 @@ public:
         return new GtkInstanceTextView(pTextView, bTakeOwnership);
     }
 
+    virtual weld::Expander* weld_expander(const OString &id, bool bTakeOwnership) override
+    {
+        GtkExpander* pExpander = GTK_EXPANDER(gtk_builder_get_object(m_pBuilder, id.getStr()));
+        if (!pExpander)
+            return nullptr;
+        auto_add_parentless_widgets_to_container(GTK_WIDGET(pExpander));
+        return new GtkInstanceExpander(pExpander, bTakeOwnership);
+    }
+
     virtual weld::DrawingArea* weld_drawing_area(const OString &id, bool bTakeOwnership) override
     {
         GtkDrawingArea* pDrawingArea = GTK_DRAWING_AREA(gtk_builder_get_object(m_pBuilder, id.getStr()));


More information about the Libreoffice-commits mailing list