[Libreoffice-commits] core.git: cui/source dbaccess/source fpicker/source include/cui include/sfx2 include/svtools include/vcl sc/source sd/source sfx2/inc sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk solenv/sanitizers starmath/inc sw/source vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 07:46:46 UTC 2020


 cui/source/inc/acccfg.hxx                       |    1 
 cui/source/inc/numpages.hxx                     |    1 
 dbaccess/source/ui/inc/directsql.hxx            |    2 
 fpicker/source/office/iodlg.cxx                 |    1 
 include/cui/cuicharmap.hxx                      |    1 
 include/sfx2/strings.hrc                        |    6 
 include/sfx2/styfitem.hxx                       |    7 
 include/sfx2/tabdlg.hxx                         |    2 
 include/sfx2/templatelocalview.hxx              |    1 
 include/sfx2/templdlg.hxx                       |    6 
 include/svtools/prnsetup.hxx                    |    1 
 include/svtools/valueset.hxx                    |    1 
 include/vcl/weld.hxx                            |    8 
 include/vcl/weldutils.hxx                       |    3 
 sc/source/ui/app/scmod.cxx                      |    4 
 sc/source/ui/dbgui/csvcontrol.cxx               |    1 
 sc/source/ui/inc/AccessibleDocument.hxx         |    1 
 sc/source/ui/inc/content.hxx                    |    1 
 sd/source/ui/animations/CustomAnimationList.cxx |    2 
 sd/source/ui/animations/CustomAnimationList.hxx |    1 
 sd/source/ui/app/sdmod2.cxx                     |    4 
 sd/source/ui/inc/sdtreelb.hxx                   |    1 
 sd/source/ui/sidebar/LayoutMenu.hxx             |    1 
 sd/source/ui/sidebar/MasterPagesSelector.hxx    |    1 
 sfx2/UIConfig_sfx.mk                            |    5 
 sfx2/inc/bitmaps.hlst                           |    4 
 sfx2/source/dialog/styfitem.cxx                 |    2 
 sfx2/source/dialog/templdlg.cxx                 | 1532 +++++++++---------------
 sfx2/source/dialog/tplcitem.cxx                 |    6 
 sfx2/source/inc/templdgi.hxx                    |  211 +--
 sfx2/uiconfig/ui/templatepanel.ui               |  326 +++++
 solenv/sanitizers/ui/sfx.suppr                  |    7 
 starmath/inc/smmod.hxx                          |    1 
 sw/source/uibase/app/swmodule.cxx               |   12 
 sw/source/uibase/inc/uitool.hxx                 |    1 
 sw/source/uibase/table/tablepg.hxx              |    1 
 vcl/source/app/salvtables.cxx                   |    8 
 vcl/source/app/weldutils.cxx                    |   19 
 vcl/unx/gtk3/gtk3gtkinst.cxx                    |   28 
 39 files changed, 1127 insertions(+), 1094 deletions(-)

New commits:
commit fe9a13dc0e6d1384416c2a2343223b33925fc925
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Apr 26 15:43:25 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Apr 29 09:46:08 2020 +0200

    weld SfxTemplatePanelControl
    
    Change-Id: Ib3f6d01ddec37afc3987423dc15ab84ad6475f37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92942
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/inc/acccfg.hxx b/cui/source/inc/acccfg.hxx
index 4256258adbb9..aecc923adec2 100644
--- a/cui/source/inc/acccfg.hxx
+++ b/cui/source/inc/acccfg.hxx
@@ -26,6 +26,7 @@
 
 #include <sfx2/tabdlg.hxx>
 #include <vcl/idle.hxx>
+#include <vcl/keycod.hxx>
 #include <i18nutil/searchopt.hxx>
 #include "cfgutil.hxx"
 
diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx
index abce15b97d42..26ec055e249b 100644
--- a/cui/source/inc/numpages.hxx
+++ b/cui/source/inc/numpages.hxx
@@ -37,6 +37,7 @@ class SvxNumValueSet;
 class SvxNumRule;
 class SvxBmpNumValueSet;
 class SvxBrushItem;
+struct ImplSVEvent;
 
 struct SvxNumSettings_Impl
 {
diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx
index 7a3c60a2d327..a58cfde7836a 100644
--- a/dbaccess/source/ui/inc/directsql.hxx
+++ b/dbaccess/source/ui/inc/directsql.hxx
@@ -35,6 +35,8 @@
 
 #include <svx/weldeditview.hxx>
 
+struct ImplSVEvent;
+
 namespace dbaui
 {
     class SQLEditView : public WeldEditView
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index c4c12a6f0a8f..89564fca2efd 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -78,7 +78,6 @@
 #include <memory>
 
 using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::frame;
 using namespace ::com::sun::star::ui::dialogs;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
diff --git a/include/cui/cuicharmap.hxx b/include/cui/cuicharmap.hxx
index 7c5ca0d28a23..76dd6c637f62 100644
--- a/include/cui/cuicharmap.hxx
+++ b/include/cui/cuicharmap.hxx
@@ -29,6 +29,7 @@
 #include <svx/ucsubset.hxx>
 #include <sfx2/charwin.hxx>
 #include <cui/cuidllapi.h>
+#include <com/sun/star/frame/XFrame.hpp>
 
 using namespace ::com::sun::star;
 class SubsetMap;
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 5d7f6d7e9ab7..436c08b09422 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -237,17 +237,11 @@
 #define STR_ERROR_WRONG_CONFIRM                 NC_("STR_ERROR_WRONG_CONFIRM", "Faulty password confirmation")
 #define STR_PDF_EXPORT_SEND                     NC_("STR_PDF_EXPORT_SEND", "Send")
 #define STR_FONT_TABPAGE                        NC_("STR_FONT_TABPAGE", "Font")
-#define STR_PREVIEW_CHECKBOX                    NC_("STR_PREVIEW_CHECKBOX", "Show previews")
 
 #define STR_VIEWVERSIONCOMMENT                  NC_("STR_VIEWVERSIONCOMMENT", "View Version Comment")
 #define STR_NO_NAME_SET                         NC_("STR_NO_NAME_SET", "(no name set)")
 
-#define STR_STYLE_ELEMTLIST                     NC_("STR_STYLE_ELEMTLIST", "Style List")
 #define STR_STYLE_FILTER_HIERARCHICAL           NC_("STR_STYLE_FILTER_HIERARCHICAL", "Hierarchical")
-#define STR_STYLE_FILL_FORMAT_MODE              NC_("STR_STYLE_FILL_FORMAT_MODE", "Fill Format Mode")
-#define STR_STYLE_NEW_STYLE_FROM_SELECTION      NC_("STR_STYLE_NEW_STYLE_FROM_SELECTION", "New Style from Selection")
-#define STR_STYLE_NEW_STYLE_ACTION              NC_("STR_STYLE_NEW_STYLE_ACTION", "Styles actions")
-#define STR_STYLE_UPDATE_STYLE                  NC_("STR_STYLE_UPDATE_STYLE", "Update Style")
 
 #define STR_MACRO_LOSS                          NC_("STR_MACRO_LOSS", "Do you really want to cancel the recording? Any steps recorded up to this point will be lost.")
 #define STR_CANCEL_RECORDING                    NC_("STR_CANCEL_RECORDING", "Cancel Recording")
diff --git a/include/sfx2/styfitem.hxx b/include/sfx2/styfitem.hxx
index fea8d735796b..dc939342689f 100644
--- a/include/sfx2/styfitem.hxx
+++ b/include/sfx2/styfitem.hxx
@@ -22,7 +22,6 @@
 #include <rtl/ustring.hxx>
 #include <sal/config.h>
 #include <sfx2/dllapi.h>
-#include <vcl/image.hxx>
 #include <svl/style.hxx>
 #include <vector>
 
@@ -43,16 +42,16 @@ class SFX2_DLLPUBLIC SfxStyleFamilyItem
 {
     SfxStyleFamily  nFamily;
     OUString        aText;
-    Image           aImage;
+    OUString        aImage;
     SfxStyleFilter  aFilterList;
 
 public:
-    SfxStyleFamilyItem(SfxStyleFamily nFamily, const OUString &rName, const Image& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rLocale);
+    SfxStyleFamilyItem(SfxStyleFamily nFamily, const OUString &rName, const OUString& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rLocale);
 
     const OUString& GetText() const { return aText; }
     SfxStyleFamily  GetFamily() const { return nFamily; }
     const SfxStyleFilter& GetFilterList() const { return aFilterList; }
-    const Image&    GetImage() const { return aImage; }
+    const OUString&    GetImage() const { return aImage; }
 };
 
 using SfxStyleFamilies = std::vector<SfxStyleFamilyItem>;
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 05230e58310b..0d770572f051 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -38,6 +38,8 @@ struct TabPageImpl;
 
 struct TabDlg_Impl;
 
+namespace com::sun::star::frame { class XFrame; }
+
 #define RET_USER        100
 #define RET_USER_CANCEL 101
 
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index 3ed02ac9037a..8144340a0ee7 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -12,6 +12,7 @@
 
 #include <sfx2/thumbnailview.hxx>
 #include <sfx2/templateproperties.hxx>
+#include <vcl/menu.hxx>
 #include <functional>
 #include <memory>
 #include <set>
diff --git a/include/sfx2/templdlg.hxx b/include/sfx2/templdlg.hxx
index 3c0f4e2e99d3..8ffc8ddfcdb0 100644
--- a/include/sfx2/templdlg.hxx
+++ b/include/sfx2/templdlg.hxx
@@ -23,19 +23,19 @@
 #include <memory>
 #include <sal/config.h>
 #include <sfx2/dllapi.h>
-#include <vcl/window.hxx>
+#include <sfx2/sidebar/PanelLayout.hxx>
 
 class SfxBindings;
 class SfxTemplateDialog_Impl;
 
-class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final : public vcl::Window
+class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final : public PanelLayout
 {
 public:
     SfxTemplatePanelControl(SfxBindings* pBindings, vcl::Window* pParentWindow);
     virtual ~SfxTemplatePanelControl() override;
     virtual void dispose() override;
 
-    virtual void Resize() override;
+    weld::Builder* get_builder() { return m_xBuilder.get(); }
 
 private:
     std::unique_ptr<SfxTemplateDialog_Impl> pImpl;
diff --git a/include/svtools/prnsetup.hxx b/include/svtools/prnsetup.hxx
index 618fc8578705..5f55b6b416b2 100644
--- a/include/svtools/prnsetup.hxx
+++ b/include/svtools/prnsetup.hxx
@@ -27,6 +27,7 @@
 
 class Printer;
 class QueueInfo;
+class VclSimpleEvent;
 
 class SVT_DLLPUBLIC PrinterSetupDialog final : public weld::GenericDialogController
 {
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index c9b2ea3b86af..3aefe3d82072 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -24,6 +24,7 @@
 #include <svtools/svtdllapi.h>
 #include <tools/wintypes.hxx>
 #include <vcl/customweld.hxx>
+#include <vcl/image.hxx>
 #include <memory>
 #include <vector>
 
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index da1522787258..384fa31155ae 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -21,7 +21,7 @@
 #include <vcl/dllapi.h>
 #include <vcl/vclenum.hxx>
 #include <vcl/font.hxx>
-#include <vcl/menu.hxx>
+#include <vcl/vclptr.hxx>
 #include <vcl/uitest/factory.hxx>
 
 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
@@ -62,9 +62,10 @@ typedef css::uno::Reference<css::accessibility::XAccessible> a11yref;
 typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset;
 
 enum class PointerStyle;
-class SvNumberFormatter;
+class CommandEvent;
 class KeyEvent;
 class MouseEvent;
+class SvNumberFormatter;
 class TransferDataContainer;
 class OutputDevice;
 class VirtualDevice;
@@ -73,6 +74,7 @@ struct SystemEnvData;
 namespace vcl
 {
 class ILibreOfficeKitNotifier;
+typedef OutputDevice RenderContext;
 }
 
 namespace weld
@@ -1138,7 +1140,7 @@ public:
     void connect_custom_get_size(const Link<get_size_args, Size>& rLink) { m_aGetSizeHdl = rLink; }
     void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; }
     // call set_column_custom_renderer after setting custom callbacks
-    virtual void set_column_custom_renderer(int nColumn) = 0;
+    virtual void set_column_custom_renderer(int nColumn, bool bEnable) = 0;
 
     // for dnd
     virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult) = 0;
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index cb04f2d74915..90a8a20a4467 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -158,6 +158,9 @@ VCL_DLLPUBLIC size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::Tree
 
 // an entry is visible if all parents are expanded
 VCL_DLLPUBLIC bool IsEntryVisible(const weld::TreeView& rTreeView, const weld::TreeIter& rIter);
+
+// A Parent's Children are turned into Children of the Parent which comes next in hierarchy
+VCL_DLLPUBLIC void RemoveParentKeepChildren(weld::TreeView& rTreeView, weld::TreeIter& rParent);
 }
 
 #endif
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index ac15258da6a3..db559c4ce4a9 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -2253,12 +2253,12 @@ std::unique_ptr<SfxStyleFamilies> ScModule::CreateStyleFamilies()
 
     pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
                                                     ScResId(STR_STYLE_FAMILY_CELL),
-                                                    Image(StockImage::Yes, BMP_STYLES_FAMILY_CELL),
+                                                    BMP_STYLES_FAMILY_CELL,
                                                     RID_CELLSTYLEFAMILY, SC_MOD()->GetResLocale()));
 
     pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
                                                     ScResId(STR_STYLE_FAMILY_PAGE),
-                                                    Image(StockImage::Yes, BMP_STYLES_FAMILY_PAGE),
+                                                    BMP_STYLES_FAMILY_PAGE,
                                                     RID_PAGESTYLEFAMILY, SC_MOD()->GetResLocale()));
 
     return pStyleFamilies;
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx
index 6ede105199c5..921a1491d022 100644
--- a/sc/source/ui/dbgui/csvcontrol.cxx
+++ b/sc/source/ui/dbgui/csvcontrol.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <csvcontrol.hxx>
+#include <vcl/keycodes.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/settings.hxx>
 
diff --git a/sc/source/ui/inc/AccessibleDocument.hxx b/sc/source/ui/inc/AccessibleDocument.hxx
index d908d952ffb4..731c6a9628e2 100644
--- a/sc/source/ui/inc/AccessibleDocument.hxx
+++ b/sc/source/ui/inc/AccessibleDocument.hxx
@@ -33,6 +33,7 @@ class ScTabViewShell;
 class ScAccessibleSpreadsheet;
 class ScChildrenShapes;
 class ScAccessibleEditObject;
+class VclWindowEvent;
 
 namespace utl
 {
diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx
index 87d093b79c5d..6abf0fd11f19 100644
--- a/sc/source/ui/inc/content.hxx
+++ b/sc/source/ui/inc/content.hxx
@@ -30,6 +30,7 @@ class ScLinkTransferObj;
 class ScDocument;
 class ScDocShell;
 class ScNavigatorDlg;
+struct ImplSVEvent;
 
 enum class ScContentId {
     ROOT, TABLE, RANGENAME, DBAREA,
diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index 3b4c3b3afaa6..e6ccb0c3c721 100644
--- a/sd/source/ui/animations/CustomAnimationList.cxx
+++ b/sd/source/ui/animations/CustomAnimationList.cxx
@@ -438,7 +438,7 @@ CustomAnimationList::CustomAnimationList(std::unique_ptr<weld::TreeView> xTreeVi
     mxTreeView->connect_drag_begin(LINK(this, CustomAnimationList, DragBeginHdl));
     mxTreeView->connect_custom_get_size(LINK(this, CustomAnimationList, CustomGetSizeHdl));
     mxTreeView->connect_custom_render(LINK(this, CustomAnimationList, CustomRenderHdl));
-    mxTreeView->set_column_custom_renderer(0);
+    mxTreeView->set_column_custom_renderer(0, true);
 }
 
 CustomAnimationListDropTarget::CustomAnimationListDropTarget(CustomAnimationList& rTreeView)
diff --git a/sd/source/ui/animations/CustomAnimationList.hxx b/sd/source/ui/animations/CustomAnimationList.hxx
index 3da6b350dce6..95ee309c5f0f 100644
--- a/sd/source/ui/animations/CustomAnimationList.hxx
+++ b/sd/source/ui/animations/CustomAnimationList.hxx
@@ -30,6 +30,7 @@
 
 namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } }
 
+struct ImplSVEvent;
 class VclBuilder;
 
 namespace sd {
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 427228c0a7d5..b94015b942af 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -802,12 +802,12 @@ std::unique_ptr<SfxStyleFamilies> SdModule::CreateStyleFamilies()
 
     pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
                                                     SdResId(STR_GRAPHICS_STYLE_FAMILY),
-                                                    Image(StockImage::Yes, BMP_STYLES_FAMILY_GRAPHICS),
+                                                    BMP_STYLES_FAMILY_GRAPHICS,
                                                     RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale()));
 
     pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
                                                     SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
-                                                    Image(StockImage::Yes, BMP_STYLES_FAMILY_PRESENTATIONS),
+                                                    BMP_STYLES_FAMILY_PRESENTATIONS,
                                                     RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale()));
 
     return pStyleFamilies;
diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx
index c9fce345c986..43bdbffded40 100644
--- a/sd/source/ui/inc/sdtreelb.hxx
+++ b/sd/source/ui/inc/sdtreelb.hxx
@@ -37,6 +37,7 @@ class SdrObject;
 class SdrObjList;
 class SdPage;
 class SvTreeListEntry;
+struct ImplSVEvent;
 
 namespace sd {
 class ViewShell;
diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx
index 368b5c8cfd31..92de46a93b9c 100644
--- a/sd/source/ui/sidebar/LayoutMenu.hxx
+++ b/sd/source/ui/sidebar/LayoutMenu.hxx
@@ -24,6 +24,7 @@
 #include <sfx2/sidebar/PanelLayout.hxx>
 
 #include <svtools/valueset.hxx>
+#include <vcl/menu.hxx>
 #include <vcl/transfer.hxx>
 #include <sfx2/request.hxx>
 #include <xmloff/autolayout.hxx>
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx b/sd/source/ui/sidebar/MasterPagesSelector.hxx
index f00e85493d34..266b5dd0a5c0 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.hxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx
@@ -26,6 +26,7 @@
 #include "PreviewValueSet.hxx"
 #include <sfx2/sidebar/ILayoutableWindow.hxx>
 #include <sfx2/sidebar/PanelLayout.hxx>
+#include <vcl/menu.hxx>
 
 #include <osl/mutex.hxx>
 
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index 15ccbcc24116..c682be2b214b 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -18,9 +18,9 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
 	sfx2/uiconfig/ui/charmapcontrol \
 	sfx2/uiconfig/ui/charviewmenu \
 	sfx2/uiconfig/ui/checkin \
+	sfx2/uiconfig/ui/classificationbox \
 	sfx2/uiconfig/ui/cmisinfopage \
 	sfx2/uiconfig/ui/cmisline \
-	sfx2/uiconfig/ui/classificationbox \
 	sfx2/uiconfig/ui/custominfopage \
 	sfx2/uiconfig/ui/descriptioninfopage \
 	sfx2/uiconfig/ui/dockingwindow \
@@ -51,6 +51,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
 	sfx2/uiconfig/ui/notebookbarpopup \
 	sfx2/uiconfig/ui/printeroptionsdialog \
 	sfx2/uiconfig/ui/querysavedialog \
+	sfx2/uiconfig/ui/saveastemplatedlg \
 	sfx2/uiconfig/ui/safemodequerydialog \
 	sfx2/uiconfig/ui/searchdialog \
 	sfx2/uiconfig/ui/securityinfopage \
@@ -58,8 +59,8 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
 	sfx2/uiconfig/ui/startcenter \
 	sfx2/uiconfig/ui/stylecontextmenu \
 	sfx2/uiconfig/ui/templatedlg \
-	sfx2/uiconfig/ui/saveastemplatedlg \
 	sfx2/uiconfig/ui/templatecategorydlg \
+	sfx2/uiconfig/ui/templatepanel \
 	sfx2/uiconfig/ui/urlbox \
 	sfx2/uiconfig/ui/versionsofdialog \
 	sfx2/uiconfig/ui/versioncommentdialog \
diff --git a/sfx2/inc/bitmaps.hlst b/sfx2/inc/bitmaps.hlst
index 28e16d920513..6ec00cd863de 100644
--- a/sfx2/inc/bitmaps.hlst
+++ b/sfx2/inc/bitmaps.hlst
@@ -88,10 +88,6 @@
 
 #define SFX_BMP_CLOSE_DOC                   "sfx2/res/closedoc.png"
 
-#define RID_SFXBMP_WATERCAN                 "res/sc05554.png"
-#define RID_SFXBMP_NEW_BY_EXAMPLE           "res/sc05555.png"
-#define RID_SFXBMP_UPDATE_BY_EXAMPLE        "res/sc05556.png"
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sfx2/source/dialog/styfitem.cxx b/sfx2/source/dialog/styfitem.cxx
index 33b731691596..a1ff5ab78094 100644
--- a/sfx2/source/dialog/styfitem.cxx
+++ b/sfx2/source/dialog/styfitem.cxx
@@ -20,7 +20,7 @@
 #include <sfx2/styfitem.hxx>
 #include <unotools/resmgr.hxx>
 
-SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &rName, const Image& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rResLocale)
+SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &rName, const OUString& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rResLocale)
     : nFamily(nFamily_)
     , aText(rName)
     , aImage(rImage)
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 2f2e1541eca0..9fe35922cd39 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -22,12 +22,14 @@
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
+#include <vcl/commandevent.hxx>
 #include <vcl/commandinfoprovider.hxx>
 #include <vcl/event.hxx>
 #include <vcl/help.hxx>
 #include <vcl/menu.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/weldutils.hxx>
 #include <svl/intitem.hxx>
 #include <svl/stritem.hxx>
 #include <svl/style.hxx>
@@ -71,112 +73,11 @@
 #include <sfx2/StyleManager.hxx>
 #include <sfx2/StylePreviewRenderer.hxx>
 
-#define STD_ENTRY_HEIGHT 17
-
 using namespace css;
 using namespace css::beans;
 using namespace css::frame;
 using namespace css::uno;
 
-namespace
-{
-
-class StyleLBoxString : public SvLBoxString
-{
-    SfxStyleFamily meStyleFamily;
-    SvViewDataItem* mpViewData;
-
-public:
-    StyleLBoxString(const OUString& sText,
-                    const SfxStyleFamily& eStyleFamily);
-
-    virtual void Paint(const Point& aPos,
-                       SvTreeListBox& rDevice,
-                       vcl::RenderContext& rRenderContext,
-                       const SvViewDataEntry* pView,
-                       const SvTreeListEntry& rEntry) override;
-
-    virtual void InitViewData(SvTreeListBox* pView,
-                              SvTreeListEntry* pEntry,
-                              SvViewDataItem* pViewData = nullptr) override;
-};
-
-
-StyleLBoxString::StyleLBoxString(const OUString& sText, const SfxStyleFamily& eStyleFamily)
-    : SvLBoxString(sText)
-    , meStyleFamily(eStyleFamily)
-    , mpViewData(nullptr)
-{}
-
-void StyleLBoxString::InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
-{
-    if (!pViewData)
-    {
-        pViewData = pView->GetViewDataItem(pEntry, this);
-    }
-    mpViewData = pViewData;
-}
-
-void StyleLBoxString::Paint(
-    const Point& aPos, SvTreeListBox& rDevice, vcl::RenderContext& rRenderContext,
-    const SvViewDataEntry* pView, const SvTreeListEntry& rEntry)
-{
-    bool bPainted = false;
-
-    SfxObjectShell* pShell = SfxObjectShell::Current();
-    sfx2::StyleManager* pStyleManager = pShell? pShell->GetStyleManager(): nullptr;
-
-    if (pStyleManager)
-    {
-        SfxStyleSheetBase* pStyleSheet = pStyleManager->Search(GetText(), meStyleFamily);
-
-        if (pStyleSheet)
-        {
-            sal_Int32 nSize = 32 * rRenderContext.GetDPIScaleFactor();
-            std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer(
-                pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize));
-
-            if (pStylePreviewRenderer)
-            {
-                if (pStylePreviewRenderer->recalculate())
-                {
-                    Size aSize(pStylePreviewRenderer->getRenderSize());
-                    mpViewData->mnWidth = aSize.Width();
-                    mpViewData->mnHeight = aSize.Height();
-                }
-                else
-                {
-                    SvLBoxString::InitViewData( &rDevice, const_cast<SvTreeListEntry*>(&rEntry), mpViewData);
-                }
-
-                tools::Rectangle aPaintRectangle = pView->GetPaintRectangle();
-                bPainted = pStylePreviewRenderer->render(aPaintRectangle);
-            }
-        }
-    }
-
-    if (!bPainted)
-    {
-        rRenderContext.DrawText(aPos, GetText());
-    }
-}
-
-} // end anonymous namespace
-
-// Window is now created dynamically. So here margins, etc.
-
-#define SFX_TEMPLDLG_HFRAME         3
-#define SFX_TEMPLDLG_VTOPFRAME      3
-
-#define SFX_TEMPLDLG_VBOTFRAME      3
-#define SFX_TEMPLDLG_MIDHSPACE      3
-#define SFX_TEMPLDLG_MIDVSPACE      3
-#define SFX_TEMPLDLG_FILTERHEIGHT   100
-
-// filter box has maximum 14 entries visible
-#define MAX_FILTER_ENTRIES          14
-
-
 class SfxCommonTemplateDialog_Impl::DeletionWatcher
 {
     typedef void (DeletionWatcher::* bool_type)();
@@ -216,43 +117,38 @@ private:
     DeletionWatcher *const m_pPrevious; /// let's add more epicycles!
 };
 
-void DropListBox_Impl::MouseButtonDown( const MouseEvent& rMEvt )
-{
-    nModifier = rMEvt.GetModifier();
-
-    bool bHitEmptySpace = ( nullptr == GetEntry( rMEvt.GetPosPixel(), true ) );
-    if( bHitEmptySpace && ( rMEvt.GetClicks() == 2 ) && rMEvt.IsMod1() )
-        Control::MouseButtonDown( rMEvt );
-    else
-        SvTreeListBox::MouseButtonDown( rMEvt );
-}
-
 /** Drop is enabled as long as it is allowed to create a new style by example, i.e. to
     create a style out of the current selection.
 */
-sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
+sal_Int8 SfxCommonTemplateDialog_Impl::AcceptDrop(const AcceptDropEvent& rEvt, const DropTargetHelper& rHelper)
 {
-    if ( IsDropFormatSupported( SotClipboardFormatId::OBJECTDESCRIPTOR ) )
+    if (rHelper.IsDropFormatSupported(SotClipboardFormatId::OBJECTDESCRIPTOR))
     {
         // special case: page styles are allowed to create new styles by example
         // but not allowed to be created by drag and drop
-        if (pDialog->GetActualFamily() == SfxStyleFamily::Page ||
-                pDialog->bNewByExampleDisabled)
+        if (GetActualFamily() == SfxStyleFamily::Page || bNewByExampleDisabled)
             return DND_ACTION_NONE;
         else
             return DND_ACTION_COPY;
     }
-    return SvTreeListBox::AcceptDrop( rEvt );
+
+    // to enable the autoscroll when we're close to the edges
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+    pTreeView->get_dest_row_at_pos(rEvt.maPosPixel, nullptr);
+    return DND_ACTION_MOVE;
 }
 
-sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
+sal_Int8 SfxCommonTemplateDialog_Impl::ExecuteDrop(const ExecuteDropEvent& rEvt)
 {
-    sal_Int8 nRet = DND_ACTION_NONE;
-    SfxObjectShell* pDocShell = pDialog->GetObjectShell();
-    TransferableDataHelper aHelper( rEvt.maDropEvent.Transferable );
-    sal_uInt32 nFormatCount = aHelper.GetFormatCount();
-    if ( pDocShell )
+    // handle drop of content into the treeview to create a new style
+    SfxObjectShell* pDocShell = GetObjectShell();
+    if (pDocShell)
     {
+        TransferableDataHelper aHelper(rEvt.maDropEvent.Transferable);
+        sal_uInt32 nFormatCount = aHelper.GetFormatCount();
+
+        sal_Int8 nRet = DND_ACTION_NONE;
+
         bool bFormatFound = false;
 
         for ( sal_uInt32 i = 0; i < nFormatCount; ++i )
@@ -264,7 +160,7 @@ sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
             {
                 if ( aDesc.maClassName == pDocShell->GetFactory().GetClassId() )
                 {
-                    PostUserEvent( LINK( this, DropListBox_Impl, OnAsyncExecuteDrop ), nullptr, true );
+                    Application::PostUserEvent(LINK(this, SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop));
 
                     bFormatFound = true;
                     nRet =  rEvt.mnAction;
@@ -273,260 +169,211 @@ sal_Int8 DropListBox_Impl::ExecuteDrop( const ExecuteDropEvent& rEvt )
             }
         }
 
-        if ( !bFormatFound )
-            return SvTreeListBox::ExecuteDrop( rEvt );
+        if (bFormatFound)
+            return nRet;
     }
 
-    return nRet;
+    if (!mxTreeBox->get_visible())
+        return DND_ACTION_NONE;
+
+    if (!bAllowReParentDrop)
+        return DND_ACTION_NONE;
+
+    // otherwise if we're dragging with the treeview to set a new parent of the dragged style
+    weld::TreeView* pSource = mxTreeBox->get_drag_source();
+    // only dragging within the same widget allowed
+    if (!pSource || pSource != mxTreeBox.get())
+        return DND_ACTION_NONE;
+
+    std::unique_ptr<weld::TreeIter> xSource(mxTreeBox->make_iterator());
+    if (!mxTreeBox->get_selected(xSource.get()))
+        return DND_ACTION_NONE;
+
+    std::unique_ptr<weld::TreeIter> xTarget(mxTreeBox->make_iterator());
+    if (!mxTreeBox->get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get()))
+    {
+        // if nothing under the mouse, use the last row
+        int nChildren = mxTreeBox->n_children();
+        if (!nChildren)
+            return DND_ACTION_NONE;
+        if (!mxTreeBox->get_iter_first(*xTarget) || !mxTreeBox->iter_nth_sibling(*xTarget, nChildren - 1))
+            return DND_ACTION_NONE;
+        while (mxTreeBox->get_row_expanded(*xTarget))
+        {
+            nChildren = mxTreeBox->iter_n_children(*xTarget);
+            if (!mxTreeBox->iter_children(*xTarget) || !mxTreeBox->iter_nth_sibling(*xTarget, nChildren - 1))
+                return DND_ACTION_NONE;
+        }
+    }
+    OUString aTargetStyle = mxTreeBox->get_text(*xTarget);
+    DropHdl(mxTreeBox->get_text(*xSource), aTargetStyle);
+    mxTreeBox->unset_drag_dest_row();
+    FillTreeBox();
+    SelectStyle(aTargetStyle, false);
+    return DND_ACTION_NONE;
 }
 
-IMPL_LINK_NOARG(DropListBox_Impl, OnAsyncExecuteDrop, void*, void)
+IMPL_LINK(SfxCommonTemplateDialog_Impl, DragBeginHdl, bool&, rUnsetDragIcon, bool)
 {
-    pDialog->ActionSelect( SID_STYLE_NEW_BY_EXAMPLE );
+    rUnsetDragIcon = false;
+    // Allow normal processing. only if bAllowReParentDrop is true
+    return !bAllowReParentDrop;
 }
 
-bool DropListBox_Impl::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop, void*, void)
+{
+    ActionSelect("new");
+}
+
+IMPL_LINK(SfxCommonTemplateDialog_Impl, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
 {
     bool bRet = false;
-    if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+    const vcl::KeyCode& rKeyCode = rKeyEvent.GetKeyCode();
+    if (bCanDel && !rKeyCode.GetModifier() && rKeyCode.GetCode() == KEY_DELETE)
     {
-        const vcl::KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
-        if(!rKeyCode.GetModifier())
-        {
-            if( pDialog->bCanDel && KEY_DELETE == rKeyCode.GetCode())
-            {
-                pDialog->DeleteHdl();
-                bRet =  true;
-            }
-            else if( KEY_RETURN == rKeyCode.GetCode())
-            {
-                GetDoubleClickHdl().Call(this);
-                bRet = true;
-            }
-        }
+        DeleteHdl();
+        bRet =  true;
     }
-    if(!bRet)
-        bRet = SvTreeListBox::EventNotify( rNEvt );
     return bRet;
 }
 
-void DropListBox_Impl::RequestHelp(const HelpEvent& rHEvt)
+IMPL_LINK(SfxCommonTemplateDialog_Impl, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUString)
 {
-    if (rHEvt.GetMode() & HelpEventMode::QUICK)
-    {
-        Point aPos(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
-        SvTreeListEntry* pEntry = GetEntry(aPos);
-        if (pEntry)
-        {
-            const OUString aTemplName(GetEntryText(pEntry));
-            OUString sQuickHelpText(aTemplName);
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+    const OUString aTemplName(pTreeView->get_text(rEntry));
+    OUString sQuickHelpText(aTemplName);
 
-            const SfxStyleFamilyItem* pItem = pDialog->GetFamilyItem_Impl();
-            SfxStyleSheetBase* pStyle = pDialog->pStyleSheetPool->Find(aTemplName, pItem->GetFamily());
-
-            if (pStyle && pStyle->IsUsed())  // pStyle is in use in the document?
-            {
-                OUString sUsedBy;
-                if (pStyle->GetFamily() == SfxStyleFamily::Pseudo)
-                {
-                    sUsedBy = pStyle->GetUsedBy();
-                }
+    const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+    SfxStyleSheetBase* pStyle = pStyleSheetPool->Find(aTemplName, pItem->GetFamily());
 
-                if (!sUsedBy.isEmpty())
-                {
-                    const sal_Int32 nMaxLen = 80;
-                    if (sUsedBy.getLength() > nMaxLen)
-                    {
-                        sUsedBy = sUsedBy.copy(0, nMaxLen) + "...";
-                    }
+    if (pStyle && pStyle->IsUsed())  // pStyle is in use in the document?
+    {
+        OUString sUsedBy;
+        if (pStyle->GetFamily() == SfxStyleFamily::Pseudo)
+            sUsedBy = pStyle->GetUsedBy();
 
-                    OUString aMessage = SfxResId(STR_STYLEUSEDBY);
-                    aMessage = aMessage.replaceFirst("%STYLELIST", sUsedBy);
-                    sQuickHelpText = aTemplName + " " + aMessage;
-                }
+        if (!sUsedBy.isEmpty())
+        {
+            const sal_Int32 nMaxLen = 80;
+            if (sUsedBy.getLength() > nMaxLen)
+            {
+                sUsedBy = sUsedBy.copy(0, nMaxLen) + "...";
             }
 
-            Size aSize(GetOutputSizePixel().Width(), GetEntryHeight());
-            tools::Rectangle aScreenRect(OutputToScreenPixel(GetEntryPosition(pEntry)), aSize);
-
-            Help::ShowQuickHelp(this, aScreenRect,
-                                 sQuickHelpText, QuickHelpFlags::Left | QuickHelpFlags::VCenter);
-            return;
+            OUString aMessage = SfxResId(STR_STYLEUSEDBY);
+            aMessage = aMessage.replaceFirst("%STYLELIST", sUsedBy);
+            sQuickHelpText = aTemplName + " " + aMessage;
         }
     }
-    SvTreeListBox::RequestHelp(rHEvt);
-}
 
-/** ListBox class that starts a PopupMenu (designer specific) in the
-    command handler.
-*/
-SfxActionListBox::SfxActionListBox(SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits)
-    : DropListBox_Impl(pParent->GetWindow(), nWinBits, pParent)
-{
-    EnableContextMenuHandling();
+    return sQuickHelpText;
 }
 
-void SfxActionListBox::Recalc()
+IMPL_STATIC_LINK(SfxCommonTemplateDialog_Impl, CustomGetSizeHdl, weld::TreeView::get_size_args, aPayload, Size)
 {
-    if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
-        SetEntryHeight(32 * GetDPIScaleFactor());
-    else
-        SetEntryHeight(STD_ENTRY_HEIGHT, true);
-    RecalcViewData();
+    vcl::RenderContext& rRenderContext = aPayload.first;
+    return Size(42, 32 * rRenderContext.GetDPIScaleFactor());
 }
 
-VclPtr<PopupMenu> SfxActionListBox::CreateContextMenu()
+IMPL_LINK(SfxCommonTemplateDialog_Impl, CustomRenderHdl, weld::TreeView::render_args, aPayload, void)
 {
+    vcl::RenderContext& rRenderContext = std::get<0>(aPayload);
+    const ::tools::Rectangle& rRect = std::get<1>(aPayload);
+    bool bSelected = std::get<2>(aPayload);
+    const OUString& rId = std::get<3>(aPayload);
 
-    if(  GetSelectionCount() <= 0 )
-    {
-        pDialog->EnableEdit( false );
-        pDialog->EnableDel( false );
-    }
-    return pDialog->CreateContextMenu();
-}
-
-SfxTemplatePanelControl::SfxTemplatePanelControl(SfxBindings* pBindings, vcl::Window* pParentWindow)
-    : Window(pParentWindow, WB_DIALOGCONTROL)
-    , pImpl(new SfxTemplateDialog_Impl(pBindings, this))
-    , mpBindings(pBindings)
-{
-    OSL_ASSERT(mpBindings!=nullptr);
-
-    SetStyle(GetStyle() & ~WB_DOCKABLE);
-}
-
-SfxTemplatePanelControl::~SfxTemplatePanelControl()
-{
-    disposeOnce();
-}
+    rRenderContext.Push(PushFlags::TEXTCOLOR);
+    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+    if (bSelected)
+        rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
+    else
+        rRenderContext.SetTextColor(rStyleSettings.GetDialogTextColor());
 
-void SfxTemplatePanelControl::dispose()
-{
-    pImpl.reset();
-    Window::dispose();
-}
+    bool bSuccess = false;
 
-void SfxTemplatePanelControl::Resize()
-{
-    if(pImpl)
-        pImpl->Resize();
-    Window::Resize();
-}
+    SfxObjectShell* pShell = SfxObjectShell::Current();
+    sfx2::StyleManager* pStyleManager = pShell ? pShell->GetStyleManager(): nullptr;
 
-void StyleTreeListBox_Impl::MakeExpanded_Impl(std::vector<OUString>& rEntries) const
-{
-    SvTreeListEntry* pEntry;
-    for (pEntry = FirstVisible(); pEntry; pEntry = NextVisible(pEntry))
+    if (pStyleManager)
     {
-        if (IsExpanded(pEntry))
+        const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+        SfxStyleSheetBase* pStyleSheet = pStyleManager->Search(rId, pItem->GetFamily());
+
+        if (pStyleSheet)
         {
-            rEntries.push_back(GetEntryText(pEntry));
+            rRenderContext.Push(PushFlags::ALL);
+            sal_Int32 nSize = rRect.GetHeight();
+            std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer(
+                pStyleManager->CreateStylePreviewRenderer(rRenderContext, pStyleSheet, nSize));
+            bSuccess = pStylePreviewRenderer->recalculate() && pStylePreviewRenderer->render(rRect);
+            rRenderContext.Pop();
         }
     }
-}
 
-VclPtr<PopupMenu> StyleTreeListBox_Impl::CreateContextMenu()
-{
-    return pDialog->CreateContextMenu();
-}
+    if (!bSuccess)
+        rRenderContext.DrawText(rRect, rId, DrawTextFlags::Left | DrawTextFlags::VCenter);
 
-/** DoubleClick-Handler; calls the link.
-    SV virtual method.
-*/
-bool StyleTreeListBox_Impl::DoubleClickHdl()
-{
-    aDoubleClickLink.Call(nullptr);
-    return false;
+    rRenderContext.Pop();
 }
 
-bool StyleTreeListBox_Impl::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupFlatMenuHdl, const CommandEvent&, rCEvt, bool)
 {
-    // handle <RETURN> as double click
+    if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+        return false;
 
-    bool bRet = false;
-    if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+    if (mxFmtLb->count_selected_rows() <= 0)
     {
-        const vcl::KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
-        if ( !rKeyCode.GetModifier() && KEY_RETURN == rKeyCode.GetCode() )
-        {
-            aDoubleClickLink.Call( nullptr );
-            bRet = true;
-        }
+        EnableEdit(false);
+        EnableDel(false);
     }
 
-    if ( !bRet )
-        bRet = DropListBox_Impl::EventNotify( rNEvt );
-
-    return bRet;
+    return PopupTreeMenuHdl(rCEvt);
 }
 
-/** NotifyMoving Handler; This leads via a link on the event to the dialog.
-    SV virtual method.
-*/
-TriState StyleTreeListBox_Impl::NotifyMoving(SvTreeListEntry*  pTarget,
-                                         SvTreeListEntry*  pEntry,
-                                         SvTreeListEntry*& rpNewParent,
-                                         sal_uLong& lPos)
-{
-    if(!pTarget || !pEntry)
-        return TRISTATE_FALSE;
-    aParent = GetEntryText(pTarget);
-    aStyle  = GetEntryText(pEntry);
-    const bool bRet = aDropLink.Call(*this);
-    rpNewParent = pTarget;
-    lPos=0;
-    IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
-    const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator();
-    for(SvTreeListEntry *pTmpEntry=FirstChild(pTarget);
-        pTmpEntry && pCollator->compareString(
-            GetEntryText(pTmpEntry),GetEntryText(pEntry)) < 0;
-        pTmpEntry=pTmpEntry->NextSibling(),lPos++) ;
-
-    return bRet ? TRISTATE_INDET : TRISTATE_FALSE;
-}
-
-/** ExpandingHdl Handler; the current entry is noticed.
-    SV virtual method.
-
-    [Cross-reference]
-    <StyleTreeListBox_Impl::ExpandedHdl()>
-*/
-bool  StyleTreeListBox_Impl::ExpandingHdl()
+IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
 {
-    pCurEntry = GetCurEntry();
+    if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+        return false;
+
+    CreateContextMenu();
+
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+    OString sCommand(mxMenu->popup_at_rect(pTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
+    MenuSelect(sCommand);
+
     return true;
 }
 
-/**  ExpandedHdl Handler;
-    SV virtual method.
+SfxTemplatePanelControl::SfxTemplatePanelControl(SfxBindings* pBindings, vcl::Window* pParentWindow)
+    : PanelLayout(pParentWindow, "TemplatePanel", "sfx/ui/templatepanel.ui", nullptr)
+    , pImpl(new SfxTemplateDialog_Impl(pBindings, this))
+    , mpBindings(pBindings)
+{
+    OSL_ASSERT(mpBindings!=nullptr);
+}
 
-    [Cross-reference]
-    <StyleTreeListBox_Impl::ExpandingHdl()>
-*/
-void  StyleTreeListBox_Impl::ExpandedHdl()
+SfxTemplatePanelControl::~SfxTemplatePanelControl()
 {
-    SvTreeListEntry *pEntry = GetHdlEntry();
-    if(!IsExpanded(pEntry) && pCurEntry != GetCurEntry())
-        SelectAll( false );
-    pCurEntry = nullptr;
+    disposeOnce();
 }
 
-/** Constructor StyleTreeListBox_Impl */
-StyleTreeListBox_Impl::StyleTreeListBox_Impl(SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle)
-    : DropListBox_Impl(pParent->GetWindow(), nWinStyle, pParent)
-    , pCurEntry(nullptr)
+void SfxTemplatePanelControl::dispose()
 {
-    EnableContextMenuHandling();
+    pImpl.reset();
+    PanelLayout::dispose();
 }
 
-void StyleTreeListBox_Impl::Recalc()
+static void MakeExpanded_Impl(weld::TreeView& rBox, std::vector<OUString>& rEntries)
 {
-    if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
-        SetEntryHeight(32 * GetDPIScaleFactor());
-    else
-        SetEntryHeight(STD_ENTRY_HEIGHT, true);
-    RecalcViewData();
+    std::unique_ptr<weld::TreeIter> xEntry = rBox.make_iterator();
+    if (rBox.get_iter_first(*xEntry))
+    {
+        do
+        {
+            if (rBox.get_row_expanded(*xEntry))
+                rEntries.push_back(rBox.get_text(*xEntry));
+        } while (rBox.iter_next(*xEntry));
+    }
 }
 
 /** Internal structure for the establishment of the hierarchical view */
@@ -615,29 +462,20 @@ static bool IsExpanded_Impl( const std::vector<OUString>& rEntries,
     return false;
 }
 
-static SvTreeListEntry* FillBox_Impl(SvTreeListBox* pBox,
-                              StyleTree_Impl* pEntry,
-                              const std::vector<OUString>& rEntries,
-                              SfxStyleFamily eStyleFamily,
-                              SvTreeListEntry* pParent)
+static void FillBox_Impl(weld::TreeView& rBox,
+                         StyleTree_Impl* pEntry,
+                         const std::vector<OUString>& rEntries,
+                         SfxStyleFamily eStyleFamily,
+                         weld::TreeIter* pParent)
 {
-    SvTreeListEntry* pTreeListEntry = pBox->InsertEntry(pEntry->getName(), pParent);
-
-    if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
-    {
-        pTreeListEntry->ReplaceItem(std::make_unique<StyleLBoxString>(pEntry->getName(), eStyleFamily), 1);
-    }
+    std::unique_ptr<weld::TreeIter> xResult = rBox.make_iterator();
+    const OUString& rName = pEntry->getName();
+    rBox.insert(pParent, -1, &rName, &rName, nullptr, nullptr, nullptr, false, xResult.get());
 
-    pBox->GetModel()->InvalidateEntry(pTreeListEntry);
-
-    for(size_t i = 0; i < pEntry->getChildren().size(); ++i)
-    {
-        FillBox_Impl(pBox, pEntry->getChildren()[i].get(), rEntries, eStyleFamily, pTreeListEntry);
-    }
-    return pTreeListEntry;
+    for (size_t i = 0; i < pEntry->getChildren().size(); ++i)
+        FillBox_Impl(rBox, pEntry->getChildren()[i].get(), rEntries, eStyleFamily, xResult.get());
 }
 
-
 namespace SfxTemplate
 {
     // converts from SFX_STYLE_FAMILY Ids to 1-6
@@ -673,7 +511,7 @@ namespace SfxTemplate
 
 // Constructor
 
-SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl::Window* pW )
+SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl(SfxBindings* pB, vcl::Window* pW, weld::Builder* pBuilder)
     : pBindings(pB)
     , pWindow(pW)
     , pModule(nullptr)
@@ -681,18 +519,16 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
     , pCurObjShell(nullptr)
     , xModuleManager(frame::ModuleManager::create(::comphelper::getProcessComponentContext()))
     , m_pDeletionWatcher(nullptr)
-
-    , aFmtLb( VclPtr<SfxActionListBox>::Create(this, WB_BORDER | WB_TABSTOP) )
-    , pTreeBox( VclPtr<StyleTreeListBox_Impl>::Create(this, WB_HASBUTTONS | WB_HASLINES |
-                                                      WB_BORDER | WB_TABSTOP | WB_HASLINESATROOT |
-                                                      WB_HASBUTTONSATROOT | WB_HIDESELECTION) )
-    , aPreviewCheckbox( VclPtr<CheckBox>::Create( pW, WB_VCENTER ))
-    , aFilterLb( VclPtr<ListBox>::Create(pW, WB_BORDER | WB_DROPDOWN | WB_TABSTOP) )
+    , mxFmtLb(pBuilder->weld_tree_view("flatview"))
+    , mxTreeBox(pBuilder->weld_tree_view("treeview"))
+    , mxPreviewCheckbox(pBuilder->weld_check_button("showpreview"))
+    , mxFilterLb(pBuilder->weld_combo_box("filter"))
 
     , nActFamily(0xffff)
     , nActFilter(0)
     , nAppFilter(SfxStyleSearchBits::Auto)
 
+    , m_nModifier(0)
     , bDontUpdate(false)
     , bIsWater(false)
     , bUpdate(false)
@@ -706,24 +542,15 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
     , bNewByExampleDisabled(false)
     , bUpdateByExampleDisabled(false)
     , bTreeDrag(true)
+    , bAllowReParentDrop(false)
     , bHierarchical(false)
     , m_bWantHierarchical(false)
     , bBindingUpdate(true)
+    , m_bNewHasMenu(false)
 {
-    aFmtLb->SetQuickSearch(true);
-    aFmtLb->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST));
-    aFmtLb->SetHelpId( HID_TEMPLATE_FMT );
-    aFilterLb->SetHelpId( HID_TEMPLATE_FILTER );
-    aFmtLb->SetStyle( aFmtLb->GetStyle() | WB_HIDESELECTION );
-    vcl::Font aFont = aFmtLb->GetFont();
-    aFont.SetWeight( WEIGHT_NORMAL );
-    aFmtLb->SetFont( aFont );
-    pTreeBox->SetQuickSearch(true);
-    pTreeBox->SetNodeDefaultImages();
-    pTreeBox->SetOptimalImageIndent();
-    pTreeBox->SetAccessibleName(SfxResId(STR_STYLE_ELEMTLIST));
-    aPreviewCheckbox->Check(officecfg::Office::Common::StylesAndFormatting::Preview::get());
-    aPreviewCheckbox->SetText( SfxResId(STR_PREVIEW_CHECKBOX) );
+    mxFmtLb->set_help_id(HID_TEMPLATE_FMT);
+    mxFilterLb->set_help_id(HID_TEMPLATE_FILTER);
+    mxPreviewCheckbox->set_active(officecfg::Office::Common::StylesAndFormatting::Preview::get());
 }
 
 sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
@@ -736,7 +563,7 @@ void SfxTemplateDialog_Impl::EnableEdit(bool bEnable)
 {
     SfxCommonTemplateDialog_Impl::EnableEdit( bEnable );
     if( !bEnable || !bUpdateByExampleDisabled )
-        EnableItem( SID_STYLE_UPDATE_BY_EXAMPLE, bEnable);
+        EnableItem("update", bEnable);
 }
 
 void SfxCommonTemplateDialog_Impl::ReadResource()
@@ -833,8 +660,6 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
         InsertFamilyItem(nId, rItem);
     }
 
-    LoadedFamilies();
-
     for ( i = SID_STYLE_FAMILY1; i <= SID_STYLE_FAMILY4; i++ )
         pBindings->Update(i);
 }
@@ -864,6 +689,29 @@ SfxCommonTemplateDialog_Impl::impl_setDeletionWatcher(
     return pRet;
 }
 
+class TreeViewDropTarget final : public DropTargetHelper
+{
+private:
+    SfxCommonTemplateDialog_Impl& m_rParent;
+
+public:
+    TreeViewDropTarget(SfxCommonTemplateDialog_Impl& rDialog, weld::TreeView& rTreeView)
+        : DropTargetHelper(rTreeView.get_drop_target())
+        , m_rParent(rDialog)
+    {
+    }
+
+    virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override
+    {
+        return m_rParent.AcceptDrop(rEvt, *this);
+    }
+
+    virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
+    {
+        return m_rParent.ExecuteDrop(rEvt);
+    }
+};
+
 void SfxCommonTemplateDialog_Impl::Initialize()
 {
     // Read global user resource
@@ -871,22 +719,41 @@ void SfxCommonTemplateDialog_Impl::Initialize()
     pBindings->Invalidate( SID_STYLE_FAMILY );
     pBindings->Update( SID_STYLE_FAMILY );
 
-    Update_Impl();
-
-    aFilterLb->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FilterSelectHdl ) );
-    aFmtLb->SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, TreeListApplyHdl ) );
-    aFmtLb->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
-    aFmtLb->SetSelectionMode(SelectionMode::Multiple);
-    pTreeBox->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
-    pTreeBox->SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl,  ApplyHdl ) );
-    pTreeBox->SetDropHdl( LINK( this, SfxCommonTemplateDialog_Impl,  DropHdl ) );
-    aPreviewCheckbox->SetClickHdl( LINK(this, SfxCommonTemplateDialog_Impl, PreviewHdl));
+    mxFilterLb->connect_changed(LINK(this, SfxCommonTemplateDialog_Impl, FilterSelectHdl));
+    mxFmtLb->connect_row_activated(LINK( this, SfxCommonTemplateDialog_Impl, TreeListApplyHdl));
+    mxFmtLb->connect_mouse_press(LINK(this, SfxCommonTemplateDialog_Impl, MousePressHdl));
+    mxFmtLb->connect_query_tooltip(LINK(this, SfxCommonTemplateDialog_Impl, QueryTooltipHdl));
+    mxFmtLb->connect_changed(LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl));
+    mxFmtLb->connect_popup_menu(LINK(this, SfxCommonTemplateDialog_Impl, PopupFlatMenuHdl));
+    mxFmtLb->connect_key_press(LINK(this, SfxCommonTemplateDialog_Impl, KeyInputHdl));
+    mxFmtLb->set_selection_mode(SelectionMode::Multiple);
+    mxTreeBox->connect_changed(LINK(this, SfxCommonTemplateDialog_Impl, FmtSelectHdl));
+    mxTreeBox->connect_row_activated(LINK( this, SfxCommonTemplateDialog_Impl, TreeListApplyHdl));
+    mxTreeBox->connect_mouse_press(LINK(this, SfxCommonTemplateDialog_Impl, MousePressHdl));
+    mxTreeBox->connect_query_tooltip(LINK(this, SfxCommonTemplateDialog_Impl, QueryTooltipHdl));
+    mxTreeBox->connect_popup_menu(LINK(this, SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl));
+    mxTreeBox->connect_key_press(LINK(this, SfxCommonTemplateDialog_Impl, KeyInputHdl));
+    mxTreeBox->connect_drag_begin(LINK(this, SfxCommonTemplateDialog_Impl, DragBeginHdl));
+    mxPreviewCheckbox->connect_clicked(LINK(this, SfxCommonTemplateDialog_Impl, PreviewHdl));
+    m_xTreeView1DropTargetHelper.reset(new TreeViewDropTarget(*this, *mxFmtLb));
+    m_xTreeView2DropTargetHelper.reset(new TreeViewDropTarget(*this, *mxTreeBox));
+
+    int nTreeHeight = mxFmtLb->get_height_rows(8);
+    mxFmtLb->set_size_request(-1, nTreeHeight);
+    mxTreeBox->set_size_request(-1, nTreeHeight);
+
+    mxFmtLb->connect_custom_get_size(LINK(this, SfxCommonTemplateDialog_Impl, CustomGetSizeHdl));
+    mxFmtLb->connect_custom_render(LINK(this, SfxCommonTemplateDialog_Impl, CustomRenderHdl));
+    mxTreeBox->connect_custom_get_size(LINK(this, SfxCommonTemplateDialog_Impl, CustomGetSizeHdl));
+    mxTreeBox->connect_custom_render(LINK(this, SfxCommonTemplateDialog_Impl, CustomRenderHdl));
+    bool bCustomPreview = officecfg::Office::Common::StylesAndFormatting::Preview::get();
+    mxFmtLb->set_column_custom_renderer(0, bCustomPreview);
+    mxTreeBox->set_column_custom_renderer(0, bCustomPreview);
+
+    mxFmtLb->set_visible(!bHierarchical);
+    mxTreeBox->set_visible(bHierarchical);
 
-
-    aFilterLb->Show();
-    if (!bHierarchical)
-        aFmtLb->Show();
-    aPreviewCheckbox->Show();
+    Update_Impl();
 }
 
 SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
@@ -898,13 +765,15 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
     if ( pStyleSheetPool )
         EndListening(*pStyleSheetPool);
     pStyleSheetPool = nullptr;
-    pTreeBox.disposeAndClear();
+    m_xTreeView1DropTargetHelper.reset();
+    m_xTreeView2DropTargetHelper.reset();
+    mxTreeBox.reset();
     pIdle.reset();
     if ( m_pDeletionWatcher )
         m_pDeletionWatcher->signal();
-    aFmtLb.disposeAndClear();
-    aPreviewCheckbox.disposeAndClear();
-    aFilterLb.disposeAndClear();
+    mxFmtLb.reset();
+    mxPreviewCheckbox.reset();
+    mxFilterLb.reset();
 }
 
 // Helper function: Access to the current family item
@@ -934,17 +803,17 @@ void SfxCommonTemplateDialog_Impl::GetSelectedStyle() const
  * Is it safe to show the water-can / fill icon. If we've a
  * hierarchical widget - we have only single select, otherwise
  * we need to check if we have a multi-selection. We either have
- * a pTreeBox showing or an aFmtLb (which we hide when not shown)
+ * a mxTreeBox showing or an mxFmtLb (which we hide when not shown)
  */
 bool SfxCommonTemplateDialog_Impl::IsSafeForWaterCan() const
 {
-    if ( pTreeBox->IsVisible() )
-        return pTreeBox->FirstSelected() != nullptr;
+    if (mxTreeBox->get_visible())
+        return mxTreeBox->get_selected_index() != -1;
     else
-        return aFmtLb->GetSelectionCount() == 1;
+        return mxFmtLb->count_selected_rows() == 1;
 }
 
-void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
+void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr, bool bIsCallback)
 {
     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
     if ( !pItem )
@@ -960,93 +829,85 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
     }
     else
     {
-        EnableEdit( false );
-        EnableHide( false );
-        EnableShow( false );
+        EnableEdit(false);
+        EnableHide(false);
+        EnableShow(false);
     }
 
-    if ( pTreeBox->IsVisible() )
+    if (!bIsCallback)
     {
-        if ( !rStr.isEmpty() )
+        if (mxTreeBox->get_visible())
         {
-            SvTreeListEntry* pEntry = pTreeBox->First();
-            while ( pEntry )
+            if (!rStr.isEmpty())
             {
-                if ( pTreeBox->GetEntryText( pEntry ) == rStr )
+                std::unique_ptr<weld::TreeIter> xEntry = mxTreeBox->make_iterator();
+                bool bEntry = mxTreeBox->get_iter_first(*xEntry);
+                while (bEntry)
                 {
-                    pTreeBox->MakeVisible( pEntry );
-                    pTreeBox->Select( pEntry );
-                    return;
+                    if (mxTreeBox->get_text(*xEntry) == rStr)
+                    {
+                        mxTreeBox->scroll_to_row(*xEntry);
+                        mxTreeBox->select(*xEntry);
+                        return;
+                    }
+                    bEntry = mxTreeBox->iter_next(*xEntry);
                 }
-                pEntry = pTreeBox->Next( pEntry );
             }
+            else
+                mxTreeBox->unselect_all();
         }
         else
-            pTreeBox->SelectAll( false );
-    }
-    else
-    {
-        bool bSelect = ! rStr.isEmpty();
-        if ( bSelect )
         {
-            SvTreeListEntry* pEntry = aFmtLb->FirstVisible();
-            while ( pEntry && aFmtLb->GetEntryText( pEntry ) != rStr )
-                pEntry = aFmtLb->NextVisible( pEntry );
-            if ( !pEntry )
-                bSelect = false;
-            else
+            bool bSelect = !rStr.isEmpty();
+            if (bSelect)
             {
-                if (!aFmtLb->IsSelected(pEntry))
+                std::unique_ptr<weld::TreeIter> xEntry = mxFmtLb->make_iterator();
+                bool bEntry = mxFmtLb->get_iter_first(*xEntry);
+                while (bEntry && mxFmtLb->get_text(*xEntry) != rStr)
+                    bEntry = mxFmtLb->iter_next(*xEntry);
+                if (!bEntry)
+                    bSelect = false;
+                else
                 {
-                    aFmtLb->MakeVisible( pEntry );
-                    aFmtLb->SelectAll(false);
-                    aFmtLb->Select( pEntry );
-                    bWaterDisabled = !IsSafeForWaterCan();
-                    FmtSelectHdl( nullptr );
+                    if (!mxFmtLb->is_selected(*xEntry))
+                    {
+                        mxFmtLb->unselect_all();
+                        mxFmtLb->scroll_to_row(*xEntry);
+                        mxFmtLb->select(*xEntry);
+                        FmtSelect(nullptr, bIsCallback);
+                    }
                 }
             }
-        }
 
-        if ( !bSelect )
-        {
-            aFmtLb->SelectAll( false );
-            EnableEdit(false);
-            EnableHide( false );
-            EnableShow( false );
+            if (!bSelect)
+            {
+                mxFmtLb->unselect_all();
+                EnableEdit(false);
+                EnableHide(false);
+                EnableShow(false);
+            }
         }
     }
+
+    bWaterDisabled = !IsSafeForWaterCan();
 }
 
 OUString SfxCommonTemplateDialog_Impl::GetSelectedEntry() const
 {
     OUString aRet;
-    if ( pTreeBox->IsVisible() )
-    {
-        SvTreeListEntry* pEntry = pTreeBox->FirstSelected();
-        if ( pEntry )
-            aRet = pTreeBox->GetEntryText( pEntry );
-    }
+    if (mxTreeBox->get_visible())
+        aRet = mxTreeBox->get_selected_text();
     else
-    {
-        SvTreeListEntry* pEntry = aFmtLb->FirstSelected();
-        if ( pEntry )
-            aRet = aFmtLb->GetEntryText( pEntry );
-    }
+        aRet = mxFmtLb->get_selected_text();
     return aRet;
 }
 
-void SfxCommonTemplateDialog_Impl::EnableTreeDrag( bool bEnable )
+void SfxCommonTemplateDialog_Impl::EnableTreeDrag(bool bEnable)
 {
-    if ( pStyleSheetPool )
+    if (pStyleSheetPool)
     {
         SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
-        if ( pTreeBox->IsVisible() )
-        {
-            if ( pStyle && pStyle->HasParentSupport() && bEnable )
-                pTreeBox->SetDragDropMode(DragDropMode::CTRL_MOVE);
-            else
-                pTreeBox->SetDragDropMode(DragDropMode::NONE);
-        }
+        bAllowReParentDrop = pStyle && pStyle->HasParentSupport() && bEnable;
     }
     bTreeDrag = bEnable;
 }
@@ -1091,7 +952,7 @@ OUString SfxCommonTemplateDialog_Impl::getDefaultStyleName( const SfxStyleFamily
 
 void SfxCommonTemplateDialog_Impl::FillTreeBox()
 {
-    OSL_ENSURE( pTreeBox, "FillTreeBox() without treebox");
+    assert(mxTreeBox && "FillTreeBox() without treebox");
     if (!pStyleSheetPool || nActFamily == 0xffff)
         return;
 
@@ -1103,10 +964,7 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
     StyleTreeArr_Impl aArr;
     SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
 
-    if(pStyle && pStyle->HasParentSupport() && bTreeDrag )
-        pTreeBox->SetDragDropMode(DragDropMode::CTRL_MOVE);
-    else
-        pTreeBox->SetDragDropMode(DragDropMode::NONE);
+    bAllowReParentDrop = pStyle && pStyle->HasParentSupport() && bTreeDrag;
 
     while (pStyle)
     {
@@ -1117,44 +975,46 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
     OUString aUIName = getDefaultStyleName(eFam);
     MakeTree_Impl(aArr, aUIName);
     std::vector<OUString> aEntries;
-    pTreeBox->MakeExpanded_Impl(aEntries);
-    pTreeBox->SetUpdateMode( false );
-    pTreeBox->Clear();
+    MakeExpanded_Impl(*mxTreeBox, aEntries);
+    mxTreeBox->freeze();
+    mxTreeBox->clear();
     const sal_uInt16 nCount = aArr.size();
 
     for (sal_uInt16 i = 0; i < nCount; ++i)
     {
-        FillBox_Impl(pTreeBox, aArr[i].get(), aEntries, eFam, nullptr);
+        FillBox_Impl(*mxTreeBox, aArr[i].get(), aEntries, eFam, nullptr);
         aArr[i].reset();
     }
-    pTreeBox->Recalc();
 
-    EnableItem(SID_STYLE_WATERCAN, false);
+    EnableItem("watercan", false);
 
     SfxTemplateItem* pState = pFamilyState[nActFamily - 1].get();
 
-    if (nCount)
-        pTreeBox->Expand(pTreeBox->First());
+    mxTreeBox->thaw();
+
+    std::unique_ptr<weld::TreeIter> xEntry = mxTreeBox->make_iterator();
+    bool bEntry = mxTreeBox->get_iter_first(*xEntry);
+    if (bEntry && nCount)
+        mxTreeBox->expand_row(*xEntry);
 
-    for (SvTreeListEntry* pEntry = pTreeBox->First(); pEntry; pEntry = pTreeBox->Next(pEntry))
+    while (bEntry)
     {
-        if (IsExpanded_Impl(aEntries, pTreeBox->GetEntryText(pEntry)))
-            pTreeBox->Expand(pEntry);
+        if (IsExpanded_Impl(aEntries, mxTreeBox->get_text(*xEntry)))
+            mxTreeBox->expand_row(*xEntry);
+        bEntry = mxTreeBox->iter_next(*xEntry);
     }
 
-    pTreeBox->SetUpdateMode( true );
-
     OUString aStyle;
     if(pState)  // Select current entry
         aStyle = pState->GetStyleName();
-    SelectStyle(aStyle);
+    SelectStyle(aStyle, false);
     EnableDelete();
 }
 
 bool SfxCommonTemplateDialog_Impl::HasSelectedStyle() const
 {
-    return pTreeBox->IsVisible()? pTreeBox->FirstSelected() != nullptr:
-            aFmtLb->GetSelectionCount() != 0;
+    return mxTreeBox->get_visible() ? mxTreeBox->get_selected_index() != -1
+                                    : mxFmtLb->count_selected_rows() != 0;
 }
 
 // internal: Refresh the display
@@ -1192,58 +1052,58 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
     pItem = GetFamilyItem_Impl();
     if(nFlags & StyleFlags::UpdateFamily)   // Update view type list (Hierarchical, All, etc.
     {
-        CheckItem(nActFamily);    // check Button in Toolbox
-        aFilterLb->SetUpdateMode(false);
-        aFilterLb->Clear();
+        CheckItem(OString::number(nActFamily));    // check Button in Toolbox
+
+        mxFilterLb->freeze();
+        mxFilterLb->clear();
+
         //insert hierarchical at the beginning
-        sal_Int32 nPos = aFilterLb->InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL), 0);
-        aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SfxStyleSearchBits::All) );
+        mxFilterLb->append(OUString::number(static_cast<int>(SfxStyleSearchBits::All)), SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
         const SfxStyleFilter& rFilter = pItem->GetFilterList();
-        for(const SfxFilterTuple& i : rFilter)
+        for (const SfxFilterTuple& i : rFilter)
         {
             SfxStyleSearchBits nFilterFlags = i.nFlags;
-            nPos = aFilterLb->InsertEntry( i.aName );
-            aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(nFilterFlags) );
+            mxFilterLb->append(OUString::number(static_cast<int>(nFilterFlags)), i.aName);
         }
-        if(nActFilter < aFilterLb->GetEntryCount() - 1)
-            aFilterLb->SelectEntryPos(nActFilter + 1);
+        mxFilterLb->thaw();
+
+        if (nActFilter < mxFilterLb->get_count() - 1)
+            mxFilterLb->set_active(nActFilter + 1);
         else
         {
             nActFilter = 0;
-            aFilterLb->SelectEntryPos(1);
+            mxFilterLb->set_active(1);
             SfxStyleSearchBits nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : SfxStyleSearchBits::Auto;
             pStyleSheetPool->SetSearchMask(eFam, nFilterFlags);
         }
 
         // if the tree view again, select family hierarchy
-        if (pTreeBox->IsVisible() || m_bWantHierarchical)
+        if (mxTreeBox->get_visible() || m_bWantHierarchical)
         {
-            aFilterLb->SelectEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
+            mxFilterLb->set_active_text(SfxResId(STR_STYLE_FILTER_HIERARCHICAL));
             EnableHierarchical(true);
         }
-
-        // show maximum 14 entries
-        aFilterLb->SetDropDownLineCount( MAX_FILTER_ENTRIES );
-        aFilterLb->SetUpdateMode(true);
     }
     else
     {
-        if (nActFilter < aFilterLb->GetEntryCount() - 1)
-            aFilterLb->SelectEntryPos(nActFilter + 1);
+        if (nActFilter < mxFilterLb->get_count() - 1)
+            mxFilterLb->set_active(nActFilter + 1);
         else
         {
             nActFilter = 0;
-            aFilterLb->SelectEntryPos(1);
+            mxFilterLb->set_active(1);
         }
     }
 
     if(!(nFlags & StyleFlags::UpdateFamilyList))
         return;
 
-    EnableItem(SID_STYLE_WATERCAN,false);
+    EnableItem("watercan", false);
 
     SfxStyleSheetBase *pStyle = pStyleSheetPool->First();
-    SvTreeListEntry* pEntry = aFmtLb->First();
+
+    std::unique_ptr<weld::TreeIter> xEntry = mxFmtLb->make_iterator();
+    bool bEntry = mxFmtLb->get_iter_first(*xEntry);
     std::vector<OUString> aStrings;
 
     comphelper::string::NaturalStringSorter aSorter(
@@ -1273,37 +1133,30 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
 
     size_t nCount = aStrings.size();
     size_t nPos = 0;
-    while(nPos < nCount && pEntry &&
-          aStrings[nPos] == aFmtLb->GetEntryText(pEntry))
+    while (nPos < nCount && bEntry &&
+           aStrings[nPos] == mxFmtLb->get_text(*xEntry))
     {
         ++nPos;
-        pEntry = aFmtLb->Next( pEntry );
+        bEntry = mxFmtLb->iter_next(*xEntry);
     }
 
-    if( nPos < nCount || pEntry )
+    if (nPos < nCount || bEntry)
     {
         // Fills the display box
-        aFmtLb->SetUpdateMode(false);
-        aFmtLb->Clear();
+        mxFmtLb->freeze();
+        mxFmtLb->clear();
 
-        for(nPos = 0; nPos < nCount; ++nPos)
-        {
-            SvTreeListEntry* pTreeListEntry = aFmtLb->InsertEntry(aStrings[nPos], nullptr, false, nPos);
-            if (officecfg::Office::Common::StylesAndFormatting::Preview::get())
-            {
-                pTreeListEntry->ReplaceItem(std::make_unique<StyleLBoxString>(aStrings[nPos], eFam), 1);
-            }
-            aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry);
-        }
-        aFmtLb->Recalc();
-        aFmtLb->SetUpdateMode(true);
+        for (nPos = 0; nPos < nCount; ++nPos)
+            mxFmtLb->append(aStrings[nPos], aStrings[nPos]);
+
+        mxFmtLb->thaw();
     }
     // Selects the current style if any
     SfxTemplateItem *pState = pFamilyState[nActFamily-1].get();
     OUString aStyle;
     if(pState)
         aStyle = pState->GetStyleName();
-    SelectStyle(aStyle);
+    SelectStyle(aStyle, false);
     EnableDelete();
 }
 
@@ -1318,15 +1171,15 @@ void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
 
     if(pItem && !bWaterDisabled)
     {
-        CheckItem(SID_STYLE_WATERCAN, pItem->GetValue());
-        EnableItem( SID_STYLE_WATERCAN );
+        CheckItem("watercan", pItem->GetValue());
+        EnableItem("watercan");
     }
     else
     {
         if(!bWaterDisabled)
-            EnableItem(SID_STYLE_WATERCAN);
+            EnableItem("watercan");
         else
-            EnableItem(SID_STYLE_WATERCAN, false);
+            EnableItem("watercan", false);
     }
 
 // Ignore while in watercan mode statusupdates
@@ -1411,7 +1264,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
     // current region not within the allowed region or default
     if(nActFamily == 0xffff || nullptr == (pItem = pFamilyState[nActFamily-1].get() ) )
     {
-         CheckItem(nActFamily, false);
+         CheckItem(OString::number(nActFamily), false);
          const size_t nFamilyCount = pStyleFamilies->size();
          size_t n;
          for( n = 0; n < nFamilyCount; n++ )
@@ -1425,13 +1278,13 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
     else if( bDocChanged )
     {
          // other DocShell -> all new
-         CheckItem( nActFamily );
+         CheckItem(OString::number(nActFamily));
          nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) );
          if ( 0xffff == nActFilter )
             nActFilter = pDocShell->GetAutoStyleFilterIndex();
 
          nAppFilter = pItem->GetValue();
-         if(!pTreeBox->IsVisible())
+         if (!mxTreeBox->get_visible())
          {
              UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
          }
@@ -1441,13 +1294,13 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
     else
     {
          // other filters for automatic
-         CheckItem( nActFamily );
+         CheckItem(OString::number(nActFamily));
          const SfxStyleFamilyItem *pStyleItem =  GetFamilyItem_Impl();
          if ( pStyleItem && SfxStyleSearchBits::Auto == pStyleItem->GetFilterList()[nActFilter].nFlags
             && nAppFilter != pItem->GetValue())
          {
              nAppFilter = pItem->GetValue();
-             if(!pTreeBox->IsVisible())
+             if (!mxTreeBox->get_visible())
                  UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
              else
                  FillTreeBox();
@@ -1456,7 +1309,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
              nAppFilter = pItem->GetValue();
     }
     const OUString aStyle(pItem->GetStyleName());
-    SelectStyle(aStyle);
+    SelectStyle(aStyle, false);
     EnableDelete();
     EnableNew( bCanNew );
 }
@@ -1466,7 +1319,7 @@ IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, void )
     if(!bDontUpdate)
     {
         bDontUpdate=true;
-        if(!pTreeBox->IsVisible())
+        if (!mxTreeBox->get_visible())
             UpdateStyles_Impl(StyleFlags::UpdateFamilyList);
         else
         {
@@ -1474,7 +1327,7 @@ IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, void )
             SfxTemplateItem *pState = pFamilyState[nActFamily-1].get();
             if(pState)
             {
-                SelectStyle(pState->GetStyleName());
+                SelectStyle(pState->GetStyleName(), false);
                 EnableDelete();
             }
         }
@@ -1499,7 +1352,7 @@ void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint
                 if (
                         bUpdate &&
                         (
-                         !IsCheckedItem(SID_STYLE_WATERCAN) ||
+                         !IsCheckedItem("watercan") ||
                          (pDocShell && pDocShell->GetStyleSheetPool() != pStyleSheetPool)
                         )
                    )
@@ -1642,7 +1495,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
     if ( !pItem || aDeleted )
         return false;
 
-    if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1) )
+    if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (mxTreeBox->get_visible() || mxFmtLb->count_selected_rows() <= 1) )
     {
         const SfxUInt16Item *pFilterItem = dynamic_cast< const SfxUInt16Item* >(pItem);
         assert(pFilterItem);
@@ -1676,29 +1529,27 @@ void SfxCommonTemplateDialog_Impl::EnableHierarchical(bool const bEnable)
             m_bWantHierarchical = true;
             SaveSelection(); // fdo#61429 store "hierarchical"
             const OUString aSelectEntry( GetSelectedEntry());
-            aFmtLb->Hide();
-            pTreeBox->SetFont( aFmtLb->GetFont() );
-            pTreeBox->SetPosSizePixel(aFmtLb->GetPosPixel(), aFmtLb->GetSizePixel());
+            mxFmtLb->hide();
             FillTreeBox();
-            SelectStyle(aSelectEntry);
-            pTreeBox->Show();
+            SelectStyle(aSelectEntry, false);
+            mxTreeBox->show();
         }
     }
     else
     {
-        pTreeBox->Hide();
-        aFmtLb->Show();
+        mxTreeBox->hide();
+        mxFmtLb->show();
         // If bHierarchical, then the family can have changed
         // minus one since hierarchical is inserted at the start
         m_bWantHierarchical = false; // before FilterSelect
-        FilterSelect(aFilterLb->GetSelectedEntryPos() - 1, bHierarchical );
+        FilterSelect(mxFilterLb->get_active() - 1, bHierarchical );
         bHierarchical=false;
     }
 }
 
-IMPL_LINK( SfxCommonTemplateDialog_Impl, FilterSelectHdl, ListBox&, rBox, void )
+IMPL_LINK(SfxCommonTemplateDialog_Impl, FilterSelectHdl, weld::ComboBox&, rBox, void)
 {
-    if (SfxResId(STR_STYLE_FILTER_HIERARCHICAL) == rBox.GetSelectedEntry())
+    if (SfxResId(STR_STYLE_FILTER_HIERARCHICAL) == rBox.get_active_text())
     {
         EnableHierarchical(true);
     }
@@ -1714,7 +1565,7 @@ void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, bool bPreview
     assert((0 < nEntry && nEntry <= MAX_FAMILIES) || 0xffff == nEntry);
     if( nEntry != nActFamily || bPreviewRefresh )
     {
-        CheckItem( nActFamily, false );
+        CheckItem(OString::number(nActFamily), false);
         nActFamily = nEntry;
         SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl();
         SfxUInt16Item const aItem(SID_STYLE_FAMILY,
@@ -1726,80 +1577,74 @@ void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry, bool bPreview
     }
 }
 
-void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
+void SfxCommonTemplateDialog_Impl::ActionSelect(const OString& rEntry)
 {
-    switch(nEntry)
+    if (rEntry == "watercan")
     {
-        case SID_STYLE_WATERCAN:
+        const bool bOldState = !IsCheckedItem(rEntry);
+        bool bCheck;
+        SfxBoolItem aBool;
+        // when a template is chosen.
+        if (!bOldState && HasSelectedStyle())
         {
-            const bool bState = IsCheckedItem(nEntry);
-            bool bCheck;
-            SfxBoolItem aBool;
-            // when a template is chosen.
-            if (!bState && HasSelectedStyle())
-            {
-                const OUString aTemplName(
-                    GetSelectedEntry());
-                Execute_Impl(
-                    SID_STYLE_WATERCAN, aTemplName, "",
-                    static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
-                bCheck = true;
-            }
-            else
-            {
-                Execute_Impl(SID_STYLE_WATERCAN, "", "", 0);
-                bCheck = false;
-            }
-            CheckItem(nEntry, bCheck);
-            aBool.SetValue(bCheck);
-            SetWaterCanState(&aBool);
-            break;
+            const OUString aTemplName(
+                GetSelectedEntry());
+            Execute_Impl(
+                SID_STYLE_WATERCAN, aTemplName, "",
+                static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
+            bCheck = true;
         }
-        case SID_STYLE_NEW_BY_EXAMPLE:
+        else
+        {
+            Execute_Impl(SID_STYLE_WATERCAN, "", "", 0);
+            bCheck = false;
+        }
+        CheckItem(rEntry, bCheck);
+        aBool.SetValue(bCheck);
+        SetWaterCanState(&aBool);
+    }
+    else if (rEntry == "new" || rEntry == "newmenu")
+    {
+        if(pStyleSheetPool && nActFamily != 0xffff)
         {
-            if(pStyleSheetPool && nActFamily != 0xffff)
+            const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily();
+            const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
+            SfxStyleSearchBits nFilter;
+            if( pItem && nActFilter != 0xffff )
             {
-                const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily();
-                const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
-                SfxStyleSearchBits nFilter;
-                if( pItem && nActFilter != 0xffff )
-                {
-                    nFilter = pItem->GetFilterList()[nActFilter].nFlags;
-                    if(nFilter == SfxStyleSearchBits::Auto)    // automatic
-                        nFilter = nAppFilter;
-                }
-                else
-                    nFilter=pStyleSheetPool->GetSearchMask();
-                pStyleSheetPool->SetSearchMask( eFam, SfxStyleSearchBits::UserDefined );
+                nFilter = pItem->GetFilterList()[nActFilter].nFlags;
+                if(nFilter == SfxStyleSearchBits::Auto)    // automatic
+                    nFilter = nAppFilter;
+            }
+            else
+                nFilter=pStyleSheetPool->GetSearchMask();
+            pStyleSheetPool->SetSearchMask( eFam, SfxStyleSearchBits::UserDefined );
 
-                // why? : FloatingWindow must not be parent of a modal dialog
-                SfxNewStyleDlg aDlg(pWindow ? pWindow->GetFrameWeld() : nullptr, *pStyleSheetPool);
-                if (aDlg.run() ==  RET_OK)
-                {
-                    pStyleSheetPool->SetSearchMask(eFam, nFilter);
-                    const OUString aTemplName(aDlg.GetName());
-                    Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE,
-                                 aTemplName, "",
-                                 static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()),
-                                 nFilter);
-                    UpdateFamily_Impl();
-                }
-                pStyleSheetPool->SetSearchMask( eFam, nFilter );
+            // why? : FloatingWindow must not be parent of a modal dialog
+            SfxNewStyleDlg aDlg(pWindow ? pWindow->GetFrameWeld() : nullptr, *pStyleSheetPool);
+            if (aDlg.run() ==  RET_OK)
+            {
+                pStyleSheetPool->SetSearchMask(eFam, nFilter);
+                const OUString aTemplName(aDlg.GetName());
+                Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE,
+                             aTemplName, "",
+                             static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()),
+                             nFilter);
+                UpdateFamily_Impl();
             }
-            break;
-        }
-        case SID_STYLE_UPDATE_BY_EXAMPLE:
-        {
-            Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE,
-                    "", "",
-                    static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
-            break;
+            pStyleSheetPool->SetSearchMask( eFam, nFilter );
         }
-        case SID_TEMPLATE_LOAD:
-            SfxGetpApp()->GetDispatcher_Impl()->Execute(nEntry);
-        break;
-        default: OSL_FAIL("not implemented"); break;
     }
+    else if (rEntry == "update")
+    {
+        Execute_Impl(SID_STYLE_UPDATE_BY_EXAMPLE,
+                "", "",
+                static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
+    }
+    else if (rEntry == "load")
+        SfxGetpApp()->GetDispatcher_Impl()->Execute(SID_TEMPLATE_LOAD);
+    else
+        SAL_WARN("sfx", "not implemented: " << rEntry);
 }
 
 static OUString getModuleIdentifier( const Reference< XModuleManager2 >& i_xModMgr, SfxObjectShell const * i_pObjSh )
@@ -1860,20 +1705,19 @@ SfxObjectShell* SfxCommonTemplateDialog_Impl::SaveSelection()
     return pDocShell;
 }
 
-IMPL_LINK( SfxCommonTemplateDialog_Impl, DropHdl, StyleTreeListBox_Impl&, rBox, bool )
+void SfxCommonTemplateDialog_Impl::DropHdl(const OUString& rStyle, const OUString& rParent)
 {
     bDontUpdate = true;
     const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
     const SfxStyleFamily eFam = pItem->GetFamily();
-    bool ret = pStyleSheetPool->SetParent(eFam, rBox.GetStyle(), rBox.GetParent());
+    pStyleSheetPool->SetParent(eFam, rStyle, rParent);
     bDontUpdate = false;
-    return ret;
 }
 
 // Handler for the New-Buttons
 void SfxCommonTemplateDialog_Impl::NewHdl()
 {
-    if ( nActFamily == 0xffff || !(pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1))
+    if ( nActFamily == 0xffff || !(mxTreeBox->get_visible() || mxFmtLb->count_selected_rows() <= 1))
         return;
 
     const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
@@ -1917,18 +1761,17 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
 
     bool bUsedStyle = false;     // one of the selected styles are used in the document?
 
-    std::vector<SvTreeListEntry*> aList;
-    SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
+    std::vector<std::unique_ptr<weld::TreeIter>> aList;
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
 
     OUStringBuffer aMsg;
     aMsg.append(SfxResId(STR_DELETE_STYLE_USED)).append(SfxResId(STR_DELETE_STYLE));
 
-    while (pEntry)
-    {
-        aList.push_back( pEntry );
+    pTreeView->selected_foreach([this, pTreeView, pItem, &aList, &bUsedStyle, &aMsg](weld::TreeIter& rEntry){
+        aList.emplace_back(pTreeView->make_iterator(&rEntry));
         // check the style is used or not
-        const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry));
+        const OUString aTemplName(pTreeView->get_text(rEntry));
 
         SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily() );
 
@@ -1940,17 +1783,17 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
             bUsedStyle = true;
         }
 
-        pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
-    }
+        return false;
+    });
 
     bool aApproved = false;
 
     // we only want to show the dialog once and if we want to delete a style in use (UX-advice)
-    if ( bUsedStyle )
+    if (bUsedStyle)
     {
-        std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
-                                                                 VclMessageType::Question, VclButtonsType::YesNo,
-                                                                 aMsg.makeStringAndClear()));
+        std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pTreeView,
+                                                  VclMessageType::Question, VclButtonsType::YesNo,
+                                                  aMsg.makeStringAndClear()));
         aApproved = xBox->run() == RET_YES;
     }
 
@@ -1960,14 +1803,14 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
 
     for (auto const& elem : aList)
     {
-        const OUString aTemplName(pTreeBox->IsVisible() ? pTreeBox->GetEntryText(elem) : aFmtLb->GetEntryText(elem));
+        const OUString aTemplName(pTreeView->get_text(*elem));
         bDontUpdate = true; // To prevent the Treelistbox to shut down while deleting
         Execute_Impl( SID_STYLE_DELETE, aTemplName,
                       OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-        if ( pTreeBox->IsVisible() )
+        if (mxTreeBox->get_visible())
         {
-            pTreeBox->RemoveParentKeepChildren(elem);
+            weld::RemoveParentKeepChildren(*mxTreeBox, *elem);
             bDontUpdate = false;
         }
     }
@@ -1980,17 +1823,15 @@ void SfxCommonTemplateDialog_Impl::HideHdl()
     if ( !IsInitialized() || !HasSelectedStyle() )
         return;
 
-    SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
-
-    while (pEntry)
-    {
-        OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+    pTreeView->selected_foreach([this, pTreeView](weld::TreeIter& rEntry){
+        OUString aTemplName = pTreeView->get_text(rEntry);
 
         Execute_Impl( SID_STYLE_HIDE, aTemplName,
                       OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-        pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
-    }
+        return false;
+    });
 }
 
 void SfxCommonTemplateDialog_Impl::ShowHdl()
@@ -1998,17 +1839,15 @@ void SfxCommonTemplateDialog_Impl::ShowHdl()
     if ( !IsInitialized() || !HasSelectedStyle() )
         return;
 
-    SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
-
-    while (pEntry)
-    {
-        OUString aTemplName = pTreeBox->IsVisible() ? pTreeBox->GetEntryText(pEntry) : aFmtLb->GetEntryText(pEntry);
+    weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+    pTreeView->selected_foreach([this, pTreeView](weld::TreeIter& rEntry){
+        OUString aTemplName = pTreeView->get_text(rEntry);
 
         Execute_Impl( SID_STYLE_SHOW, aTemplName,
                       OUString(), static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()) );
 
-        pEntry = pTreeBox->IsVisible() ? pTreeBox->NextSelected(pEntry) : aFmtLb->NextSelected(pEntry);
-    }
+        return false;
+    });
 }
 
 void SfxCommonTemplateDialog_Impl::EnableDelete()
@@ -2026,7 +1865,7 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
         if(nFilter == SfxStyleSearchBits::Auto)    // automatic
             nFilter = nAppFilter;
         const SfxStyleSheetBase *pStyle =
-            pStyleSheetPool->Find(aTemplName,eFam, pTreeBox->IsVisible()? SfxStyleSearchBits::All : nFilter);
+            pStyleSheetPool->Find(aTemplName,eFam, mxTreeBox->get_visible() ? SfxStyleSearchBits::All : nFilter);
 
         OSL_ENSURE(pStyle, "Style not found");
         if (pStyle && pStyle->IsUserDefined())
@@ -2054,24 +1893,23 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
     EnableDel(bEnableDelete);
 }
 
-IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, TreeListApplyHdl, SvTreeListBox *, bool )
+IMPL_LINK(SfxCommonTemplateDialog_Impl, MousePressHdl, const MouseEvent&, rMEvt, bool)
 {
-    ApplyHdl(nullptr);
+    m_nModifier = rMEvt.GetModifier();
     return false;
 }
 
 // Double-click on a style sheet in the ListBox is applied.
-IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, ApplyHdl, LinkParamNone*, void )
+IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, TreeListApplyHdl, weld::TreeView&, bool)
 {
     // only if that region is allowed
     if ( IsInitialized() && nullptr != pFamilyState[nActFamily-1] &&
          !GetSelectedEntry().isEmpty() )
     {
-        sal_uInt16 nModifier = aFmtLb->GetModifier();
         Execute_Impl(SID_STYLE_APPLY,
                      GetSelectedEntry(), OUString(),
                      static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()),
-                     SfxStyleSearchBits::Auto, nullptr, &nModifier );
+                     SfxStyleSearchBits::Auto, nullptr, &m_nModifier);
     }
     // After selecting a focused item if possible again on the app window
     if ( dynamic_cast< const SfxTemplateDialog_Impl* >(this) !=  nullptr )
@@ -2082,43 +1920,49 @@ IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, ApplyHdl, LinkParamNone*, void )
         if(pAppWin)
             pAppWin->GrabFocus();
     }
+
+    return true;
 }
 
-IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, PreviewHdl, Button*, void)
+IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, PreviewHdl, weld::Button&, void)
 {
     std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() );
-    officecfg::Office::Common::StylesAndFormatting::Preview::set( aPreviewCheckbox->IsChecked(), batch );
+    bool bCustomPreview = mxPreviewCheckbox->get_active();
+    officecfg::Office::Common::StylesAndFormatting::Preview::set(bCustomPreview, batch );
     batch->commit();
-    if(!bHierarchical)
-    {
-        sal_uInt16 nSize = aFmtLb->GetEntryCount();
-        for (sal_uInt16 nPos = 0; nPos < nSize; ++nPos )
-        {
-            SvTreeListEntry* pTreeListEntry = aFmtLb->GetEntry(nPos);
-            OUString aEntryStr = aFmtLb->GetEntryText(pTreeListEntry);
-            const SfxStyleFamily eFam = aPreviewCheckbox->IsChecked() ? GetFamilyItem_Impl()->GetFamily(): SfxStyleFamily::None;
-            pTreeListEntry->ReplaceItem(std::make_unique<StyleLBoxString>(aEntryStr, eFam), 1);
-            aFmtLb->GetModel()->InvalidateEntry(pTreeListEntry);
-            aFmtLb->Recalc();
-        }
-    }
-    else
-    {
-        FamilySelect(nActFamily, true);
-    }
+
+    mxFmtLb->clear();
+    mxFmtLb->set_column_custom_renderer(0, bCustomPreview);
+    mxTreeBox->clear();
+    mxTreeBox->set_column_custom_renderer(0, bCustomPreview);
+
+    FamilySelect(nActFamily, true);
 }
 
 // Selection of a template during the Watercan-Status
-IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox, void )
+IMPL_LINK(SfxCommonTemplateDialog_Impl, FmtSelectHdl, weld::TreeView&, rListBox, void)
 {
+    FmtSelect(&rListBox, true);
+}
+
+void SfxCommonTemplateDialog_Impl::FmtSelect(weld::TreeView* pListBox, bool bIsCallback)
+{
+    std::unique_ptr<weld::TreeIter> xHdlEntry;
+    if (pListBox)
+    {
+        xHdlEntry = pListBox->make_iterator();
+        if (!pListBox->get_cursor(xHdlEntry.get()))
+            return;
+    }
+
     // Trigger Help PI, if this is permitted of call handlers and field
-    if( !pListBox || pListBox->IsSelected( pListBox->GetHdlEntry() ) )
+    if (!pListBox || pListBox->is_selected(*xHdlEntry))
     {
         // Only when the watercan is on
         if ( IsInitialized() &&
-             IsCheckedItem(SID_STYLE_WATERCAN) &&
+             IsCheckedItem("watercan") &&
              // only if that region is allowed
-             nullptr != pFamilyState[nActFamily-1] && (pTreeBox || aFmtLb->GetSelectionCount() <= 1) )
+             nullptr != pFamilyState[nActFamily-1] && (mxTreeBox || mxFmtLb->count_selected_rows() <= 1) )
         {
             Execute_Impl(SID_STYLE_WATERCAN,
                          "", "", 0);
@@ -2126,24 +1970,25 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox
                          GetSelectedEntry(), "",
                          static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
         }
-        EnableItem(SID_STYLE_WATERCAN, !bWaterDisabled);
+        EnableItem("watercan", !bWaterDisabled);
         EnableDelete();
     }
     if( !pListBox )
         return;
 
-    SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() ));
+    SelectStyle(pListBox->get_text(*xHdlEntry), bIsCallback);
 }
 
-IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu*, pMenu, bool )
+void SfxCommonTemplateDialog_Impl::MenuSelect(const OString& rIdent)
 {
-    sLastItemIdent = pMenu->GetCurItemIdent();
+    sLastItemIdent = rIdent;
+    if (sLastItemIdent.isEmpty())
+        return;
     Application::PostUserEvent(
-        LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl ) );
-    return true;
+        LINK(this, SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl));
 }
 
-IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl, void*, void )
+IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, MenuSelectAsyncHdl, void*, void)
 {
     if (sLastItemIdent == "new")
         NewHdl();
@@ -2169,15 +2014,20 @@ SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const
 void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, bool bEnable)
 {
     bool bDisable = !bEnable || !IsSafeForWaterCan();
-    if( nId == SID_STYLE_NEW_BY_EXAMPLE )
+    if (nId == SID_STYLE_NEW_BY_EXAMPLE)
+    {
         bNewByExampleDisabled = bDisable;
+        EnableItem("new", bEnable);
+        EnableItem("newmenu", bEnable);
+    }
     else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE )
+    {
         bUpdateByExampleDisabled = bDisable;
-
-    EnableItem(nId, bEnable);
+        EnableItem("update", bEnable);
+    }
 }
 
-VclPtr<PopupMenu> const & SfxCommonTemplateDialog_Impl::CreateContextMenu()
+void SfxCommonTemplateDialog_Impl::CreateContextMenu()
 {
     if ( bBindingUpdate )
     {
@@ -2185,68 +2035,82 @@ VclPtr<PopupMenu> const & SfxCommonTemplateDialog_Impl::CreateContextMenu()
         pBindings->Update( SID_STYLE_NEW );
         bBindingUpdate = false;
     }
-    mxMenu.disposeAndClear();
-    mxBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "sfx/ui/stylecontextmenu.ui", ""));
-    mxMenu.set(mxBuilder->get_menu("menu"));
-    mxMenu->SetMenuFlags(MenuFlags::AlwaysShowDisabledEntries);
-    mxMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) );
-    mxMenu->EnableItem(mxMenu->GetItemId("edit"), bCanEdit);
-    mxMenu->EnableItem(mxMenu->GetItemId("delete"), bCanDel);
-    mxMenu->EnableItem(mxMenu->GetItemId("new"), bCanNew);
-    mxMenu->EnableItem(mxMenu->GetItemId("hide"), bCanHide);
-    mxMenu->EnableItem(mxMenu->GetItemId("show"), bCanShow);
+    mxMenu.reset();
+    mxMenuBuilder.reset(Application::CreateBuilder(nullptr, "sfx/ui/stylecontextmenu.ui"));
+    mxMenu = mxMenuBuilder->weld_menu("menu");
+    mxMenu->set_sensitive("edit", bCanEdit);
+    mxMenu->set_sensitive("delete", bCanDel);
+    mxMenu->set_sensitive("new", bCanNew);
+    mxMenu->set_sensitive("hide", bCanHide);
+    mxMenu->set_sensitive("show", bCanShow);
 
     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
     if (pItem && pItem->GetFamily() == SfxStyleFamily::Table) //tdf#101648, no ui for this yet
     {
-        mxMenu->EnableItem(mxMenu->GetItemId("edit"), false);
-        mxMenu->EnableItem(mxMenu->GetItemId("new"), false);
+        mxMenu->set_sensitive("edit", false);
+        mxMenu->set_sensitive("new", false);
     }
-
-    return mxMenu;
 }
 
 SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(SfxBindings* pB, SfxTemplatePanelControl* pDlgWindow)
-    : SfxCommonTemplateDialog_Impl(pB, pDlgWindow)
-    , m_pFloat(pDlgWindow)
-    , m_aActionTbL(VclPtrInstance<DropToolBox_Impl>(pDlgWindow, this))
-    , m_aActionTbR(VclPtrInstance<ToolBox>(pDlgWindow))
+    : SfxCommonTemplateDialog_Impl(pB, pDlgWindow, pDlgWindow->get_builder())
+    , m_xActionTbL(pDlgWindow->get_builder()->weld_toolbar("left"))
+    , m_xActionTbR(pDlgWindow->get_builder()->weld_toolbar("right"))
+    , m_xToolMenu(pDlgWindow->get_builder()->weld_menu("toolmenu"))
+    , m_nActionTbLVisible(0)
+{
+    m_xActionTbR->set_item_help_id("watercan", HID_TEMPLDLG_WATERCAN);
+    // shown/hidden in SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
+    m_xActionTbR->set_item_help_id("new", HID_TEMPLDLG_NEWBYEXAMPLE);
+    m_xActionTbR->set_item_help_id("newmenu", HID_TEMPLDLG_NEWBYEXAMPLE);
+    m_xActionTbR->set_item_menu("newmenu", m_xToolMenu.get());
+    m_xToolMenu->connect_activate(LINK(this, SfxTemplateDialog_Impl, ToolMenuSelectHdl));
+    m_xActionTbR->set_item_help_id("update", HID_TEMPLDLG_UPDATEBYEXAMPLE);
+
+    Initialize();
+}
+
+class ToolbarDropTarget final : public DropTargetHelper
 {
-    m_aActionTbR->InsertItem(SID_STYLE_WATERCAN, Image(StockImage::Yes, RID_SFXBMP_WATERCAN), SfxResId(STR_STYLE_FILL_FORMAT_MODE));
-    m_aActionTbR->SetHelpId(SID_STYLE_WATERCAN, HID_TEMPLDLG_WATERCAN);
+private:
+    SfxTemplateDialog_Impl& m_rParent;
 
-    m_aActionTbR->InsertItem(SID_STYLE_NEW_BY_EXAMPLE, Image(StockImage::Yes, RID_SFXBMP_NEW_BY_EXAMPLE), SfxResId(STR_STYLE_NEW_STYLE_FROM_SELECTION));
-    //renamed to SID_STYLE_NEW_BY_EXAMPLE in SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
-    m_aActionTbR->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE);
+public:
+    ToolbarDropTarget(SfxTemplateDialog_Impl& rDialog, weld::Toolbar& rToolbar)
+        : DropTargetHelper(rToolbar.get_drop_target())
+        , m_rParent(rDialog)
+    {
+    }
 
-    m_aActionTbR->InsertItem(SID_STYLE_UPDATE_BY_EXAMPLE, Image(StockImage::Yes, RID_SFXBMP_UPDATE_BY_EXAMPLE), SfxResId(STR_STYLE_UPDATE_STYLE));
-    m_aActionTbR->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE);
+    virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override
+    {
+        return m_rParent.AcceptToolbarDrop(rEvt, *this);
+    }
 
-    Initialize();
-}
+    virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
+    {
+        return m_rParent.ExecuteDrop(rEvt);
+    }
+};
 
 void SfxTemplateDialog_Impl::Initialize()
 {
     SfxCommonTemplateDialog_Impl::Initialize();
 
-    m_aActionTbL->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect));
-    m_aActionTbR->SetSelectHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRSelect));
-    m_aActionTbR->SetDropdownClickHdl(LINK(this, SfxTemplateDialog_Impl, ToolBoxRClick));
-    m_aActionTbL->Show();
-    m_aActionTbR->Show();
-    vcl::Font aFont = aFilterLb->GetFont();
-    aFont.SetWeight( WEIGHT_NORMAL );
-    aFilterLb->SetFont( aFont );
-    m_aActionTbL->SetHelpId( HID_TEMPLDLG_TOOLBOX_LEFT );
+    m_xActionTbL->connect_clicked(LINK(this, SfxTemplateDialog_Impl, ToolBoxLSelect));
+    m_xActionTbR->connect_clicked(LINK(this, SfxTemplateDialog_Impl, ToolBoxRSelect));
+    m_xActionTbL->set_help_id(HID_TEMPLDLG_TOOLBOX_LEFT);
+
+    m_xToolbarDropTargetHelper.reset(new ToolbarDropTarget(*this, *m_xActionTbL));
 }
 
-void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, bool bEnable )
+void SfxTemplateDialog_Impl::EnableFamilyItem(sal_uInt16 nId, bool bEnable)
 {
-    m_aActionTbL->EnableItem( nId, bEnable );
+    m_xActionTbL->set_item_sensitive(OString::number(nId), bEnable);
 }
 
 // Insert element into dropdown filter "Frame Styles", "List Styles", etc.
-void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem &rItem)
+void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem &rItem)
 {
     OString sHelpId;
     switch( rItem.GetFamily() )
@@ -2256,25 +2120,32 @@ void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamil
         case SfxStyleFamily::Frame:    sHelpId = ".uno:FrameStyle"; break;
         case SfxStyleFamily::Page:     sHelpId = ".uno:PageStyle"; break;
         case SfxStyleFamily::Pseudo:   sHelpId = ".uno:ListStyle"; break;
-        case SfxStyleFamily::Table:   sHelpId = ".uno:TableStyle"; break;
+        case SfxStyleFamily::Table:    sHelpId = ".uno:TableStyle"; break;
         default: OSL_FAIL("unknown StyleFamily"); break;
     }
-    m_aActionTbL->InsertItem( nId, rItem.GetImage(), rItem.GetText(), ToolBoxItemBits::NONE, 0);
-    m_aActionTbL->SetHelpId( nId, sHelpId );
+
+    OString sId(OString::number(nId));
+    m_xActionTbL->set_item_visible(sId, true);
+    m_xActionTbL->set_item_icon_name(sId, rItem.GetImage());
+    m_xActionTbL->set_item_tooltip_text(sId, rItem.GetText());
+    m_xActionTbL->set_item_help_id(sId, sHelpId);
+    ++m_nActionTbLVisible;
 }
 
 void SfxTemplateDialog_Impl::ReplaceUpdateButtonByMenu()
 {
-    m_aActionTbR->HideItem(SID_STYLE_UPDATE_BY_EXAMPLE);
-    m_aActionTbR->SetItemBits( SID_STYLE_NEW_BY_EXAMPLE,
-            ToolBoxItemBits::DROPDOWNONLY|m_aActionTbR->GetItemBits( SID_STYLE_NEW_BY_EXAMPLE ));
-    //rename menu in case of Writer
-    m_aActionTbR->SetItemText(SID_STYLE_NEW_BY_EXAMPLE, SfxResId(STR_STYLE_NEW_STYLE_ACTION));
+    m_xActionTbR->set_item_visible("update", false);
+    m_xActionTbR->set_item_visible("new", false);
+    m_xActionTbR->set_item_visible("newmenu", true);
+    m_bNewHasMenu = true;
+    FillToolMenu();
 }
 
 void SfxTemplateDialog_Impl::ClearFamilyList()
 {
-    m_aActionTbL->Clear();
+    for (int i = 0, nCount = m_xActionTbL->get_n_items(); i < nCount; ++i)
+        m_xActionTbL->set_item_visible(m_xActionTbL->get_item_ident(i), false);
+
 }
 
 void SfxCommonTemplateDialog_Impl::InvalidateBindings()
@@ -2293,197 +2164,72 @@ void SfxCommonTemplateDialog_Impl::InvalidateBindings()
 
 SfxTemplateDialog_Impl::~SfxTemplateDialog_Impl()
 {
-    m_pFloat.clear();
-    m_aActionTbL.disposeAndClear();
-    m_aActionTbR.disposeAndClear();
+    m_xToolbarDropTargetHelper.reset();
+    m_xActionTbL.reset();
+    m_xActionTbR.reset();
 }
 
-void SfxTemplateDialog_Impl::LoadedFamilies()
+void SfxTemplateDialog_Impl::EnableItem(const OString& rMesId, bool bCheck)
 {
-    Resize();
-}
-
-// Override Resize-Handler ( StarView )
-// The size of the Listboxen is adjusted
-void SfxTemplateDialog_Impl::Resize()
-{
-    if (m_pFloat == nullptr)
-        return;
-    Size aDlgSize=m_pFloat->PixelToLogic(m_pFloat->GetOutputSizePixel());
-    Size aSizeATL=m_pFloat->PixelToLogic(m_aActionTbL->CalcWindowSizePixel());
-    Size aSizeATR=m_pFloat->PixelToLogic(m_aActionTbR->CalcWindowSizePixel());
-    Size aMinSize = GetMinOutputSizePixel();
-
-    long nListHeight = m_pFloat->PixelToLogic( aFilterLb->GetSizePixel() ).Height();
-    long nWidth = aDlgSize.Width()- 2 * SFX_TEMPLDLG_HFRAME;
-
-    m_aActionTbL->SetPosSizePixel(m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,SFX_TEMPLDLG_VTOPFRAME)),
-                                 m_pFloat->LogicToPixel(aSizeATL));
-
-    // only change the position of the right toolbox, when the window is wide
-    // enough
-    Point aPosATR(aDlgSize.Width()-SFX_TEMPLDLG_HFRAME-aSizeATR.Width(),SFX_TEMPLDLG_VTOPFRAME);
-    if(aDlgSize.Width() >= aMinSize.Width())
-        m_aActionTbR->SetPosPixel(m_pFloat->LogicToPixel(aPosATR));
-    else
-        m_aActionTbR->SetPosPixel( m_pFloat->LogicToPixel(
-            Point( SFX_TEMPLDLG_HFRAME + aSizeATL.Width() + SFX_TEMPLDLG_MIDHSPACE,
-                   SFX_TEMPLDLG_VTOPFRAME ) ) );
-
-    m_aActionTbR->SetSizePixel(m_pFloat->LogicToPixel(aSizeATR));
-
-    Point aFilterPos(
-        m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,
-            aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-nListHeight)) );
-
-    Size aFilterSize(
-        m_pFloat->LogicToPixel(Size(nWidth,SFX_TEMPLDLG_FILTERHEIGHT)) );
-
-    Point aCheckBoxPos(
-        m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME,
-            aDlgSize.Height()-SFX_TEMPLDLG_VBOTFRAME-2*nListHeight)) );
-
-    Size aCheckBoxSize(
-        m_pFloat->LogicToPixel(Size(nWidth, nListHeight)) );
-
-    Point aFmtPos(
-        m_pFloat->LogicToPixel(Point(SFX_TEMPLDLG_HFRAME, SFX_TEMPLDLG_VTOPFRAME +
-                            SFX_TEMPLDLG_MIDVSPACE+aSizeATL.Height())) );
-    Size aFmtSize(
-        m_pFloat->LogicToPixel(Size(nWidth,
-                    aDlgSize.Height() - SFX_TEMPLDLG_VBOTFRAME -
-                    SFX_TEMPLDLG_VTOPFRAME - 2*SFX_TEMPLDLG_MIDVSPACE-
-                    2*nListHeight-aSizeATL.Height())) );
-
-    // only change the position of the listbox, when the window is high enough
-    if(aDlgSize.Height() >= aMinSize.Height())
-    {
-        aFilterLb->SetPosPixel(aFilterPos);
-        aFmtLb->SetPosPixel( aFmtPos );
-        aPreviewCheckbox->SetPosPixel(aCheckBoxPos);
-        if(pTreeBox->IsVisible())
-            pTreeBox->SetPosPixel(aFmtPos);
-    }
-    else
-        aFmtSize.AdjustHeight(aFilterSize.Height() );
-
-    aFilterLb->SetSizePixel(aFilterSize);
-    aFmtLb->SetSizePixel( aFmtSize );
-    aPreviewCheckbox->SetSizePixel( aCheckBoxSize );
-    if(pTreeBox->IsVisible())
-        pTreeBox->SetSizePixel(aFmtSize);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list