diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-04 17:22:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-03-11 17:42:22 +0100 |
commit | 1653bb9bffaa84a40b7d81a8277e887ea28df4e4 (patch) | |
tree | 5e56142b7b63ab66fb1dcc781ffeb3ae5afda2ad /sw/source | |
parent | lok: avoid a set of invalidations per view on re-size. (diff) | |
download | core-1653bb9bffaa84a40b7d81a8277e887ea28df4e4.tar.gz core-1653bb9bffaa84a40b7d81a8277e887ea28df4e4.zip |
remove intermediate containers in sidebars
tested extension sidebars of:
a) Wollmux extension sidebars
b) Analog Clock Extension demo
https://wiki.openoffice.org/wiki/Sidebar_for_Developers#Example:_Analog_Clock_Extension
Change-Id: If9729e20526681928137989f01a8ae733a9b0cb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112035
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
26 files changed, 185 insertions, 341 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 24488a8c713b..95eb75efb6cd 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -89,7 +89,7 @@ class SwContentTree final : public SfxListener std::unique_ptr<weld::TreeView> m_xTreeView; std::unique_ptr<weld::TreeIter> m_xScratchIter; SwContentTreeDropTarget m_aDropTargetHelper; - VclPtr<SwNavigationPI> m_xDialog; + SwNavigationPI* m_pDialog; OUString m_sSpace; AutoTimer m_aUpdTimer; @@ -298,7 +298,7 @@ class SwGlobalTree final private: std::unique_ptr<weld::TreeView> m_xTreeView; SwGlobalTreeDropTarget m_aDropTargetHelper; - VclPtr<SwNavigationPI> m_xDialog; + SwNavigationPI* m_pDialog; AutoTimer m_aUpdateTimer; OUString m_aContextStrings[GLOBAL_CONTEXT_COUNT]; diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx index 0b0d0134a811..c203284ca500 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -73,6 +73,8 @@ class SwNavigationPI : public PanelLayout OUString m_sContentFileName; OUString m_aStatusArr[4]; + VclPtr<SfxNavigator> m_xNavigatorDlg; + std::unique_ptr<SfxObjectShellLock> m_pxObjectShell; SwView *m_pContentView; SwWrtShell *m_pContentWrtShell; @@ -111,6 +113,8 @@ class SwNavigationPI : public PanelLayout bool EditAction(); void UsePage(); + void UpdateInitShow(); + protected: // release ObjectShellLock early enough for app end @@ -121,14 +125,13 @@ protected: public: - static VclPtr<PanelLayout> Create(vcl::Window* pParent, + static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, SfxBindings* pBindings); - SwNavigationPI(vcl::Window* pParent, + SwNavigationPI(weld::Widget* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, - SfxBindings* _pBindings); + SfxBindings* _pBindings, SfxNavigator* pNavigatorDlg); virtual ~SwNavigationPI() override; - virtual void dispose() override; void UpdateListBox(); void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget); @@ -140,8 +143,6 @@ public: virtual void GetControlState(const sal_uInt16 /*nSId*/, boost::property_tree::ptree& /*rState*/) override {}; - virtual void StateChanged(StateChangedType nStateChange) override; - static OUString CreateDropFileName( TransferableDataHelper& rData ); static OUString CleanEntry(const OUString& rEntry); @@ -155,6 +156,8 @@ public: bool IsGlobalMode() const {return m_bGlobalMode;} SwView* GetCreateView() const; + + virtual weld::Window* GetFrameWeld() const override; }; class SwNavigatorWrapper final : public SfxNavigatorWrapper diff --git a/sw/source/uibase/inc/redlndlg.hxx b/sw/source/uibase/inc/redlndlg.hxx index faf6d65d34b8..63cfca9d9409 100644 --- a/sw/source/uibase/inc/redlndlg.hxx +++ b/sw/source/uibase/inc/redlndlg.hxx @@ -153,9 +153,8 @@ class SwRedlineAcceptPanel : public PanelLayout, public SfxListener std::unique_ptr<SwRedlineAcceptDlg> mpImplDlg; std::unique_ptr<weld::Container> mxContentArea; public: - SwRedlineAcceptPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame); + SwRedlineAcceptPanel(weld::Widget* pParent); virtual ~SwRedlineAcceptPanel() override; - virtual void dispose() override; /// We need to be a SfxListener to be able to update the list of changes when we get SfxHintId::DocChanged. virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index cb7990fcd1fc..ebbb7f0c2a00 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -1246,8 +1246,8 @@ void SwRedlineAcceptDlg::FillInfo(OUString &rExtraData) const rExtraData += ")"; } -SwRedlineAcceptPanel::SwRedlineAcceptPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame) - : PanelLayout(pParent, "ManageChangesPanel", "modules/swriter/ui/managechangessidebar.ui", rFrame) +SwRedlineAcceptPanel::SwRedlineAcceptPanel(weld::Widget* pParent) + : PanelLayout(pParent, "ManageChangesPanel", "modules/swriter/ui/managechangessidebar.ui") , mxContentArea(m_xBuilder->weld_container("content_area")) { mpImplDlg.reset(new SwRedlineAcceptDlg(nullptr, m_xBuilder.get(), mxContentArea.get())); @@ -1260,14 +1260,6 @@ SwRedlineAcceptPanel::SwRedlineAcceptPanel(vcl::Window* pParent, const css::uno: SwRedlineAcceptPanel::~SwRedlineAcceptPanel() { - disposeOnce(); -} - -void SwRedlineAcceptPanel::dispose() -{ - mpImplDlg.reset(); - mxContentArea.reset(); - PanelLayout::dispose(); } void SwRedlineAcceptPanel::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) diff --git a/sw/source/uibase/sidebar/PageFooterPanel.cxx b/sw/source/uibase/sidebar/PageFooterPanel.cxx index 0cc1037a829f..c85969e29168 100644 --- a/sw/source/uibase/sidebar/PageFooterPanel.cxx +++ b/sw/source/uibase/sidebar/PageFooterPanel.cxx @@ -33,17 +33,13 @@ namespace sw::sidebar{ -VclPtr<PanelLayout> PageFooterPanel::Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, +std::unique_ptr<PanelLayout> PageFooterPanel::Create( + weld::Widget* pParent, SfxBindings* pBindings) { if( pParent == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageFooterPanel::Create", nullptr, 0); - if( !rxFrame.is() ) - throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageFooterPanel::Create", nullptr, 0); - - return VclPtr<PageFooterPanel>::Create(pParent, rxFrame, pBindings); + return std::make_unique<PageFooterPanel>(pParent, pBindings); } void PageFooterPanel::SetMarginsAndSpacingFieldUnit() @@ -53,10 +49,9 @@ void PageFooterPanel::SetMarginsAndSpacingFieldUnit() } PageFooterPanel::PageFooterPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings) : - PanelLayout(pParent, "PageFooterPanel", "modules/swriter/ui/pagefooterpanel.ui", rxFrame), + PanelLayout(pParent, "PageFooterPanel", "modules/swriter/ui/pagefooterpanel.ui"), mpBindings( pBindings ), maHFToggleController(SID_ATTR_PAGE_FOOTER, *pBindings, *this), maMetricController(SID_ATTR_METRIC, *pBindings,*this), @@ -80,19 +75,12 @@ PageFooterPanel::PageFooterPanel( PageFooterPanel::~PageFooterPanel() { - disposeOnce(); -} - -void PageFooterPanel::dispose() -{ mxFooterToggle.reset(); maMetricController.dispose(); mxFooterSpacingLB.reset(); mxFooterLayoutLB.reset(); mxFooterMarginPresetLB.reset(); mxCustomEntry.reset(); - - PanelLayout::dispose(); } FieldUnit PageFooterPanel::GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState) diff --git a/sw/source/uibase/sidebar/PageFooterPanel.hxx b/sw/source/uibase/sidebar/PageFooterPanel.hxx index 6c4750441950..aa67de6e760d 100644 --- a/sw/source/uibase/sidebar/PageFooterPanel.hxx +++ b/sw/source/uibase/sidebar/PageFooterPanel.hxx @@ -20,28 +20,23 @@ #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEFOOTERPANEL_HXX #include <memory> -#include <com/sun/star/frame/XFrame.hpp> #include <sfx2/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> - -#include <svx/rulritem.hxx> - #include <svl/intitem.hxx> #include <svl/poolitem.hxx> #include <svl/eitem.hxx> +#include <svx/rulritem.hxx> namespace sw::sidebar { -class PageFooterPanel: +class PageFooterPanel : public PanelLayout, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: - static VclPtr<PanelLayout> Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, SfxBindings* pBindings); virtual void NotifyItemUpdate( @@ -55,11 +50,9 @@ public: SfxBindings* GetBindings() const { return mpBindings; } PageFooterPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings); virtual ~PageFooterPanel() override; - virtual void dispose() override; private: diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx index 442faf4d2ac6..61cded7dc56f 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.cxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx @@ -43,17 +43,14 @@ namespace sw::sidebar{ -VclPtr<PanelLayout> PageFormatPanel::Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, +std::unique_ptr<PanelLayout> PageFormatPanel::Create( + weld::Widget* pParent, SfxBindings* pBindings) { if( pParent == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageFormatPanel::Create", nullptr, 0); - if( !rxFrame.is() ) - throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageFormatPanel::Create", nullptr, 0); - return VclPtr<PageFormatPanel>::Create(pParent, rxFrame, pBindings); + return std::make_unique<PageFormatPanel>(pParent, pBindings); } void PageFormatPanel::SetMarginFieldUnit() @@ -83,11 +80,8 @@ void PageFormatPanel::SetMarginFieldUnit() mxMarginSelectBox->set_active(nSelected); } -PageFormatPanel::PageFormatPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, - SfxBindings* pBindings) : - PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui", rxFrame), +PageFormatPanel::PageFormatPanel(weld::Widget* pParent, SfxBindings* pBindings) : + PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui"), mpBindings( pBindings ), mxPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box("papersize"))), mxPaperWidth(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("paperwidth", FieldUnit::CM))), @@ -112,11 +106,6 @@ PageFormatPanel::PageFormatPanel( PageFormatPanel::~PageFormatPanel() { - disposeOnce(); -} - -void PageFormatPanel::dispose() -{ mxPaperSizeBox.reset(); mxPaperWidth.reset(); mxPaperHeight.reset(); @@ -132,8 +121,6 @@ void PageFormatPanel::dispose() mpPageULMarginItem.reset(); mpPageLRMarginItem.reset(); mpPageItem.reset(); - - PanelLayout::dispose(); } void PageFormatPanel::Initialize() diff --git a/sw/source/uibase/sidebar/PageFormatPanel.hxx b/sw/source/uibase/sidebar/PageFormatPanel.hxx index fcf60030868c..e5fd689982a8 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.hxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.hxx @@ -18,10 +18,7 @@ */ #pragma once -#include <com/sun/star/frame/XFrame.hpp> - #include <sfx2/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> #include <svx/pageitem.hxx> @@ -36,14 +33,13 @@ namespace sw::sidebar { -class PageFormatPanel: +class PageFormatPanel : public PanelLayout, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: - static VclPtr<PanelLayout> Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, SfxBindings* pBindings); virtual void NotifyItemUpdate( @@ -56,11 +52,9 @@ public: boost::property_tree::ptree& /*rState*/) override {}; PageFormatPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings); virtual ~PageFormatPanel() override; - virtual void dispose() override; static FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState ); diff --git a/sw/source/uibase/sidebar/PageHeaderPanel.cxx b/sw/source/uibase/sidebar/PageHeaderPanel.cxx index c47084d14371..9f7cd0b795d6 100644 --- a/sw/source/uibase/sidebar/PageHeaderPanel.cxx +++ b/sw/source/uibase/sidebar/PageHeaderPanel.cxx @@ -33,19 +33,16 @@ namespace sw::sidebar{ -VclPtr<PanelLayout> PageHeaderPanel::Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, +std::unique_ptr<PanelLayout> PageHeaderPanel::Create( + weld::Widget* pParent, SfxBindings* pBindings) { if( pParent == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageHeaderPanel::Create", nullptr, 0); - if( !rxFrame.is() ) - throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageHeaderPanel::Create", nullptr, 0); if( pBindings == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to PageHeaderPanel::Create", nullptr, 0); - return VclPtr<PageHeaderPanel>::Create(pParent, rxFrame, pBindings); + return std::make_unique<PageHeaderPanel>(pParent, pBindings); } void PageHeaderPanel::SetMarginsAndSpacingFieldUnit() @@ -55,11 +52,10 @@ void PageHeaderPanel::SetMarginsAndSpacingFieldUnit() } PageHeaderPanel::PageHeaderPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings ) : - PanelLayout(pParent, "PageHeaderPanel", "modules/swriter/ui/pageheaderpanel.ui", rxFrame), + PanelLayout(pParent, "PageHeaderPanel", "modules/swriter/ui/pageheaderpanel.ui"), mpBindings( pBindings ), maHFToggleController(SID_ATTR_PAGE_HEADER, *pBindings, *this), maMetricController(SID_ATTR_METRIC, *pBindings,*this), @@ -83,18 +79,11 @@ PageHeaderPanel::PageHeaderPanel( PageHeaderPanel::~PageHeaderPanel() { - disposeOnce(); -} - -void PageHeaderPanel::dispose() -{ mxHeaderToggle.reset(); mxHeaderSpacingLB.reset(); mxHeaderLayoutLB.reset(); mxHeaderMarginPresetLB.reset(); mxCustomEntry.reset(); - - PanelLayout::dispose(); } FieldUnit PageHeaderPanel::GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState) diff --git a/sw/source/uibase/sidebar/PageHeaderPanel.hxx b/sw/source/uibase/sidebar/PageHeaderPanel.hxx index f695fc675ed8..bffc5d992b75 100644 --- a/sw/source/uibase/sidebar/PageHeaderPanel.hxx +++ b/sw/source/uibase/sidebar/PageHeaderPanel.hxx @@ -20,28 +20,22 @@ #pragma once #include <memory> -#include <com/sun/star/frame/XFrame.hpp> - #include <sfx2/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> - -#include <svx/rulritem.hxx> - #include <svl/intitem.hxx> #include <svl/poolitem.hxx> #include <svl/eitem.hxx> +#include <svx/rulritem.hxx> namespace sw::sidebar { -class PageHeaderPanel: +class PageHeaderPanel : public PanelLayout, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: - static VclPtr<PanelLayout> Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, SfxBindings* pBindings); virtual void NotifyItemUpdate( @@ -55,11 +49,9 @@ public: SfxBindings* GetBindings() const { return mpBindings; } PageHeaderPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings); virtual ~PageHeaderPanel() override; - virtual void dispose() override; private: diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx index a2cf10cd3faf..b514c628f4bf 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.cxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx @@ -68,7 +68,6 @@ static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) return 3; } - static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) { if ( nPos >= SAL_N_ELEMENTS(aArr) ) @@ -76,27 +75,21 @@ static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) return aArr[nPos]; } -VclPtr<PanelLayout> PageStylesPanel::Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, - SfxBindings* pBindings) +std::unique_ptr<PanelLayout> PageStylesPanel::Create(weld::Widget* pParent, SfxBindings* pBindings) { if( pParent == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageStylesPanel::Create", nullptr, 0); - if( !rxFrame.is() ) - throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageStylesPanel::Create", nullptr, 0); if( pBindings == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to PageStylesPanel::Create", nullptr, 0); - return VclPtr<PageStylesPanel>::Create(pParent, rxFrame, pBindings); + return std::make_unique<PageStylesPanel>(pParent, pBindings); } PageStylesPanel::PageStylesPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings ) : - PanelLayout(pParent, "PageStylesPanel", "modules/swriter/ui/pagestylespanel.ui", rxFrame), + PanelLayout(pParent, "PageStylesPanel", "modules/swriter/ui/pagestylespanel.ui"), mpBindings( pBindings ), mpPageColumnItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN) ), mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ), @@ -123,11 +116,6 @@ PageStylesPanel::PageStylesPanel( PageStylesPanel::~PageStylesPanel() { - disposeOnce(); -} - -void PageStylesPanel::dispose() -{ mxColumnCount.reset(); mxNumberSelectLB.reset(); mxBgFillType.reset(); @@ -145,7 +133,6 @@ void PageStylesPanel::dispose() maBgHatchingControl.dispose(); maPageColumnControl.dispose(); maPageNumFormatControl.dispose(); - PanelLayout::dispose(); } void PageStylesPanel::Initialize() diff --git a/sw/source/uibase/sidebar/PageStylesPanel.hxx b/sw/source/uibase/sidebar/PageStylesPanel.hxx index 77d2ed462813..6047d2535666 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.hxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.hxx @@ -20,20 +20,16 @@ #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGESTYLESPANEL_HXX #include <memory> -#include <com/sun/star/frame/XFrame.hpp> #include <sfx2/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> - -#include <svx/pageitem.hxx> - #include <svl/intitem.hxx> #include <svl/poolitem.hxx> #include <svx/xbtmpit.hxx> #include <svx/xflclit.hxx> #include <svx/xflgrit.hxx> #include <svx/xflhtit.hxx> +#include <svx/pageitem.hxx> #include <svx/pagenumberlistbox.hxx> class List; @@ -45,9 +41,8 @@ class PageStylesPanel: public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: - static VclPtr<PanelLayout> Create( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, SfxBindings* pBindings); virtual void NotifyItemUpdate( @@ -61,11 +56,9 @@ public: SfxBindings* GetBindings() const { return mpBindings; } PageStylesPanel( - vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + weld::Widget* pParent, SfxBindings* pBindings); virtual ~PageStylesPanel() override; - virtual void dispose() override; private: diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.cxx b/sw/source/uibase/sidebar/StylePresetsPanel.cxx index 4851bff5f09e..79b1b93ed34c 100644 --- a/sw/source/uibase/sidebar/StylePresetsPanel.cxx +++ b/sw/source/uibase/sidebar/StylePresetsPanel.cxx @@ -130,20 +130,16 @@ BitmapEx CreatePreview(OUString const & aUrl, OUString const & aName) } -VclPtr<PanelLayout> StylePresetsPanel::Create (vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) +std::unique_ptr<PanelLayout> StylePresetsPanel::Create(weld::Widget* pParent) { if (pParent == nullptr) throw css::lang::IllegalArgumentException("no parent Window given to StylePresetsPanel::Create", nullptr, 0); - if (!rxFrame.is()) - throw css::lang::IllegalArgumentException("no XFrame given to StylePresetsPanel::Create", nullptr, 1); - return VclPtr<StylePresetsPanel>::Create(pParent, rxFrame); + return std::make_unique<StylePresetsPanel>(pParent); } -StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) - : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui", rxFrame) +StylePresetsPanel::StylePresetsPanel(weld::Widget* pParent) + : PanelLayout(pParent, "StylePresetsPanel", "modules/swriter/ui/sidebarstylepresets.ui") , mxValueSet(new ValueSet(nullptr)) , mxValueSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxValueSet)) { @@ -152,8 +148,6 @@ StylePresetsPanel::StylePresetsPanel(vcl::Window* pParent, mxValueSet->SetDoubleClickHdl(LINK(this, StylePresetsPanel, DoubleClickHdl)); RefreshList(); - - m_pInitialFocusWidget = mxValueSet->GetDrawingArea(); } void StylePresetsPanel::RefreshList() @@ -182,15 +176,6 @@ void StylePresetsPanel::RefreshList() StylePresetsPanel::~StylePresetsPanel() { - disposeOnce(); -} - -void StylePresetsPanel::dispose() -{ - mxValueSetWin.reset(); - mxValueSet.reset(); - - PanelLayout::dispose(); } IMPL_LINK_NOARG(StylePresetsPanel, DoubleClickHdl, ValueSet*, void) diff --git a/sw/source/uibase/sidebar/StylePresetsPanel.hxx b/sw/source/uibase/sidebar/StylePresetsPanel.hxx index 1de8af74db71..75a6cb3c4e0e 100644 --- a/sw/source/uibase/sidebar/StylePresetsPanel.hxx +++ b/sw/source/uibase/sidebar/StylePresetsPanel.hxx @@ -11,12 +11,9 @@ #pragma once #include <memory> -#include <com/sun/star/frame/XFrame.hpp> #include <sfx2/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> - #include <svtools/valueset.hxx> namespace sw::sidebar { @@ -24,10 +21,12 @@ namespace sw::sidebar { class StylePresetsPanel : public PanelLayout, public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { - friend class VclPtr<StylePresetsPanel>; public: - static VclPtr<PanelLayout> Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); + static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent); + + StylePresetsPanel(weld::Widget* pParent); + + virtual ~StylePresetsPanel() override; virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, @@ -49,12 +48,6 @@ private: void RefreshList(); - StylePresetsPanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); - - virtual ~StylePresetsPanel() override; - virtual void dispose() override; - std::unique_ptr<ValueSet> mxValueSet; std::unique_ptr<weld::CustomWeld> mxValueSetWin; diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx index cc34ba5b3fdb..ff5c0e58d93e 100644 --- a/sw/source/uibase/sidebar/SwPanelFactory.cxx +++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx @@ -32,8 +32,7 @@ #include <redlndlg.hxx> #include <sfx2/sidebar/SidebarPanelBase.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include <vcl/window.hxx> +#include <vcl/weldutils.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <comphelper/namedvaluecollection.hxx> @@ -94,8 +93,11 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement ( const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); - VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); - if ( ! xParentWindow.is() || pParentWindow==nullptr) + weld::Widget* pParent(nullptr); + if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get())) + pParent = pTunnel->getWidget(); + + if (!pParent) throw RuntimeException( "PanelFactory::createUIElement called without ParentWindow", nullptr); @@ -110,93 +112,93 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement ( if(rsResourceURL.endsWith("/PageStylesPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageStylesPanel::Create( pParent, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if(rsResourceURL.endsWith("/PageFormatPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFormatPanel::Create( pParent, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if(rsResourceURL.endsWith("/PageHeaderPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::PageHeaderPanel::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageHeaderPanel::Create( pParent, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if(rsResourceURL.endsWith("/PageFooterPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::PageFooterPanel::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFooterPanel::Create( pParent, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if (rsResourceURL.endsWith("/WrapPropertyPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WrapPropertyPanel::Create( pParent, xFrame, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if (rsResourceURL.endsWith("/NavigatorPanel")) { - VclPtr<PanelLayout> pPanel = SwNavigationPI::Create( pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = SwNavigationPI::Create( pParent, xFrame, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(0,-1,-1)); } else if (rsResourceURL.endsWith("/ManageChangesPanel")) { - VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame); + auto xPanel = std::make_unique<SwRedlineAcceptPanel>(pParent); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if (rsResourceURL.endsWith("/WriterInspectorTextPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::WriterInspectorTextPanel::Create( pParentWindow, xFrame); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WriterInspectorTextPanel::Create(pParent); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, - pPanel, + std::move(xPanel), ui::LayoutSize(0,-1,-1)); } else if (rsResourceURL.endsWith("/StylePresetsPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::StylePresetsPanel::Create(pParent); xElement = sfx2::sidebar::SidebarPanelBase::Create( - rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1)); + rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if (rsResourceURL.endsWith("/ThemePanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::ThemePanel::Create(pParent); xElement = sfx2::sidebar::SidebarPanelBase::Create( - rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1)); + rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } else if (rsResourceURL.endsWith("/TableEditPanel")) { - VclPtr<PanelLayout> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame, pBindings ); + std::unique_ptr<PanelLayout> xPanel = sw::sidebar::TableEditPanel::Create(pParent, xFrame, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( - rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1)); + rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1)); } return xElement; diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx index 3b7262e6e673..22b45f7419b4 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.cxx +++ b/sw/source/uibase/sidebar/TableEditPanel.cxx @@ -24,9 +24,10 @@ namespace sw::sidebar { -VclPtr<PanelLayout> TableEditPanel::Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings) +std::unique_ptr<PanelLayout> +TableEditPanel::Create(weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) { if (pParent == nullptr) throw css::lang::IllegalArgumentException( @@ -35,7 +36,7 @@ VclPtr<PanelLayout> TableEditPanel::Create(vcl::Window* pParent, throw css::lang::IllegalArgumentException("no XFrame given to TableEditPanel::Create", nullptr, 1); - return VclPtr<TableEditPanel>::Create(pParent, rxFrame, pBindings); + return std::make_unique<TableEditPanel>(pParent, rxFrame, pBindings); } void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState eState, @@ -86,10 +87,10 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState } } -TableEditPanel::TableEditPanel(vcl::Window* pParent, +TableEditPanel::TableEditPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings) - : PanelLayout(pParent, "TableEditPanel", "modules/swriter/ui/sidebartableedit.ui", rxFrame) + : PanelLayout(pParent, "TableEditPanel", "modules/swriter/ui/sidebartableedit.ui") , m_pBindings(pBindings) , m_xRowHeightEdit( new SvxRelativeField(m_xBuilder->weld_metric_spin_button("rowheight", FieldUnit::CM))) @@ -137,12 +138,8 @@ TableEditPanel::TableEditPanel(vcl::Window* pParent, if (comphelper::LibreOfficeKit::isActive()) m_xMisc->set_item_visible(".uno:InsertFormula", false); - - m_pInitialFocusWidget = &m_xRowHeightEdit->get_widget(); } -TableEditPanel::~TableEditPanel() { disposeOnce(); } - void TableEditPanel::InitRowHeightToolitem() { Link<weld::MetricSpinButton&, void> aLink = LINK(this, TableEditPanel, RowHeightMofiyHdl); @@ -171,7 +168,7 @@ void TableEditPanel::InitColumnWidthToolitem() limitWidthForSidebar(*m_xColumnWidthEdit); } -void TableEditPanel::dispose() +TableEditPanel::~TableEditPanel() { m_xRowHeightEdit.reset(); m_xColumnWidthEdit.reset(); @@ -213,8 +210,6 @@ void TableEditPanel::dispose() m_aSetOptimalColumnWidthController.dispose(); m_aDistributeColumnsController.dispose(); m_aMergeCellsController.dispose(); - - PanelLayout::dispose(); } IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, weld::MetricSpinButton&, void) diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index cb8097aaf4cb..01098df5e60f 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -21,12 +21,14 @@ namespace sw::sidebar class TableEditPanel : public PanelLayout, public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { - friend class VclPtr<TableEditPanel>; - public: - static VclPtr<PanelLayout> Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings); + static std::unique_ptr<PanelLayout> + Create(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + TableEditPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~TableEditPanel() override; virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem* pState) override; @@ -35,11 +37,6 @@ public: boost::property_tree::ptree& /*rState*/) override{}; private: - TableEditPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings); - virtual ~TableEditPanel() override; - virtual void dispose() override; - void InitRowHeightToolitem(); void InitColumnWidthToolitem(); diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index 93ee7b557a84..3ff74fcdb016 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -397,20 +397,16 @@ BitmapEx GenerateColorPreview(const svx::ColorSet& rColorSet) namespace sw::sidebar { -VclPtr<PanelLayout> ThemePanel::Create (vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) +std::unique_ptr<PanelLayout> ThemePanel::Create(weld::Widget* pParent) { if (pParent == nullptr) throw css::lang::IllegalArgumentException("no parent Window given to PagePropertyPanel::Create", nullptr, 0); - if (!rxFrame.is()) - throw css::lang::IllegalArgumentException("no XFrame given to PagePropertyPanel::Create", nullptr, 1); - return VclPtr<ThemePanel>::Create(pParent, rxFrame); + return std::make_unique<ThemePanel>(pParent); } -ThemePanel::ThemePanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) - : PanelLayout(pParent, "ThemePanel", "modules/swriter/ui/sidebartheme.ui", rxFrame) +ThemePanel::ThemePanel(weld::Widget* pParent) + : PanelLayout(pParent, "ThemePanel", "modules/swriter/ui/sidebartheme.ui") , mxListBoxFonts(m_xBuilder->weld_tree_view("listbox_fonts")) , mxValueSetColors(new ValueSet(nullptr)) , mxValueSetColorsWin(new weld::CustomWeld(*m_xBuilder, "valueset_colors", *mxValueSetColors)) @@ -447,23 +443,14 @@ ThemePanel::ThemePanel(vcl::Window* pParent, if (!aColorSets.empty()) mxValueSetColors->SelectItem(1); // ItemId 1, position 0 - - m_pInitialFocusWidget = mxListBoxFonts.get(); } ThemePanel::~ThemePanel() { - disposeOnce(); -} - -void ThemePanel::dispose() -{ mxListBoxFonts.reset(); mxValueSetColorsWin.reset(); mxValueSetColors.reset(); mxApplyButton.reset(); - - PanelLayout::dispose(); } IMPL_LINK_NOARG(ThemePanel, ClickHdl, weld::Button&, void) diff --git a/sw/source/uibase/sidebar/ThemePanel.hxx b/sw/source/uibase/sidebar/ThemePanel.hxx index 34a982bb2d29..14af479e664a 100644 --- a/sw/source/uibase/sidebar/ThemePanel.hxx +++ b/sw/source/uibase/sidebar/ThemePanel.hxx @@ -10,7 +10,6 @@ #pragma once -#include <com/sun/star/frame/XFrame.hpp> #include <sfx2/sidebar/PanelLayout.hxx> #include <sfx2/sidebar/ControllerItem.hxx> #include <svtools/valueset.hxx> @@ -21,10 +20,11 @@ namespace sw::sidebar { class ThemePanel : public PanelLayout, public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { - friend class VclPtr<ThemePanel>; public: - static VclPtr<PanelLayout> Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); + static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent); + + ThemePanel(weld::Widget* pParent); + virtual ~ThemePanel() override; virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, @@ -35,12 +35,6 @@ public: boost::property_tree::ptree& /*rState*/) override {}; private: - ThemePanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); - virtual ~ThemePanel() override; - - virtual void dispose() override; - std::unique_ptr<weld::TreeView> mxListBoxFonts; std::unique_ptr<ValueSet> mxValueSetColors; std::unique_ptr<weld::CustomWeld> mxValueSetColorsWin; diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx index 33fd16da7764..c45b0a6078ab 100644 --- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx +++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx @@ -33,8 +33,8 @@ namespace sw::sidebar { -VclPtr<PanelLayout> WrapPropertyPanel::Create ( - vcl::Window* pParent, +std::unique_ptr<PanelLayout> WrapPropertyPanel::Create ( + weld::Widget* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, SfxBindings* pBindings) { @@ -45,17 +45,14 @@ VclPtr<PanelLayout> WrapPropertyPanel::Create ( if (pBindings == nullptr) throw css::lang::IllegalArgumentException("no SfxBindings given to WrapPropertyPanel::Create", nullptr, 2); - return VclPtr<WrapPropertyPanel>::Create( - pParent, - rxFrame, - pBindings); + return std::make_unique<WrapPropertyPanel>(pParent, rxFrame, pBindings); } WrapPropertyPanel::WrapPropertyPanel( - vcl::Window* pParent, + weld::Widget* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, SfxBindings* pBindings ) - : PanelLayout(pParent, "WrapPropertyPanel", "modules/swriter/ui/sidebarwrap.ui", rxFrame) + : PanelLayout(pParent, "WrapPropertyPanel", "modules/swriter/ui/sidebarwrap.ui") , mpBindings(pBindings) // spacing , nTop(0) @@ -75,26 +72,16 @@ WrapPropertyPanel::WrapPropertyPanel( SpacingListBox::Fill(IsInch(eMetric) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM, *mxSpacingLB); Initialize(); - - m_pInitialFocusWidget = mxWrapOptions.get(); } WrapPropertyPanel::~WrapPropertyPanel() { - disposeOnce(); -} - -void WrapPropertyPanel::dispose() -{ - mxSpacingLB.reset(); mxWrapOptionsDispatch.reset(); mxWrapOptions.reset(); maSwLRSpacingControl.dispose(); maSwULSpacingControl.dispose(); - - PanelLayout::dispose(); } void WrapPropertyPanel::Initialize() diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.hxx b/sw/source/uibase/sidebar/WrapPropertyPanel.hxx index 7a07ff3be9d7..319085513e1b 100644 --- a/sw/source/uibase/sidebar/WrapPropertyPanel.hxx +++ b/sw/source/uibase/sidebar/WrapPropertyPanel.hxx @@ -32,8 +32,8 @@ namespace sw::sidebar { , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: - static VclPtr<PanelLayout> Create( - vcl::Window* pParent, + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, const css::uno::Reference< css::frame::XFrame>& rxFrame, SfxBindings* pBindings ); @@ -48,10 +48,9 @@ namespace sw::sidebar { boost::property_tree::ptree& /*rState*/) override {}; virtual ~WrapPropertyPanel() override; - virtual void dispose() override; WrapPropertyPanel( - vcl::Window* pParent, + weld::Widget* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, SfxBindings* pBindings ); private: diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx index 83546dec8fc7..959c2bd48a25 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -44,22 +45,16 @@ namespace sw::sidebar { static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& aStore); -VclPtr<PanelLayout> WriterInspectorTextPanel::Create(vcl::Window* pParent, - const uno::Reference<frame::XFrame>& rxFrame) +std::unique_ptr<PanelLayout> WriterInspectorTextPanel::Create(weld::Widget* pParent) { if (pParent == nullptr) throw lang::IllegalArgumentException( "no parent Window given to WriterInspectorTextPanel::Create", nullptr, 0); - if (!rxFrame.is()) - throw lang::IllegalArgumentException("no XFrame given to WriterInspectorTextPanel::Create", - nullptr, 1); - - return VclPtr<WriterInspectorTextPanel>::Create(pParent, rxFrame); + return std::make_unique<WriterInspectorTextPanel>(pParent); } -WriterInspectorTextPanel::WriterInspectorTextPanel(vcl::Window* pParent, - const uno::Reference<frame::XFrame>& rxFrame) - : InspectorTextPanel(pParent, rxFrame) +WriterInspectorTextPanel::WriterInspectorTextPanel(weld::Widget* pParent) + : InspectorTextPanel(pParent) { SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); m_pShell = pDocSh->GetWrtShell(); @@ -76,14 +71,7 @@ WriterInspectorTextPanel::WriterInspectorTextPanel(vcl::Window* pParent, updateEntries(aStore); } -WriterInspectorTextPanel::~WriterInspectorTextPanel() { disposeOnce(); } - -void WriterInspectorTextPanel::dispose() -{ - m_pShell->SetChgLnk(m_oldLink); - - InspectorTextPanel::dispose(); -} +WriterInspectorTextPanel::~WriterInspectorTextPanel() { m_pShell->SetChgLnk(m_oldLink); } static OUString PropertyNametoRID(const OUString& rName) { diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx index 56137399c679..2f72c6317523 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx @@ -27,14 +27,11 @@ namespace sw::sidebar class WriterInspectorTextPanel final : public svx::sidebar::InspectorTextPanel { public: - static VclPtr<PanelLayout> Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); + static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent); - WriterInspectorTextPanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); + WriterInspectorTextPanel(weld::Widget* pParent); virtual ~WriterInspectorTextPanel() override; - virtual void dispose() override; private: SwWrtShell* m_pShell; diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 6a1e66bbb1aa..d70494d64cc7 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -925,7 +925,7 @@ SwContentTree::SwContentTree(std::unique_ptr<weld::TreeView> xTreeView, SwNaviga : m_xTreeView(std::move(xTreeView)) , m_xScratchIter(m_xTreeView->make_iterator()) , m_aDropTargetHelper(*this) - , m_xDialog(pDialog) + , m_pDialog(pDialog) , m_sSpace(OUString(" ")) , m_sInvisible(SwResId(STR_INVISIBLE)) , m_pHiddenShell(nullptr) @@ -978,7 +978,6 @@ SwContentTree::~SwContentTree() clear(); // If applicable erase content types previously. m_aUpdTimer.Stop(); SetActiveShell(nullptr); - m_xDialog.clear(); } // Drag&Drop methods @@ -4542,7 +4541,7 @@ bool NaviContentBookmark::Paste( TransferableDataHelper& rData ) SwNavigationPI* SwContentTree::GetParentWindow() { - return m_xDialog; + return m_pDialog; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx index 745ac10ce8d1..fb6326f37ae7 100644 --- a/sw/source/uibase/utlui/glbltree.cxx +++ b/sw/source/uibase/utlui/glbltree.cxx @@ -125,7 +125,7 @@ static const char* GLOBAL_CONTEXT_ARY[] = SwGlobalTree::SwGlobalTree(std::unique_ptr<weld::TreeView> xTreeView, SwNavigationPI* pDialog) : m_xTreeView(std::move(xTreeView)) , m_aDropTargetHelper(*this) - , m_xDialog(pDialog) + , m_pDialog(pDialog) , m_pActiveShell(nullptr) { m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 30, @@ -153,7 +153,6 @@ SwGlobalTree::~SwGlobalTree() m_pSwGlblDocContents.reset(); m_pDocInserter.reset(); m_aUpdateTimer.Stop(); - m_xDialog.clear(); } SwGlobalTreeDropTarget::SwGlobalTreeDropTarget(SwGlobalTree& rTreeView) @@ -513,7 +512,8 @@ void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const OUString* Sequence< OUString > aFileNames; if ( !pFileName ) { - m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetParentWindow()->GetFrameWeld(), "swriter", sfx2::DocumentInserter::Mode::InsertMulti)); + SwNavigationPI* pNavi = GetParentWindow(); + m_pDocInserter.reset(new ::sfx2::DocumentInserter(pNavi->GetFrameWeld(), "swriter", sfx2::DocumentInserter::Mode::InsertMulti)); m_pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) ); } else if ( !pFileName->isEmpty() ) @@ -963,7 +963,7 @@ IMPL_LINK_NOARG( SwGlobalTree, DoubleClickHdl, weld::TreeView&, bool) SwNavigationPI* SwGlobalTree::GetParentWindow() { - return m_xDialog; + return m_pDialog; } IMPL_STATIC_LINK_NOARG(SwGlobalTree, ShowFrameHdl, void*, void) diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 08ba46dae8e3..bbfc9b062fce 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -193,7 +193,7 @@ IMPL_LINK(SwNavigationPI, ToolBoxSelectHdl, const OString&, rCommand, void) } else if (rCommand == "listbox") { - if (ParentIsFloatingWindow(GetParent())) + if (ParentIsFloatingWindow(m_xNavigatorDlg)) { if (IsZoomedIn()) { @@ -394,7 +394,7 @@ void SwNavigationPI::ZoomOut() { if (!IsZoomedIn()) return; - SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(GetParent()); + SfxNavigator* pNav = m_xNavigatorDlg.get(); if (!pNav) return; m_bIsZoomedIn = false; @@ -411,7 +411,8 @@ void SwNavigationPI::ZoomOut() m_xDocListBox->show(); } - Size aOptimalSize(m_xContainer->get_preferred_size()); + pNav->InvalidateChildSizeCache(); + Size aOptimalSize(pNav->GetOptimalSize()); Size aNewSize(pNav->GetOutputSizePixel()); aNewSize.setHeight( m_aExpandedSize.Height() ); pNav->SetMinOutputSizePixel(aOptimalSize); @@ -426,11 +427,11 @@ void SwNavigationPI::ZoomIn() { if (IsZoomedIn()) return; - SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(GetParent()); + SfxNavigator* pNav = m_xNavigatorDlg.get(); if (!pNav) return; - m_aExpandedSize = GetSizePixel(); + m_aExpandedSize = m_xNavigatorDlg->GetSizePixel(); m_xContentBox->hide(); m_xContentTree->HideTree(); @@ -439,7 +440,8 @@ void SwNavigationPI::ZoomIn() m_xDocListBox->hide(); m_bIsZoomedIn = true; - Size aOptimalSize(m_xContainer->get_preferred_size()); + pNav->InvalidateChildSizeCache(); + Size aOptimalSize(pNav->GetOptimalSize()); Size aNewSize(pNav->GetOutputSizePixel()); aNewSize.setHeight( aOptimalSize.Height() ); pNav->SetMinOutputSizePixel(aOptimalSize); @@ -462,7 +464,7 @@ enum StatusIndex } -VclPtr<PanelLayout> SwNavigationPI::Create(vcl::Window* pParent, +std::unique_ptr<PanelLayout> SwNavigationPI::Create(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* pBindings) { @@ -472,13 +474,13 @@ VclPtr<PanelLayout> SwNavigationPI::Create(vcl::Window* pParent, throw css::lang::IllegalArgumentException("no XFrame given to SwNavigationPI::Create", nullptr, 0); if( pBindings == nullptr ) throw css::lang::IllegalArgumentException("no SfxBindings given to SwNavigationPI::Create", nullptr, 0); - return VclPtr<SwNavigationPI>::Create(pParent, rxFrame, pBindings); + return std::make_unique<SwNavigationPI>(pParent, rxFrame, pBindings, nullptr); } -SwNavigationPI::SwNavigationPI(vcl::Window* pParent, +SwNavigationPI::SwNavigationPI(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* _pBindings) - : PanelLayout(pParent, "NavigatorPanel", "modules/swriter/ui/navigatorpanel.ui", rxFrame) + SfxBindings* _pBindings, SfxNavigator* pNavigatorDlg) + : PanelLayout(pParent, "NavigatorPanel", "modules/swriter/ui/navigatorpanel.ui") , m_aDocFullName(SID_DOCFULLNAME, *_pBindings, *this) , m_aPageStats(FN_STAT_PAGE, *_pBindings, *this) , m_xContent1ToolBox(m_xBuilder->weld_toolbar("content1")) @@ -500,6 +502,7 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, , m_xGlobalBox(m_xBuilder->weld_widget("globalbox")) , m_xGlobalTree(new SwGlobalTree(m_xBuilder->weld_tree_view("globaltree"), this)) , m_xDocListBox(m_xBuilder->weld_combo_box("documents")) + , m_xNavigatorDlg(pNavigatorDlg) , m_pContentView(nullptr) , m_pContentWrtShell(nullptr) , m_pActContView(nullptr) @@ -512,7 +515,7 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, { m_xContainer->connect_container_focus_changed(LINK(this, SwNavigationPI, SetFocusChildHdl)); - set_id("NavigatorPanelParent"); // for uitest/writer_tests5/tdf114724.py + UpdateInitShow(); GetCreateView(); @@ -562,7 +565,7 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, m_aStatusArr[3] = SwResId(STR_ACTIVE_VIEW); - bool bFloatingNavigator = ParentIsFloatingWindow(GetParent()); + bool bFloatingNavigator = ParentIsFloatingWindow(m_xNavigatorDlg); m_xContentTree->set_selection_mode(SelectionMode::Single); m_xContentTree->ShowTree(); @@ -622,16 +625,16 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, m_xDocListBox->set_accessible_name(m_aStatusArr[3]); m_aExpandedSize = m_xContainer->get_preferred_size(); - - m_pInitialFocusWidget = m_xContent1ToolBox.get(); } -SwNavigationPI::~SwNavigationPI() +weld::Window* SwNavigationPI::GetFrameWeld() const { - disposeOnce(); + if (m_xNavigatorDlg) + return m_xNavigatorDlg->GetFrameWeld(); + return PanelLayout::GetFrameWeld(); } -void SwNavigationPI::dispose() +SwNavigationPI::~SwNavigationPI() { if (IsGlobalDoc() && !IsGlobalMode()) { @@ -674,8 +677,6 @@ void SwNavigationPI::dispose() m_aDocFullName.dispose(); m_aPageStats.dispose(); - - PanelLayout::dispose(); } void SwNavigationPI::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState /*eState*/, @@ -717,24 +718,21 @@ void SwNavigationPI::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState /*eState*/, } } -void SwNavigationPI::StateChanged(StateChangedType nStateChange) +void SwNavigationPI::UpdateInitShow() { - PanelLayout::StateChanged(nStateChange); - if (nStateChange == StateChangedType::InitShow) + // if the parent isn't a float, then the navigator is displayed in + // the sidebar or is otherwise docked. While the navigator could change + // its size, the sidebar can not, and the navigator would just waste + // space. Therefore disable this button. + bool bParentIsFloatingWindow(ParentIsFloatingWindow(m_xNavigatorDlg)); + m_xContent6ToolBox->set_item_sensitive("listbox", bParentIsFloatingWindow); + // show content if docked + if (!bParentIsFloatingWindow && IsZoomedIn()) + ZoomOut(); + if (m_xContentTree) { - // if the parent isn't a float, then the navigator is displayed in - // the sidebar or is otherwise docked. While the navigator could change - // its size, the sidebar can not, and the navigator would just waste - // space. Therefore disable this button. - m_xContent6ToolBox->set_item_sensitive("listbox", ParentIsFloatingWindow(GetParent())); - // show content if docked - if (!ParentIsFloatingWindow(GetParent()) && IsZoomedIn()) - ZoomOut(); - if (m_xContentTree) - { - m_xContentTree->SetActiveShell(GetActiveWrtShell()); - m_xContentTree->UpdateTracking(); - } + m_xContentTree->SetActiveShell(GetActiveWrtShell()); + m_xContentTree->UpdateTracking(); } } @@ -1092,12 +1090,13 @@ SwView* SwNavigationPI::GetCreateView() const class SwNavigatorWin : public SfxNavigator { private: - VclPtr<SwNavigationPI> pNavi; + std::unique_ptr<SwNavigationPI> m_xNavi; public: SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* pParent); + virtual void StateChanged(StateChangedType nStateChange) override; virtual void dispose() override { - pNavi.disposeAndClear(); + m_xNavi.reset(); SfxNavigator::dispose(); } virtual ~SwNavigatorWin() override @@ -1108,9 +1107,8 @@ public: SwNavigatorWin::SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* pParent) : SfxNavigator(_pBindings, _pMgr, pParent) + , m_xNavi(std::make_unique<SwNavigationPI>(m_xContainer.get(), _pBindings->GetActiveFrame(), _pBindings, this)) { - Reference< XFrame > xFrame = _pBindings->GetActiveFrame(); - pNavi = VclPtr< SwNavigationPI >::Create( this, xFrame, _pBindings ); _pBindings->Invalidate(SID_NAVIGATOR); SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); @@ -1118,20 +1116,26 @@ SwNavigatorWin::SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, v const ContentTypeId nRootType = pNaviConfig->GetRootType(); if( nRootType != ContentTypeId::UNKNOWN ) { - pNavi->m_xContentTree->SetRootType(nRootType); - pNavi->m_xContent5ToolBox->set_item_active("root", true); + m_xNavi->m_xContentTree->SetRootType(nRootType); + m_xNavi->m_xContent5ToolBox->set_item_active("root", true); if (nRootType == ContentTypeId::OUTLINE) { - pNavi->m_xContentTree->set_selection_mode(SelectionMode::Multiple); + m_xNavi->m_xContentTree->set_selection_mode(SelectionMode::Multiple); } } - pNavi->m_xContentTree->SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); - pNavi->SetRegionDropMode( pNaviConfig->GetRegionMode() ); - pNavi->Show(); + m_xNavi->m_xContentTree->SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); + m_xNavi->SetRegionDropMode( pNaviConfig->GetRegionMode() ); - SetMinOutputSizePixel(pNavi->GetOptimalSize()); + SetMinOutputSizePixel(GetOptimalSize()); if (pNaviConfig->IsSmall()) - pNavi->ZoomIn(); + m_xNavi->ZoomIn(); +} + +void SwNavigatorWin::StateChanged(StateChangedType nStateChange) +{ + SfxNavigator::StateChanged(nStateChange); + if (nStateChange == StateChangedType::InitShow) + m_xNavi->UpdateInitShow(); } SFX_IMPL_DOCKINGWINDOW(SwNavigatorWrapper, SID_NAVIGATOR); |