diff options
Diffstat (limited to 'sfx2/source/sidebar')
28 files changed, 218 insertions, 188 deletions
diff --git a/sfx2/source/sidebar/ControlFactory.cxx b/sfx2/source/sidebar/ControlFactory.cxx index 23e17a671deb..d8a49b3dd148 100644 --- a/sfx2/source/sidebar/ControlFactory.cxx +++ b/sfx2/source/sidebar/ControlFactory.cxx @@ -25,14 +25,14 @@ namespace sfx2 { namespace sidebar { -CheckBox* ControlFactory::CreateMenuButton (vcl::Window* pParentWindow) +VclPtr<CheckBox> ControlFactory::CreateMenuButton (vcl::Window* pParentWindow) { - return new MenuButton(pParentWindow); + return VclPtr<CheckBox>(new MenuButton(pParentWindow), SAL_NO_ACQUIRE); } -ImageRadioButton* ControlFactory::CreateTabItem (vcl::Window* pParentWindow) +VclPtr<ImageRadioButton> ControlFactory::CreateTabItem (vcl::Window* pParentWindow) { - return new TabItem(pParentWindow); + return VclPtr<ImageRadioButton>(new TabItem(pParentWindow), SAL_NO_ACQUIRE); } } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx index 729e2b210164..22dd244e52e0 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -117,8 +117,16 @@ ControllerItem::ControllerItem ( ControllerItem::~ControllerItem() { + dispose(); +} + +void ControllerItem::dispose() +{ if (mxFrameActionListener.is()) mxFrameActionListener->dispose(); + mxFrameActionListener.clear(); + + SfxControllerItem::dispose(); } void ControllerItem::StateChanged ( diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index 831c05325d8c..de2066defd74 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -48,11 +48,11 @@ Deck::Deck ( maIcon(), mnMinimalWidth(0), maPanels(), - mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)), - mpScrollClipWindow(new vcl::Window(this)), - mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())), - mpFiller(new vcl::Window(this)), - mpVerticalScrollBar(new ScrollBar(this)) + mpTitleBar(VclPtr<DeckTitleBar>::Create(rDeckDescriptor.msTitle, this, rCloserAction)), + mpScrollClipWindow(VclPtr<vcl::Window>::Create(this)), + mpScrollContainer(VclPtr<ScrollContainerWindow>::Create(mpScrollClipWindow.get())), + mpFiller(VclPtr<vcl::Window>::Create(this)), + mpVerticalScrollBar(VclPtr<ScrollBar>::Create(this)) { SetBackground(Wallpaper()); @@ -75,35 +75,27 @@ Deck::Deck ( Deck::~Deck() { - Dispose(); - - // We have to explicitly trigger the destruction of panels. - // Otherwise that is done by one of our base class destructors - // without updating maPanels. - maPanels.clear(); + disposeOnce(); } -void Deck::Dispose() +void Deck::dispose() { SharedPanelContainer aPanels; aPanels.swap(maPanels); - for (SharedPanelContainer::iterator - iPanel(aPanels.begin()), - iEnd(aPanels.end()); - iPanel!=iEnd; - ++iPanel) - { - if (*iPanel) - { - (*iPanel)->Dispose(); - OSL_ASSERT(iPanel->unique()); - iPanel->reset(); - } - } - mpTitleBar.reset(); - mpFiller.reset(); - mpVerticalScrollBar.reset(); + // We have to explicitly trigger the destruction of panels. + // Otherwise that is done by one of our base class destructors + // without updating maPanels. + for (size_t i = 0; i < aPanels.size(); i++) + aPanels[i].disposeAndClear(); + + mpTitleBar.disposeAndClear(); + mpFiller.disposeAndClear(); + mpVerticalScrollBar.disposeAndClear(); + mpScrollContainer.disposeAndClear(); + mpScrollClipWindow.disposeAndClear(); + + vcl::Window::dispose(); } DeckTitleBar* Deck::GetTitleBar() const @@ -210,8 +202,21 @@ bool Deck::ProcessWheelEvent(CommandEvent* pCommandEvent) return true; } -void Deck::SetPanels (const SharedPanelContainer& rPanels) +/** + * This container may contain existing panels that are + * being re-used, and new ones too. + */ +void Deck::ResetPanels (const SharedPanelContainer& rPanels) { + // First dispose old panels we no longer need. + for (size_t i = 0; i < maPanels.size(); i++) + { + bool bFound = false; + for (size_t j = 0; j < rPanels.size(); j++) + bFound = bFound || (maPanels[i].get() == rPanels[j].get()); + if (!bFound) // this one didn't survive. + maPanels[i].disposeAndClear(); + } maPanels = rPanels; RequestLayout(); @@ -323,10 +328,6 @@ Deck::ScrollContainerWindow::ScrollContainerWindow (vcl::Window* pParentWindow) #endif } -Deck::ScrollContainerWindow::~ScrollContainerWindow() -{ -} - void Deck::ScrollContainerWindow::Paint (const Rectangle& rUpdateArea) { (void)rUpdateArea; diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx index ddb5354b21e1..b231b5c9b628 100644 --- a/sfx2/source/sidebar/Deck.hxx +++ b/sfx2/source/sidebar/Deck.hxx @@ -47,13 +47,12 @@ public: vcl::Window* pParentWindow, const ::boost::function<void()>& rCloserAction); virtual ~Deck(); - - void Dispose(); + virtual void dispose() SAL_OVERRIDE; const ::rtl::OUString& GetId() const { return msId;} DeckTitleBar* GetTitleBar() const; Rectangle GetContentArea() const; - void SetPanels (const SharedPanelContainer& rPanels); + void ResetPanels (const SharedPanelContainer& rPanels); const SharedPanelContainer& GetPanels() const { return maPanels;} void RequestLayout(); vcl::Window* GetPanelParentWindow(); @@ -77,7 +76,6 @@ public: { public: ScrollContainerWindow (vcl::Window* pParentWindow); - virtual ~ScrollContainerWindow(); virtual void Paint (const Rectangle& rUpdateArea) SAL_OVERRIDE; void SetSeparators (const ::std::vector<sal_Int32>& rSeparators); private: @@ -89,11 +87,11 @@ private: Image maIcon; sal_Int32 mnMinimalWidth; SharedPanelContainer maPanels; - ::boost::scoped_ptr<DeckTitleBar> mpTitleBar; - ::boost::scoped_ptr<vcl::Window> mpScrollClipWindow; - ::boost::scoped_ptr<ScrollContainerWindow> mpScrollContainer; - ::boost::scoped_ptr<vcl::Window> mpFiller; - ::boost::scoped_ptr<ScrollBar> mpVerticalScrollBar; + VclPtr<DeckTitleBar> mpTitleBar; + VclPtr<vcl::Window> mpScrollClipWindow; + VclPtr<ScrollContainerWindow> mpScrollContainer; + VclPtr<vcl::Window> mpFiller; + VclPtr<ScrollBar> mpVerticalScrollBar; DECL_LINK(HandleVerticalScrollBarChange,void*); bool ProcessWheelEvent(CommandEvent* pCommandEvent); diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx index aae65c611950..110a77fc4cbb 100644 --- a/sfx2/source/sidebar/DeckLayouter.cxx +++ b/sfx2/source/sidebar/DeckLayouter.cxx @@ -43,7 +43,7 @@ namespace { class LayoutItem { public: - SharedPanel mpPanel; + VclPtr<Panel> mpPanel; css::ui::LayoutSize maLayoutSize; sal_Int32 mnDistributedHeight; sal_Int32 mnWeight; @@ -348,7 +348,7 @@ void GetRequestedSizes ( IterateLayoutItems(iItem,rLayoutItems) { ui::LayoutSize aLayoutSize (ui::LayoutSize(0,0,0)); - if (iItem->mpPanel != 0) + if (iItem->mpPanel != nullptr) { if (rLayoutItems.size() == 1 && iItem->mpPanel->IsTitleBarOptional()) diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx b/sfx2/source/sidebar/DeckTitleBar.cxx index 9c296b1f3f3d..4e52d1aa57ab 100644 --- a/sfx2/source/sidebar/DeckTitleBar.cxx +++ b/sfx2/source/sidebar/DeckTitleBar.cxx @@ -52,10 +52,6 @@ DeckTitleBar::DeckTitleBar ( #endif } -DeckTitleBar::~DeckTitleBar() -{ -} - void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) { if (mbIsCloserVisible != bIsCloserVisible) @@ -64,16 +60,16 @@ void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) if (mbIsCloserVisible) { - maToolBox.InsertItem( + maToolBox->InsertItem( mnCloserItemIndex, Theme::GetImage(Theme::Image_Closer)); - maToolBox.SetQuickHelpText( + maToolBox->SetQuickHelpText( mnCloserItemIndex, SFX2_RESSTR(SFX_STR_SIDEBAR_CLOSE_DECK)); } else - maToolBox.RemoveItem( - maToolBox.GetItemPos(mnCloserItemIndex)); + maToolBox->RemoveItem( + maToolBox->GetItemPos(mnCloserItemIndex)); } } @@ -119,7 +115,7 @@ css::uno::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessi void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent) { - maToolBox.SetItemImage( + maToolBox->SetItemImage( mnCloserItemIndex, Theme::GetImage(Theme::Image_Closer)); TitleBar::DataChanged(rEvent); diff --git a/sfx2/source/sidebar/DeckTitleBar.hxx b/sfx2/source/sidebar/DeckTitleBar.hxx index d481b2d842d3..871635b42632 100644 --- a/sfx2/source/sidebar/DeckTitleBar.hxx +++ b/sfx2/source/sidebar/DeckTitleBar.hxx @@ -33,7 +33,6 @@ public: const ::rtl::OUString& rsTitle, vcl::Window* pParentWindow, const ::boost::function<void()>& rCloserAction); - virtual ~DeckTitleBar(); void SetCloserVisible (const bool bIsCloserVisible); diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx index 1dae58556cbd..37fa9940c1ea 100644 --- a/sfx2/source/sidebar/FocusManager.cxx +++ b/sfx2/source/sidebar/FocusManager.cxx @@ -65,9 +65,9 @@ void FocusManager::Clear() void FocusManager::ClearPanels() { - ::std::vector<Panel*> aPanels; + ::std::vector<VclPtr<Panel> > aPanels; aPanels.swap(maPanels); - for (::std::vector<Panel*>::iterator iPanel(aPanels.begin()),iEnd(aPanels.end()); + for (auto iPanel(aPanels.begin()),iEnd(aPanels.end()); iPanel!=iEnd; ++iPanel) { @@ -84,9 +84,9 @@ void FocusManager::ClearPanels() void FocusManager::ClearButtons() { - ::std::vector<Button*> aButtons; + ::std::vector<VclPtr<Button> > aButtons; aButtons.swap(maButtons); - for (::std::vector<Button*>::iterator iButton(aButtons.begin()),iEnd(aButtons.end()); + for (auto iButton(aButtons.begin()),iEnd(aButtons.end()); iButton!=iEnd; ++iButton) { @@ -96,14 +96,14 @@ void FocusManager::ClearButtons() void FocusManager::SetDeckTitle (DeckTitleBar* pDeckTitleBar) { - if (mpDeckTitleBar != NULL) + if (mpDeckTitleBar != nullptr) { UnregisterWindow(*mpDeckTitleBar); UnregisterWindow(mpDeckTitleBar->GetToolBox()); } mpDeckTitleBar = pDeckTitleBar; - if (mpDeckTitleBar != NULL) + if (mpDeckTitleBar != nullptr) { RegisterWindow(*mpDeckTitleBar); RegisterWindow(mpDeckTitleBar->GetToolBox()); @@ -156,7 +156,7 @@ void FocusManager::UnregisterWindow (vcl::Window& rWindow) FocusManager::FocusLocation FocusManager::GetFocusLocation (const vcl::Window& rWindow) const { // Check the deck title. - if (mpDeckTitleBar != NULL) + if (mpDeckTitleBar != nullptr) { if (mpDeckTitleBar == &rWindow) return FocusLocation(PC_DeckTitle, -1); @@ -186,7 +186,7 @@ FocusManager::FocusLocation FocusManager::GetFocusLocation (const vcl::Window& r void FocusManager::FocusDeckTitle() { - if (mpDeckTitleBar != NULL) + if (mpDeckTitleBar != nullptr) { if (IsDeckTitleVisible()) { @@ -207,7 +207,7 @@ void FocusManager::FocusDeckTitle() bool FocusManager::IsDeckTitleVisible() const { - return mpDeckTitleBar != NULL && mpDeckTitleBar->IsVisible(); + return mpDeckTitleBar != nullptr && mpDeckTitleBar->IsVisible(); } bool FocusManager::IsPanelTitleVisible (const sal_Int32 nPanelIndex) const @@ -286,7 +286,7 @@ void FocusManager::ClickButton (const sal_Int32 nButtonIndex) void FocusManager::RemoveWindow (vcl::Window& rWindow) { - ::std::vector<Panel*>::iterator iPanel (::std::find(maPanels.begin(), maPanels.end(), &rWindow)); + auto iPanel (::std::find(maPanels.begin(), maPanels.end(), &rWindow)); if (iPanel != maPanels.end()) { UnregisterWindow(rWindow); @@ -299,7 +299,7 @@ void FocusManager::RemoveWindow (vcl::Window& rWindow) return; } - ::std::vector<Button*>::iterator iButton (::std::find(maButtons.begin(), maButtons.end(), &rWindow)); + auto iButton (::std::find(maButtons.begin(), maButtons.end(), &rWindow)); if (iButton != maButtons.end()) { UnregisterWindow(rWindow); @@ -596,7 +596,7 @@ IMPL_LINK(FocusManager, ChildEventListener, VclSimpleEvent*, pEvent) break; case KEY_TAB: - if (mpFirstFocusedContentControl!=NULL + if (mpFirstFocusedContentControl!=nullptr && mpLastFocusedWindow == mpFirstFocusedContentControl) { // Move focus back to panel (or deck) diff --git a/sfx2/source/sidebar/FocusManager.hxx b/sfx2/source/sidebar/FocusManager.hxx index 4db5fe1ead64..93367bd4ce44 100644 --- a/sfx2/source/sidebar/FocusManager.hxx +++ b/sfx2/source/sidebar/FocusManager.hxx @@ -68,13 +68,13 @@ public: void SetButtons (const ::std::vector<Button*>& rButtons); private: - DeckTitleBar* mpDeckTitleBar; - ::std::vector<Panel*> maPanels; - ::std::vector<Button*> maButtons; + VclPtr<DeckTitleBar> mpDeckTitleBar; + ::std::vector<VclPtr<Panel> > maPanels; + ::std::vector<VclPtr<Button> > maButtons; const ::boost::function<void(const Panel&)> maShowPanelFunctor; bool mbObservingContentControlFocus; - vcl::Window* mpFirstFocusedContentControl; - vcl::Window* mpLastFocusedWindow; + VclPtr<vcl::Window> mpFirstFocusedContentControl; + VclPtr<vcl::Window> mpLastFocusedWindow; enum PanelComponent { diff --git a/sfx2/source/sidebar/MenuButton.cxx b/sfx2/source/sidebar/MenuButton.cxx index 8620b30f9b93..c0e131109dc5 100644 --- a/sfx2/source/sidebar/MenuButton.cxx +++ b/sfx2/source/sidebar/MenuButton.cxx @@ -39,10 +39,6 @@ MenuButton::MenuButton (vcl::Window* pParentWindow) #endif } -MenuButton::~MenuButton() -{ -} - void MenuButton::Paint (const Rectangle& rUpdateArea) { switch(mePaintType) diff --git a/sfx2/source/sidebar/MenuButton.hxx b/sfx2/source/sidebar/MenuButton.hxx index 121dd991d4c6..1d09e14d4e9d 100644 --- a/sfx2/source/sidebar/MenuButton.hxx +++ b/sfx2/source/sidebar/MenuButton.hxx @@ -28,7 +28,6 @@ class MenuButton { public: MenuButton (vcl::Window* pParentWindow); - virtual ~MenuButton(); virtual void Paint (const Rectangle& rUpdateArea) SAL_OVERRIDE; virtual void MouseMove (const MouseEvent& rEvent) SAL_OVERRIDE; diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx index d72f15e57c22..52c9abc831f7 100644 --- a/sfx2/source/sidebar/Panel.cxx +++ b/sfx2/source/sidebar/Panel.cxx @@ -51,7 +51,7 @@ Panel::Panel ( const ::boost::function<Context()>& rContextAccess) : Window(pParentWindow), msPanelId(rPanelDescriptor.msId), - mpTitleBar(new PanelTitleBar( + mpTitleBar(VclPtr<PanelTitleBar>::Create( rPanelDescriptor.msTitle, pParentWindow, this)), @@ -71,10 +71,10 @@ Panel::Panel ( Panel::~Panel() { - Dispose(); + disposeOnce(); } -void Panel::Dispose() +void Panel::dispose() { mxPanelComponent = NULL; @@ -91,7 +91,9 @@ void Panel::Dispose() xComponent->dispose(); } - mpTitleBar.reset(); + mpTitleBar.disposeAndClear(); + + vcl::Window::dispose(); } PanelTitleBar* Panel::GetTitleBar() const diff --git a/sfx2/source/sidebar/Panel.hxx b/sfx2/source/sidebar/Panel.hxx index ad2c78d6e95d..03cd81ca5ec8 100644 --- a/sfx2/source/sidebar/Panel.hxx +++ b/sfx2/source/sidebar/Panel.hxx @@ -47,8 +47,7 @@ public: const ::boost::function<void()>& rDeckLayoutTrigger, const ::boost::function<Context()>& rContextAccess); virtual ~Panel(); - - void Dispose(); + virtual void dispose() SAL_OVERRIDE; PanelTitleBar* GetTitleBar() const; bool IsTitleBarOptional() const { return mbIsTitleBarOptional;} @@ -67,7 +66,7 @@ public: private: const ::rtl::OUString msPanelId; - ::boost::scoped_ptr<PanelTitleBar> mpTitleBar; + VclPtr<PanelTitleBar> mpTitleBar; const bool mbIsTitleBarOptional; css::uno::Reference<css::ui::XUIElement> mxElement; css::uno::Reference<css::ui::XSidebarPanel> mxPanelComponent; @@ -75,8 +74,7 @@ private: const ::boost::function<void()> maDeckLayoutTrigger; const ::boost::function<Context()> maContextAccess; }; -typedef ::boost::shared_ptr<Panel> SharedPanel; -typedef ::std::vector<SharedPanel> SharedPanelContainer; +typedef ::std::vector< VclPtr< Panel > > SharedPanelContainer; } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx index b8cf19fbc507..f526c0250055 100644 --- a/sfx2/source/sidebar/PanelTitleBar.cxx +++ b/sfx2/source/sidebar/PanelTitleBar.cxx @@ -51,7 +51,7 @@ PanelTitleBar::PanelTitleBar ( msMoreOptionsCommand(), msAccessibleNamePrefix(SFX2_RESSTR(SFX_STR_SIDEBAR_ACCESSIBILITY_PANEL_PREFIX)) { - OSL_ASSERT(mpPanel != NULL); + OSL_ASSERT(mpPanel != nullptr); #ifdef DEBUG SetText(OUString("PanelTitleBar")); @@ -60,6 +60,13 @@ PanelTitleBar::PanelTitleBar ( PanelTitleBar::~PanelTitleBar() { + disposeOnce(); +} + +void PanelTitleBar::dispose() +{ + mpPanel.clear(); + TitleBar::dispose(); } void PanelTitleBar::SetMoreOptionsCommand ( @@ -69,27 +76,27 @@ void PanelTitleBar::SetMoreOptionsCommand ( if ( ! rsCommandName.equals(msMoreOptionsCommand)) { if (msMoreOptionsCommand.getLength() > 0) - maToolBox.RemoveItem(maToolBox.GetItemPos(mnMenuItemIndex)); + maToolBox->RemoveItem(maToolBox->GetItemPos(mnMenuItemIndex)); msMoreOptionsCommand = rsCommandName; mxFrame = rxFrame; if (msMoreOptionsCommand.getLength() > 0) { - maToolBox.InsertItem( + maToolBox->InsertItem( mnMenuItemIndex, Theme::GetImage(Theme::Image_PanelMenu)); Reference<frame::XToolbarController> xController ( ControllerFactory::CreateToolBoxController( - &maToolBox, + maToolBox.get(), mnMenuItemIndex, msMoreOptionsCommand, rxFrame, - VCLUnoHelper::GetInterface(&maToolBox), + VCLUnoHelper::GetInterface(maToolBox.get()), 0)); - maToolBox.SetController(mnMenuItemIndex, xController, msMoreOptionsCommand); - maToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT); - maToolBox.SetQuickHelpText( + maToolBox->SetController(mnMenuItemIndex, xController, msMoreOptionsCommand); + maToolBox->SetOutStyle(TOOLBOX_STYLE_FLAT); + maToolBox->SetQuickHelpText( mnMenuItemIndex, SFX2_RESSTR(SFX_STR_SIDEBAR_MORE_OPTIONS)); } @@ -98,7 +105,7 @@ void PanelTitleBar::SetMoreOptionsCommand ( Rectangle PanelTitleBar::GetTitleArea (const Rectangle& rTitleBarBox) { - if (mpPanel != NULL) + if (mpPanel != nullptr) { Image aImage (mpPanel->IsExpanded() ? Theme::GetImage(Theme::Image_Expand) @@ -117,7 +124,7 @@ void PanelTitleBar::PaintDecoration (const Rectangle& rTitleBarBox) { (void)rTitleBarBox; - if (mpPanel != NULL) + if (mpPanel != nullptr) { Image aImage (mpPanel->IsExpanded() ? Theme::GetImage(Theme::Image_Collapse) @@ -185,7 +192,7 @@ void PanelTitleBar::MouseButtonUp (const MouseEvent& rMouseEvent) { if (mbIsLeftButtonDown) { - if (mpPanel != NULL) + if (mpPanel != nullptr) { mpPanel->SetExpanded( ! mpPanel->IsExpanded()); Invalidate(); @@ -198,7 +205,7 @@ void PanelTitleBar::MouseButtonUp (const MouseEvent& rMouseEvent) void PanelTitleBar::DataChanged (const DataChangedEvent& rEvent) { - maToolBox.SetItemImage( + maToolBox->SetItemImage( mnMenuItemIndex, Theme::GetImage(Theme::Image_PanelMenu)); TitleBar::DataChanged(rEvent); diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx b/sfx2/source/sidebar/PanelTitleBar.hxx index 37effd70726f..ede039f863dd 100644 --- a/sfx2/source/sidebar/PanelTitleBar.hxx +++ b/sfx2/source/sidebar/PanelTitleBar.hxx @@ -37,6 +37,7 @@ public: vcl::Window* pParentWindow, Panel* pPanel ); virtual ~PanelTitleBar(); + virtual void dispose() SAL_OVERRIDE; void SetMoreOptionsCommand ( const ::rtl::OUString& rsCommandName, @@ -56,7 +57,7 @@ protected: private: bool mbIsLeftButtonDown; - Panel* mpPanel; + VclPtr<Panel> mpPanel; const sal_uInt16 mnMenuItemIndex; css::uno::Reference<css::frame::XFrame> mxFrame; ::rtl::OUString msMoreOptionsCommand; diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx b/sfx2/source/sidebar/SidebarChildWindow.cxx index 4d4730d06df4..8587c290e335 100644 --- a/sfx2/source/sidebar/SidebarChildWindow.cxx +++ b/sfx2/source/sidebar/SidebarChildWindow.cxx @@ -37,17 +37,17 @@ SidebarChildWindow::SidebarChildWindow ( SfxChildWinInfo* pInfo) : SfxChildWindow(pParentWindow, nId) { - pWindow = new SidebarDockingWindow( + pWindow.reset(VclPtr<SidebarDockingWindow>::Create( pBindings, *this, pParentWindow, - WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE); + WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE)); eChildAlignment = SfxChildAlignment::RIGHT; pWindow->SetHelpId(HID_SIDEBAR_WINDOW); pWindow->SetOutputSizePixel(Size(GetDefaultWidth(pWindow), 450)); - SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pWindow); + SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pWindow.get()); if (pDockingParent != NULL) { if (pInfo && pInfo->aExtraString.isEmpty() && pInfo->aModule != "sdraw" && pInfo->aModule != "simpress") diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 6268a1e2abd0..4392c1b1c979 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -95,7 +95,7 @@ SidebarController::SidebarController ( : SidebarControllerInterfaceBase(m_aMutex), mpCurrentDeck(), mpParentWindow(pParentWindow), - mpTabBar(new TabBar( + mpTabBar(VclPtr<TabBar>::Create( mpParentWindow, rxFrame, ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1), @@ -117,8 +117,7 @@ SidebarController::SidebarController ( mxReadOnlyModeDispatch(), mbIsDocumentReadOnly(false), mpSplitWindow(NULL), - mnWidthOnSplitterButtonDown(0), - mpCloseIndicator() + mnWidthOnSplitterButtonDown(0) { // Listen for context change events. css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( @@ -173,6 +172,8 @@ SidebarController* SidebarController::GetSidebarControllerForFrame ( void SAL_CALL SidebarController::disposing() { + mpCloseIndicator.disposeAndClear(); + SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(mxFrame)); if (iEntry != maSidebarControllerContainer.end()) maSidebarControllerContainer.erase(iEntry); @@ -188,13 +189,13 @@ void SAL_CALL SidebarController::disposing() if (mxReadOnlyModeDispatch.is()) mxReadOnlyModeDispatch->removeStatusListener(this, Tools::GetURL(gsReadOnlyCommandName)); - if (mpSplitWindow != NULL) + if (mpSplitWindow != nullptr) { mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); mpSplitWindow = NULL; } - if (mpParentWindow != NULL) + if (mpParentWindow != nullptr) { mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); mpParentWindow = NULL; @@ -202,12 +203,11 @@ void SAL_CALL SidebarController::disposing() if (mpCurrentDeck) { - mpCurrentDeck->Dispose(); - mpCurrentDeck->PrintWindowTree(); - mpCurrentDeck.reset(); + mpCurrentDeck.disposeAndClear(); +// mpCurrentDeck->PrintWindowTree(); } - mpTabBar.reset(); + mpTabBar.disposeAndClear(); Theme::GetPropertySet()->removePropertyChangeListener( OUString(""), @@ -292,7 +292,7 @@ void SidebarController::NotifyResize() { if (mpTabBar == 0) { - OSL_ASSERT(mpTabBar!=0); + OSL_ASSERT(mpTabBar!=nullptr); return; } @@ -527,18 +527,13 @@ void SidebarController::SwitchToDeck ( const bool bForceNewDeck ((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0); const bool bForceNewPanels ((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0); - mnRequestedForceFlags = SwitchFlag_NoForce; if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId) || bForceNewDeck) { // When the deck changes then destroy the deck and all panels // and create everything new. - if (mpCurrentDeck) - { - mpCurrentDeck->Dispose(); - mpCurrentDeck.reset(); - } + mpCurrentDeck.disposeAndClear(); msCurrentDeckId = rDeckDescriptor.msId; } @@ -576,7 +571,7 @@ void SidebarController::SwitchToDeck ( if ( ! mpCurrentDeck) { mpCurrentDeck.reset( - new Deck( + VclPtr<Deck>::Create( rDeckDescriptor, mpParentWindow, ::boost::bind(&SidebarController::RequestCloseDeck, this))); @@ -597,6 +592,7 @@ void SidebarController::SwitchToDeck ( const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size()); SharedPanelContainer aNewPanels; const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels()); + aNewPanels.resize(nNewPanelCount); sal_Int32 nWriteIndex (0); bool bHasPanelSetChanged (false); @@ -612,19 +608,19 @@ void SidebarController::SwitchToDeck ( // Find the corresponding panel among the currently active // panels. - SharedPanelContainer::const_iterator iPanel; - if (bForceNewPanels) + SharedPanelContainer::const_iterator iPanel = rCurrentPanels.end(); + + if (!bForceNewPanels) { - // All panels have to be created in any case. There is no - // point in searching already existing panels. iPanel = rCurrentPanels.end(); - } - else - { - iPanel = ::std::find_if( - rCurrentPanels.begin(), - rCurrentPanels.end(), - ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))); + for (auto a = rCurrentPanels.begin(); a != rCurrentPanels.end(); ++a) + { + if ((*a)->HasIdPredicate(rPanelContexDescriptor.msId)) + { + iPanel = a; + break; + } + } } if (iPanel != rCurrentPanels.end()) { @@ -643,7 +639,7 @@ void SidebarController::SwitchToDeck ( rContext); bHasPanelSetChanged = true; } - if (aNewPanels[nWriteIndex] != 0) + if (aNewPanels[nWriteIndex] != nullptr) { // Depending on the context we have to change the command // for the "more options" dialog. @@ -659,6 +655,7 @@ void SidebarController::SwitchToDeck ( } } + // mpCurrentPanels - may miss stuff (?) aNewPanels.resize(nWriteIndex); // Activate the deck and the new set of panels. @@ -668,7 +665,7 @@ void SidebarController::SwitchToDeck ( mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor(), mpParentWindow->GetSizePixel().Height()); - mpCurrentDeck->SetPanels(aNewPanels); + mpCurrentDeck->ResetPanels(aNewPanels); mpCurrentDeck->Show(); mpParentWindow->SetText(rDeckDescriptor.msTitle); @@ -684,7 +681,7 @@ void SidebarController::SwitchToDeck ( UpdateTitleBarIcons(); } -SharedPanel SidebarController::CreatePanel ( +VclPtr<Panel> SidebarController::CreatePanel ( const OUString& rsPanelId, vcl::Window* pParentWindow, const bool bIsInitiallyExpanded, @@ -692,15 +689,15 @@ SharedPanel SidebarController::CreatePanel ( { const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); if (pPanelDescriptor == NULL) - return SharedPanel(); + return NULL; // Create the panel which is the parent window of the UIElement. - SharedPanel pPanel (new Panel( + VclPtr<Panel> pPanel = VclPtr<Panel>::Create( *pPanelDescriptor, pParentWindow, bIsInitiallyExpanded, ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()), - ::boost::bind(&SidebarController::GetCurrentContext, this))); + ::boost::bind(&SidebarController::GetCurrentContext, this)); // Create the XUIElement. Reference<ui::XUIElement> xUIElement (CreateUIElement( @@ -715,7 +712,7 @@ SharedPanel SidebarController::CreatePanel ( } else { - pPanel.reset(); + pPanel.disposeAndClear(); } return pPanel; @@ -737,7 +734,7 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement ( ::comphelper::NamedValueCollection aCreationArguments; aCreationArguments.put("Frame", makeAny(mxFrame)); aCreationArguments.put("ParentWindow", makeAny(rxWindow)); - SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); + SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow.get()); if (pSfxDockingWindow != NULL) aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); aCreationArguments.put("Theme", Theme::GetPropertySet()); @@ -802,7 +799,7 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) break; } } - else if (pEvent->GetWindow()==mpSplitWindow && mpSplitWindow!=NULL) + else if (pEvent->GetWindow()==mpSplitWindow && mpSplitWindow!=nullptr) { switch (pEvent->GetId()) { @@ -1060,7 +1057,7 @@ void SidebarController::RestrictWidth (sal_Int32 nWidth) SfxSplitWindow* pSplitWindow = GetSplitWindow(); if (pSplitWindow != NULL) { - const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); + const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow.get())); const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); pSplitWindow->SetItemSizeRange( nSetId, @@ -1071,17 +1068,17 @@ void SidebarController::RestrictWidth (sal_Int32 nWidth) SfxSplitWindow* SidebarController::GetSplitWindow() { - if (mpParentWindow != NULL) + if (mpParentWindow != nullptr) { SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); if (pSplitWindow != mpSplitWindow) { - if (mpSplitWindow != NULL) + if (mpSplitWindow != nullptr) mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); mpSplitWindow = pSplitWindow; - if (mpSplitWindow != NULL) + if (mpSplitWindow != nullptr) mpSplitWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); } return mpSplitWindow; @@ -1092,7 +1089,7 @@ SfxSplitWindow* SidebarController::GetSplitWindow() void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag) { - if (mpParentWindow == NULL) + if (mpParentWindow == nullptr) return; if (bCloseAfterDrag) @@ -1100,7 +1097,7 @@ void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag) // Make sure that the indicator exists. if ( ! mpCloseIndicator) { - mpCloseIndicator.reset(new FixedImage(mpParentWindow)); + mpCloseIndicator.reset(VclPtr<FixedImage>::Create(mpParentWindow)); FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get()); const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator)); pFixedImage->SetImage(aImage); diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx index 14705d91ca02..5fb8466b1fbc 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/sfx2/source/sidebar/SidebarController.hxx @@ -144,9 +144,9 @@ private: > SidebarControllerContainer; static SidebarControllerContainer maSidebarControllerContainer; - ::boost::scoped_ptr<Deck> mpCurrentDeck; - SidebarDockingWindow* mpParentWindow; - ::boost::scoped_ptr<TabBar> mpTabBar; + VclPtr<Deck> mpCurrentDeck; + VclPtr<SidebarDockingWindow> mpParentWindow; + VclPtr<TabBar> mpTabBar; css::uno::Reference<css::frame::XFrame> mxFrame; Context maCurrentContext; Context maRequestedContext; @@ -177,7 +177,7 @@ private: FocusManager maFocusManager; css::uno::Reference<css::frame::XDispatch> mxReadOnlyModeDispatch; bool mbIsDocumentReadOnly; - SfxSplitWindow* mpSplitWindow; + VclPtr<SfxSplitWindow> mpSplitWindow; /** When the user moves the splitter then we remember the width at that time. */ @@ -186,7 +186,7 @@ private: to indicate that when the current mouse drag operation ends, the sidebar will only show the tab bar. */ - ::boost::scoped_ptr<vcl::Window> mpCloseIndicator; + VclPtr<vcl::Window> mpCloseIndicator; DECL_LINK(WindowEventHandler, VclWindowEvent*); /** Make maRequestedContext the current context. @@ -198,7 +198,7 @@ private: const ::rtl::OUString& rsImplementationURL, const bool bWantsCanvas, const Context& rContext); - SharedPanel CreatePanel ( + VclPtr<Panel> CreatePanel ( const ::rtl::OUString& rsPanelId, vcl::Window* pParentWindow, const bool bIsInitiallyExpanded, diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index f67240c1a06c..7c9a150aeb79 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -53,7 +53,13 @@ SidebarDockingWindow::SidebarDockingWindow( SidebarDockingWindow::~SidebarDockingWindow() { + disposeOnce(); +} + +void SidebarDockingWindow::dispose() +{ DoDispose(); + SfxDockingWindow::dispose(); } void SidebarDockingWindow::DoDispose() diff --git a/sfx2/source/sidebar/SidebarDockingWindow.hxx b/sfx2/source/sidebar/SidebarDockingWindow.hxx index 47724b4d3520..fd45c691842d 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.hxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.hxx @@ -39,6 +39,7 @@ public: vcl::Window* pParent, WinBits nBits); virtual ~SidebarDockingWindow(); + virtual void dispose() SAL_OVERRIDE; virtual bool Close() SAL_OVERRIDE; diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index fbe51379f322..a7ec830687dd 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -67,7 +67,7 @@ SidebarPanelBase::SidebarPanelBase ( if (xMultiplexer.is()) xMultiplexer->addContextChangeEventListener(this, mxFrame->getController()); } - if (mpControl != NULL) + if (mpControl != nullptr) { mpControl->SetBackground(Theme::GetWallpaper(Theme::Paint_PanelBackground)); mpControl->Show(); @@ -81,11 +81,7 @@ SidebarPanelBase::~SidebarPanelBase() void SAL_CALL SidebarPanelBase::disposing() throw (css::uno::RuntimeException) { - if (mpControl != NULL) - { - delete mpControl; - mpControl = NULL; - } + mpControl.disposeAndClear(); if (mxFrame.is()) { @@ -104,7 +100,7 @@ void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( throw (css::uno::RuntimeException, std::exception) { IContextChangeReceiver* pContextChangeReceiver - = dynamic_cast<IContextChangeReceiver*>(mpControl); + = dynamic_cast<IContextChangeReceiver*>(mpControl.get()); if (pContextChangeReceiver != NULL) { const EnumContext aContext( @@ -161,7 +157,7 @@ Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessibl Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow() throw(css::uno::RuntimeException, std::exception) { - if (mpControl != NULL) + if (mpControl != nullptr) return Reference<awt::XWindow>( mpControl->GetComponentInterface(), UNO_QUERY); @@ -176,7 +172,7 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi return maLayoutSize; else { - ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl); + ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl.get()); if (isLayoutEnabled(mpControl)) { @@ -186,7 +182,7 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi } else if (pLayoutableWindow != NULL) return pLayoutableWindow->GetHeightForWidth(nWidth); - else if (mpControl != NULL) + else if (mpControl != nullptr) { const sal_Int32 nHeight (mpControl->GetSizePixel().Height()); return ui::LayoutSize(nHeight,nHeight,nHeight); diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index e1987fd8c9cc..af27f4757f07 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -57,6 +57,11 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSidebarToolBox(vcl::Wi SidebarToolBox::~SidebarToolBox() { + disposeOnce(); +} + +void SidebarToolBox::dispose() +{ ControllerContainer aControllers; aControllers.swap(maControllers); for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); @@ -76,7 +81,10 @@ SidebarToolBox::~SidebarToolBox() SetSelectHdl(Link()); SetActivateHdl(Link()); SetDeactivateHdl(Link()); + mbAreHandlersRegistered = false; } + + ToolBox::dispose(); } void SidebarToolBox::InsertItem(const OUString& rCommand, diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index 7f63755b5b82..08cbe7f602a6 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -64,6 +64,19 @@ TabBar::TabBar ( TabBar::~TabBar() { + disposeOnce(); +} + +void TabBar::dispose() +{ + for(ItemContainer::iterator + iItem(maItems.begin()), iEnd(maItems.end()); + iItem!=iEnd; + ++iItem) + iItem->mpButton.disposeAndClear(); + maItems.clear(); + mpMenuButton.disposeAndClear(); + vcl::Window::dispose(); } void TabBar::Paint (const Rectangle& rUpdateArea) @@ -94,7 +107,7 @@ void TabBar::SetDecks ( iItem!=iEnd; ++iItem) { - iItem->mpButton.reset(); + iItem->mpButton.disposeAndClear(); } maItems.clear(); } @@ -115,7 +128,8 @@ void TabBar::SetDecks ( Item& rItem (maItems[nIndex++]); rItem.msDeckId = pDescriptor->msId; - rItem.mpButton.reset(CreateTabItem(*pDescriptor)); + rItem.mpButton.disposeAndClear(); + rItem.mpButton = CreateTabItem(*pDescriptor); rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick)); rItem.maDeckActivationFunctor = maDeckActivationFunctor; rItem.mbIsHiddenByDefault = false; @@ -176,7 +190,7 @@ void TabBar::Layout() Theme::GetInteger(Theme::Int_TabItemHeight) * GetDPIScaleFactor()); // Place the menu button and the separator. - if (mpMenuButton != 0) + if (mpMenuButton != nullptr) { mpMenuButton->SetPosSizePixel( Point(nX,nY), @@ -245,12 +259,11 @@ bool TabBar::Notify (NotifyEvent&) return false; } -RadioButton* TabBar::CreateTabItem (const DeckDescriptor& rDeckDescriptor) +VclPtr<RadioButton> TabBar::CreateTabItem (const DeckDescriptor& rDeckDescriptor) { - RadioButton* pItem = ControlFactory::CreateTabItem(this); + VclPtr<RadioButton> pItem = ControlFactory::CreateTabItem(this); pItem->SetHelpText(rDeckDescriptor.msHelpText); pItem->SetQuickHelpText(rDeckDescriptor.msHelpText); - return pItem; } diff --git a/sfx2/source/sidebar/TabBar.hxx b/sfx2/source/sidebar/TabBar.hxx index a0c14ab0d4ff..523abb7ba726 100644 --- a/sfx2/source/sidebar/TabBar.hxx +++ b/sfx2/source/sidebar/TabBar.hxx @@ -68,6 +68,7 @@ public: const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor, const PopupMenuProvider& rPopupMenuProvider); virtual ~TabBar(); + virtual void dispose() SAL_OVERRIDE; virtual void Paint (const Rectangle& rUpdateArea) SAL_OVERRIDE; virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) SAL_OVERRIDE; @@ -93,12 +94,12 @@ public: private: css::uno::Reference<css::frame::XFrame> mxFrame; - ::boost::scoped_ptr<CheckBox> mpMenuButton; + VclPtr<CheckBox> mpMenuButton; class Item { public: DECL_LINK(HandleClick, Button*); - ::boost::shared_ptr<RadioButton> mpButton; + VclPtr<RadioButton> mpButton; ::rtl::OUString msDeckId; ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; bool mbIsHidden; @@ -110,7 +111,7 @@ private: sal_Int32 mnMenuSeparatorY; PopupMenuProvider maPopupMenuProvider; - RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor); + VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor); Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const; void Layout(); void UpdateButtonIcons(); diff --git a/sfx2/source/sidebar/TabItem.cxx b/sfx2/source/sidebar/TabItem.cxx index 476803bae488..678e1f0e80a8 100644 --- a/sfx2/source/sidebar/TabItem.cxx +++ b/sfx2/source/sidebar/TabItem.cxx @@ -42,10 +42,6 @@ TabItem::TabItem (vcl::Window* pParentWindow) #endif } -TabItem::~TabItem() -{ -} - void TabItem::Paint (const Rectangle& rUpdateArea) { switch(mePaintType) diff --git a/sfx2/source/sidebar/TabItem.hxx b/sfx2/source/sidebar/TabItem.hxx index 33fa016aceb3..818a38bbc402 100644 --- a/sfx2/source/sidebar/TabItem.hxx +++ b/sfx2/source/sidebar/TabItem.hxx @@ -34,7 +34,6 @@ class TabItem { public: TabItem (vcl::Window* pParentWindow); - virtual ~TabItem(); virtual void Paint (const Rectangle& rUpdateArea) SAL_OVERRIDE; virtual void MouseMove (const MouseEvent& rEvent) SAL_OVERRIDE; diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx index ff5687336811..f2647b386d6b 100644 --- a/sfx2/source/sidebar/TitleBar.cxx +++ b/sfx2/source/sidebar/TitleBar.cxx @@ -41,17 +41,24 @@ TitleBar::TitleBar ( vcl::Window* pParentWindow, const sidebar::Paint& rInitialBackgroundPaint) : Window(pParentWindow), - maToolBox(this), + maToolBox(VclPtr<SidebarToolBox>::Create(this)), msTitle(rsTitle), maIcon() { SetBackground(rInitialBackgroundPaint.GetWallpaper()); - maToolBox.SetSelectHdl(LINK(this, TitleBar, SelectionHandler)); + maToolBox->SetSelectHdl(LINK(this, TitleBar, SelectionHandler)); } TitleBar::~TitleBar() { + disposeOnce(); +} + +void TitleBar::dispose() +{ + maToolBox.disposeAndClear(); + vcl::Window::dispose(); } void TitleBar::SetTitle (const ::rtl::OUString& rsTitle) @@ -102,9 +109,9 @@ void TitleBar::setPosSizePixel ( Window::setPosSizePixel(nX,nY,nWidth,nHeight,nFlags); // Place the toolbox. - const sal_Int32 nToolBoxWidth (maToolBox.GetItemPosRect(0).GetWidth()); - maToolBox.setPosSizePixel(nWidth-nToolBoxWidth,0, nToolBoxWidth,nHeight, WINDOW_POSSIZE_POSSIZE); - maToolBox.Show(); + const sal_Int32 nToolBoxWidth (maToolBox->GetItemPosRect(0).GetWidth()); + maToolBox->setPosSizePixel(nWidth-nToolBoxWidth,0, nToolBoxWidth,nHeight, WINDOW_POSSIZE_POSSIZE); + maToolBox->Show(); } void TitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) @@ -181,8 +188,8 @@ void TitleBar::PaintFocus (const Rectangle& rFocusBox) IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox) { (void)pToolBox; - OSL_ASSERT(&maToolBox==pToolBox); - const sal_uInt16 nItemId (maToolBox.GetHighlightItemId()); + OSL_ASSERT(maToolBox.get()==pToolBox); + const sal_uInt16 nItemId (maToolBox->GetHighlightItemId()); HandleToolBoxItemClick(nItemId); diff --git a/sfx2/source/sidebar/TitleBar.hxx b/sfx2/source/sidebar/TitleBar.hxx index 735eca4e25a3..2bb36264202e 100644 --- a/sfx2/source/sidebar/TitleBar.hxx +++ b/sfx2/source/sidebar/TitleBar.hxx @@ -35,6 +35,7 @@ public: vcl::Window* pParentWindow, const sidebar::Paint& rInitialBackgroundPaint); virtual ~TitleBar(); + virtual void dispose() SAL_OVERRIDE; void SetTitle (const ::rtl::OUString& rsTitle); void SetIcon (const Image& rIcon); @@ -48,11 +49,11 @@ public: long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL) SAL_OVERRIDE; - ToolBox& GetToolBox() { return maToolBox;} - const ToolBox& GetToolBox() const { return maToolBox;} + ToolBox& GetToolBox() { return *maToolBox.get();} + const ToolBox& GetToolBox() const { return *maToolBox.get();} protected: - SidebarToolBox maToolBox; + VclPtr<SidebarToolBox> maToolBox; ::rtl::OUString msTitle; virtual Rectangle GetTitleArea (const Rectangle& rTitleBarBox) = 0; |