diff options
Diffstat (limited to 'extensions')
87 files changed, 1241 insertions, 658 deletions
diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx index 1cf24b87a2ac..bb9e12a31d8d 100644 --- a/extensions/source/abpilot/abpfinalpage.cxx +++ b/extensions/source/abpilot/abpfinalpage.cxx @@ -64,7 +64,19 @@ namespace abp FinalPage::~FinalPage() { + disposeOnce(); + } + + void FinalPage::dispose() + { delete m_pLocationController; + m_pLocation.clear(); + m_pBrowse.clear(); + m_pRegisterName.clear(); + m_pNameLabel.clear(); + m_pName.clear(); + m_pDuplicateNameError.clear(); + AddressBookSourcePage::dispose(); } bool FinalPage::isValidName() const diff --git a/extensions/source/abpilot/abpfinalpage.hxx b/extensions/source/abpilot/abpfinalpage.hxx index 821f39f62525..eedeac43b25d 100644 --- a/extensions/source/abpilot/abpfinalpage.hxx +++ b/extensions/source/abpilot/abpfinalpage.hxx @@ -26,6 +26,7 @@ #include <svtools/urlcontrol.hxx> #include <svx/databaselocationinput.hxx> #include <vcl/edit.hxx> +#include <vcl/vclptr.hxx> namespace abp @@ -38,12 +39,12 @@ namespace abp class FinalPage : public AddressBookSourcePage { protected: - ::svt::OFileURLControl* m_pLocation; - PushButton* m_pBrowse; - CheckBox* m_pRegisterName; - FixedText* m_pNameLabel; - Edit* m_pName; - FixedText* m_pDuplicateNameError; + VclPtr<::svt::OFileURLControl> m_pLocation; + VclPtr<PushButton> m_pBrowse; + VclPtr<CheckBox> m_pRegisterName; + VclPtr<FixedText> m_pNameLabel; + VclPtr<Edit> m_pName; + VclPtr<FixedText> m_pDuplicateNameError; ::svx::DatabaseLocationInputController* m_pLocationController; @@ -53,6 +54,7 @@ namespace abp public: FinalPage( OAddessBookSourcePilot* _pParent ); virtual ~FinalPage(); + virtual void dispose() SAL_OVERRIDE; protected: // OWizardPage overridables diff --git a/extensions/source/abpilot/abspilot.cxx b/extensions/source/abpilot/abspilot.cxx index 45abc6bf7036..f06fa97156f9 100644 --- a/extensions/source/abpilot/abspilot.cxx +++ b/extensions/source/abpilot/abspilot.cxx @@ -130,11 +130,6 @@ namespace abp SetHelpId(HID_ABSPILOT); } - OAddessBookSourcePilot::~OAddessBookSourcePilot() - { - } - - OUString OAddessBookSourcePilot::getStateDisplayName( WizardState _nState ) const { sal_uInt16 nResId = 0; @@ -413,24 +408,24 @@ namespace abp } - OWizardPage* OAddessBookSourcePilot::createPage(WizardState _nState) + VclPtr<TabPage> OAddessBookSourcePilot::createPage(WizardState _nState) { switch (_nState) { case STATE_SELECT_ABTYPE: - return new TypeSelectionPage( this ); + return VclPtr<TypeSelectionPage>::Create( this ); case STATE_INVOKE_ADMIN_DIALOG: - return new AdminDialogInvokationPage( this ); + return VclPtr<AdminDialogInvokationPage>::Create( this ); case STATE_TABLE_SELECTION: - return new TableSelectionPage( this ); + return VclPtr<TableSelectionPage>::Create( this ); case STATE_MANUAL_FIELD_MAPPING: - return new FieldMappingPage( this ); + return VclPtr<FieldMappingPage>::Create( this ); case STATE_FINAL_CONFIRM: - return new FinalPage( this ); + return VclPtr<FinalPage>::Create( this ); default: OSL_FAIL("OAddessBookSourcePilot::createPage: invalid state!"); diff --git a/extensions/source/abpilot/abspilot.hxx b/extensions/source/abpilot/abspilot.hxx index de7a5895b627..5b24ff244e45 100644 --- a/extensions/source/abpilot/abspilot.hxx +++ b/extensions/source/abpilot/abspilot.hxx @@ -49,8 +49,6 @@ namespace abp OAddessBookSourcePilot( vcl::Window* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB); - /// dtor - virtual ~OAddessBookSourcePilot(); /// get the service factory which was used to create the dialog const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& @@ -69,7 +67,7 @@ namespace abp protected: // OWizardMachine overridables - virtual ::svt::OWizardPage* createPage( WizardState _nState ) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage( WizardState _nState ) SAL_OVERRIDE; virtual void enterState( WizardState _nState ) SAL_OVERRIDE; virtual bool prepareLeaveCurrentState( CommitPageReason _eReason ) SAL_OVERRIDE; virtual bool onFinish() SAL_OVERRIDE; diff --git a/extensions/source/abpilot/admininvokationimpl.hxx b/extensions/source/abpilot/admininvokationimpl.hxx index 486223ca30c0..9dc5d3b0cb8a 100644 --- a/extensions/source/abpilot/admininvokationimpl.hxx +++ b/extensions/source/abpilot/admininvokationimpl.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } @@ -36,7 +37,7 @@ namespace abp ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource; - vcl::Window* m_pMessageParent; + VclPtr<vcl::Window> m_pMessageParent; public: OAdminDialogInvokation( diff --git a/extensions/source/abpilot/admininvokationpage.cxx b/extensions/source/abpilot/admininvokationpage.cxx index a92e90d7eb1e..57bb822c076f 100644 --- a/extensions/source/abpilot/admininvokationpage.cxx +++ b/extensions/source/abpilot/admininvokationpage.cxx @@ -34,7 +34,16 @@ namespace abp get(m_pErrorMessage, "warning"); m_pInvokeAdminDialog->SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) ); } - + AdminDialogInvokationPage::~AdminDialogInvokationPage() + { + disposeOnce(); + } + void AdminDialogInvokationPage::dispose() + { + m_pInvokeAdminDialog.clear(); + m_pErrorMessage.clear(); + AddressBookSourcePage::dispose(); + } void AdminDialogInvokationPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); diff --git a/extensions/source/abpilot/admininvokationpage.hxx b/extensions/source/abpilot/admininvokationpage.hxx index 4b264274f290..7e2e7efce8c2 100644 --- a/extensions/source/abpilot/admininvokationpage.hxx +++ b/extensions/source/abpilot/admininvokationpage.hxx @@ -29,14 +29,15 @@ namespace abp class AdminDialogInvokationPage : public AddressBookSourcePage { protected: - PushButton* m_pInvokeAdminDialog; - FixedText* m_pErrorMessage; + VclPtr<PushButton> m_pInvokeAdminDialog; + VclPtr<FixedText> m_pErrorMessage; bool m_bSuccessfullyExecutedDialog; public: AdminDialogInvokationPage( OAddessBookSourcePilot* _pParent ); - + virtual ~AdminDialogInvokationPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabDialog overridables virtual void ActivatePage() SAL_OVERRIDE; diff --git a/extensions/source/abpilot/fieldmappingpage.cxx b/extensions/source/abpilot/fieldmappingpage.cxx index c30bf82265c6..9ad8a3b0f11d 100644 --- a/extensions/source/abpilot/fieldmappingpage.cxx +++ b/extensions/source/abpilot/fieldmappingpage.cxx @@ -37,6 +37,18 @@ namespace abp m_pInvokeDialog->SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) ); } + FieldMappingPage::~FieldMappingPage() + { + disposeOnce(); + } + + void FieldMappingPage::dispose() + { + m_pInvokeDialog.clear(); + m_pHint.clear(); + AddressBookSourcePage::dispose(); + } + void FieldMappingPage::ActivatePage() { AddressBookSourcePage::ActivatePage(); diff --git a/extensions/source/abpilot/fieldmappingpage.hxx b/extensions/source/abpilot/fieldmappingpage.hxx index 35ce8a2fcc3b..6adaf511800a 100644 --- a/extensions/source/abpilot/fieldmappingpage.hxx +++ b/extensions/source/abpilot/fieldmappingpage.hxx @@ -21,6 +21,7 @@ #define INCLUDED_EXTENSIONS_SOURCE_ABPILOT_FIELDMAPPINGPAGE_HXX #include "abspage.hxx" +#include <vcl/vclptr.hxx> namespace abp @@ -33,12 +34,13 @@ namespace abp class FieldMappingPage : public AddressBookSourcePage { protected: - PushButton* m_pInvokeDialog; - FixedText* m_pHint; + VclPtr<PushButton> m_pInvokeDialog; + VclPtr<FixedText> m_pHint; public: FieldMappingPage( OAddessBookSourcePilot* _pParent ); - + virtual ~FieldMappingPage(); + virtual void dispose() SAL_OVERRIDE; protected: // OWizardPage overridables virtual void initializePage() SAL_OVERRIDE; diff --git a/extensions/source/abpilot/tableselectionpage.cxx b/extensions/source/abpilot/tableselectionpage.cxx index 61ac27d8f1ce..537ef7b2b73e 100644 --- a/extensions/source/abpilot/tableselectionpage.cxx +++ b/extensions/source/abpilot/tableselectionpage.cxx @@ -41,6 +41,16 @@ namespace abp m_pTableList->SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) ); } + TableSelectionPage::~TableSelectionPage() + { + disposeOnce(); + } + + void TableSelectionPage::dispose() + { + m_pTableList.clear(); + AddressBookSourcePage::dispose(); + } void TableSelectionPage::ActivatePage() { diff --git a/extensions/source/abpilot/tableselectionpage.hxx b/extensions/source/abpilot/tableselectionpage.hxx index c9fcd755920d..7abcf547af45 100644 --- a/extensions/source/abpilot/tableselectionpage.hxx +++ b/extensions/source/abpilot/tableselectionpage.hxx @@ -22,6 +22,7 @@ #include "abspage.hxx" #include <vcl/lstbox.hxx> +#include <vcl/vclptr.hxx> namespace abp @@ -34,11 +35,12 @@ namespace abp class TableSelectionPage : public AddressBookSourcePage { protected: - ListBox* m_pTableList; + VclPtr<ListBox> m_pTableList; public: TableSelectionPage( OAddessBookSourcePilot* _pParent ); - + virtual ~TableSelectionPage(); + virtual void dispose() SAL_OVERRIDE; protected: // OWizardPage overridables virtual void initializePage() SAL_OVERRIDE; diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx index 79361869e8b7..f732eff901b4 100644 --- a/extensions/source/abpilot/typeselectionpage.cxx +++ b/extensions/source/abpilot/typeselectionpage.cxx @@ -151,11 +151,28 @@ namespace abp TypeSelectionPage::~TypeSelectionPage() { + disposeOnce(); + } + + void TypeSelectionPage::dispose() + { for ( ::std::vector< ButtonItem >::iterator loop = m_aAllTypes.begin(); loop != m_aAllTypes.end(); ++loop ) { loop->m_bVisible = false; } + m_pEvolution.clear(); + m_pEvolutionGroupwise.clear(); + m_pEvolutionLdap.clear(); + m_pMORK.clear(); + m_pThunderbird.clear(); + m_pKab.clear(); + m_pMacab.clear(); + m_pLDAP.clear(); + m_pOutlook.clear(); + m_pOE.clear(); + m_pOther.clear(); + AddressBookSourcePage::dispose(); } @@ -226,8 +243,8 @@ namespace abp if (AST_INVALID == getSelectedType( )) { - MessageDialog aError(this, ModuleRes(RID_STR_NEEDTYPESELECTION)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(this, ModuleRes(RID_STR_NEEDTYPESELECTION)); + aError->Execute(); return false; } diff --git a/extensions/source/abpilot/typeselectionpage.hxx b/extensions/source/abpilot/typeselectionpage.hxx index 2e4437e285f8..b7c628f884c1 100644 --- a/extensions/source/abpilot/typeselectionpage.hxx +++ b/extensions/source/abpilot/typeselectionpage.hxx @@ -23,6 +23,7 @@ #include "abspage.hxx" #include "addresssettings.hxx" #include <vcl/edit.hxx> +#include <vcl/vclptr.hxx> namespace abp @@ -35,20 +36,20 @@ namespace abp class TypeSelectionPage : public AddressBookSourcePage { protected: - RadioButton* m_pEvolution; - RadioButton* m_pEvolutionGroupwise; - RadioButton* m_pEvolutionLdap; - RadioButton* m_pMORK; - RadioButton* m_pThunderbird; - RadioButton* m_pKab; - RadioButton* m_pMacab; - RadioButton* m_pLDAP; - RadioButton* m_pOutlook; - RadioButton* m_pOE; - RadioButton* m_pOther; + VclPtr<RadioButton> m_pEvolution; + VclPtr<RadioButton> m_pEvolutionGroupwise; + VclPtr<RadioButton> m_pEvolutionLdap; + VclPtr<RadioButton> m_pMORK; + VclPtr<RadioButton> m_pThunderbird; + VclPtr<RadioButton> m_pKab; + VclPtr<RadioButton> m_pMacab; + VclPtr<RadioButton> m_pLDAP; + VclPtr<RadioButton> m_pOutlook; + VclPtr<RadioButton> m_pOE; + VclPtr<RadioButton> m_pOther; struct ButtonItem { - RadioButton *m_pItem; + VclPtr<RadioButton> m_pItem; AddressSourceType m_eType; bool m_bVisible; @@ -66,6 +67,7 @@ namespace abp public: TypeSelectionPage( OAddessBookSourcePilot* _pParent ); virtual ~TypeSelectionPage(); + virtual void dispose() SAL_OVERRIDE; // retrieves the currently selected type AddressSourceType getSelectedType() const; diff --git a/extensions/source/abpilot/unodialogabp.cxx b/extensions/source/abpilot/unodialogabp.cxx index f8afef08c385..fdf27d8a7609 100644 --- a/extensions/source/abpilot/unodialogabp.cxx +++ b/extensions/source/abpilot/unodialogabp.cxx @@ -152,9 +152,9 @@ namespace abp } - Dialog* OABSPilotUno::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> OABSPilotUno::createDialog(vcl::Window* _pParent) { - return new OAddessBookSourcePilot(_pParent, m_aContext ); + return VclPtr<OAddessBookSourcePilot>::Create(_pParent, m_aContext ); } @@ -179,7 +179,7 @@ namespace abp { if ( _nExecutionResult == RET_OK ) { - const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings(); + const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog.get())->getSettings(); m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName; } } diff --git a/extensions/source/abpilot/unodialogabp.hxx b/extensions/source/abpilot/unodialogabp.hxx index b444095823a5..efd84acdfb11 100644 --- a/extensions/source/abpilot/unodialogabp.hxx +++ b/extensions/source/abpilot/unodialogabp.hxx @@ -84,7 +84,7 @@ namespace abp using OABSPilotUno_DBase::execute; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; virtual void executedDialog(sal_Int16 _nExecutionResult) SAL_OVERRIDE; }; diff --git a/extensions/source/bibliography/bibbeam.cxx b/extensions/source/bibliography/bibbeam.cxx index 72120f8d36ce..9e6235055801 100644 --- a/extensions/source/bibliography/bibbeam.cxx +++ b/extensions/source/bibliography/bibbeam.cxx @@ -29,6 +29,7 @@ #include <vcl/edit.hxx> #include <tools/debug.hxx> #include "bibbeam.hxx" +#include "bibview.hxx" #include "toolbar.hrc" #include "bibresid.hxx" #include "datman.hxx" @@ -87,6 +88,7 @@ namespace bib BibGridwin(vcl::Window* pParent, WinBits nStyle = WB_3DLOOK ); virtual ~BibGridwin(); + virtual void dispose() SAL_OVERRIDE; void createGridWin(const Reference< awt::XControlModel > & xDbForm); void disposeGridWin(); @@ -107,9 +109,15 @@ namespace bib BibGridwin::~BibGridwin() { + disposeOnce(); + } + + void BibGridwin::dispose() + { RemoveFromTaskPaneList( this ); disposeGridWin(); + vcl::Window::dispose(); } void BibGridwin::Resize() @@ -195,6 +203,11 @@ namespace bib BibBeamer::~BibBeamer() { + disposeOnce(); + } + + void BibBeamer::dispose() + { if ( isFormConnected() ) disconnectForm(); @@ -202,25 +215,16 @@ namespace bib m_xToolBarRef->dispose(); if ( pToolBar ) - { pDatMan->SetToolbar(0); - DELETEZ( pToolBar ); - } - - if( pGridWin ) - { - BibGridwin* pDel = pGridWin; - pGridWin = NULL; - pDel->disposeGridWin(); - delete pDel; - } - + pToolBar.disposeAndClear(); + pGridWin.disposeAndClear(); + BibSplitWindow::dispose(); } void BibBeamer::createToolBar() { - pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl )); + pToolBar= VclPtr<BibToolBar>::Create(this, LINK( this, BibBeamer, RecalcLayout_Impl )); ::Size aSize=pToolBar->GetSizePixel(); InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED ); if ( m_xController.is() ) @@ -229,7 +233,7 @@ namespace bib void BibBeamer::createGridWin() { - pGridWin = new BibGridwin(this,0); + pGridWin = VclPtr<BibGridwin>::Create(this,0); InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE ); diff --git a/extensions/source/bibliography/bibbeam.hxx b/extensions/source/bibliography/bibbeam.hxx index bfecf435ecb5..aea7d49db079 100644 --- a/extensions/source/bibliography/bibbeam.hxx +++ b/extensions/source/bibliography/bibbeam.hxx @@ -52,8 +52,8 @@ namespace bib ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xGridWin; BibDataManager* pDatMan; - BibToolBar* pToolBar; - BibGridwin* pGridWin; + VclPtr<BibToolBar> pToolBar; + VclPtr<BibGridwin> pGridWin; DECL_LINK( RecalcLayout_Impl, void* ); @@ -72,6 +72,7 @@ namespace bib BibBeamer(vcl::Window* pParent,BibDataManager* pDatMan, WinBits nStyle = WB_3DLOOK ); virtual ~BibBeamer(); + virtual void dispose() SAL_OVERRIDE; void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &); diff --git a/extensions/source/bibliography/bibcont.cxx b/extensions/source/bibliography/bibcont.cxx index 954700c24277..5eba4bac1bbc 100644 --- a/extensions/source/bibliography/bibcont.cxx +++ b/extensions/source/bibliography/bibcont.cxx @@ -31,6 +31,7 @@ #include "datman.hxx" #include "bibcont.hxx" +#include "bibview.hxx" BibShortCutHandler::~BibShortCutHandler() @@ -56,20 +57,11 @@ BibSplitWindow::BibSplitWindow( vcl::Window* pParent, WinBits nStyle ) : SplitWi { } -BibSplitWindow::~BibSplitWindow() -{ -} - BibTabPage::BibTabPage( vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription ) : TabPage( pParent, rID, rUIXMLDescription ), BibShortCutHandler( this ) { } -BibTabPage::~BibTabPage() -{ -} - - using namespace osl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -94,12 +86,18 @@ BibWindowContainer::BibWindowContainer( vcl::Window* pParent, BibShortCutHandler BibWindowContainer::~BibWindowContainer() { + disposeOnce(); +} + +void BibWindowContainer::dispose() +{ if( pChild ) { - vcl::Window* pDel = GetChild(); + VclPtr<vcl::Window> pDel = GetChild(); pChild = NULL; // prevents GetFocus for child while deleting! - delete pDel; + pDel.disposeAndClear(); } + vcl::Window::dispose(); } void BibWindowContainer::Resize() @@ -132,6 +130,11 @@ BibBookContainer::BibBookContainer(vcl::Window* pParent, WinBits nStyle): BibBookContainer::~BibBookContainer() { + disposeOnce(); +} + +void BibBookContainer::dispose() +{ if( xTopFrameRef.is() ) xTopFrameRef->dispose(); if( xBottomFrameRef.is() ) @@ -139,19 +142,22 @@ BibBookContainer::~BibBookContainer() if( pTopWin ) { - vcl::Window* pDel = pTopWin; + VclPtr<vcl::Window> pDel = pTopWin; pTopWin = NULL; // prevents GetFocus for child while deleting! - delete pDel; + pDel.disposeAndClear(); } if( pBottomWin ) { - vcl::Window* pDel = pBottomWin; + VclPtr<vcl::Window> pDel = pBottomWin; pBottomWin = NULL; // prevents GetFocus for child while deleting! - delete pDel; + pDel.disposeAndClear(); } CloseBibModul( pBibMod ); + pTopWin.clear(); + pBottomWin.clear(); + BibSplitWindow::dispose(); } void BibBookContainer::Split() @@ -175,9 +181,9 @@ void BibBookContainer::createTopFrame( BibShortCutHandler* pWin ) if(pTopWin) { RemoveItem(TOP_WINDOW); - delete pTopWin; + pTopWin.disposeAndClear(); } - pTopWin=new BibWindowContainer(this,pWin); + pTopWin=VclPtr<BibWindowContainer>::Create(this,pWin); pTopWin->Show(); BibConfig* pConfig = BibModul::GetConfig(); long nSize = pConfig->getBeamerSize(); @@ -192,10 +198,10 @@ void BibBookContainer::createBottomFrame( BibShortCutHandler* pWin ) if(pBottomWin) { RemoveItem(BOTTOM_WINDOW); - delete pBottomWin; + pBottomWin.disposeAndClear(); } - pBottomWin=new BibWindowContainer(this,pWin); + pBottomWin=VclPtr<BibWindowContainer>::Create(this,pWin); BibConfig* pConfig = BibModul::GetConfig(); long nSize = pConfig->getViewSize(); diff --git a/extensions/source/bibliography/bibcont.hxx b/extensions/source/bibliography/bibcont.hxx index af6a78839900..3488c2ee27ee 100644 --- a/extensions/source/bibliography/bibcont.hxx +++ b/extensions/source/bibliography/bibcont.hxx @@ -43,8 +43,9 @@ class BibWindowContainer : public BibWindow //Window public: BibWindowContainer( vcl::Window* pParent, BibShortCutHandler* pChild, WinBits nStyle = WB_3DLOOK); virtual ~BibWindowContainer(); + virtual void dispose() SAL_OVERRIDE; - inline vcl::Window* GetChild(); + inline vcl::Window* GetChild(); virtual void GetFocus() SAL_OVERRIDE; @@ -55,7 +56,7 @@ class BibWindowContainer : public BibWindow //Window inline vcl::Window* BibWindowContainer::GetChild() { - return pChild? pChild->GetWindow() : NULL; + return pChild ? pChild->GetWindow() : NULL; } @@ -69,8 +70,8 @@ class BibBookContainer: public BibSplitWindow ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xTopPeerRef; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xBottomPeerRef; - BibWindowContainer* pTopWin; - BibWindowContainer* pBottomWin; + VclPtr<BibWindowContainer> pTopWin; + VclPtr<BibWindowContainer> pBottomWin; HdlBibModul pBibMod; Idle aIdle; @@ -86,6 +87,7 @@ class BibBookContainer: public BibSplitWindow BibBookContainer(vcl::Window* pParent, WinBits nStyle = WB_3DLOOK ); virtual ~BibBookContainer(); + virtual void dispose() SAL_OVERRIDE; inline BibWindow* GetTopWin() {return pTopWin;} inline BibWindow* GetBottomWin() {return pBottomWin;} diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx index 97ad1f1fa9e8..afa6cb083076 100644 --- a/extensions/source/bibliography/bibload.cxx +++ b/extensions/source/bibliography/bibload.cxx @@ -273,7 +273,7 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt vcl::Window* pParent = VCLUnoHelper::GetWindow( aWindow ); - BibBookContainer *pMyWindow = new BibBookContainer( pParent ); + VclPtrInstance<BibBookContainer> pMyWindow( pParent ); pMyWindow->Show(); ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_VSCROLL | WB_HSCROLL | WB_3DLOOK ); diff --git a/extensions/source/bibliography/bibmod.cxx b/extensions/source/bibliography/bibmod.cxx index 4336c1a54461..cda8769d0204 100644 --- a/extensions/source/bibliography/bibmod.cxx +++ b/extensions/source/bibliography/bibmod.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/lang/XLocalizable.hpp> #include "bibmod.hxx" +#include "bibview.hxx" #include "bibresid.hxx" #include "datman.hxx" #include "bibconfig.hxx" diff --git a/extensions/source/bibliography/bibshortcuthandler.hxx b/extensions/source/bibliography/bibshortcuthandler.hxx index 45bf279df404..d6310f549629 100644 --- a/extensions/source/bibliography/bibshortcuthandler.hxx +++ b/extensions/source/bibliography/bibshortcuthandler.hxx @@ -31,7 +31,7 @@ class BibShortCutHandler { private: - vcl::Window* pBaseClass; // in cases, where BibShortCutHandler also has to be a window + VclPtr<vcl::Window> pBaseClass; // in cases, where BibShortCutHandler also has to be a window protected: inline BibShortCutHandler( vcl::Window* pBaseClass ); @@ -63,14 +63,12 @@ class BibSplitWindow : public SplitWindow, public BibShortCutHandler { public: BibSplitWindow( vcl::Window* pParent,WinBits nStyle = WB_3DLOOK); - virtual ~BibSplitWindow(); }; class BibTabPage : public TabPage, public BibShortCutHandler { public: BibTabPage( vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription ); - virtual ~BibTabPage(); }; #endif diff --git a/extensions/source/bibliography/bibview.cxx b/extensions/source/bibliography/bibview.cxx index 2d715d040d5a..dd13a1e2453d 100644 --- a/extensions/source/bibliography/bibview.cxx +++ b/extensions/source/bibliography/bibview.cxx @@ -52,16 +52,22 @@ namespace bib ,m_pDatMan( _pManager ) ,m_xDatMan( _pManager ) ,m_pGeneralPage( NULL ) + ,m_aFormControlContainer(this) { if ( m_xDatMan.is() ) - connectForm( m_xDatMan ); + m_aFormControlContainer.connectForm( m_xDatMan ); } BibView::~BibView() { + disposeOnce(); + } + + void BibView::dispose() + { BibGeneralPage* pGeneralPage = m_pGeneralPage; - m_pGeneralPage = NULL; + m_pGeneralPage.clear(); pGeneralPage->CommitActiveControl(); Reference< XForm > xForm = m_pDatMan->getForm(); @@ -92,11 +98,12 @@ namespace bib } } - if ( isFormConnected() ) - disconnectForm(); + if ( m_aFormControlContainer.isFormConnected() ) + m_aFormControlContainer.disconnectForm(); pGeneralPage->RemoveListeners(); m_xGeneralPage = NULL; + BibWindow::dispose(); } void BibView::UpdatePages() @@ -112,7 +119,8 @@ namespace bib m_xGeneralPage = 0; } - m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan ); + m_pGeneralPage = VclPtr<BibGeneralPage>::Create( this, m_pDatMan ); + m_xGeneralPage = &m_pGeneralPage->GetFocusListener(); m_pGeneralPage->Show(); if( HasFocus() ) @@ -133,11 +141,11 @@ namespace bib { sErrorString += "\n"; sErrorString += BIB_RESSTR(RID_MAP_QUESTION); - QueryBox aQuery( this, WB_YES_NO, sErrorString ); - aQuery.SetDefaultCheckBoxText(); - short nResult = aQuery.Execute(); + ScopedVclPtrInstance< QueryBox > aQuery(this, WB_YES_NO, sErrorString); + aQuery->SetDefaultCheckBoxText(); + short nResult = aQuery->Execute(); BibModul::GetConfig()->SetShowColumnAssignmentWarning( - !aQuery.GetCheckBoxState()); + !aQuery->GetCheckBoxState()); if( RET_YES != nResult ) { bExecute = false; @@ -150,18 +158,20 @@ namespace bib } } - void BibView::_loaded( const EventObject& _rEvent ) + BibViewFormControlContainer::BibViewFormControlContainer(BibView *pBibView) : mpBibView(pBibView) {} + + void BibViewFormControlContainer::_loaded( const EventObject& _rEvent ) { - UpdatePages(); + mpBibView->UpdatePages(); FormControlContainer::_loaded( _rEvent ); - Resize(); + mpBibView->Resize(); } - void BibView::_reloaded( const EventObject& _rEvent ) + void BibViewFormControlContainer::_reloaded( const EventObject& _rEvent ) { - UpdatePages(); + mpBibView->UpdatePages(); FormControlContainer::_loaded( _rEvent ); - Resize(); + mpBibView->Resize(); } IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG ) @@ -180,6 +190,11 @@ namespace bib Window::Resize(); } + Reference< awt::XControlContainer > BibViewFormControlContainer::getControlContainer() + { + return mpBibView->getControlContainer(); + } + Reference< awt::XControlContainer > BibView::getControlContainer() { Reference< awt::XControlContainer > xReturn; diff --git a/extensions/source/bibliography/bibview.hxx b/extensions/source/bibliography/bibview.hxx index add53d7c2bbe..1f797c6e990f 100644 --- a/extensions/source/bibliography/bibview.hxx +++ b/extensions/source/bibliography/bibview.hxx @@ -34,35 +34,48 @@ namespace bib { + class BibView; + class BibViewFormControlContainer : public FormControlContainer + { + private: + VclPtr<BibView> mpBibView; + protected: + // FormControlContainer + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > + getControlContainer() SAL_OVERRIDE; + // XLoadListener equivalents + virtual void _loaded( const ::com::sun::star::lang::EventObject& _rEvent ) SAL_OVERRIDE; + virtual void _reloaded( const ::com::sun::star::lang::EventObject& _rEvent ) SAL_OVERRIDE; + public: + using FormControlContainer::connectForm; + using FormControlContainer::disconnectForm; + using FormControlContainer::isFormConnected; + BibViewFormControlContainer(BibView *pBibView); + }; - class BibView : public BibWindow, public FormControlContainer + class BibView : public BibWindow { private: BibDataManager* m_pDatMan; ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable> m_xDatMan; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener> m_xGeneralPage; - BibGeneralPage* m_pGeneralPage; + VclPtr<BibGeneralPage> m_pGeneralPage; + BibViewFormControlContainer m_aFormControlContainer; private: DECL_STATIC_LINK(BibView, CallMappingHdl, BibView*); - protected: + public: // Window overridables - virtual void Resize() SAL_OVERRIDE; - - // FormControlContainer - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > - getControlContainer() SAL_OVERRIDE; - - // XLoadListener equivalents - virtual void _loaded( const ::com::sun::star::lang::EventObject& _rEvent ) SAL_OVERRIDE; - virtual void _reloaded( const ::com::sun::star::lang::EventObject& _rEvent ) SAL_OVERRIDE; + virtual void Resize() SAL_OVERRIDE; public: BibView( vcl::Window* _pParent, BibDataManager* _pDatMan, WinBits nStyle = WB_3DLOOK ); virtual ~BibView(); + virtual void dispose() SAL_OVERRIDE; void UpdatePages(); + css::uno::Reference< css::awt::XControlContainer > getControlContainer(); virtual void GetFocus() SAL_OVERRIDE; diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index 257d08d189e0..b6681c756320 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -197,39 +197,39 @@ Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm) class MappingDialog_Impl : public ModalDialog { BibDataManager* pDatMan; - OKButton* pOKBT; - ListBox* pIdentifierLB; - ListBox* pAuthorityTypeLB; - ListBox* pAuthorLB; - ListBox* pTitleLB; - ListBox* pMonthLB; - ListBox* pYearLB; - ListBox* pISBNLB; - ListBox* pBooktitleLB; - ListBox* pChapterLB; - ListBox* pEditionLB; - ListBox* pEditorLB; - ListBox* pHowpublishedLB; - ListBox* pInstitutionLB; - ListBox* pJournalLB; - ListBox* pNoteLB; - ListBox* pAnnoteLB; - ListBox* pNumberLB; - ListBox* pOrganizationsLB; - ListBox* pPagesLB; - ListBox* pPublisherLB; - ListBox* pAddressLB; - ListBox* pSchoolLB; - ListBox* pSeriesLB; - ListBox* pReportTypeLB; - ListBox* pVolumeLB; - ListBox* pURLLB; - ListBox* pCustom1LB; - ListBox* pCustom2LB; - ListBox* pCustom3LB; - ListBox* pCustom4LB; - ListBox* pCustom5LB; - ListBox* aListBoxes[COLUMN_COUNT]; + VclPtr<OKButton> pOKBT; + VclPtr<ListBox> pIdentifierLB; + VclPtr<ListBox> pAuthorityTypeLB; + VclPtr<ListBox> pAuthorLB; + VclPtr<ListBox> pTitleLB; + VclPtr<ListBox> pMonthLB; + VclPtr<ListBox> pYearLB; + VclPtr<ListBox> pISBNLB; + VclPtr<ListBox> pBooktitleLB; + VclPtr<ListBox> pChapterLB; + VclPtr<ListBox> pEditionLB; + VclPtr<ListBox> pEditorLB; + VclPtr<ListBox> pHowpublishedLB; + VclPtr<ListBox> pInstitutionLB; + VclPtr<ListBox> pJournalLB; + VclPtr<ListBox> pNoteLB; + VclPtr<ListBox> pAnnoteLB; + VclPtr<ListBox> pNumberLB; + VclPtr<ListBox> pOrganizationsLB; + VclPtr<ListBox> pPagesLB; + VclPtr<ListBox> pPublisherLB; + VclPtr<ListBox> pAddressLB; + VclPtr<ListBox> pSchoolLB; + VclPtr<ListBox> pSeriesLB; + VclPtr<ListBox> pReportTypeLB; + VclPtr<ListBox> pVolumeLB; + VclPtr<ListBox> pURLLB; + VclPtr<ListBox> pCustom1LB; + VclPtr<ListBox> pCustom2LB; + VclPtr<ListBox> pCustom3LB; + VclPtr<ListBox> pCustom4LB; + VclPtr<ListBox> pCustom5LB; + VclPtr<ListBox> aListBoxes[COLUMN_COUNT]; OUString sNone; bool bModified; @@ -242,6 +242,7 @@ class MappingDialog_Impl : public ModalDialog public: MappingDialog_Impl(vcl::Window* pParent, BibDataManager* pDatMan); virtual ~MappingDialog_Impl(); + virtual void dispose() SAL_OVERRIDE; void SetModified() {bModified = true;} @@ -378,7 +379,48 @@ MappingDialog_Impl::MappingDialog_Impl(vcl::Window* pParent, BibDataManager* pMa } MappingDialog_Impl::~MappingDialog_Impl() -{} +{ + disposeOnce(); +} + +void MappingDialog_Impl::dispose() +{ + pOKBT.clear(); + pIdentifierLB.clear(); + pAuthorityTypeLB.clear(); + pAuthorLB.clear(); + pTitleLB.clear(); + pMonthLB.clear(); + pYearLB.clear(); + pISBNLB.clear(); + pBooktitleLB.clear(); + pChapterLB.clear(); + pEditionLB.clear(); + pEditorLB.clear(); + pHowpublishedLB.clear(); + pInstitutionLB.clear(); + pJournalLB.clear(); + pNoteLB.clear(); + pAnnoteLB.clear(); + pNumberLB.clear(); + pOrganizationsLB.clear(); + pPagesLB.clear(); + pPublisherLB.clear(); + pAddressLB.clear(); + pSchoolLB.clear(); + pSeriesLB.clear(); + pReportTypeLB.clear(); + pVolumeLB.clear(); + pURLLB.clear(); + pCustom1LB.clear(); + pCustom2LB.clear(); + pCustom3LB.clear(); + pCustom4LB.clear(); + pCustom5LB.clear(); + for(auto & a : aListBoxes) + a.clear(); + ModalDialog::dispose(); +} IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox) { @@ -428,7 +470,7 @@ IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl) class DBChangeDialog_Impl : public ModalDialog { - ListBox* m_pSelectionLB; + VclPtr<ListBox> m_pSelectionLB; DBChangeDialogConfig_Impl aConfig; BibDataManager* pDatMan; @@ -437,6 +479,7 @@ class DBChangeDialog_Impl : public ModalDialog public: DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* pMan ); virtual ~DBChangeDialog_Impl(); + virtual void dispose() SAL_OVERRIDE; OUString GetCurrentURL()const; }; @@ -479,6 +522,13 @@ IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/) DBChangeDialog_Impl::~DBChangeDialog_Impl() { + disposeOnce(); +} + +void DBChangeDialog_Impl::dispose() +{ + m_pSelectionLB.clear(); + ModalDialog::dispose(); } OUString DBChangeDialog_Impl::GetCurrentURL()const @@ -1492,7 +1542,7 @@ void BibDataManager::RemoveMeAsUidListener() void BibDataManager::CreateMappingDialog(vcl::Window* pParent) { - boost::scoped_ptr<MappingDialog_Impl> pDlg(new MappingDialog_Impl(pParent, this)); + VclPtrInstance< MappingDialog_Impl > pDlg(pParent, this); if(RET_OK == pDlg->Execute() && pBibView) { reload(); @@ -1502,7 +1552,7 @@ void BibDataManager::CreateMappingDialog(vcl::Window* pParent) OUString BibDataManager::CreateDBChangeDialog(vcl::Window* pParent) { OUString uRet; - boost::scoped_ptr<DBChangeDialog_Impl> pDlg(new DBChangeDialog_Impl(pParent, this )); + VclPtrInstance< DBChangeDialog_Impl > pDlg(pParent, this ); if(RET_OK == pDlg->Execute()) { OUString sNewURL = pDlg->GetCurrentURL(); diff --git a/extensions/source/bibliography/datman.hxx b/extensions/source/bibliography/datman.hxx index 655644ed07fa..366c81f952d5 100644 --- a/extensions/source/bibliography/datman.hxx +++ b/extensions/source/bibliography/datman.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <cppuhelper/implbase1.hxx> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } @@ -100,8 +101,8 @@ private: ::cppu::OInterfaceContainerHelper m_aLoadListeners; - ::bib::BibView* pBibView; - BibToolBar* pToolbar; + VclPtr<::bib::BibView> pBibView; + VclPtr<BibToolBar> pToolbar; OUString sIdentifierMapping; protected: diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index a586fe69aa4c..563aa8a57067 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -25,6 +25,7 @@ #include <comphelper/sequence.hxx> #include "framectr.hxx" #include "datman.hxx" +#include "bibview.hxx" #include "bibresid.hxx" #include "bib.hrc" #include <toolkit/helper/vclunohelper.hxx> diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 238b1606d1e6..f84ab5855411 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -35,6 +35,7 @@ #include "bibprop.hrc" #include "bib.hrc" #include "bibmod.hxx" +#include "bibview.hxx" #include "bibtools.hxx" #include "bibliography.hrc" #include <tools/debug.hxx> @@ -69,7 +70,7 @@ static OUString lcl_GetColumnName( const Mapping* pMapping, sal_uInt16 nIndexPos class BibPosListener :public cppu::WeakImplHelper1 <sdbc::XRowSetListener> { - BibGeneralPage* pParentPage; + VclPtr<BibGeneralPage> pParentPage; public: BibPosListener(BibGeneralPage* pParent); @@ -167,6 +168,7 @@ void BibPosListener::disposing(const lang::EventObject& /*Source*/) throw( uno:: BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan): BibTabPage(pParent, "GeneralPage", "modules/sbibliography/ui/generalpage.ui"), sErrorPrefix(BIB_RESSTR(ST_ERROR_PREFIX)), + maBibGeneralPageFocusListener(this), pDatMan(pMan) { get(pIdentifierFT, "shortname"); @@ -340,12 +342,52 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan): BibGeneralPage::~BibGeneralPage() { + disposeOnce(); +} + +void BibGeneralPage::dispose() +{ if (pDatMan && xPosListener.is()) { uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY); if(xRowSet.is()) xRowSet->removeRowSetListener(xPosListener); } + pGrid.clear(); + pScrolledWindow.clear(); + pIdentifierFT.clear(); + pAuthTypeFT.clear(); + pYearFT.clear(); + pAuthorFT.clear(); + pTitleFT.clear(); + pPublisherFT.clear(); + pAddressFT.clear(); + pISBNFT.clear(); + pChapterFT.clear(); + pPagesFT.clear(); + pEditorFT.clear(); + pEditionFT.clear(); + pBooktitleFT.clear(); + pVolumeFT.clear(); + pHowpublishedFT.clear(); + pOrganizationsFT.clear(); + pInstitutionFT.clear(); + pSchoolFT.clear(); + pReportTypeFT.clear(); + pMonthFT.clear(); + pJournalFT.clear(); + pNumberFT.clear(); + pSeriesFT.clear(); + pAnnoteFT.clear(); + pNoteFT.clear(); + pURLFT.clear(); + pCustom1FT.clear(); + pCustom2FT.clear(); + pCustom3FT.clear(); + pCustom4FT.clear(); + pCustom5FT.clear(); + for (auto & a: aFixedTexts) a.clear(); + BibTabPage::dispose(); } void BibGeneralPage::RemoveListeners() @@ -355,7 +397,7 @@ void BibGeneralPage::RemoveListeners() if(aControls[i].is()) { uno::Reference< awt::XWindow > xCtrWin(aControls[i], uno::UNO_QUERY ); - xCtrWin->removeFocusListener( this ); + xCtrWin->removeFocusListener( &maBibGeneralPageFocusListener ); aControls[i] = 0; } } @@ -446,7 +488,7 @@ uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl( // Peer as Child to the FrameWindow xCtrlContnr->addControl(rName, xControl); uno::Reference< awt::XWindow > xCtrWin(xControl, UNO_QUERY ); - xCtrWin->addFocusListener( this ); + xCtrWin->addFocusListener( &maBibGeneralPageFocusListener ); rIndex = -1; // -> implies, that not found for(sal_uInt16 i = 0; i < FIELD_COUNT; i++) if(!aControls[i].is()) @@ -567,10 +609,6 @@ void BibGeneralPage::focusLost(const awt::FocusEvent& ) throw( uno::RuntimeExcep CommitActiveControl(); } -void BibGeneralPage::disposing(const lang::EventObject& /*Source*/) throw( uno::RuntimeException, std::exception ) -{ -} - void BibGeneralPage::GetFocus() { Reference< awt::XWindow >* pxControl = aControls; @@ -653,4 +691,20 @@ bool BibGeneralPage::HandleShortCutKey( const KeyEvent& rKeyEvent ) return bHandled; } +BibGeneralPageFocusListener::BibGeneralPageFocusListener(BibGeneralPage *pBibGeneralPage): mpBibGeneralPage(pBibGeneralPage) +{} + +void BibGeneralPageFocusListener::focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) +{ + mpBibGeneralPage->focusGained(e); +} + +void BibGeneralPageFocusListener::focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) +{ + mpBibGeneralPage->focusLost(e); +} + +void BibGeneralPageFocusListener::disposing( const ::com::sun::star::lang::EventObject& ) throw( com::sun::star::uno::RuntimeException, std::exception ) +{} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/bibliography/general.hxx b/extensions/source/bibliography/general.hxx index 2c0c17aaf5fe..e566c9f15e81 100644 --- a/extensions/source/bibliography/general.hxx +++ b/extensions/source/bibliography/general.hxx @@ -41,56 +41,70 @@ class BibDataManager; #define TYPE_COUNT 22 #define FIELD_COUNT 31 -typedef cppu::WeakAggImplHelper1 < ::com::sun::star::awt::XFocusListener > BibGeneralPageBaseClass; +/** + * We need to split off the listener because both it and the vcl::Window baseclass are ref-counted + */ +class BibGeneralPage; +class BibGeneralPageFocusListener : public cppu::WeakAggImplHelper1 < ::com::sun::star::awt::XFocusListener > +{ +private: + VclPtr<BibGeneralPage> mpBibGeneralPage; +public: + BibGeneralPageFocusListener(BibGeneralPage *pBibGeneralPage); + virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; -class BibGeneralPage: public BibGeneralPageBaseClass, public BibTabPage +}; + +class BibGeneralPage: public BibTabPage { - VclGrid* pGrid; - VclScrolledWindow* pScrolledWindow; + VclPtr<VclGrid> pGrid; + VclPtr<VclScrolledWindow> pScrolledWindow; - FixedText* pIdentifierFT; - FixedText* pAuthTypeFT; - FixedText* pYearFT; + VclPtr<FixedText> pIdentifierFT; + VclPtr<FixedText> pAuthTypeFT; + VclPtr<FixedText> pYearFT; - FixedText* pAuthorFT; - FixedText* pTitleFT; + VclPtr<FixedText> pAuthorFT; + VclPtr<FixedText> pTitleFT; - FixedText* pPublisherFT; - FixedText* pAddressFT; - FixedText* pISBNFT; + VclPtr<FixedText> pPublisherFT; + VclPtr<FixedText> pAddressFT; + VclPtr<FixedText> pISBNFT; - FixedText* pChapterFT; - FixedText* pPagesFT; + VclPtr<FixedText> pChapterFT; + VclPtr<FixedText> pPagesFT; - FixedText* pEditorFT; - FixedText* pEditionFT; + VclPtr<FixedText> pEditorFT; + VclPtr<FixedText> pEditionFT; - FixedText* pBooktitleFT; - FixedText* pVolumeFT; - FixedText* pHowpublishedFT; + VclPtr<FixedText> pBooktitleFT; + VclPtr<FixedText> pVolumeFT; + VclPtr<FixedText> pHowpublishedFT; - FixedText* pOrganizationsFT; - FixedText* pInstitutionFT; - FixedText* pSchoolFT; + VclPtr<FixedText> pOrganizationsFT; + VclPtr<FixedText> pInstitutionFT; + VclPtr<FixedText> pSchoolFT; - FixedText* pReportTypeFT; - FixedText* pMonthFT; + VclPtr<FixedText> pReportTypeFT; + VclPtr<FixedText> pMonthFT; - FixedText* pJournalFT; - FixedText* pNumberFT; - FixedText* pSeriesFT; + VclPtr<FixedText> pJournalFT; + VclPtr<FixedText> pNumberFT; + VclPtr<FixedText> pSeriesFT; - FixedText* pAnnoteFT; - FixedText* pNoteFT; - FixedText* pURLFT; + VclPtr<FixedText> pAnnoteFT; + VclPtr<FixedText> pNoteFT; + VclPtr<FixedText> pURLFT; - FixedText* pCustom1FT; - FixedText* pCustom2FT; - FixedText* pCustom3FT; - FixedText* pCustom4FT; - FixedText* pCustom5FT; + VclPtr<FixedText> pCustom1FT; + VclPtr<FixedText> pCustom2FT; + VclPtr<FixedText> pCustom3FT; + VclPtr<FixedText> pCustom4FT; + VclPtr<FixedText> pCustom5FT; - FixedText* aFixedTexts[ FIELD_COUNT ]; + VclPtr<FixedText> aFixedTexts[ FIELD_COUNT ]; sal_Int16 nFT2CtrlMap[ FIELD_COUNT ]; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > @@ -113,6 +127,7 @@ class BibGeneralPage: public BibGeneralPageBaseClass, public BibTabPage ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener > xPosListener; + BibGeneralPageFocusListener maBibGeneralPageFocusListener; BibDataManager* pDatMan; @@ -130,6 +145,7 @@ protected: public: BibGeneralPage(vcl::Window* pParent, BibDataManager* pDatMan); virtual ~BibGeneralPage(); + virtual void dispose() SAL_OVERRIDE; inline const OUString& GetErrorString() const; @@ -142,16 +158,17 @@ public: void CommitActiveControl(); - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; - - void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; - void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; - void RemoveListeners(); virtual void GetFocus() SAL_OVERRIDE; virtual bool HandleShortCutKey( const KeyEvent& rKeyEvent ) SAL_OVERRIDE; // returns true, if key was handled + + inline BibGeneralPageFocusListener& GetFocusListener() { return maBibGeneralPageFocusListener; } + + void focusGained(const css::awt::FocusEvent& rEvent) throw( css::uno::RuntimeException, std::exception ); + void focusLost(const css::awt::FocusEvent& rEvent) throw( css::uno::RuntimeException, std::exception ); + }; diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx index 66ed1ca4bea9..f6db18010275 100644 --- a/extensions/source/bibliography/toolbar.cxx +++ b/extensions/source/bibliography/toolbar.cxx @@ -31,6 +31,7 @@ #include <vcl/settings.hxx> #include <vcl/mnemonic.hxx> #include "bibbeam.hxx" +#include "bibview.hxx" #include "toolbar.hrc" #include "bibresid.hxx" @@ -179,10 +180,10 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink, WinBits nStyle): ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)), aImgLst(BibResId( RID_TOOLBAR_IMGLIST )), aBigImgLst(BibResId( RID_TOOLBAR_BIGIMGLIST )), - aFtSource(this,WB_VCENTER), - aLBSource(this,WB_DROPDOWN), - aFtQuery(this,WB_VCENTER), - aEdQuery(this), + aFtSource(VclPtr<FixedText>::Create(this,WB_VCENTER)), + aLBSource(VclPtr<ListBox>::Create(this,WB_DROPDOWN)), + aFtQuery(VclPtr<FixedText>::Create(this,WB_VCENTER)), + aEdQuery(VclPtr<Edit>::Create(this)), nMenuId(0), nSelMenuItem(0), aLayoutManager( aLink ), @@ -198,10 +199,10 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink, WinBits nStyle): SetOutStyle(TOOLBOX_STYLE_FLAT); Size a2Size(GetOutputSizePixel()); a2Size.Width()=100; - aLBSource.SetSizePixel(a2Size); - aLBSource.SetDropDownLineCount(9); - aLBSource.Show(); - aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl)); + aLBSource->SetSizePixel(a2Size); + aLBSource->SetDropDownLineCount(9); + aLBSource->Show(); + aLBSource->SetSelectHdl(LINK( this, BibToolBar, SelHdl)); SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); @@ -211,32 +212,42 @@ BibToolBar::BibToolBar(vcl::Window* pParent, Link aLink, WinBits nStyle): SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl)); - aEdQuery.SetSizePixel(aLBSource.GetSizePixel()); - aEdQuery.Show(); + aEdQuery->SetSizePixel(aLBSource->GetSizePixel()); + aEdQuery->Show(); OUString aStr=GetItemText(TBC_FT_SOURCE); - aFtSource.SetText(aStr); - aFtSource.SetSizePixel(aFtSource.get_preferred_size()); - aFtSource.SetBackground(Wallpaper( COL_TRANSPARENT )); + aFtSource->SetText(aStr); + aFtSource->SetSizePixel(aFtSource->get_preferred_size()); + aFtSource->SetBackground(Wallpaper( COL_TRANSPARENT )); aStr=GetItemText(TBC_FT_QUERY); - aFtQuery.SetText(aStr); - aFtQuery.SetSizePixel(aFtQuery.get_preferred_size()); - aFtQuery.SetBackground(Wallpaper( COL_TRANSPARENT )); + aFtQuery->SetText(aStr); + aFtQuery->SetSizePixel(aFtQuery->get_preferred_size()); + aFtQuery->SetBackground(Wallpaper( COL_TRANSPARENT )); - SetItemWindow(TBC_FT_SOURCE,&aFtSource); - SetItemWindow(TBC_LB_SOURCE,&aLBSource); - SetItemWindow(TBC_FT_QUERY ,&aFtQuery); - SetItemWindow(TBC_ED_QUERY ,&aEdQuery); + SetItemWindow(TBC_FT_SOURCE, aFtSource.get()); + SetItemWindow(TBC_LB_SOURCE, aLBSource.get()); + SetItemWindow(TBC_FT_QUERY , aFtQuery.get()); + SetItemWindow(TBC_ED_QUERY , aEdQuery.get()); ::bib::AddToTaskPaneList( this ); } BibToolBar::~BibToolBar() { + disposeOnce(); +} + +void BibToolBar::dispose() +{ SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) ); Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) ); ::bib::RemoveFromTaskPaneList( this ); + aFtSource.disposeAndClear(); + aFtQuery.disposeAndClear(); + aEdQuery.disposeAndClear(); + aLBSource.disposeAndClear(); + ToolBox::dispose(); } void BibToolBar::InitListener() @@ -308,7 +319,7 @@ void BibToolBar::Select() Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name="QueryText"; - OUString aSelection = aEdQuery.GetText(); + OUString aSelection = aEdQuery->GetText(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; @@ -386,39 +397,39 @@ void BibToolBar::SelectFilterItem(sal_uInt16 nId) void BibToolBar::EnableSourceList(bool bFlag) { - aFtSource.Enable(bFlag); - aLBSource.Enable(bFlag); + aFtSource->Enable(bFlag); + aLBSource->Enable(bFlag); } void BibToolBar::ClearSourceList() { - aLBSource.Clear(); + aLBSource->Clear(); } void BibToolBar::UpdateSourceList(bool bFlag) { - aLBSource.SetUpdateMode(bFlag); + aLBSource->SetUpdateMode(bFlag); } void BibToolBar::InsertSourceEntry(const OUString& aEntry, sal_Int32 nPos) { - aLBSource.InsertEntry(aEntry, nPos); + aLBSource->InsertEntry(aEntry, nPos); } void BibToolBar::SelectSourceEntry(const OUString& aStr) { - aLBSource.SelectEntry(aStr); + aLBSource->SelectEntry(aStr); } void BibToolBar::EnableQuery(bool bFlag) { - aFtQuery.Enable(bFlag); - aEdQuery.Enable(bFlag); + aFtQuery->Enable(bFlag); + aEdQuery->Enable(bFlag); } void BibToolBar::SetQueryString(const OUString& aStr) { - aEdQuery.SetText(aStr); + aEdQuery->SetText(aStr); } @@ -427,7 +438,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt ) bool nResult = true; MouseNotifyEvent nSwitch=rNEvt.GetType(); - if(aEdQuery.HasFocus() && nSwitch==MouseNotifyEvent::KEYINPUT) + if(aEdQuery->HasFocus() && nSwitch==MouseNotifyEvent::KEYINPUT) { const vcl::KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); sal_uInt16 nKey = aKeyCode.GetCode(); @@ -436,7 +447,7 @@ bool BibToolBar::PreNotify( NotifyEvent& rNEvt ) Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "QueryText"; - OUString aSelection = aEdQuery.GetText(); + OUString aSelection = aEdQuery->GetText(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; pPropertyVal[1].Value <<= aQueryField; @@ -462,7 +473,7 @@ IMPL_LINK( BibToolBar, SendSelHdl, Timer*,/*pT*/) Sequence<PropertyValue> aPropVal(1); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "DataSourceName"; - OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) ); + OUString aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource->GetSelectEntry() ) ); OUString aSelection = aEntry; pPropertyVal[0].Value <<= aSelection; SendDispatch(TBC_LB_SOURCE,aPropVal); @@ -490,7 +501,7 @@ IMPL_LINK( BibToolBar, MenuHdl, ToolBox*, /*pToolbox*/) Sequence<PropertyValue> aPropVal(2); PropertyValue* pPropertyVal = const_cast<PropertyValue*>(aPropVal.getConstArray()); pPropertyVal[0].Name = "QueryText"; - OUString aSelection = aEdQuery.GetText(); + OUString aSelection = aEdQuery->GetText(); pPropertyVal[0].Value <<= aSelection; pPropertyVal[1].Name="QueryField"; pPropertyVal[1].Value <<= aQueryField; diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx index 177fc0b195df..f7eef64155bd 100644 --- a/extensions/source/bibliography/toolbar.hxx +++ b/extensions/source/bibliography/toolbar.hxx @@ -39,12 +39,12 @@ class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame { private: - sal_uInt16 nIndex; + sal_uInt16 nIndex; OUString aCommand; protected: - BibToolBar *pToolBar; + VclPtr<BibToolBar> pToolBar; public: @@ -109,20 +109,20 @@ class BibToolBar: public ToolBox private: BibToolBarListenerArr aListenerArr; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController; + css::uno::Reference< css::frame::XController > xController; Idle aIdle; ImageList aImgLst; ImageList aImgLstHC; ImageList aBigImgLst; ImageList aBigImgLstHC; - FixedText aFtSource; - ListBox aLBSource; - FixedText aFtQuery; - Edit aEdQuery; + VclPtr<FixedText> aFtSource; + VclPtr<ListBox> aLBSource; + VclPtr<FixedText> aFtQuery; + VclPtr<Edit> aEdQuery; PopupMenu aPopupMenu; sal_uInt16 nMenuId; sal_uInt16 nSelMenuItem; - OUString aQueryField; + OUString aQueryField; Link aLayoutManager; sal_Int16 nSymbolsSize; sal_Int16 nOutStyle; @@ -150,6 +150,7 @@ class BibToolBar: public ToolBox BibToolBar(vcl::Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK ); virtual ~BibToolBar(); + virtual void dispose() SAL_OVERRIDE; void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &); diff --git a/extensions/source/dbpilots/commonpagesdbp.cxx b/extensions/source/dbpilots/commonpagesdbp.cxx index 5a9817164ca0..5c730601a17c 100644 --- a/extensions/source/dbpilots/commonpagesdbp.cxx +++ b/extensions/source/dbpilots/commonpagesdbp.cxx @@ -77,6 +77,19 @@ namespace dbp m_pDatasource->SetDropDownLineCount(10); } + OTableSelectionPage::~OTableSelectionPage() + { + disposeOnce(); + } + + void OTableSelectionPage::dispose() + { + m_pDatasourceLabel.clear(); + m_pDatasource.clear(); + m_pSearchDatabase.clear(); + m_pTable.clear(); + OControlWizardPage::dispose(); + } void OTableSelectionPage::ActivatePage() { @@ -383,6 +396,19 @@ namespace dbp { } + OMaybeListSelectionPage::~OMaybeListSelectionPage() + { + disposeOnce(); + } + + void OMaybeListSelectionPage::dispose() + { + m_pYes.clear(); + m_pNo.clear(); + m_pList.clear(); + OControlWizardPage::dispose(); + } + void OMaybeListSelectionPage::announceControls(RadioButton& _rYesButton, RadioButton& _rNoButton, ListBox& _rSelection) { m_pYes = &_rYesButton; @@ -453,6 +479,19 @@ namespace dbp m_pStoreWhere->SetDropDownLineCount(10); } + ODBFieldPage::~ODBFieldPage() + { + disposeOnce(); + } + + void ODBFieldPage::dispose() + { + m_pDescription.clear(); + m_pStoreYes.clear(); + m_pStoreNo.clear(); + m_pStoreWhere.clear(); + OMaybeListSelectionPage::dispose(); + } void ODBFieldPage::initializePage() { diff --git a/extensions/source/dbpilots/commonpagesdbp.hxx b/extensions/source/dbpilots/commonpagesdbp.hxx index 8d9d9c801d3f..1ff1d51b4601 100644 --- a/extensions/source/dbpilots/commonpagesdbp.hxx +++ b/extensions/source/dbpilots/commonpagesdbp.hxx @@ -36,16 +36,18 @@ namespace dbp class OTableSelectionPage : public OControlWizardPage { protected: - FixedText *m_pDatasourceLabel; - ListBox *m_pDatasource; - PushButton *m_pSearchDatabase; - ListBox *m_pTable; + VclPtr<FixedText> m_pDatasourceLabel; + VclPtr<ListBox> m_pDatasource; + VclPtr<PushButton> m_pSearchDatabase; + VclPtr<ListBox> m_pTable; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseContext > m_xDSContext; public: OTableSelectionPage(OControlWizard* _pParent); + virtual ~OTableSelectionPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables @@ -74,12 +76,14 @@ namespace dbp class OMaybeListSelectionPage : public OControlWizardPage { protected: - RadioButton* m_pYes; - RadioButton* m_pNo; - ListBox* m_pList; + VclPtr<RadioButton> m_pYes; + VclPtr<RadioButton> m_pNo; + VclPtr<ListBox> m_pList; public: OMaybeListSelectionPage( OControlWizard* _pParent, const OString& _rID, const OUString& _rUIXMLDescription ); + virtual ~OMaybeListSelectionPage(); + virtual void dispose() SAL_OVERRIDE; protected: DECL_LINK( OnRadioSelected, RadioButton* ); @@ -105,13 +109,15 @@ namespace dbp class ODBFieldPage : public OMaybeListSelectionPage { protected: - FixedText* m_pDescription; - RadioButton* m_pStoreYes; - RadioButton* m_pStoreNo; - ListBox* m_pStoreWhere; + VclPtr<FixedText> m_pDescription; + VclPtr<RadioButton> m_pStoreYes; + VclPtr<RadioButton> m_pStoreNo; + VclPtr<ListBox> m_pStoreWhere; public: ODBFieldPage( OControlWizard* _pParent ); + virtual ~ODBFieldPage(); + virtual void dispose() SAL_OVERRIDE; protected: void setDescriptionText(const OUString& _rDesc) { m_pDescription->SetText(_rDesc); } diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx index c3f8c025d20c..9128bbbf4589 100644 --- a/extensions/source/dbpilots/controlwizard.cxx +++ b/extensions/source/dbpilots/controlwizard.cxx @@ -86,6 +86,18 @@ namespace dbp OControlWizardPage::~OControlWizardPage() { + disposeOnce(); + } + + void OControlWizardPage::dispose() + { + m_pFormDatasourceLabel.clear(); + m_pFormDatasource.clear(); + m_pFormContentTypeLabel.clear(); + m_pFormContentType.clear(); + m_pFormTableLabel.clear(); + m_pFormTable.clear(); + OControlWizardPage_Base::dispose(); } OControlWizard* OControlWizardPage::getDialog() diff --git a/extensions/source/dbpilots/controlwizard.hxx b/extensions/source/dbpilots/controlwizard.hxx index 879520db1c99..529e94bb25c4 100644 --- a/extensions/source/dbpilots/controlwizard.hxx +++ b/extensions/source/dbpilots/controlwizard.hxx @@ -57,12 +57,12 @@ namespace dbp class OControlWizardPage : public OControlWizardPage_Base { protected: - FixedText* m_pFormDatasourceLabel; - FixedText* m_pFormDatasource; - FixedText* m_pFormContentTypeLabel; - FixedText* m_pFormContentType; - FixedText* m_pFormTableLabel; - FixedText* m_pFormTable; + VclPtr<FixedText> m_pFormDatasourceLabel; + VclPtr<FixedText> m_pFormDatasource; + VclPtr<FixedText> m_pFormContentTypeLabel; + VclPtr<FixedText> m_pFormContentType; + VclPtr<FixedText> m_pFormTableLabel; + VclPtr<FixedText> m_pFormTable; protected: OControlWizard* getDialog(); @@ -75,6 +75,7 @@ namespace dbp public: OControlWizardPage( OControlWizard* _pParent, const OString& rID, const OUString& rUIXMLDescription ); virtual ~OControlWizardPage(); + virtual void dispose() SAL_OVERRIDE; protected: static void fillListBox( diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx index 882847b0f99f..aec86cd649ca 100644 --- a/extensions/source/dbpilots/gridwizard.cxx +++ b/extensions/source/dbpilots/gridwizard.cxx @@ -228,17 +228,16 @@ namespace dbp } - OWizardPage* OGridWizard::createPage(WizardState _nState) + VclPtr<TabPage> OGridWizard::createPage(WizardState _nState) { switch (_nState) { case GW_STATE_DATASOURCE_SELECTION: - return new OTableSelectionPage(this); + return VclPtr<OTableSelectionPage>::Create(this); case GW_STATE_FIELDSELECTION: - return new OGridFieldsSelection(this); + return VclPtr<OGridFieldsSelection>::Create(this); } - - return NULL; + return VclPtr<TabPage>(); } @@ -319,6 +318,21 @@ namespace dbp m_pSelFields->SetDoubleClickHdl(LINK(this, OGridFieldsSelection, OnEntryDoubleClicked)); } + OGridFieldsSelection::~OGridFieldsSelection() + { + disposeOnce(); + } + + void OGridFieldsSelection::dispose() + { + m_pExistFields.clear(); + m_pSelectOne.clear(); + m_pSelectAll.clear(); + m_pDeselectOne.clear(); + m_pDeselectAll.clear(); + m_pSelFields.clear(); + OGridPage::dispose(); + } void OGridFieldsSelection::ActivatePage() { diff --git a/extensions/source/dbpilots/gridwizard.hxx b/extensions/source/dbpilots/gridwizard.hxx index 91da2fd5bee7..9c66ae9e72cd 100644 --- a/extensions/source/dbpilots/gridwizard.hxx +++ b/extensions/source/dbpilots/gridwizard.hxx @@ -56,7 +56,7 @@ namespace dbp protected: // OWizardMachine overridables - virtual ::svt::OWizardPage* createPage( WizardState _nState ) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage( WizardState _nState ) SAL_OVERRIDE; virtual WizardState determineNextState( WizardState _nCurrentState ) const SAL_OVERRIDE; virtual void enterState( WizardState _nState ) SAL_OVERRIDE; virtual bool leaveState( WizardState _nState ) SAL_OVERRIDE; @@ -82,15 +82,17 @@ namespace dbp class OGridFieldsSelection : public OGridPage { protected: - ListBox *m_pExistFields; - PushButton *m_pSelectOne; - PushButton *m_pSelectAll; - PushButton *m_pDeselectOne; - PushButton *m_pDeselectAll; - ListBox *m_pSelFields; + VclPtr<ListBox> m_pExistFields; + VclPtr<PushButton> m_pSelectOne; + VclPtr<PushButton> m_pSelectAll; + VclPtr<PushButton> m_pDeselectOne; + VclPtr<PushButton> m_pDeselectAll; + VclPtr<ListBox> m_pSelFields; public: OGridFieldsSelection( OGridWizard* _pParent ); + virtual ~OGridFieldsSelection(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx index 2f165addf0cf..fbcaa668990b 100644 --- a/extensions/source/dbpilots/groupboxwiz.cxx +++ b/extensions/source/dbpilots/groupboxwiz.cxx @@ -69,24 +69,24 @@ namespace dbp } - OWizardPage* OGroupBoxWizard::createPage(::svt::WizardTypes::WizardState _nState) + VclPtr<TabPage> OGroupBoxWizard::createPage(::svt::WizardTypes::WizardState _nState) { switch (_nState) { case GBW_STATE_OPTIONLIST: - return new ORadioSelectionPage(this); + return VclPtr<ORadioSelectionPage>::Create(this); case GBW_STATE_DEFAULTOPTION: - return new ODefaultFieldSelectionPage(this); + return VclPtr<ODefaultFieldSelectionPage>::Create(this); case GBW_STATE_OPTIONVALUES: - return new OOptionValuesPage(this); + return VclPtr<OOptionValuesPage>::Create(this); case GBW_STATE_DBFIELD: - return new OOptionDBFieldPage(this); + return VclPtr<OOptionDBFieldPage>::Create(this); case GBW_STATE_FINALIZE: - return new OFinalizeGBWPage(this); + return VclPtr<OFinalizeGBWPage>::Create(this); } return NULL; @@ -207,11 +207,24 @@ namespace dbp implCheckMoveButtons(); m_pExistingRadios->EnableMultiSelection(true); - getDialog()->defaultButton(m_pMoveRight); + getDialog()->defaultButton(m_pMoveRight.get()); m_pExistingRadios->SetAccessibleRelationMemberOf(m_pExistingRadios); } + ORadioSelectionPage::~ORadioSelectionPage() + { + disposeOnce(); + } + + void ORadioSelectionPage::dispose() + { + m_pRadioName.clear(); + m_pMoveRight.clear(); + m_pMoveLeft.clear(); + m_pExistingRadios.clear(); + OGBWPage::dispose(); + } void ORadioSelectionPage::ActivatePage() { @@ -315,7 +328,7 @@ namespace dbp if (bUnfinishedInput) { if (0 == (m_pMoveRight->GetStyle() & WB_DEFBUTTON)) - getDialog()->defaultButton(m_pMoveRight); + getDialog()->defaultButton(m_pMoveRight.get()); } else { @@ -341,6 +354,18 @@ namespace dbp m_pDefSelection->SetStyle(WB_DROPDOWN); } + ODefaultFieldSelectionPage::~ODefaultFieldSelectionPage() + { + disposeOnce(); + } + + void ODefaultFieldSelectionPage::dispose() + { + m_pDefSelYes.clear(); + m_pDefSelNo.clear(); + m_pDefSelection.clear(); + OMaybeListSelectionPage::dispose(); + } void ODefaultFieldSelectionPage::initializePage() { @@ -388,6 +413,17 @@ namespace dbp m_pOptions->SetAccessibleRelationMemberOf(m_pOptions); } + OOptionValuesPage::~OOptionValuesPage() + { + disposeOnce(); + } + + void OOptionValuesPage::dispose() + { + m_pValue.clear(); + m_pOptions.clear(); + OGBWPage::dispose(); + } IMPL_LINK( OOptionValuesPage, OnOptionSelected, ListBox*, /*NOTINTERESTEDIN*/ ) { @@ -486,6 +522,16 @@ namespace dbp get(m_pName, "nameit"); } + OFinalizeGBWPage::~OFinalizeGBWPage() + { + disposeOnce(); + } + + void OFinalizeGBWPage::dispose() + { + m_pName.clear(); + OGBWPage::dispose(); + } void OFinalizeGBWPage::ActivatePage() { diff --git a/extensions/source/dbpilots/groupboxwiz.hxx b/extensions/source/dbpilots/groupboxwiz.hxx index e37840f88216..9413628bcc88 100644 --- a/extensions/source/dbpilots/groupboxwiz.hxx +++ b/extensions/source/dbpilots/groupboxwiz.hxx @@ -62,7 +62,7 @@ namespace dbp protected: // OWizardMachine overridables - virtual ::svt::OWizardPage* createPage( WizardState _nState ) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage( WizardState _nState ) SAL_OVERRIDE; virtual WizardState determineNextState( WizardState _nCurrentState ) const SAL_OVERRIDE; virtual void enterState( WizardState _nState ) SAL_OVERRIDE; virtual bool onFinish() SAL_OVERRIDE; @@ -94,13 +94,15 @@ namespace dbp class ORadioSelectionPage : public OGBWPage { protected: - Edit *m_pRadioName; - PushButton *m_pMoveRight; - PushButton *m_pMoveLeft; - ListBox *m_pExistingRadios; + VclPtr<Edit> m_pRadioName; + VclPtr<PushButton> m_pMoveRight; + VclPtr<PushButton> m_pMoveLeft; + VclPtr<ListBox> m_pExistingRadios; public: ORadioSelectionPage( OControlWizard* _pParent ); + virtual ~ORadioSelectionPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables @@ -124,12 +126,14 @@ namespace dbp class ODefaultFieldSelectionPage : public OMaybeListSelectionPage { protected: - RadioButton *m_pDefSelYes; - RadioButton *m_pDefSelNo; - ListBox *m_pDefSelection; + VclPtr<RadioButton> m_pDefSelYes; + VclPtr<RadioButton> m_pDefSelNo; + VclPtr<ListBox> m_pDefSelection; public: ODefaultFieldSelectionPage( OControlWizard* _pParent ); + virtual ~ODefaultFieldSelectionPage(); + virtual void dispose() SAL_OVERRIDE; protected: // OWizardPage overridables @@ -145,8 +149,8 @@ namespace dbp class OOptionValuesPage : public OGBWPage { protected: - Edit *m_pValue; - ListBox *m_pOptions; + VclPtr<Edit> m_pValue; + VclPtr<ListBox> m_pOptions; StringArray m_aUncommittedValues; ::svt::WizardTypes::WizardState @@ -154,6 +158,8 @@ namespace dbp public: OOptionValuesPage( OControlWizard* _pParent ); + virtual ~OOptionValuesPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables @@ -189,10 +195,12 @@ namespace dbp class OFinalizeGBWPage : public OGBWPage { protected: - Edit *m_pName; + VclPtr<Edit> m_pName; public: OFinalizeGBWPage( OControlWizard* _pParent ); + virtual ~OFinalizeGBWPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables diff --git a/extensions/source/dbpilots/listcombowizard.cxx b/extensions/source/dbpilots/listcombowizard.cxx index 6349c0796c58..0173584e3455 100644 --- a/extensions/source/dbpilots/listcombowizard.cxx +++ b/extensions/source/dbpilots/listcombowizard.cxx @@ -88,23 +88,23 @@ namespace dbp } - OWizardPage* OListComboWizard::createPage(WizardState _nState) + VclPtr<TabPage> OListComboWizard::createPage(WizardState _nState) { switch (_nState) { case LCW_STATE_DATASOURCE_SELECTION: - return new OTableSelectionPage(this); + return VclPtr<OTableSelectionPage>::Create(this); case LCW_STATE_TABLESELECTION: - return new OContentTableSelection(this); + return VclPtr<OContentTableSelection>::Create(this); case LCW_STATE_FIELDSELECTION: - return new OContentFieldSelection(this); + return VclPtr<OContentFieldSelection>::Create(this); case LCW_STATE_FIELDLINK: - return new OLinkFieldsPage(this); + return VclPtr<OLinkFieldsPage>::Create(this); case LCW_STATE_COMBODBFIELD: - return new OComboDBFieldPage(this); + return VclPtr<OComboDBFieldPage>::Create(this); } - return NULL; + return VclPtr<TabPage>(); } @@ -285,6 +285,16 @@ namespace dbp m_pSelectTable->SetSelectHdl(LINK(this, OContentTableSelection, OnTableSelected)); } + OContentTableSelection::~OContentTableSelection() + { + disposeOnce(); + } + + void OContentTableSelection::dispose() + { + m_pSelectTable.clear(); + OLCPage::dispose(); + } void OContentTableSelection::ActivatePage() { @@ -369,6 +379,18 @@ namespace dbp m_pSelectTableField->SetDoubleClickHdl(LINK(this, OContentFieldSelection, OnTableDoubleClicked)); } + OContentFieldSelection::~OContentFieldSelection() + { + disposeOnce(); + } + + void OContentFieldSelection::dispose() + { + m_pSelectTableField.clear(); + m_pDisplayedField.clear(); + m_pInfo.clear(); + OLCPage::dispose(); + } void OContentFieldSelection::ActivatePage() { @@ -439,6 +461,17 @@ namespace dbp m_pTableField->SetSelectHdl(LINK(this, OLinkFieldsPage, OnSelectionModified)); } + OLinkFieldsPage::~OLinkFieldsPage() + { + disposeOnce(); + } + + void OLinkFieldsPage::dispose() + { + m_pValueListField.clear(); + m_pTableField.clear(); + OLCPage::dispose(); + } void OLinkFieldsPage::ActivatePage() { diff --git a/extensions/source/dbpilots/listcombowizard.hxx b/extensions/source/dbpilots/listcombowizard.hxx index 6d4908cdda5c..ec28093479ce 100644 --- a/extensions/source/dbpilots/listcombowizard.hxx +++ b/extensions/source/dbpilots/listcombowizard.hxx @@ -68,7 +68,7 @@ namespace dbp protected: // OWizardMachine overridables - virtual ::svt::OWizardPage* createPage( WizardState _nState ) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage( WizardState _nState ) SAL_OVERRIDE; virtual WizardState determineNextState( WizardState _nCurrentState ) const SAL_OVERRIDE; virtual void enterState( WizardState _nState ) SAL_OVERRIDE; virtual bool leaveState( WizardState _nState ) SAL_OVERRIDE; @@ -108,10 +108,12 @@ namespace dbp class OContentTableSelection : public OLCPage { protected: - ListBox *m_pSelectTable; + VclPtr<ListBox> m_pSelectTable; public: OContentTableSelection( OListComboWizard* _pParent ); + virtual ~OContentTableSelection(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables @@ -133,13 +135,15 @@ namespace dbp class OContentFieldSelection : public OLCPage { protected: - ListBox *m_pSelectTableField; - Edit *m_pDisplayedField; - FixedText *m_pInfo; + VclPtr<ListBox> m_pSelectTableField; + VclPtr<Edit> m_pDisplayedField; + VclPtr<FixedText> m_pInfo; public: OContentFieldSelection( OListComboWizard* _pParent ); + virtual ~OContentFieldSelection(); + virtual void dispose() SAL_OVERRIDE; protected: DECL_LINK( OnFieldSelected, ListBox* ); @@ -160,12 +164,14 @@ namespace dbp class OLinkFieldsPage : public OLCPage { protected: - ComboBox *m_pValueListField; - ComboBox *m_pTableField; + VclPtr<ComboBox> m_pValueListField; + VclPtr<ComboBox> m_pTableField; public: OLinkFieldsPage( OListComboWizard* _pParent ); + virtual ~OLinkFieldsPage(); + virtual void dispose() SAL_OVERRIDE; protected: // TabPage overridables diff --git a/extensions/source/dbpilots/unoautopilot.hxx b/extensions/source/dbpilots/unoautopilot.hxx index c70597fca7d5..0e669efb8af9 100644 --- a/extensions/source/dbpilots/unoautopilot.hxx +++ b/extensions/source/dbpilots/unoautopilot.hxx @@ -85,7 +85,7 @@ namespace dbp protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; virtual void implInitialize(const com::sun::star::uno::Any& _rValue) SAL_OVERRIDE; }; diff --git a/extensions/source/dbpilots/unoautopilot.inl b/extensions/source/dbpilots/unoautopilot.inl index 77f3cf6e795d..55e5861f3595 100644 --- a/extensions/source/dbpilots/unoautopilot.inl +++ b/extensions/source/dbpilots/unoautopilot.inl @@ -96,9 +96,9 @@ template <class TYPE, class SERVICEINFO> template <class TYPE, class SERVICEINFO> -Dialog* OUnoAutoPilot<TYPE, SERVICEINFO>::createDialog(::vcl::Window* _pParent) +VclPtr<Dialog> OUnoAutoPilot<TYPE, SERVICEINFO>::createDialog(::vcl::Window* _pParent) { - return new TYPE(_pParent, m_xObjectModel, m_aContext); + return VclPtr<TYPE>::Create(_pParent, m_xObjectModel, m_aContext); } diff --git a/extensions/source/plugin/base/plctrl.cxx b/extensions/source/plugin/base/plctrl.cxx index 6ad9fdd5aa5b..4276ba98eb01 100644 --- a/extensions/source/plugin/base/plctrl.cxx +++ b/extensions/source/plugin/base/plctrl.cxx @@ -169,7 +169,7 @@ void PluginControl_Impl::createPeer( const Reference< ::com::sun::star::awt::XTo vcl::Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer ); if (pImpl) { - _pSysChild = new SystemChildWindow( pImpl, WB_CLIPCHILDREN ); + _pSysChild = VclPtr<SystemChildWindow>::Create( pImpl, WB_CLIPCHILDREN ); if (pImpl->HasFocus()) _pSysChild->GrabFocus(); diff --git a/extensions/source/plugin/inc/plugin/plctrl.hxx b/extensions/source/plugin/inc/plugin/plctrl.hxx index 0684a9a6fe20..2a0db6ff7bda 100644 --- a/extensions/source/plugin/inc/plugin/plctrl.hxx +++ b/extensions/source/plugin/inc/plugin/plctrl.hxx @@ -60,6 +60,7 @@ #include <com/sun/star/awt/PosSize.hpp> #include <cppuhelper/implbase4.hxx> +#include <vcl/vclptr.hxx> #include <list> @@ -152,9 +153,9 @@ protected: protected: ::std::list< Reference< ::com::sun::star::lang::XEventListener > > _aDisposeListeners; - MRCListenerMultiplexerHelper* _pMultiplexer; + MRCListenerMultiplexerHelper* _pMultiplexer; - Reference< XInterface > _xContext; + Reference< XInterface > _xContext; sal_Int32 _nX; sal_Int32 _nY; @@ -162,11 +163,11 @@ protected: sal_Int32 _nHeight; sal_Int16 _nFlags; - bool _bVisible; - bool _bInDesignMode; - bool _bEnable; + bool _bVisible; + bool _bInDesignMode; + bool _bEnable; - SystemChildWindow* _pSysChild; + VclPtr<SystemChildWindow> _pSysChild; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > _xPeer; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > _xPeerWindow; diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx index 8f7f24b9d5cd..7803b2951f20 100644 --- a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx +++ b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx @@ -103,9 +103,9 @@ namespace pcr } - Dialog* MasterDetailLinkDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> MasterDetailLinkDialog::createDialog(vcl::Window* _pParent) { - return new FormLinkDialog(_pParent,m_xDetail,m_xMaster, m_aContext + return VclPtr<FormLinkDialog>::Create(_pParent,m_xDetail,m_xMaster, m_aContext ,m_sExplanation,m_sDetailLabel,m_sMasterLabel); } diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx index 28a6ddfa7875..a00f852028b2 100644 --- a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx +++ b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx @@ -60,7 +60,7 @@ namespace pcr virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; virtual void implInitialize(const com::sun::star::uno::Any& _rValue) SAL_OVERRIDE; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xDetail; diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx index bd0b335f6af7..174c01eef667 100644 --- a/extensions/source/propctrlr/browserline.cxx +++ b/extensions/source/propctrlr/browserline.cxx @@ -55,7 +55,7 @@ namespace pcr OBrowserLine::OBrowserLine( const OUString& _rEntryName, vcl::Window* pParent ) :m_sEntryName( _rEntryName ) - ,m_aFtTitle(pParent) + ,m_aFtTitle(VclPtr<FixedText>::Create(pParent)) ,m_pControlWindow( NULL ) ,m_pBrowseButton(NULL) ,m_pAdditionalBrowseButton( NULL ) @@ -66,7 +66,7 @@ namespace pcr ,m_bIndentTitle( false ) ,m_bReadOnly( false ) { - m_aFtTitle.Show(); + m_aFtTitle->Show(); } @@ -109,7 +109,7 @@ namespace pcr void OBrowserLine::setControl( const Reference< XPropertyControl >& _rxControl ) { m_xControl = _rxControl; - m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : NULL; + m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : VclPtr<vcl::Window>(); DBG_ASSERT( m_pControlWindow, "OBrowserLine::setControl: setting NULL controls/windows is not allowed!" ); if ( m_pControlWindow ) @@ -123,7 +123,7 @@ namespace pcr vcl::Window* OBrowserLine::GetRefWindow() { - vcl::Window* pRefWindow=&m_aFtTitle; + vcl::Window* pRefWindow = m_aFtTitle.get(); if(m_pBrowseButton) { @@ -139,9 +139,9 @@ namespace pcr void OBrowserLine::SetTabOrder(vcl::Window* pRefWindow, sal_uInt16 nFlags ) { - m_aFtTitle.SetZOrder(pRefWindow,nFlags); + m_aFtTitle->SetZOrder(pRefWindow,nFlags); if ( m_pControlWindow ) - m_pControlWindow->SetZOrder( (vcl::Window*)&m_aFtTitle, WINDOW_ZORDER_BEHIND ); + m_pControlWindow->SetZOrder( m_aFtTitle.get(), WINDOW_ZORDER_BEHIND ); if ( m_pBrowseButton && m_pControlWindow ) m_pBrowseButton->SetZOrder( m_pControlWindow, WINDOW_ZORDER_BEHIND ); @@ -185,7 +185,7 @@ namespace pcr void OBrowserLine::Show(bool bFlag) { - m_aFtTitle.Show(bFlag); + m_aFtTitle->Show(bFlag); if ( m_pControlWindow ) m_pControlWindow->Show( bFlag ); if ( m_pBrowseButton ) @@ -203,7 +203,7 @@ namespace pcr bool OBrowserLine::IsVisible() { - return m_aFtTitle.IsVisible(); + return m_aFtTitle->IsVisible(); } @@ -219,7 +219,7 @@ namespace pcr aTitlePos.X() += aIndent.Width(); aTitleSize.Width() -= aIndent.Width(); } - m_aFtTitle.SetPosSizePixel( aTitlePos, aTitleSize ); + m_aFtTitle->SetPosSizePixel( aTitlePos, aTitleSize ); } sal_Int32 nBrowseButtonSize = m_aOutputSize.Height() - 4; @@ -255,7 +255,7 @@ namespace pcr if ( GetTitle() == _rNewTtile ) return; // #99102# -------------- - m_aFtTitle.SetText( _rNewTtile ); + m_aFtTitle->SetText( _rNewTtile ); if ( m_pControlWindow ) m_pControlWindow->SetAccessibleName( _rNewTtile ); if ( m_pBrowseButton ) @@ -268,7 +268,7 @@ namespace pcr { if( m_pTheParent ) { - OUStringBuffer aText( m_aFtTitle.GetText() ); + OUStringBuffer aText( m_aFtTitle->GetText() ); while( m_pTheParent->GetTextWidth( aText.toString() ) < m_nNameWidth ) aText.append("..........."); @@ -280,14 +280,14 @@ namespace pcr aText.append( OUString(cRTL_mark) ); } - m_aFtTitle.SetText( aText.makeStringAndClear() ); + m_aFtTitle->SetText( aText.makeStringAndClear() ); } } OUString OBrowserLine::GetTitle() const { - OUString sDisplayName = m_aFtTitle.GetText(); + OUString sDisplayName = m_aFtTitle->GetText(); // for Issue 69452 if (AllSettings::GetLayoutRTL()) @@ -341,7 +341,7 @@ namespace pcr void OBrowserLine::implUpdateEnabledDisabled() { - implEnable( &m_aFtTitle, m_nEnableFlags, PropertyLineElement::CompleteLine ); + implEnable( m_aFtTitle.get(), m_nEnableFlags, PropertyLineElement::CompleteLine ); if ( m_pControlWindow ) implEnable( m_pControlWindow, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::InputControl ); @@ -376,11 +376,11 @@ namespace pcr PushButton& OBrowserLine::impl_ensureButton( bool _bPrimary ) { - PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; + VclPtr<PushButton>& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; if ( !rpButton ) { - rpButton = new PushButton( m_pTheParent, WB_NOPOINTERFOCUS ); + rpButton = VclPtr<PushButton>::Create( m_pTheParent, WB_NOPOINTERFOCUS ); rpButton->SetGetFocusHdl( LINK( this, OBrowserLine, OnButtonFocus ) ); rpButton->SetClickHdl( LINK( this, OBrowserLine, OnButtonClicked ) ); rpButton->SetText(OUString("...")); @@ -443,13 +443,12 @@ namespace pcr void OBrowserLine::implHideBrowseButton( bool _bPrimary, bool _bReLayout ) { - PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; + VclPtr<PushButton>& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; if ( rpButton ) { rpButton->Hide(); - delete rpButton; - rpButton = NULL; + rpButton.disposeAndClear(); } if ( _bReLayout ) diff --git a/extensions/source/propctrlr/browserline.hxx b/extensions/source/propctrlr/browserline.hxx index 1fa64a89a47c..9f39ec6277f3 100644 --- a/extensions/source/propctrlr/browserline.hxx +++ b/extensions/source/propctrlr/browserline.hxx @@ -50,17 +50,17 @@ namespace pcr class OBrowserLine { private: - OUString m_sEntryName; - FixedText m_aFtTitle; + OUString m_sEntryName; + VclPtr<FixedText> m_aFtTitle; Size m_aOutputSize; Point m_aLinePos; ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > m_xControl; - vcl::Window* m_pControlWindow; - PushButton* m_pBrowseButton; - PushButton* m_pAdditionalBrowseButton; + VclPtr<vcl::Window> m_pControlWindow; + VclPtr<PushButton> m_pBrowseButton; + VclPtr<PushButton> m_pAdditionalBrowseButton; IButtonClickListener* m_pClickListener; - vcl::Window* m_pTheParent; + VclPtr<vcl::Window> m_pTheParent; sal_uInt16 m_nNameWidth; sal_uInt16 m_nEnableFlags; bool m_bIndentTitle; diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx index f31fd5de1a82..13b2df89e334 100644 --- a/extensions/source/propctrlr/browserlistbox.cxx +++ b/extensions/source/propctrlr/browserlistbox.cxx @@ -345,9 +345,9 @@ namespace pcr OBrowserListBox::OBrowserListBox( vcl::Window* pParent, WinBits nWinStyle) :Control(pParent, nWinStyle| WB_CLIPCHILDREN) - ,m_aLinesPlayground(this,WB_DIALOGCONTROL | WB_CLIPCHILDREN) - ,m_aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG) - ,m_pHelpWindow( new InspectorHelpWindow( this ) ) + ,m_aLinesPlayground(VclPtr<vcl::Window>::Create(this,WB_DIALOGCONTROL | WB_CLIPCHILDREN)) + ,m_aVScroll(VclPtr<ScrollBar>::Create(this,WB_VSCROLL|WB_REPEAT|WB_DRAG)) + ,m_pHelpWindow( VclPtr<InspectorHelpWindow>::Create( this ) ) ,m_pLineListener(NULL) ,m_pControlObserver( NULL ) ,m_nYOffset(0) @@ -357,23 +357,27 @@ namespace pcr ,m_bUpdate(true) ,m_pControlContextImpl( new PropertyControlContext_Impl( *this ) ) { - - ListBox aListBox(this,WB_DROPDOWN); - aListBox.SetPosSizePixel(Point(0,0),Size(100,100)); - m_nRowHeight = aListBox.GetSizePixel().Height()+2; + ScopedVclPtrInstance< ListBox > aListBox(this,WB_DROPDOWN); + aListBox->SetPosSizePixel(Point(0,0),Size(100,100)); + m_nRowHeight = aListBox->GetSizePixel().Height()+2; SetBackground( pParent->GetBackground() ); - m_aLinesPlayground.SetBackground( GetBackground() ); + m_aLinesPlayground->SetBackground( GetBackground() ); - m_aLinesPlayground.SetPosPixel(Point(0,0)); - m_aLinesPlayground.SetPaintTransparent(true); - m_aLinesPlayground.Show(); - m_aVScroll.Hide(); - m_aVScroll.SetScrollHdl(LINK(this, OBrowserListBox, ScrollHdl)); + m_aLinesPlayground->SetPosPixel(Point(0,0)); + m_aLinesPlayground->SetPaintTransparent(true); + m_aLinesPlayground->Show(); + m_aVScroll->Hide(); + m_aVScroll->SetScrollHdl(LINK(this, OBrowserListBox, ScrollHdl)); } OBrowserListBox::~OBrowserListBox() { + disposeOnce(); + } + + void OBrowserListBox::dispose() + { OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" ); // doing the commit here, while we, as well as our owner, as well as some other components, // are already "half dead" (means within their dtor) is potentially dangerous. @@ -384,7 +388,10 @@ namespace pcr Hide(); Clear(); - + m_aLinesPlayground.disposeAndClear(); + m_aVScroll.disposeAndClear(); + m_pHelpWindow.disposeAndClear(); + Control::dispose(); } @@ -425,7 +432,7 @@ namespace pcr if (m_bIsActive) { // TODO: what's the sense of this? - m_aVScroll.SetThumbPos(100); + m_aVScroll->SetThumbPos(100); MoveThumbTo(0); Resize(); } @@ -452,31 +459,31 @@ namespace pcr aLinesArea.Bottom() -= nHelpWindowHeight; aLinesArea.Bottom() -= aHelpWindowDistance.Height(); } - m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() ); + m_aLinesPlayground->SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() ); UpdateVScroll(); bool bNeedScrollbar = m_aLines.size() > (sal_uInt32)CalcVisibleLines(); if ( !bNeedScrollbar ) { - if ( m_aVScroll.IsVisible() ) - m_aVScroll.Hide(); + if ( m_aVScroll->IsVisible() ) + m_aVScroll->Hide(); // scroll to top m_nYOffset = 0; - m_aVScroll.SetThumbPos( 0 ); + m_aVScroll->SetThumbPos( 0 ); } else { - Size aVScrollSize( m_aVScroll.GetSizePixel() ); + Size aVScrollSize( m_aVScroll->GetSizePixel() ); // adjust the playground's width aLinesArea.Right() -= aVScrollSize.Width(); - m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() ); + m_aLinesPlayground->SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() ); // position the scrollbar aVScrollSize.Height() = aLinesArea.GetHeight(); Point aVScrollPos( aLinesArea.GetWidth(), 0 ); - m_aVScroll.SetPosSizePixel( aVScrollPos, aVScrollSize ); + m_aVScroll->SetPosSizePixel( aVScrollPos, aVScrollSize ); } for ( sal_uInt16 i = 0; i < m_aLines.size(); ++i ) @@ -489,7 +496,7 @@ namespace pcr // show the scrollbar if ( bNeedScrollbar ) - m_aVScroll.Show(); + m_aVScroll->Show(); // position the help window if ( bPositionHelpWindow ) @@ -543,7 +550,7 @@ namespace pcr sal_uInt16 OBrowserListBox::CalcVisibleLines() { - Size aSize(m_aLinesPlayground.GetOutputSizePixel()); + Size aSize(m_aLinesPlayground->GetOutputSizePixel()); sal_uInt16 nResult = 0; if (0 != m_nRowHeight) nResult = (sal_uInt16) aSize.Height()/m_nRowHeight; @@ -555,18 +562,18 @@ namespace pcr void OBrowserListBox::UpdateVScroll() { sal_uInt16 nLines = CalcVisibleLines(); - m_aVScroll.SetPageSize(nLines-1); - m_aVScroll.SetVisibleSize(nLines-1); + m_aVScroll->SetPageSize(nLines-1); + m_aVScroll->SetVisibleSize(nLines-1); size_t nCount = m_aLines.size(); if (nCount>0) { - m_aVScroll.SetRange(Range(0,nCount-1)); - m_nYOffset = -m_aVScroll.GetThumbPos()*m_nRowHeight; + m_aVScroll->SetRange(Range(0,nCount-1)); + m_nYOffset = -m_aVScroll->GetThumbPos()*m_nRowHeight; } else { - m_aVScroll.SetRange(Range(0,0)); + m_aVScroll->SetRange(Range(0,0)); m_nYOffset = 0; } } @@ -574,7 +581,7 @@ namespace pcr void OBrowserListBox::PositionLine( sal_uInt16 _nIndex ) { - Size aSize(m_aLinesPlayground.GetOutputSizePixel()); + Size aSize(m_aLinesPlayground->GetOutputSizePixel()); Point aPos(0, m_nYOffset); aSize.Height() = m_nRowHeight; @@ -612,7 +619,7 @@ namespace pcr void OBrowserListBox::UpdatePlayGround() { - sal_Int32 nThumbPos = m_aVScroll.GetThumbPos(); + sal_Int32 nThumbPos = m_aVScroll->GetThumbPos(); sal_Int32 nLines = CalcVisibleLines(); sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines); @@ -729,7 +736,7 @@ namespace pcr sal_uInt16 OBrowserListBox::InsertEntry(const OLineDescriptor& _rPropertyData, sal_uInt16 _nPos) { // create a new line - BrowserLinePointer pBrowserLine( new OBrowserLine( _rPropertyData.sName, &m_aLinesPlayground ) ); + BrowserLinePointer pBrowserLine( new OBrowserLine( _rPropertyData.sName, m_aLinesPlayground.get() ) ); // check that the name is unique ListBoxLines::iterator it = m_aLines.begin(); @@ -794,7 +801,7 @@ namespace pcr { if ( _nPos < m_aLines.size() ) { - sal_Int32 nThumbPos = m_aVScroll.GetThumbPos(); + sal_Int32 nThumbPos = m_aVScroll->GetThumbPos(); if (_nPos < nThumbPos) MoveThumbTo(_nPos); @@ -812,19 +819,19 @@ namespace pcr void OBrowserListBox::MoveThumbTo(sal_Int32 _nNewThumbPos) { // disable painting to prevent flicker - m_aLinesPlayground.EnablePaint(false); + m_aLinesPlayground->EnablePaint(false); - sal_Int32 nDelta = _nNewThumbPos - m_aVScroll.GetThumbPos(); + sal_Int32 nDelta = _nNewThumbPos - m_aVScroll->GetThumbPos(); // adjust the scrollbar - m_aVScroll.SetThumbPos(_nNewThumbPos); + m_aVScroll->SetThumbPos(_nNewThumbPos); sal_Int32 nThumbPos = _nNewThumbPos; - m_nYOffset = -m_aVScroll.GetThumbPos() * m_nRowHeight; + m_nYOffset = -m_aVScroll->GetThumbPos() * m_nRowHeight; sal_Int32 nLines = CalcVisibleLines(); sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines); - m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN); + m_aLinesPlayground->Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN); if (1 == nDelta) { @@ -841,27 +848,27 @@ namespace pcr UpdatePlayGround(); } - m_aLinesPlayground.EnablePaint(true); - m_aLinesPlayground.Invalidate(INVALIDATE_CHILDREN); + m_aLinesPlayground->EnablePaint(true); + m_aLinesPlayground->Invalidate(INVALIDATE_CHILDREN); } IMPL_LINK(OBrowserListBox, ScrollHdl, ScrollBar*, _pScrollBar ) { - DBG_ASSERT(_pScrollBar == &m_aVScroll, "OBrowserListBox::ScrollHdl: where does this come from?"); + DBG_ASSERT(_pScrollBar == m_aVScroll.get(), "OBrowserListBox::ScrollHdl: where does this come from?"); (void)_pScrollBar; // disable painting to prevent flicker - m_aLinesPlayground.EnablePaint(false); + m_aLinesPlayground->EnablePaint(false); - sal_Int32 nThumbPos = m_aVScroll.GetThumbPos(); + sal_Int32 nThumbPos = m_aVScroll->GetThumbPos(); - sal_Int32 nDelta = m_aVScroll.GetDelta(); + sal_Int32 nDelta = m_aVScroll->GetDelta(); m_nYOffset = -nThumbPos * m_nRowHeight; sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + CalcVisibleLines()); - m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN); + m_aLinesPlayground->Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN); if (1 == nDelta) { @@ -872,12 +879,12 @@ namespace pcr { PositionLine((sal_uInt16)nThumbPos); } - else if (nDelta!=0 || m_aVScroll.GetType() == SCROLL_DONTKNOW) + else if (nDelta!=0 || m_aVScroll->GetType() == SCROLL_DONTKNOW) { UpdatePlayGround(); } - m_aLinesPlayground.EnablePaint(true); + m_aLinesPlayground->EnablePaint(true); return 0; } @@ -1129,7 +1136,7 @@ namespace pcr rLine.pLine->SetTitle(_rPropertyData.DisplayName); rLine.xHandler = _rPropertyData.xPropertyHandler; - sal_uInt16 nTextWidth = (sal_uInt16)m_aLinesPlayground.GetTextWidth(_rPropertyData.DisplayName); + sal_uInt16 nTextWidth = (sal_uInt16)m_aLinesPlayground->GetTextWidth(_rPropertyData.DisplayName); if (m_nTheNameSize< nTextWidth) m_nTheNameSize = nTextWidth; @@ -1216,21 +1223,21 @@ namespace pcr break; long nScrollOffset = 0; - if ( m_aVScroll.IsVisible() ) + if ( m_aVScroll->IsVisible() ) { if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP ) - nScrollOffset = -m_aVScroll.GetPageSize(); + nScrollOffset = -m_aVScroll->GetPageSize(); else if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN ) - nScrollOffset = m_aVScroll.GetPageSize(); + nScrollOffset = m_aVScroll->GetPageSize(); } if ( nScrollOffset ) { - long nNewThumbPos = m_aVScroll.GetThumbPos() + nScrollOffset; - nNewThumbPos = ::std::max( nNewThumbPos, m_aVScroll.GetRangeMin() ); - nNewThumbPos = ::std::min( nNewThumbPos, m_aVScroll.GetRangeMax() ); - m_aVScroll.DoScroll( nNewThumbPos ); - nNewThumbPos = m_aVScroll.GetThumbPos(); + long nNewThumbPos = m_aVScroll->GetThumbPos() + nScrollOffset; + nNewThumbPos = ::std::max( nNewThumbPos, m_aVScroll->GetRangeMin() ); + nNewThumbPos = ::std::min( nNewThumbPos, m_aVScroll->GetRangeMax() ); + m_aVScroll->DoScroll( nNewThumbPos ); + nNewThumbPos = m_aVScroll->GetThumbPos(); sal_uInt16 nFocusControlPos = 0; sal_uInt16 nActiveControlPos = impl_getControlPos( m_xActiveControl ); @@ -1271,9 +1278,9 @@ namespace pcr ) { // interested in scroll events if we have a scrollbar - if ( m_aVScroll.IsVisible() ) + if ( m_aVScroll->IsVisible() ) { - HandleScrollCommand( *pCommand, NULL, &m_aVScroll ); + HandleScrollCommand( *pCommand, NULL, m_aVScroll.get() ); } } } diff --git a/extensions/source/propctrlr/browserlistbox.hxx b/extensions/source/propctrlr/browserlistbox.hxx index 3b50d467c943..f8b3c754839f 100644 --- a/extensions/source/propctrlr/browserlistbox.hxx +++ b/extensions/source/propctrlr/browserlistbox.hxx @@ -93,10 +93,9 @@ namespace pcr ,public PcrClient { protected: - Window m_aLinesPlayground; - ScrollBar m_aVScroll; - ::std::unique_ptr< InspectorHelpWindow > - m_pHelpWindow; + VclPtr<Window> m_aLinesPlayground; + VclPtr<ScrollBar> m_aVScroll; + VclPtr<InspectorHelpWindow> m_pHelpWindow; ListBoxLines m_aLines; IPropertyLineListener* m_pLineListener; IPropertyControlObserver* m_pControlObserver; @@ -125,6 +124,7 @@ namespace pcr OBrowserListBox( vcl::Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL ); virtual ~OBrowserListBox(); + virtual void dispose() SAL_OVERRIDE; void UpdateAll(); diff --git a/extensions/source/propctrlr/browserpage.cxx b/extensions/source/propctrlr/browserpage.cxx index 2e733a9ed727..dfb0236317fd 100644 --- a/extensions/source/propctrlr/browserpage.cxx +++ b/extensions/source/propctrlr/browserpage.cxx @@ -35,25 +35,31 @@ namespace pcr OBrowserPage::OBrowserPage(vcl::Window* pParent,WinBits nWinStyle) :TabPage(pParent,nWinStyle) - ,m_aListBox(this) + ,m_aListBox(VclPtr<OBrowserListBox>::Create(this)) { - m_aListBox.SetBackground(GetBackground()); - m_aListBox.SetPaintTransparent( true ); - m_aListBox.Show(); + m_aListBox->SetBackground(GetBackground()); + m_aListBox->SetPaintTransparent( true ); + m_aListBox->Show(); } OBrowserPage::~OBrowserPage() { + disposeOnce(); } + void OBrowserPage::dispose() + { + m_aListBox.disposeAndClear(); + TabPage::dispose(); + } void OBrowserPage::Resize() { Size aSize( GetOutputSizePixel() ); aSize.Width() -= LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT; aSize.Height() -= LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM; - m_aListBox.SetPosSizePixel( Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ), aSize ); + m_aListBox->SetPosSizePixel( Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ), aSize ); } @@ -65,19 +71,19 @@ namespace pcr { Window::StateChanged( nType); if (StateChangedType::VISIBLE == nType) - m_aListBox.ActivateListBox(IsVisible()); + m_aListBox->ActivateListBox(IsVisible()); } sal_Int32 OBrowserPage::getMinimumWidth() { - return m_aListBox.GetMinimumWidth() + LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT; + return m_aListBox->GetMinimumWidth() + LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT; } sal_Int32 OBrowserPage::getMinimumHeight() { - return m_aListBox.GetMinimumHeight() + LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM; + return m_aListBox->GetMinimumHeight() + LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM; } diff --git a/extensions/source/propctrlr/browserpage.hxx b/extensions/source/propctrlr/browserpage.hxx index 6ef6ef80bce9..8ce0b50cd8fe 100644 --- a/extensions/source/propctrlr/browserpage.hxx +++ b/extensions/source/propctrlr/browserpage.hxx @@ -34,7 +34,7 @@ namespace pcr class OBrowserPage : public TabPage { private: - OBrowserListBox m_aListBox; + VclPtr<OBrowserListBox> m_aListBox; protected: virtual void Resize() SAL_OVERRIDE; @@ -43,12 +43,13 @@ namespace pcr public: OBrowserPage(vcl::Window* pParent, WinBits nWinStyle = 0); virtual ~OBrowserPage(); + virtual void dispose() SAL_OVERRIDE; sal_Int32 getMinimumWidth(); sal_Int32 getMinimumHeight(); - OBrowserListBox& getListBox() { return m_aListBox; } - const OBrowserListBox& getListBox() const { return m_aListBox; } + OBrowserListBox& getListBox() { return *m_aListBox.get(); } + const OBrowserListBox& getListBox() const { return *m_aListBox.get(); } }; diff --git a/extensions/source/propctrlr/browserview.cxx b/extensions/source/propctrlr/browserview.cxx index 4179cbe8e3ed..ab512b46eccc 100644 --- a/extensions/source/propctrlr/browserview.cxx +++ b/extensions/source/propctrlr/browserview.cxx @@ -21,6 +21,7 @@ #include "propertyeditor.hxx" #include "propctrlr.hrc" #include <boost/scoped_ptr.hpp> +#include <vcl/tabpage.hxx> namespace pcr { @@ -34,7 +35,7 @@ namespace pcr :Window(_pParent, nBits | WB_3DLOOK) ,m_nActivePage(0) { - m_pPropBox = new OPropertyEditor( this ); + m_pPropBox = VclPtr<OPropertyEditor>::Create( this ); m_pPropBox->SetHelpId(HID_FM_PROPDLG_TABCTR); m_pPropBox->setPageActivationHandler(LINK(this, OPropertyBrowserView, OnPageActivation)); @@ -53,15 +54,19 @@ namespace pcr OPropertyBrowserView::~OPropertyBrowserView() { + disposeOnce(); + } + + void OPropertyBrowserView::dispose() + { if(m_pPropBox) { sal_uInt16 nTmpPage = m_pPropBox->GetCurPage(); if (nTmpPage) m_nActivePage = nTmpPage; - boost::scoped_ptr<vcl::Window> aTemp(m_pPropBox); - m_pPropBox = NULL; } - + m_pPropBox.disposeAndClear(); + vcl::Window::dispose(); } diff --git a/extensions/source/propctrlr/browserview.hxx b/extensions/source/propctrlr/browserview.hxx index c87dd55b3c0a..9ae97d364295 100644 --- a/extensions/source/propctrlr/browserview.hxx +++ b/extensions/source/propctrlr/browserview.hxx @@ -37,7 +37,7 @@ namespace pcr class OPropertyBrowserView : public vcl::Window { - OPropertyEditor* m_pPropBox; + VclPtr<OPropertyEditor> m_pPropBox; sal_uInt16 m_nActivePage; Link m_aPageActivationHandler; @@ -50,6 +50,7 @@ namespace pcr OPropertyBrowserView( vcl::Window* pParent, WinBits nBits = 0); virtual ~OPropertyBrowserView(); + virtual void dispose() SAL_OVERRIDE; OPropertyEditor& getPropertyBox() { return *m_pPropBox; } diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx index ac33ace00daa..e337ccf7a0dc 100644 --- a/extensions/source/propctrlr/commoncontrol.cxx +++ b/extensions/source/propctrlr/commoncontrol.cxx @@ -47,7 +47,7 @@ namespace pcr ,m_pModifyListener( _pModifyListener ) ,m_bModified( false ) { - DBG_ASSERT( m_pControlWindow != NULL, "ControlHelper::ControlHelper: invalid window!" ); + DBG_ASSERT( m_pControlWindow != nullptr, "ControlHelper::ControlHelper: invalid window!" ); } @@ -55,11 +55,6 @@ namespace pcr { } - - - - - void SAL_CALL ControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException) { m_xContext = _controlcontext; @@ -93,7 +88,7 @@ namespace pcr void SAL_CALL ControlHelper::dispose() { - DELETEZ( m_pControlWindow ); + m_pControlWindow.disposeAndClear(); } @@ -103,9 +98,9 @@ namespace pcr if ( !m_pControlWindow ) return; - ComboBox aComboBox(m_pControlWindow, WB_DROPDOWN); - aComboBox.SetPosSizePixel(Point(0,0), Size(100,100)); - m_pControlWindow->SetSizePixel(aComboBox.GetSizePixel()); + ScopedVclPtrInstance< ComboBox > aComboBox(m_pControlWindow, WB_DROPDOWN); + aComboBox->SetPosSizePixel(Point(0,0), Size(100,100)); + m_pControlWindow->SetSizePixel(aComboBox->GetSizePixel()); // TODO/UNOize: why do the controls this themselves? Shouldn't this be the task // of the browser listbox/line? diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx index 629660eda8d7..cbe825f32156 100644 --- a/extensions/source/propctrlr/commoncontrol.hxx +++ b/extensions/source/propctrlr/commoncontrol.hxx @@ -86,7 +86,7 @@ namespace pcr class ControlHelper { private: - vcl::Window* m_pControlWindow; + VclPtr<vcl::Window> m_pControlWindow; sal_Int16 m_nControlType; ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > m_xContext; diff --git a/extensions/source/propctrlr/controlfontdialog.cxx b/extensions/source/propctrlr/controlfontdialog.cxx index 675f2aa74739..54ae2733d633 100644 --- a/extensions/source/propctrlr/controlfontdialog.cxx +++ b/extensions/source/propctrlr/controlfontdialog.cxx @@ -141,7 +141,7 @@ namespace pcr } - Dialog* OControlFontDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> OControlFontDialog::createDialog(vcl::Window* _pParent) { ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults); @@ -152,8 +152,7 @@ namespace pcr // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first // execute) will be re-used upon the second execute, and thus it won't be initialized correctly. - ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems); - return pDialog; + return VclPtr<ControlCharacterDialog>::Create(_pParent, *m_pFontItems); } @@ -169,7 +168,7 @@ namespace pcr OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!"); if (m_pDialog && (RET_OK == _nExecutionResult) && m_xControlModel.is()) { - const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet(); + const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog.get())->GetOutputItemSet(); if (pOutput) ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel ); } diff --git a/extensions/source/propctrlr/controlfontdialog.hxx b/extensions/source/propctrlr/controlfontdialog.hxx index 3df0b46fcdc5..e9d30f4c67d0 100644 --- a/extensions/source/propctrlr/controlfontdialog.hxx +++ b/extensions/source/propctrlr/controlfontdialog.hxx @@ -82,7 +82,7 @@ namespace pcr protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; virtual void destroyDialog() SAL_OVERRIDE; virtual void executedDialog(sal_Int16 _nExecutionResult) SAL_OVERRIDE; }; diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index e45398145741..a13fd939a3dc 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2608,9 +2608,9 @@ namespace pcr OSL_PRECOND( m_pInfoService.get(), "FormComponentPropertyHandler::impl_dialogListSelection_nothrow: no property meta data!" ); OUString sPropertyUIName( m_pInfoService->getPropertyTranslation( m_pInfoService->getPropertyId( _rProperty ) ) ); - ListSelectionDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName ); + ScopedVclPtrInstance< ListSelectionDialog > aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName ); _rClearBeforeDialog.clear(); - return ( RET_OK == aDialog.Execute() ); + return ( RET_OK == aDialog->Execute() ); } @@ -2685,9 +2685,9 @@ namespace pcr return false; - FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_xContext ); + ScopedVclPtrInstance< FormLinkDialog > aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_xContext ); _rClearBeforeDialog.clear(); - return ( RET_OK == aDialog.Execute() ); + return ( RET_OK == aDialog->Execute() ); } @@ -2722,9 +2722,8 @@ namespace pcr aCoreSet.Put( aFormatter ); // a tab dialog with a single page - boost::scoped_ptr< SfxSingleTabDialog > xDialog(new SfxSingleTabDialog( - impl_getDefaultDialogParent_nothrow(), aCoreSet, - "FormatNumberDialog", "cui/ui/formatnumberdialog.ui")); + ScopedVclPtrInstance< SfxSingleTabDialog > xDialog( impl_getDefaultDialogParent_nothrow(), aCoreSet, + "FormatNumberDialog", "cui/ui/formatnumberdialog.ui"); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); DBG_ASSERT( pFact, "CreateFactory fail!" ); ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ); @@ -2871,11 +2870,11 @@ namespace pcr { // do this in an own block. The dialog needs to be destroyed before we call // destroyItemSet - ControlCharacterDialog aDlg( impl_getDefaultDialogParent_nothrow(), *pSet ); + ScopedVclPtrInstance< ControlCharacterDialog > aDlg( impl_getDefaultDialogParent_nothrow(), *pSet ); _rClearBeforeDialog.clear(); - if ( RET_OK == aDlg.Execute() ) + if ( RET_OK == aDlg->Execute() ) { - const SfxItemSet* pOut = aDlg.GetOutputItemSet(); + const SfxItemSet* pOut = aDlg->GetOutputItemSet(); if ( pOut ) { Sequence< NamedValue > aFontPropertyValues; @@ -2942,11 +2941,11 @@ namespace pcr bool FormComponentPropertyHandler::impl_dialogChooseLabelControl_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const { - OSelectLabelDialog dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent ); + ScopedVclPtrInstance< OSelectLabelDialog > dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent ); _rClearBeforeDialog.clear(); - bool bSuccess = ( RET_OK == dlgSelectLabel.Execute() ); + bool bSuccess = ( RET_OK == dlgSelectLabel->Execute() ); if ( bSuccess ) - _out_rNewValue <<= dlgSelectLabel.GetSelected(); + _out_rNewValue <<= dlgSelectLabel->GetSelected(); return bSuccess; } @@ -2965,14 +2964,14 @@ namespace pcr OSL_PRECOND( impl_getContextControlContainer_nothrow().is(), "FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow: invalid control context!" ); Reference< XTabControllerModel > xTabControllerModel( impl_getRowSet_nothrow(), UNO_QUERY ); - TabOrderDialog aDialog( + ScopedVclPtrInstance<TabOrderDialog> aDialog( impl_getDefaultDialogParent_nothrow(), xTabControllerModel, impl_getContextControlContainer_nothrow(), m_xContext ); _rClearBeforeDialog.clear(); - return ( RET_OK == aDialog.Execute() ); + return ( RET_OK == aDialog->Execute() ); } diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index 3a7d97003c6d..3689a775c961 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -65,13 +65,15 @@ namespace pcr class FieldLinkRow : public TabPage { private: - ComboBox* m_pDetailColumn; - ComboBox* m_pMasterColumn; + VclPtr<ComboBox> m_pDetailColumn; + VclPtr<ComboBox> m_pMasterColumn; Link m_aLinkChangeHandler; public: FieldLinkRow( vcl::Window* _pParent ); + virtual ~FieldLinkRow(); + virtual void dispose() SAL_OVERRIDE; inline void SetLinkChangeHandler( const Link& _rHdl ) { m_aLinkChangeHandler = _rHdl; } @@ -106,6 +108,17 @@ namespace pcr m_pMasterColumn->SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) ); } + FieldLinkRow::~FieldLinkRow() + { + disposeOnce(); + } + + void FieldLinkRow::dispose() + { + m_pDetailColumn.clear(); + m_pMasterColumn.clear(); + TabPage::dispose(); + } void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames ) { @@ -156,10 +169,10 @@ namespace pcr const OUString& _sDetailLabel, const OUString& _sMasterLabel) :ModalDialog( _pParent, "FormLinks", "modules/spropctrlr/ui/formlinksdialog.ui" ) - ,m_aRow1 ( new FieldLinkRow( get<VclVBox>("box") ) ) - ,m_aRow2 ( new FieldLinkRow( get<VclVBox>("box") ) ) - ,m_aRow3 ( new FieldLinkRow( get<VclVBox>("box") ) ) - ,m_aRow4 ( new FieldLinkRow( get<VclVBox>("box") ) ) + ,m_aRow1 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) + ,m_aRow2 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) + ,m_aRow3 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) + ,m_aRow4 ( VclPtr<FieldLinkRow>::Create( get<VclVBox>("box") ) ) ,m_xContext ( _rxContext ) ,m_xDetailForm( _rxDetailForm ) ,m_xMasterForm( _rxMasterForm ) @@ -194,8 +207,24 @@ namespace pcr FormLinkDialog::~FormLinkDialog( ) { + disposeOnce(); } + void FormLinkDialog::dispose( ) + { + m_pExplanation.clear(); + m_pDetailLabel.clear(); + m_pMasterLabel.clear(); + m_pOK.clear(); + m_pSuggest.clear(); + + m_aRow1.disposeAndClear(); + m_aRow2.disposeAndClear(); + m_aRow3.disposeAndClear(); + m_aRow4.disposeAndClear(); + + ModalDialog::dispose(); + } void FormLinkDialog::commitLinkPairs() { diff --git a/extensions/source/propctrlr/formlinkdialog.hxx b/extensions/source/propctrlr/formlinkdialog.hxx index 6dd94e915dd4..9ce65e8377ce 100644 --- a/extensions/source/propctrlr/formlinkdialog.hxx +++ b/extensions/source/propctrlr/formlinkdialog.hxx @@ -44,15 +44,15 @@ namespace pcr class FormLinkDialog : public ModalDialog { private: - FixedText* m_pExplanation; - FixedText* m_pDetailLabel; - FixedText* m_pMasterLabel; - ::std::unique_ptr< FieldLinkRow > m_aRow1; - ::std::unique_ptr< FieldLinkRow > m_aRow2; - ::std::unique_ptr< FieldLinkRow > m_aRow3; - ::std::unique_ptr< FieldLinkRow > m_aRow4; - OKButton* m_pOK; - PushButton* m_pSuggest; + VclPtr<FixedText> m_pExplanation; + VclPtr<FixedText> m_pDetailLabel; + VclPtr<FixedText> m_pMasterLabel; + VclPtr<FieldLinkRow> m_aRow1; + VclPtr<FieldLinkRow> m_aRow2; + VclPtr<FieldLinkRow> m_aRow3; + VclPtr<FieldLinkRow> m_aRow4; + VclPtr<OKButton> m_pOK; + VclPtr<PushButton> m_pSuggest; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; @@ -80,6 +80,7 @@ namespace pcr const OUString& _sMasterLabel = OUString() ); virtual ~FormLinkDialog( ); + virtual void dispose() SAL_OVERRIDE; // Dialog overridables virtual short Execute() SAL_OVERRIDE; diff --git a/extensions/source/propctrlr/inspectorhelpwindow.cxx b/extensions/source/propctrlr/inspectorhelpwindow.cxx index b62010cf6cd9..b174b69bd6c2 100644 --- a/extensions/source/propctrlr/inspectorhelpwindow.cxx +++ b/extensions/source/propctrlr/inspectorhelpwindow.cxx @@ -29,27 +29,38 @@ namespace pcr InspectorHelpWindow::InspectorHelpWindow( vcl::Window* _pParent ) :Window( _pParent, WB_DIALOGCONTROL ) - ,m_aSeparator( this ) - ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL ) + ,m_aSeparator( VclPtr<FixedLine>::Create(this) ) + ,m_aHelpText( VclPtr<MultiLineEdit>::Create(this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL) ) ,m_nMinLines( 3 ) ,m_nMaxLines( 8 ) { SetBackground(); SetPaintTransparent(true); - m_aSeparator.SetText( PcrRes(RID_STR_HELP_SECTION_LABEL).toString() ); - m_aSeparator.SetBackground(); - m_aSeparator.Show(); - - m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */); - m_aHelpText.SetBackground(); - m_aHelpText.SetPaintTransparent(true); - m_aHelpText.Show(); + m_aSeparator->SetText( PcrRes(RID_STR_HELP_SECTION_LABEL).toString() ); + m_aSeparator->SetBackground(); + m_aSeparator->Show(); + + m_aHelpText->SetControlBackground( /*m_aSeparator->GetBackground().GetColor() */); + m_aHelpText->SetBackground(); + m_aHelpText->SetPaintTransparent(true); + m_aHelpText->Show(); } + InspectorHelpWindow::~InspectorHelpWindow() + { + disposeOnce(); + } + + void InspectorHelpWindow::dispose() + { + m_aSeparator.disposeAndClear(); + m_aHelpText.disposeAndClear(); + vcl::Window::dispose(); + } void InspectorHelpWindow::SetText( const OUString& _rStr ) { - m_aHelpText.SetText( _rStr ); + m_aHelpText->SetText( _rStr ); } @@ -63,7 +74,7 @@ namespace pcr long InspectorHelpWindow::impl_getHelpTextBorderHeight() { sal_Int32 nTop(0), nBottom(0), nDummy(0); - m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom ); + m_aHelpText->GetBorder( nDummy, nTop, nDummy, nBottom ); return nTop + nBottom; } @@ -84,13 +95,13 @@ namespace pcr long InspectorHelpWindow::impl_getMinimalTextWindowHeight() { - return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines; + return impl_getHelpTextBorderHeight() + m_aHelpText->GetTextHeight() * m_nMinLines; } long InspectorHelpWindow::impl_getMaximalTextWindowHeight() { - return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines; + return impl_getHelpTextBorderHeight() + m_aHelpText->GetTextHeight() * m_nMaxLines; } @@ -100,8 +111,8 @@ namespace pcr long nMinTextWindowHeight = impl_getMinimalTextWindowHeight(); long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight(); - Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() ); - aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(), + Rectangle aTextRect( Point( 0, 0 ), m_aHelpText->GetOutputSizePixel() ); + aTextRect = m_aHelpText->GetTextRect( aTextRect, m_aHelpText->GetText(), TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight(); @@ -120,11 +131,11 @@ namespace pcr Rectangle aSeparatorArea( aPlayground ); aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height(); - m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() ); + m_aSeparator->SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() ); Rectangle aTextArea( aPlayground ); aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height(); - m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() ); + m_aHelpText->SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() ); } diff --git a/extensions/source/propctrlr/inspectorhelpwindow.hxx b/extensions/source/propctrlr/inspectorhelpwindow.hxx index 9419a72ec7a9..0159cff96ca6 100644 --- a/extensions/source/propctrlr/inspectorhelpwindow.hxx +++ b/extensions/source/propctrlr/inspectorhelpwindow.hxx @@ -33,14 +33,16 @@ namespace pcr class InspectorHelpWindow : public vcl::Window { private: - FixedLine m_aSeparator; - MultiLineEdit m_aHelpText; + VclPtr<FixedLine> m_aSeparator; + VclPtr<MultiLineEdit> m_aHelpText; sal_Int32 m_nMinLines; sal_Int32 m_nMaxLines; public: InspectorHelpWindow( vcl::Window* _pParent ); + virtual ~InspectorHelpWindow(); + virtual void dispose() SAL_OVERRIDE; virtual void SetText( const OUString& rStr ) SAL_OVERRIDE; diff --git a/extensions/source/propctrlr/listselectiondlg.cxx b/extensions/source/propctrlr/listselectiondlg.cxx index fdb6229dc370..9b2bbedcb368 100644 --- a/extensions/source/propctrlr/listselectiondlg.cxx +++ b/extensions/source/propctrlr/listselectiondlg.cxx @@ -48,6 +48,17 @@ namespace pcr initialize( ); } + ListSelectionDialog::~ListSelectionDialog() + { + disposeOnce(); + } + + void ListSelectionDialog::dispose() + { + m_pEntries.clear(); + ModalDialog::dispose(); + } + short ListSelectionDialog::Execute() { short nResult = ModalDialog::Execute(); diff --git a/extensions/source/propctrlr/listselectiondlg.hxx b/extensions/source/propctrlr/listselectiondlg.hxx index aaccb0754ec2..ca9a118c06f9 100644 --- a/extensions/source/propctrlr/listselectiondlg.hxx +++ b/extensions/source/propctrlr/listselectiondlg.hxx @@ -31,7 +31,7 @@ namespace pcr class ListSelectionDialog : public ModalDialog { private: - ListBox* m_pEntries; + VclPtr<ListBox> m_pEntries; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xListBox; @@ -44,6 +44,8 @@ namespace pcr const OUString& _rPropertyName, const OUString& _rPropertyUIName ); + virtual ~ListSelectionDialog(); + virtual void dispose() SAL_OVERRIDE; // Dialog overridables virtual short Execute() SAL_OVERRIDE; diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx index 62cc6da9c247..50f85e22489b 100644 --- a/extensions/source/propctrlr/newdatatype.cxx +++ b/extensions/source/propctrlr/newdatatype.cxx @@ -67,6 +67,17 @@ namespace pcr OnNameModified( NULL ); } + NewDataTypeDialog::~NewDataTypeDialog() + { + disposeOnce(); + } + + void NewDataTypeDialog::dispose() + { + m_pName.clear(); + m_pOK.clear(); + ModalDialog::dispose(); + } IMPL_LINK( NewDataTypeDialog, OnNameModified, void*, /*_pNotInterestedIn*/ ) { diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx index 135514aaa271..abccb19bd1f9 100644 --- a/extensions/source/propctrlr/newdatatype.hxx +++ b/extensions/source/propctrlr/newdatatype.hxx @@ -35,14 +35,16 @@ namespace pcr class NewDataTypeDialog : public ModalDialog { private: - Edit* m_pName; - OKButton* m_pOK; + VclPtr<Edit> m_pName; + VclPtr<OKButton> m_pOK; ::std::set< OUString > m_aProhibitedNames; public: NewDataTypeDialog(vcl::Window* _pParent, const OUString& _rNameBase, const ::std::vector< OUString >& _rProhibitedNames ); + virtual ~NewDataTypeDialog(); + virtual void dispose() SAL_OVERRIDE; OUString GetName() const { return m_pName->GetText(); } diff --git a/extensions/source/propctrlr/pcrunodialogs.cxx b/extensions/source/propctrlr/pcrunodialogs.cxx index 2f2d56086fb6..98c4b49ad590 100644 --- a/extensions/source/propctrlr/pcrunodialogs.cxx +++ b/extensions/source/propctrlr/pcrunodialogs.cxx @@ -130,9 +130,9 @@ namespace pcr } - Dialog* OTabOrderDialog::createDialog( vcl::Window* _pParent ) + VclPtr<Dialog> OTabOrderDialog::createDialog( vcl::Window* _pParent ) { - return new TabOrderDialog( _pParent, m_xTabbingModel, m_xControlContext, m_aContext ); + return VclPtr<TabOrderDialog>::Create( _pParent, m_xTabbingModel, m_xControlContext, m_aContext ); } void OTabOrderDialog::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception) diff --git a/extensions/source/propctrlr/pcrunodialogs.hxx b/extensions/source/propctrlr/pcrunodialogs.hxx index e0e6e4325e22..35663f1e6b7b 100644 --- a/extensions/source/propctrlr/pcrunodialogs.hxx +++ b/extensions/source/propctrlr/pcrunodialogs.hxx @@ -78,7 +78,7 @@ namespace pcr protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index 77b518878526..dc85415a63fa 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -44,6 +44,7 @@ #include <comphelper/property.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vcl/tabpage.hxx> #include <osl/mutex.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/component_context.hxx> @@ -374,7 +375,7 @@ namespace pcr // announcement is responsible for calling setComponent, too. Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow(); VCLXWindow* pContainerWindow = VCLXWindow::GetImplementation(xContainerWindow); - vcl::Window* pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : NULL; + VclPtr<vcl::Window> pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : VclPtr<vcl::Window>(); if (!pParentWin) throw RuntimeException("The frame is invalid. Unable to extract the container window.",*this); @@ -702,7 +703,7 @@ namespace pcr DBG_ASSERT(!haveView(), "OPropertyBrowserController::Construct: already have a view!"); DBG_ASSERT(_pParentWin, "OPropertyBrowserController::Construct: invalid parent window!"); - m_pView = new OPropertyBrowserView(_pParentWin); + m_pView = VclPtr<OPropertyBrowserView>::Create(_pParentWin); m_pView->setPageActivationHandler(LINK(this, OPropertyBrowserController, OnPageActivation)); // add as dispose listener for our view. The view is disposed by the frame we're plugged into, diff --git a/extensions/source/propctrlr/propcontroller.hxx b/extensions/source/propctrlr/propcontroller.hxx index af943de01f13..f204a86c8735 100644 --- a/extensions/source/propctrlr/propcontroller.hxx +++ b/extensions/source/propctrlr/propcontroller.hxx @@ -105,7 +105,7 @@ namespace pcr ::cppu::OInterfaceContainerHelper m_aDisposeListeners; ::cppu::OInterfaceContainerHelper m_aControlObservers; // meta data about the properties - OPropertyBrowserView* m_pView; + VclPtr<OPropertyBrowserView> m_pView; OUString m_sPageSelection; OUString m_sLastValidPageSelection; @@ -242,7 +242,7 @@ namespace pcr // stop the inspection void stopInspection( bool _bCommitModified ); - bool haveView() const { return NULL != m_pView; } + bool haveView() const { return nullptr != m_pView; } OPropertyEditor& getPropertyBox() { return m_pView->getPropertyBox(); } // does the inspection of the objects as indicated by our model diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx index 5fcafaf92c64..daa9e8c965f6 100644 --- a/extensions/source/propctrlr/propertyeditor.cxx +++ b/extensions/source/propctrlr/propertyeditor.cxx @@ -43,7 +43,7 @@ namespace pcr OPropertyEditor::OPropertyEditor( vcl::Window* pParent, WinBits nWinStyle) :Control(pParent, nWinStyle) - ,m_aTabControl( this ) + ,m_aTabControl( VclPtr<TabControl>::Create(this) ) ,m_pListener(NULL) ,m_pObserver(NULL) ,m_nNextId(1) @@ -52,37 +52,44 @@ namespace pcr ,m_nMaxHelpLines( 0 ) { - m_aTabControl.Show(); - m_aTabControl.SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate)); - m_aTabControl.SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate)); - m_aTabControl.SetBackground(GetBackground()); - m_aTabControl.SetPaintTransparent(true); + m_aTabControl->Show(); + m_aTabControl->SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate)); + m_aTabControl->SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate)); + m_aTabControl->SetBackground(GetBackground()); + m_aTabControl->SetPaintTransparent(true); } OPropertyEditor::~OPropertyEditor() { + disposeOnce(); + } + + void OPropertyEditor::dispose() + { Hide(); ClearAll(); + m_aTabControl.disposeAndClear(); + Control::dispose(); } void OPropertyEditor::ClearAll() { m_nNextId=1; - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); for(long i = nCount-1; i >= 0; --i) { - sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i); - OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); + sal_uInt16 nID = m_aTabControl->GetPageId((sal_uInt16)i); + VclPtr<OBrowserPage> pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) { pPage->EnableInput(false); - m_aTabControl.RemovePage(nID); - delete pPage; + m_aTabControl->RemovePage(nID); + pPage.disposeAndClear(); } } - m_aTabControl.Clear(); + m_aTabControl->Clear(); { MapStringToPageId aEmpty; @@ -91,9 +98,10 @@ namespace pcr while ( !m_aHiddenPages.empty() ) { - delete m_aHiddenPages.begin()->second.pPage; + m_aHiddenPages.begin()->second.pPage.disposeAndClear(); m_aHiddenPages.erase( m_aHiddenPages.begin() ); } + m_aHiddenPages.clear(); } @@ -101,16 +109,16 @@ namespace pcr { sal_Int32 nMinHeight( LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM ); - if ( m_aTabControl.GetPageCount() > 0 ) + if ( m_aTabControl->GetPageCount() > 0 ) { - sal_uInt16 nFirstID = m_aTabControl.GetPageId( 0 ); + sal_uInt16 nFirstID = m_aTabControl->GetPageId( 0 ); // reserve space for the tabs themself - Rectangle aTabArea( m_aTabControl.GetTabBounds( nFirstID ) ); + Rectangle aTabArea( m_aTabControl->GetTabBounds( nFirstID ) ); nMinHeight += aTabArea.GetHeight(); // ask the page how much it requires - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nFirstID ) ); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( nFirstID ) ); if ( pPage ) nMinHeight += pPage->getMinimumHeight(); } @@ -123,12 +131,12 @@ namespace pcr sal_Int32 OPropertyEditor::getMinimumWidth() { - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); sal_Int32 nPageMinWidth = 0; for(long i = nCount-1; i >= 0; --i) { - sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i); - OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); + sal_uInt16 nID = m_aTabControl->GetPageId((sal_uInt16)i); + OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) { sal_Int32 nCurPageMinWidth = pPage->getMinimumWidth(); @@ -144,11 +152,11 @@ namespace pcr { // commit all of my pages, if necessary - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); for ( sal_uInt16 i=0; i<nCount; ++i ) { - sal_uInt16 nID = m_aTabControl.GetPageId( i ); - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) ); + sal_uInt16 nID = m_aTabControl->GetPageId( i ); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( nID ) ); if ( pPage && pPage->getListBox().IsModified() ) pPage->getListBox().CommitModified(); @@ -158,7 +166,7 @@ namespace pcr void OPropertyEditor::GetFocus() { - m_aTabControl.GrabFocus(); + m_aTabControl->GrabFocus(); } @@ -167,7 +175,7 @@ namespace pcr OBrowserPage* pPage = NULL; MapStringToPageId::const_iterator aPropertyPageIdPos = m_aPropertyPageIds.find( _rPropertyName ); if ( aPropertyPageIdPos != m_aPropertyPageIds.end() ) - pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( aPropertyPageIdPos->second ) ); + pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( aPropertyPageIdPos->second ) ); return pPage; } @@ -180,7 +188,7 @@ namespace pcr OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) { - return static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( _rPageId ) ); + return static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( _rPageId ) ); } @@ -201,7 +209,7 @@ namespace pcr ); Rectangle aTabArea( aPlayground ); - m_aTabControl.SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() ); + m_aTabControl->SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() ); } @@ -210,13 +218,13 @@ namespace pcr // obtain a new id sal_uInt16 nId = m_nNextId++; // insert the id - m_aTabControl.InsertPage(nId, _rText); + m_aTabControl->InsertPage(nId, _rText); // create a new page - OBrowserPage* pPage = new OBrowserPage(&m_aTabControl); + VclPtrInstance<OBrowserPage> pPage(m_aTabControl.get()); pPage->SetText( _rText ); // some knittings - pPage->SetSizePixel(m_aTabControl.GetTabPageSizePixel()); + pPage->SetSizePixel(m_aTabControl->GetTabPageSizePixel()); pPage->getListBox().SetListener(m_pListener); pPage->getListBox().SetObserver(m_pObserver); pPage->getListBox().EnableHelpSection( m_bHasHelpSection ); @@ -224,8 +232,8 @@ namespace pcr pPage->SetHelpId( _rHelpId ); // immediately activate the page - m_aTabControl.SetTabPage(nId, pPage); - m_aTabControl.SetCurPageId(nId); + m_aTabControl->SetTabPage(nId, pPage); + m_aTabControl->SetCurPageId(nId); return nId; } @@ -234,32 +242,31 @@ namespace pcr void OPropertyEditor::SetHelpId( const OString& rHelpId ) { Control::SetHelpId(""); - m_aTabControl.SetHelpId(rHelpId); + m_aTabControl->SetHelpId(rHelpId); } void OPropertyEditor::RemovePage(sal_uInt16 nID) { - OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); + VclPtr<OBrowserPage> pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) pPage->EnableInput(false); - m_aTabControl.RemovePage(nID); - if (pPage) - delete pPage; + m_aTabControl->RemovePage(nID); + pPage.disposeAndClear(); } void OPropertyEditor::SetPage(sal_uInt16 nId) { - m_aTabControl.SetCurPageId(nId); + m_aTabControl->SetCurPageId(nId); } sal_uInt16 OPropertyEditor::GetCurPage() { - if(m_aTabControl.GetPageCount()>0) - return m_aTabControl.GetCurPageId(); + if(m_aTabControl->GetPageCount()>0) + return m_aTabControl->GetCurPageId(); else return 0; } @@ -268,11 +275,11 @@ namespace pcr void OPropertyEditor::Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction) { // forward this to all our pages - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); for (sal_uInt16 i=0;i<nCount;++i) { - sal_uInt16 nID = m_aTabControl.GetPageId(i); - OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID)); + sal_uInt16 nID = m_aTabControl->GetPageId(i); + OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) _aUpdateFunction(&pPage->getListBox()); } @@ -291,11 +298,11 @@ namespace pcr void OPropertyEditor::forEachPage( PageOperation _pOperation, const void* _pArgument ) { - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); for ( sal_uInt16 i=0; i<nCount; ++i ) { - sal_uInt16 nID = m_aTabControl.GetPageId(i); - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) ); + sal_uInt16 nID = m_aTabControl->GetPageId(i); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( nID ) ); if ( !pPage ) continue; (this->*_pOperation)( *pPage, _pArgument ); @@ -340,11 +347,11 @@ namespace pcr void OPropertyEditor::SetHelpText( const OUString& _rHelpText ) { - sal_uInt16 nCount = m_aTabControl.GetPageCount(); + sal_uInt16 nCount = m_aTabControl->GetPageCount(); for ( sal_uInt16 i=0; i<nCount; ++i ) { - sal_uInt16 nID = m_aTabControl.GetPageId(i); - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) ); + sal_uInt16 nID = m_aTabControl->GetPageId(i); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( nID ) ); if ( !pPage ) continue; setHelpSectionText( *pPage, &_rHelpText ); @@ -445,13 +452,13 @@ namespace pcr { if ( !_bShow ) { - sal_uInt16 nPagePos = m_aTabControl.GetPagePos( _nPageId ); + sal_uInt16 nPagePos = m_aTabControl->GetPagePos( _nPageId ); if ( TAB_PAGE_NOTFOUND == nPagePos ) return; DBG_ASSERT( m_aHiddenPages.find( _nPageId ) == m_aHiddenPages.end(), "OPropertyEditor::ShowPropertyPage: page already hidden!" ); - m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl.GetTabPage( _nPageId ) ); - m_aTabControl.RemovePage( _nPageId ); + m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl->GetTabPage( _nPageId ) ); + m_aTabControl->RemovePage( _nPageId ); } else { @@ -459,9 +466,9 @@ namespace pcr if ( aPagePos == m_aHiddenPages.end() ) return; - aPagePos->second.pPage->SetSizePixel( m_aTabControl.GetTabPageSizePixel() ); - m_aTabControl.InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos ); - m_aTabControl.SetTabPage( aPagePos->first, aPagePos->second.pPage ); + aPagePos->second.pPage->SetSizePixel( m_aTabControl->GetTabPageSizePixel() ); + m_aTabControl->InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos ); + m_aTabControl->SetTabPage( aPagePos->first, aPagePos->second.pPage ); m_aHiddenPages.erase( aPagePos ); } @@ -470,9 +477,9 @@ namespace pcr void OPropertyEditor::EnablePropertyControls( const OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable ) { - for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i ) + for ( sal_uInt16 i = 0; i < m_aTabControl->GetPageCount(); ++i ) { - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) ); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( m_aTabControl->GetPageId( i ) ) ); if ( pPage ) pPage->getListBox().EnablePropertyControls( _rEntryName, _nControls, _bEnable ); } @@ -481,9 +488,9 @@ namespace pcr void OPropertyEditor::EnablePropertyLine( const OUString& _rEntryName, bool _bEnable ) { - for ( sal_uInt16 i = 0; i < m_aTabControl.GetPageCount(); ++i ) + for ( sal_uInt16 i = 0; i < m_aTabControl->GetPageCount(); ++i ) { - OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) ); + OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl->GetTabPage( m_aTabControl->GetPageId( i ) ) ); if ( pPage ) pPage->getListBox().EnablePropertyLine( _rEntryName, _bEnable ); } @@ -494,7 +501,7 @@ namespace pcr { Reference< XPropertyControl > xControl; // let the current page handle this - OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(m_aTabControl.GetCurPageId())); + OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(m_aTabControl->GetCurPageId())); if (pPage) xControl = pPage->getListBox().GetPropertyControl(rEntryName); return xControl; @@ -513,8 +520,8 @@ namespace pcr { // commit the data on the current (to-be-decativated) tab page // (79404) - sal_Int32 nCurrentId = m_aTabControl.GetCurPageId(); - OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage((sal_uInt16)nCurrentId)); + sal_Int32 nCurrentId = m_aTabControl->GetCurPageId(); + OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage((sal_uInt16)nCurrentId)); if ( !pCurrentPage ) return 1L; diff --git a/extensions/source/propctrlr/propertyeditor.hxx b/extensions/source/propctrlr/propertyeditor.hxx index 18861826ed7a..3a868386d7b0 100644 --- a/extensions/source/propctrlr/propertyeditor.hxx +++ b/extensions/source/propctrlr/propertyeditor.hxx @@ -24,13 +24,13 @@ #include <com/sun/star/inspection/XPropertyControl.hpp> #include <vcl/tabctrl.hxx> +#include <vcl/vclptr.hxx> +#include <boost/mem_fn.hpp> #include <map> - namespace pcr { - class IPropertyLineListener; class IPropertyControlObserver; class OBrowserPage; @@ -47,13 +47,13 @@ namespace pcr struct HiddenPage { sal_uInt16 nPos; - TabPage* pPage; + VclPtr<TabPage> pPage; HiddenPage() : nPos( 0 ), pPage( NULL ) { } HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { } }; private: - TabControl m_aTabControl; + VclPtr<TabControl> m_aTabControl; IPropertyLineListener* m_pListener; IPropertyControlObserver* m_pObserver; sal_uInt16 m_nNextId; @@ -73,6 +73,7 @@ namespace pcr OPropertyEditor (vcl::Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL); virtual ~OPropertyEditor(); + virtual void dispose() SAL_OVERRIDE; void EnableUpdate(); void DisableUpdate(); diff --git a/extensions/source/propctrlr/selectlabeldialog.cxx b/extensions/source/propctrlr/selectlabeldialog.cxx index 27ed6d5d1799..43f372deecc1 100644 --- a/extensions/source/propctrlr/selectlabeldialog.cxx +++ b/extensions/source/propctrlr/selectlabeldialog.cxx @@ -145,6 +145,11 @@ namespace pcr OSelectLabelDialog::~OSelectLabelDialog() { + disposeOnce(); + } + + void OSelectLabelDialog::dispose() + { // delete the entry datas of the listbox entries SvTreeListEntry* pLoop = m_pControlTree->First(); while (pLoop) @@ -154,7 +159,10 @@ namespace pcr delete static_cast<Reference< XPropertySet > *>(pData); pLoop = m_pControlTree->Next(pLoop); } - + m_pMainDesc.clear(); + m_pControlTree.clear(); + m_pNoAssignment.clear(); + ModalDialog::dispose(); } sal_Int32 OSelectLabelDialog::InsertEntries(const Reference< XInterface > & _xContainer, SvTreeListEntry* pContainerEntry) diff --git a/extensions/source/propctrlr/selectlabeldialog.hxx b/extensions/source/propctrlr/selectlabeldialog.hxx index abb138248f97..45144c646738 100644 --- a/extensions/source/propctrlr/selectlabeldialog.hxx +++ b/extensions/source/propctrlr/selectlabeldialog.hxx @@ -40,9 +40,9 @@ namespace pcr :public ModalDialog ,public PcrClient { - FixedText *m_pMainDesc; - SvTreeListBox *m_pControlTree; - CheckBox *m_pNoAssignment; + VclPtr<FixedText> m_pMainDesc; + VclPtr<SvTreeListBox> m_pControlTree; + VclPtr<CheckBox> m_pNoAssignment; ImageList m_aModelImages; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControlModel; @@ -58,6 +58,7 @@ namespace pcr public: OSelectLabelDialog(vcl::Window* pParent, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xControlModel); virtual ~OSelectLabelDialog(); + virtual void dispose() SAL_OVERRIDE; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetSelected() const { return m_pNoAssignment->IsChecked() ? ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > () : m_xSelectedControl; } diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index af4d001dc784..240b3f51131c 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -959,14 +959,16 @@ namespace pcr class OMultilineFloatingEdit : public FloatingWindow { private: - MultiLineEdit m_aImplEdit; + VclPtr<MultiLineEdit> m_aImplEdit; protected: virtual void Resize() SAL_OVERRIDE; public: OMultilineFloatingEdit(vcl::Window* _pParen); - MultiLineEdit& getEdit() { return m_aImplEdit; } + virtual ~OMultilineFloatingEdit(); + virtual void dispose() SAL_OVERRIDE; + MultiLineEdit& getEdit() { return *m_aImplEdit.get(); } protected: virtual bool PreNotify(NotifyEvent& _rNEvt) SAL_OVERRIDE; @@ -975,15 +977,25 @@ namespace pcr OMultilineFloatingEdit::OMultilineFloatingEdit(vcl::Window* _pParent) :FloatingWindow(_pParent, WB_BORDER) - ,m_aImplEdit(this, WB_VSCROLL|WB_IGNORETAB|WB_NOBORDER) + ,m_aImplEdit(VclPtr<MultiLineEdit>::Create(this, WB_VSCROLL|WB_IGNORETAB|WB_NOBORDER)) { - m_aImplEdit.Show(); + m_aImplEdit->Show(); } + OMultilineFloatingEdit::~OMultilineFloatingEdit() + { + disposeOnce(); + } + + void OMultilineFloatingEdit::dispose() + { + m_aImplEdit.disposeAndClear(); + FloatingWindow::dispose(); + } void OMultilineFloatingEdit::Resize() { - m_aImplEdit.SetSizePixel(GetOutputSizePixel()); + m_aImplEdit->SetSizePixel(GetOutputSizePixel()); } @@ -1023,26 +1035,25 @@ namespace pcr DropDownEditControl::DropDownEditControl( vcl::Window* _pParent, WinBits _nStyle ) :DropDownEditControl_Base( _pParent, _nStyle ) ,m_pFloatingEdit( NULL ) - ,m_pImplEdit( NULL ) ,m_pDropdownButton( NULL ) ,m_nOperationMode( eStringList ) ,m_bDropdown( false ) { SetCompoundControl( true ); - m_pImplEdit = new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) ); + m_pImplEdit = VclPtr<MultiLineEdit>::Create( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) ); SetSubEdit( m_pImplEdit ); m_pImplEdit->Show(); if ( _nStyle & WB_DROPDOWN ) { - m_pDropdownButton = new PushButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP); + m_pDropdownButton = VclPtr<PushButton>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP); m_pDropdownButton->SetSymbol(SymbolType::SPIN_DOWN); m_pDropdownButton->SetClickHdl( LINK( this, DropDownEditControl, DropDownHdl ) ); m_pDropdownButton->Show(); } - m_pFloatingEdit = new OMultilineFloatingEdit(this); //FloatingWindow + m_pFloatingEdit = VclPtr<OMultilineFloatingEdit>::Create(this); m_pFloatingEdit->SetPopupModeEndHdl( LINK( this, DropDownEditControl, ReturnHdl ) ); m_pFloatingEdit->getEdit().SetReadOnly( ( _nStyle & WB_READONLY ) != 0 ); @@ -1061,19 +1072,16 @@ namespace pcr DropDownEditControl::~DropDownEditControl() { - { - boost::scoped_ptr<vcl::Window> aTemp(m_pFloatingEdit); - m_pFloatingEdit = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pImplEdit); - SetSubEdit( NULL ); - m_pImplEdit = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pDropdownButton); - m_pDropdownButton = NULL; - } + disposeOnce(); + } + + void DropDownEditControl::dispose() + { + SetSubEdit(nullptr); + m_pImplEdit.disposeAndClear(); + m_pFloatingEdit.disposeAndClear(); + m_pDropdownButton.disposeAndClear(); + DropDownEditControl_Base::dispose(); } @@ -1081,7 +1089,7 @@ namespace pcr { ::Size aOutSz = GetOutputSizePixel(); - if (m_pDropdownButton!=NULL) + if (m_pDropdownButton!=nullptr) { long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); nSBWidth = CalcZoom( nSBWidth ); @@ -1106,7 +1114,7 @@ namespace pcr { if ( m_pHelper ) { - m_pHelper->LoseFocusHdl( m_pImplEdit ); + m_pHelper->LoseFocusHdl( m_pImplEdit.get() ); m_pHelper->activateNextControl(); } } diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx index 8c80714bc3d5..9eb99354abda 100644 --- a/extensions/source/propctrlr/standardcontrol.hxx +++ b/extensions/source/propctrlr/standardcontrol.hxx @@ -374,15 +374,16 @@ namespace pcr class DropDownEditControl : public DropDownEditControl_Base { private: - OMultilineFloatingEdit* m_pFloatingEdit; - MultiLineEdit* m_pImplEdit; - PushButton* m_pDropdownButton; + VclPtr<OMultilineFloatingEdit> m_pFloatingEdit; + VclPtr<MultiLineEdit> m_pImplEdit; + VclPtr<PushButton> m_pDropdownButton; MultiLineOperationMode m_nOperationMode; bool m_bDropdown : 1; public: DropDownEditControl( vcl::Window* _pParent, WinBits _nStyle ); virtual ~DropDownEditControl(); + virtual void dispose() SAL_OVERRIDE; void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; } MultiLineOperationMode getOperationMode() const { return m_nOperationMode; } diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx index 8c64920aad01..8189fca44a92 100644 --- a/extensions/source/propctrlr/taborder.cxx +++ b/extensions/source/propctrlr/taborder.cxx @@ -118,10 +118,20 @@ namespace pcr TabOrderDialog::~TabOrderDialog() { + disposeOnce(); + } + + void TabOrderDialog::dispose() + { m_pLB_Controls->Hide(); // delete pLB_Controls; delete pImageList; - + m_pLB_Controls.clear(); + m_pPB_OK.clear(); + m_pPB_MoveUp.clear(); + m_pPB_MoveDown.clear(); + m_pPB_AutoOrder.clear(); + ModalDialog::dispose(); } diff --git a/extensions/source/propctrlr/taborder.hxx b/extensions/source/propctrlr/taborder.hxx index d70e60cce47f..f56d4b45bc01 100644 --- a/extensions/source/propctrlr/taborder.hxx +++ b/extensions/source/propctrlr/taborder.hxx @@ -73,13 +73,13 @@ namespace pcr ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xORB; - TabOrderListBox* m_pLB_Controls; + VclPtr<TabOrderListBox> m_pLB_Controls; - OKButton* m_pPB_OK; + VclPtr<OKButton> m_pPB_OK; - PushButton* m_pPB_MoveUp; - PushButton* m_pPB_MoveDown; - PushButton* m_pPB_AutoOrder; + VclPtr<PushButton> m_pPB_MoveUp; + VclPtr<PushButton> m_pPB_MoveDown; + VclPtr<PushButton> m_pPB_AutoOrder; ImageList* pImageList; @@ -102,6 +102,7 @@ namespace pcr ); virtual ~TabOrderDialog(); + virtual void dispose() SAL_OVERRIDE; void SetModified(); }; diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx index 99df0140e250..5d01cc891db5 100644 --- a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx +++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx @@ -496,11 +496,11 @@ namespace pcr ::std::vector< OUString > aExistentNames; m_pHelper->getAvailableDataTypeNames( aExistentNames ); - NewDataTypeDialog aDialog( NULL, pType->getName(), aExistentNames ); // TODO/eForms: proper parent - if ( aDialog.Execute() != RET_OK ) + ScopedVclPtrInstance<NewDataTypeDialog> aDialog( nullptr, pType->getName(), aExistentNames ); // TODO/eForms: proper parent + if ( aDialog->Execute() != RET_OK ) return false; - _rNewName = aDialog.GetName(); + _rNewName = aDialog->GetName(); return true; } @@ -535,8 +535,8 @@ namespace pcr // confirmation message OUString sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ).toString() ); sConfirmation = sConfirmation.replaceFirst( "#type#", pType->getName() ); - QueryBox aQuery( NULL, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent - if ( aQuery.Execute() != RET_YES ) + ScopedVclPtrInstance<QueryBox> aQuery( nullptr, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent + if ( aQuery->Execute() != RET_YES ) return false; return true; diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx index 1056a1474c9b..346715b4bc28 100644 --- a/extensions/source/scanner/grid.cxx +++ b/extensions/source/scanner/grid.cxx @@ -120,6 +120,7 @@ public: GridWindow(vcl::Window* pParent); void Init(double* pXValues, double* pYValues, int nValues, bool bCutValues, const BitmapEx &rMarkerBitmap); virtual ~GridWindow(); + virtual void dispose() SAL_OVERRIDE; void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY ); @@ -212,9 +213,29 @@ GridDialog::GridDialog(double* pXValues, double* pYValues, int nValues, vcl::Win m_pResetButton->SetClickHdl( LINK( this, GridDialog, ClickButtonHdl ) ); } +GridDialog::~GridDialog() +{ + disposeOnce(); +} + +void GridDialog::dispose() +{ + m_pOKButton.clear(); + m_pResetTypeBox.clear(); + m_pResetButton.clear(); + m_pGridWindow.clear(); + ModalDialog::dispose(); +} + GridWindow::~GridWindow() { + disposeOnce(); +} + +void GridWindow::dispose() +{ delete [] m_pNewYValues; + vcl::Window::dispose(); } double GridWindow::findMinX() diff --git a/extensions/source/scanner/grid.hxx b/extensions/source/scanner/grid.hxx index 6fca647facd5..940dec60097e 100644 --- a/extensions/source/scanner/grid.hxx +++ b/extensions/source/scanner/grid.hxx @@ -37,19 +37,20 @@ enum resetType class GridDialog : public ModalDialog { - OKButton* m_pOKButton; + VclPtr<OKButton> m_pOKButton; - ListBox* m_pResetTypeBox; - PushButton* m_pResetButton; + VclPtr<ListBox> m_pResetTypeBox; + VclPtr<PushButton> m_pResetButton; - GridWindow* m_pGridWindow; + VclPtr<GridWindow> m_pGridWindow; DECL_LINK( ClickButtonHdl, Button* ); public: GridDialog(double* pXValues, double* pYValues, int nValues, vcl::Window* pParent, bool bCutValues = true); - + virtual ~GridDialog(); + virtual void dispose() SAL_OVERRIDE; void setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY); double* getNewYValues(); }; diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx index ae9c4d5cc00d..384be4d3371d 100644 --- a/extensions/source/scanner/sanedlg.cxx +++ b/extensions/source/scanner/sanedlg.cxx @@ -43,7 +43,7 @@ private: Rectangle maPreviewRect; Point maTopLeft, maBottomRight; Point maMinTopLeft, maMaxBottomRight; - SaneDlg* mpParentDialog; + VclPtr<SaneDlg> mpParentDialog; DragDirection meDragDirection; bool mbDragEnable; bool mbDragDrawn; @@ -61,6 +61,12 @@ public: , mbIsDragging(false) { } + virtual ~ScanPreview() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE + { + mpParentDialog.clear(); + vcl::Window::dispose(); + } void Init(SaneDlg *pParent) { mpParentDialog = pParent; @@ -151,8 +157,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeScanPreview(vcl::Windo OString sBorder = VclBuilder::extractCustomProperty(rMap); if (!sBorder.isEmpty()) nWinStyle |= WB_BORDER; - ScanPreview *pWindow = new ScanPreview(pParent, nWinStyle); - return pWindow; + return new ScanPreview(pParent, nWinStyle); } SaneDlg::SaneDlg( vcl::Window* pParent, Sane& rSane, bool bScanEnabled ) : @@ -239,7 +244,37 @@ SaneDlg::SaneDlg( vcl::Window* pParent, Sane& rSane, bool bScanEnabled ) : SaneDlg::~SaneDlg() { + disposeOnce(); +} + +void SaneDlg::dispose() +{ mrSane.SetReloadOptionsHdl( maOldLink ); + mpOKButton.clear(); + mpCancelButton.clear(); + mpDeviceInfoButton.clear(); + mpPreviewButton.clear(); + mpScanButton.clear(); + mpButtonOption.clear(); + mpOptionTitle.clear(); + mpOptionDescTxt.clear(); + mpVectorTxt.clear(); + mpLeftField.clear(); + mpTopField.clear(); + mpRightField.clear(); + mpBottomField.clear(); + mpDeviceBox.clear(); + mpReslBox.clear(); + mpAdvancedBox.clear(); + mpVectorBox.clear(); + mpQuantumRangeBox.clear(); + mpStringRangeBox.clear(); + mpBoolCheckBox.clear(); + mpStringEdit.clear(); + mpNumericEdit.clear(); + mpOptionBox.clear(); + mpPreview.clear(); + ModalDialog::dispose(); } namespace { @@ -256,8 +291,8 @@ short SaneDlg::Execute() { if( ! Sane::IsSane() ) { - MessageDialog aErrorBox(NULL, SaneResId(STR_COULD_NOT_BE_INIT)); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, SaneResId(STR_COULD_NOT_BE_INIT)); + aErrorBox->Execute(); return RET_CANCEL; } LoadState(); @@ -539,8 +574,8 @@ IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton ) aString = aString.replaceFirst( "%s", Sane::GetVendor( mrSane.GetDeviceNumber() ) ); aString = aString.replaceFirst( "%s", Sane::GetModel( mrSane.GetDeviceNumber() ) ); aString = aString.replaceFirst( "%s", Sane::GetType( mrSane.GetDeviceNumber() ) ); - MessageDialog aInfoBox(this, aString, VCL_MESSAGE_INFO); - aInfoBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aInfoBox(this, aString, VCL_MESSAGE_INFO); + aInfoBox->Execute(); } else if( pButton == mpPreviewButton ) AcquirePreview(); @@ -568,11 +603,11 @@ IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton ) x[ i ] = (double)i; mrSane.GetOptionValue( mnCurrentOption, y.get() ); - GridDialog aGrid( x.get(), y.get(), nElements, this ); - aGrid.SetText( mrSane.GetOptionName( mnCurrentOption ) ); - aGrid.setBoundings( 0, mfMin, nElements, mfMax ); - if( aGrid.Execute() && aGrid.getNewYValues() ) - mrSane.SetOptionValue( mnCurrentOption, aGrid.getNewYValues() ); + ScopedVclPtrInstance< GridDialog > aGrid( x.get(), y.get(), nElements, this ); + aGrid->SetText( mrSane.GetOptionName( mnCurrentOption ) ); + aGrid->setBoundings( 0, mfMin, nElements, mfMax ); + if( aGrid->Execute() && aGrid->getNewYValues() ) + mrSane.SetOptionValue( mnCurrentOption, aGrid->getNewYValues() ); } break; case SANE_TYPE_BOOL: @@ -820,8 +855,8 @@ void SaneDlg::AcquirePreview() if( nOption == -1 ) { OUString aString(SaneResId(STR_SLOW_PREVIEW)); - MessageDialog aBox(this, aString, VCL_MESSAGE_WARNING, VCL_BUTTONS_OK_CANCEL); - if (aBox.Execute() == RET_CANCEL) + ScopedVclPtrInstance< MessageDialog > aBox(this, aString, VCL_MESSAGE_WARNING, VCL_BUTTONS_OK_CANCEL); + if (aBox->Execute() == RET_CANCEL) return; } else @@ -830,8 +865,8 @@ void SaneDlg::AcquirePreview() BitmapTransporter aTransporter; if( ! mrSane.Start( aTransporter ) ) { - MessageDialog aErrorBox(this, SaneResId(STR_ERROR_SCAN)); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox(this, SaneResId(STR_ERROR_SCAN)); + aErrorBox->Execute(); } else { diff --git a/extensions/source/scanner/sanedlg.hxx b/extensions/source/scanner/sanedlg.hxx index 57eaa54b0cb3..6aca2733c3a7 100644 --- a/extensions/source/scanner/sanedlg.hxx +++ b/extensions/source/scanner/sanedlg.hxx @@ -40,38 +40,38 @@ private: Link maOldLink; - OKButton* mpOKButton; - CancelButton* mpCancelButton; - PushButton* mpDeviceInfoButton; - PushButton* mpPreviewButton; - PushButton* mpScanButton; - PushButton* mpButtonOption; + VclPtr<OKButton> mpOKButton; + VclPtr<CancelButton> mpCancelButton; + VclPtr<PushButton> mpDeviceInfoButton; + VclPtr<PushButton> mpPreviewButton; + VclPtr<PushButton> mpScanButton; + VclPtr<PushButton> mpButtonOption; - FixedText* mpOptionTitle; - FixedText* mpOptionDescTxt; - FixedText* mpVectorTxt; + VclPtr<FixedText> mpOptionTitle; + VclPtr<FixedText> mpOptionDescTxt; + VclPtr<FixedText> mpVectorTxt; - MetricField* mpLeftField; - MetricField* mpTopField; - MetricField* mpRightField; - MetricField* mpBottomField; + VclPtr<MetricField> mpLeftField; + VclPtr<MetricField> mpTopField; + VclPtr<MetricField> mpRightField; + VclPtr<MetricField> mpBottomField; - ListBox* mpDeviceBox; - NumericBox* mpReslBox; - CheckBox* mpAdvancedBox; + VclPtr<ListBox> mpDeviceBox; + VclPtr<NumericBox> mpReslBox; + VclPtr<CheckBox> mpAdvancedBox; - NumericField* mpVectorBox; - ListBox* mpQuantumRangeBox; - ListBox* mpStringRangeBox; + VclPtr<NumericField> mpVectorBox; + VclPtr<ListBox> mpQuantumRangeBox; + VclPtr<ListBox> mpStringRangeBox; - CheckBox* mpBoolCheckBox; + VclPtr<CheckBox> mpBoolCheckBox; - Edit* mpStringEdit; - Edit* mpNumericEdit; + VclPtr<Edit> mpStringEdit; + VclPtr<Edit> mpNumericEdit; - SvTreeListBox* mpOptionBox; + VclPtr<SvTreeListBox> mpOptionBox; - ScanPreview* mpPreview; + VclPtr<ScanPreview> mpPreview; int mnCurrentOption; int mnCurrentElement; @@ -105,6 +105,7 @@ private: public: SaneDlg( vcl::Window*, Sane&, bool ); virtual ~SaneDlg(); + virtual void dispose() SAL_OVERRIDE; virtual short Execute() SAL_OVERRIDE; void UpdateScanArea( bool ); diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx index a66d797587dc..7d4da1f523fe 100644 --- a/extensions/source/scanner/scanunx.cxx +++ b/extensions/source/scanner/scanunx.cxx @@ -299,9 +299,9 @@ sal_Bool ScannerManager::configureScannerAndScan( ScannerContext& scanner_contex ); pHolder->m_bBusy = true; - SaneDlg aDlg( NULL, pHolder->m_aSane, listener.is() ); - bRet = aDlg.Execute(); - bScan = aDlg.getDoScan(); + ScopedVclPtrInstance< SaneDlg > aDlg(nullptr, pHolder->m_aSane, listener.is()); + bRet = aDlg->Execute(); + bScan = aDlg->getDoScan(); pHolder->m_bBusy = false; } if ( bScan ) diff --git a/extensions/workben/testframecontrol.cxx b/extensions/workben/testframecontrol.cxx index bb22d173db05..5cfa08c2c2a5 100644 --- a/extensions/workben/testframecontrol.cxx +++ b/extensions/workben/testframecontrol.cxx @@ -239,7 +239,7 @@ void FrameControlApplication::init() XInterfaceRef xInst = xMgr->createInstance( L"stardiv.one.frame.FrameControl" ); if (xInst->queryInterface( XControl::getSmartUik(), _xControl )) { - _pWorkWin = new WorkWindow( NULL, WB_APP | WB_STDWORK ); + _pWorkWin = VclPtr<WorkWindow>::Create( nullptr, WB_APP | WB_STDWORK ); _pWorkWin->Show(); XWindowPeerRef xParent( _pWorkWin->GetComponentInterface() ); |