diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 11:41:31 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 15:08:48 +0100 |
commit | e8b97a52c96df9c8e8055407b1e40ed7cb9cfc67 (patch) | |
tree | b322529f4a54a6427862cb20cb4cf87fb6a5d065 /basctl | |
parent | 2b0be6c0e9d23f1b8535ba7033732ae2e3bfb5c9 (diff) | |
parent | 0cde74f788a054fa2b65107a030dd463b8d11c7a (diff) |
Merge remote-tracking branch 'origin/feature/vclptr'
Resolve several thousand lines of conflicts.
Conflicts:
accessibility/source/extended/accessiblelistbox.cxx
accessibility/source/standard/vclxaccessiblecombobox.cxx
accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
accessibility/source/standard/vclxaccessiblelistbox.cxx
accessibility/source/standard/vclxaccessibletextfield.cxx
basctl/source/basicide/basidesh.cxx
cui/source/inc/chardlg.hxx
cui/source/tabpages/tpbitmap.cxx
dbaccess/source/ui/dlg/UserAdmin.cxx
dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
extensions/source/propctrlr/propertyeditor.hxx
extensions/source/scanner/sanedlg.cxx
filter/source/pdf/impdialog.cxx
include/sfx2/mgetempl.hxx
include/sfx2/sidebar/SidebarToolBox.hxx
include/sfx2/viewsh.hxx
include/svtools/brwbox.hxx
include/svtools/filectrl.hxx
include/svtools/scrwin.hxx
include/svx/dlgctrl.hxx
include/svx/sidebar/Popup.hxx
include/svx/sidebar/PopupContainer.hxx
include/svx/sidebar/PopupControl.hxx
include/svx/sidebar/SidebarDialControl.hxx
include/svx/sidebar/ValueSetWithTextControl.hxx
sc/source/ui/condformat/condformatdlgentry.cxx
sc/source/ui/navipi/navipi.cxx
sc/source/ui/sidebar/CellBorderStyleControl.hxx
sd/source/ui/animations/CustomAnimationDialog.cxx
sd/source/ui/inc/DrawViewShell.hxx
sd/source/ui/inc/Ruler.hxx
sd/source/ui/inc/SlideSorter.hxx
sd/source/ui/inc/ViewTabBar.hxx
sd/source/ui/inc/Window.hxx
sd/source/ui/inc/morphdlg.hxx
sd/source/ui/inc/sdpreslt.hxx
sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
sd/source/ui/sidebar/LayoutMenu.hxx
sd/source/ui/sidebar/MasterPagesSelector.hxx
sd/source/ui/sidebar/NavigatorWrapper.hxx
sd/source/ui/sidebar/PanelBase.hxx
sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
sd/source/ui/sidebar/RecentMasterPagesSelector.hxx
sd/source/ui/slideshow/showwindow.hxx
sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
sd/source/ui/view/ViewShellBase.cxx
sd/source/ui/view/drviewsa.cxx
sfx2/source/appl/fileobj.hxx
sfx2/source/appl/opengrf.cxx
sfx2/source/control/thumbnailviewacc.hxx
sfx2/source/dialog/securitypage.cxx
sfx2/source/dialog/templdlg.cxx
sfx2/source/doc/docinsert.cxx
sfx2/source/doc/guisaveas.cxx
sfx2/source/inc/alienwarn.hxx
sfx2/source/sidebar/Deck.cxx
sfx2/source/sidebar/Deck.hxx
sfx2/source/sidebar/DeckTitleBar.cxx
sfx2/source/sidebar/DeckTitleBar.hxx
sfx2/source/sidebar/MenuButton.cxx
sfx2/source/sidebar/MenuButton.hxx
sfx2/source/sidebar/Panel.cxx
sfx2/source/sidebar/Panel.hxx
sfx2/source/sidebar/PanelTitleBar.hxx
sfx2/source/sidebar/SidebarDockingWindow.hxx
sfx2/source/sidebar/SidebarToolBox.cxx
sfx2/source/sidebar/TabBar.hxx
sfx2/source/sidebar/TabItem.cxx
sfx2/source/sidebar/TabItem.hxx
sfx2/source/sidebar/TitleBar.hxx
sfx2/source/toolbox/imgmgr.cxx
starmath/inc/edit.hxx
starmath/inc/smmod.hxx
starmath/qa/cppunit/test_starmath.cxx
starmath/source/edit.cxx
starmath/source/smmod.cxx
svtools/source/brwbox/brwbox1.cxx
svtools/source/brwbox/datwin.hxx
svtools/source/contnr/fileview.cxx
svtools/source/contnr/simptabl.cxx
svtools/source/control/filectrl.cxx
svtools/source/control/valueimp.hxx
svx/inc/GalleryControl.hxx
svx/source/dialog/dlgctrl.cxx
svx/source/dialog/swframeexample.cxx
svx/source/fmcomp/fmgridif.cxx
svx/source/gallery2/GalleryControl.cxx
svx/source/sidebar/EmptyPanel.hxx
svx/source/sidebar/area/AreaPropertyPanel.hxx
svx/source/sidebar/area/AreaTransparencyGradientControl.hxx
svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
svx/source/sidebar/insert/InsertPropertyPanel.cxx
svx/source/sidebar/insert/InsertPropertyPanel.hxx
svx/source/sidebar/line/LinePropertyPanel.hxx
svx/source/sidebar/line/LineWidthControl.cxx
svx/source/sidebar/line/LineWidthControl.hxx
svx/source/sidebar/line/LineWidthValueSet.hxx
svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
svx/source/sidebar/possize/SidebarDialControl.cxx
svx/source/sidebar/text/TextCharacterSpacingPopup.hxx
svx/source/sidebar/text/TextPropertyPanel.hxx
svx/source/sidebar/tools/PopupContainer.cxx
svx/source/sidebar/tools/PopupControl.cxx
svx/source/sidebar/tools/ValueSetWithTextControl.cxx
svx/source/svdraw/svdfmtf.hxx
svx/source/svdraw/svdibrow.cxx
svx/source/tbxctrls/colrctrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
sw/source/ui/dbui/mmaddressblockpage.cxx
sw/source/ui/dialog/uiregionsw.cxx
sw/source/ui/index/cnttab.cxx
sw/source/uibase/inc/drpcps.hxx
sw/source/uibase/sidebar/PageColumnControl.hxx
sw/source/uibase/sidebar/PageMarginControl.hxx
sw/source/uibase/sidebar/PageOrientationControl.hxx
sw/source/uibase/sidebar/PagePropertyPanel.hxx
sw/source/uibase/sidebar/PageSizeControl.hxx
sw/source/uibase/uiview/view2.cxx
sw/source/uibase/utlui/navipi.cxx
vcl/inc/svdata.hxx
vcl/source/control/combobox.cxx
vcl/source/control/lstbox.cxx
vcl/source/window/dockwin.cxx
vcl/source/window/winproc.cxx
Change-Id: I056cf3026ff17d65cca0b6e6588bda4a88fa8d95
Diffstat (limited to 'basctl')
44 files changed, 859 insertions, 495 deletions
diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx index 7f0388960c11..93302febee1d 100644 --- a/basctl/source/basicide/basdoc.cxx +++ b/basctl/source/basicide/basdoc.cxx @@ -51,7 +51,9 @@ DocShell::DocShell() } DocShell::~DocShell() -{ } +{ + pPrinter.disposeAndClear(); +} SfxPrinter* DocShell::GetPrinter( bool bCreate ) { @@ -66,7 +68,10 @@ SfxPrinter* DocShell::GetPrinter( bool bCreate ) void DocShell::SetPrinter( SfxPrinter* pPr ) { if (pPr != pPrinter.get()) + { + pPrinter.disposeAndClear(); pPrinter.reset(pPr); + } } void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, OUString*, OUString*, sal_Int32, bool bTemplate) const diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx index 5b6210d5dcab..083049ce073d 100644 --- a/basctl/source/basicide/basdoc.hxx +++ b/basctl/source/basicide/basdoc.hxx @@ -23,17 +23,16 @@ #include <iderid.hxx> #include <sfx2/docfac.hxx> #include <svx/ifaceids.hxx> - +#include <vcl/vclptr.hxx> +#include <sfx2/printer.hxx> #include <boost/scoped_ptr.hpp> -class SfxPrinter; - namespace basctl { class DocShell: public SfxObjectShell { - boost::scoped_ptr<SfxPrinter> pPrinter; + ScopedVclPtr<SfxPrinter> pPrinter; protected: virtual void Draw( OutputDevice *, const JobSetup & rSetup, diff --git a/basctl/source/basicide/basicbox.cxx b/basctl/source/basicide/basicbox.cxx index d4cbae63aa88..a774c1bd796d 100644 --- a/basctl/source/basicide/basicbox.cxx +++ b/basctl/source/basicide/basicbox.cxx @@ -46,12 +46,6 @@ LibBoxControl::LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx -LibBoxControl::~LibBoxControl() -{ -} - - - void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) { LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId())); @@ -71,9 +65,9 @@ void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPool -vcl::Window* LibBoxControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> LibBoxControl::CreateItemWindow( vcl::Window *pParent ) { - return new LibBox( pParent, m_xFrame ); + return VclPtr<LibBox>::Create( pParent, m_xFrame ); } @@ -88,7 +82,13 @@ DocListenerBox::DocListenerBox( vcl::Window* pParent ) DocListenerBox::~DocListenerBox() { + disposeOnce(); +} + +void DocListenerBox::dispose() +{ m_aNotifier.dispose(); + ListBox::dispose(); } void DocListenerBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) @@ -156,7 +156,13 @@ LibBox::LibBox( vcl::Window* pParent, const uno::Reference< frame::XFrame >& rFr LibBox::~LibBox() { + disposeOnce(); +} + +void LibBox::dispose() +{ ClearBox(); + DocListenerBox::dispose(); } void LibBox::Update( const SfxStringItem* pItem ) @@ -341,10 +347,6 @@ LanguageBoxControl::LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, Tool { } -LanguageBoxControl::~LanguageBoxControl() -{ -} - void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, const SfxPoolItem* pItem ) { (void)nID; @@ -360,9 +362,9 @@ void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, cons } } -vcl::Window* LanguageBoxControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> LanguageBoxControl::CreateItemWindow( vcl::Window *pParent ) { - return new LanguageBox( pParent ); + return VclPtr<LanguageBox>::Create( pParent ); } // class basctl::LanguageBox ----------------------------------------------- @@ -384,7 +386,13 @@ LanguageBox::LanguageBox( vcl::Window* pParent ) : LanguageBox::~LanguageBox() { + disposeOnce(); +} + +void LanguageBox::dispose() +{ ClearBox(); + DocListenerBox::dispose(); } void LanguageBox::FillBox() diff --git a/basctl/source/basicide/basicbox.hxx b/basctl/source/basicide/basicbox.hxx index f6d31703f7d1..3e4cc8045f04 100644 --- a/basctl/source/basicide/basicbox.hxx +++ b/basctl/source/basicide/basicbox.hxx @@ -33,11 +33,10 @@ public: SFX_DECL_TOOLBOX_CONTROL(); LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - virtual ~LibBoxControl(); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE; - virtual vcl::Window* CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; + virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; }; /** base class for list boxes which need to update their content according to the list @@ -49,6 +48,7 @@ class DocListenerBox :public ListBox protected: DocListenerBox( vcl::Window* pParent ); virtual ~DocListenerBox(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void FillBox() = 0; @@ -95,7 +95,8 @@ protected: public: LibBox( vcl::Window* pParent, const com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); - virtual ~LibBox(); + virtual ~LibBox(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; void Update( const SfxStringItem* pItem ); @@ -107,10 +108,9 @@ public: SFX_DECL_TOOLBOX_CONTROL(); LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - virtual ~LanguageBoxControl(); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE; - virtual vcl::Window* CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; + virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; }; class LanguageBox : public DocListenerBox @@ -135,6 +135,7 @@ protected: public: LanguageBox( vcl::Window* pParent ); virtual ~LanguageBox(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; void Update( const SfxStringItem* pItem ); diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx index ee5ed4bef958..72814178984b 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -77,17 +77,17 @@ Renderable::~Renderable() { } -Printer* Renderable::getPrinter() +VclPtr< Printer > Renderable::getPrinter() { - Printer* pPrinter = NULL; + VclPtr< Printer > pPrinter; Any aValue( getValue( "RenderDevice" ) ); Reference<awt::XDevice> xRenderDevice; if( aValue >>= xRenderDevice ) { VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice); - OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL; - pPrinter = dynamic_cast<Printer*>(pOut); + VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >(); + pPrinter = dynamic_cast<Printer*>(pOut.get()); } return pPrinter; } diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx index f91a5ef8a9d3..dd60f1653b03 100644 --- a/basctl/source/basicide/basicrenderable.hxx +++ b/basctl/source/basicide/basicrenderable.hxx @@ -33,10 +33,10 @@ class Renderable : public cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >, public vcl::PrinterOptionsHelper { - BaseWindow* mpWindow; + VclPtr<BaseWindow> mpWindow; osl::Mutex maMutex; - Printer* getPrinter(); + VclPtr<Printer> getPrinter(); public: Renderable (BaseWindow*); virtual ~Renderable(); diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 1c11bb11a24d..f6e491a03abe 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -192,10 +192,10 @@ ModulWindow::ModulWindow ( BaseWindow(pParent, rDocument, aLibName, aName), rLayout(*pParent), nValid(ValidWindow), - aXEditorWindow(this), + aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this)), m_aModule(aModule) { - aXEditorWindow.Show(); + aXEditorWindow->Show(); SetBackground(); } @@ -227,9 +227,15 @@ SbModuleRef ModulWindow::XModule() ModulWindow::~ModulWindow() { - nValid = 0; + disposeOnce(); +} +void ModulWindow::dispose() +{ + nValid = 0; StarBASIC::Stop(); + aXEditorWindow.disposeAndClear(); + BaseWindow::dispose(); } @@ -237,7 +243,7 @@ void ModulWindow::GetFocus() { if (nValid != ValidWindow) return; - aXEditorWindow.GetEdtWindow().GrabFocus(); + aXEditorWindow->GetEdtWindow().GrabFocus(); // don't call basic calls because focus is somewhere else... } @@ -256,7 +262,7 @@ void ModulWindow::Paint( const Rectangle& ) void ModulWindow::Resize() { - aXEditorWindow.SetPosSizePixel( Point( 0, 0 ), + aXEditorWindow->SetPosSizePixel( Point( 0, 0 ), Size( GetOutputSizePixel() ) ); } @@ -580,7 +586,7 @@ bool ModulWindow::BasicToggleBreakPoint() bNewBreakPoint = true; } - aXEditorWindow.GetBrkWindow().Invalidate(); + aXEditorWindow->GetBrkWindow().Invalidate(); return bNewBreakPoint; } @@ -613,8 +619,8 @@ void ModulWindow::BasicToggleBreakPointEnabled() void ModulWindow::ManageBreakPoints() { BreakPointWindow& rBrkWin = GetBreakPointWindow(); - BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( &rBrkWin, GetBreakPoints() ); + aBrkDlg->Execute(); rBrkWin.Invalidate(); } @@ -638,7 +644,7 @@ bool ModulWindow::BasicErrorHdl( StarBASIC * pBasic ) // if other basic, the IDE should try to display the correct module bool const bMarkError = pBasic == GetBasic(); if ( bMarkError ) - aXEditorWindow.GetBrkWindow().SetMarkerPos(nErrorLine, true); + aXEditorWindow->GetBrkWindow().SetMarkerPos(nErrorLine, true); // #i47002# Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this ); @@ -651,7 +657,7 @@ bool ModulWindow::BasicErrorHdl( StarBASIC * pBasic ) return false; if ( bMarkError ) - aXEditorWindow.GetBrkWindow().SetNoMarker(); + aXEditorWindow->GetBrkWindow().SetNoMarker(); return false; } @@ -676,7 +682,7 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic ) AssertValidEditEngine(); GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) ); - aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine ); + aXEditorWindow->GetBrkWindow().SetMarkerPos( nErrorLine ); rLayout.UpdateDebug(false); @@ -691,7 +697,7 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic ) Application::Yield(); aStatus.bIsInReschedule = false; - aXEditorWindow.GetBrkWindow().SetNoMarker(); + aXEditorWindow->GetBrkWindow().SetNoMarker(); ClearStatus( BASWIN_INRESCHEDULE ); @@ -1022,7 +1028,7 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) { SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false); bSourceLinesEnabled = pItem && pItem->GetValue(); - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); } break; case SID_BASICIDE_DELETECURRENT: @@ -1037,9 +1043,9 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) break; case SID_GOTOLINE: { - GotoLineDialog aGotoDlg(this); - if (aGotoDlg.Execute()) - if (sal_Int32 const nLine = aGotoDlg.GetLineNumber()) + ScopedVclPtrInstance< GotoLineDialog > aGotoDlg(this); + if (aGotoDlg->Execute()) + if (sal_Int32 const nLine = aGotoDlg->GetLineNumber()) { TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0)); GetEditView()->SetSelection(aSel); @@ -1236,7 +1242,7 @@ void ModulWindow::AssertValidEditEngine() void ModulWindow::Activating () { - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); Show(); } @@ -1420,7 +1426,7 @@ bool ModulWindow::IsPasteAllowed() void ModulWindow::OnNewDocument () { - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); } char const* ModulWindow::GetHid () const @@ -1464,15 +1470,28 @@ void ModulWindow::UpdateModule () ModulWindowLayout::ModulWindowLayout (vcl::Window* pParent, ObjectCatalog& rObjectCatalog_) : Layout(pParent), pChild(0), - aWatchWindow(this), - aStackWindow(this), + aWatchWindow(VclPtr<WatchWindow>::Create(this)), + aStackWindow(VclPtr<StackWindow>::Create(this)), rObjectCatalog(rObjectCatalog_) { } +ModulWindowLayout::~ModulWindowLayout() +{ + disposeOnce(); +} + +void ModulWindowLayout::dispose() +{ + aWatchWindow.disposeAndClear(); + aStackWindow.disposeAndClear(); + pChild.clear(); + Layout::dispose(); +} + void ModulWindowLayout::UpdateDebug (bool bBasicStopped) { - aWatchWindow.UpdateWatches(bBasicStopped); - aStackWindow.UpdateCalls(); + aWatchWindow->UpdateWatches(bBasicStopped); + aStackWindow->UpdateCalls(); } void ModulWindowLayout::Paint (Rectangle const&) @@ -1493,8 +1512,8 @@ void ModulWindowLayout::Activating (BaseWindow& rChild) { assert(dynamic_cast<ModulWindow*>(&rChild)); pChild = &static_cast<ModulWindow&>(rChild); - aWatchWindow.Show(); - aStackWindow.Show(); + aWatchWindow->Show(); + aStackWindow->Show(); rObjectCatalog.Show(); rObjectCatalog.SetLayoutWindow(this); rObjectCatalog.UpdateEntries(); @@ -1506,8 +1525,8 @@ void ModulWindowLayout::Deactivating () { aSyntaxColors.SetActiveEditor(0); Layout::Deactivating(); - aWatchWindow.Hide(); - aStackWindow.Hide(); + aWatchWindow->Hide(); + aStackWindow->Hide(); rObjectCatalog.Hide(); pChild = 0; } @@ -1528,19 +1547,19 @@ void ModulWindowLayout::GetState (SfxItemSet &rSet, unsigned nWhich) void ModulWindowLayout::BasicAddWatch (OUString const& rWatchStr) { - aWatchWindow.AddWatch(rWatchStr); + aWatchWindow->AddWatch(rWatchStr); } void ModulWindowLayout::BasicRemoveWatch () { - aWatchWindow.RemoveSelectedWatch(); + aWatchWindow->RemoveSelectedWatch(); } void ModulWindowLayout::OnFirstSize (long const nWidth, long const nHeight) { AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75)); - AddToBottom(&aWatchWindow, Size(nWidth * 0.67, nHeight * 0.25)); - AddToBottom(&aStackWindow, Size(nWidth * 0.33, nHeight * 0.25)); + AddToBottom(aWatchWindow.get(), Size(nWidth * 0.67, nHeight * 0.25)); + AddToBottom(aStackWindow.get(), Size(nWidth * 0.33, nHeight * 0.25)); } diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index a5c3b91fc29e..2d5afed4fb17 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -109,7 +109,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) SAL_OVERRIDE; CodeCompleteDataCache aCodeCompleteCache; - boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd; + VclPtr<CodeCompleteWindow> pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number void SetupAndShowCodeCompleteWnd(const std::vector< OUString >& aEntryVect, TextSelection aSel ); void HandleAutoCorrect(); @@ -137,6 +137,7 @@ protected: public: EditorWindow (vcl::Window* pParent, ModulWindow*); virtual ~EditorWindow(); + virtual void dispose() SAL_OVERRIDE; ExtTextEngine* GetEditEngine() const { return pEditEngine.get(); } ExtTextView* GetEditView() const { return pEditView.get(); } @@ -186,7 +187,6 @@ protected: public: BreakPointWindow (vcl::Window* pParent, ModulWindow*); - virtual ~BreakPointWindow(); void SetMarkerPos( sal_uInt16 nLine, bool bErrorMarker = false ); void SetNoMarker (); @@ -211,6 +211,7 @@ protected: public: WatchTreeListBox( vcl::Window* pParent, WinBits nWinBits ); virtual ~WatchTreeListBox(); + virtual void dispose() SAL_OVERRIDE; void RequestingChildren( SvTreeListEntry * pParent ) SAL_OVERRIDE; void UpdateWatches( bool bBasicStopped = false ); @@ -225,10 +226,10 @@ class WatchWindow : public DockingWindow { private: OUString aWatchStr; - ExtendedEdit aXEdit; - ImageButton aRemoveWatchButton; - WatchTreeListBox aTreeListBox; - HeaderBar aHeaderBar; + VclPtr<ExtendedEdit> aXEdit; + VclPtr<ImageButton> aRemoveWatchButton; + VclPtr<WatchTreeListBox> aTreeListBox; + VclPtr<HeaderBar> aHeaderBar; protected: virtual void Resize() SAL_OVERRIDE; @@ -243,20 +244,21 @@ protected: public: WatchWindow (Layout* pParent); virtual ~WatchWindow(); + virtual void dispose() SAL_OVERRIDE; void AddWatch( const OUString& rVName ); bool RemoveSelectedWatch(); void UpdateWatches( bool bBasicStopped = false ); - WatchTreeListBox& GetWatchTreeListBox() { return aTreeListBox; } + WatchTreeListBox& GetWatchTreeListBox() { return *aTreeListBox.get(); } }; class StackWindow : public DockingWindow { private: - SvTreeListBox aTreeListBox; - OUString aStackStr; + VclPtr<SvTreeListBox> aTreeListBox; + OUString aStackStr; protected: virtual void Resize() SAL_OVERRIDE; @@ -265,6 +267,7 @@ protected: public: StackWindow (Layout* pParent); virtual ~StackWindow(); + virtual void dispose() SAL_OVERRIDE; void UpdateCalls(); }; @@ -273,10 +276,10 @@ public: class ComplexEditorWindow : public vcl::Window { private: - BreakPointWindow aBrkWindow; - LineNumberWindow aLineNumberWindow; - EditorWindow aEdtWindow; - ScrollBar aEWVScrollBar; + VclPtr<BreakPointWindow> aBrkWindow; + VclPtr<LineNumberWindow> aLineNumberWindow; + VclPtr<EditorWindow> aEdtWindow; + VclPtr<ScrollBar> aEWVScrollBar; virtual void DataChanged(DataChangedEvent const & rDCEvt) SAL_OVERRIDE; @@ -286,11 +289,12 @@ protected: public: ComplexEditorWindow( ModulWindow* pParent ); - - BreakPointWindow& GetBrkWindow() { return aBrkWindow; } - LineNumberWindow& GetLineNumberWindow() { return aLineNumberWindow; } - EditorWindow& GetEdtWindow() { return aEdtWindow; } - ScrollBar& GetEWVScrollBar() { return aEWVScrollBar; } + virtual ~ComplexEditorWindow(); + virtual void dispose() SAL_OVERRIDE; + BreakPointWindow& GetBrkWindow() { return *aBrkWindow.get(); } + LineNumberWindow& GetLineNumberWindow() { return *aLineNumberWindow.get(); } + EditorWindow& GetEdtWindow() { return *aEdtWindow.get(); } + ScrollBar& GetEWVScrollBar() { return *aEWVScrollBar.get(); } void SetLineNumberDisplay(bool b); }; @@ -302,7 +306,7 @@ private: ModulWindowLayout& rLayout; StarBASICRef xBasic; short nValid; - ComplexEditorWindow aXEditorWindow; + VclPtr<ComplexEditorWindow> aXEditorWindow; BasicStatus aStatus; SbModuleRef xModule; OUString aCurPath; @@ -328,6 +332,7 @@ public: ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString& aModule ); virtual ~ModulWindow(); + virtual void dispose() SAL_OVERRIDE; virtual void ExecuteCommand (SfxRequest& rReq) SAL_OVERRIDE; virtual void ExecuteGlobal (SfxRequest& rReq) SAL_OVERRIDE; @@ -386,10 +391,10 @@ public: virtual SearchOptionFlags GetSearchOptions() SAL_OVERRIDE; virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false) SAL_OVERRIDE; - EditorWindow& GetEditorWindow() { return aXEditorWindow.GetEdtWindow(); } - BreakPointWindow& GetBreakPointWindow() { return aXEditorWindow.GetBrkWindow(); } - LineNumberWindow& GetLineNumberWindow() { return aXEditorWindow.GetLineNumberWindow(); } - ScrollBar& GetEditVScrollBar() { return aXEditorWindow.GetEWVScrollBar(); } + EditorWindow& GetEditorWindow() { return aXEditorWindow->GetEdtWindow(); } + BreakPointWindow& GetBreakPointWindow() { return aXEditorWindow->GetBrkWindow(); } + LineNumberWindow& GetLineNumberWindow() { return aXEditorWindow->GetLineNumberWindow(); } + ScrollBar& GetEditVScrollBar() { return aXEditorWindow->GetEWVScrollBar(); } ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); } ExtTextView* GetEditView() { return GetEditorWindow().GetEditView(); } BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); } @@ -419,6 +424,8 @@ class ModulWindowLayout: public Layout { public: ModulWindowLayout (vcl::Window* pParent, ObjectCatalog&); + virtual ~ModulWindowLayout(); + virtual void dispose() SAL_OVERRIDE; public: // Layout: virtual void Activating (BaseWindow&) SAL_OVERRIDE; @@ -438,10 +445,10 @@ protected: private: // main child window - ModulWindow* pChild; + VclPtr<ModulWindow> pChild; // dockable windows - WatchWindow aWatchWindow; - StackWindow aStackWindow; + VclPtr<WatchWindow> aWatchWindow; + VclPtr<StackWindow> aStackWindow; ObjectCatalog& rObjectCatalog; private: virtual void DataChanged (DataChangedEvent const& rDCEvt) SAL_OVERRIDE; @@ -468,7 +475,7 @@ private: // the configuration svtools::ColorConfig aConfig; // the active editor - EditorWindow* pEditor; + VclPtr<EditorWindow> pEditor; } aSyntaxColors; }; @@ -482,7 +489,7 @@ private: /* a buffer to build up function name when typing * a function name, used for showing/hiding listbox values * */ - CodeCompleteWindow* pCodeCompleteWindow; // parent window + VclPtr<CodeCompleteWindow> pCodeCompleteWindow; // parent window void SetMatchingEntries(); // sets the visible entries based on aFuncBuffer variable void HideAndRestoreFocus(); @@ -490,6 +497,8 @@ private: public: CodeCompleteListBox( CodeCompleteWindow* pPar ); + virtual ~CodeCompleteListBox(); + virtual void dispose() SAL_OVERRIDE; void InsertSelectedEntry(); //insert the selected entry DECL_LINK(ImplDoubleClickHdl, void*); @@ -503,15 +512,16 @@ class CodeCompleteWindow: public vcl::Window { friend class CodeCompleteListBox; private: - EditorWindow* pParent; // parent window + VclPtr<EditorWindow> pParent; // parent window TextSelection aTextSelection; - CodeCompleteListBox* pListBox; + VclPtr<CodeCompleteListBox> pListBox; void InitListBox(); // initialize the ListBox public: CodeCompleteWindow( EditorWindow* pPar ); - virtual ~CodeCompleteWindow(){ delete pListBox; } + virtual ~CodeCompleteWindow(); + virtual void dispose() SAL_OVERRIDE; void InsertEntry( const OUString& aStr ); void ClearListBox(); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 46796215108f..fbf4da6470bf 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -227,7 +227,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : bHighlightning(false), bDoSyntaxHighlight(true), bDelayHighlight(true), - pCodeCompleteWnd(new CodeCompleteWindow(this)) + pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this)) { SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); SetPointer( Pointer( POINTER_TEXT ) ); @@ -250,6 +250,11 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : EditorWindow::~EditorWindow() { + disposeOnce(); +} + +void EditorWindow::dispose() +{ Reference< beans::XMultiPropertySet > n; { osl::MutexGuard g(mutex_); @@ -266,6 +271,8 @@ EditorWindow::~EditorWindow() EndListening( *pEditEngine ); pEditEngine->RemoveView(pEditView.get()); } + pCodeCompleteWnd.disposeAndClear(); + vcl::Window::dispose(); } OUString EditorWindow::GetWordAtCursor() @@ -1376,12 +1383,6 @@ BreakPointWindow::BreakPointWindow (vcl::Window* pParent, ModulWindow* pModulWin SetHelpId(HID_BASICIDE_BREAKPOINTWINDOW); } -BreakPointWindow::~BreakPointWindow() -{ -} - - - void BreakPointWindow::Paint( const Rectangle& ) { if ( SyncYOffset() ) @@ -1519,9 +1520,9 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt ) break; case RID_BRKPROPS: { - BreakPointDialog aBrkDlg( this, GetBreakPoints() ); - aBrkDlg.SetCurrentBreakPoint( pBrk ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( this, GetBreakPoints() ); + aBrkDlg->SetCurrentBreakPoint( pBrk ); + aBrkDlg->Execute(); Invalidate(); } break; @@ -1534,8 +1535,8 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt ) { case RID_BRKDLG: { - BreakPointDialog aBrkDlg( this, GetBreakPoints() ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( this, GetBreakPoints() ); + aBrkDlg->Execute(); Invalidate(); } break; @@ -1598,69 +1599,69 @@ namespace WatchWindow::WatchWindow (Layout* pParent) : DockingWindow(pParent), aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ), - aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ), - aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ), - aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP - | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ), - aHeaderBar( this, WB_BUTTONSTYLE | WB_BORDER ) + aXEdit( VclPtr<ExtendedEdit>::Create(this, IDEResId( RID_EDT_WATCHEDIT )) ), + aRemoveWatchButton( VclPtr<ImageButton>::Create(this, IDEResId( RID_IMGBTN_REMOVEWATCH )) ), + aTreeListBox( VclPtr<WatchTreeListBox>::Create(this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP + | WB_HASLINESATROOT | WB_HASBUTTONSATROOT) ), + aHeaderBar( VclPtr<HeaderBar>::Create( this, WB_BUTTONSTYLE | WB_BORDER ) ) { - aXEdit.SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); - aTreeListBox.SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); + aXEdit->SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); + aTreeListBox->SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); long nTextLen = GetTextWidth( aWatchStr ) + DWBORDER + 3; - aXEdit.SetPosPixel( Point( nTextLen, 3 ) ); - aXEdit.SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) ); - aXEdit.GetAccelerator().InsertItem( 1, vcl::KeyCode( KEY_RETURN ) ); - aXEdit.GetAccelerator().InsertItem( 2, vcl::KeyCode( KEY_ESCAPE ) ); - aXEdit.Show(); - - aRemoveWatchButton.Disable(); - aRemoveWatchButton.SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) ); - aRemoveWatchButton.SetPosPixel( Point( nTextLen + aXEdit.GetSizePixel().Width() + 4, 2 ) ); - Size aSz( aRemoveWatchButton.GetModeImage().GetSizePixel() ); + aXEdit->SetPosPixel( Point( nTextLen, 3 ) ); + aXEdit->SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) ); + aXEdit->GetAccelerator().InsertItem( 1, vcl::KeyCode( KEY_RETURN ) ); + aXEdit->GetAccelerator().InsertItem( 2, vcl::KeyCode( KEY_ESCAPE ) ); + aXEdit->Show(); + + aRemoveWatchButton->Disable(); + aRemoveWatchButton->SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) ); + aRemoveWatchButton->SetPosPixel( Point( nTextLen + aXEdit->GetSizePixel().Width() + 4, 2 ) ); + Size aSz( aRemoveWatchButton->GetModeImage().GetSizePixel() ); aSz.Width() += 6; aSz.Height() += 6; - aRemoveWatchButton.SetSizePixel( aSz ); - aRemoveWatchButton.Show(); + aRemoveWatchButton->SetSizePixel( aSz ); + aRemoveWatchButton->Show(); - long nRWBtnSize = aRemoveWatchButton.GetModeImage().GetSizePixel().Height() + 10; - nVirtToolBoxHeight = aXEdit.GetSizePixel().Height() + 7; + long nRWBtnSize = aRemoveWatchButton->GetModeImage().GetSizePixel().Height() + 10; + nVirtToolBoxHeight = aXEdit->GetSizePixel().Height() + 7; if ( nRWBtnSize > nVirtToolBoxHeight ) nVirtToolBoxHeight = nRWBtnSize; nHeaderBarHeight = 16; - aTreeListBox.SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST); - aTreeListBox.EnableInplaceEditing(true); - aTreeListBox.SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) ); - aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) ); - aTreeListBox.SetHighlightRange( 1, 5 ); + aTreeListBox->SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST); + aTreeListBox->EnableInplaceEditing(true); + aTreeListBox->SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) ); + aTreeListBox->SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) ); + aTreeListBox->SetHighlightRange( 1, 5 ); Point aPnt( DWBORDER, nVirtToolBoxHeight + 1 ); - aHeaderBar.SetPosPixel( aPnt ); - aHeaderBar.SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) ); + aHeaderBar->SetPosPixel( aPnt ); + aHeaderBar->SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) ); long nVarTabWidth = 220; long nValueTabWidth = 100; long nTypeTabWidth = 1250; - aHeaderBar.InsertItem( ITEM_ID_VARIABLE, IDEResId(RID_STR_WATCHVARIABLE).toString(), nVarTabWidth ); - aHeaderBar.InsertItem( ITEM_ID_VALUE, IDEResId(RID_STR_WATCHVALUE).toString(), nValueTabWidth ); - aHeaderBar.InsertItem( ITEM_ID_TYPE, IDEResId(RID_STR_WATCHTYPE).toString(), nTypeTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_VARIABLE, IDEResId(RID_STR_WATCHVARIABLE).toString(), nVarTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_VALUE, IDEResId(RID_STR_WATCHVALUE).toString(), nValueTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_TYPE, IDEResId(RID_STR_WATCHTYPE).toString(), nTypeTabWidth ); long tabs[ 4 ]; tabs[ 0 ] = 3; // two tabs tabs[ 1 ] = 0; tabs[ 2 ] = nVarTabWidth; tabs[ 3 ] = nVarTabWidth + nValueTabWidth; - aTreeListBox.SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL ); - aTreeListBox.InitHeaderBar( &aHeaderBar ); + aTreeListBox->SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL ); + aTreeListBox->InitHeaderBar( aHeaderBar.get() ); - aTreeListBox.SetNodeDefaultImages( ); + aTreeListBox->SetNodeDefaultImages( ); - aHeaderBar.Show(); + aHeaderBar->Show(); - aTreeListBox.Show(); + aTreeListBox->Show(); SetText(IDEResId(RID_STR_WATCHNAME).toString()); @@ -1674,7 +1675,18 @@ WatchWindow::WatchWindow (Layout* pParent) : WatchWindow::~WatchWindow() { - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + disposeOnce(); +} + +void WatchWindow::dispose() +{ + aXEdit.disposeAndClear(); + aRemoveWatchButton.disposeAndClear(); + aHeaderBar.disposeAndClear(); + aTreeListBox.disposeAndClear(); + if (!IsDisposed()) + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + DockingWindow::dispose(); } @@ -1698,11 +1710,11 @@ void WatchWindow::Resize() aBoxSz.Height() = 0; aBoxSz.Height() -= nHeaderBarHeight; - aTreeListBox.SetSizePixel( aBoxSz ); - aTreeListBox.GetHScroll()->SetPageSize( aTreeListBox.GetHScroll()->GetVisibleSize() ); + aTreeListBox->SetSizePixel( aBoxSz ); + aTreeListBox->GetHScroll()->SetPageSize( aTreeListBox->GetHScroll()->GetVisibleSize() ); aBoxSz.Height() = nHeaderBarHeight; - aHeaderBar.SetSizePixel( aBoxSz ); + aHeaderBar->SetSizePixel( aBoxSz ); Invalidate(); } @@ -1766,29 +1778,29 @@ void WatchWindow::AddWatch( const OUString& rVName ) OUString aWatchStr_( aVar ); aWatchStr_ += "\t\t"; - SvTreeListEntry* pNewEntry = aTreeListBox.InsertEntry( aWatchStr_, 0, true, TREELIST_APPEND ); + SvTreeListEntry* pNewEntry = aTreeListBox->InsertEntry( aWatchStr_, 0, true, TREELIST_APPEND ); pNewEntry->SetUserData( pWatchItem ); - aTreeListBox.Select(pNewEntry, true); - aTreeListBox.MakeVisible(pNewEntry); - aRemoveWatchButton.Enable(); + aTreeListBox->Select(pNewEntry, true); + aTreeListBox->MakeVisible(pNewEntry); + aRemoveWatchButton->Enable(); UpdateWatches(); } bool WatchWindow::RemoveSelectedWatch() { - SvTreeListEntry* pEntry = aTreeListBox.GetCurEntry(); + SvTreeListEntry* pEntry = aTreeListBox->GetCurEntry(); if ( pEntry ) { - aTreeListBox.GetModel()->Remove( pEntry ); - pEntry = aTreeListBox.GetCurEntry(); + aTreeListBox->GetModel()->Remove( pEntry ); + pEntry = aTreeListBox->GetCurEntry(); if ( pEntry ) - aXEdit.SetText( static_cast<WatchItem*>(pEntry->GetUserData())->maName ); + aXEdit->SetText( static_cast<WatchItem*>(pEntry->GetUserData())->maName ); else - aXEdit.SetText( OUString() ); - if ( !aTreeListBox.GetEntryCount() ) - aRemoveWatchButton.Disable(); + aXEdit->SetText( OUString() ); + if ( !aTreeListBox->GetEntryCount() ) + aRemoveWatchButton->Disable(); return true; } else @@ -1798,7 +1810,7 @@ bool WatchWindow::RemoveSelectedWatch() IMPL_LINK_INLINE_START( WatchWindow, ButtonHdl, ImageButton *, pButton ) { - if (pButton == &aRemoveWatchButton) + if (pButton == aRemoveWatchButton.get()) if (SfxDispatcher* pDispatcher = GetDispatcher()) pDispatcher->Execute(SID_BASICIDE_REMOVEWATCH); return 0; @@ -1809,9 +1821,9 @@ IMPL_LINK_INLINE_END( WatchWindow, ButtonHdl, ImageButton *, pButton ) IMPL_LINK_NOARG_INLINE_START(WatchWindow, TreeListHdl) { - SvTreeListEntry* pCurEntry = aTreeListBox.GetCurEntry(); + SvTreeListEntry* pCurEntry = aTreeListBox->GetCurEntry(); if ( pCurEntry && pCurEntry->GetUserData() ) - aXEdit.SetText( static_cast<WatchItem*>(pCurEntry->GetUserData())->maName ); + aXEdit->SetText( static_cast<WatchItem*>(pCurEntry->GetUserData())->maName ); return 0; } @@ -1824,29 +1836,29 @@ IMPL_LINK_INLINE_START( WatchWindow, implEndDragHdl, HeaderBar *, pBar ) const sal_Int32 TAB_WIDTH_MIN = 10; sal_Int32 nMaxWidth = - aHeaderBar.GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN; + aHeaderBar->GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN; - sal_Int32 nVariableWith = aHeaderBar.GetItemSize( ITEM_ID_VARIABLE ); + sal_Int32 nVariableWith = aHeaderBar->GetItemSize( ITEM_ID_VARIABLE ); if( nVariableWith < TAB_WIDTH_MIN ) - aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN ); + aHeaderBar->SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN ); else if( nVariableWith > nMaxWidth ) - aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, nMaxWidth ); + aHeaderBar->SetItemSize( ITEM_ID_VARIABLE, nMaxWidth ); - sal_Int32 nValueWith = aHeaderBar.GetItemSize( ITEM_ID_VALUE ); + sal_Int32 nValueWith = aHeaderBar->GetItemSize( ITEM_ID_VALUE ); if( nValueWith < TAB_WIDTH_MIN ) - aHeaderBar.SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN ); + aHeaderBar->SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN ); else if( nValueWith > nMaxWidth ) - aHeaderBar.SetItemSize( ITEM_ID_VALUE, nMaxWidth ); + aHeaderBar->SetItemSize( ITEM_ID_VALUE, nMaxWidth ); - if (aHeaderBar.GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN) - aHeaderBar.SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN ); + if (aHeaderBar->GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN) + aHeaderBar->SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN ); sal_Int32 nPos = 0; - sal_uInt16 nTabs = aHeaderBar.GetItemCount(); + sal_uInt16 nTabs = aHeaderBar->GetItemCount(); for( sal_uInt16 i = 1 ; i < nTabs ; ++i ) { - nPos += aHeaderBar.GetItemSize( i ); - aTreeListBox.SetTab( i, nPos, MAP_PIXEL ); + nPos += aHeaderBar->GetItemSize( i ); + aTreeListBox->SetTab( i, nPos, MAP_PIXEL ); } return 0; } @@ -1859,17 +1871,17 @@ IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc ) { case KEY_RETURN: { - OUString aCurText( aXEdit.GetText() ); + OUString aCurText( aXEdit->GetText() ); if ( !aCurText.isEmpty() ) { AddWatch( aCurText ); - aXEdit.SetSelection( Selection( 0, 0xFFFF ) ); + aXEdit->SetSelection( Selection( 0, 0xFFFF ) ); } } break; case KEY_ESCAPE: { - aXEdit.SetText( OUString() ); + aXEdit->SetText( OUString() ); } break; } @@ -1879,7 +1891,7 @@ IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc ) void WatchWindow::UpdateWatches( bool bBasicStopped ) { - aTreeListBox.UpdateWatches( bBasicStopped ); + aTreeListBox->UpdateWatches( bBasicStopped ); } @@ -1890,16 +1902,16 @@ void WatchWindow::UpdateWatches( bool bBasicStopped ) StackWindow::StackWindow (Layout* pParent) : DockingWindow(pParent), - aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ), + aTreeListBox( VclPtr<SvTreeListBox>::Create(this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP) ), aStackStr( IDEResId( RID_STR_STACK ) ) { - aTreeListBox.SetHelpId(HID_BASICIDE_STACKWINDOW_LIST); - aTreeListBox.SetAccessibleName(IDEResId(RID_STR_STACKNAME).toString()); - aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) ); - aTreeListBox.SetHighlightRange(); - aTreeListBox.SetSelectionMode( NO_SELECTION ); - aTreeListBox.InsertEntry( OUString(), 0, false, TREELIST_APPEND ); - aTreeListBox.Show(); + aTreeListBox->SetHelpId(HID_BASICIDE_STACKWINDOW_LIST); + aTreeListBox->SetAccessibleName(IDEResId(RID_STR_STACKNAME).toString()); + aTreeListBox->SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) ); + aTreeListBox->SetHighlightRange(); + aTreeListBox->SetSelectionMode( NO_SELECTION ); + aTreeListBox->InsertEntry( OUString(), 0, false, TREELIST_APPEND ); + aTreeListBox->Show(); SetText(IDEResId(RID_STR_STACKNAME).toString()); @@ -1913,7 +1925,15 @@ StackWindow::StackWindow (Layout* pParent) : StackWindow::~StackWindow() { - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + disposeOnce(); +} + +void StackWindow::dispose() +{ + if (!IsDisposed()) + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + aTreeListBox.disposeAndClear(); + DockingWindow::dispose(); } @@ -1936,20 +1956,20 @@ void StackWindow::Resize() if ( aBoxSz.Height() < 4 ) aBoxSz.Height() = 0; - aTreeListBox.SetSizePixel( aBoxSz ); + aTreeListBox->SetSizePixel( aBoxSz ); Invalidate(); } void StackWindow::UpdateCalls() { - aTreeListBox.SetUpdateMode(false); - aTreeListBox.Clear(); + aTreeListBox->SetUpdateMode(false); + aTreeListBox->Clear(); if ( StarBASIC::IsRunning() ) { SbxError eOld = SbxBase::GetError(); - aTreeListBox.SetSelectionMode( SINGLE_SELECTION ); + aTreeListBox->SetSelectionMode( SINGLE_SELECTION ); sal_Int32 nScope = 0; SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope ); @@ -1998,7 +2018,7 @@ void StackWindow::UpdateCalls() } aEntry += ")"; } - aTreeListBox.InsertEntry( aEntry, 0, false, TREELIST_APPEND ); + aTreeListBox->InsertEntry( aEntry, 0, false, TREELIST_APPEND ); nScope++; pMethod = StarBASIC::GetActiveMethod( nScope ); } @@ -2009,11 +2029,11 @@ void StackWindow::UpdateCalls() } else { - aTreeListBox.SetSelectionMode( NO_SELECTION ); - aTreeListBox.InsertEntry( OUString(), 0, false, TREELIST_APPEND ); + aTreeListBox->SetSelectionMode( NO_SELECTION ); + aTreeListBox->InsertEntry( OUString(), 0, false, TREELIST_APPEND ); } - aTreeListBox.SetUpdateMode(true); + aTreeListBox->SetUpdateMode(true); } @@ -2024,18 +2044,33 @@ void StackWindow::UpdateCalls() ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) : Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ), - aBrkWindow(this, pParent), - aLineNumberWindow(this, pParent), - aEdtWindow(this, pParent), - aEWVScrollBar( this, WB_VSCROLL | WB_DRAG ) + aBrkWindow(VclPtr<BreakPointWindow>::Create(this, pParent)), + aLineNumberWindow(VclPtr<LineNumberWindow>::Create(this, pParent)), + aEdtWindow(VclPtr<EditorWindow>::Create(this, pParent)), + aEWVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ) +{ + aEdtWindow->Show(); + aBrkWindow->Show(); + + aEWVScrollBar->SetLineSize(nScrollLine); + aEWVScrollBar->SetPageSize(nScrollPage); + aEWVScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) ); + aEWVScrollBar->Show(); +} + + +ComplexEditorWindow::~ComplexEditorWindow() { - aEdtWindow.Show(); - aBrkWindow.Show(); + disposeOnce(); +} - aEWVScrollBar.SetLineSize(nScrollLine); - aEWVScrollBar.SetPageSize(nScrollPage); - aEWVScrollBar.SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) ); - aEWVScrollBar.Show(); +void ComplexEditorWindow::dispose() +{ + aBrkWindow.disposeAndClear(); + aLineNumberWindow.disposeAndClear(); + aEdtWindow.disposeAndClear(); + aEWVScrollBar.disposeAndClear(); + vcl::Window::dispose(); } void ComplexEditorWindow::Resize() @@ -2045,40 +2080,40 @@ void ComplexEditorWindow::Resize() aSz.Width() -= 2*DWBORDER; aSz.Height() -= 2*DWBORDER; long nBrkWidth = 20; - long nSBWidth = aEWVScrollBar.GetSizePixel().Width(); + long nSBWidth = aEWVScrollBar->GetSizePixel().Width(); Size aBrkSz(nBrkWidth, aSz.Height()); - Size aLnSz(aLineNumberWindow.GetWidth(), aSz.Height()); + Size aLnSz(aLineNumberWindow->GetWidth(), aSz.Height()); - if (aLineNumberWindow.IsVisible()) + if (aLineNumberWindow->IsVisible()) { - aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); - aLineNumberWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz); - Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow.GetWidth() - nSBWidth + 2, aSz.Height()); - aEdtWindow.SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz ); + aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); + aLineNumberWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz); + Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow->GetWidth() - nSBWidth + 2, aSz.Height()); + aEdtWindow->SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz ); } else { - aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); + aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height()); - aEdtWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz); + aEdtWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz); } - aEWVScrollBar.SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) ); + aEWVScrollBar->SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) ); } IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar ) { - if ( aEdtWindow.GetEditView() ) + if ( aEdtWindow->GetEditView() ) { - DBG_ASSERT( pCurScrollBar == &aEWVScrollBar, "Wer scrollt hier ?" ); - long nDiff = aEdtWindow.GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); - aEdtWindow.GetEditView()->Scroll( 0, nDiff ); - aBrkWindow.DoScroll( 0, nDiff ); - aLineNumberWindow.DoScroll(0, nDiff); - aEdtWindow.GetEditView()->ShowCursor(false, true); - pCurScrollBar->SetThumbPos( aEdtWindow.GetEditView()->GetStartDocPos().Y() ); + DBG_ASSERT( pCurScrollBar == aEWVScrollBar.get(), "Wer scrollt hier ?" ); + long nDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); + aEdtWindow->GetEditView()->Scroll( 0, nDiff ); + aBrkWindow->DoScroll( 0, nDiff ); + aLineNumberWindow->DoScroll(0, nDiff); + aEdtWindow->GetEditView()->ShowCursor(false, true); + pCurScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() ); } return 0; @@ -2102,7 +2137,7 @@ void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt) void ComplexEditorWindow::SetLineNumberDisplay(bool b) { - aLineNumberWindow.Show(b); + aLineNumberWindow->Show(b); Resize(); } @@ -2135,13 +2170,20 @@ WatchTreeListBox::WatchTreeListBox( vcl::Window* pParent, WinBits nWinBits ) WatchTreeListBox::~WatchTreeListBox() { + disposeOnce(); +} + +void WatchTreeListBox::dispose() +{ // Destroy user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { delete static_cast<WatchItem*>(pEntry->GetUserData()); + pEntry->SetUserData(NULL); pEntry = Next( pEntry ); } + SvHeaderTabListBox::dispose(); } void WatchTreeListBox::SetTabs() @@ -2642,6 +2684,17 @@ pCodeCompleteWindow( pPar ) SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectHdl)); } +CodeCompleteListBox::~CodeCompleteListBox() +{ + disposeOnce(); +} + +void CodeCompleteListBox::dispose() +{ + pCodeCompleteWindow.clear(); + ListBox::dispose(); +} + IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) { InsertSelectedEntry(); @@ -2807,12 +2860,24 @@ void CodeCompleteListBox::HideAndRestoreFocus() CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) : Window( pPar ), pParent( pPar ), -pListBox( new CodeCompleteListBox(this) ) +pListBox( VclPtr<CodeCompleteListBox>::Create(this) ) { SetSizePixel( Size(151,151) ); //default, later it changes InitListBox(); } +CodeCompleteWindow::~CodeCompleteWindow() +{ + disposeOnce(); +} + +void CodeCompleteWindow::dispose() +{ + pListBox.disposeAndClear(); + pParent.clear(); + vcl::Window::dispose(); +} + void CodeCompleteWindow::InitListBox() { pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index af89dfb3292d..fa99f7cd2855 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -100,9 +100,6 @@ DialogWindow::DialogWindow ( SetReadOnly(true); } -DialogWindow::~DialogWindow() -{ } - void DialogWindow::LoseFocus() { if ( IsModified() ) @@ -1027,8 +1024,8 @@ bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const Script OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TEXT)); aQueryBoxText = aQueryBoxText.replaceAll("$(ARG1)", aXmlDlgName); - NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); - sal_uInt16 nRet = aQueryBox.Execute(); + ScopedVclPtrInstance< NameClashQueryBox > aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); + sal_uInt16 nRet = aQueryBox->Execute(); if( RET_YES == nRet ) { // RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox @@ -1089,8 +1086,8 @@ bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const Script { OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TITLE)); OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TEXT)); - LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); - sal_uInt16 nRet = aQueryBox.Execute(); + ScopedVclPtrInstance< LanguageMismatchQueryBox > aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); + sal_uInt16 nRet = aQueryBox->Execute(); if( RET_YES == nRet ) { // RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox @@ -1411,11 +1408,16 @@ DialogWindowLayout::DialogWindowLayout (vcl::Window* pParent, ObjectCatalog& rOb DialogWindowLayout::~DialogWindowLayout() { - if (pPropertyBrowser != 0) - { + disposeOnce(); +} + +void DialogWindowLayout::dispose() +{ + if (pPropertyBrowser) Remove(pPropertyBrowser); - delete pPropertyBrowser; - } + pPropertyBrowser.disposeAndClear(); + pChild.clear(); + Layout::dispose(); } // shows the property browser (and creates if necessary) @@ -1425,7 +1427,7 @@ void DialogWindowLayout::ShowPropertyBrowser () if (!pPropertyBrowser) { // creating - pPropertyBrowser = new PropBrw(*this); + pPropertyBrowser = VclPtr<PropBrw>::Create(*this); pPropertyBrowser->Show(); // after OnFirstSize(): if (HasSize()) diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 1a620ce03a41..b713ffe1e878 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -126,7 +126,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) break; if (it != aWindowTable.end()) ++it; - BaseWindow* pWin = it != aWindowTable.end() ? it->second : 0; + BaseWindow* pWin = it != aWindowTable.end() ? it->second.get() : 0; bool bSearchedFromStart = false; while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) ) @@ -136,8 +136,8 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) SfxViewFrame* pViewFrame = GetViewFrame(); SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : NULL; vcl::Window* pParent = pChildWin ? pChildWin->GetWindow() : NULL; - QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART)); - if ( aQuery.Execute() == RET_YES ) + ScopedVclPtrInstance< QueryBox > aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART)); + if ( aQuery->Execute() == RET_YES ) { it = aWindowTable.begin(); if ( it != aWindowTable.end() ) @@ -166,7 +166,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) { if ( it != aWindowTable.end() ) ++it; - pWin = it != aWindowTable.end() ? it->second : 0; + pWin = it != aWindowTable.end() ? it->second.get() : 0; } else pWin = 0; @@ -202,7 +202,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICSTOP: { // maybe do not simply stop if on breakpoint! - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) pMCurWin->BasicStop(); StopBasic(); } @@ -330,7 +330,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICIDE_OBJCAT: // toggling object catalog - aObjectCatalog.Show(!aObjectCatalog.IsVisible()); + aObjectCatalog->Show(!aObjectCatalog->IsVisible()); if (pLayout) pLayout->ArrangeWindows(); // refresh the button state @@ -676,8 +676,8 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICIDE_MANAGE_LANG: { - ManageLanguageDialog aDlg(pCurWin, m_pCurLocalizationMgr); - aDlg.Execute(); + ScopedVclPtrInstance< ManageLanguageDialog > aDlg(pCurWin, m_pCurLocalizationMgr); + aDlg->Execute(); rReq.Done(); } break; @@ -750,7 +750,7 @@ void Shell::GetState(SfxItemSet &rSet) break; case SID_BASICIDE_OBJCAT: if (pLayout) - rSet.Put(SfxBoolItem(nWh, aObjectCatalog.IsVisible())); + rSet.Put(SfxBoolItem(nWh, aObjectCatalog->IsVisible())); else rSet.Put(SfxVisibilityItem(nWh, false)); break; @@ -769,7 +769,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_BASICSAVEAS: case SID_BASICIDE_MATCHGROUP: { - if (!dynamic_cast<ModulWindow*>(pCurWin)) + if (!dynamic_cast<ModulWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) ) rSet.DisableItem( nWh ); @@ -782,7 +782,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_BASICIDE_TOGGLEBRKPNT: case SID_BASICIDE_MANAGEBRKPNTS: { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { if (StarBASIC::IsRunning() && !pMCurWin->GetBasicStatus().bIsInReschedule) rSet.DisableItem(nWh); @@ -793,7 +793,7 @@ void Shell::GetState(SfxItemSet &rSet) break; case SID_BASICCOMPILE: { - if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin)) + if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); } break; @@ -814,7 +814,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_INSERT_FORM_HSCROLL: case SID_INSERT_FORM_SPIN: { - if (!dynamic_cast<DialogWindow*>(pCurWin)) + if (!dynamic_cast<DialogWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); } break; @@ -945,7 +945,7 @@ void Shell::GetState(SfxItemSet &rSet) // if this is not a module window hide the // setting, doesn't make sense for example if the // dialog editor is open - if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin)) + if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin.get())) { rSet.DisableItem( nWh ); rSet.Put(SfxVisibilityItem(nWh, false)); @@ -968,7 +968,7 @@ bool Shell::HasUIFeature( sal_uInt32 nFeature ) if ( (nFeature & BASICIDE_UI_FEATURE_SHOW_BROWSER) == BASICIDE_UI_FEATURE_SHOW_BROWSER ) { // fade out (in) property browser in module (dialog) windows - if (dynamic_cast<DialogWindow*>(pCurWin) && !pCurWin->IsReadOnly()) + if (dynamic_cast<DialogWindow*>(pCurWin.get()) && !pCurWin->IsReadOnly()) bResult = true; } @@ -1032,10 +1032,10 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); SfxObjectShell::SetCurrentComponent(0); } - aObjectCatalog.SetCurrentEntry(pCurWin); + aObjectCatalog->SetCurrentEntry(pCurWin); SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : 0 ); InvalidateBasicIDESlots(); - EnableScrollbars(pCurWin != 0); + EnableScrollbars(pCurWin != nullptr); if ( m_pCurLocalizationMgr ) m_pCurLocalizationMgr->handleTranslationbar(); @@ -1067,7 +1067,7 @@ void Shell::ManageToolbars() if ( xLayoutManager.is() ) { xLayoutManager->lock(); - if (dynamic_cast<DialogWindow*>(pCurWin)) + if (dynamic_cast<DialogWindow*>(pCurWin.get())) { xLayoutManager->destroyElement( aMacroBarResName ); @@ -1188,13 +1188,13 @@ void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) return; Size aSz( rSize ); - Size aScrollBarBoxSz( aScrollBarBox.GetSizePixel() ); + Size aScrollBarBoxSz( aScrollBarBox->GetSizePixel() ); aSz.Height() -= aScrollBarBoxSz.Height(); Size aOutSz( aSz ); aSz.Width() -= aScrollBarBoxSz.Width(); - aScrollBarBox.SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) ); - aVScrollBar.SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) ); + aScrollBarBox->SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) ); + aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) ); if ( bTabBarSplitted ) { // SplitSize is 0 at a resize! @@ -1203,17 +1203,17 @@ void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) nSplitPos = aSz.Width(); pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( nSplitPos, aScrollBarBoxSz.Height() ) ); long nScrlStart = rPos.X() + nSplitPos; - aHScrollBar.SetPosSizePixel( Point( nScrlStart, rPos.Y()+aSz.Height() ), Size( aSz.Width() - nScrlStart + 1, aScrollBarBoxSz.Height() ) ); - aHScrollBar.Update(); + aHScrollBar->SetPosSizePixel( Point( nScrlStart, rPos.Y()+aSz.Height() ), Size( aSz.Width() - nScrlStart + 1, aScrollBarBoxSz.Height() ) ); + aHScrollBar->Update(); } else { - aHScrollBar.SetPosSizePixel( Point( rPos.X()+ aSz.Width()/2 - 1, rPos.Y()+aSz.Height() ), Size( aSz.Width()/2 + 2, aScrollBarBoxSz.Height() ) ); + aHScrollBar->SetPosSizePixel( Point( rPos.X()+ aSz.Width()/2 - 1, rPos.Y()+aSz.Height() ), Size( aSz.Width()/2 + 2, aScrollBarBoxSz.Height() ) ); pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) ); } if (pLayout) - pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin) ? aSz : aOutSz); + pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin.get()) ? aSz : aOutSz); } Reference< XModel > Shell::GetCurrentDocument() const @@ -1230,7 +1230,7 @@ void Shell::Activate( bool bMDI ) if ( bMDI ) { - if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin.get())) pDCurWin->UpdateBrowser(); } } @@ -1241,7 +1241,7 @@ void Shell::Deactivate( bool bMDI ) // deactivate due to a MessageBox bMDI is false if ( bMDI ) { - if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin.get())) { pXDlgWin->DisableBrowser(); if( pXDlgWin->IsModified() ) diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 1801060e581e..e05869a64831 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -44,7 +44,7 @@ Reference< view::XRenderable > Shell::GetRenderable() bool Shell::HasSelection( bool /* bText */ ) const { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { TextView* pEditView = pMCurWin->GetEditView(); if ( pEditView && pEditView->HasSelection() ) @@ -56,7 +56,7 @@ bool Shell::HasSelection( bool /* bText */ ) const OUString Shell::GetSelectionText( bool bWholeWord ) { OUString aText; - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { if (TextView* pEditView = pMCurWin->GetEditView()) { @@ -166,8 +166,8 @@ ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUStrin { // new module window if (!pModulLayout) - pModulLayout.reset(new ModulWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog)); - pWin = new ModulWindow(pModulLayout.get(), rDocument, aLibName, aModName, aModule); + pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog.get())); + pWin = VclPtr<ModulWindow>::Create(pModulLayout.get(), rDocument, aLibName, aModName, aModule); nKey = InsertWindowInTable( pWin ); } else // we've gotten called recursively ( via listener from createModule above ), get outta here @@ -195,7 +195,7 @@ ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUStrin pTabBar->Sort(); if(pWin) { - pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); + pWin->GrabScrollBars( aHScrollBar.get(), aVScrollBar.get() ); if ( !pCurWin ) SetCurWindow( pWin, false, false ); } @@ -220,14 +220,14 @@ void Shell::Move() void Shell::ShowCursor( bool bOn ) { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) pMCurWin->ShowCursor(bOn); } // only if basic window above: void Shell::ExecuteBasic( SfxRequest& rReq ) { - if (dynamic_cast<ModulWindow*>(pCurWin)) + if (dynamic_cast<ModulWindow*>(pCurWin.get())) { pCurWin->ExecuteCommand( rReq ); if (nShellCount) diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index ff53a779c932..8479fd8a39a2 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -77,8 +77,8 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri // new dialog window if (!pDialogLayout) - pDialogLayout.reset(new DialogWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog)); - pWin = new DialogWindow(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel); + pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog.get())); + pWin = VclPtr<DialogWindow>::Create(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel); nKey = InsertWindowInTable( pWin ); } } @@ -96,7 +96,7 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri if( pWin ) { - pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); + pWin->GrabScrollBars( aHScrollBar.get(), aVScrollBar.get() ); pTabBar->InsertPage( (sal_uInt16)nKey, aDlgName ); pTabBar->Sort(); if ( !pCurWin ) @@ -128,7 +128,7 @@ sal_uInt16 Shell::GetWindowId(const BaseWindow* pWin) const SdrView* Shell::GetCurDlgView() const { - if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin.get())) return &pDCurWin->GetView(); else return 0; @@ -137,7 +137,7 @@ SdrView* Shell::GetCurDlgView() const // only if dialogue window above: void Shell::ExecuteDialog( SfxRequest& rReq ) { - if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin) || rReq.GetSlot() == SID_IMPORT_DIALOG)) + if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin.get()) || rReq.GetSlot() == SID_IMPORT_DIALOG)) pCurWin->ExecuteCommand(rReq); } diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index dce1ea4b680a..214c5b6967db 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -148,11 +148,11 @@ unsigned Shell::nShellCount = 0; Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) : SfxViewShell( pFrame_, SfxViewShellFlags::CAN_PRINT | SfxViewShellFlags::NO_NEWWINDOW ), m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ), - aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ), - aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ), - aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ), + aHScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG )) ), + aVScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG )) ), + aScrollBarBox( VclPtr<ScrollBarBox>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE )) ), pLayout(0), - aObjectCatalog(&GetViewFrame()->GetWindow()), + aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())), m_bAppBasicModified( false ), m_aNotifier( *this ) { @@ -188,7 +188,7 @@ void Shell::Init() m_aCurDocument = ScriptDocument::getApplicationScriptDocument(); bCreatingWindow = false; - pTabBar.reset(new TabBar(&GetViewFrame()->GetWindow())); + pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame()->GetWindow())); pTabBar->SetSplitHdl( LINK( this, Shell, TabBarSplitHdl ) ); bTabBarSplitted = false; @@ -225,12 +225,15 @@ Shell::~Shell() SetWindow( 0 ); SetCurWindow( 0 ); - for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) + for (WindowTable::iterator it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { // no store; does already happen when the BasicManagers are destroyed - delete it->second; + it->second.disposeAndClear(); } + // no store; does already happen when the BasicManagers are destroyed + aWindowTable.clear(); + // Destroy all ContainerListeners for Basic Container. if (ContainerListenerImpl* pListener = static_cast<ContainerListenerImpl*>(m_xLibListener.get())) pListener->removeContainerListener(m_aCurDocument, m_aCurLibName); @@ -290,7 +293,7 @@ void Shell::onDocumentClosed( const ScriptDocument& _rDocument ) bool bSetCurWindow = false; bool bSetCurLib = ( _rDocument == m_aCurDocument ); - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; // remove all windows which belong to this document for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) @@ -311,7 +314,7 @@ void Shell::onDocumentClosed( const ScriptDocument& _rDocument ) } } // delete windows outside main loop so we don't invalidate the original iterator - for (std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it) + for (auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it) { BaseWindow* pWin = *it; pWin->StoreData(); @@ -409,15 +412,15 @@ bool Shell::PrepareClose( bool bUI ) void Shell::InitScrollBars() { - aVScrollBar.SetLineSize( 300 ); - aVScrollBar.SetPageSize( 2000 ); - aHScrollBar.SetLineSize( 300 ); - aHScrollBar.SetPageSize( 2000 ); - aHScrollBar.Enable(); - aVScrollBar.Enable(); - aVScrollBar.Show(); - aHScrollBar.Show(); - aScrollBarBox.Show(); + aVScrollBar->SetLineSize( 300 ); + aVScrollBar->SetPageSize( 2000 ); + aHScrollBar->SetLineSize( 300 ); + aHScrollBar->SetPageSize( 2000 ); + aHScrollBar->Enable(); + aVScrollBar->Enable(); + aVScrollBar->Show(); + aHScrollBar->Show(); + aScrollBarBox->Show(); } @@ -485,16 +488,16 @@ bool Shell::NextPage( bool bPrev ) void Shell::ArrangeTabBar() { - long nBoxPos = aScrollBarBox.GetPosPixel().X() - 1; + long nBoxPos = aScrollBarBox->GetPosPixel().X() - 1; long nPos = pTabBar->GetSplitSize(); if ( nPos <= nBoxPos ) { Point aPnt( pTabBar->GetPosPixel() ); - long nH = aHScrollBar.GetSizePixel().Height(); + long nH = aHScrollBar->GetSizePixel().Height(); pTabBar->SetPosSizePixel( aPnt, Size( nPos, nH ) ); long nScrlStart = aPnt.X() + nPos; - aHScrollBar.SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) ); - aHScrollBar.Update(); + aHScrollBar->SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) ); + aHScrollBar->Update(); } } @@ -523,7 +526,7 @@ void Shell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, case SFX_HINT_DYING: { EndListening( rBC, true /* log off all */ ); - aObjectCatalog.UpdateEntries(); + aObjectCatalog->UpdateEntries(); } break; } @@ -592,14 +595,14 @@ void Shell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, void Shell::CheckWindows() { bool bSetCurWindow = false; - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; if ( pWin->GetStatus() & BASWIN_TOBEKILLED ) aDeleteVec.push_back( pWin ); } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { BaseWindow* pWin = *it; pWin->StoreData(); @@ -615,15 +618,15 @@ void Shell::CheckWindows() void Shell::RemoveWindows( const ScriptDocument& rDocument, const OUString& rLibName, bool bDestroy ) { - bool bChangeCurWindow = pCurWin == nullptr; - std::vector<BaseWindow*> aDeleteVec; + bool bChangeCurWindow = pCurWin; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName ) aDeleteVec.push_back( pWin ); } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { BaseWindow* pWin = *it; if ( pWin == pCurWin ) @@ -643,7 +646,7 @@ void Shell::UpdateWindows() bool bChangeCurWindow = pCurWin == nullptr; if ( !m_aCurLibName.isEmpty() ) { - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; @@ -659,7 +662,7 @@ void Shell::UpdateWindows() aDeleteVec.push_back( pWin ); } } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { RemoveWindow( *it, false, false ); } @@ -806,7 +809,7 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange { if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) ) { - delete pWindow_; + pWindow_->disposeOnce(); } else { @@ -901,8 +904,8 @@ void Shell::InvalidateBasicIDESlots() void Shell::EnableScrollbars( bool bEnable ) { - aHScrollBar.Enable(bEnable); - aVScrollBar.Enable(bEnable); + aHScrollBar->Enable(bEnable); + aVScrollBar->Enable(bEnable); } void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck ) diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 2e41965b81c9..43d1be3d6b1f 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -149,16 +149,16 @@ bool RenameModule ( if ( rDocument.hasModule( rLibName, rNewName ) ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); + aError->Execute(); return false; } // #i74440 if ( rNewName.isEmpty() ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); + aError->Execute(); return false; } @@ -242,7 +242,7 @@ OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument, OUString aScriptURL; SbMethod* pMethod = NULL; - boost::scoped_ptr< MacroChooser > pChooser( new MacroChooser( NULL, true ) ); + ScopedVclPtrInstance< MacroChooser > pChooser( nullptr, true ); if ( bChooseOnly || !SvtModuleOptions::IsBasicIDE() ) pChooser->SetMode(MacroChooser::ChooseOnly); diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index df25cbbfcb6e..dd700b1bb4ce 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -155,16 +155,16 @@ bool RenameDialog ( if ( rDocument.hasDialog( rLibName, rNewName ) ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); + aError->Execute(); return false; } // #i74440 if ( rNewName.isEmpty() ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); + aError->Execute(); return false; } diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 5d105dbe1082..79ebd6d8dacd 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -206,15 +206,22 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeTreeListBox(vcl::Windo TreeListBox::~TreeListBox () { + disposeOnce(); +} + +void TreeListBox::dispose() +{ m_aNotifier.dispose(); // destroy user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { - delete static_cast<Entry*>(pEntry->GetUserData()); + delete static_cast<Entry*>( pEntry->GetUserData() ); + pEntry->SetUserData( NULL ); pEntry = Next( pEntry ); } + SvTreeListBox::dispose(); } void TreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ) diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx index f08f298b6dc8..bf270e28413a 100644 --- a/basctl/source/basicide/bastype2.hxx +++ b/basctl/source/basicide/bastype2.hxx @@ -208,6 +208,7 @@ public: TreeListBox(vcl::Window* pParent, const ResId& rRes); TreeListBox(vcl::Window* pParent, WinBits nStyle); virtual ~TreeListBox(); + virtual void dispose() SAL_OVERRIDE; void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ); void ScanAllEntries(); diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 854621f0adda..6efa5cb29a19 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -56,10 +56,18 @@ BaseWindow::BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, c BaseWindow::~BaseWindow() { + disposeOnce(); +} + +void BaseWindow::dispose() +{ if ( pShellVScrollBar ) pShellVScrollBar->SetScrollHdl( Link() ); if ( pShellHScrollBar ) pShellHScrollBar->SetScrollHdl( Link() ); + pShellVScrollBar.clear(); + pShellHScrollBar.clear(); + vcl::Window::dispose(); } @@ -274,6 +282,17 @@ DockingWindow::DockingWindow (Layout* pParent) : nShowCount(0) { } +DockingWindow::~DockingWindow() +{ + disposeOnce(); +} + +void DockingWindow::dispose() +{ + pLayout.clear(); + ::DockingWindow::dispose(); +} + // Sets the position and the size of the docking window. This property is saved // when the window is floating. Called by Layout. void DockingWindow::ResizeIfDocking (Point const& rPos, Size const& rSize) @@ -521,7 +540,7 @@ void TabBar::Command( const CommandEvent& rCEvt ) { Shell::WindowTable& aWindowTable = pShell->GetWindowTable(); Shell::WindowTableIt it = aWindowTable.find( GetCurPageId() ); - if (it != aWindowTable.end() && dynamic_cast<ModulWindow*>(it->second)) + if (it != aWindowTable.end() && dynamic_cast<ModulWindow*>(it->second.get())) { SbModule* pActiveModule = pBasic->FindModule( it->second->GetName() ); if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) ) @@ -785,8 +804,8 @@ bool QueryDel( const OUString& rName, const ResId& rId, vcl::Window* pParent ) aNameBuf.append('\''); aNameBuf.insert(0, '\''); aQuery = aQuery.replaceAll("XX", aNameBuf.makeStringAndClear()); - MessageDialog aQueryBox(pParent, aQuery, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - return ( aQueryBox.Execute() == RET_YES ); + ScopedVclPtrInstance< MessageDialog > aQueryBox(pParent, aQuery, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + return ( aQueryBox->Execute() == RET_YES ); } bool QueryDelMacro( const OUString& rName, vcl::Window* pParent ) @@ -822,19 +841,19 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, do { // password dialog - SfxPasswordDialog aDlg(Application::GetDefDialogParent()); - aDlg.SetMinLen( 1 ); + ScopedVclPtrInstance< SfxPasswordDialog > aDlg(Application::GetDefDialogParent()); + aDlg->SetMinLen( 1 ); // set new title if ( bNewTitle ) { OUString aTitle(IDE_RESSTR(RID_STR_ENTERPASSWORD)); aTitle = aTitle.replaceAll("XX", rLibName); - aDlg.SetText( aTitle ); + aDlg->SetText( aTitle ); } // execute dialog - nRet = aDlg.Execute(); + nRet = aDlg->Execute(); // verify password if ( nRet == RET_OK ) @@ -844,14 +863,14 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY ); if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( rLibName ) && !xPasswd->isLibraryPasswordVerified( rLibName ) ) { - rPassword = aDlg.GetPassword(); + rPassword = aDlg->GetPassword(); // OUString aOUPassword( rPassword ); bOK = xPasswd->verifyLibraryPassword( rLibName, rPassword ); if ( !bOK ) { - MessageDialog aErrorBox(Application::GetDefDialogParent(), IDE_RESSTR(RID_STR_WRONGPASSWORD)); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox(Application::GetDefDialogParent(), IDE_RESSTR(RID_STR_WRONGPASSWORD)); + aErrorBox->Execute(); } } } diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx index b5b2ef17d9dc..fa8399a00512 100644 --- a/basctl/source/basicide/brkdlg.cxx +++ b/basctl/source/basicide/brkdlg.cxx @@ -106,6 +106,22 @@ BreakPointDialog::BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkPn CheckButtons(); } +BreakPointDialog::~BreakPointDialog() +{ + disposeOnce(); +} + +void BreakPointDialog::dispose() +{ + m_pComboBox.clear(); + m_pOKButton.clear(); + m_pNewButton.clear(); + m_pDelButton.clear(); + m_pNumericField.clear(); + m_pCheckBox.clear(); + ModalDialog::dispose(); +} + void BreakPointDialog::SetCurrentBreakPoint( BreakPoint* pBrk ) { OUString aStr( "# " + OUString::number(pBrk->nLine) ); diff --git a/basctl/source/basicide/brkdlg.hxx b/basctl/source/basicide/brkdlg.hxx index 703744efd345..50d18543d846 100644 --- a/basctl/source/basicide/brkdlg.hxx +++ b/basctl/source/basicide/brkdlg.hxx @@ -31,12 +31,12 @@ namespace basctl class BreakPointDialog : public ModalDialog { private: - ComboBox* m_pComboBox; - OKButton* m_pOKButton; - PushButton* m_pNewButton; - PushButton* m_pDelButton; - ::CheckBox* m_pCheckBox; - NumericField* m_pNumericField; + VclPtr<ComboBox> m_pComboBox; + VclPtr<OKButton> m_pOKButton; + VclPtr<PushButton> m_pNewButton; + VclPtr<PushButton> m_pDelButton; + VclPtr<CheckBox> m_pCheckBox; + VclPtr<NumericField> m_pNumericField; BreakPointList & m_rOriginalBreakPointList; BreakPointList m_aModifiedBreakPointList; @@ -53,6 +53,8 @@ protected: public: BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkList ); + virtual ~BreakPointDialog(); + virtual void dispose() SAL_OVERRIDE; void SetCurrentBreakPoint( BreakPoint* pBrk ); }; diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx index 961a7bde65e4..2bca3ce4349b 100644 --- a/basctl/source/basicide/layout.cxx +++ b/basctl/source/basicide/layout.cxx @@ -53,9 +53,16 @@ Layout::Layout (vcl::Window* pParent) : SetFont(aFont); } -// virtual dtor Layout::~Layout() -{ } +{ + disposeOnce(); +} + +void Layout::dispose() +{ + pChild.clear(); + Window::dispose(); +} // removes a docking window void Layout::Remove (DockingWindow* pWin) @@ -166,9 +173,9 @@ Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) : bVertical(eSide == Left || eSide == Right), bLower(eSide == Left || eSide == Top), nSize(0), - aSplitter(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL) + aSplitter(VclPtr<Splitter>::Create(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL)) { - InitSplitter(aSplitter); + InitSplitter(*aSplitter.get()); } @@ -188,7 +195,7 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize) // splitter if (!vItems.empty()) { - aItem.pSplit = boost::make_shared<Splitter>(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL); + aItem.pSplit = VclPtr<Splitter>::Create(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL); aItem.pSplit->SetSplitPosPixel(aItem.nStartPos - nSplitThickness); InitSplitter(*aItem.pSplit); } @@ -267,19 +274,19 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect) // shown if any of the windows is docked if (!bEmpty) { - aSplitter.Show(); + aSplitter->Show(); // split position - aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness); + aSplitter->SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness); // the actual position and size - aSplitter.SetPosSizePixel( - MakePoint(nPos2, aSplitter.GetSplitPosPixel()), + aSplitter->SetPosSizePixel( + MakePoint(nPos2, aSplitter->GetSplitPosPixel()), MakeSize(nLength, nSplitThickness) ); // dragging rectangle - aSplitter.SetDragRectPixel(aRect); + aSplitter->SetDragRectPixel(aRect); } else - aSplitter.Hide(); + aSplitter->Hide(); // positioning separator lines and windows bool bPrevDocking = false; // is the previous window docked? @@ -350,7 +357,7 @@ IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter) // checking margins CheckMarginsFor(pSplitter); // changing stored sizes - if (pSplitter == &aSplitter) + if (pSplitter == aSplitter.get()) { // nSize if (bLower) diff --git a/basctl/source/basicide/layout.hxx b/basctl/source/basicide/layout.hxx index fac9bdc86b69..e25cb11461ea 100644 --- a/basctl/source/basicide/layout.hxx +++ b/basctl/source/basicide/layout.hxx @@ -21,6 +21,7 @@ #define INCLUDED_BASCTL_SOURCE_BASICIDE_LAYOUT_HXX #include <vcl/split.hxx> +#include <vcl/vclptr.hxx> class DockingWindow; @@ -49,9 +50,11 @@ public: virtual void GetState (SfxItemSet&, unsigned nWhich) = 0; virtual void UpdateDebug (bool bBasicStopped ) = 0; + virtual ~Layout(); + virtual void dispose() SAL_OVERRIDE; + protected: Layout (vcl::Window* pParent); - virtual ~Layout (); void AddToLeft (DockingWindow* pWin, Size const& rSize) { aLeftSide.Add(pWin, rSize); } void AddToBottom (DockingWindow* pWin, Size const& rSize) { aBottomSide.Add(pWin, rSize); } @@ -67,7 +70,7 @@ protected: private: // the main child window (either ModulWindow or DialogWindow) - BaseWindow* pChild; + VclPtr<BaseWindow> pChild; // when this window has at first (nonempty) size bool bFirstSize; @@ -96,12 +99,12 @@ private: // size (width or height) long nSize; // the main splitting line - Splitter aSplitter; + VclPtr<Splitter> aSplitter; // the dockable windows (and some data) struct Item { // pointer to the dockable window - DockingWindow* pWin; + VclPtr<DockingWindow> pWin; // starting and ending position in the strip // They may be different from the actual window position, because // the window may fill the space of the adjacent currently @@ -110,7 +113,7 @@ private: long nStartPos, nEndPos; // splitter line window before the window // (the first one is always nullptr) - boost::shared_ptr<Splitter> pSplit; + VclPtr<Splitter> pSplit; }; std::vector<Item> vItems; private: diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx index 2ba7043207da..a2f01eea8795 100644 --- a/basctl/source/basicide/linenumberwindow.cxx +++ b/basctl/source/basicide/linenumberwindow.cxx @@ -26,7 +26,15 @@ LineNumberWindow::LineNumberWindow (vcl::Window* pParent, ModulWindow* pModulWin } LineNumberWindow::~LineNumberWindow() -{ } +{ + disposeOnce(); +} + +void LineNumberWindow::dispose() +{ + m_pModulWindow.clear(); + Window::dispose(); +} void LineNumberWindow::Paint( const Rectangle& ) { diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx index caa7f15350c0..65498937eda8 100644 --- a/basctl/source/basicide/linenumberwindow.hxx +++ b/basctl/source/basicide/linenumberwindow.hxx @@ -19,7 +19,7 @@ class ModulWindow; class LineNumberWindow : public vcl::Window { private: - ModulWindow* m_pModulWindow; + VclPtr<ModulWindow> m_pModulWindow; int m_nWidth; long m_nCurYOffset; int m_nBaseWidth; @@ -31,6 +31,7 @@ protected: public: LineNumberWindow (vcl::Window* pParent, ModulWindow* pModulWin); virtual ~LineNumberWindow(); + virtual void dispose() SAL_OVERRIDE; void DoScroll( long nHorzScroll, long nVertScroll ); diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index be4c92593604..2960bfa34929 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -112,8 +112,31 @@ MacroChooser::MacroChooser( vcl::Window* pParnt, bool bCreateEntries ) MacroChooser::~MacroChooser() { + disposeOnce(); +} + +void MacroChooser::dispose() +{ if ( bForceStoreBasic ) + { SfxGetpApp()->SaveBasicAndDialogContainer(); + bForceStoreBasic = false; + } + m_pMacroNameEdit.clear(); + m_pMacroFromTxT.clear(); + m_pMacrosSaveInTxt.clear(); + m_pBasicBox.clear(); + m_pMacrosInTxt.clear(); + m_pMacroBox.clear(); + m_pRunButton.clear(); + m_pCloseButton.clear(); + m_pAssignButton.clear(); + m_pEditButton.clear(); + m_pDelButton.clear(); + m_pOrganizeButton.clear(); + m_pNewLibButton.clear(); + m_pNewModButton.clear(); + SfxModalDialog::dispose(); } void MacroChooser::StoreMacroDescription() @@ -754,7 +777,7 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton ) StoreMacroDescription(); EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(m_pBasicBox->FirstSelected()); - boost::scoped_ptr<OrganizeDialog> pDlg(new OrganizeDialog( this, 0, aDesc )); + VclPtrInstance< OrganizeDialog > pDlg( this, 0, aDesc ); sal_uInt16 nRet = pDlg->Execute(); pDlg.reset(); diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx index 5cd80eb12540..c9c36cee13a6 100644 --- a/basctl/source/basicide/macrodlg.hxx +++ b/basctl/source/basicide/macrodlg.hxx @@ -45,22 +45,22 @@ public: }; private: - Edit* m_pMacroNameEdit; - FixedText* m_pMacroFromTxT; - FixedText* m_pMacrosSaveInTxt; - TreeListBox* m_pBasicBox; - FixedText* m_pMacrosInTxt; + VclPtr<Edit> m_pMacroNameEdit; + VclPtr<FixedText> m_pMacroFromTxT; + VclPtr<FixedText> m_pMacrosSaveInTxt; + VclPtr<TreeListBox> m_pBasicBox; + VclPtr<FixedText> m_pMacrosInTxt; OUString m_aMacrosInTxtBaseStr; - SvTreeListBox* m_pMacroBox; + VclPtr<SvTreeListBox> m_pMacroBox; - PushButton* m_pRunButton; - CloseButton* m_pCloseButton; - PushButton* m_pAssignButton; - PushButton* m_pEditButton; - PushButton* m_pDelButton; - PushButton* m_pOrganizeButton; - PushButton* m_pNewLibButton; - PushButton* m_pNewModButton; + VclPtr<PushButton> m_pRunButton; + VclPtr<CloseButton> m_pCloseButton; + VclPtr<PushButton> m_pAssignButton; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pDelButton; + VclPtr<PushButton> m_pOrganizeButton; + VclPtr<PushButton> m_pNewLibButton; + VclPtr<PushButton> m_pNewModButton; bool bNewDelIsDel; bool bForceStoreBasic; @@ -87,6 +87,7 @@ private: public: MacroChooser( vcl::Window* pParent, bool bCreateEntries = true ); virtual ~MacroChooser(); + virtual void dispose() SAL_OVERRIDE; SbMethod* GetMacro(); void DeleteMacro(); diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 8793ca43aa89..7ac4766d3e14 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -161,15 +161,23 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeCheckBox(vcl::Window * CheckBox::~CheckBox() { + disposeOnce(); +} + +void CheckBox::dispose() +{ delete pCheckButton; + pCheckButton = NULL; // delete user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { - delete static_cast<LibUserData*>(pEntry->GetUserData()); + delete static_cast<LibUserData*>( pEntry->GetUserData() ); + pEntry->SetUserData( NULL ); pEntry = Next( pEntry ); } + SvTabListBox::dispose(); } void CheckBox::Init() @@ -384,6 +392,18 @@ NewObjectDialog::NewObjectDialog(vcl::Window * pParent, ObjectMode::Mode eMode, m_pOKButton->SetClickHdl(LINK(this, NewObjectDialog, OkButtonHandler)); } +NewObjectDialog::~NewObjectDialog() +{ + disposeOnce(); +} + +void NewObjectDialog::dispose() +{ + m_pEdit.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + // GotoLineDialog GotoLineDialog::GotoLineDialog(vcl::Window * pParent ) : ModalDialog(pParent, "GotoLineDialog", @@ -395,6 +415,18 @@ GotoLineDialog::GotoLineDialog(vcl::Window * pParent ) m_pOKButton->SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler)); } +GotoLineDialog::~GotoLineDialog() +{ + disposeOnce(); +} + +void GotoLineDialog::dispose() +{ + m_pEdit.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + sal_Int32 GotoLineDialog::GetLineNumber() const { return m_pEdit->GetText().toInt32(); @@ -429,6 +461,18 @@ ExportDialog::ExportDialog(vcl::Window * pParent) m_pOKButton->SetClickHdl(LINK(this, ExportDialog, OkButtonHandler)); } +ExportDialog::~ExportDialog() +{ + disposeOnce(); +} + +void ExportDialog::dispose() +{ + m_pExportAsPackageButton.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + // LibPage LibPage::LibPage(vcl::Window * pParent) : TabPage(pParent, "LibPage", @@ -476,12 +520,30 @@ LibPage::LibPage(vcl::Window * pParent) LibPage::~LibPage() { - sal_uInt16 nCount = m_pBasicsBox->GetEntryCount(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) + disposeOnce(); +} + +void LibPage::dispose() +{ + if (m_pBasicsBox) { - DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i )); - delete pEntry; + sal_uInt16 nCount = m_pBasicsBox->GetEntryCount(); + for ( sal_uInt16 i = 0; i < nCount; ++i ) + { + DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i )); + delete pEntry; + } } + m_pBasicsBox.clear(); + m_pLibBox.clear(); + m_pEditButton.clear(); + m_pPasswordButton.clear(); + m_pNewLibButton.clear(); + m_pInsertLibButton.clear(); + m_pExportButton.clear(); + m_pDelButton.clear(); + pTabDlg.clear(); + TabPage::dispose(); } void LibPage::CheckButtons() @@ -626,7 +688,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton ) bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName ); // change password dialog - boost::scoped_ptr<SvxPasswordDialog> pDlg(new SvxPasswordDialog( this, true, !bProtected )); + VclPtrInstance< SvxPasswordDialog > pDlg( this, true, !bProtected ); pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) ); if ( pDlg->Execute() == RET_OK ) @@ -764,7 +826,7 @@ void LibPage::InsertLib() if ( xModLibContImport.is() || xDlgLibContImport.is() ) { - boost::scoped_ptr<LibDialog> pLibDlg; + VclPtr<LibDialog> pLibDlg; Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY ); Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY ); @@ -776,7 +838,7 @@ void LibPage::InsertLib() // library import dialog if ( !pLibDlg ) { - pLibDlg.reset(new LibDialog( this )); + pLibDlg.reset(VclPtr<LibDialog>::Create( this )); pLibDlg->SetStorageName( aURLObj.getName() ); pLibDlg->GetLibBox().SetMode(ObjectMode::Library); } @@ -1066,12 +1128,12 @@ void LibPage::Export() return; } - ExportDialog aNewDlg(this); - if (aNewDlg.Execute() == RET_OK) + ScopedVclPtrInstance< ExportDialog > aNewDlg(this); + if (aNewDlg->Execute() == RET_OK) { try { - if (aNewDlg.isExportAsPackage()) + if (aNewDlg->isExportAsPackage()) ExportAsPackage( aLibName ); else ExportAsBasic( aLibName ); @@ -1442,13 +1504,13 @@ void createLibImpl( vcl::Window* pWin, const ScriptDocument& rDocument, i++; } - NewObjectDialog aNewDlg(pWin, ObjectMode::Library); - aNewDlg.SetObjectName(aLibName); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(pWin, ObjectMode::Library); + aNewDlg->SetObjectName(aLibName); - if (aNewDlg.Execute()) + if (aNewDlg->Execute()) { - if (!aNewDlg.GetObjectName().isEmpty()) - aLibName = aNewDlg.GetObjectName(); + if (!aNewDlg->GetObjectName().isEmpty()) + aLibName = aNewDlg->GetObjectName(); if ( aLibName.getLength() > 30 ) { diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index ff181b230ec1..8abed4ee8893 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -62,9 +62,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeExtTreeListBox(vcl::Wi return new ExtTreeListBox(pParent, nWinBits); } -ExtTreeListBox::~ExtTreeListBox () -{ } - bool ExtTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& ) { bool bRet = false; @@ -489,8 +486,19 @@ OrganizeDialog::OrganizeDialog(vcl::Window* pParent, sal_Int16 tabId, OrganizeDialog::~OrganizeDialog() { - for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ ) - delete m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) ); + disposeOnce(); +} + +void OrganizeDialog::dispose() +{ + if (m_pTabCtrl) + { + for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ ) + VclPtr<vcl::Window>(m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) )).disposeAndClear(); + } + m_pTabCtrl.clear(); + + TabDialog::dispose(); }; short OrganizeDialog::Execute() @@ -510,25 +518,25 @@ IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl ) if ( !pTabCtrl->GetTabPage( nId ) ) { OString sPageName(pTabCtrl->GetPageName(nId)); - TabPage* pNewTabPage = 0; + VclPtr<TabPage> pNewTabPage; if (sPageName == "modules") { - ObjectPage* pObjectPage = new ObjectPage(pTabCtrl, "ModulePage", BROWSEMODE_MODULES); - pNewTabPage = pObjectPage; + VclPtrInstance<ObjectPage> pObjectPage(pTabCtrl, "ModulePage", BROWSEMODE_MODULES); + pNewTabPage.reset(pObjectPage); pObjectPage->SetTabDlg(this); pObjectPage->SetCurrentEntry(m_aCurEntry); } else if (sPageName == "dialogs") { - ObjectPage* pObjectPage = new ObjectPage( pTabCtrl, "DialogPage", BROWSEMODE_DIALOGS ); - pNewTabPage = pObjectPage; + VclPtrInstance<ObjectPage> pObjectPage( pTabCtrl, "DialogPage", BROWSEMODE_DIALOGS ); + pNewTabPage.reset(pObjectPage); pObjectPage->SetTabDlg(this); pObjectPage->SetCurrentEntry(m_aCurEntry); } else if (sPageName == "libraries") { - LibPage* pLibPage = new LibPage( pTabCtrl ); - pNewTabPage = pLibPage; + VclPtrInstance<LibPage> pLibPage( pTabCtrl ); + pNewTabPage.reset(pLibPage); pLibPage->SetTabDlg( this ); } else @@ -590,6 +598,22 @@ ObjectPage::ObjectPage(vcl::Window *pParent, const OString &rName, sal_uInt16 nM CheckButtons(); } +ObjectPage::~ObjectPage() +{ + disposeOnce(); +} + +void ObjectPage::dispose() +{ + m_pBasicBox.clear(); + m_pEditButton.clear(); + m_pNewModButton.clear(); + m_pNewDlgButton.clear(); + m_pDelButton.clear(); + pTabDlg.clear(); + TabPage::dispose(); +} + void ObjectPage::SetCurrentEntry (EntryDescriptor& rDesc) { m_pBasicBox->SetCurrentEntry( rDesc ); @@ -801,12 +825,12 @@ void ObjectPage::NewDialog() { aDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); - NewObjectDialog aNewDlg(this, ObjectMode::Dialog, true); - aNewDlg.SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) ); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(this, ObjectMode::Dialog, true); + aNewDlg->SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) ); - if (aNewDlg.Execute() != 0) + if (aNewDlg->Execute() != 0) { - OUString aDlgName = aNewDlg.GetObjectName(); + OUString aDlgName = aNewDlg->GetObjectName(); if (aDlgName.isEmpty()) aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); @@ -919,6 +943,21 @@ LibDialog::LibDialog( vcl::Window* pParent ) m_pLibBox->set_width_request(m_pLibBox->approximate_char_width() * 32); } +LibDialog::~LibDialog() +{ + disposeOnce(); +} + +void LibDialog::dispose() +{ + m_pStorageFrame.clear(); + m_pLibBox.clear(); + m_pReferenceBox.clear(); + m_pReplaceBox.clear(); + ModalDialog::dispose(); +} + + void LibDialog::SetStorageName( const OUString& rName ) { OUString aName( IDE_RESSTR(RID_STR_FILENAME) ); @@ -944,13 +983,13 @@ SbModule* createModImpl( vcl::Window* pWin, const ScriptDocument& rDocument, if ( aModName.isEmpty() ) aModName = rDocument.createObjectName( E_SCRIPTS, aLibName ); - NewObjectDialog aNewDlg(pWin, ObjectMode::Module, true); - aNewDlg.SetObjectName( aModName ); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(pWin, ObjectMode::Module, true); + aNewDlg->SetObjectName( aModName ); - if (aNewDlg.Execute() != 0) + if (aNewDlg->Execute() != 0) { - if (!aNewDlg.GetObjectName().isEmpty() ) - aModName = aNewDlg.GetObjectName(); + if (!aNewDlg->GetObjectName().isEmpty() ) + aModName = aNewDlg->GetObjectName(); try { diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index a1c3f79e8e45..12907c0c2342 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -48,12 +48,14 @@ namespace ObjectMode class NewObjectDialog : public ModalDialog { private: - Edit* m_pEdit; - OKButton* m_pOKButton; + VclPtr<Edit> m_pEdit; + VclPtr<OKButton> m_pOKButton; DECL_LINK(OkButtonHandler, void *); public: NewObjectDialog (vcl::Window* pParent, ObjectMode::Mode, bool bCheckName = false); + virtual ~NewObjectDialog(); + virtual void dispose() SAL_OVERRIDE; OUString GetObjectName() const { return m_pEdit->GetText(); } void SetObjectName( const OUString& rName ) { @@ -64,19 +66,21 @@ public: class GotoLineDialog : public ModalDialog { - Edit* m_pEdit; - OKButton* m_pOKButton; + VclPtr<Edit> m_pEdit; + VclPtr<OKButton> m_pOKButton; DECL_LINK(OkButtonHandler, void *); public: GotoLineDialog(vcl::Window * pParent); + virtual ~GotoLineDialog(); + virtual void dispose() SAL_OVERRIDE; sal_Int32 GetLineNumber() const; }; class ExportDialog : public ModalDialog { private: - RadioButton* m_pExportAsPackageButton; - OKButton* m_pOKButton; + VclPtr<RadioButton> m_pExportAsPackageButton; + VclPtr<OKButton> m_pOKButton; bool mbExportAsPackage; @@ -84,6 +88,8 @@ private: public: ExportDialog( vcl::Window * pParent ); + virtual ~ExportDialog(); + virtual void dispose() SAL_OVERRIDE; bool isExportAsPackage () const { return mbExportAsPackage; } }; @@ -107,7 +113,6 @@ protected: public: ExtTreeListBox(vcl::Window* pParent, WinBits nStyle); - virtual ~ExtTreeListBox(); }; class CheckBox : public SvTabListBox @@ -121,6 +126,7 @@ private: public: CheckBox(vcl::Window* pParent, WinBits nStyle); virtual ~CheckBox(); + virtual void dispose() SAL_OVERRIDE; SvTreeListEntry* DoInsertEntry( const OUString& rStr, sal_uLong nPos = LISTBOX_APPEND ); SvTreeListEntry* FindEntry( const OUString& rName ); @@ -141,13 +147,15 @@ public: class LibDialog: public ModalDialog { private: - VclFrame* m_pStorageFrame; - CheckBox* m_pLibBox; - ::CheckBox* m_pReferenceBox; - ::CheckBox* m_pReplaceBox; + VclPtr<VclFrame> m_pStorageFrame; + VclPtr<CheckBox> m_pLibBox; + VclPtr<::CheckBox> m_pReferenceBox; + VclPtr<::CheckBox> m_pReplaceBox; public: LibDialog( vcl::Window* pParent ); + virtual ~LibDialog(); + virtual void dispose() SAL_OVERRIDE; void SetStorageName( const OUString& rName ); @@ -162,12 +170,13 @@ public: class OrganizeDialog : public TabDialog { private: - TabControl* m_pTabCtrl; + VclPtr<TabControl> m_pTabCtrl; EntryDescriptor m_aCurEntry; public: OrganizeDialog( vcl::Window* pParent, sal_Int16 tabId, EntryDescriptor& rDesc ); virtual ~OrganizeDialog(); + virtual void dispose() SAL_OVERRIDE; virtual short Execute() SAL_OVERRIDE; @@ -177,11 +186,11 @@ public: class ObjectPage: public TabPage { protected: - ExtTreeListBox* m_pBasicBox; - PushButton* m_pEditButton; - PushButton* m_pNewModButton; - PushButton* m_pNewDlgButton; - PushButton* m_pDelButton; + VclPtr<ExtTreeListBox> m_pBasicBox; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pNewModButton; + VclPtr<PushButton> m_pNewDlgButton; + VclPtr<PushButton> m_pDelButton; DECL_LINK( BasicBoxHighlightHdl, TreeListBox * ); DECL_LINK( ButtonHdl, Button * ); @@ -192,13 +201,15 @@ protected: void NewDialog(); void EndTabDialog( sal_uInt16 nRet ); - TabDialog* pTabDlg; + VclPtr<TabDialog> pTabDlg; virtual void ActivatePage() SAL_OVERRIDE; virtual void DeactivatePage() SAL_OVERRIDE; public: ObjectPage(vcl::Window* pParent, const OString& rName, sal_uInt16 nMode); + virtual ~ObjectPage(); + virtual void dispose() SAL_OVERRIDE; void SetCurrentEntry( EntryDescriptor& rDesc ); void SetTabDlg( TabDialog* p ) { pTabDlg = p;} @@ -208,14 +219,14 @@ public: class LibPage: public TabPage { protected: - ListBox* m_pBasicsBox; - CheckBox* m_pLibBox; - PushButton* m_pEditButton; - PushButton* m_pPasswordButton; - PushButton* m_pNewLibButton; - PushButton* m_pInsertLibButton; - PushButton* m_pExportButton; - PushButton* m_pDelButton; + VclPtr<ListBox> m_pBasicsBox; + VclPtr<CheckBox> m_pLibBox; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pPasswordButton; + VclPtr<PushButton> m_pNewLibButton; + VclPtr<PushButton> m_pInsertLibButton; + VclPtr<PushButton> m_pExportButton; + VclPtr<PushButton> m_pDelButton; ScriptDocument m_aCurDocument; LibraryLocation m_eCurLocation; @@ -241,11 +252,12 @@ protected: virtual void ActivatePage() SAL_OVERRIDE; virtual void DeactivatePage() SAL_OVERRIDE; - TabDialog* pTabDlg; + VclPtr<TabDialog> pTabDlg; public: LibPage( vcl::Window* pParent ); virtual ~LibPage(); + virtual void dispose() SAL_OVERRIDE; void SetTabDlg( TabDialog* p ) { pTabDlg = p;} }; diff --git a/basctl/source/basicide/objdlg.cxx b/basctl/source/basicide/objdlg.cxx index 7bc31392b8c9..d8b9538aff3d 100644 --- a/basctl/source/basicide/objdlg.cxx +++ b/basctl/source/basicide/objdlg.cxx @@ -30,27 +30,27 @@ namespace basctl ObjectCatalog::ObjectCatalog (vcl::Window* pParent) : DockingWindow(pParent), - aTitle(this), - aTree(this, IDEResId(RID_TLB_MACROS)) + aTitle(VclPtr<FixedText>::Create(this)), + aTree(VclPtr<TreeListBox>::Create(this, IDEResId(RID_TLB_MACROS))) { SetHelpId("basctl:FloatingWindow:RID_BASICIDE_OBJCAT"); SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); // title - aTitle.SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); - aTitle.SetStyle(WB_CENTER); + aTitle->SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); + aTitle->SetStyle(WB_CENTER); // tree list - aTree.Hide(); - aTree.SetStyle( + aTree->Hide(); + aTree->SetStyle( WB_BORDER | WB_TABSTOP | WB_HSCROLL | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HASBUTTONSATROOT ); - aTree.SetAccessibleName(IDEResId(RID_STR_TLB_MACROS).toString()); - aTree.SetHelpId(HID_BASICIDE_OBJECTCAT); - aTree.ScanAllEntries(); - aTree.GrabFocus(); + aTree->SetAccessibleName(IDEResId(RID_STR_TLB_MACROS).toString()); + aTree->SetHelpId(HID_BASICIDE_OBJECTCAT); + aTree->ScanAllEntries(); + aTree->GrabFocus(); { // centered after AppWin: @@ -67,9 +67,18 @@ ObjectCatalog::ObjectCatalog (vcl::Window* pParent) : GetParent()->GetSystemWindow()->GetTaskPaneList()->AddWindow(this); } -ObjectCatalog::~ObjectCatalog () +ObjectCatalog::~ObjectCatalog() { - GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); + disposeOnce(); +} + +void ObjectCatalog::dispose() +{ + if (!IsDisposed()) + GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); + aTitle.disposeAndClear(); + aTree.disposeAndClear(); + DockingWindow::dispose(); } // Resize() -- called by Window @@ -97,14 +106,14 @@ void ObjectCatalog::ArrangeWindows () // title // (showing only if no title bar) if (bFloating) - aTitle.Hide(); + aTitle->Hide(); else { Size aTitleSize = LogicToPixel(Size(3, 10), MAP_APPFONT); aTitleSize.Width() = aSize.Width() - 2*aTitleSize.Width(); - aTitle.SetPosPixel(LogicToPixel(Point(3, 3), MAP_APPFONT)); - aTitle.SetSizePixel(aTitleSize); - aTitle.Show(); + aTitle->SetPosPixel(LogicToPixel(Point(3, 3), MAP_APPFONT)); + aTitle->SetSizePixel(aTitleSize); + aTitle->Show(); } // tree @@ -116,11 +125,11 @@ void ObjectCatalog::ArrangeWindows () ); if (aTreeSize.Height() > 0) { - aTree.SetPosSizePixel(aTreePos, aTreeSize); - aTree.Show(); + aTree->SetPosSizePixel(aTreePos, aTreeSize); + aTree->Show(); } else - aTree.Hide(); + aTree->Hide(); } void ObjectCatalog::SetCurrentEntry (BaseWindow* pCurWin) @@ -128,7 +137,7 @@ void ObjectCatalog::SetCurrentEntry (BaseWindow* pCurWin) EntryDescriptor aDescriptor; if (pCurWin) aDescriptor = pCurWin->CreateEntryDescriptor(); - aTree.SetCurrentEntry(aDescriptor); + aTree->SetCurrentEntry(aDescriptor); } diff --git a/basctl/source/basicide/objdlg.hxx b/basctl/source/basicide/objdlg.hxx index aca869793836..1ce7389044c4 100644 --- a/basctl/source/basicide/objdlg.hxx +++ b/basctl/source/basicide/objdlg.hxx @@ -37,15 +37,16 @@ class ObjectCatalog : public DockingWindow public: ObjectCatalog (vcl::Window* pParent); virtual ~ObjectCatalog (); + virtual void dispose() SAL_OVERRIDE; public: - void UpdateEntries () { aTree.UpdateEntries(); } + void UpdateEntries () { aTree->UpdateEntries(); } void SetCurrentEntry (BaseWindow* pCurWin); private: // title: "Object Catalog" - FixedText aTitle; + VclPtr<FixedText> aTitle; // the tree-list of the objects - TreeListBox aTree; + VclPtr<TreeListBox> aTree; private: virtual void Resize () SAL_OVERRIDE; // Window diff --git a/basctl/source/basicide/tbxctl.cxx b/basctl/source/basicide/tbxctl.cxx index fac2961b8455..328ea08e3f27 100644 --- a/basctl/source/basicide/tbxctl.cxx +++ b/basctl/source/basicide/tbxctl.cxx @@ -141,7 +141,7 @@ void TbxControls::Select( sal_uInt16 nModifier ) |* rItemRect are the screen coordinates |* \************************************************************************/ -SfxPopupWindow* TbxControls::CreatePopupWindow() +VclPtr<SfxPopupWindow> TbxControls::CreatePopupWindow() { if ( GetSlotId() == SID_CHOOSE_CONTROLS ) createAndPositionSubToolBar( aSubToolBarResName ); diff --git a/basctl/source/basicide/tbxctl.hxx b/basctl/source/basicide/tbxctl.hxx index 7e8a5dcc409d..d9152a07211b 100644 --- a/basctl/source/basicide/tbxctl.hxx +++ b/basctl/source/basicide/tbxctl.hxx @@ -46,7 +46,7 @@ public: virtual ~TbxControls() {} virtual SfxPopupWindowType GetPopupWindowType() const SAL_OVERRIDE; - virtual SfxPopupWindow* CreatePopupWindow() SAL_OVERRIDE; + virtual VclPtr<SfxPopupWindow> CreatePopupWindow() SAL_OVERRIDE; using SfxToolBoxControl::Select; void Select( sal_uInt16 nModifier ) SAL_OVERRIDE; diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx index fb513dc637db..eb4632366a23 100644 --- a/basctl/source/dlged/managelang.cxx +++ b/basctl/source/dlged/managelang.cxx @@ -75,7 +75,17 @@ ManageLanguageDialog::ManageLanguageDialog(vcl::Window* pParent, boost::shared_p ManageLanguageDialog::~ManageLanguageDialog() { + disposeOnce(); +} + +void ManageLanguageDialog::dispose() +{ ClearLanguageBox(); + m_pLanguageLB.clear(); + m_pAddPB.clear(); + m_pDeletePB.clear(); + m_pMakeDefPB.clear(); + ModalDialog::dispose(); } void ManageLanguageDialog::Init() @@ -136,11 +146,11 @@ void ManageLanguageDialog::ClearLanguageBox() IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl) { - SetDefaultLanguageDialog aDlg( this, m_xLocalizationMgr ); - if ( RET_OK == aDlg.Execute() ) + ScopedVclPtrInstance< SetDefaultLanguageDialog > aDlg( this, m_xLocalizationMgr ); + if ( RET_OK == aDlg->Execute() ) { // add new locales - Sequence< Locale > aLocaleSeq = aDlg.GetLocales(); + Sequence< Locale > aLocaleSeq = aDlg->GetLocales(); m_xLocalizationMgr->handleAddLocales( aLocaleSeq ); // update listbox ClearLanguageBox(); @@ -154,8 +164,8 @@ IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl) IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl) { - MessageDialog aQBox(this, "DeleteLangDialog", "modules/BasicIDE/ui/deletelang.ui"); - if ( aQBox.Execute() == RET_OK ) + ScopedVclPtrInstance< MessageDialog > aQBox(this, "DeleteLangDialog", "modules/BasicIDE/ui/deletelang.ui"); + if ( aQBox->Execute() == RET_OK ) { sal_uInt16 i, nCount = m_pLanguageLB->GetSelectEntryCount(); sal_uInt16 nPos = m_pLanguageLB->GetSelectEntryPos(); @@ -247,6 +257,22 @@ SetDefaultLanguageDialog::SetDefaultLanguageDialog(vcl::Window* pParent, boost:: FillLanguageBox(); } +SetDefaultLanguageDialog::~SetDefaultLanguageDialog() +{ + disposeOnce(); +} + +void SetDefaultLanguageDialog::dispose() +{ + m_pLanguageFT.clear(); + m_pLanguageLB.clear(); + m_pCheckLangFT.clear(); + m_pCheckLangLB.clear(); + m_pDefinedFT.clear(); + m_pAddedFT.clear(); + ModalDialog::dispose(); +} + void SetDefaultLanguageDialog::FillLanguageBox() { // fill list with all languages diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx index e38c26632a82..5f89f2627a40 100644 --- a/basctl/source/dlged/propbrw.cxx +++ b/basctl/source/dlged/propbrw.cxx @@ -190,8 +190,14 @@ void PropBrw::ImplReCreateController() PropBrw::~PropBrw() { + disposeOnce(); +} + +void PropBrw::dispose() +{ if ( m_xBrowserController.is() ) ImplDestroyController(); + DockingWindow::dispose(); } diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx index 7192763c27dc..bc0d52b33eec 100644 --- a/basctl/source/inc/accessibledialogcontrolshape.hxx +++ b/basctl/source/inc/accessibledialogcontrolshape.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessiblecomponenthelper.hxx> #include <cppuhelper/implbase3.hxx> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } class VCLExternalSolarLock; @@ -56,7 +57,7 @@ class AccessibleDialogControlShape : public AccessibleExtendedComponentHelper private: VCLExternalSolarLock* m_pExternalLock; - DialogWindow* m_pDialogWindow; + VclPtr<DialogWindow> m_pDialogWindow; DlgEdObj* m_pDlgEdObj; bool m_bFocused; bool m_bSelected; diff --git a/basctl/source/inc/accessibledialogwindow.hxx b/basctl/source/inc/accessibledialogwindow.hxx index c57b2590ae71..bd2739440160 100644 --- a/basctl/source/inc/accessibledialogwindow.hxx +++ b/basctl/source/inc/accessibledialogwindow.hxx @@ -26,6 +26,7 @@ #include <cppuhelper/implbase3.hxx> #include <svl/lstner.hxx> #include <tools/link.hxx> +#include <vcl/vclptr.hxx> class VCLExternalSolarLock; class VclSimpleEvent; @@ -80,7 +81,7 @@ private: AccessibleChildren m_aAccessibleChildren; VCLExternalSolarLock* m_pExternalLock; - basctl::DialogWindow* m_pDialogWindow; + VclPtr<basctl::DialogWindow> m_pDialogWindow; DlgEditor* m_pDlgEditor; DlgEdModel* m_pDlgEdModel; diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx index b73b9e571b6e..de17eb08403c 100644 --- a/basctl/source/inc/baside3.hxx +++ b/basctl/source/inc/baside3.hxx @@ -81,8 +81,7 @@ protected: public: TYPEINFO_OVERRIDE(); DialogWindow (DialogWindowLayout* pParent, ScriptDocument const& rDocument, const OUString& aLibName, const OUString& aName, com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel); - DialogWindow( DialogWindow* pCurView ); // never implemented - virtual ~DialogWindow(); + DialogWindow( DialogWindow* pCurView ); // never implemented virtual void ExecuteCommand( SfxRequest& rReq ) SAL_OVERRIDE; virtual void GetState( SfxItemSet& ) SAL_OVERRIDE; @@ -129,6 +128,7 @@ class DialogWindowLayout : public Layout public: DialogWindowLayout (vcl::Window* pParent, ObjectCatalog&); virtual ~DialogWindowLayout(); + virtual void dispose() SAL_OVERRIDE; public: void ShowPropertyBrowser (); void UpdatePropertyBrowser (); @@ -146,12 +146,12 @@ protected: private: // child window - DialogWindow* pChild; + VclPtr<DialogWindow> pChild; // dockable windows: // object catalog (owned by Shell) ObjectCatalog& rObjectCatalog; // property browser (created by this, deleted by toolkit) - PropBrw* pPropertyBrowser; + VclPtr<PropBrw> pPropertyBrowser; private: void AddPropertyBrowser (); diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index a6e8ecc43e39..3ae9b5bac73b 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -56,7 +56,7 @@ class Shell : public DocumentEventListener { public: - typedef std::map<sal_uInt16, BaseWindow*> WindowTable; + typedef std::map<sal_uInt16, VclPtr<BaseWindow> > WindowTable; typedef WindowTable::const_iterator WindowTableIt; private: @@ -64,26 +64,26 @@ private: friend class LocalizationMgr; friend bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName ); // defined in baside3.cxx - WindowTable aWindowTable; + WindowTable aWindowTable; sal_uInt16 nCurKey; - BaseWindow* pCurWin; + VclPtr<BaseWindow> pCurWin; ScriptDocument m_aCurDocument; OUString m_aCurLibName; boost::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr; - ScrollBar aHScrollBar; - ScrollBar aVScrollBar; - ScrollBarBox aScrollBarBox; - boost::scoped_ptr<TabBar> pTabBar; // basctl::TabBar + VclPtr<ScrollBar> aHScrollBar; + VclPtr<ScrollBar> aVScrollBar; + VclPtr<ScrollBarBox> aScrollBarBox; + VclPtr<TabBar> pTabBar; // basctl::TabBar bool bTabBarSplitted; bool bCreatingWindow; // layout windows - boost::scoped_ptr<ModulWindowLayout> pModulLayout; - boost::scoped_ptr<DialogWindowLayout> pDialogLayout; + VclPtr<ModulWindowLayout> pModulLayout; + VclPtr<DialogWindowLayout> pDialogLayout; // the active layout window - Layout* pLayout; + VclPtr<Layout> pLayout; // common object catalog window - ObjectCatalog aObjectCatalog; + VclPtr<ObjectCatalog> aObjectCatalog; bool m_bAppBasicModified; DocumentEventNotifier m_aNotifier; @@ -163,9 +163,9 @@ public: OUString const& GetCurLibName() const { return m_aCurLibName; } boost::shared_ptr<LocalizationMgr> GetCurLocalizationMgr() const { return m_pCurLocalizationMgr; } - ScrollBar& GetHScrollBar() { return aHScrollBar; } - ScrollBar& GetVScrollBar() { return aVScrollBar; } - ScrollBarBox& GetScrollBarBox() { return aScrollBarBox; } + ScrollBar& GetHScrollBar() { return *aHScrollBar.get(); } + ScrollBar& GetVScrollBar() { return *aVScrollBar.get(); } + ScrollBarBox& GetScrollBarBox() { return *aScrollBarBox.get(); } TabBar& GetTabBar() { return *pTabBar; } WindowTable& GetWindowTable() { return aWindowTable; } sal_uInt16 GetWindowId (BaseWindow const* pWin) const; @@ -212,7 +212,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetCurrentDocument() const SAL_OVERRIDE; - void UpdateObjectCatalog () { aObjectCatalog.UpdateEntries(); } + void UpdateObjectCatalog () { aObjectCatalog->UpdateEntries(); } void RemoveWindow (BaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true); }; diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index c7e1e1d913a7..8b67fcc1270a 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -81,7 +81,8 @@ class DockingWindow : public ::DockingWindow public: DockingWindow (vcl::Window* pParent); DockingWindow (Layout* pParent); -public: + virtual ~DockingWindow(); + virtual void dispose() SAL_OVERRIDE; void ResizeIfDocking (Point const&, Size const&); void ResizeIfDocking (Size const&); Size GetDockingSize () const { return aDockingRect.GetSize(); } @@ -103,7 +104,7 @@ private: // the position and the size of the docking window Rectangle aDockingRect; // the parent layout window (only when docking) - Layout* pLayout; + VclPtr<Layout> pLayout; // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide() int nShowCount; @@ -149,8 +150,8 @@ class EntryDescriptor; class BaseWindow : public vcl::Window { private: - ScrollBar* pShellHScrollBar; - ScrollBar* pShellVScrollBar; + VclPtr<ScrollBar> pShellHScrollBar; + VclPtr<ScrollBar> pShellVScrollBar; DECL_LINK( ScrollHdl, ScrollBar * ); int nStatus; @@ -169,6 +170,7 @@ public: TYPEINFO(); BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName ); virtual ~BaseWindow(); + virtual void dispose() SAL_OVERRIDE; void Init(); virtual void DoInit(); diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index 81e9f61ef57d..af9ad3c8e41d 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -30,6 +30,7 @@ #include <tools/gen.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> +#include <vcl/vclptr.hxx> #include <boost/scoped_ptr.hpp> @@ -106,8 +107,8 @@ private: static void Print( Printer* pPrinter, const OUString& rTitle ); private: - ScrollBar* pHScroll; - ScrollBar* pVScroll; + VclPtr<ScrollBar> pHScroll; + VclPtr<ScrollBar> pVScroll; boost::scoped_ptr<DlgEdModel> pDlgEdModel; // never nullptr DlgEdPage* pDlgEdPage; // never nullptr boost::scoped_ptr<DlgEdView> pDlgEdView; // never nullptr diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx index 8b07b27c0f80..f7b9335e5e24 100644 --- a/basctl/source/inc/managelang.hxx +++ b/basctl/source/inc/managelang.hxx @@ -52,10 +52,10 @@ extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft, class ManageLanguageDialog : public ModalDialog { private: - ListBox* m_pLanguageLB; - PushButton* m_pAddPB; - PushButton* m_pDeletePB; - PushButton* m_pMakeDefPB; + VclPtr<ListBox> m_pLanguageLB; + VclPtr<PushButton> m_pAddPB; + VclPtr<PushButton> m_pDeletePB; + VclPtr<PushButton> m_pMakeDefPB; boost::shared_ptr<LocalizationMgr> m_xLocalizationMgr; @@ -74,17 +74,18 @@ private: public: ManageLanguageDialog( vcl::Window* pParent, boost::shared_ptr<LocalizationMgr> _pLMgr ); virtual ~ManageLanguageDialog(); + virtual void dispose() SAL_OVERRIDE; }; class SetDefaultLanguageDialog : public ModalDialog { private: - FixedText* m_pLanguageFT; - SvxLanguageBox* m_pLanguageLB; - FixedText* m_pCheckLangFT; - SvxCheckListBox* m_pCheckLangLB; - FixedText* m_pDefinedFT; - FixedText* m_pAddedFT; + VclPtr<FixedText> m_pLanguageFT; + VclPtr<SvxLanguageBox> m_pLanguageLB; + VclPtr<FixedText> m_pCheckLangFT; + VclPtr<SvxCheckListBox> m_pCheckLangLB; + VclPtr<FixedText> m_pDefinedFT; + VclPtr<FixedText> m_pAddedFT; boost::shared_ptr<LocalizationMgr> m_xLocalizationMgr; @@ -92,6 +93,8 @@ private: public: SetDefaultLanguageDialog(vcl::Window* pParent, boost::shared_ptr<LocalizationMgr> xLMgr); + virtual ~SetDefaultLanguageDialog(); + virtual void dispose() SAL_OVERRIDE; ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > GetLocales() const; }; diff --git a/basctl/source/inc/propbrw.hxx b/basctl/source/inc/propbrw.hxx index 04ab22d5dccf..3262d36301d0 100644 --- a/basctl/source/inc/propbrw.hxx +++ b/basctl/source/inc/propbrw.hxx @@ -75,6 +75,7 @@ protected: public: explicit PropBrw (DialogWindowLayout&); virtual ~PropBrw(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; // note: changing the Context document to an instance other than the one given in the ctor is not supported // currently |