diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 11:41:31 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 15:08:48 +0100 |
commit | e8b97a52c96df9c8e8055407b1e40ed7cb9cfc67 (patch) | |
tree | b322529f4a54a6427862cb20cb4cf87fb6a5d065 /dbaccess | |
parent | 2b0be6c0e9d23f1b8535ba7033732ae2e3bfb5c9 (diff) | |
parent | 0cde74f788a054fa2b65107a030dd463b8d11c7a (diff) |
Merge remote-tracking branch 'origin/feature/vclptr'
Resolve several thousand lines of conflicts.
Conflicts:
accessibility/source/extended/accessiblelistbox.cxx
accessibility/source/standard/vclxaccessiblecombobox.cxx
accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
accessibility/source/standard/vclxaccessiblelistbox.cxx
accessibility/source/standard/vclxaccessibletextfield.cxx
basctl/source/basicide/basidesh.cxx
cui/source/inc/chardlg.hxx
cui/source/tabpages/tpbitmap.cxx
dbaccess/source/ui/dlg/UserAdmin.cxx
dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
extensions/source/propctrlr/propertyeditor.hxx
extensions/source/scanner/sanedlg.cxx
filter/source/pdf/impdialog.cxx
include/sfx2/mgetempl.hxx
include/sfx2/sidebar/SidebarToolBox.hxx
include/sfx2/viewsh.hxx
include/svtools/brwbox.hxx
include/svtools/filectrl.hxx
include/svtools/scrwin.hxx
include/svx/dlgctrl.hxx
include/svx/sidebar/Popup.hxx
include/svx/sidebar/PopupContainer.hxx
include/svx/sidebar/PopupControl.hxx
include/svx/sidebar/SidebarDialControl.hxx
include/svx/sidebar/ValueSetWithTextControl.hxx
sc/source/ui/condformat/condformatdlgentry.cxx
sc/source/ui/navipi/navipi.cxx
sc/source/ui/sidebar/CellBorderStyleControl.hxx
sd/source/ui/animations/CustomAnimationDialog.cxx
sd/source/ui/inc/DrawViewShell.hxx
sd/source/ui/inc/Ruler.hxx
sd/source/ui/inc/SlideSorter.hxx
sd/source/ui/inc/ViewTabBar.hxx
sd/source/ui/inc/Window.hxx
sd/source/ui/inc/morphdlg.hxx
sd/source/ui/inc/sdpreslt.hxx
sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
sd/source/ui/sidebar/LayoutMenu.hxx
sd/source/ui/sidebar/MasterPagesSelector.hxx
sd/source/ui/sidebar/NavigatorWrapper.hxx
sd/source/ui/sidebar/PanelBase.hxx
sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
sd/source/ui/sidebar/RecentMasterPagesSelector.hxx
sd/source/ui/slideshow/showwindow.hxx
sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
sd/source/ui/view/ViewShellBase.cxx
sd/source/ui/view/drviewsa.cxx
sfx2/source/appl/fileobj.hxx
sfx2/source/appl/opengrf.cxx
sfx2/source/control/thumbnailviewacc.hxx
sfx2/source/dialog/securitypage.cxx
sfx2/source/dialog/templdlg.cxx
sfx2/source/doc/docinsert.cxx
sfx2/source/doc/guisaveas.cxx
sfx2/source/inc/alienwarn.hxx
sfx2/source/sidebar/Deck.cxx
sfx2/source/sidebar/Deck.hxx
sfx2/source/sidebar/DeckTitleBar.cxx
sfx2/source/sidebar/DeckTitleBar.hxx
sfx2/source/sidebar/MenuButton.cxx
sfx2/source/sidebar/MenuButton.hxx
sfx2/source/sidebar/Panel.cxx
sfx2/source/sidebar/Panel.hxx
sfx2/source/sidebar/PanelTitleBar.hxx
sfx2/source/sidebar/SidebarDockingWindow.hxx
sfx2/source/sidebar/SidebarToolBox.cxx
sfx2/source/sidebar/TabBar.hxx
sfx2/source/sidebar/TabItem.cxx
sfx2/source/sidebar/TabItem.hxx
sfx2/source/sidebar/TitleBar.hxx
sfx2/source/toolbox/imgmgr.cxx
starmath/inc/edit.hxx
starmath/inc/smmod.hxx
starmath/qa/cppunit/test_starmath.cxx
starmath/source/edit.cxx
starmath/source/smmod.cxx
svtools/source/brwbox/brwbox1.cxx
svtools/source/brwbox/datwin.hxx
svtools/source/contnr/fileview.cxx
svtools/source/contnr/simptabl.cxx
svtools/source/control/filectrl.cxx
svtools/source/control/valueimp.hxx
svx/inc/GalleryControl.hxx
svx/source/dialog/dlgctrl.cxx
svx/source/dialog/swframeexample.cxx
svx/source/fmcomp/fmgridif.cxx
svx/source/gallery2/GalleryControl.cxx
svx/source/sidebar/EmptyPanel.hxx
svx/source/sidebar/area/AreaPropertyPanel.hxx
svx/source/sidebar/area/AreaTransparencyGradientControl.hxx
svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
svx/source/sidebar/insert/InsertPropertyPanel.cxx
svx/source/sidebar/insert/InsertPropertyPanel.hxx
svx/source/sidebar/line/LinePropertyPanel.hxx
svx/source/sidebar/line/LineWidthControl.cxx
svx/source/sidebar/line/LineWidthControl.hxx
svx/source/sidebar/line/LineWidthValueSet.hxx
svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
svx/source/sidebar/possize/SidebarDialControl.cxx
svx/source/sidebar/text/TextCharacterSpacingPopup.hxx
svx/source/sidebar/text/TextPropertyPanel.hxx
svx/source/sidebar/tools/PopupContainer.cxx
svx/source/sidebar/tools/PopupControl.cxx
svx/source/sidebar/tools/ValueSetWithTextControl.cxx
svx/source/svdraw/svdfmtf.hxx
svx/source/svdraw/svdibrow.cxx
svx/source/tbxctrls/colrctrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
sw/source/ui/dbui/mmaddressblockpage.cxx
sw/source/ui/dialog/uiregionsw.cxx
sw/source/ui/index/cnttab.cxx
sw/source/uibase/inc/drpcps.hxx
sw/source/uibase/sidebar/PageColumnControl.hxx
sw/source/uibase/sidebar/PageMarginControl.hxx
sw/source/uibase/sidebar/PageOrientationControl.hxx
sw/source/uibase/sidebar/PagePropertyPanel.hxx
sw/source/uibase/sidebar/PageSizeControl.hxx
sw/source/uibase/uiview/view2.cxx
sw/source/uibase/utlui/navipi.cxx
vcl/inc/svdata.hxx
vcl/source/control/combobox.cxx
vcl/source/control/lstbox.cxx
vcl/source/window/dockwin.cxx
vcl/source/window/winproc.cxx
Change-Id: I056cf3026ff17d65cca0b6e6588bda4a88fa8d95
Diffstat (limited to 'dbaccess')
244 files changed, 2771 insertions, 1799 deletions
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index a0bb7289ca28..5062648b9e3f 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1505,6 +1505,7 @@ void SAL_CALL ODatabaseDocument::close( sal_Bool _bDeliverOwnership ) throw (Clo // SYNCHRONIZED -> { DocumentGuard aGuard(*this, DocumentGuard::DefaultMethod); + assert (!m_bClosing); m_bClosing = true; } // <- SYNCHRONIZED diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx index c643e8042942..b778fd68587e 100644 --- a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx @@ -406,8 +406,8 @@ namespace dbmm // check that the backup location isn't the same as the document itself if ( lcl_equalURLs_nothrow( m_pData->aContext, sBackupLocation, m_pData->xDocumentModel->getURL() ) ) { - MessageDialog aErrorBox( const_cast< MacroMigrationDialog* >( this ), MacroMigrationResId( STR_INVALID_BACKUP_LOCATION ) ); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox( const_cast< MacroMigrationDialog* >( this ), MacroMigrationResId( STR_INVALID_BACKUP_LOCATION ) ); + aErrorBox->Execute(); rBackupPage.grabLocationFocus(); return false; } diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.cxx b/dbaccess/source/ext/macromigration/macromigrationpages.cxx index c4ccd03e6353..c97494f41fda 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.cxx @@ -67,14 +67,25 @@ namespace dbmm get(m_pCloseDocError, "closedocerror"); } + PreparationPage::~PreparationPage() + { + disposeOnce(); + } + + void PreparationPage::dispose() + { + m_pCloseDocError.clear(); + MacroMigrationPage::dispose(); + } + void PreparationPage::showCloseDocsError( bool _bShow ) { m_pCloseDocError->Show( _bShow ); } - TabPage* PreparationPage::Create( ::svt::RoadmapWizard& _rParentDialog ) + VclPtr<TabPage> PreparationPage::Create( ::svt::RoadmapWizard& _rParentDialog ) { - return new PreparationPage(&_rParentDialog); + return VclPtr<PreparationPage>::Create(&_rParentDialog); } // SaveDBDocPage @@ -95,7 +106,16 @@ namespace dbmm SaveDBDocPage::~SaveDBDocPage() { + disposeOnce(); + } + + void SaveDBDocPage::dispose() + { delete m_pLocationController; + m_pSaveAsLocation.clear(); + m_pBrowseSaveAsLocation.clear(); + m_pStartMigration.clear(); + MacroMigrationPage::dispose(); } void SaveDBDocPage::impl_updateLocationDependentItems() @@ -156,9 +176,9 @@ namespace dbmm return true; } - TabPage* SaveDBDocPage::Create( ::svt::RoadmapWizard& _rParentDialog ) + VclPtr<TabPage> SaveDBDocPage::Create( ::svt::RoadmapWizard& _rParentDialog ) { - return new SaveDBDocPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) ); + return VclPtr<SaveDBDocPage>::Create( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) ); } // ProgressPage @@ -174,9 +194,24 @@ namespace dbmm get(m_pMigrationDone, "done"); } - TabPage* ProgressPage::Create(::svt::RoadmapWizard& _rParentDialog) + ProgressPage::~ProgressPage() { - return new ProgressPage(&_rParentDialog); + disposeOnce(); + } + + void ProgressPage::dispose() + { + m_pObjectCount.clear(); + m_pCurrentObject.clear(); + m_pCurrentAction.clear(); + m_pAllProgressText.clear(); + m_pMigrationDone.clear(); + MacroMigrationPage::dispose(); + } + + VclPtr<TabPage> ProgressPage::Create(::svt::RoadmapWizard& _rParentDialog) + { + return VclPtr<ProgressPage>::Create(&_rParentDialog); } void ProgressPage::setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports ) @@ -256,9 +291,22 @@ namespace dbmm get(m_pFailureLabel, "failure"); } - TabPage* ResultPage::Create(::svt::RoadmapWizard& _rParentDialog) + ResultPage::~ResultPage() + { + disposeOnce(); + } + + void ResultPage::dispose() + { + m_pSuccessLabel.clear(); + m_pFailureLabel.clear(); + m_pChanges.clear(); + MacroMigrationPage::dispose(); + } + + VclPtr<TabPage> ResultPage::Create(::svt::RoadmapWizard& _rParentDialog) { - return new ResultPage(&_rParentDialog); + return VclPtr<ResultPage>::Create(&_rParentDialog); } void ResultPage::displayMigrationLog(const bool _bSuccessful, const OUString& _rSummary) diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.hxx b/dbaccess/source/ext/macromigration/macromigrationpages.hxx index fc6ffc934521..70a70826783f 100644 --- a/dbaccess/source/ext/macromigration/macromigrationpages.hxx +++ b/dbaccess/source/ext/macromigration/macromigrationpages.hxx @@ -57,14 +57,16 @@ namespace dbmm { public: PreparationPage(vcl::Window *pParent); + virtual ~PreparationPage(); + virtual void dispose() SAL_OVERRIDE; - static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog ); + static VclPtr<TabPage> Create( ::svt::RoadmapWizard& _rParentDialog ); public: void showCloseDocsError(bool _bShow); protected: - FixedText* m_pCloseDocError; + VclPtr<FixedText> m_pCloseDocError; }; // SaveDBDocPage @@ -73,16 +75,17 @@ namespace dbmm public: SaveDBDocPage(MacroMigrationDialog& _rParentDialog); virtual ~SaveDBDocPage(); - static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog ); + virtual void dispose() SAL_OVERRIDE; + static VclPtr<TabPage> Create( ::svt::RoadmapWizard& _rParentDialog ); public: OUString getBackupLocation() const { return m_pLocationController->getURL(); } void grabLocationFocus() { m_pSaveAsLocation->GrabFocus(); } protected: - ::svt::OFileURLControl* m_pSaveAsLocation; - PushButton* m_pBrowseSaveAsLocation; - FixedText* m_pStartMigration; + VclPtr<::svt::OFileURLControl> m_pSaveAsLocation; + VclPtr<PushButton> m_pBrowseSaveAsLocation; + VclPtr<FixedText> m_pStartMigration; ::svx::DatabaseLocationInputController* m_pLocationController; protected: @@ -101,8 +104,10 @@ namespace dbmm { public: ProgressPage(vcl::Window *pParent); + virtual ~ProgressPage(); + virtual void dispose() SAL_OVERRIDE; - static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog ); + static VclPtr<TabPage> Create( ::svt::RoadmapWizard& _rParentDialog ); void setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports ); void onFinishedSuccessfully(); @@ -118,13 +123,13 @@ namespace dbmm virtual void setOverallProgressValue( const sal_uInt32 _nValue ) SAL_OVERRIDE; private: - FixedText* m_pObjectCount; - FixedText* m_pCurrentObject; - FixedText* m_pCurrentAction; - RangeProgressBar m_aCurrentProgress; - FixedText* m_pAllProgressText; - RangeProgressBar m_aAllProgress; - FixedText* m_pMigrationDone; + VclPtr<FixedText> m_pObjectCount; + VclPtr<FixedText> m_pCurrentObject; + VclPtr<FixedText> m_pCurrentAction; + RangeProgressBar m_aCurrentProgress; + VclPtr<FixedText> m_pAllProgressText; + RangeProgressBar m_aAllProgress; + VclPtr<FixedText> m_pMigrationDone; }; // ResultPage @@ -132,15 +137,17 @@ namespace dbmm { public: ResultPage(vcl::Window *pParent); + virtual ~ResultPage(); + virtual void dispose() SAL_OVERRIDE; - static TabPage* Create( ::svt::RoadmapWizard& _rParentDialog ); + static VclPtr<TabPage> Create( ::svt::RoadmapWizard& _rParentDialog ); void displayMigrationLog( const bool _bSuccessful, const OUString& _rLog ); private: - FixedText* m_pSuccessLabel; - FixedText* m_pFailureLabel; - VclMultiLineEdit* m_pChanges; + VclPtr<FixedText> m_pSuccessLabel; + VclPtr<FixedText> m_pFailureLabel; + VclPtr<VclMultiLineEdit> m_pChanges; }; } // namespace dbmm diff --git a/dbaccess/source/ext/macromigration/macromigrationwizard.cxx b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx index 5966a9b27e3c..740a337aeca8 100644 --- a/dbaccess/source/ext/macromigration/macromigrationwizard.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx @@ -88,7 +88,7 @@ namespace dbmm virtual ~MacroMigrationDialogService(); protected: - virtual Dialog* createDialog( vcl::Window* _pParent ) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog( vcl::Window* _pParent ) SAL_OVERRIDE; virtual void destroyDialog() SAL_OVERRIDE; private: @@ -121,9 +121,9 @@ namespace dbmm return *(new MacroMigrationDialogService( _rxContext ) ); } - Dialog* MacroMigrationDialogService::createDialog( vcl::Window* _pParent ) + VclPtr<Dialog> MacroMigrationDialogService::createDialog( vcl::Window* _pParent ) { - return new MacroMigrationDialog( _pParent, m_aContext, m_xDocument ); + return VclPtr<MacroMigrationDialog>::Create( _pParent, m_aContext, m_xDocument ); } void MacroMigrationDialogService::destroyDialog() diff --git a/dbaccess/source/ext/macromigration/rangeprogressbar.hxx b/dbaccess/source/ext/macromigration/rangeprogressbar.hxx index 0dde133e7f10..7b5a1a0e1282 100644 --- a/dbaccess/source/ext/macromigration/rangeprogressbar.hxx +++ b/dbaccess/source/ext/macromigration/rangeprogressbar.hxx @@ -65,7 +65,7 @@ namespace dbmm } private: - ProgressBar *m_pBar; + VclPtr<ProgressBar> m_pBar; sal_uInt32 m_nRange; }; diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 1cbbf0e24897..8836a5dc0dce 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -309,9 +309,7 @@ OApplicationController::~OApplicationController() osl_atomic_increment( &m_refCount ); dispose(); } - ::std::unique_ptr< vcl::Window> aTemp( getView() ); clearView(); - } IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base) @@ -427,7 +425,7 @@ void SAL_CALL OApplicationController::disposing() bool OApplicationController::Construct(vcl::Window* _pParent) { - setView( * new OApplicationView( _pParent, getORB(), *this, m_ePreviewMode ) ); + setView( VclPtr<OApplicationView>::Create( _pParent, getORB(), *this, m_ePreviewMode ) ); getView()->SetUniqueId(UID_APP_VIEW); // late construction @@ -447,7 +445,6 @@ bool OApplicationController::Construct(vcl::Window* _pParent) if ( !bSuccess ) { - ::std::unique_ptr< vcl::Window> aTemp( getView() ); clearView(); return false; } @@ -2048,7 +2045,7 @@ void OApplicationController::renameEntry() if ( xContainer.is() ) { ::std::unique_ptr< IObjectNameCheck > pNameChecker; - ::std::unique_ptr< OSaveAsDlg > aDialog; + VclPtr< OSaveAsDlg > aDialog; Reference<XRename> xRename; const ElementType eType = getContainer()->getElementType(); @@ -2081,7 +2078,8 @@ void OApplicationController::renameEntry() } } pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), OUString() ) ); - aDialog.reset( new OSaveAsDlg( + aDialog.reset( VclPtr<OSaveAsDlg>::Create( + getView(), getORB(), sName, sLabel, *pNameChecker, SAD_TITLE_RENAME ) ); } } @@ -2100,7 +2098,8 @@ void OApplicationController::renameEntry() ensureConnection(); pNameChecker.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType ) ); - aDialog.reset( new OSaveAsDlg( + aDialog.reset( VclPtr<OSaveAsDlg>::Create( + getView(), nCommandType, getORB(), getConnection(), *aList.begin(), *pNameChecker, SAD_TITLE_RENAME ) ); } diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx index 4f4da2f070d0..f18b2d010b85 100644 --- a/dbaccess/source/ui/app/AppControllerDnD.cxx +++ b/dbaccess/source/ui/app/AppControllerDnD.cxx @@ -175,8 +175,8 @@ void OApplicationController::deleteTables(const ::std::vector< OUString>& _rList else { OUString sMessage(ModuleRes(STR_MISSING_TABLES_XDROP)); - MessageDialog aError(getView(), sMessage); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(getView(), sMessage); + aError->Execute(); } } } @@ -210,19 +210,19 @@ void OApplicationController::deleteObjects( ElementType _eType, const ::std::vec if ( eResult != svtools::QUERYDELETE_ALL ) { - svtools::QueryDeleteDlg_Impl aDlg( getView(), *aThisRound ); + ScopedVclPtrInstance< svtools::QueryDeleteDlg_Impl > aDlg(getView(), *aThisRound); if ( !sDialogPosition.isEmpty() ) - aDlg.SetWindowState( sDialogPosition ); + aDlg->SetWindowState( sDialogPosition ); if ( nObjectsLeft > 1 ) - aDlg.EnableAllButton(); + aDlg->EnableAllButton(); - eResult = aDlg.Execute(); + eResult = aDlg->Execute(); if (eResult == svtools::QUERYDELETE_CANCEL) return; - sDialogPosition = aDlg.GetWindowState( ); + sDialogPosition = aDlg->GetWindowState( ); } bool bSuccess = false; @@ -686,17 +686,18 @@ bool OApplicationController::paste( ElementType _eType, const ::svx::ODataAccess has a /table/ with that name) */ if ( bNeedAskForName ) { - OSaveAsDlg aAskForName( getView(), + ScopedVclPtrInstance<OSaveAsDlg> aAskForName( + getView(), CommandType::QUERY, getORB(), getConnection(), sTargetName, aNameChecker, - SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS); - if ( RET_OK != aAskForName.Execute() ) + SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS ); + if ( RET_OK != aAskForName->Execute() ) // cancelled by the user return false; - sTargetName = aAskForName.getName(); + sTargetName = aAskForName->getName(); } // create a new object diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index 3eda31592a78..e9424506727a 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -111,12 +111,12 @@ void OApplicationController::convertToView(const OUString& _sName) OUString aDefaultName = ::dbaui::createDefaultName(xMeta,xTables,aName); DynamicTableOrQueryNameCheck aNameChecker( xConnection, CommandType::TABLE ); - OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), xConnection, aDefaultName, aNameChecker ); - if ( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance< OSaveAsDlg > aDlg( getView(), CommandType::TABLE, getORB(), xConnection, aDefaultName, aNameChecker ); + if ( aDlg->Execute() == RET_OK ) { - OUString sName = aDlg.getName(); - OUString sCatalog = aDlg.getCatalog(); - OUString sSchema = aDlg.getSchema(); + OUString sName = aDlg->getName(); + OUString sCatalog = aDlg->getCatalog(); + OUString sSchema = aDlg->getSchema(); OUString sNewName( ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sName, false, ::dbtools::eInTableDefinitions ) ); Reference<XPropertySet> xView = ::dbaui::createView(sNewName,xConnection,xSourceObject); @@ -534,8 +534,8 @@ void OApplicationController::askToReconnect() bool bClear = true; if ( !m_pSubComponentManager->empty() ) { - MessageDialog aQry(getView(), ModuleRes(STR_QUERY_CLOSEDOCUMENTS), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - switch (aQry.Execute()) + ScopedVclPtrInstance< MessageDialog > aQry(getView(), ModuleRes(STR_QUERY_CLOSEDOCUMENTS), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + switch (aQry->Execute()) { case RET_YES: closeSubComponents(); diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index f01c26bcf9ef..6907968e1fa2 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -188,34 +188,33 @@ namespace // class OAppDetailPageHelper OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL) ,m_rBorderWin(_rBorderWin) - ,m_aFL(this,WB_VERT) - ,m_aTBPreview(this,WB_TABSTOP ) - ,m_aBorder(this,WB_BORDER | WB_READONLY) - ,m_aPreview(&m_aBorder) - ,m_aDocumentInfo(&m_aBorder,WB_LEFT | WB_VSCROLL | WB_READONLY ) - ,m_pTablePreview(NULL) + ,m_aFL(VclPtr<FixedLine>::Create(this,WB_VERT)) + ,m_aTBPreview(VclPtr<ToolBox>::Create(this,WB_TABSTOP) ) + ,m_aBorder(VclPtr<Window>::Create(this,WB_BORDER | WB_READONLY)) + ,m_aPreview(VclPtr<OPreviewWindow>::Create(m_aBorder.get())) + ,m_aDocumentInfo(new ::svtools::ODocumentInfoPreview(m_aBorder.get(), WB_LEFT | WB_VSCROLL | WB_READONLY) ) ,m_ePreviewMode(_ePreviewMode) { - m_aBorder.SetBorderStyle(WindowBorderStyle::MONO); + m_aBorder->SetBorderStyle(WindowBorderStyle::MONO); m_aMenu.reset(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) )); - m_aTBPreview.SetOutStyle(TOOLBOX_STYLE_FLAT); - m_aTBPreview.InsertItem(SID_DB_APP_DISABLE_PREVIEW,m_aMenu->GetItemText(SID_DB_APP_DISABLE_PREVIEW),ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK); - m_aTBPreview.SetHelpId(HID_APP_VIEW_PREVIEW_CB); - m_aTBPreview.SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) ); - m_aTBPreview.EnableMenuStrings(); - m_aTBPreview.Enable(true); + m_aTBPreview->SetOutStyle(TOOLBOX_STYLE_FLAT); + m_aTBPreview->InsertItem(SID_DB_APP_DISABLE_PREVIEW,m_aMenu->GetItemText(SID_DB_APP_DISABLE_PREVIEW),ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN|ToolBoxItemBits::AUTOSIZE|ToolBoxItemBits::RADIOCHECK); + m_aTBPreview->SetHelpId(HID_APP_VIEW_PREVIEW_CB); + m_aTBPreview->SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) ); + m_aTBPreview->EnableMenuStrings(); + m_aTBPreview->Enable(true); - m_aBorder.SetUniqueId(UID_APP_VIEW_PREVIEW_1); + m_aBorder->SetUniqueId(UID_APP_VIEW_PREVIEW_1); - m_aPreview.SetHelpId(HID_APP_VIEW_PREVIEW_1); + m_aPreview->SetHelpId(HID_APP_VIEW_PREVIEW_1); - m_pTablePreview = new OTablePreviewWindow(&m_aBorder,WB_READONLY | WB_DIALOGCONTROL ); + m_pTablePreview.set( VclPtr<OTablePreviewWindow>::Create(m_aBorder.get(), WB_READONLY | WB_DIALOGCONTROL ) ); m_pTablePreview->SetHelpId(HID_APP_VIEW_PREVIEW_2); - m_aDocumentInfo.SetHelpId(HID_APP_VIEW_PREVIEW_3); + m_aDocumentInfo->SetHelpId(HID_APP_VIEW_PREVIEW_3); m_xWindow = VCLUnoHelper::GetInterface( m_pTablePreview ); @@ -227,6 +226,11 @@ OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindo OAppDetailPageHelper::~OAppDetailPageHelper() { + disposeOnce(); +} + +void OAppDetailPageHelper::dispose() +{ try { Reference< ::util::XCloseable> xCloseable(m_xFrame,UNO_QUERY); @@ -244,13 +248,19 @@ OAppDetailPageHelper::~OAppDetailPageHelper() { m_pLists[i]->clearCurrentSelection(); m_pLists[i]->Hide(); - boost::scoped_ptr<DBTreeListBox> aTemp(m_pLists[i]); m_pLists[i]->clearCurrentSelection(); // why a second time? - m_pLists[i] = NULL; + m_pLists[i].disposeAndClear(); } - } - + m_aMenu.reset(); + m_pTablePreview.disposeAndClear(); + m_aDocumentInfo.disposeAndClear(); + m_aPreview.disposeAndClear(); + m_aBorder.disposeAndClear(); + m_aTBPreview.disposeAndClear(); + m_aFL.disposeAndClear(); + + vcl::Window::dispose(); } int OAppDetailPageHelper::getVisibleControlIndex() const @@ -358,7 +368,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _r void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects ) { OSL_ENSURE( _eType < E_ELEMENT_TYPE_COUNT, "OAppDetailPageHelper::describeCurrentSelectionForType: invalid type!" ); - DBTreeListBox* pList = ( _eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ _eType ] : NULL; + DBTreeListBox* pList = ( _eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ _eType ].get() : NULL; OSL_ENSURE( pList, "OAppDetailPageHelper::describeCurrentSelectionForType: " "You really should ensure this type has already been viewed before!" ); if ( !pList ) @@ -560,7 +570,7 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon if ( !m_pLists[E_TABLE] ) { - OTableTreeListBox* pTreeView = new OTableTreeListBox(this, + VclPtrInstance<OTableTreeListBox> pTreeView(this, WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP); pTreeView->SetHelpId(HID_APP_TABLE_TREE); m_pLists[E_TABLE] = pTreeView; @@ -571,11 +581,11 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon ); pTreeView->notifyHiContrastChanged(); - m_aBorder.SetZOrder(pTreeView, WINDOW_ZORDER_BEHIND); + m_aBorder->SetZOrder(pTreeView, WINDOW_ZORDER_BEHIND); } if ( !m_pLists[E_TABLE]->GetEntryCount() ) { - static_cast<OTableTreeListBox*>(m_pLists[E_TABLE])->UpdateTableList(_xConnection); + static_cast<OTableTreeListBox*>(m_pLists[E_TABLE].get())->UpdateTableList(_xConnection); SvTreeListEntry* pEntry = m_pLists[E_TABLE]->First(); if ( pEntry ) @@ -657,13 +667,13 @@ void OAppDetailPageHelper::setDetailPage(vcl::Window* _pWindow) showPreview(NULL); bool bHasFocus = false; - m_aFL.Show(); + m_aFL->Show(); { bHasFocus = pCurrent != 0 && pCurrent->HasChildPathFocus(); _pWindow->Show(); } - m_aTBPreview.Show(); - m_aBorder.Show(); + m_aTBPreview->Show(); + m_aBorder->Show(); switchPreview(m_ePreviewMode,true); if ( bHasFocus ) @@ -727,7 +737,7 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine DBTreeListBox* OAppDetailPageHelper::createSimpleTree( const OString& _sHelpId, const Image& _rImage) { - DBTreeListBox* pTreeView = new DBTreeListBox(this, + VclPtrInstance<DBTreeListBox> pTreeView(this, WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP); pTreeView->SetHelpId( _sHelpId ); return createTree( pTreeView, _rImage ); @@ -947,17 +957,17 @@ void OAppDetailPageHelper::Resize() pWindow->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) ); - m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0 ), Size(aFLSize.Width(), nOutputHeight ) ); + m_aFL->SetPosSizePixel( Point(nHalfOutputWidth , 0 ), Size(aFLSize.Width(), nOutputHeight ) ); - Size aTBSize = m_aTBPreview.CalcWindowSizePixel(); - m_aTBPreview.SetPosSizePixel(Point(nOutputWidth - aTBSize.getWidth(), 0 ), + Size aTBSize = m_aTBPreview->CalcWindowSizePixel(); + m_aTBPreview->SetPosSizePixel(Point(nOutputWidth - aTBSize.getWidth(), 0 ), aTBSize ); - m_aBorder.SetPosSizePixel(Point(nHalfOutputWidth + aFLSize.Width() + n6PPT, aTBSize.getHeight() + n6PPT ), + m_aBorder->SetPosSizePixel(Point(nHalfOutputWidth + aFLSize.Width() + n6PPT, aTBSize.getHeight() + n6PPT ), Size(nHalfOutputWidth - aFLSize.Width() - n6PPT, nOutputHeight - 2*n6PPT - aTBSize.getHeight()) ); - m_aPreview.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() ); - m_aDocumentInfo.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() ); - m_pTablePreview->SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() ); + m_aPreview->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() ); + m_aDocumentInfo->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() ); + m_pTablePreview->SetPosSizePixel(Point(0,0),m_aBorder->GetSizePixel() ); } } @@ -993,7 +1003,7 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce) } m_aMenu->CheckItem(nSelectedAction); - m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, m_aMenu->GetItemText(nSelectedAction)); + m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, m_aMenu->GetItemText(nSelectedAction)); Resize(); // simulate a selectionChanged event at the controller, to force the preview to be updated @@ -1007,8 +1017,8 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,bool _bForce) else { m_pTablePreview->Hide(); - m_aPreview.Hide(); - m_aDocumentInfo.Hide(); + m_aPreview->Hide(); + m_aDocumentInfo->Hide(); } } } @@ -1034,8 +1044,8 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent) Any aPreview = xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >()); if ( m_ePreviewMode == E_DOCUMENT ) { - m_aDocumentInfo.Hide(); - m_aPreview.Show(); + m_aDocumentInfo->Hide(); + m_aPreview->Show(); Graphic aGraphic; Sequence < sal_Int8 > aBmpSequence; @@ -1047,24 +1057,24 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent) GraphicConverter::Import(aData,aGraphic); } - m_aPreview.setGraphic( aGraphic ); - m_aPreview.Invalidate(); + m_aPreview->setGraphic( aGraphic ); + m_aPreview->Invalidate(); } else { - m_aPreview.Hide(); - m_aDocumentInfo.clear(); - m_aDocumentInfo.Show(); + m_aPreview->Hide(); + m_aDocumentInfo->clear(); + m_aDocumentInfo->Show(); Reference<document::XDocumentProperties> xProp( aPreview, UNO_QUERY); if ( xProp.is() ) - m_aDocumentInfo.fill(xProp,OUString()); + m_aDocumentInfo->fill(xProp,OUString()); } } else { - m_aPreview.Hide(); - m_aDocumentInfo.Hide(); + m_aPreview->Hide(); + m_aDocumentInfo->Hide(); } } catch( const Exception& ) @@ -1081,8 +1091,8 @@ void OAppDetailPageHelper::showPreview( const OUString& _sDataSourceName, if ( isPreviewEnabled() ) { WaitObject aWaitCursor( this ); - m_aPreview.Hide(); - m_aDocumentInfo.Hide(); + m_aPreview->Hide(); + m_aDocumentInfo->Hide(); m_pTablePreview->Show(); if ( !m_xFrame.is() ) { @@ -1142,17 +1152,17 @@ void OAppDetailPageHelper::showPreview( const OUString& _sDataSourceName, IMPL_LINK(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, /*pToolBox*/) { - m_aTBPreview.EndSelection(); + m_aTBPreview->EndSelection(); // tell the toolbox that the item is pressed down - m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, true ); + m_aTBPreview->SetItemDown( SID_DB_APP_DISABLE_PREVIEW, true ); // simulate a mouse move (so the "down" state is really painted) - Point aPoint = m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW ).TopLeft(); + Point aPoint = m_aTBPreview->GetItemRect( SID_DB_APP_DISABLE_PREVIEW ).TopLeft(); MouseEvent aMove( aPoint, 0, MouseEventModifiers::SIMPLEMOVE | MouseEventModifiers::SYNTHETIC ); - m_aTBPreview.MouseMove( aMove ); + m_aTBPreview->MouseMove( aMove ); - m_aTBPreview.Update(); + m_aTBPreview->Update(); // execute the menu boost::scoped_ptr<PopupMenu> aMenu(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) )); @@ -1171,14 +1181,14 @@ IMPL_LINK(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, /*pToolBox*/) // no disabled entries aMenu->RemoveDisabledEntries(); - sal_uInt16 nSelectedAction = aMenu->Execute(&m_aTBPreview, m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW )); + sal_uInt16 nSelectedAction = aMenu->Execute(m_aTBPreview.get(), m_aTBPreview->GetItemRect( SID_DB_APP_DISABLE_PREVIEW )); // "cleanup" the toolbox state MouseEvent aLeave( aPoint, 0, MouseEventModifiers::LEAVEWINDOW | MouseEventModifiers::SYNTHETIC ); - m_aTBPreview.MouseMove( aLeave ); - m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, false); + m_aTBPreview->MouseMove( aLeave ); + m_aTBPreview->SetItemDown( SID_DB_APP_DISABLE_PREVIEW, false); if ( nSelectedAction ) { - m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, aMenu->GetItemText(nSelectedAction)); + m_aTBPreview->SetItemText(SID_DB_APP_DISABLE_PREVIEW, aMenu->GetItemText(nSelectedAction)); Resize(); getBorderWin().getView()->getAppController().executeChecked(nSelectedAction,Sequence<PropertyValue>()); } @@ -1215,7 +1225,7 @@ void OAppDetailPageHelper::DataChanged( const DataChangedEvent& rDCEvt ) ImplInitSettings(); if ( m_pLists[ E_TABLE ] ) { - OTableTreeListBox* pTableTree = dynamic_cast< OTableTreeListBox* >( m_pLists[ E_TABLE ] ); + OTableTreeListBox* pTableTree = dynamic_cast< OTableTreeListBox* >( m_pLists[ E_TABLE ].get() ); OSL_ENSURE( pTableTree != NULL, "OAppDetailPageHelper::DataChanged: a tree list for tables which is no TableTreeList?" ); if ( pTableTree ) pTableTree->notifyHiContrastChanged(); @@ -1230,19 +1240,19 @@ void OAppDetailPageHelper::ImplInitSettings() aFont = rStyleSettings.GetFieldFont(); aFont.SetColor( rStyleSettings.GetWindowTextColor() ); SetPointFont( aFont ); - m_aTBPreview.SetPointFont( aFont ); + m_aTBPreview->SetPointFont( aFont ); SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - m_aBorder.SetTextColor( rStyleSettings.GetFieldTextColor() ); - m_aBorder.SetTextFillColor(); - m_aTBPreview.SetTextColor( rStyleSettings.GetFieldTextColor() ); - m_aTBPreview.SetTextFillColor(); + m_aBorder->SetTextColor( rStyleSettings.GetFieldTextColor() ); + m_aBorder->SetTextFillColor(); + m_aTBPreview->SetTextColor( rStyleSettings.GetFieldTextColor() ); + m_aTBPreview->SetTextFillColor(); SetBackground( rStyleSettings.GetFieldColor() ); - m_aBorder.SetBackground( rStyleSettings.GetFieldColor() ); - m_aFL.SetBackground( rStyleSettings.GetFieldColor() ); - m_aDocumentInfo.SetBackground( rStyleSettings.GetFieldColor() ); - m_aTBPreview.SetBackground( rStyleSettings.GetFieldColor() ); + m_aBorder->SetBackground( rStyleSettings.GetFieldColor() ); + m_aFL->SetBackground( rStyleSettings.GetFieldColor() ); + m_aDocumentInfo->SetBackground( rStyleSettings.GetFieldColor() ); + m_aTBPreview->SetBackground( rStyleSettings.GetFieldColor() ); m_pTablePreview->SetBackground( rStyleSettings.GetFieldColor() ); } diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx index fb86bdd3f050..9240fb94e0b5 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.hxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx @@ -77,15 +77,15 @@ namespace dbaui // Combines general functionality. class OAppDetailPageHelper : public vcl::Window { - DBTreeListBox* m_pLists[ELEMENT_COUNT]; + VclPtr<DBTreeListBox> m_pLists[ELEMENT_COUNT]; OAppBorderWindow& m_rBorderWin; - FixedLine m_aFL; - ToolBox m_aTBPreview; - Window m_aBorder; - OPreviewWindow m_aPreview; - ::svtools::ODocumentInfoPreview - m_aDocumentInfo; - vcl::Window* m_pTablePreview; + VclPtr<FixedLine> m_aFL; + VclPtr<ToolBox> m_aTBPreview; + VclPtr<Window> m_aBorder; + VclPtr<OPreviewWindow> m_aPreview; + VclPtr<::svtools::ODocumentInfoPreview> + m_aDocumentInfo; + VclPtr<vcl::Window> m_pTablePreview; ::std::unique_ptr<PopupMenu> m_aMenu; PreviewMode m_ePreviewMode; ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 > @@ -169,6 +169,7 @@ namespace dbaui public: OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode); virtual ~OAppDetailPageHelper(); + virtual void dispose() SAL_OVERRIDE; // Window overrides virtual void Resize() SAL_OVERRIDE; @@ -193,7 +194,7 @@ namespace dbaui inline DBTreeListBox* getCurrentView() const { ElementType eType = getElementType(); - return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)] : NULL; + return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)].get() : NULL; } /// select all entries in the visible control diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx index aebcd5d3d35d..5ef2b69be554 100644 --- a/dbaccess/source/ui/app/AppDetailView.cxx +++ b/dbaccess/source/ui/app/AppDetailView.cxx @@ -341,30 +341,41 @@ void OCreationList::KeyInput( const KeyEvent& rKEvt ) OTasksWindow::OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView) : Window(_pParent,WB_DIALOGCONTROL ) - ,m_aCreation(*this) - ,m_aDescription(this) - ,m_aHelpText(this,WB_WORDBREAK) - ,m_aFL(this,WB_VERT) + ,m_aCreation(VclPtr<OCreationList>::Create(*this)) + ,m_aDescription(VclPtr<FixedText>::Create(this)) + ,m_aHelpText(VclPtr<FixedText>::Create(this,WB_WORDBREAK)) + ,m_aFL(VclPtr<FixedLine>::Create(this,WB_VERT)) ,m_pDetailView(_pDetailView) { SetUniqueId(UID_APP_TASKS_WINDOW); - m_aCreation.SetHelpId(HID_APP_CREATION_LIST); - m_aCreation.SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl)); - m_aHelpText.SetHelpId(HID_APP_HELP_TEXT); - m_aDescription.SetHelpId(HID_APP_DESCRIPTION_TEXT); - m_aDescription.SetText(ModuleRes(STR_DESCRIPTION)); + m_aCreation->SetHelpId(HID_APP_CREATION_LIST); + m_aCreation->SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl)); + m_aHelpText->SetHelpId(HID_APP_HELP_TEXT); + m_aDescription->SetHelpId(HID_APP_DESCRIPTION_TEXT); + m_aDescription->SetText(ModuleRes(STR_DESCRIPTION)); ImageProvider aImageProvider; Image aFolderImage = aImageProvider.getFolderImage( css::sdb::application::DatabaseObject::FORM ); - m_aCreation.SetDefaultCollapsedEntryBmp( aFolderImage ); - m_aCreation.SetDefaultExpandedEntryBmp( aFolderImage ); + m_aCreation->SetDefaultCollapsedEntryBmp( aFolderImage ); + m_aCreation->SetDefaultExpandedEntryBmp( aFolderImage ); ImplInitSettings(true,true,true); } OTasksWindow::~OTasksWindow() { + disposeOnce(); +} + +void OTasksWindow::dispose() +{ Clear(); + m_aCreation.disposeAndClear(); + m_aDescription.disposeAndClear(); + m_aHelpText.disposeAndClear(); + m_aFL.disposeAndClear(); + m_pDetailView.clear(); + vcl::Window::dispose(); } void OTasksWindow::DataChanged( const DataChangedEvent& rDCEvt ) @@ -394,23 +405,23 @@ void OTasksWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackgro { SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - m_aHelpText.SetTextColor( rStyleSettings.GetFieldTextColor() ); - m_aHelpText.SetTextFillColor(); - m_aDescription.SetTextColor( rStyleSettings.GetFieldTextColor() ); - m_aDescription.SetTextFillColor(); + m_aHelpText->SetTextColor( rStyleSettings.GetFieldTextColor() ); + m_aHelpText->SetTextFillColor(); + m_aDescription->SetTextColor( rStyleSettings.GetFieldTextColor() ); + m_aDescription->SetTextFillColor(); } if( bBackground ) { SetBackground( rStyleSettings.GetFieldColor() ); - m_aHelpText.SetBackground( rStyleSettings.GetFieldColor() ); - m_aDescription.SetBackground( rStyleSettings.GetFieldColor() ); - m_aFL.SetBackground( rStyleSettings.GetFieldColor() ); + m_aHelpText->SetBackground( rStyleSettings.GetFieldColor() ); + m_aDescription->SetBackground( rStyleSettings.GetFieldColor() ); + m_aFL->SetBackground( rStyleSettings.GetFieldColor() ); } - vcl::Font aFont = m_aDescription.GetControlFont(); + vcl::Font aFont = m_aDescription->GetControlFont(); aFont.SetWeight(WEIGHT_BOLD); - m_aDescription.SetControlFont(aFont); + m_aDescription->SetControlFont(aFont); } void OTasksWindow::setHelpText(sal_uInt16 _nId) @@ -418,20 +429,20 @@ void OTasksWindow::setHelpText(sal_uInt16 _nId) if ( _nId ) { OUString sText = ModuleRes(_nId); - m_aHelpText.SetText(sText); + m_aHelpText->SetText(sText); } else { - m_aHelpText.SetText(OUString()); + m_aHelpText->SetText(OUString()); } } IMPL_LINK(OTasksWindow, OnEntrySelectHdl, SvTreeListBox*, /*_pTreeBox*/) { - SvTreeListEntry* pEntry = m_aCreation.GetHdlEntry(); + SvTreeListEntry* pEntry = m_aCreation->GetHdlEntry(); if ( pEntry ) - m_aHelpText.SetText( ModuleRes( static_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) ); + m_aHelpText->SetText( ModuleRes( static_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) ); return 1L; } @@ -446,14 +457,14 @@ void OTasksWindow::Resize() sal_Int32 n6PPT = aFLSize.Height(); long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5); - m_aCreation.SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) ); + m_aCreation->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) ); // i77897 make the m_aHelpText a little bit smaller. (-5) sal_Int32 nNewWidth = nOutputWidth - nHalfOutputWidth - aFLSize.Width() - 5; - m_aDescription.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) ); - Size aDesc = m_aDescription.CalcMinimumSize(); - m_aHelpText.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) ); + m_aDescription->SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) ); + Size aDesc = m_aDescription->CalcMinimumSize(); + m_aHelpText->SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) ); - m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) ); + m_aFL->SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) ); } void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) @@ -485,79 +496,88 @@ void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages ) { - SvTreeListEntry* pEntry = m_aCreation.InsertEntry( pTask->sTitle ); + SvTreeListEntry* pEntry = m_aCreation->InsertEntry( pTask->sTitle ); pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) ); Image aImage = Image( *pImages ); - m_aCreation.SetExpandedEntryBmp( pEntry, aImage ); - m_aCreation.SetCollapsedEntryBmp( pEntry, aImage ); + m_aCreation->SetExpandedEntryBmp( pEntry, aImage ); + m_aCreation->SetCollapsedEntryBmp( pEntry, aImage ); } } catch(Exception&) { } - m_aCreation.Show(); - m_aCreation.SelectAll(false); - m_aHelpText.Show(); - m_aDescription.Show(); - m_aFL.Show(); - m_aCreation.updateHelpText(); + m_aCreation->Show(); + m_aCreation->SelectAll(false); + m_aHelpText->Show(); + m_aDescription->Show(); + m_aFL->Show(); + m_aCreation->updateHelpText(); Enable(!_rList.empty()); } void OTasksWindow::Clear() { - m_aCreation.resetLastActive(); - SvTreeListEntry* pEntry = m_aCreation.First(); + m_aCreation->resetLastActive(); + SvTreeListEntry* pEntry = m_aCreation->First(); while ( pEntry ) { delete static_cast< TaskEntry* >( pEntry->GetUserData() ); - pEntry = m_aCreation.Next(pEntry); + pEntry = m_aCreation->Next(pEntry); } - m_aCreation.Clear(); + m_aCreation->Clear(); } // class OApplicationDetailView OApplicationDetailView::OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode) : OSplitterView(&_rParent,false ) - ,m_aHorzSplitter(this) - ,m_aTasks(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL ) - ,m_aContainer(this,0,WB_BORDER | WB_DIALOGCONTROL ) + ,m_aHorzSplitter(VclPtr<Splitter>::Create(this)) + ,m_aTasks(VclPtr<dbaui::OTitleWindow>::Create(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL) ) + ,m_aContainer(VclPtr<dbaui::OTitleWindow>::Create(this,0,WB_BORDER | WB_DIALOGCONTROL) ) ,m_rBorderWin(_rParent) { SetUniqueId(UID_APP_DETAIL_VIEW); ImplInitSettings( true, true, true ); - m_pControlHelper = new OAppDetailPageHelper(&m_aContainer,m_rBorderWin,_ePreviewMode); + m_pControlHelper = VclPtr<OAppDetailPageHelper>::Create(m_aContainer.get(),m_rBorderWin,_ePreviewMode); m_pControlHelper->Show(); - m_aContainer.setChildWindow(m_pControlHelper); + m_aContainer->setChildWindow(m_pControlHelper); - OTasksWindow* pTasks = new OTasksWindow(&m_aTasks,this); + VclPtrInstance<OTasksWindow> pTasks(m_aTasks.get(),this); pTasks->Show(); pTasks->Disable(m_rBorderWin.getView()->getCommandController().isDataSourceReadOnly()); - m_aTasks.setChildWindow(pTasks); - m_aTasks.SetUniqueId(UID_APP_TASKS_VIEW); - m_aTasks.Show(); + m_aTasks->setChildWindow(pTasks); + m_aTasks->SetUniqueId(UID_APP_TASKS_VIEW); + m_aTasks->Show(); - m_aContainer.SetUniqueId(UID_APP_CONTAINER_VIEW); - m_aContainer.Show(); + m_aContainer->SetUniqueId(UID_APP_CONTAINER_VIEW); + m_aContainer->Show(); const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); - m_aHorzSplitter.SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) ); + m_aHorzSplitter->SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) ); // now set the components at the base class - set(&m_aContainer,&m_aTasks); + set(m_aContainer.get(),m_aTasks.get()); - m_aHorzSplitter.Show(); - m_aHorzSplitter.SetUniqueId(UID_APP_VIEW_HORZ_SPLIT); - setSplitter(&m_aHorzSplitter); + m_aHorzSplitter->Show(); + m_aHorzSplitter->SetUniqueId(UID_APP_VIEW_HORZ_SPLIT); + setSplitter(m_aHorzSplitter.get()); } OApplicationDetailView::~OApplicationDetailView() { + disposeOnce(); +} + +void OApplicationDetailView::dispose() +{ set(NULL,NULL); setSplitter(NULL); - m_pControlHelper = NULL; + m_aHorzSplitter.disposeAndClear(); + m_aTasks.disposeAndClear(); + m_aContainer.disposeAndClear(); + m_pControlHelper.clear(); + OSplitterView::dispose(); } void OApplicationDetailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) @@ -580,9 +600,9 @@ void OApplicationDetailView::ImplInitSettings( bool bFont, bool bForeground, boo if( bBackground ) SetBackground( rStyleSettings.GetFieldColor() ); - m_aHorzSplitter.SetBackground( rStyleSettings.GetDialogColor() ); - m_aHorzSplitter.SetFillColor( rStyleSettings.GetDialogColor() ); - m_aHorzSplitter.SetTextFillColor(rStyleSettings.GetDialogColor() ); + m_aHorzSplitter->SetBackground( rStyleSettings.GetDialogColor() ); + m_aHorzSplitter->SetFillColor( rStyleSettings.GetDialogColor() ); + m_aHorzSplitter->SetTextFillColor(rStyleSettings.GetDialogColor() ); } void OApplicationDetailView::DataChanged( const DataChangedEvent& rDCEvt ) @@ -642,7 +662,7 @@ void OApplicationDetailView::impl_createPage( ElementType _eType, const Referenc bool bEnabled = !rData.aTasks.empty() && getBorderWin().getView()->getCommandController().isCommandEnabled( rData.aTasks[0].sUNOCommand ); getTasksWindow().Enable( bEnabled ); - m_aContainer.setTitle( rData.nTitleId ); + m_aContainer->setTitle( rData.nTitleId ); // let our helper create the object list if ( _eType == E_TABLE ) diff --git a/dbaccess/source/ui/app/AppDetailView.hxx b/dbaccess/source/ui/app/AppDetailView.hxx index f90048248ce8..fadf67574c38 100644 --- a/dbaccess/source/ui/app/AppDetailView.hxx +++ b/dbaccess/source/ui/app/AppDetailView.hxx @@ -111,11 +111,11 @@ namespace dbaui class OTasksWindow : public vcl::Window { - OCreationList m_aCreation; - FixedText m_aDescription; - FixedText m_aHelpText; - FixedLine m_aFL; - OApplicationDetailView* m_pDetailView; + VclPtr<OCreationList> m_aCreation; + VclPtr<FixedText> m_aDescription; + VclPtr<FixedText> m_aHelpText; + VclPtr<FixedLine> m_aFL; + VclPtr<OApplicationDetailView> m_pDetailView; DECL_LINK( OnEntrySelectHdl, SvTreeListBox* ); void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); @@ -124,6 +124,7 @@ namespace dbaui public: OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView); virtual ~OTasksWindow(); + virtual void dispose() SAL_OVERRIDE; // Window overrides virtual void Resize() SAL_OVERRIDE; @@ -135,7 +136,7 @@ namespace dbaui inline bool HandleKeyInput( const KeyEvent& _rKEvt ) { - return m_aCreation.HandleKeyInput( _rKEvt ); + return m_aCreation->HandleKeyInput( _rKEvt ); } void Clear(); @@ -144,11 +145,11 @@ namespace dbaui class OApplicationDetailView : public OSplitterView , public IClipboardTest { - Splitter m_aHorzSplitter; - OTitleWindow m_aTasks; - OTitleWindow m_aContainer; + VclPtr<Splitter> m_aHorzSplitter; + VclPtr<OTitleWindow> m_aTasks; + VclPtr<OTitleWindow> m_aContainer; OAppBorderWindow& m_rBorderWin; // my parent - OAppDetailPageHelper* m_pControlHelper; + VclPtr<OAppDetailPageHelper> m_pControlHelper; ::std::vector< TaskPaneData > m_aTaskPaneData; MnemonicGenerator m_aExternalMnemonics; @@ -161,6 +162,7 @@ namespace dbaui OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode); virtual ~OApplicationDetailView(); // Window overrides + virtual void dispose() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; /** creates the tables page @@ -188,7 +190,7 @@ namespace dbaui bool interceptKeyInput( const KeyEvent& _rEvent ); inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; } - inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks.getChildWindow() ); } + inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks->getChildWindow() ); } bool isCutAllowed() SAL_OVERRIDE ; bool isCopyAllowed() SAL_OVERRIDE ; diff --git a/dbaccess/source/ui/app/AppIconControl.cxx b/dbaccess/source/ui/app/AppIconControl.cxx index ff73ba0fdafc..a4b7d02bb944 100644 --- a/dbaccess/source/ui/app/AppIconControl.cxx +++ b/dbaccess/source/ui/app/AppIconControl.cxx @@ -62,6 +62,11 @@ OApplicationIconControl::OApplicationIconControl(vcl::Window* _pParent) OApplicationIconControl::~OApplicationIconControl() { + disposeOnce(); +} + +void OApplicationIconControl::dispose() +{ sal_uLong nCount = GetEntryCount(); for ( sal_uLong i = 0; i < nCount; ++i ) { @@ -72,7 +77,7 @@ OApplicationIconControl::~OApplicationIconControl() pEntry->SetUserData(NULL); } } - + SvtIconChoiceCtrl::dispose(); } sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt ) diff --git a/dbaccess/source/ui/app/AppIconControl.hxx b/dbaccess/source/ui/app/AppIconControl.hxx index 5fcecef90022..10c425b6ea31 100644 --- a/dbaccess/source/ui/app/AppIconControl.hxx +++ b/dbaccess/source/ui/app/AppIconControl.hxx @@ -34,6 +34,7 @@ namespace dbaui public: OApplicationIconControl(vcl::Window* _pParent); virtual ~OApplicationIconControl(); + virtual void dispose() SAL_OVERRIDE; void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; } IControlActionListener* getControlActionListener( ) const { return m_pActionListener; } diff --git a/dbaccess/source/ui/app/AppSwapWindow.cxx b/dbaccess/source/ui/app/AppSwapWindow.cxx index 902c7181d5fe..1f215dfd22b5 100644 --- a/dbaccess/source/ui/app/AppSwapWindow.cxx +++ b/dbaccess/source/ui/app/AppSwapWindow.cxx @@ -38,35 +38,41 @@ using namespace ::com::sun::star::container; // class OApplicationSwapWindow OApplicationSwapWindow::OApplicationSwapWindow( vcl::Window* _pParent, OAppBorderWindow& _rBorderWindow ) :Window(_pParent,WB_DIALOGCONTROL ) - ,m_aIconControl(this) + ,m_aIconControl(VclPtr<OApplicationIconControl>::Create(this)) ,m_eLastType(E_NONE) ,m_rBorderWin( _rBorderWindow ) { ImplInitSettings( true, true, true ); - m_aIconControl.SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl)); - m_aIconControl.setControlActionListener( &m_rBorderWin.getView()->getAppController() ); - m_aIconControl.SetHelpId(HID_APP_SWAP_ICONCONTROL); - m_aIconControl.Show(); + m_aIconControl->SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl)); + m_aIconControl->setControlActionListener( &m_rBorderWin.getView()->getAppController() ); + m_aIconControl->SetHelpId(HID_APP_SWAP_ICONCONTROL); + m_aIconControl->Show(); } OApplicationSwapWindow::~OApplicationSwapWindow() { + disposeOnce(); +} +void OApplicationSwapWindow::dispose() +{ + m_aIconControl.disposeAndClear(); + vcl::Window::dispose(); } void OApplicationSwapWindow::Resize() { Size aFLSize = LogicToPixel( Size( 8, 0 ), MAP_APPFONT ); long nX = 0; - if ( m_aIconControl.GetEntryCount() != 0 ) - nX = m_aIconControl.GetBoundingBox( m_aIconControl.GetEntry(0) ).GetWidth() + aFLSize.Width(); + if ( m_aIconControl->GetEntryCount() != 0 ) + nX = m_aIconControl->GetBoundingBox( m_aIconControl->GetEntry(0) ).GetWidth() + aFLSize.Width(); Size aOutputSize = GetOutputSize(); - m_aIconControl.SetPosSizePixel( Point(static_cast<long>((aOutputSize.Width() - nX)*0.5), 0) ,Size(nX,aOutputSize.Height())); - m_aIconControl.ArrangeIcons(); + m_aIconControl->SetPosSizePixel( Point(static_cast<long>((aOutputSize.Width() - nX)*0.5), 0) ,Size(nX,aOutputSize.Height())); + m_aIconControl->ArrangeIcons(); } void OApplicationSwapWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) @@ -106,24 +112,24 @@ void OApplicationSwapWindow::DataChanged( const DataChangedEvent& rDCEvt ) void OApplicationSwapWindow::clearSelection() { - m_aIconControl.SetNoSelection(); + m_aIconControl->SetNoSelection(); sal_uLong nPos = 0; - SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos); + SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(nPos); if ( pEntry ) - m_aIconControl.InvalidateEntry(pEntry); - m_aIconControl.GetClickHdl().Call(&m_aIconControl); + m_aIconControl->InvalidateEntry(pEntry); + m_aIconControl->GetClickHdl().Call(&m_aIconControl); } void OApplicationSwapWindow::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics ) { - m_aIconControl.CreateAutoMnemonics( _rMnemonics ); + m_aIconControl->CreateAutoMnemonics( _rMnemonics ); } bool OApplicationSwapWindow::interceptKeyInput( const KeyEvent& _rEvent ) { const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode(); if ( rKeyCode.GetModifier() == KEY_MOD2 ) - return m_aIconControl.DoKeyInput( _rEvent ); + return m_aIconControl->DoKeyInput( _rEvent ); // not handled return false; @@ -132,7 +138,7 @@ bool OApplicationSwapWindow::interceptKeyInput( const KeyEvent& _rEvent ) ElementType OApplicationSwapWindow::getElementType() const { sal_uLong nPos = 0; - SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos); + SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(nPos); return ( pEntry ) ? *static_cast<ElementType*>(pEntry->GetUserData()) : E_NONE; } @@ -174,18 +180,18 @@ IMPL_LINK_NOARG(OApplicationSwapWindow, ChangeToLastSelected) void OApplicationSwapWindow::selectContainer(ElementType _eType) { - sal_uLong nCount = m_aIconControl.GetEntryCount(); + sal_uLong nCount = m_aIconControl->GetEntryCount(); SvxIconChoiceCtrlEntry* pEntry = NULL; for (sal_uLong i=0; i < nCount; ++i) { - pEntry = m_aIconControl.GetEntry(i); + pEntry = m_aIconControl->GetEntry(i); if ( pEntry && *static_cast<ElementType*>(pEntry->GetUserData()) == _eType ) break; pEntry = NULL; } if ( pEntry ) - m_aIconControl.SetCursor(pEntry); // this call also initiates a onContainerSelected call + m_aIconControl->SetCursor(pEntry); // this call also initiates a onContainerSelected call else onContainerSelected( _eType ); } diff --git a/dbaccess/source/ui/app/AppSwapWindow.hxx b/dbaccess/source/ui/app/AppSwapWindow.hxx index c7b61c4651c6..b655dd8e4dc1 100644 --- a/dbaccess/source/ui/app/AppSwapWindow.hxx +++ b/dbaccess/source/ui/app/AppSwapWindow.hxx @@ -21,6 +21,7 @@ #include "IClipBoardTest.hxx" #include <vcl/lstbox.hxx> +#include <vcl/vclptr.hxx> #include "AppIconControl.hxx" #include "AppElementType.hxx" @@ -30,7 +31,7 @@ namespace dbaui class OApplicationSwapWindow : public vcl::Window, public IClipboardTest { - OApplicationIconControl m_aIconControl; + VclPtr<OApplicationIconControl> m_aIconControl; ElementType m_eLastType; OAppBorderWindow& m_rBorderWin; @@ -44,6 +45,7 @@ namespace dbaui OApplicationSwapWindow( vcl::Window* _pParent, OAppBorderWindow& _rBorderWindow ); virtual ~OApplicationSwapWindow(); // Window overrides + virtual void dispose() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE; bool isCutAllowed() SAL_OVERRIDE { return false; } @@ -54,9 +56,9 @@ namespace dbaui void cut() SAL_OVERRIDE { } void paste() SAL_OVERRIDE { } - inline sal_uLong GetEntryCount() const { return m_aIconControl.GetEntryCount(); } - inline SvxIconChoiceCtrlEntry* GetEntry( sal_uLong nPos ) const { return m_aIconControl.GetEntry(nPos); } - inline Rectangle GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const { return m_aIconControl.GetBoundingBox(pEntry); } + inline sal_uLong GetEntryCount() const { return m_aIconControl->GetEntryCount(); } + inline SvxIconChoiceCtrlEntry* GetEntry( sal_uLong nPos ) const { return m_aIconControl->GetEntry(nPos); } + inline Rectangle GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const { return m_aIconControl->GetBoundingBox(pEntry); } /** automatically creates mnemonics for the icon/texts in our left hand side panel */ diff --git a/dbaccess/source/ui/app/AppTitleWindow.cxx b/dbaccess/source/ui/app/AppTitleWindow.cxx index 2bbd2c66231c..71317b01a82b 100644 --- a/dbaccess/source/ui/app/AppTitleWindow.cxx +++ b/dbaccess/source/ui/app/AppTitleWindow.cxx @@ -29,9 +29,9 @@ namespace dbaui OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,bool _bShift) : Window(_pParent,_nBits | WB_DIALOGCONTROL) -, m_aSpace1(this) -, m_aSpace2(this) -, m_aTitle(this) +, m_aSpace1(VclPtr<FixedText>::Create(this)) +, m_aSpace2(VclPtr<FixedText>::Create(this)) +, m_aTitle(VclPtr<FixedText>::Create(this)) , m_pChild(NULL) , m_bShift(_bShift) { @@ -40,20 +40,27 @@ OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _n SetBorderStyle(WindowBorderStyle::MONO); ImplInitSettings( true, true, true ); - vcl::Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle }; + vcl::Window* pWindows [] = { m_aSpace1.get(), m_aSpace2.get(), m_aTitle.get() }; for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i) pWindows[i]->Show(); } OTitleWindow::~OTitleWindow() { + disposeOnce(); +} + +void OTitleWindow::dispose() +{ if ( m_pChild ) { m_pChild->Hide(); - boost::scoped_ptr<vcl::Window> aTemp(m_pChild); - m_pChild = NULL; } - + m_pChild.disposeAndClear(); + m_aSpace1.disposeAndClear(); + m_aSpace2.disposeAndClear(); + m_aTitle.disposeAndClear(); + vcl::Window::dispose(); } void OTitleWindow::setChildWindow(vcl::Window* _pChild) @@ -74,11 +81,11 @@ void OTitleWindow::Resize() sal_Int32 nYOffset = aTextSize.Height(); sal_Int32 nHeight = GetTextHeight() + 2*nYOffset; - m_aSpace1.SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ), + m_aSpace1->SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ), Size(nXOffset , nHeight - SPACE_BORDER) ); - m_aSpace2.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ), + m_aSpace2->SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ), Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) ); - m_aTitle.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER), + m_aTitle->SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER), Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) ); if ( m_pChild ) { @@ -91,7 +98,7 @@ void OTitleWindow::setTitle(sal_uInt16 _nTitleId) { if ( _nTitleId != 0 ) { - m_aTitle.SetText(ModuleRes(_nTitleId)); + m_aTitle->SetText(ModuleRes(_nTitleId)); } } @@ -105,7 +112,7 @@ void OTitleWindow::GetFocus() long OTitleWindow::GetWidthPixel() const { Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT ); - sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width(); + sal_Int32 nWidth = GetTextWidth(m_aTitle->GetText()) + 2*aTextSize.Width(); return nWidth; } @@ -151,7 +158,7 @@ void OTitleWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackgro if( bBackground ) SetBackground( rStyleSettings.GetFieldColor() ); - vcl::Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle}; + vcl::Window* pWindows [] = { m_aSpace1.get(), m_aSpace2.get(), m_aTitle.get()}; for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i) { vcl::Font aFont = pWindows[i]->GetFont(); diff --git a/dbaccess/source/ui/app/AppTitleWindow.hxx b/dbaccess/source/ui/app/AppTitleWindow.hxx index 76228b54b6cf..875f693107ab 100644 --- a/dbaccess/source/ui/app/AppTitleWindow.hxx +++ b/dbaccess/source/ui/app/AppTitleWindow.hxx @@ -25,10 +25,10 @@ namespace dbaui { class OTitleWindow : public vcl::Window { - FixedText m_aSpace1; - FixedText m_aSpace2; - FixedText m_aTitle; - vcl::Window* m_pChild; + VclPtr<FixedText> m_aSpace1; + VclPtr<FixedText> m_aSpace2; + VclPtr<FixedText> m_aTitle; + VclPtr<vcl::Window> m_pChild; bool m_bShift; void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); protected: @@ -36,6 +36,7 @@ namespace dbaui public: OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,bool _bShift = true); virtual ~OTitleWindow(); + virtual void dispose() SAL_OVERRIDE; // Window overrides virtual void Resize() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx index fe2d505e9018..6fa8030ceadc 100644 --- a/dbaccess/source/ui/app/AppView.cxx +++ b/dbaccess/source/ui/app/AppView.cxx @@ -68,9 +68,9 @@ OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePrev SetBorderStyle(WindowBorderStyle::MONO); - m_pPanel = new OTitleWindow(this,STR_DATABASE,WB_BORDER | WB_DIALOGCONTROL, false); + m_pPanel = VclPtr<OTitleWindow>::Create(this,STR_DATABASE,WB_BORDER | WB_DIALOGCONTROL, false); m_pPanel->SetBorderStyle(WindowBorderStyle::MONO); - OApplicationSwapWindow* pSwap = new OApplicationSwapWindow( m_pPanel, *this ); + VclPtrInstance<OApplicationSwapWindow> pSwap( m_pPanel, *this ); pSwap->Show(); pSwap->SetUniqueId(UID_APP_SWAP_VIEW); @@ -78,7 +78,7 @@ OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePrev m_pPanel->SetUniqueId(UID_APP_DATABASE_VIEW); m_pPanel->Show(); - m_pDetailView = new OApplicationDetailView(*this,_ePreviewMode); + m_pDetailView = VclPtr<OApplicationDetailView>::Create(*this,_ePreviewMode); m_pDetailView->Show(); ImplInitSettings(); @@ -86,20 +86,20 @@ OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePrev OAppBorderWindow::~OAppBorderWindow() { + disposeOnce(); +} + +void OAppBorderWindow::dispose() +{ // destroy children if ( m_pPanel ) - { m_pPanel->Hide(); - boost::scoped_ptr<vcl::Window> aTemp(m_pPanel); - m_pPanel = NULL; - } + m_pPanel.disposeAndClear(); if ( m_pDetailView ) - { m_pDetailView->Hide(); - boost::scoped_ptr<vcl::Window> aTemp(m_pDetailView); - m_pDetailView = NULL; - } - + m_pDetailView.disposeAndClear(); + m_pView.clear(); + vcl::Window::dispose(); } void OAppBorderWindow::GetFocus() @@ -195,7 +195,7 @@ OApplicationView::OApplicationView( vcl::Window* pParent { } - m_pWin = new OAppBorderWindow(this,_ePreviewMode); + m_pWin = VclPtr<OAppBorderWindow>::Create(this,_ePreviewMode); m_pWin->SetUniqueId(UID_APP_VIEW_BORDER_WIN); m_pWin->Show(); @@ -204,13 +204,16 @@ OApplicationView::OApplicationView( vcl::Window* pParent OApplicationView::~OApplicationView() { + disposeOnce(); +} - { - stopComponentListening(m_xObject); - m_pWin->Hide(); - boost::scoped_ptr<vcl::Window> aTemp(m_pWin); - m_pWin = NULL; - } +void OApplicationView::dispose() +{ + stopComponentListening(m_xObject); + m_xObject.clear(); + m_pWin->Hide(); + m_pWin.disposeAndClear(); + ODataView::dispose(); } void OApplicationView::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics ) diff --git a/dbaccess/source/ui/app/AppView.hxx b/dbaccess/source/ui/app/AppView.hxx index 87288117d2cd..41f30c85b99e 100644 --- a/dbaccess/source/ui/app/AppView.hxx +++ b/dbaccess/source/ui/app/AppView.hxx @@ -44,9 +44,9 @@ namespace dbaui class OTitleWindow; class OAppBorderWindow : public vcl::Window { - OTitleWindow* m_pPanel; - OApplicationDetailView* m_pDetailView; - OApplicationView* m_pView; + VclPtr<OTitleWindow> m_pPanel; + VclPtr<OApplicationDetailView> m_pDetailView; + VclPtr<OApplicationView> m_pView; void ImplInitSettings(); protected: @@ -55,6 +55,7 @@ namespace dbaui public: OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode); virtual ~OAppBorderWindow(); + virtual void dispose() SAL_OVERRIDE; // Window overrides virtual void GetFocus() SAL_OVERRIDE; @@ -79,7 +80,7 @@ namespace dbaui ::com::sun::star::lang::Locale m_aLocale; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xObject; - OAppBorderWindow* m_pWin; + VclPtr<OAppBorderWindow> m_pWin; IApplicationController& m_rAppController; ChildFocusState m_eChildFocus; @@ -103,6 +104,7 @@ namespace dbaui ,PreviewMode _ePreviewMode ); virtual ~OApplicationView(); + virtual void dispose() SAL_OVERRIDE; /// automatically creates mnemonics for the icon/texts in our left hand side panel void createIconAutoMnemonics( MnemonicGenerator& _rMnemonics ); diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx index e4c05397585b..880504587747 100644 --- a/dbaccess/source/ui/app/subcomponentmanager.cxx +++ b/dbaccess/source/ui/app/subcomponentmanager.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <tools/diagnose_ex.h> +#include <dbaccess/dataview.hxx> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 0bfddcc7bb6c..d39dd447553b 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -757,7 +757,7 @@ bool SbaXDataBrowserController::Construct(vcl::Window* pParent) } // create the view - setView( * new UnoDataBrowserView( pParent, *this, getORB() ) ); + setView( VclPtr<UnoDataBrowserView>::Create( pParent, *this, getORB() ) ); if (!getBrowserView()) return false; @@ -1271,8 +1271,8 @@ IMPL_LINK( SbaXDataBrowserController, OnAsyncDisplayError, void*, /* _pNotIntere { if ( m_aCurrentError.isValid() ) { - OSQLMessageBox aDlg( getBrowserView(), m_aCurrentError ); - aDlg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aDlg( getBrowserView(), m_aCurrentError ); + aDlg->Execute(); } return 0L; } @@ -1764,19 +1764,19 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(bool bFilter) Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); if(bFilter) { - DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() ); - if ( !aDlg.Execute() ) + ScopedVclPtrInstance< DlgFilterCrit > aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() ); + if ( !aDlg->Execute() ) return; // if so we don't need to update the grid - aDlg.BuildWherePart(); + aDlg->BuildWherePart(); } else { - DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() ); - if(!aDlg.Execute()) + ScopedVclPtrInstance< DlgOrderCrit > aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() ); + if(!aDlg->Execute()) { return; // if so we don't need to actualize the grid } - aDlg.BuildOrderPart(); + aDlg->BuildOrderPart(); } } catch(const SQLException& ) @@ -2172,11 +2172,11 @@ bool SbaXDataBrowserController::SaveModified(bool bAskFor) { getBrowserView()->getVclControl()->GrabFocus(); - MessageDialog aQry(getBrowserView()->getVclControl(), - "SaveModifiedDialog", - "dbaccess/ui/savemodifieddialog.ui"); + ScopedVclPtrInstance<MessageDialog> aQry( getBrowserView()->getVclControl(), + "SaveModifiedDialog", + "dbaccess/ui/savemodifieddialog.ui" ); - switch (aQry.Execute()) + switch (aQry->Execute()) { case RET_NO: Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>()); diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx index f41289e3a797..fe0ad003ab79 100644 --- a/dbaccess/source/ui/browser/brwview.cxx +++ b/dbaccess/source/ui/browser/brwview.cxx @@ -106,7 +106,7 @@ void UnoDataBrowserView::Construct(const Reference< ::com::sun::star::awt::XCont m_pVclControl = NULL; getVclControl(); - OSL_ENSURE(m_pVclControl != NULL, "UnoDataBrowserView::Construct : no real grid control !"); + OSL_ENSURE(m_pVclControl != nullptr, "UnoDataBrowserView::Construct : no real grid control !"); } catch(const Exception&) { @@ -117,17 +117,15 @@ void UnoDataBrowserView::Construct(const Reference< ::com::sun::star::awt::XCont UnoDataBrowserView::~UnoDataBrowserView() { - { - boost::scoped_ptr<Splitter> aTemp(m_pSplitter); - m_pSplitter = NULL; - } + disposeOnce(); +} + +void UnoDataBrowserView::dispose() +{ + m_pSplitter.disposeAndClear(); setTreeView(NULL); - if ( m_pStatus ) - { - delete m_pStatus; - m_pStatus = NULL; - } + m_pStatus.disposeAndClear(); try { @@ -136,7 +134,9 @@ UnoDataBrowserView::~UnoDataBrowserView() } catch(const Exception&) {} - + m_pTreeView.clear(); + m_pVclControl.clear(); + ODataView::dispose(); } IMPL_LINK( UnoDataBrowserView, SplitHdl, void*, /*NOINTERESTEDIN*/ ) @@ -157,13 +157,9 @@ void UnoDataBrowserView::setSplitter(Splitter* _pSplitter) void UnoDataBrowserView::setTreeView(DBTreeView* _pTreeView) { - if (m_pTreeView != _pTreeView) + if (m_pTreeView.get() != _pTreeView) { - if (m_pTreeView) - { - boost::scoped_ptr<vcl::Window> aTemp(m_pTreeView); - m_pTreeView = NULL; - } + m_pTreeView.disposeAndClear(); m_pTreeView = _pTreeView; } } @@ -175,7 +171,7 @@ void UnoDataBrowserView::showStatus( const OUString& _rStatus ) else { if (!m_pStatus) - m_pStatus = new FixedText(this); + m_pStatus = VclPtr<FixedText>::Create(this); m_pStatus->SetText(_rStatus); m_pStatus->Show(); Resize(); @@ -268,7 +264,7 @@ SbaGridControl* UnoDataBrowserView::getVclControl() const UnoDataBrowserView* pTHIS = const_cast<UnoDataBrowserView*>(this); if ( pPeer ) { - m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow()); + m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow().get()); pTHIS->startComponentListening(Reference<XComponent>(VCLUnoHelper::GetInterface(m_pVclControl),UNO_QUERY)); } } diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx index dc27afe956a3..fd7451f34891 100644 --- a/dbaccess/source/ui/browser/dataview.cxx +++ b/dbaccess/source/ui/browser/dataview.cxx @@ -42,7 +42,7 @@ namespace dbaui class ColorChanger { protected: - OutputDevice* m_pDev; + VclPtr<OutputDevice> m_pDev; public: ColorChanger( OutputDevice* _pDev, const ::Color& _rNewLineColor, const ::Color& _rNewFillColor ) @@ -65,12 +65,11 @@ namespace dbaui WinBits nStyle) :Window(pParent,nStyle) ,m_xContext(_rxContext) - ,m_rController( _rController ) - ,m_aSeparator( this ) + ,m_xController( &_rController ) + ,m_aSeparator( VclPtr<FixedLine>::Create(this) ) { - m_rController.acquire(); m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper()); - m_aSeparator.Show(); + m_aSeparator->Show(); } void ODataView::Construct() @@ -79,8 +78,15 @@ namespace dbaui ODataView::~ODataView() { + disposeOnce(); + } - m_rController.release(); + void ODataView::dispose() + { + m_xController.clear(); + m_aSeparator.disposeAndClear(); + m_pAccel.reset(); + vcl::Window::dispose(); } void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ ) @@ -105,7 +111,7 @@ namespace dbaui // position the separator const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 ); - m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize ); + m_aSeparator->SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize ); aPlayground.Top() += aSeparatorSize.Height() + 1; // position the controls of the document's view @@ -134,7 +140,7 @@ namespace dbaui case MouseNotifyEvent::KEYUP: case MouseNotifyEvent::MOUSEBUTTONDOWN: case MouseNotifyEvent::MOUSEBUTTONUP: - bHandled = m_rController.interceptUserInput( _rNEvt ); + bHandled = m_xController->interceptUserInput( _rNEvt ); break; default: break; @@ -148,7 +154,7 @@ namespace dbaui if ( nType == StateChangedType::CONTROLBACKGROUND ) { // Check if we need to get new images for normal/high contrast mode - m_rController.notifyHiContrastChanged(); + m_xController->notifyHiContrastChanged(); } if ( nType == StateChangedType::INITSHOW ) @@ -157,7 +163,7 @@ namespace dbaui // model's arguments. try { - Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW ); + Reference< XController > xController( m_xController->getXController(), UNO_SET_THROW ); Reference< XModel > xModel( xController->getModel(), UNO_QUERY ); if ( xModel.is() ) { @@ -183,7 +189,7 @@ namespace dbaui (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) { // Check if we need to get new images for normal/high contrast mode - m_rController.notifyHiContrastChanged(); + m_xController->notifyHiContrastChanged(); } } void ODataView::attachFrame(const Reference< XFrame >& _xFrame) diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx index 9dba9af17c20..bc0b44194983 100644 --- a/dbaccess/source/ui/browser/dbtreeview.cxx +++ b/dbaccess/source/ui/browser/dbtreeview.cxx @@ -36,7 +36,7 @@ DBTreeView::DBTreeView( vcl::Window* pParent, WinBits nBits) , m_pTreeListBox(NULL) { - m_pTreeListBox = new DBTreeListBox(this, WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT); + m_pTreeListBox = VclPtr<DBTreeListBox>::Create(this, WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT); m_pTreeListBox->EnableCheckButton(NULL); m_pTreeListBox->SetDragDropMode( DragDropMode::NONE ); m_pTreeListBox->EnableInplaceEditing( true ); @@ -46,6 +46,11 @@ DBTreeView::DBTreeView( vcl::Window* pParent, WinBits nBits) DBTreeView::~DBTreeView() { + disposeOnce(); +} + +void DBTreeView::dispose() +{ if (m_pTreeListBox) { if (m_pTreeListBox->GetModel()) @@ -53,9 +58,9 @@ DBTreeView::~DBTreeView() m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox); m_pTreeListBox->DisconnectFromModel(); } - boost::scoped_ptr<vcl::Window> aTemp(m_pTreeListBox); - m_pTreeListBox = NULL; } + m_pTreeListBox.disposeAndClear(); + vcl::Window::dispose(); } void DBTreeView::SetPreExpandHandler(const Link& _rHdl) diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx index 99bf4416ce8c..5313583fc061 100644 --- a/dbaccess/source/ui/browser/dbtreeview.hxx +++ b/dbaccess/source/ui/browser/dbtreeview.hxx @@ -31,7 +31,7 @@ namespace dbaui class DBTreeView : public vcl::Window { private: - DBTreeListBox* m_pTreeListBox; + VclPtr<DBTreeListBox> m_pTreeListBox; protected: // window overridables virtual void Resize() SAL_OVERRIDE; @@ -40,6 +40,7 @@ namespace dbaui DBTreeView( vcl::Window* pParent, WinBits nBits ); virtual ~DBTreeView(); + virtual void dispose() SAL_OVERRIDE; /** sets a handler which is called when an list box entry is to be expanded. <p>When calling the link, the parameter is an SvTreeListEntry marking the entry to be expanded. diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index c0e6c4686d56..7bf028e18ac1 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -291,7 +291,7 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen xParent = xFrame->getContainerWindow(); VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent); - vcl::Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL; + VclPtr< vcl::Window > pParentWin = pParentComponent ? pParentComponent->GetWindow() : VclPtr< vcl::Window >(); if (!pParentWin) { throw IllegalArgumentException("Parent window is null", *this, 1 ); @@ -312,7 +312,6 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen catch(Exception&) { // no one clears my view if I won't - boost::scoped_ptr<vcl::Window> aTemp(m_pView); m_pView = NULL; throw; } @@ -983,6 +982,16 @@ Reference< XConnection > OGenericUnoController::connect( const OUString& _rDataS return xConnection; } +void OGenericUnoController::setView( const VclPtr<ODataView> &i_rView ) +{ + m_pView = i_rView; +} + +void OGenericUnoController::clearView() +{ + m_pView = NULL; +} + void OGenericUnoController::showError(const SQLExceptionInfo& _rInfo) { ::dbaui::showError(_rInfo,getView(),getORB()); diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 92bf55a2457e..fad16daabc0b 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -309,7 +309,7 @@ void SAL_CALL SbaXGridPeer::dispose() throw( RuntimeException, std::exception ) void SbaXGridPeer::NotifyStatusChanged(const ::com::sun::star::util::URL& _rUrl, const Reference< ::com::sun::star::frame::XStatusListener > & xControl) { - SbaGridControl* pGrid = static_cast<SbaGridControl*>(GetWindow()); + VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >(); if (!pGrid) return; @@ -361,7 +361,7 @@ Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaXGridPeer::queryDis IMPL_LINK( SbaXGridPeer, OnDispatchEvent, void*, /*NOTINTERESTEDIN*/ ) { - SbaGridControl* pGrid = static_cast< SbaGridControl* >( GetWindow() ); + VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >(); if ( pGrid ) // if this fails, we were disposing before arriving here { if ( Application::GetMainThreadIdentifier() != ::osl::Thread::getCurrentIdentifier() ) @@ -398,7 +398,7 @@ SbaXGridPeer::DispatchType SbaXGridPeer::classifyDispatchURL( const URL& _rURL ) void SAL_CALL SbaXGridPeer::dispatch(const URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException, std::exception ) { - SbaGridControl* pGrid = static_cast<SbaGridControl*>(GetWindow()); + VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >(); if (!pGrid) return; @@ -549,9 +549,9 @@ SbaXGridPeer* SbaXGridPeer::getImplementation(const Reference< XInterface >& _rx return NULL; } -FmGridControl* SbaXGridPeer::imp_CreateControl(vcl::Window* pParent, WinBits nStyle) +VclPtr<FmGridControl> SbaXGridPeer::imp_CreateControl(vcl::Window* pParent, WinBits nStyle) { - return new SbaGridControl( m_xContext, pParent, this, nStyle); + return VclPtr<SbaGridControl>::Create( m_xContext, pParent, this, nStyle); } // SbaGridHeader @@ -717,13 +717,19 @@ SbaGridControl::SbaGridControl(Reference< XComponentContext > _rM, SbaGridControl::~SbaGridControl() { + disposeOnce(); +} + +void SbaGridControl::dispose() +{ if (m_nAsyncDropEvent) Application::RemoveUserEvent(m_nAsyncDropEvent); + FmGridControl::dispose(); } -BrowserHeader* SbaGridControl::imp_CreateHeaderBar(BrowseBox* pParent) +VclPtr<BrowserHeader> SbaGridControl::imp_CreateHeaderBar(BrowseBox* pParent) { - return new SbaGridHeader(pParent); + return VclPtr<SbaGridHeader>::Create(pParent); } CellController* SbaGridControl::GetController(long nRow, sal_uInt16 nCol) @@ -786,10 +792,10 @@ void SbaGridControl::SetColWidth(sal_uInt16 nColId) Any aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH); sal_Int32 nCurWidth = aWidth.hasValue() ? ::comphelper::getINT32(aWidth) : -1; - DlgSize aDlgColWidth(this, nCurWidth, false); - if (aDlgColWidth.Execute()) + ScopedVclPtrInstance< DlgSize > aDlgColWidth(this, nCurWidth, false); + if (aDlgColWidth->Execute()) { - sal_Int32 nValue = aDlgColWidth.GetValue(); + sal_Int32 nValue = aDlgColWidth->GetValue(); Any aNewWidth; if (-1 == nValue) { // set to default @@ -815,10 +821,10 @@ void SbaGridControl::SetRowHeight() Any aHeight = xCols->getPropertyValue(PROPERTY_ROW_HEIGHT); sal_Int32 nCurHeight = aHeight.hasValue() ? ::comphelper::getINT32(aHeight) : -1; - DlgSize aDlgRowHeight(this, nCurHeight, true); - if (aDlgRowHeight.Execute()) + ScopedVclPtrInstance< DlgSize > aDlgRowHeight(this, nCurHeight, true); + if (aDlgRowHeight->Execute()) { - sal_Int32 nValue = aDlgRowHeight.GetValue(); + sal_Int32 nValue = aDlgRowHeight->GetValue(); Any aNewHeight; if ((sal_Int16)-1 == nValue) { // set to default diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index ddc38f897c88..e546a4a7b33e 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -348,11 +348,11 @@ bool SbaTableQueryBrowser::Construct(vcl::Window* pParent) // create controls and set sizes const long nFrameWidth = getBrowserView()->LogicToPixel( ::Size( 3, 0 ), MAP_APPFONT ).Width(); - m_pSplitter = new Splitter(getBrowserView(),WB_HSCROLL); + m_pSplitter = VclPtr<Splitter>::Create(getBrowserView(),WB_HSCROLL); m_pSplitter->SetPosSizePixel( ::Point(0,0), ::Size(nFrameWidth,0) ); m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); - m_pTreeView = new DBTreeView(getBrowserView(), WB_TABSTOP | WB_BORDER); + m_pTreeView = VclPtr<DBTreeView>::Create(getBrowserView(), WB_TABSTOP | WB_BORDER); m_pTreeView->SetPreExpandHandler(LINK(this, SbaTableQueryBrowser, OnExpandEntry)); m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry)); diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx index a4d44cbc6464..36aff78e2f96 100644 --- a/dbaccess/source/ui/control/ColumnControlWindow.cxx +++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx @@ -47,11 +47,6 @@ OColumnControlWindow::OColumnControlWindow(vcl::Window* pParent m_aLocale = SvtSysLocale().GetLanguageTag().getLocale(); } -OColumnControlWindow::~OColumnControlWindow() -{ - -} - void OColumnControlWindow::ActivateAggregate( EControlType eType ) { switch(eType ) diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 7643cfeb50e0..a6fb6d753efe 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -76,17 +76,15 @@ using namespace ::com::sun::star::util; namespace { - template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText) + template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,VclPtr<T1>& _pControl, VclPtr<T2>& _pControlText) { - if ( *_pControl ) + if ( _pControl ) { --_nPos; - (*_pControl)->Hide(); - (*_pControlText)->Hide(); - delete *_pControl; - delete *_pControlText; - (*_pControl) = NULL; - (*_pControlText) = NULL; + _pControl->Hide(); + _pControlText->Hide(); + _pControl.disposeAndClear(); + _pControlText.disposeAndClear(); } } @@ -141,8 +139,8 @@ OFieldDescControl::OFieldDescControl( vcl::Window* pParent, OTableDesignHelpBar* void OFieldDescControl::Contruct() { - m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); - m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); + m_pVertScroll = VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); + m_pHorzScroll = VclPtr<ScrollBar>::Create(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); m_pVertScroll->Show(); @@ -161,18 +159,13 @@ void OFieldDescControl::Contruct() OFieldDescControl::~OFieldDescControl() { + disposeOnce(); +} - { - boost::scoped_ptr<vcl::Window> aTemp(m_pVertScroll); - m_pVertScroll = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pHorzScroll); - m_pHorzScroll = NULL; - } +void OFieldDescControl::dispose() +{ if ( m_bAdded ) ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - pLastFocusWindow = NULL; // Destroy children DeactivateAggregate( tpDefault ); @@ -187,6 +180,37 @@ OFieldDescControl::~OFieldDescControl() DeactivateAggregate( tpColumnName ); DeactivateAggregate( tpType ); DeactivateAggregate( tpAutoIncrementValue ); + pHelp.clear(); + pLastFocusWindow.clear(); + m_pActFocusWindow.clear(); + pDefaultText.clear(); + pRequiredText.clear(); + pAutoIncrementText.clear(); + pTextLenText.clear(); + pNumTypeText.clear(); + pLengthText.clear(); + pScaleText.clear(); + pFormatText.clear(); + pBoolDefaultText.clear(); + m_pColumnNameText.clear(); + m_pTypeText.clear(); + m_pAutoIncrementValueText.clear(); + pRequired.clear(); + pNumType.clear(); + pAutoIncrement.clear(); + pDefault.clear(); + pTextLen.clear(); + pLength.clear(); + pScale.clear(); + pFormatSample.clear(); + pBoolDefault.clear(); + m_pColumnName.clear(); + m_pType.clear(); + m_pAutoIncrementValue.clear(); + pFormat.clear(); + m_pVertScroll.clear(); + m_pHorzScroll.clear(); + TabPage::dispose(); } OUString OFieldDescControl::BoolStringPersistent(const OUString& rUIString) const @@ -680,8 +704,8 @@ void OFieldDescControl::ArrangeAggregates() // A Control's description struct AGGREGATE_DESCRIPTION { - Control* pctrlInputControl; // The actual Control for input - Control* pctrlTextControl; // The corresponding Label + VclPtr<Control> pctrlInputControl; // The actual Control for input + VclPtr<Control> pctrlTextControl; // The corresponding Label sal_uInt16 nPosSizeArgument; // The second argument for SetPosSize }; AGGREGATE_DESCRIPTION adAggregates[] = { @@ -717,8 +741,8 @@ void OFieldDescControl::ArrangeAggregates() { if (adAggregates[i].pctrlInputControl) { - SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0); - SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument); + SetPosSize(adAggregates[i].pctrlTextControl, nCurrentControlPos, 0); + SetPosSize(adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument); // Set the z-order in a way such that the Controls can be traversed in the same sequence in which they have been arranged here adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); @@ -758,7 +782,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; pDefaultText = CreateText(STR_DEFAULT_VALUE); - pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); + pDefault = VclPtr<OPropEditCtrl>::Create( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false); break; case tpAutoIncrementValue: @@ -766,7 +790,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE); - m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PROPERTY_AUTOINCREMENT, WB_BORDER ); + m_pAutoIncrementValue = VclPtr<OPropEditCtrl>::Create( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PROPERTY_AUTOINCREMENT, WB_BORDER ); m_pAutoIncrementValue->SetText( getAutoIncrementValue() ); InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false); break; @@ -781,7 +805,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) { m_nPos++; pRequiredText = CreateText(STR_FIELD_REQUIRED); - pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); + pRequired = VclPtr<OPropListBoxCtrl>::Create( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); pRequired->InsertEntry( aYes ); pRequired->InsertEntry( aNo ); @@ -797,7 +821,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT); - pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); + pAutoIncrement = VclPtr<OPropListBoxCtrl>::Create( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); pAutoIncrement->InsertEntry( aYes ); pAutoIncrement->InsertEntry( aNo ); pAutoIncrement->SelectEntryPos(0); @@ -817,7 +841,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE); - m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_TYPE, WB_DROPDOWN ); + m_pType = VclPtr<OPropListBoxCtrl>::Create( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_TYPE, WB_DROPDOWN ); m_pType->SetDropDownLineCount(20); { const OTypeInfoMap* pTypeInfo = getTypeInfo(); @@ -850,7 +874,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) DBG_UNHANDLED_EXCEPTION(); } m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME); - m_pColumnName = new OPropColumnEditCtrl( this, + m_pColumnName = VclPtr<OPropColumnEditCtrl>::Create( this, aTmpString, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_COLUMNNAME, @@ -867,7 +891,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_nPos++; pNumTypeText = CreateText(STR_NUMERIC_TYPE); - pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); + pNumType = VclPtr<OPropListBoxCtrl>::Create( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); pNumType->SetDropDownLineCount(5); pNumType->InsertEntry( OUString("Byte") ); @@ -901,12 +925,12 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_nPos++; pFormatText = CreateText(STR_FORMAT); - pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); + pFormatSample = VclPtr<OPropEditCtrl>::Create( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); pFormatSample->SetReadOnly(true); pFormatSample->Enable(false); InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false); - pFormat = new PushButton( this, ModuleRes(PB_FORMAT) ); + pFormat = VclPtr<PushButton>::Create( this, ModuleRes(PB_FORMAT) ); const sal_Int32 nControlHeight = GetMaxControlHeight(); pFormat->SetSizePixel(Size(nControlHeight, nControlHeight)); pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) ); @@ -921,7 +945,7 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_nPos++; pBoolDefaultText = CreateText(STR_DEFAULT_VALUE); - pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN ); + pBoolDefault = VclPtr<OPropListBoxCtrl>::Create( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN ); pBoolDefault->SetDropDownLineCount(3); pBoolDefault->InsertEntry(OUString(ModuleRes(STR_VALUE_NONE))); pBoolDefault->InsertEntry(aYes); @@ -943,17 +967,17 @@ void OFieldDescControl::InitializeControl(Control* _pControl,const OString& _sHe _pControl->EnableClipSiblings(); } -FixedText* OFieldDescControl::CreateText(sal_uInt16 _nTextRes) +VclPtr<FixedText> OFieldDescControl::CreateText(sal_uInt16 _nTextRes) { - FixedText* pFixedText = new FixedText( this ); + VclPtrInstance<FixedText> pFixedText( this ); pFixedText->SetText( ModuleRes(_nTextRes) ); pFixedText->EnableClipSiblings(); return pFixedText; } -OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const OString& _sHelpId) +VclPtr<OPropNumericEditCtrl> OFieldDescControl::CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const OString& _sHelpId) { - OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER ); + VclPtrInstance<OPropNumericEditCtrl> pControl( this, _nHelpStr, _nProperty, WB_BORDER ); pControl->SetDecimalDigits(0); pControl->SetMin(0); pControl->SetMax(0x7FFFFFFF); // Should be changed outside, if needed @@ -971,62 +995,61 @@ void OFieldDescControl::DeactivateAggregate( EControlType eType ) switch( eType ) { case tpDefault: - lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText); + lcl_HideAndDeleteControl(m_nPos,pDefault,pDefaultText); break; case tpAutoIncrementValue: - lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText); + lcl_HideAndDeleteControl(m_nPos,m_pAutoIncrementValue,m_pAutoIncrementValueText); break; case tpColumnName: - lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText); + lcl_HideAndDeleteControl(m_nPos,m_pColumnName,m_pColumnNameText); break; case tpType: - lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText); + lcl_HideAndDeleteControl(m_nPos,m_pType,m_pTypeText); break; case tpAutoIncrement: - lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText); + lcl_HideAndDeleteControl(m_nPos,pAutoIncrement,pAutoIncrementText); break; case tpRequired: - lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText); + lcl_HideAndDeleteControl(m_nPos,pRequired,pRequiredText); break; case tpTextLen: - lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText); + lcl_HideAndDeleteControl(m_nPos,pTextLen,pTextLenText); break; case tpNumType: - lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText); + lcl_HideAndDeleteControl(m_nPos,pNumType,pNumTypeText); break; case tpLength: - lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText); + lcl_HideAndDeleteControl(m_nPos,pLength,pLengthText); break; case tpScale: - lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText); + lcl_HideAndDeleteControl(m_nPos,pScale,pScaleText); break; case tpFormat: // TODO: we have to check if we have to increment m_nPos again - lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText); + lcl_HideAndDeleteControl(m_nPos,pFormat,pFormatText); if ( pFormatSample ) { pFormatSample->Hide(); - delete pFormatSample; - pFormatSample = NULL; + pFormatSample.disposeAndClear(); } break; case tpBoolDefault: - lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText); + lcl_HideAndDeleteControl(m_nPos,pBoolDefault,pBoolDefaultText); break; } } -void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol ) +void OFieldDescControl::SetPosSize( VclPtr<Control>& rControl, long nRow, sal_uInt16 nCol ) { // Calculate size @@ -1077,18 +1100,18 @@ void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 n aPosition.X() = 0; } - (*ppControl)->SetSizePixel( aSize ); - aSize = (*ppControl)->GetSizePixel( ); + rControl->SetSizePixel( aSize ); + aSize = rControl->GetSizePixel( ); const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); aPosition.Y() += ((nRow+1)*nControl_Spacing_y) + (nRow*nControlHeight); // Display Control - (*ppControl)->SetPosSizePixel( aPosition, aSize ); - aSize = (*ppControl)->GetSizePixel(); + rControl->SetPosSizePixel( aPosition, aSize ); + aSize = rControl->GetSizePixel(); - (*ppControl)->Show(); + rControl->Show(); } void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) @@ -1453,7 +1476,7 @@ IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl ) if (pControl == pFormat) strHelpText = ModuleRes(STR_HELP_FORMAT_BUTTON); - if (!strHelpText.isEmpty() && (pHelp != NULL)) + if (!strHelpText.isEmpty() && (pHelp != nullptr)) pHelp->SetHelpText(strHelpText); m_pActFocusWindow = pControl; @@ -1579,30 +1602,30 @@ void OFieldDescControl::LoseFocus() bool OFieldDescControl::isCopyAllowed() { - bool bAllowed = (m_pActFocusWindow != NULL) && + bool bAllowed = (m_pActFocusWindow != nullptr) && (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || m_pActFocusWindow == m_pAutoIncrementValue) && - !static_cast<Edit*>(m_pActFocusWindow)->GetSelected().isEmpty(); + !static_cast<Edit*>(m_pActFocusWindow.get())->GetSelected().isEmpty(); return bAllowed; } bool OFieldDescControl::isCutAllowed() { - bool bAllowed = (m_pActFocusWindow != NULL) && + bool bAllowed = (m_pActFocusWindow != nullptr) && (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || m_pActFocusWindow == m_pAutoIncrementValue) && - !static_cast<Edit*>(m_pActFocusWindow)->GetSelected().isEmpty(); + !static_cast<Edit*>(m_pActFocusWindow.get())->GetSelected().isEmpty(); return bAllowed; } bool OFieldDescControl::isPasteAllowed() { - bool bAllowed = (m_pActFocusWindow != NULL) && + bool bAllowed = (m_pActFocusWindow != nullptr) && (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || @@ -1618,19 +1641,19 @@ bool OFieldDescControl::isPasteAllowed() void OFieldDescControl::cut() { if(isCutAllowed()) - static_cast<Edit*>(m_pActFocusWindow)->Cut(); + static_cast<Edit*>(m_pActFocusWindow.get())->Cut(); } void OFieldDescControl::copy() { if(isCopyAllowed()) // this only checks if the focus window is valid - static_cast<Edit*>(m_pActFocusWindow)->Copy(); + static_cast<Edit*>(m_pActFocusWindow.get())->Copy(); } void OFieldDescControl::paste() { if(m_pActFocusWindow) // this only checks if the focus window is valid - static_cast<Edit*>(m_pActFocusWindow)->Paste(); + static_cast<Edit*>(m_pActFocusWindow.get())->Paste(); } bool OFieldDescControl::isTextFormat(const OFieldDescription* _pFieldDescr, sal_uInt32& _nFormatKey) const diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index 0a7035d6f7f6..f011e060a719 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -59,7 +59,7 @@ namespace dbaui { friend class OTableListBoxControl; - ::std::unique_ptr< ::svt::ListBoxControl> m_pListCell; + VclPtr< ::svt::ListBoxControl> m_pListCell; TTableConnectionData::value_type m_pConnData; OTableListBoxControl* m_pBoxControl; long m_nDataPos; @@ -83,7 +83,6 @@ namespace dbaui { m_pBoxControl = pController; } - virtual ~ORelationControl(); /** searches for a connection between these two tables @param _pSource @@ -102,6 +101,8 @@ namespace dbaui void lateInit(); protected: + virtual ~ORelationControl() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE { m_pListCell.disposeAndClear(); ORelationControl_Base::dispose(); } virtual void Resize() SAL_OVERRIDE; virtual Size GetOptimalSize() const SAL_OVERRIDE; virtual bool PreNotify(NotifyEvent& rNEvt ) SAL_OVERRIDE; @@ -144,10 +145,6 @@ namespace dbaui return new ORelationControl(pParent); } - ORelationControl::~ORelationControl() - { - } - void ORelationControl::Init(const TTableConnectionData::value_type& _pConnData) { @@ -170,7 +167,7 @@ namespace dbaui InsertDataColumn( DEST_COLUMN, m_pConnData->getReferencedTable()->GetWinName(), 100); // If the Defs do not yet exits, we need to set them with SetSource-/-DestDef - m_pListCell.reset( new ListBoxControl( &GetDataWindow() ) ); + m_pListCell.reset( VclPtr<ListBoxControl>::Create( &GetDataWindow() ) ); // set browse mode SetMode( BrowserMode::COLUMNSELECTION | diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx index 122f230d4afb..1496a3610fcd 100644 --- a/dbaccess/source/ui/control/TableGrantCtrl.cxx +++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx @@ -71,16 +71,22 @@ OTableGrantControl::OTableGrantControl( vcl::Window* pParent, WinBits nBits) OTableGrantControl::~OTableGrantControl() { + disposeOnce(); +} + +void OTableGrantControl::dispose() +{ if (m_nDeactivateEvent) { Application::RemoveUserEvent(m_nDeactivateEvent); m_nDeactivateEvent = 0; } - delete m_pCheckCell; - delete m_pEdit; + m_pCheckCell.disposeAndClear(); + m_pEdit.disposeAndClear(); m_xTables = NULL; + ::svt::EditBrowseBox::dispose(); } void OTableGrantControl::setTablesSupplier(const Reference< XTablesSupplier >& _xTablesSup) @@ -122,10 +128,10 @@ void OTableGrantControl::Init() // ComboBox instanzieren if(!m_pCheckCell) { - m_pCheckCell = new CheckBoxControl( &GetDataWindow() ); + m_pCheckCell = VclPtr<CheckBoxControl>::Create( &GetDataWindow() ); m_pCheckCell->GetBox().EnableTriState(false); - m_pEdit = new Edit( &GetDataWindow() ); + m_pEdit = VclPtr<Edit>::Create( &GetDataWindow() ); m_pEdit->SetReadOnly(); m_pEdit->Enable(false); } diff --git a/dbaccess/source/ui/control/VertSplitView.cxx b/dbaccess/source/ui/control/VertSplitView.cxx index 5313d4213cb6..5644fbbaf4bf 100644 --- a/dbaccess/source/ui/control/VertSplitView.cxx +++ b/dbaccess/source/ui/control/VertSplitView.cxx @@ -39,7 +39,15 @@ OSplitterView::OSplitterView(vcl::Window* _pParent,bool _bVertical) : Window(_pP OSplitterView::~OSplitterView() { - m_pRight = m_pLeft = NULL; + disposeOnce(); +} + +void OSplitterView::dispose() +{ + m_pSplitter.clear(); + m_pLeft.clear(); + m_pRight.clear(); + vcl::Window::dispose(); } IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ ) diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx index 9daa8b9be5de..d7a510b4e255 100644 --- a/dbaccess/source/ui/control/charsetlistbox.cxx +++ b/dbaccess/source/ui/control/charsetlistbox.cxx @@ -43,10 +43,6 @@ namespace dbaui return new CharSetListBox(pParent); } - CharSetListBox::~CharSetListBox() - { - } - void CharSetListBox::SelectEntryByIanaName( const OUString& _rIanaName ) { OCharsetDisplay::const_iterator aFind = m_aCharSets.findIanaName( _rIanaName ); diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx index 4dc9d7fffb52..917e8870c43a 100644 --- a/dbaccess/source/ui/control/curledit.cxx +++ b/dbaccess/source/ui/control/curledit.cxx @@ -40,11 +40,14 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeConnectionURLEdit(vcl: OConnectionURLEdit::~OConnectionURLEdit() { - // delete my sub controls - Edit* pSubEdit = GetSubEdit(); - SetSubEdit(NULL); - delete pSubEdit; - delete m_pForcedPrefix; + disposeOnce(); +} + +void OConnectionURLEdit::dispose() +{ + SetSubEdit(nullptr); + m_pForcedPrefix.disposeAndClear(); + Edit::dispose(); } void OConnectionURLEdit::SetTextNoPrefix(const OUString& _rText) @@ -86,10 +89,10 @@ void OConnectionURLEdit::SetText(const OUString& _rStr, const Selection& /*_rNew { // create new sub controls, if necessary if (!GetSubEdit()) - SetSubEdit(new Edit(this, 0)); + SetSubEdit(VclPtr<Edit>::Create(this, 0)); if ( !m_pForcedPrefix ) { - m_pForcedPrefix = new FixedText(this, WB_VCENTER); + m_pForcedPrefix = VclPtr<FixedText>::Create(this, WB_VCENTER); // we use a gray background for the fixed text StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx index 2d4e0cea22aa..afd7b1b60fb0 100644 --- a/dbaccess/source/ui/control/dbtreelistbox.cxx +++ b/dbaccess/source/ui/control/dbtreelistbox.cxx @@ -84,7 +84,13 @@ void DBTreeListBox::init() DBTreeListBox::~DBTreeListBox() { + disposeOnce(); +} + +void DBTreeListBox::dispose() +{ implStopSelectionTimer(); + SvTreeListBox::dispose(); } SvTreeListEntry* DBTreeListBox::GetEntryPosByName( const OUString& aName, SvTreeListEntry* pStart, const IEntryFilter* _pFilter ) const diff --git a/dbaccess/source/ui/control/marktree.cxx b/dbaccess/source/ui/control/marktree.cxx index 2fc45e769fa2..ddd50aa66e58 100644 --- a/dbaccess/source/ui/control/marktree.cxx +++ b/dbaccess/source/ui/control/marktree.cxx @@ -37,8 +37,13 @@ OMarkableTreeListBox::OMarkableTreeListBox( vcl::Window* pParent, WinBits nWinSt OMarkableTreeListBox::~OMarkableTreeListBox() { - delete m_pCheckButton; + disposeOnce(); +} +void OMarkableTreeListBox::dispose() +{ + delete m_pCheckButton; + DBTreeListBox::dispose(); } void OMarkableTreeListBox::Paint(const Rectangle& _rRect) diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx index ff4007f729f9..9048294db7c3 100644 --- a/dbaccess/source/ui/control/sqledit.cxx +++ b/dbaccess/source/ui/control/sqledit.cxx @@ -105,6 +105,11 @@ OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) : OSqlEdit::~OSqlEdit() { + disposeOnce(); +} + +void OSqlEdit::dispose() +{ if (m_timerUndoActionCreation.IsActive()) m_timerUndoActionCreation.Stop(); css::uno::Reference< css::beans::XMultiPropertySet > n; @@ -116,6 +121,8 @@ OSqlEdit::~OSqlEdit() n->removePropertiesChangeListener(m_listener.get()); } m_ColorConfig.RemoveListener(this); + m_pView.clear(); + MultiLineEditSyntaxHighlight::dispose(); } void OSqlEdit::KeyInput( const KeyEvent& rKEvt ) diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx index cb6d3061ad46..079e4a5f61e8 100644 --- a/dbaccess/source/ui/control/toolboxcontroller.cxx +++ b/dbaccess/source/ui/control/toolboxcontroller.cxx @@ -131,7 +131,7 @@ namespace dbaui for (; aIter != aEnd; ++aIter) addStatusListener(aIter->first); - ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent())); + VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get()); if ( pToolBox ) { sal_uInt16 nCount = pToolBox->GetItemCount(); @@ -169,7 +169,7 @@ namespace dbaui { m_aCommandURL = aFind->first; - ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent())); + VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get()); lcl_copy(pMenu.get(),nItemId,i,pToolBox,m_nToolBoxId, m_aCommandURL); break; } @@ -228,7 +228,7 @@ namespace dbaui SolarMutexGuard aSolarMutexGuard; ::osl::MutexGuard aGuard(m_aMutex); - ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent())); + VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get()); ::std::unique_ptr<PopupMenu> pMenu = getMenu(); sal_uInt16 nSelected = pMenu->Execute(pToolBox, pToolBox->GetItemRect( m_nToolBoxId ),POPUPMENU_EXECUTE_DOWN); diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx index aa50eb9bc4ca..1ceb8a62931d 100644 --- a/dbaccess/source/ui/dlg/CollectionView.cxx +++ b/dbaccess/source/ui/dlg/CollectionView.cxx @@ -91,10 +91,21 @@ OCollectionView::OCollectionView( vcl::Window * pParent m_pPB_OK->SetClickHdl( LINK( this, OCollectionView, Save_Click ) ); } -OCollectionView::~OCollectionView( ) +OCollectionView::~OCollectionView() { + disposeOnce(); } +void OCollectionView::dispose() +{ + m_pFTCurrentPath.clear(); + m_pNewFolder.clear(); + m_pUp.clear(); + m_pView.clear(); + m_pName.clear(); + m_pPB_OK.clear(); + ModalDialog::dispose(); +} IMPL_LINK_NOARG(OCollectionView, Save_Click) { @@ -169,8 +180,8 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click) Reference< XContent> xContent; if ( xNameContainer->hasByName(sName) ) { - QueryBox aBox( this, WB_YES_NO, ModuleRes( STR_ALREADYEXISTOVERWRITE ) ); - if ( aBox.Execute() != RET_YES ) + ScopedVclPtrInstance< QueryBox > aBox( this, WB_YES_NO, ModuleRes( STR_ALREADYEXISTOVERWRITE ) ); + if ( aBox->Execute() != RET_YES ) return 0; } m_pName->SetText(sName); diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index a02b5d68b80b..8bf6989c9ab9 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -91,7 +91,6 @@ namespace dbaui : OGenericAdministrationPage(pParent, _rId, _rUIXMLDescription, _rCoreAttrs) , m_bUserGrabFocus(false) , m_pCollection(NULL) - , m_bDelete(false) { get(m_pFT_Connection, "browseurllabel"); get(m_pConnectionURL, "browseurl"); @@ -110,13 +109,17 @@ namespace dbaui OConnectionHelper::~OConnectionHelper() { - if(m_bDelete) - { - delete m_pFT_Connection; - delete m_pConnectionURL; - delete m_pPB_Connection; - delete m_pPB_CreateDB; - } + disposeOnce(); + } + + void OConnectionHelper::dispose() + { + // FIXME: used to have an if (m_bDelete) ... + m_pFT_Connection.disposeAndClear(); + m_pConnectionURL.disposeAndClear(); + m_pPB_Connection.disposeAndClear(); + m_pPB_CreateDB.disposeAndClear(); + OGenericAdministrationPage::dispose(); } void OConnectionHelper::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) @@ -306,16 +309,16 @@ namespace dbaui aProfiles.insert(pArray[index]); // execute the select dialog - ODatasourceSelectDialog aSelector(GetParent(), aProfiles); + ScopedVclPtrInstance< ODatasourceSelectDialog > aSelector(GetParent(), aProfiles); OUString sOldProfile=getURLNoPrefix(); if (!sOldProfile.isEmpty()) - aSelector.Select(sOldProfile); + aSelector->Select(sOldProfile); else - aSelector.Select(xMozillaBootstrap->getDefaultProfile(profileType)); + aSelector->Select(xMozillaBootstrap->getDefaultProfile(profileType)); - if ( RET_OK == aSelector.Execute() ) - setURLNoPrefix(aSelector.GetSelected()); + if ( RET_OK == aSelector->Execute() ) + setURLNoPrefix(aSelector->GetSelected()); break; } case ::dbaccess::DST_FIREBIRD: @@ -476,8 +479,8 @@ namespace dbaui sQuery = sQuery.replaceFirst("$path$", aTransformer.get(OFileNotation::N_SYSTEM)); m_bUserGrabFocus = false; - QueryBox aQuery(GetParent(), WB_YES_NO | WB_DEF_YES, sQuery); - sal_Int32 nQueryResult = aQuery.Execute(); + ScopedVclPtrInstance< QueryBox > aQuery(GetParent(), WB_YES_NO | WB_DEF_YES, sQuery); + sal_Int32 nQueryResult = aQuery->Execute(); m_bUserGrabFocus = true; switch (nQueryResult) @@ -493,8 +496,8 @@ namespace dbaui sQuery = sQuery.replaceFirst("$name$", aTransformer.get(OFileNotation::N_SYSTEM)); m_bUserGrabFocus = false; - QueryBox aWhatToDo(GetParent(), WB_RETRY_CANCEL | WB_DEF_RETRY, sQuery); - nQueryResult = aWhatToDo.Execute(); + ScopedVclPtrInstance< QueryBox > aWhatToDo(GetParent(), WB_RETRY_CANCEL | WB_DEF_RETRY, sQuery); + nQueryResult = aWhatToDo->Execute(); m_bUserGrabFocus = true; if (RET_RETRY == nQueryResult) diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx index 117295bea89d..9fd69e7459c4 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.hxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx @@ -42,10 +42,11 @@ namespace dbaui public: OConnectionHelper( vcl::Window* pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rCoreAttrs); virtual ~OConnectionHelper(); - FixedText *m_pFT_Connection; - OConnectionURLEdit *m_pConnectionURL; - PushButton *m_pPB_Connection; - PushButton *m_pPB_CreateDB; + virtual void dispose() SAL_OVERRIDE; + VclPtr<FixedText> m_pFT_Connection; + VclPtr<OConnectionURLEdit> m_pConnectionURL; + VclPtr<PushButton> m_pPB_Connection; + VclPtr<PushButton> m_pPB_CreateDB; OUString m_eType; // the type can't be changed in this class, so we hold it as member. public: @@ -95,7 +96,6 @@ namespace dbaui OUString impl_getURL( bool _bPrefix ) const; void impl_setURL( const OUString& _rURL, bool _bPrefix ); void implUpdateURLDependentStates() const; - bool m_bDelete; }; } // namespace dbaui diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index 4e7b8cc39987..ed99f813357d 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -81,10 +81,11 @@ namespace dbaui using namespace ::dbtools; using namespace ::svt; - SfxTabPage* OConnectionTabPage::Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> OConnectionTabPage::Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OConnectionTabPage( pParent, *_rAttrSet ) ); + return VclPtr<SfxTabPage>(new OConnectionTabPage( pParent, *_rAttrSet ), SAL_NO_ACQUIRE); } + // OConnectionTabPage OConnectionTabPage::OConnectionTabPage(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs) :OConnectionHelper(pParent, "ConnectionPage", "dbaccess/ui/connectionpage.ui", _rCoreAttrs) @@ -111,6 +112,21 @@ namespace dbaui OConnectionTabPage::~OConnectionTabPage() { + disposeOnce(); + } + + void OConnectionTabPage::dispose() + { + m_pFL2.clear(); + m_pUserNameLabel.clear(); + m_pUserName.clear(); + m_pPasswordRequired.clear(); + m_pFL3.clear(); + m_pJavaDriverLabel.clear(); + m_pJavaDriver.clear(); + m_pTestJavaDriver.clear(); + m_pTestConnection.clear(); + OConnectionHelper::dispose(); } void OConnectionTabPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) @@ -293,8 +309,8 @@ namespace dbaui const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error; - OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); - aMsg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); + aMsg->Execute(); return 0L; } bool OConnectionTabPage::checkTestConnection() diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hxx b/dbaccess/source/ui/dlg/ConnectionPage.hxx index 5e1c84fb88a1..2b4626d8fa08 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.hxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.hxx @@ -36,26 +36,28 @@ namespace dbaui { protected: // user authentification - FixedText* m_pFL2; - FixedText* m_pUserNameLabel; - Edit* m_pUserName; - CheckBox* m_pPasswordRequired; + VclPtr<FixedText> m_pFL2; + VclPtr<FixedText> m_pUserNameLabel; + VclPtr<Edit> m_pUserName; + VclPtr<CheckBox> m_pPasswordRequired; // jdbc driver - FixedText* m_pFL3; - FixedText* m_pJavaDriverLabel; - Edit* m_pJavaDriver; - PushButton* m_pTestJavaDriver; + VclPtr<FixedText> m_pFL3; + VclPtr<FixedText> m_pJavaDriverLabel; + VclPtr<Edit> m_pJavaDriver; + VclPtr<PushButton> m_pTestJavaDriver; // connection test - PushButton* m_pTestConnection; + VclPtr<PushButton> m_pTestConnection; // called when the test connection button was clicked - DECL_LINK(OnTestJavaClickHdl,PushButton*); - DECL_LINK(OnEditModified,Edit*); + DECL_LINK(OnTestJavaClickHdl, PushButton*); + DECL_LINK(OnEditModified, Edit*); public: - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); + virtual ~OConnectionTabPage(); + virtual void dispose() SAL_OVERRIDE; + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); virtual bool FillItemSet (SfxItemSet* _rCoreAttrs) SAL_OVERRIDE; virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; @@ -70,7 +72,6 @@ namespace dbaui private: OConnectionTabPage(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); // nControlFlags is a combination of the CBTP_xxx-constants - virtual ~OConnectionTabPage(); private: /** enables the test connection button, if allowed diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx index db19ebb9d21b..b081ad82c565 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx @@ -63,29 +63,29 @@ namespace dbaui using namespace ::dbtools; using namespace ::svt; - OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE); + return VclPtr<OGenericAdministrationPage>( new OConnectionTabPageSetup ( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE), SAL_NO_ACQUIRE ); } - OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE); + return VclPtr<OGenericAdministrationPage>( new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE), SAL_NO_ACQUIRE ); } - OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL); + return VclPtr<OGenericAdministrationPage>( new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL), SAL_NO_ACQUIRE ); } - OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE); + return VclPtr<OGenericAdministrationPage>( new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE), SAL_NO_ACQUIRE ); } - OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OConnectionTabPageSetup::CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL); + return VclPtr<OGenericAdministrationPage>( new OConnectionTabPageSetup( pParent, "ConnectionPage", "dbaccess/ui/dbwizconnectionpage.ui", _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL), SAL_NO_ACQUIRE ); } OConnectionTabPageSetup::OConnectionTabPageSetup(vcl::Window* pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId) @@ -121,6 +121,14 @@ namespace dbaui OConnectionTabPageSetup::~OConnectionTabPageSetup() { + disposeOnce(); + } + + void OConnectionTabPageSetup::dispose() + { + m_pHelpText.clear(); + m_pHeaderText.clear(); + OConnectionHelper::dispose(); } void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx index 5705c1530cc2..1f0a22c69cf4 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx @@ -39,18 +39,20 @@ namespace dbaui bool m_bUserGrabFocus : 1; protected: - FixedText *m_pHelpText; - FixedText *m_pHeaderText; + VclPtr<FixedText> m_pHelpText; + VclPtr<FixedText> m_pHeaderText; // called when the test connection button was clicked DECL_LINK(OnEditModified,Edit*); public: - static OGenericAdministrationPage* CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - static OGenericAdministrationPage* CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - static OGenericAdministrationPage* CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - static OGenericAdministrationPage* CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - static OGenericAdministrationPage* CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + virtual ~OConnectionTabPageSetup(); + virtual void dispose() SAL_OVERRIDE; + static VclPtr<OGenericAdministrationPage> CreateDbaseTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateMSAccessTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateADOTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateODBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateUserDefinedTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); virtual bool FillItemSet (SfxItemSet* _rCoreAttrs) SAL_OVERRIDE; @@ -71,7 +73,6 @@ namespace dbaui OConnectionTabPageSetup(vcl::Window* pParent, const OString& _rId, const OUString& _rUIXMLDescription, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId); virtual bool checkTestConnection() SAL_OVERRIDE; // nControlFlags is a combination of the CBTP_xxx-constants - virtual ~OConnectionTabPageSetup(); }; } // namespace dbaui diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index 523b1aa9278d..c457c962c8fa 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -60,9 +60,9 @@ namespace dbaui { using namespace ::com::sun::star; - OGenericAdministrationPage* OTextConnectionPageSetup::CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OTextConnectionPageSetup::CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) ); + return VclPtr<OTextConnectionPageSetup>::Create( pParent, _rAttrSet ); } // OTextConnectionPageSetup @@ -70,14 +70,19 @@ using namespace ::com::sun::star; :OConnectionTabPageSetup(pParent, "DBWizTextPage", "dbaccess/ui/dbwiztextpage.ui", _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE) { - m_pTextConnectionHelper = new OTextConnectionHelper( get<VclVBox>("TextPageContainer"), TC_EXTENSION | TC_SEPARATORS ); + m_pTextConnectionHelper = VclPtr<OTextConnectionHelper>::Create( get<VclVBox>("TextPageContainer"), TC_EXTENSION | TC_SEPARATORS ); m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) ); } OTextConnectionPageSetup::~OTextConnectionPageSetup() { - DELETEZ(m_pTextConnectionHelper); + disposeOnce(); + } + void OTextConnectionPageSetup::dispose() + { + m_pTextConnectionHelper.disposeAndClear(); + OConnectionTabPageSetup::dispose(); } IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/) @@ -124,9 +129,9 @@ using namespace ::com::sun::star; return m_pTextConnectionHelper->prepareLeave(); } - OGenericAdministrationPage* OLDAPConnectionPageSetup::CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OLDAPConnectionPageSetup::CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) ); + return VclPtr<OLDAPConnectionPageSetup>::Create( pParent, _rAttrSet ); } // OLDAPPageSetup @@ -151,6 +156,25 @@ using namespace ::com::sun::star; SetRoadmapStateValue(false); } + OLDAPConnectionPageSetup::~OLDAPConnectionPageSetup() + { + disposeOnce(); + } + + void OLDAPConnectionPageSetup::dispose() + { + m_pFTHelpText.clear(); + m_pFTHostServer.clear(); + m_pETHostServer.clear(); + m_pFTBaseDN.clear(); + m_pETBaseDN.clear(); + m_pFTPortNumber.clear(); + m_pNFPortNumber.clear(); + m_pFTDefaultPortNumber.clear(); + m_pCBUseSSL.clear(); + OGenericAdministrationPage::dispose(); + } + bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet* _rSet ) { bool bChangedSomething = false; @@ -217,9 +241,9 @@ using namespace ::com::sun::star; return 0L; } - OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( vcl::Window* _pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OMySQLIntroPageSetup> OMySQLIntroPageSetup::CreateMySQLIntroTabPage( vcl::Window* _pParent, const SfxItemSet& _rAttrSet ) { - return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) ); + return VclPtr<OMySQLIntroPageSetup>::Create( _pParent, _rAttrSet); } @@ -235,15 +259,23 @@ using namespace ::com::sun::star; m_pNATIVEDatabase->SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected)); } - IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/) + OMySQLIntroPageSetup::~OMySQLIntroPageSetup() { - maClickHdl.Call( this ); - return long(true); + disposeOnce(); } - OMySQLIntroPageSetup::~OMySQLIntroPageSetup() + void OMySQLIntroPageSetup::dispose() { + m_pODBCDatabase.clear(); + m_pJDBCDatabase.clear(); + m_pNATIVEDatabase.clear(); + OGenericAdministrationPage::dispose(); + } + IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/) + { + maClickHdl.Call( this ); + return long(true); } void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, bool /*_bSaveValue*/) @@ -292,38 +324,50 @@ using namespace ::com::sun::star; // MySQLNativeSetupPage MySQLNativeSetupPage::MySQLNativeSetupPage( vcl::Window* _pParent, const SfxItemSet& _rCoreAttrs ) :OGenericAdministrationPage( _pParent, "DBWizMysqlNativePage", "dbaccess/ui/dbwizmysqlnativepage.ui", _rCoreAttrs ) - ,m_aMySQLSettings ( *get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink() ) + ,m_aMySQLSettings ( VclPtr<MySQLNativeSettings>::Create(*get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink()) ) { get(m_pHelpText, "helptext"); - m_aMySQLSettings.Show(); + m_aMySQLSettings->Show(); SetRoadmapStateValue(false); } - OGenericAdministrationPage* MySQLNativeSetupPage::Create( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + MySQLNativeSetupPage::~MySQLNativeSetupPage() + { + disposeOnce(); + } + + void MySQLNativeSetupPage::dispose() { - return new MySQLNativeSetupPage( pParent, _rAttrSet ); + m_aMySQLSettings.disposeAndClear(); + m_pHelpText.clear(); + OGenericAdministrationPage::dispose(); + } + + VclPtr<OGenericAdministrationPage> MySQLNativeSetupPage::Create( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<MySQLNativeSetupPage>::Create( pParent, _rAttrSet ); } void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) { - m_aMySQLSettings.fillControls( _rControlList ); + m_aMySQLSettings->fillControls( _rControlList ); } void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) { _rControlList.push_back( new ODisableWrapper< FixedText >( m_pHelpText ) ); - m_aMySQLSettings.fillWindows( _rControlList ); + m_aMySQLSettings->fillWindows( _rControlList ); } bool MySQLNativeSetupPage::FillItemSet( SfxItemSet* _rSet ) { - return m_aMySQLSettings.FillItemSet( _rSet ); + return m_aMySQLSettings->FillItemSet( _rSet ); } void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) { - m_aMySQLSettings.implInitControls( _rSet ); + m_aMySQLSettings->implInitControls( _rSet ); OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue ); @@ -337,7 +381,7 @@ using namespace ::com::sun::star; IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit ) { - SetRoadmapStateValue( m_aMySQLSettings.canAdvance() ); + SetRoadmapStateValue( m_aMySQLSettings->canAdvance() ); return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit ); } @@ -387,26 +431,48 @@ using namespace ::com::sun::star; SetRoadmapStateValue(false); } - OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + OGeneralSpecialJDBCConnectionPageSetup::~OGeneralSpecialJDBCConnectionPageSetup() + { + disposeOnce(); + } + + void OGeneralSpecialJDBCConnectionPageSetup::dispose() { - return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + m_pHeaderText.clear(); + m_pFTHelpText.clear(); + m_pFTDatabasename.clear(); + m_pETDatabasename.clear(); + m_pFTHostname.clear(); + m_pETHostname.clear(); + m_pFTPortNumber.clear(); + m_pFTDefaultPortNumber.clear(); + m_pNFPortNumber.clear(); + m_pFTDriverClass.clear(); + m_pETDriverClass.clear(); + m_pPBTestJavaDriver.clear(); + OGenericAdministrationPage::dispose(); + } + + VclPtr<OGenericAdministrationPage> OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + { + return VclPtr<OGeneralSpecialJDBCConnectionPageSetup>::Create( pParent, _rAttrSet, DSID_MYSQL_PORTNUMBER , STR_MYSQL_DEFAULT, STR_MYSQLJDBC_HELPTEXT, STR_MYSQLJDBC_HEADERTEXT, - STR_MYSQL_DRIVERCLASSTEXT) ); + STR_MYSQL_DRIVERCLASSTEXT); } - OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + return VclPtr<OGeneralSpecialJDBCConnectionPageSetup>::Create( pParent, _rAttrSet, DSID_ORACLE_PORTNUMBER, STR_ORACLE_DEFAULT, STR_ORACLE_HELPTEXT, STR_ORACLE_HEADERTEXT, - STR_ORACLE_DRIVERCLASSTEXT) ); + STR_ORACLE_DRIVERCLASSTEXT); } void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) @@ -497,8 +563,8 @@ using namespace ::com::sun::star; #endif const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error; - OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); - aMsg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); + aMsg->Execute(); return 0L; } @@ -512,9 +578,9 @@ using namespace ::com::sun::star; return 0L; } - OGenericAdministrationPage* OJDBCConnectionPageSetup::CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OJDBCConnectionPageSetup::CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet)); + return VclPtr<OJDBCConnectionPageSetup>::Create( pParent, _rAttrSet); } // OMySQLJDBCConnectionPageSetup @@ -529,6 +595,19 @@ using namespace ::com::sun::star; m_pPBTestJavaDriver->SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl)); } + OJDBCConnectionPageSetup::~OJDBCConnectionPageSetup() + { + disposeOnce(); + } + + void OJDBCConnectionPageSetup::dispose() + { + m_pFTDriverClass.clear(); + m_pETDriverClass.clear(); + m_pPBTestJavaDriver.clear(); + OConnectionTabPageSetup::dispose(); + } + void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) { _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETDriverClass)); @@ -606,8 +685,8 @@ using namespace ::com::sun::star; } #endif sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; - OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString() ); - aMsg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, OUString( ModuleRes( nMessage ) ), OUString() ); + aMsg->Execute(); return 0L; } @@ -621,9 +700,9 @@ using namespace ::com::sun::star; return 0L; } - OGenericAdministrationPage* OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) ); + return VclPtr<OSpreadSheetConnectionPageSetup>::Create( pParent, _rAttrSet ); } @@ -636,7 +715,13 @@ using namespace ::com::sun::star; OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup() { + disposeOnce(); + } + void OSpreadSheetConnectionPageSetup::dispose() + { + m_pPasswordrequired.clear(); + OConnectionTabPageSetup::dispose(); } void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/) @@ -662,9 +747,9 @@ using namespace ::com::sun::star; return bChangedSomething; } - OGenericAdministrationPage* OAuthentificationPageSetup::CreateAuthentificationTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) + VclPtr<OGenericAdministrationPage> OAuthentificationPageSetup::CreateAuthentificationTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OAuthentificationPageSetup( pParent, _rAttrSet) ); + return VclPtr<OAuthentificationPageSetup>::Create( pParent, _rAttrSet); } @@ -685,7 +770,17 @@ using namespace ::com::sun::star; OAuthentificationPageSetup::~OAuthentificationPageSetup() { + disposeOnce(); + } + void OAuthentificationPageSetup::dispose() + { + m_pFTHelpText.clear(); + m_pFTUserName.clear(); + m_pETUserName.clear(); + m_pCBPasswordRequired.clear(); + m_pPBTestConnection.clear(); + OGenericAdministrationPage::dispose(); } void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) @@ -729,9 +824,9 @@ using namespace ::com::sun::star; return bChangedSomething; } - OGenericAdministrationPage* OFinalDBPageSetup::CreateFinalDBTabPageSetup( vcl::Window* pParent, const SfxItemSet& _rAttrSet) + VclPtr<OGenericAdministrationPage> OFinalDBPageSetup::CreateFinalDBTabPageSetup( vcl::Window* pParent, const SfxItemSet& _rAttrSet) { - return ( new OFinalDBPageSetup( pParent, _rAttrSet) ); + return VclPtr<OFinalDBPageSetup>::Create( pParent, _rAttrSet); } @@ -755,7 +850,20 @@ using namespace ::com::sun::star; OFinalDBPageSetup::~OFinalDBPageSetup() { + disposeOnce(); + } + void OFinalDBPageSetup::dispose() + { + m_pFTFinalHeader.clear(); + m_pFTFinalHelpText.clear(); + m_pRBRegisterDataSource.clear(); + m_pRBDontregisterDataSource.clear(); + m_pFTAdditionalSettings.clear(); + m_pCBOpenAfterwards.clear(); + m_pCBStartTableWizard.clear(); + m_pFTFinalText.clear(); + OGenericAdministrationPage::dispose(); } bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered() diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx index 4756b6c75b57..109c3f3c93d3 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx @@ -40,12 +40,13 @@ namespace dbaui { public: virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; - static OGenericAdministrationPage* CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); OSpreadSheetConnectionPageSetup(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); + virtual ~OSpreadSheetConnectionPageSetup(); + virtual void dispose() SAL_OVERRIDE; protected: - CheckBox *m_pPasswordrequired; - virtual ~OSpreadSheetConnectionPageSetup(); + VclPtr<CheckBox> m_pPasswordrequired; protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; @@ -58,14 +59,14 @@ namespace dbaui class OTextConnectionPageSetup : public OConnectionTabPageSetup { public: + VclPtr<OTextConnectionHelper> m_pTextConnectionHelper; + virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; - static OGenericAdministrationPage* CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); OTextConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); - OTextConnectionHelper* m_pTextConnectionHelper; - private: - - protected: virtual ~OTextConnectionPageSetup(); + virtual void dispose() SAL_OVERRIDE; + protected: virtual bool prepareLeave() SAL_OVERRIDE; virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; @@ -81,8 +82,10 @@ namespace dbaui { public: virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; - static OGenericAdministrationPage* CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); OLDAPConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~OLDAPConnectionPageSetup(); + virtual void dispose() SAL_OVERRIDE; virtual Link getControlModifiedLink() SAL_OVERRIDE { return LINK(this, OLDAPConnectionPageSetup, OnEditModified); } protected: @@ -92,28 +95,30 @@ namespace dbaui DECL_LINK(OnEditModified,Edit*); private: - FixedText* m_pFTHelpText; - FixedText* m_pFTHostServer; - Edit* m_pETHostServer; - FixedText* m_pFTBaseDN; - Edit* m_pETBaseDN; - FixedText* m_pFTPortNumber; - NumericField* m_pNFPortNumber; - FixedText* m_pFTDefaultPortNumber; - CheckBox* m_pCBUseSSL; + VclPtr<FixedText> m_pFTHelpText; + VclPtr<FixedText> m_pFTHostServer; + VclPtr<Edit> m_pETHostServer; + VclPtr<FixedText> m_pFTBaseDN; + VclPtr<Edit> m_pETBaseDN; + VclPtr<FixedText> m_pFTPortNumber; + VclPtr<NumericField> m_pNFPortNumber; + VclPtr<FixedText> m_pFTDefaultPortNumber; + VclPtr<CheckBox> m_pCBUseSSL; }; // MySQLNativeSetupPage class MySQLNativeSetupPage : public OGenericAdministrationPage { private: - FixedText *m_pHelpText; - MySQLNativeSettings m_aMySQLSettings; + VclPtr<FixedText> m_pHelpText; + VclPtr<MySQLNativeSettings> m_aMySQLSettings; public: MySQLNativeSetupPage( vcl::Window* _pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~MySQLNativeSetupPage(); + virtual void dispose() SAL_OVERRIDE; - static OGenericAdministrationPage* Create( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> Create( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); protected: virtual void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) SAL_OVERRIDE; @@ -139,8 +144,10 @@ namespace dbaui , sal_uInt16 _nHelpTextResId , sal_uInt16 _nHeaderTextResId , sal_uInt16 _nDriverClassId ); - static OGenericAdministrationPage* CreateMySQLJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); - static OGenericAdministrationPage* CreateOracleJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + virtual ~OGeneralSpecialJDBCConnectionPageSetup(); + virtual void dispose() SAL_OVERRIDE; + static VclPtr<OGenericAdministrationPage> CreateMySQLJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateOracleJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); protected: virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; @@ -151,19 +158,19 @@ namespace dbaui DECL_LINK(OnTestJavaClickHdl,PushButton*); DECL_LINK(OnEditModified,Edit*); - FixedText* m_pHeaderText; - FixedText* m_pFTHelpText; - FixedText* m_pFTDatabasename; - Edit* m_pETDatabasename; - FixedText* m_pFTHostname; - Edit* m_pETHostname; - FixedText* m_pFTPortNumber; - FixedText* m_pFTDefaultPortNumber; - NumericField* m_pNFPortNumber; - - FixedText* m_pFTDriverClass; - Edit* m_pETDriverClass; - PushButton* m_pPBTestJavaDriver; + VclPtr<FixedText> m_pHeaderText; + VclPtr<FixedText> m_pFTHelpText; + VclPtr<FixedText> m_pFTDatabasename; + VclPtr<Edit> m_pETDatabasename; + VclPtr<FixedText> m_pFTHostname; + VclPtr<Edit> m_pETHostname; + VclPtr<FixedText> m_pFTPortNumber; + VclPtr<FixedText> m_pFTDefaultPortNumber; + VclPtr<NumericField> m_pNFPortNumber; + + VclPtr<FixedText> m_pFTDriverClass; + VclPtr<Edit> m_pETDriverClass; + VclPtr<PushButton> m_pPBTestJavaDriver; OUString m_sDefaultJdbcDriverName; sal_uInt16 m_nPortId; @@ -174,7 +181,9 @@ namespace dbaui { public: OJDBCConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); - static OGenericAdministrationPage* CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + virtual ~OJDBCConnectionPageSetup(); + virtual void dispose() SAL_OVERRIDE; + static VclPtr<OGenericAdministrationPage> CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); protected: virtual bool checkTestConnection() SAL_OVERRIDE; @@ -186,9 +195,9 @@ namespace dbaui DECL_LINK(OnTestJavaClickHdl,PushButton*); DECL_LINK(OnEditModified,Edit*); - FixedText* m_pFTDriverClass; - Edit* m_pETDriverClass; - PushButton* m_pPBTestJavaDriver; + VclPtr<FixedText> m_pFTDriverClass; + VclPtr<Edit> m_pETDriverClass; + VclPtr<PushButton> m_pPBTestJavaDriver; }; // OJDBCConnectionPageSetup @@ -203,8 +212,10 @@ namespace dbaui }; OMySQLIntroPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); + virtual ~OMySQLIntroPageSetup(); + virtual void dispose() SAL_OVERRIDE; - static OMySQLIntroPageSetup* CreateMySQLIntroTabPage( vcl::Window* _pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OMySQLIntroPageSetup> CreateMySQLIntroTabPage( vcl::Window* _pParent, const SfxItemSet& _rAttrSet ); ConnectionType getMySQLMode(); Link maClickHdl; void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } @@ -216,12 +227,11 @@ namespace dbaui virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; - virtual ~OMySQLIntroPageSetup(); private: - RadioButton *m_pODBCDatabase; - RadioButton *m_pJDBCDatabase; - RadioButton *m_pNATIVEDatabase; + VclPtr<RadioButton> m_pODBCDatabase; + VclPtr<RadioButton> m_pJDBCDatabase; + VclPtr<RadioButton> m_pNATIVEDatabase; DECL_LINK(OnSetupModeSelected, RadioButton*); @@ -232,16 +242,17 @@ namespace dbaui { public: virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; - static OGenericAdministrationPage* CreateAuthentificationTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); + static VclPtr<OGenericAdministrationPage> CreateAuthentificationTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ); OAuthentificationPageSetup(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); + virtual ~OAuthentificationPageSetup(); + virtual void dispose() SAL_OVERRIDE; protected: - FixedText* m_pFTHelpText; - FixedText* m_pFTUserName; - Edit* m_pETUserName; - CheckBox* m_pCBPasswordRequired; - PushButton* m_pPBTestConnection; - virtual ~OAuthentificationPageSetup(); + VclPtr<FixedText> m_pFTHelpText; + VclPtr<FixedText> m_pFTUserName; + VclPtr<Edit> m_pETUserName; + VclPtr<CheckBox> m_pCBPasswordRequired; + VclPtr<PushButton> m_pPBTestConnection; protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; @@ -254,18 +265,20 @@ namespace dbaui { public: virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; - static OGenericAdministrationPage* CreateFinalDBTabPageSetup( vcl::Window* pParent, const SfxItemSet& _rAttrSet); + static VclPtr<OGenericAdministrationPage> CreateFinalDBTabPageSetup( vcl::Window* pParent, const SfxItemSet& _rAttrSet); - FixedText* m_pFTFinalHeader; - FixedText* m_pFTFinalHelpText; - RadioButton* m_pRBRegisterDataSource; - RadioButton* m_pRBDontregisterDataSource; - FixedText* m_pFTAdditionalSettings; - CheckBox* m_pCBOpenAfterwards; - CheckBox* m_pCBStartTableWizard; - FixedText* m_pFTFinalText; + VclPtr<FixedText> m_pFTFinalHeader; + VclPtr<FixedText> m_pFTFinalHelpText; + VclPtr<RadioButton> m_pRBRegisterDataSource; + VclPtr<RadioButton> m_pRBDontregisterDataSource; + VclPtr<FixedText> m_pFTAdditionalSettings; + VclPtr<CheckBox> m_pCBOpenAfterwards; + VclPtr<CheckBox> m_pCBStartTableWizard; + VclPtr<FixedText> m_pFTFinalText; OFinalDBPageSetup(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); + virtual ~OFinalDBPageSetup(); + virtual void dispose() SAL_OVERRIDE; bool IsDatabaseDocumentToBeRegistered(); bool IsDatabaseDocumentToBeOpened(); bool IsTableWizardToBeStarted(); @@ -276,9 +289,6 @@ namespace dbaui DECL_LINK(OnOpenSelected, CheckBox*); protected: - virtual ~OFinalDBPageSetup(); - - protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx index 4b46778afb92..890a7acc33cd 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.hxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx @@ -35,6 +35,7 @@ #include <svl/itemset.hxx> #include <com/sun/star/frame/XModel.hpp> #include <svl/poolitem.hxx> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } namespace dbaui @@ -68,7 +69,7 @@ namespace dbaui MapInt2String m_aDirectPropTranslator; /// translating property id's into names (direct properties of a data source) MapInt2String m_aIndirectPropTranslator; /// translating property id's into names (indirect properties of a data source) - vcl::Window* m_pParent; + VclPtr<vcl::Window> m_pParent; IItemSetHelper* m_pItemSetHelper; public: diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx index 6a6ed636f295..071c346df3ba 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.hxx +++ b/dbaccess/source/ui/dlg/DriverSettings.hxx @@ -21,6 +21,7 @@ #include "dsntypes.hxx" #include <svl/poolitem.hxx> +#include <vcl/vclptr.hxx> #include <vector> class SfxTabPage; @@ -44,53 +45,53 @@ namespace dbaui /** Creates the detail page for Dbase */ - static SfxTabPage* CreateDbase2( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateDbase2( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for ado */ - static SfxTabPage* CreateDbase( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateDbase( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for ado */ - static SfxTabPage* CreateAdo( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateAdo( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for ODBC */ - static SfxTabPage* CreateODBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateODBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for user */ - static SfxTabPage* CreateUser( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateUser( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for MySQLODBC */ - static SfxTabPage* CreateMySQLODBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateMySQLODBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for MySQLJDBC */ - static SfxTabPage* CreateMySQLJDBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateMySQLJDBC( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for MySQLNATIVE */ - static SfxTabPage* CreateMySQLNATIVE( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateMySQLNATIVE( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for Oracle JDBC */ - static SfxTabPage* CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); /** Creates the detail page for LDAP */ - static SfxTabPage* CreateLDAP( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateLDAP( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /// Creates the detail page for Text - static SfxTabPage* CreateText( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateText( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /// creates the GeneratedValues page - static SfxTabPage* CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); /// creates the "Special Settings" page of the "Advanced Settings" dialog - static SfxTabPage* CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ); }; } diff --git a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx index 2c8b9b68ab48..7182276a6224 100644 --- a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx +++ b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx @@ -30,6 +30,15 @@ QueryPropertiesDialog::QueryPropertiesDialog( QueryPropertiesDialog::~QueryPropertiesDialog() { + disposeOnce(); +} + +void QueryPropertiesDialog::dispose() +{ + m_pRB_Distinct.clear(); + m_pRB_NonDistinct.clear(); + m_pLB_Limit.clear(); + ModalDialog::dispose(); } } ///dbaui namespace diff --git a/dbaccess/source/ui/dlg/RelationDlg.cxx b/dbaccess/source/ui/dlg/RelationDlg.cxx index 28d33723dae6..50913994c298 100644 --- a/dbaccess/source/ui/dlg/RelationDlg.cxx +++ b/dbaccess/source/ui/dlg/RelationDlg.cxx @@ -88,6 +88,26 @@ ORelationDialog::ORelationDialog( OJoinTableView* pParent, m_xTableControl->NotifyCellChange(); } +ORelationDialog::~ORelationDialog() +{ + disposeOnce(); +} + +void ORelationDialog::dispose() +{ + m_pRB_NoCascUpd.clear(); + m_pRB_CascUpd.clear(); + m_pRB_CascUpdNull.clear(); + m_pRB_CascUpdDefault.clear(); + m_pRB_NoCascDel.clear(); + m_pRB_CascDel.clear(); + m_pRB_CascDelNull.clear(); + m_pRB_CascDelDefault.clear(); + m_pPB_OK.clear(); + ModalDialog::dispose(); +} + + void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionData) { ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(_pConnectionData.get()); @@ -132,10 +152,6 @@ void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionD } } -ORelationDialog::~ORelationDialog() -{ -} - IMPL_LINK( ORelationDialog, OKClickHdl, Button*, /*pButton*/ ) { // RadioButtons auslesen diff --git a/dbaccess/source/ui/dlg/TablesSingleDlg.cxx b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx index a4a51e3d2623..8a29c4873208 100644 --- a/dbaccess/source/ui/dlg/TablesSingleDlg.cxx +++ b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx @@ -54,14 +54,20 @@ OTableSubscriptionDialog::OTableSubscriptionDialog(vcl::Window* pParent m_pImpl->translateProperties(xDatasource, *m_pOutSet); SetInputSet(m_pOutSet); - OTableSubscriptionPage* pTabPage = new OTableSubscriptionPage(get_content_area(), *m_pOutSet, this); + VclPtrInstance<OTableSubscriptionPage> pTabPage(get_content_area(), *m_pOutSet, this); pTabPage->SetServiceFactory(_rxORB); SetTabPage(pTabPage); } OTableSubscriptionDialog::~OTableSubscriptionDialog() { + disposeOnce(); +} + +void OTableSubscriptionDialog::dispose() +{ delete m_pOutSet; + SfxSingleTabDialog::dispose(); } short OTableSubscriptionDialog::Execute() diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx index c99292a925ef..5c8b4b3551aa 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx @@ -114,7 +114,7 @@ namespace dbaui struct SectionDescriptor { short nFlag; - vcl::Window* pFirstControl; + VclPtr<vcl::Window> pFirstControl; } aSections[] = { { TC_EXTENSION, m_pExtensionHeader }, { TC_SEPARATORS, m_pFormatHeader }, @@ -153,7 +153,31 @@ namespace dbaui OTextConnectionHelper::~OTextConnectionHelper() { + disposeOnce(); + } + void OTextConnectionHelper::dispose() + { + m_pExtensionHeader.clear(); + m_pAccessTextFiles.clear(); + m_pAccessCSVFiles.clear(); + m_pAccessOtherFiles.clear(); + m_pOwnExtension.clear(); + m_pExtensionExample.clear(); + m_pFormatHeader.clear(); + m_pFieldSeparatorLabel.clear(); + m_pFieldSeparator.clear(); + m_pTextSeparatorLabel.clear(); + m_pTextSeparator.clear(); + m_pDecimalSeparatorLabel.clear(); + m_pDecimalSeparator.clear(); + m_pThousandsSeparatorLabel.clear(); + m_pThousandsSeparator.clear(); + m_pRowHeader.clear(); + m_pCharSetHeader.clear(); + m_pCharSetLabel.clear(); + m_pCharSet.clear(); + TabPage::dispose(); } IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/) diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx index b9317f8b46b6..56610e6e615b 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx @@ -49,27 +49,28 @@ namespace dbaui public: OTextConnectionHelper( vcl::Window* pParent, const short _nAvailableSections ); virtual ~OTextConnectionHelper(); + virtual void dispose() SAL_OVERRIDE; private: - FixedText *m_pExtensionHeader; - RadioButton *m_pAccessTextFiles; - RadioButton *m_pAccessCSVFiles; - RadioButton *m_pAccessOtherFiles; - Edit *m_pOwnExtension; - FixedText *m_pExtensionExample; - FixedText *m_pFormatHeader; - FixedText *m_pFieldSeparatorLabel; - ComboBox *m_pFieldSeparator; - FixedText *m_pTextSeparatorLabel; - ComboBox *m_pTextSeparator; - FixedText *m_pDecimalSeparatorLabel; - ComboBox *m_pDecimalSeparator; - FixedText *m_pThousandsSeparatorLabel; - ComboBox *m_pThousandsSeparator; - CheckBox *m_pRowHeader; - FixedText *m_pCharSetHeader; - FixedText *m_pCharSetLabel; - CharSetListBox *m_pCharSet; + VclPtr<FixedText> m_pExtensionHeader; + VclPtr<RadioButton> m_pAccessTextFiles; + VclPtr<RadioButton> m_pAccessCSVFiles; + VclPtr<RadioButton> m_pAccessOtherFiles; + VclPtr<Edit> m_pOwnExtension; + VclPtr<FixedText> m_pExtensionExample; + VclPtr<FixedText> m_pFormatHeader; + VclPtr<FixedText> m_pFieldSeparatorLabel; + VclPtr<ComboBox> m_pFieldSeparator; + VclPtr<FixedText> m_pTextSeparatorLabel; + VclPtr<ComboBox> m_pTextSeparator; + VclPtr<FixedText> m_pDecimalSeparatorLabel; + VclPtr<ComboBox> m_pDecimalSeparator; + VclPtr<FixedText> m_pThousandsSeparatorLabel; + VclPtr<ComboBox> m_pThousandsSeparator; + VclPtr<CheckBox> m_pRowHeader; + VclPtr<FixedText> m_pCharSetHeader; + VclPtr<FixedText> m_pCharSetLabel; + VclPtr<CharSetListBox> m_pCharSet; OUString m_aFieldSeparatorList; OUString m_aTextSeparatorList; OUString m_aTextNone; diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx index 66556c6b8630..ee25dd304bb1 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.cxx +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -51,17 +51,27 @@ using namespace comphelper; class OPasswordDialog : public ModalDialog { - VclFrame* m_pUser; - Edit* m_pEDOldPassword; - Edit* m_pEDPassword; - Edit* m_pEDPasswordRepeat; - OKButton* m_pOKBtn; + VclPtr<VclFrame> m_pUser; + VclPtr<Edit> m_pEDOldPassword; + VclPtr<Edit> m_pEDPassword; + VclPtr<Edit> m_pEDPasswordRepeat; + VclPtr<OKButton> m_pOKBtn; DECL_LINK( OKHdl_Impl, void * ); DECL_LINK( ModifiedHdl, Edit * ); public: OPasswordDialog( vcl::Window* pParent,const OUString& _sUserName); + virtual ~OPasswordDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE + { + m_pUser.clear(); + m_pEDOldPassword.clear(); + m_pEDPassword.clear(); + m_pEDPasswordRepeat.clear(); + m_pOKBtn.clear(); + ModalDialog::dispose(); + } OUString GetOldPassword() const { return m_pEDOldPassword->GetText(); } OUString GetNewPassword() const { return m_pEDPassword->GetText(); } @@ -92,8 +102,8 @@ IMPL_LINK_NOARG(OPasswordDialog, OKHdl_Impl) else { OUString aErrorMsg( ModuleRes( STR_ERROR_PASSWORDS_NOT_IDENTICAL)); - MessageDialog aErrorBox(this, aErrorMsg); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox(this, aErrorMsg); + aErrorBox->Execute(); m_pEDPassword->SetText( OUString() ); m_pEDPasswordRepeat->SetText( OUString() ); m_pEDPassword->GrabFocus(); @@ -114,9 +124,9 @@ OUserAdmin::OUserAdmin(vcl::Window* pParent,const SfxItemSet& _rAttrSet) , m_pNEWUSER(0) , m_pCHANGEPWD(0) , m_pDELETEUSER(0) - ,m_TableCtrl(get<VclAlignment>("table"), WB_TABSTOP) + ,m_TableCtrl(VclPtr<OTableGrantControl>::Create(get<VclAlignment>("table"), WB_TABSTOP)) { - m_TableCtrl.Show(); + m_TableCtrl->Show(); get(m_pUSER, "user"); get(m_pNEWUSER, "add"); get(m_pCHANGEPWD, "changepass"); @@ -131,7 +141,18 @@ OUserAdmin::OUserAdmin(vcl::Window* pParent,const SfxItemSet& _rAttrSet) OUserAdmin::~OUserAdmin() { + disposeOnce(); +} + +void OUserAdmin::dispose() +{ m_xConnection = NULL; + m_TableCtrl.disposeAndClear(); + m_pUSER.clear(); + m_pNEWUSER.clear(); + m_pCHANGEPWD.clear(); + m_pDELETEUSER.clear(); + OGenericAdministrationPage::dispose(); } void OUserAdmin::FillUserNames() @@ -162,11 +183,11 @@ void OUserAdmin::FillUserNames() { Reference<XAuthorizable> xAuth; m_xUsers->getByName(m_UserName) >>= xAuth; - m_TableCtrl.setGrantUser(xAuth); + m_TableCtrl->setGrantUser(xAuth); } - m_TableCtrl.setUserName(GetUser()); - m_TableCtrl.Init(); + m_TableCtrl->setUserName(GetUser()); + m_TableCtrl->Init(); } } } @@ -177,13 +198,13 @@ void OUserAdmin::FillUserNames() m_pDELETEUSER->Enable(xDrop.is()); m_pCHANGEPWD->Enable(m_xUsers.is()); - m_TableCtrl.Enable(m_xUsers.is()); + m_TableCtrl->Enable(m_xUsers.is()); } -SfxTabPage* OUserAdmin::Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) +VclPtr<SfxTabPage> OUserAdmin::Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OUserAdmin( pParent, *_rAttrSet ) ); + return VclPtr<SfxTabPage>(new OUserAdmin( pParent, *_rAttrSet ), SAL_NO_ACQUIRE); } IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) @@ -192,16 +213,16 @@ IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) { if(pButton == m_pNEWUSER) { - SfxPasswordDialog aPwdDlg(this); - aPwdDlg.ShowExtras(SfxShowExtras::ALL); - if(aPwdDlg.Execute()) + ScopedVclPtrInstance< SfxPasswordDialog > aPwdDlg(this); + aPwdDlg->ShowExtras(SfxShowExtras::ALL); + if(aPwdDlg->Execute()) { Reference<XDataDescriptorFactory> xUserFactory(m_xUsers,UNO_QUERY); Reference<XPropertySet> xNewUser = xUserFactory->createDataDescriptor(); if(xNewUser.is()) { - xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(OUString(aPwdDlg.GetUser()))); - xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(OUString(aPwdDlg.GetPassword()))); + xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(OUString(aPwdDlg->GetUser()))); + xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(OUString(aPwdDlg->GetPassword()))); Reference<XAppend> xAppend(m_xUsers,UNO_QUERY); if(xAppend.is()) xAppend->appendByDescriptor(xNewUser); @@ -219,11 +240,11 @@ IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) if(xUser.is()) { OUString sNewPassword,sOldPassword; - OPasswordDialog aDlg(this,sName); - if(aDlg.Execute() == RET_OK) + ScopedVclPtrInstance< OPasswordDialog > aDlg(this,sName); + if(aDlg->Execute() == RET_OK) { - sNewPassword = aDlg.GetNewPassword(); - sOldPassword = aDlg.GetOldPassword(); + sNewPassword = aDlg->GetNewPassword(); + sOldPassword = aDlg->GetOldPassword(); if(!sNewPassword.isEmpty()) xUser->changePassword(sOldPassword,sNewPassword); @@ -238,8 +259,8 @@ IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) Reference<XDrop> xDrop(m_xUsers,UNO_QUERY); if(xDrop.is()) { - MessageDialog aQry(this, ModuleRes(STR_QUERY_USERADMIN_DELETE_USER), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - if(aQry.Execute() == RET_YES) + ScopedVclPtrInstance< MessageDialog > aQry(this, ModuleRes(STR_QUERY_USERADMIN_DELETE_USER), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + if(aQry->Execute() == RET_YES) xDrop->dropByName(GetUser()); } } @@ -261,10 +282,10 @@ IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton ) IMPL_LINK( OUserAdmin, ListDblClickHdl, ListBox *, /*pListBox*/ ) { - m_TableCtrl.setUserName(GetUser()); - m_TableCtrl.UpdateTables(); - m_TableCtrl.DeactivateCell(); - m_TableCtrl.ActivateCell(m_TableCtrl.GetCurRow(),m_TableCtrl.GetCurColumnId()); + m_TableCtrl->setUserName(GetUser()); + m_TableCtrl->UpdateTables(); + m_TableCtrl->DeactivateCell(); + m_TableCtrl->ActivateCell(m_TableCtrl->GetCurRow(),m_TableCtrl->GetCurColumnId()); return 0; } @@ -283,7 +304,7 @@ void OUserAdmin::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlLis void OUserAdmin::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) { - m_TableCtrl.setComponentContext(m_xORB); + m_TableCtrl->setComponentContext(m_xORB); try { if ( !m_xConnection.is() && m_pAdminDialog ) @@ -302,7 +323,7 @@ void OUserAdmin::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) } if ( xUsersSup.is() ) { - m_TableCtrl.setTablesSupplier(xTablesSup); + m_TableCtrl->setTablesSupplier(xTablesSup); m_xUsers = xUsersSup->getUsers(); } } diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx index 6f0720d7a43b..eeea260a60ee 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.hxx +++ b/dbaccess/source/ui/dlg/UserAdmin.hxx @@ -41,11 +41,11 @@ namespace dbaui class OUserAdmin : public OGenericAdministrationPage { protected: - ListBox *m_pUSER; - PushButton *m_pNEWUSER; - PushButton *m_pCHANGEPWD; - PushButton *m_pDELETEUSER; - OTableGrantControl m_TableCtrl; // show the grant rights of one user + VclPtr<ListBox> m_pUSER; + VclPtr<PushButton> m_pNEWUSER; + VclPtr<PushButton> m_pCHANGEPWD; + VclPtr<PushButton> m_pDELETEUSER; + VclPtr<OTableGrantControl> m_TableCtrl; // show the grant rights of one user ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers; @@ -62,9 +62,10 @@ protected: OUserAdmin( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); public: - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* _rAttrSet ); virtual ~OUserAdmin(); + virtual void dispose() SAL_OVERRIDE; OUString GetUser(); // subclasses must override this, but it isn't pure virtual diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.cxx b/dbaccess/source/ui/dlg/UserAdminDlg.cxx index 2b17eccec0f9..57f8c8ec2673 100644 --- a/dbaccess/source/ui/dlg/UserAdminDlg.cxx +++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx @@ -73,6 +73,11 @@ namespace dbaui OUserAdminDlg::~OUserAdminDlg() { + disposeOnce(); + } + + void OUserAdminDlg::dispose() + { if ( m_bOwnConnection ) { try @@ -86,8 +91,9 @@ namespace dbaui SetInputSet(NULL); DELETEZ(pExampleSet); - + SfxTabDialog::dispose(); } + short OUserAdminDlg::Execute() { try diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx index ddff2e67b7cf..a4ff866067d7 100644 --- a/dbaccess/source/ui/dlg/admincontrols.cxx +++ b/dbaccess/source/ui/dlg/admincontrols.cxx @@ -170,6 +170,24 @@ namespace dbaui MySQLNativeSettings::~MySQLNativeSettings() { + disposeOnce(); + } + + void MySQLNativeSettings::dispose() + { + m_pDatabaseNameLabel.clear(); + m_pDatabaseName.clear(); + m_pHostPortRadio.clear(); + m_pSocketRadio.clear(); + m_pNamedPipeRadio.clear(); + m_pHostNameLabel.clear(); + m_pHostName.clear(); + m_pPortLabel.clear(); + m_pPort.clear(); + m_pDefaultPort.clear(); + m_pSocket.clear(); + m_pNamedPipe.clear(); + TabPage::dispose(); } void MySQLNativeSettings::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ) diff --git a/dbaccess/source/ui/dlg/admincontrols.hxx b/dbaccess/source/ui/dlg/admincontrols.hxx index e6e214dca1b9..544ef8b89a24 100644 --- a/dbaccess/source/ui/dlg/admincontrols.hxx +++ b/dbaccess/source/ui/dlg/admincontrols.hxx @@ -35,18 +35,18 @@ namespace dbaui class MySQLNativeSettings : public TabPage { private: - FixedText *m_pDatabaseNameLabel; - Edit *m_pDatabaseName; - RadioButton *m_pHostPortRadio; - RadioButton *m_pSocketRadio; - RadioButton *m_pNamedPipeRadio; - FixedText *m_pHostNameLabel; - Edit *m_pHostName; - FixedText *m_pPortLabel; - NumericField *m_pPort; - FixedText *m_pDefaultPort; - Edit *m_pSocket; - Edit *m_pNamedPipe; + VclPtr<FixedText> m_pDatabaseNameLabel; + VclPtr<Edit> m_pDatabaseName; + VclPtr<RadioButton> m_pHostPortRadio; + VclPtr<RadioButton> m_pSocketRadio; + VclPtr<RadioButton> m_pNamedPipeRadio; + VclPtr<FixedText> m_pHostNameLabel; + VclPtr<Edit> m_pHostName; + VclPtr<FixedText> m_pPortLabel; + VclPtr<NumericField> m_pPort; + VclPtr<FixedText> m_pDefaultPort; + VclPtr<Edit> m_pSocket; + VclPtr<Edit> m_pNamedPipe; ::svt::ControlDependencyManager m_aControlDependencies; @@ -54,7 +54,7 @@ namespace dbaui public: MySQLNativeSettings( vcl::Window& _rParent, const Link& _rControlModificationLink ); virtual ~MySQLNativeSettings(); - + virtual void dispose() SAL_OVERRIDE; void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList ); void fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ); diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx index ffb2c8d02df4..5848b5b2036c 100644 --- a/dbaccess/source/ui/dlg/adminpages.cxx +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -117,19 +117,19 @@ namespace dbaui // show an error message OUString sError( ModuleRes( STR_COULD_NOT_LOAD_ODBC_LIB ) ); sError = sError.replaceFirst("#lib#", aEnumeration.getLibraryName()); - MessageDialog aDialog(this, sError); - aDialog.Execute(); + ScopedVclPtrInstance< MessageDialog > aDialog(this, sError); + aDialog->Execute(); return false; } else { aEnumeration.getDatasourceNames(aOdbcDatasources); // execute the select dialog - ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources); + ScopedVclPtrInstance< ODatasourceSelectDialog > aSelector(GetParent(), aOdbcDatasources); if (!_sCurr.isEmpty()) - aSelector.Select(_sCurr); - if ( RET_OK == aSelector.Execute() ) - _sReturn = aSelector.GetSelected(); + aSelector->Select(_sCurr); + if ( RET_OK == aSelector->Execute() ) + _sReturn = aSelector->GetSelected(); } return true; } @@ -242,8 +242,8 @@ namespace dbaui eImage = OSQLMessageBox::Error; aMessage = ModuleRes(STR_CONNECTION_NO_SUCCESS); } - OSQLMessageBox aMsg( this, sTitle, aMessage, WB_OK, eImage ); - aMsg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, sTitle, aMessage, WB_OK, eImage ); + aMsg->Execute(); } if ( !bSuccess ) m_pAdminDialog->clearPassword(); diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx index b866cd721f38..3572cd860055 100644 --- a/dbaccess/source/ui/dlg/adminpages.hxx +++ b/dbaccess/source/ui/dlg/adminpages.hxx @@ -231,7 +231,7 @@ namespace dbaui is modified. The implementation just calls callModifiedHdl. */ DECL_LINK(OnControlModified, void*); - DECL_LINK(OnTestConnectionClickHdl,PushButton*); + DECL_LINK(OnTestConnectionClickHdl, PushButton*); /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method> virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); } diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx index 5e4cb63aa6f0..1b42d45ffcd1 100644 --- a/dbaccess/source/ui/dlg/adtabdlg.cxx +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -362,7 +362,19 @@ OAddTableDlg::OAddTableDlg( vcl::Window* pParent, IAddTableDialogContext& _rCont OAddTableDlg::~OAddTableDlg() { + disposeOnce(); +} + +void OAddTableDlg::dispose() +{ m_rContext.onWindowClosing( this ); + m_pCaseTables.clear(); + m_pCaseQueries.clear(); + m_pTableList.clear(); + m_pQueryList.clear(); + m_pAddButton.clear(); + m_pCloseButton.clear(); + ModelessDialog::dispose(); } void OAddTableDlg::impl_switchTo( ObjectList _eList ) diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx index 65288cd41c81..2fe318634f13 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.cxx +++ b/dbaccess/source/ui/dlg/advancedsettings.cxx @@ -48,7 +48,7 @@ namespace dbaui // SpecialSettingsPage struct BooleanSettingDesc { - CheckBox** ppControl; // the dialog's control which displays this setting + VclPtr<CheckBox>* ppControl; // the dialog's control which displays this setting OString sControlId; // the widget name of the control in the .ui sal_uInt16 nItemId; // the ID of the item (in an SfxItemSet) which corresponds to this setting bool bInvertedDisplay; // true if and only if the checkbox is checked when the item is sal_False, and vice versa @@ -95,7 +95,7 @@ namespace dbaui sal_uInt16 nItemId = setting->nItemId; if ( rFeatures.has( nItemId ) ) { - get((*setting->ppControl), setting->sControlId); + get(*setting->ppControl, setting->sControlId); (*setting->ppControl)->SetClickHdl( getControlModifiedLink() ); (*setting->ppControl)->Show(); @@ -134,7 +134,33 @@ namespace dbaui SpecialSettingsPage::~SpecialSettingsPage() { + disposeOnce(); + } + + void SpecialSettingsPage::dispose() + { m_aControlDependencies.clear(); + m_pIsSQL92Check.clear(); + m_pAppendTableAlias.clear(); + m_pAsBeforeCorrelationName.clear(); + m_pEnableOuterJoin.clear(); + m_pIgnoreDriverPrivileges.clear(); + m_pParameterSubstitution.clear(); + m_pSuppressVersionColumn.clear(); + m_pCatalog.clear(); + m_pSchema.clear(); + m_pIndexAppendix.clear(); + m_pDosLineEnds.clear(); + m_pCheckRequiredFields.clear(); + m_pIgnoreCurrency.clear(); + m_pEscapeDateTime.clear(); + m_pPrimaryKeySupport.clear(); + m_pRespectDriverResultSetType.clear(); + m_pBooleanComparisonModeLabel.clear(); + m_pBooleanComparisonMode.clear(); + m_pMaxRowScanLabel.clear(); + m_pMaxRowScan.clear(); + OGenericAdministrationPage::dispose(); } void SpecialSettingsPage::impl_initBooleanSettings() @@ -149,22 +175,21 @@ namespace dbaui { &m_pEnableOuterJoin, "useoj", DSID_ENABLEOUTERJOIN, false }, { &m_pIgnoreDriverPrivileges, "ignoreprivs", DSID_IGNOREDRIVER_PRIV, false }, { &m_pParameterSubstitution, "replaceparams", DSID_PARAMETERNAMESUBST, false }, - { &m_pSuppressVersionColumn, "displayver", DSID_SUPPRESSVERSIONCL, true }, + { &m_pSuppressVersionColumn, "displayver", DSID_SUPPRESSVERSIONCL, true }, { &m_pCatalog, "usecatalogname", DSID_CATALOG, false }, { &m_pSchema, "useschemaname", DSID_SCHEMA, false }, { &m_pIndexAppendix, "createindex", DSID_INDEXAPPENDIX, false }, { &m_pDosLineEnds, "eol", DSID_DOSLINEENDS, false }, - { &m_pCheckRequiredFields, "inputchecks", DSID_CHECK_REQUIRED_FIELDS, false }, - { &m_pIgnoreCurrency, "ignorecurrency", DSID_IGNORECURRENCY, false }, + { &m_pCheckRequiredFields, "ignorecurrency", DSID_CHECK_REQUIRED_FIELDS, false }, + { &m_pIgnoreCurrency, "inputchecks", DSID_IGNORECURRENCY, false }, { &m_pEscapeDateTime, "useodbcliterals", DSID_ESCAPE_DATETIME, false }, { &m_pPrimaryKeySupport, "primarykeys", DSID_PRIMARY_KEY_SUPPORT, false }, - { &m_pRespectDriverResultSetType, "resulttype", DSID_RESPECTRESULTSETTYPE, false }, - { NULL, "", 0, false } + { &m_pRespectDriverResultSetType, "resulttype", DSID_RESPECTRESULTSETTYPE, false } }; - for ( const BooleanSettingDesc* pCopy = aSettings; pCopy->nItemId != 0; ++pCopy ) + for ( const BooleanSettingDesc& pCopy : aSettings ) { - m_aBooleanSettings.push_back( *pCopy ); + m_aBooleanSettings.push_back( pCopy ); } } @@ -187,7 +212,7 @@ namespace dbaui ++setting ) { - if ( *setting->ppControl ) + if ( (*setting->ppControl) ) { _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *setting->ppControl ) ); } @@ -217,7 +242,7 @@ namespace dbaui ++setting ) { - if ( !*setting->ppControl ) + if ( !(*setting->ppControl) ) continue; ::boost::optional< bool > aValue(false); @@ -317,7 +342,19 @@ namespace dbaui GeneratedValuesPage::~GeneratedValuesPage() { + disposeOnce(); + } + + void GeneratedValuesPage::dispose() + { m_aControlDependencies.clear(); + m_pAutoFrame.clear(); + m_pAutoRetrievingEnabled.clear(); + m_pAutoIncrementLabel.clear(); + m_pAutoIncrement.clear(); + m_pAutoRetrievingLabel.clear(); + m_pAutoRetrieving.clear(); + OGenericAdministrationPage::dispose(); } void GeneratedValuesPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) @@ -406,8 +443,14 @@ namespace dbaui AdvancedSettingsDialog::~AdvancedSettingsDialog() { + disposeOnce(); + } + + void AdvancedSettingsDialog::dispose() + { SetInputSet(NULL); DELETEZ(pExampleSet); + SfxTabDialog::dispose(); } bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const OUString& _sURL ) diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx index 005f0cb909c5..7c08e920a687 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.hxx +++ b/dbaccess/source/ui/dlg/advancedsettings.hxx @@ -40,28 +40,28 @@ namespace dbaui class SpecialSettingsPage : public OGenericAdministrationPage { protected: - CheckBox* m_pIsSQL92Check; - CheckBox* m_pAppendTableAlias; - CheckBox* m_pAsBeforeCorrelationName; - CheckBox* m_pEnableOuterJoin; - CheckBox* m_pIgnoreDriverPrivileges; - CheckBox* m_pParameterSubstitution; - CheckBox* m_pSuppressVersionColumn; - CheckBox* m_pCatalog; - CheckBox* m_pSchema; - CheckBox* m_pIndexAppendix; - CheckBox* m_pDosLineEnds; - CheckBox* m_pCheckRequiredFields; - CheckBox* m_pIgnoreCurrency; - CheckBox* m_pEscapeDateTime; - CheckBox* m_pPrimaryKeySupport; - CheckBox* m_pRespectDriverResultSetType; - - FixedText* m_pBooleanComparisonModeLabel; - ListBox* m_pBooleanComparisonMode; - - FixedText* m_pMaxRowScanLabel; - NumericField* m_pMaxRowScan; + VclPtr<CheckBox> m_pIsSQL92Check; + VclPtr<CheckBox> m_pAppendTableAlias; + VclPtr<CheckBox> m_pAsBeforeCorrelationName; + VclPtr<CheckBox> m_pEnableOuterJoin; + VclPtr<CheckBox> m_pIgnoreDriverPrivileges; + VclPtr<CheckBox> m_pParameterSubstitution; + VclPtr<CheckBox> m_pSuppressVersionColumn; + VclPtr<CheckBox> m_pCatalog; + VclPtr<CheckBox> m_pSchema; + VclPtr<CheckBox> m_pIndexAppendix; + VclPtr<CheckBox> m_pDosLineEnds; + VclPtr<CheckBox> m_pCheckRequiredFields; + VclPtr<CheckBox> m_pIgnoreCurrency; + VclPtr<CheckBox> m_pEscapeDateTime; + VclPtr<CheckBox> m_pPrimaryKeySupport; + VclPtr<CheckBox> m_pRespectDriverResultSetType; + + VclPtr<FixedText> m_pBooleanComparisonModeLabel; + VclPtr<ListBox> m_pBooleanComparisonMode; + + VclPtr<FixedText> m_pMaxRowScanLabel; + VclPtr<NumericField> m_pMaxRowScan; ::svt::ControlDependencyManager m_aControlDependencies; @@ -78,6 +78,7 @@ namespace dbaui protected: virtual ~SpecialSettingsPage(); + virtual void dispose() SAL_OVERRIDE; // OGenericAdministrationPage overridables virtual void implInitControls (const SfxItemSet& _rSet, bool _bSaveValue ) SAL_OVERRIDE; @@ -97,12 +98,12 @@ namespace dbaui { protected: - VclFrame* m_pAutoFrame; - CheckBox* m_pAutoRetrievingEnabled; - FixedText* m_pAutoIncrementLabel; - Edit* m_pAutoIncrement; - FixedText* m_pAutoRetrievingLabel; - Edit* m_pAutoRetrieving; + VclPtr<VclFrame> m_pAutoFrame; + VclPtr<CheckBox> m_pAutoRetrievingEnabled; + VclPtr<FixedText> m_pAutoIncrementLabel; + VclPtr<Edit> m_pAutoIncrement; + VclPtr<FixedText> m_pAutoRetrievingLabel; + VclPtr<Edit> m_pAutoRetrieving; ::svt::ControlDependencyManager m_aControlDependencies; @@ -115,6 +116,7 @@ namespace dbaui // nControlFlags is a combination of the CBTP_xxx-constants virtual ~GeneratedValuesPage(); + virtual void dispose() SAL_OVERRIDE; // subclasses must override this, but it isn't pure virtual virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index 7eeedec9500a..6f040bec4838 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -66,9 +66,14 @@ ODbAdminDialog::ODbAdminDialog(vcl::Window* _pParent ODbAdminDialog::~ODbAdminDialog() { + disposeOnce(); +} + +void ODbAdminDialog::dispose() +{ SetInputSet(NULL); DELETEZ(pExampleSet); - + SfxTabDialog::dispose(); } short ODbAdminDialog::Ok() diff --git a/dbaccess/source/ui/dlg/dbfindex.cxx b/dbaccess/source/ui/dlg/dbfindex.cxx index 1493734256b1..f767f4ea31e9 100644 --- a/dbaccess/source/ui/dlg/dbfindex.cxx +++ b/dbaccess/source/ui/dlg/dbfindex.cxx @@ -76,6 +76,25 @@ ODbaseIndexDialog::ODbaseIndexDialog(vcl::Window * pParent, const OUString& aDat SetCtrls(); } +ODbaseIndexDialog::~ODbaseIndexDialog() +{ + disposeOnce(); +} + +void ODbaseIndexDialog::dispose() +{ + m_pPB_OK.clear(); + m_pCB_Tables.clear(); + m_pIndexes.clear(); + m_pLB_TableIndexes.clear(); + m_pLB_FreeIndexes.clear(); + m_pAdd.clear(); + m_pRemove.clear(); + m_pAddAll.clear(); + m_pRemoveAll.clear(); + ModalDialog::dispose(); +} + bool ODbaseIndexDialog::GetTable(const OUString& _rName, TableInfoList::iterator& _rPosition) { for ( _rPosition = m_aTableInfoList.begin(); diff --git a/dbaccess/source/ui/dlg/dbfindex.hxx b/dbaccess/source/ui/dlg/dbfindex.hxx index 58aae3b04091..46aac76028af 100644 --- a/dbaccess/source/ui/dlg/dbfindex.hxx +++ b/dbaccess/source/ui/dlg/dbfindex.hxx @@ -73,16 +73,16 @@ typedef ::std::list< OTableInfo > TableInfoList; class ODbaseIndexDialog : public ModalDialog { protected: - OKButton* m_pPB_OK; - ComboBox* m_pCB_Tables; - VclContainer* m_pIndexes; - ListBox* m_pLB_TableIndexes; - ListBox* m_pLB_FreeIndexes; + VclPtr<OKButton> m_pPB_OK; + VclPtr<ComboBox> m_pCB_Tables; + VclPtr<VclContainer> m_pIndexes; + VclPtr<ListBox> m_pLB_TableIndexes; + VclPtr<ListBox> m_pLB_FreeIndexes; - PushButton* m_pAdd; - PushButton* m_pRemove; - PushButton* m_pAddAll; - PushButton* m_pRemoveAll; + VclPtr<PushButton> m_pAdd; + VclPtr<PushButton> m_pRemove; + VclPtr<PushButton> m_pAddAll; + VclPtr<PushButton> m_pRemoveAll; DECL_LINK( TableSelectHdl, ComboBox* ); DECL_LINK( AddClickHdl, PushButton* ); @@ -113,6 +113,8 @@ protected: public: ODbaseIndexDialog( vcl::Window * pParent, const OUString& aDataSrcName ); + virtual ~ODbaseIndexDialog(); + virtual void dispose() SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index f39d0dba2454..566c30af0fa0 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -102,7 +102,13 @@ ODbTypeWizDialog::ODbTypeWizDialog(vcl::Window* _pParent ODbTypeWizDialog::~ODbTypeWizDialog() { + disposeOnce(); +} + +void ODbTypeWizDialog::dispose() +{ delete m_pOutSet; + svt::OWizardMachine::dispose(); } IMPL_LINK(ODbTypeWizDialog, OnTypeSelected, OGeneralPage*, _pTabPage) @@ -227,16 +233,16 @@ void ODbTypeWizDialog::clearPassword() m_pImpl->clearPassword(); } -TabPage* ODbTypeWizDialog::createPage(WizardState _nState) +VclPtr<TabPage> ODbTypeWizDialog::createPage(WizardState _nState) { sal_uInt16 nStringId = STR_PAGETITLE_ADVANCED; - TabPage* pPage = NULL; + VclPtr<TabPage> pPage; switch(_nState) { case START_PAGE: // start state { - pPage = new OGeneralPageDialog(this,*m_pOutSet); - OGeneralPage* pGeneralPage = static_cast< OGeneralPage* >( pPage ); + pPage = VclPtr<OGeneralPageDialog>::Create(this,*m_pOutSet); + OGeneralPage* pGeneralPage = static_cast< OGeneralPage* >( pPage.get() ); pGeneralPage->SetTypeSelectHandler( LINK( this, ODbTypeWizDialog, OnTypeSelected)); nStringId = STR_PAGETITLE_GENERAL; } @@ -284,8 +290,8 @@ TabPage* ODbTypeWizDialog::createPage(WizardState _nState) // register ourself as modified listener if ( pPage ) { - static_cast<OGenericAdministrationPage*>(pPage)->SetServiceFactory( m_pImpl->getORB() ); - static_cast<OGenericAdministrationPage*>(pPage)->SetAdminDialog(this,this); + static_cast<OGenericAdministrationPage*>(pPage.get())->SetServiceFactory( m_pImpl->getORB() ); + static_cast<OGenericAdministrationPage*>(pPage.get())->SetAdminDialog(this,this); pPage->SetText(ModuleRes(nStringId)); defaultButton( _nState == START_PAGE ? WZB_NEXT : WZB_FINISH ); enableButtons( WZB_FINISH, _nState != START_PAGE); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 6a9f3c814928..b063828432e3 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -264,7 +264,16 @@ OUString ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const ODbTypeWizDialogSetup::~ODbTypeWizDialogSetup() { + disposeOnce(); +} + +void ODbTypeWizDialogSetup::dispose() +{ delete m_pOutSet; + m_pGeneralPage.clear(); + m_pMySQLIntroPage.clear(); + m_pFinalPage.clear(); + svt::RoadmapWizard::dispose(); } IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/) @@ -420,7 +429,7 @@ Reference< XDriver > ODbTypeWizDialogSetup::getDriver() ::dbaccess::DATASOURCE_TYPE LocDatabaseType = _DatabaseType; if ((LocDatabaseType == ::dbaccess::DST_MYSQL_JDBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_ODBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_NATIVE)) { - if (m_pMySQLIntroPage != NULL) + if (m_pMySQLIntroPage != nullptr) { switch( m_pMySQLIntroPage->getMySQLMode() ) { @@ -439,7 +448,7 @@ Reference< XDriver > ODbTypeWizDialogSetup::getDriver() OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const { OUString sRet = dbaui::ODbDataSourceAdministrationHelper::getDatasourceType(_rSet); - if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() ) + if (m_pMySQLIntroPage != nullptr && m_pMySQLIntroPage->IsVisible() ) { switch( m_pMySQLIntroPage->getMySQLMode() ) { @@ -462,16 +471,16 @@ void ODbTypeWizDialogSetup::clearPassword() m_pImpl->clearPassword(); } -TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) +VclPtr<TabPage> ODbTypeWizDialogSetup::createPage(WizardState _nState) { - SfxTabPage* pFirstPage; - OGenericAdministrationPage* pPage = NULL; + VclPtr<SfxTabPage> pFirstPage; + VclPtr<OGenericAdministrationPage> pPage; switch(_nState) { case PAGE_DBSETUPWIZARD_INTRO: - pFirstPage = new OGeneralPageWizard(this,*m_pOutSet); - pPage = static_cast<OGenericAdministrationPage*> (pFirstPage); - m_pGeneralPage = static_cast<OGeneralPageWizard*>(pFirstPage); + pFirstPage = VclPtr<OGeneralPageWizard>::Create(this,*m_pOutSet); + pPage = static_cast<OGenericAdministrationPage*> (pFirstPage.get()); + m_pGeneralPage = static_cast<OGeneralPageWizard*>(pFirstPage.get()); m_pGeneralPage->SetTypeSelectHandler(LINK(this, ODbTypeWizDialogSetup, OnTypeSelected)); m_pGeneralPage->SetCreationModeHandler(LINK( this, ODbTypeWizDialogSetup, OnChangeCreationMode ) ); m_pGeneralPage->SetDocumentSelectionHandler(LINK( this, ODbTypeWizDialogSetup, OnRecentDocumentSelected ) ); @@ -543,7 +552,7 @@ TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) case PAGE_DBSETUPWIZARD_FINAL: pPage = OFinalDBPageSetup::CreateFinalDBTabPageSetup(this,*m_pOutSet); - m_pFinalPage = static_cast<OFinalDBPageSetup*> (pPage); + m_pFinalPage = static_cast<OFinalDBPageSetup*> (pPage.get()); break; } @@ -734,7 +743,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPageWizard::eOpenExisting ) return true; - if ( m_pFinalPage != NULL ) + if ( m_pFinalPage != nullptr ) return m_pFinalPage->IsDatabaseDocumentToBeOpened(); return true; @@ -745,7 +754,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPageWizard::eOpenExisting ) return false; - if ( m_pFinalPage != NULL ) + if ( m_pFinalPage != nullptr ) return m_pFinalPage->IsTableWizardToBeStarted(); return false; diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx index 5018b582288d..b090ddc8df06 100644 --- a/dbaccess/source/ui/dlg/detailpages.cxx +++ b/dbaccess/source/ui/dlg/detailpages.cxx @@ -71,7 +71,6 @@ namespace dbaui ,m_pAutoRetrievingLabel(NULL) ,m_pAutoRetrieving(NULL) ,m_nControlFlags(nControlFlags) - ,m_bDelete(false) { if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS) @@ -97,22 +96,21 @@ namespace dbaui OCommonBehaviourTabPage::~OCommonBehaviourTabPage() { - if(m_bDelete) - { - DELETEZ(m_pOptionsLabel); - DELETEZ(m_pOptions); - - DELETEZ(m_pCharsetLabel); - DELETEZ(m_pCharset); - - DELETEZ(m_pAutoIncrementLabel); - DELETEZ(m_pAutoIncrement); - - DELETEZ(m_pAutoRetrievingEnabled); - DELETEZ(m_pAutoRetrievingLabel); - DELETEZ(m_pAutoRetrieving); - } + disposeOnce(); + } + void OCommonBehaviourTabPage::dispose() + { + m_pOptionsLabel.disposeAndClear(); + m_pOptions.disposeAndClear(); + m_pCharsetLabel.disposeAndClear(); + m_pCharset.disposeAndClear(); + m_pAutoIncrementLabel.disposeAndClear(); + m_pAutoIncrement.disposeAndClear(); + m_pAutoRetrievingEnabled.disposeAndClear(); + m_pAutoRetrievingLabel.disposeAndClear(); + m_pAutoRetrieving.disposeAndClear(); + OGenericAdministrationPage::dispose(); } void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) @@ -196,12 +194,20 @@ namespace dbaui ODbaseDetailsPage::~ODbaseDetailsPage() { + disposeOnce(); + } + void ODbaseDetailsPage::dispose() + { + m_pShowDeleted.clear(); + m_pFT_Message.clear(); + m_pIndexes.clear(); + OCommonBehaviourTabPage::dispose(); } - SfxTabPage* ODriversSettings::CreateDbase( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateDbase( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new ODbaseDetailsPage( pParent, *_rAttrSet ) ); + return VclPtr<ODbaseDetailsPage>::Create( pParent, *_rAttrSet ); } void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) @@ -241,8 +247,8 @@ namespace dbaui { if (m_pIndexes == pButton) { - ODbaseIndexDialog aIndexDialog(this, m_sDsn); - aIndexDialog.Execute(); + ScopedVclPtrInstance< ODbaseIndexDialog > aIndexDialog(this, m_sDsn); + aIndexDialog->Execute(); } else { @@ -261,13 +267,9 @@ namespace dbaui } - OAdoDetailsPage::~OAdoDetailsPage() - { - - } - SfxTabPage* ODriversSettings::CreateAdo( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateAdo( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OAdoDetailsPage( pParent, *_rAttrSet ) ); + return VclPtr<OAdoDetailsPage>::Create( pParent, *_rAttrSet ); } // OOdbcDetailsPage @@ -278,9 +280,20 @@ namespace dbaui m_pUseCatalog->SetToggleHdl(getControlModifiedLink()); } - SfxTabPage* ODriversSettings::CreateODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + OOdbcDetailsPage::~OOdbcDetailsPage() + { + disposeOnce(); + } + + void OOdbcDetailsPage::dispose() { - return ( new OOdbcDetailsPage( pParent, *_rAttrSet ) ); + m_pUseCatalog.clear(); + OCommonBehaviourTabPage::dispose(); + } + + VclPtr<SfxTabPage> ODriversSettings::CreateODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + { + return VclPtr<OOdbcDetailsPage>::Create( pParent, *_rAttrSet ); } bool OOdbcDetailsPage::FillItemSet( SfxItemSet* _rSet ) @@ -316,9 +329,24 @@ namespace dbaui m_pUseCatalog->SetToggleHdl(getControlModifiedLink()); } - SfxTabPage* ODriversSettings::CreateUser( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + OUserDriverDetailsPage::~OUserDriverDetailsPage() + { + disposeOnce(); + } + + void OUserDriverDetailsPage::dispose() + { + m_pFTHostname.clear(); + m_pEDHostname.clear(); + m_pPortNumber.clear(); + m_pNFPortNumber.clear(); + m_pUseCatalog.clear(); + OCommonBehaviourTabPage::dispose(); + } + + VclPtr<SfxTabPage> ODriversSettings::CreateUser( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OUserDriverDetailsPage( pParent, *_rAttrSet ) ); + return VclPtr<OUserDriverDetailsPage>::Create( pParent, *_rAttrSet ); } bool OUserDriverDetailsPage::FillItemSet( SfxItemSet* _rSet ) @@ -373,9 +401,9 @@ namespace dbaui { } - SfxTabPage* ODriversSettings::CreateMySQLODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateMySQLODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OMySQLODBCDetailsPage( pParent, *_rAttrSet ) ); + return VclPtr<OMySQLODBCDetailsPage>::Create( pParent, *_rAttrSet ); } // OMySQLJDBCDetailsPage @@ -422,6 +450,23 @@ namespace dbaui m_pEDSocket->SetModifyHdl(getControlModifiedLink()); } + OGeneralSpecialJDBCDetailsPage::~OGeneralSpecialJDBCDetailsPage() + { + disposeOnce(); + } + + void OGeneralSpecialJDBCDetailsPage::dispose() + { + m_pEDHostname.clear(); + m_pNFPortNumber.clear(); + m_pFTSocket.clear(); + m_pEDSocket.clear(); + m_pFTDriverClass.clear(); + m_pEDDriverClass.clear(); + m_pTestJavaDriver.clear(); + OCommonBehaviourTabPage::dispose(); + } + bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet* _rSet ) { bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet); @@ -494,8 +539,8 @@ namespace dbaui #endif const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS; const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error; - OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); - aMsg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt ); + aMsg->Execute(); return 0L; } IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit) @@ -511,7 +556,7 @@ namespace dbaui // MySQLNativePage MySQLNativePage::MySQLNativePage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ) :OCommonBehaviourTabPage(pParent, "MysqlNativePage", "dbaccess/ui/mysqlnativepage.ui", _rCoreAttrs, CBTP_USE_CHARSET ) - ,m_aMySQLSettings ( *get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink() ) + ,m_aMySQLSettings ( VclPtr<MySQLNativeSettings>::Create(*get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink()) ) { get(m_pSeparator1, "connectionheader"); get(m_pSeparator2, "userheader"); @@ -521,13 +566,29 @@ namespace dbaui m_pUserName->SetModifyHdl(getControlModifiedLink()); - m_aMySQLSettings.Show(); + m_aMySQLSettings->Show(); + } + + MySQLNativePage::~MySQLNativePage() + { + disposeOnce(); + } + + void MySQLNativePage::dispose() + { + m_aMySQLSettings.disposeAndClear(); + m_pSeparator1.clear(); + m_pSeparator2.clear(); + m_pUserNameLabel.clear(); + m_pUserName.clear(); + m_pPasswordRequired.clear(); + OCommonBehaviourTabPage::dispose(); } void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) { OCommonBehaviourTabPage::fillControls( _rControlList ); - m_aMySQLSettings.fillControls( _rControlList ); + m_aMySQLSettings->fillControls( _rControlList ); _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pUserName)); _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pPasswordRequired)); @@ -535,7 +596,7 @@ namespace dbaui void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) { OCommonBehaviourTabPage::fillWindows( _rControlList ); - m_aMySQLSettings.fillWindows( _rControlList); + m_aMySQLSettings->fillWindows( _rControlList); _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator1)); _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator2)); @@ -546,7 +607,7 @@ namespace dbaui { bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet ); - bChangedSomething |= m_aMySQLSettings.FillItemSet( _rSet ); + bChangedSomething |= m_aMySQLSettings->FillItemSet( _rSet ); if ( m_pUserName->IsValueChangedFromSaved() ) { @@ -564,7 +625,7 @@ namespace dbaui bool bValid, bReadonly; getFlags(_rSet, bValid, bReadonly); - m_aMySQLSettings.implInitControls( _rSet ); + m_aMySQLSettings->implInitControls( _rSet ); SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, true); SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, true); @@ -579,18 +640,18 @@ namespace dbaui OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue); } - SfxTabPage* ODriversSettings::CreateMySQLJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateMySQLJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OGeneralSpecialJDBCDetailsPage( pParent, *_rAttrSet,DSID_MYSQL_PORTNUMBER ) ); + return VclPtr<OGeneralSpecialJDBCDetailsPage>::Create( pParent, *_rAttrSet,DSID_MYSQL_PORTNUMBER ); } - SfxTabPage* ODriversSettings::CreateMySQLNATIVE( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateMySQLNATIVE( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new MySQLNativePage( pParent, *_rAttrSet ) ); + return VclPtr<MySQLNativePage>::Create( pParent, *_rAttrSet ); } - SfxTabPage* ODriversSettings::CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OGeneralSpecialJDBCDetailsPage( pParent, *_rAttrSet,DSID_ORACLE_PORTNUMBER, false) ); + return VclPtr<OGeneralSpecialJDBCDetailsPage>::Create( pParent, *_rAttrSet,DSID_ORACLE_PORTNUMBER, false); } // OLDAPDetailsPage @@ -614,9 +675,23 @@ namespace dbaui m_pCBUseSSL->SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick)); } - SfxTabPage* ODriversSettings::CreateLDAP( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + OLDAPDetailsPage::~OLDAPDetailsPage() + { + disposeOnce(); + } + + void OLDAPDetailsPage::dispose() { - return ( new OLDAPDetailsPage( pParent, *_rAttrSet ) ); + m_pETBaseDN.clear(); + m_pCBUseSSL.clear(); + m_pNFPortNumber.clear(); + m_pNFRowCount.clear(); + OCommonBehaviourTabPage::dispose(); + } + + VclPtr<SfxTabPage> ODriversSettings::CreateLDAP( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + { + return VclPtr<OLDAPDetailsPage>::Create( pParent, *_rAttrSet ); } bool OLDAPDetailsPage::FillItemSet( SfxItemSet* _rSet ) @@ -675,18 +750,23 @@ namespace dbaui :OCommonBehaviourTabPage(pParent, "EmptyPage", "dbaccess/ui/emptypage.ui", _rCoreAttrs, 0) { - m_pTextConnectionHelper = new OTextConnectionHelper( get<VclVBox>("EmptyPage"), TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET ); + m_pTextConnectionHelper = VclPtr<OTextConnectionHelper>::Create( get<VclVBox>("EmptyPage"), TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET ); } OTextDetailsPage::~OTextDetailsPage() { - DELETEZ(m_pTextConnectionHelper); + disposeOnce(); + } + void OTextDetailsPage::dispose() + { + m_pTextConnectionHelper.disposeAndClear(); + OCommonBehaviourTabPage::dispose(); } - SfxTabPage* ODriversSettings::CreateText( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateText( vcl::Window* pParent, const SfxItemSet* _rAttrSet ) { - return ( new OTextDetailsPage( pParent, *_rAttrSet ) ); + return VclPtr<OTextDetailsPage>::Create( pParent, *_rAttrSet ); } void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) { @@ -722,16 +802,16 @@ namespace dbaui return m_pTextConnectionHelper->prepareLeave(); } - SfxTabPage* ODriversSettings::CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ) { - return new GeneratedValuesPage( _pParent, *_rAttrSet ); + return VclPtr<GeneratedValuesPage>::Create( _pParent, *_rAttrSet ); } - SfxTabPage* ODriversSettings::CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ) + VclPtr<SfxTabPage> ODriversSettings::CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet ) { OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( *_rAttrSet ); DataSourceMetaData aMetaData( eType ); - return new SpecialSettingsPage( _pParent, *_rAttrSet, aMetaData ); + return VclPtr<SpecialSettingsPage>::Create( _pParent, *_rAttrSet, aMetaData ); } } // namespace dbaui diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx index fd4119bdbbfa..407a986c2c1c 100644 --- a/dbaccess/source/ui/dlg/detailpages.hxx +++ b/dbaccess/source/ui/dlg/detailpages.hxx @@ -50,22 +50,20 @@ namespace dbaui { protected: - FixedText* m_pOptionsLabel; - Edit* m_pOptions; + VclPtr<FixedText> m_pOptionsLabel; + VclPtr<Edit> m_pOptions; - FixedText* m_pCharsetLabel; - CharSetListBox* m_pCharset; + VclPtr<FixedText> m_pCharsetLabel; + VclPtr<CharSetListBox> m_pCharset; - CheckBox* m_pAutoRetrievingEnabled; - FixedText* m_pAutoIncrementLabel; - Edit* m_pAutoIncrement; - FixedText* m_pAutoRetrievingLabel; - Edit* m_pAutoRetrieving; + VclPtr<CheckBox> m_pAutoRetrievingEnabled; + VclPtr<FixedText> m_pAutoIncrementLabel; + VclPtr<Edit> m_pAutoIncrement; + VclPtr<FixedText> m_pAutoRetrievingLabel; + VclPtr<Edit> m_pAutoRetrieving; sal_uInt32 m_nControlFlags; - bool m_bDelete; - public: virtual bool FillItemSet (SfxItemSet* _rCoreAttrs) SAL_OVERRIDE; @@ -74,6 +72,7 @@ namespace dbaui protected: virtual ~OCommonBehaviourTabPage(); + virtual void dispose() SAL_OVERRIDE; // subclasses must override this, but it isn't pure virtual virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; @@ -92,18 +91,16 @@ namespace dbaui virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; ODbaseDetailsPage(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs); + virtual ~ODbaseDetailsPage(); + virtual void dispose() SAL_OVERRIDE; private: - CheckBox* m_pShowDeleted; - FixedText* m_pFT_Message; - PushButton* m_pIndexes; + VclPtr<CheckBox> m_pShowDeleted; + VclPtr<FixedText> m_pFT_Message; + VclPtr<PushButton> m_pIndexes; OUString m_sDsn; protected: - - virtual ~ODbaseDetailsPage(); - - protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; private: @@ -113,10 +110,7 @@ namespace dbaui // OAdoDetailsPage class OAdoDetailsPage : public OCommonBehaviourTabPage { - protected: - virtual ~OAdoDetailsPage(); public: - OAdoDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); }; @@ -127,10 +121,12 @@ namespace dbaui virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; OOdbcDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~OOdbcDetailsPage(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; private: - CheckBox* m_pUseCatalog; + VclPtr<CheckBox> m_pUseCatalog; }; // OUserDriverDetailsPage @@ -140,16 +136,18 @@ namespace dbaui virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; OUserDriverDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~OUserDriverDetailsPage(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; private: - FixedText* m_pFTHostname; - Edit* m_pEDHostname; - FixedText* m_pPortNumber; - NumericField* m_pNFPortNumber; - CheckBox* m_pUseCatalog; + VclPtr<FixedText> m_pFTHostname; + VclPtr<Edit> m_pEDHostname; + VclPtr<FixedText> m_pPortNumber; + VclPtr<NumericField> m_pNFPortNumber; + VclPtr<CheckBox> m_pUseCatalog; }; // OMySQLODBCDetailsPage @@ -168,6 +166,8 @@ namespace dbaui , sal_uInt16 _nPortId , bool bShowSocket = true ); + virtual ~OGeneralSpecialJDBCDetailsPage(); + virtual void dispose() SAL_OVERRIDE; protected: @@ -177,14 +177,14 @@ namespace dbaui DECL_LINK(OnTestJavaClickHdl,PushButton*); DECL_LINK(OnEditModified,Edit*); - Edit* m_pEDHostname; - NumericField* m_pNFPortNumber; - FixedText* m_pFTSocket; - Edit* m_pEDSocket; + VclPtr<Edit> m_pEDHostname; + VclPtr<NumericField> m_pNFPortNumber; + VclPtr<FixedText> m_pFTSocket; + VclPtr<Edit> m_pEDSocket; - FixedText* m_pFTDriverClass; - Edit* m_pEDDriverClass; - PushButton* m_pTestJavaDriver; + VclPtr<FixedText> m_pFTDriverClass; + VclPtr<Edit> m_pEDDriverClass; + VclPtr<PushButton> m_pTestJavaDriver; OUString m_sDefaultJdbcDriverName; sal_uInt16 m_nPortId; @@ -197,15 +197,17 @@ namespace dbaui public: MySQLNativePage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~MySQLNativePage(); + virtual void dispose() SAL_OVERRIDE; private: - FixedText *m_pSeparator1; - MySQLNativeSettings m_aMySQLSettings; + VclPtr<FixedText> m_pSeparator1; + VclPtr<MySQLNativeSettings> m_aMySQLSettings; - FixedText *m_pSeparator2; - FixedText *m_pUserNameLabel; - Edit *m_pUserName; - CheckBox *m_pPasswordRequired; + VclPtr<FixedText> m_pSeparator2; + VclPtr<FixedText> m_pUserNameLabel; + VclPtr<Edit> m_pUserName; + VclPtr<CheckBox> m_pPasswordRequired; protected: virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; @@ -221,13 +223,15 @@ namespace dbaui virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; OLDAPDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); + virtual ~OLDAPDetailsPage(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; private: - Edit* m_pETBaseDN; - CheckBox* m_pCBUseSSL; - NumericField* m_pNFPortNumber; - NumericField* m_pNFRowCount; + VclPtr<Edit> m_pETBaseDN; + VclPtr<CheckBox> m_pCBUseSSL; + VclPtr<NumericField> m_pNFPortNumber; + VclPtr<NumericField> m_pNFRowCount; sal_Int32 m_iSSLPort; sal_Int32 m_iNormalPort; @@ -237,10 +241,7 @@ namespace dbaui // OMozillaDetailsPage Detail page for Mozilla and Thunderbird addressbook class OMozillaDetailsPage : public OCommonBehaviourTabPage { - protected: - virtual ~OMozillaDetailsPage(); public: - OMozillaDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); }; @@ -251,10 +252,11 @@ namespace dbaui virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) SAL_OVERRIDE; OTextDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); - OTextConnectionHelper* m_pTextConnectionHelper; + VclPtr<OTextConnectionHelper> m_pTextConnectionHelper; protected: virtual ~OTextDetailsPage(); + virtual void dispose() SAL_OVERRIDE; virtual bool prepareLeave() SAL_OVERRIDE; virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx index b02b73332e6f..c5ceccbae91b 100644 --- a/dbaccess/source/ui/dlg/directsql.cxx +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -76,11 +76,23 @@ namespace dbaui DirectSQLDialog::~DirectSQLDialog() { + disposeOnce(); + } + + void DirectSQLDialog::dispose() + { { ::osl::MutexGuard aGuard(m_aMutex); stopAllComponentListening(); } - + m_pSQL.clear(); + m_pExecute.clear(); + m_pSQLHistory.clear(); + m_pStatus.clear(); + m_pShowOutput.clear(); + m_pOutput.clear(); + m_pClose.clear(); + ModalDialog::dispose(); } void DirectSQLDialog::_disposing( const EventObject& _rSource ) @@ -94,8 +106,8 @@ namespace dbaui { OUString sMessage(ModuleRes(STR_DIRECTSQL_CONNECTIONLOST)); - MessageDialog aError(this, sMessage); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(this, sMessage); + aError->Execute(); } PostUserEvent(LINK(this, DirectSQLDialog, OnClose)); diff --git a/dbaccess/source/ui/dlg/dlgattr.cxx b/dbaccess/source/ui/dlg/dlgattr.cxx index 468233f5c748..1ca5043be4bb 100644 --- a/dbaccess/source/ui/dlg/dlgattr.cxx +++ b/dbaccess/source/ui/dlg/dlgattr.cxx @@ -52,8 +52,13 @@ SbaSbAttrDlg::SbaSbAttrDlg(vcl::Window* pParent, const SfxItemSet* pCellAttrs, SbaSbAttrDlg::~SbaSbAttrDlg() { - delete pNumberInfoItem; + disposeOnce(); +} +void SbaSbAttrDlg::dispose() +{ + delete pNumberInfoItem; + SfxTabDialog::dispose(); } void SbaSbAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx index e2817a3d9b7a..46bbbacf63c7 100644 --- a/dbaccess/source/ui/dlg/dlgsave.cxx +++ b/dbaccess/source/ui/dlg/dlgsave.cxx @@ -48,14 +48,14 @@ namespace dbaui class OSaveAsDlgImpl { public: - FixedText* m_pDescription; - FixedText* m_pCatalogLbl; - OSQLNameComboBox* m_pCatalog; - FixedText* m_pSchemaLbl; - OSQLNameComboBox* m_pSchema; - FixedText* m_pLabel; - OSQLNameEdit* m_pTitle; - OKButton* m_pPB_OK; + VclPtr<FixedText> m_pDescription; + VclPtr<FixedText> m_pCatalogLbl; + VclPtr<OSQLNameComboBox> m_pCatalog; + VclPtr<FixedText> m_pSchemaLbl; + VclPtr<OSQLNameComboBox> m_pSchema; + VclPtr<FixedText> m_pLabel; + VclPtr<OSQLNameEdit> m_pTitle; + VclPtr<OKButton> m_pPB_OK; OUString m_aQryLabel; OUString m_sTblLabel; OUString m_aName; @@ -285,7 +285,13 @@ OSaveAsDlg::OSaveAsDlg( vcl::Window * pParent, OSaveAsDlg::~OSaveAsDlg() { + disposeOnce(); +} + +void OSaveAsDlg::dispose() +{ DELETEZ(m_pImpl); + ModalDialog::dispose(); } IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton) diff --git a/dbaccess/source/ui/dlg/dlgsize.cxx b/dbaccess/source/ui/dlg/dlgsize.cxx index 11750ab0917a..6c254a494e84 100644 --- a/dbaccess/source/ui/dlg/dlgsize.cxx +++ b/dbaccess/source/ui/dlg/dlgsize.cxx @@ -51,6 +51,19 @@ DlgSize::DlgSize( vcl::Window* pParent, sal_Int32 nVal, bool bRow, sal_Int32 _nA LINK(this,DlgSize,CbClickHdl).Call(m_pCB_STANDARD); } +DlgSize::~DlgSize() +{ + disposeOnce(); +} + +void DlgSize::dispose() +{ + m_pMF_VALUE.clear(); + m_pCB_STANDARD.clear(); + ModalDialog::dispose(); +} + + void DlgSize::SetValue( sal_Int32 nVal ) { m_pMF_VALUE->SetValue(nVal, FUNIT_CM ); diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx index bcd1dc6add60..950903da5ccd 100644 --- a/dbaccess/source/ui/dlg/dsselect.cxx +++ b/dbaccess/source/ui/dlg/dsselect.cxx @@ -72,8 +72,18 @@ ODatasourceSelectDialog::ODatasourceSelectDialog(vcl::Window* _pParent, const St ODatasourceSelectDialog::~ODatasourceSelectDialog() { + disposeOnce(); } +void ODatasourceSelectDialog::dispose() +{ + m_pDatasource.clear(); + m_pOk.clear(); + m_pCancel.clear(); + ModalDialog::dispose(); +} + + IMPL_LINK( ODatasourceSelectDialog, ListDblClickHdl, ListBox *, pListBox ) { if (pListBox->GetSelectEntryCount()) diff --git a/dbaccess/source/ui/dlg/dsselect.hxx b/dbaccess/source/ui/dlg/dsselect.hxx index b124fb0cdaee..2cb4cb6537e6 100644 --- a/dbaccess/source/ui/dlg/dsselect.hxx +++ b/dbaccess/source/ui/dlg/dsselect.hxx @@ -41,12 +41,12 @@ namespace dbaui class ODatasourceSelectDialog : public ModalDialog { protected: - ListBox* m_pDatasource; - OKButton* m_pOk; - CancelButton* m_pCancel; + VclPtr<ListBox> m_pDatasource; + VclPtr<OKButton> m_pOk; + VclPtr<CancelButton> m_pCancel; SfxItemSet* m_pOutputSet; #ifdef HAVE_ODBC_ADMINISTRATION - PushButton* m_pManageDatasources; + VclPtr<PushButton> m_pManageDatasources; ::std::unique_ptr< OOdbcManagement > m_pODBCManagement; #endif @@ -54,7 +54,7 @@ protected: public: ODatasourceSelectDialog( vcl::Window* _pParent, const StringBag& _rDatasources, SfxItemSet* _pOutputSet = NULL ); virtual ~ODatasourceSelectDialog(); - + virtual void dispose() SAL_OVERRIDE; OUString GetSelected() const { return m_pDatasource->GetSelectEntry();} void Select( const OUString& _rEntry ) { m_pDatasource->SelectEntry(_rEntry); } diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 1a543dce4c73..4ece5045c04d 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -76,6 +76,14 @@ namespace dbaui OGeneralPage::~OGeneralPage() { + disposeOnce(); + } + + void OGeneralPage::dispose() + { + m_pSpecialMessage.clear(); + m_pDatasourceType.clear(); + OGenericAdministrationPage::dispose(); } namespace @@ -537,6 +545,24 @@ namespace dbaui m_pPB_OpenDatabase->SetClickHdl( LINK( this, OGeneralPageWizard, OnOpenDocument ) ); } + OGeneralPageWizard::~OGeneralPageWizard() + { + disposeOnce(); + } + + void OGeneralPageWizard::dispose() + { + m_pRB_CreateDatabase.clear(); + m_pRB_OpenExistingDatabase.clear(); + m_pRB_ConnectDatabase.clear(); + m_pFT_EmbeddedDBLabel.clear(); + m_pEmbeddedDBType.clear(); + m_pFT_DocListLabel.clear(); + m_pLB_DocumentList.clear(); + m_pPB_OpenDatabase.clear(); + OGeneralPage::dispose(); + } + OGeneralPageWizard::CreationMode OGeneralPageWizard::GetDatabaseCreationMode() const { if ( m_pRB_CreateDatabase->IsChecked() ) @@ -712,8 +738,8 @@ namespace dbaui if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) ) { OUString sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO)); - InfoBox aError(this, sMessage); - aError.Execute(); + ScopedVclPtrInstance< InfoBox > aError(this, sMessage); + aError->Execute(); m_pRB_ConnectDatabase->Check(); OnSetupModeSelected( m_pRB_ConnectDatabase ); return 0L; diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx index 0668f679721a..6c5d3294f749 100644 --- a/dbaccess/source/ui/dlg/generalpage.hxx +++ b/dbaccess/source/ui/dlg/generalpage.hxx @@ -34,14 +34,13 @@ namespace dbaui { protected: OGeneralPage( vcl::Window* pParent, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems ); - virtual ~OGeneralPage(); OUString m_eCurrentSelection; /// currently selected type ::dbaccess::DATASOURCE_TYPE m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered .... private: - FixedText* m_pSpecialMessage; + VclPtr<FixedText> m_pSpecialMessage; enum SPECIAL_MESSAGE { @@ -57,7 +56,7 @@ namespace dbaui void insertDatasourceTypeEntryData( const OUString& _sType, const OUString& sDisplayName ); protected: - ListBox* m_pDatasourceType; + VclPtr<ListBox> m_pDatasourceType; ::dbaccess::ODsnTypeCollection* m_pCollection; /// the DSN type collection instance @@ -66,6 +65,9 @@ namespace dbaui m_aURLPrefixes; public: + virtual ~OGeneralPage(); + virtual void dispose() SAL_OVERRIDE; + /// set a handler which gets called every time the user selects a new type void SetTypeSelectHandler( const Link& _rHandler ) { m_aTypeSelectHandler = _rHandler; } @@ -116,7 +118,8 @@ namespace dbaui { public: OGeneralPageWizard( vcl::Window* pParent, const SfxItemSet& _rItems ); - + virtual ~OGeneralPageWizard(); + virtual void dispose() SAL_OVERRIDE; public: enum CreationMode { @@ -133,16 +136,16 @@ namespace dbaui private: // dialog controls - RadioButton* m_pRB_CreateDatabase; - RadioButton* m_pRB_OpenExistingDatabase; - RadioButton* m_pRB_ConnectDatabase; + VclPtr<RadioButton> m_pRB_CreateDatabase; + VclPtr<RadioButton> m_pRB_OpenExistingDatabase; + VclPtr<RadioButton> m_pRB_ConnectDatabase; - FixedText* m_pFT_EmbeddedDBLabel; - ListBox* m_pEmbeddedDBType; + VclPtr<FixedText> m_pFT_EmbeddedDBLabel; + VclPtr<ListBox> m_pEmbeddedDBType; - FixedText* m_pFT_DocListLabel; - OpenDocumentListBox* m_pLB_DocumentList; - OpenDocumentButton* m_pPB_OpenDatabase; + VclPtr<FixedText> m_pFT_DocListLabel; + VclPtr<OpenDocumentListBox> m_pLB_DocumentList; + VclPtr<OpenDocumentButton> m_pPB_OpenDatabase; // state DocumentDescriptor m_aBrowsedDocument; diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx index d034b68bd597..a033fab3b3bf 100644 --- a/dbaccess/source/ui/dlg/indexdialog.cxx +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -311,9 +311,23 @@ namespace dbaui DbaIndexDialog::~DbaIndexDialog( ) { + disposeOnce(); + } + + void DbaIndexDialog::dispose() + { setToolBox(NULL); delete m_pIndexes; - + m_pActions.clear(); + m_pIndexList.clear(); + m_pIndexDetails.clear(); + m_pDescriptionLabel.clear(); + m_pDescription.clear(); + m_pUnique.clear(); + m_pFieldsLabel.clear(); + m_pFields.clear(); + m_pClose.clear(); + ModalDialog::dispose(); } bool DbaIndexDialog::implCommit(SvTreeListEntry* _pEntry) @@ -408,8 +422,8 @@ namespace dbaui { OUString sConfirm(ModuleRes(STR_CONFIRM_DROP_INDEX)); sConfirm = sConfirm.replaceFirst("$name$", m_pIndexList->GetEntryText(pSelected)); - MessageDialog aConfirm(this, sConfirm, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - if (RET_YES != aConfirm.Execute()) + ScopedVclPtrInstance< MessageDialog > aConfirm(this, sConfirm, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + if (RET_YES != aConfirm->Execute()) return; } @@ -572,9 +586,9 @@ namespace dbaui if (aSelected->isModified() || aSelected->isNew()) { - MessageDialog aQuestion(this, "SaveIndexDialog", - "dbaccess/ui/saveindexdialog.ui"); - nResponse = aQuestion.Execute(); + ScopedVclPtrInstance<MessageDialog> aQuestion(this, "SaveIndexDialog", + "dbaccess/ui/saveindexdialog.ui" ); + nResponse = aQuestion->Execute(); } } @@ -616,8 +630,8 @@ namespace dbaui { OUString sError(ModuleRes(STR_INDEX_NAME_ALREADY_USED)); sError = sError.replaceFirst("$name$", sNewName); - MessageDialog aError(this, sError); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(this, sError); + aError->Execute(); updateToolbox(); m_bEditAgain = true; @@ -677,8 +691,8 @@ namespace dbaui // need at least one field if (0 == _rPos->aFields.size()) { - MessageDialog aError(this, ModuleRes(STR_NEED_INDEX_FIELDS)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(this, ModuleRes(STR_NEED_INDEX_FIELDS)); + aError->Execute(); m_pFields->GrabFocus(); return false; } @@ -695,8 +709,8 @@ namespace dbaui // a column is specified twice ... won't work anyway, so prevent this here and now OUString sMessage(ModuleRes(STR_INDEXDESIGN_DOUBLE_COLUMN_NAME)); sMessage = sMessage.replaceFirst("$name$", aFieldCheck->sFieldName); - MessageDialog aError(this, sMessage); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(this, sMessage); + aError->Execute(); m_pFields->GrabFocus(); return false; } diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx index dc0d7a40d3b6..a236e46ea7dc 100644 --- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -110,9 +110,14 @@ namespace dbaui IndexFieldsControl::~IndexFieldsControl() { - delete m_pSortingCell; - delete m_pFieldNameCell; + disposeOnce(); + } + void IndexFieldsControl::dispose() + { + m_pSortingCell.disposeAndClear(); + m_pFieldNameCell.disposeAndClear(); + ::svt::EditBrowseBox::dispose(); } bool IndexFieldsControl::SeekRow(long nRow) @@ -240,7 +245,7 @@ namespace dbaui nSortOrderColumnWidth += GetTextWidth(OUString('0')) * 2; InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HeaderBarItemBits::STDSTYLE, 1); - m_pSortingCell = new ListBoxControl(&GetDataWindow()); + m_pSortingCell = VclPtr<ListBoxControl>::Create(&GetDataWindow()); m_pSortingCell->InsertEntry(m_sAscendingText); m_pSortingCell->InsertEntry(m_sDescendingText); m_pSortingCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_SORTORDER ); @@ -256,7 +261,7 @@ namespace dbaui // create the cell controllers // for the field name cell - m_pFieldNameCell = new ListBoxControl(&GetDataWindow()); + m_pFieldNameCell = VclPtr<ListBoxControl>::Create(&GetDataWindow()); m_pFieldNameCell->InsertEntry(OUString()); m_pFieldNameCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_FIELD ); const OUString* pFields = _rAvailableFields.getConstArray(); diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index d39d86fb623a..c0425048091a 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -113,9 +113,19 @@ namespace dbaui OParameterDialog::~OParameterDialog() { + disposeOnce(); + } + + void OParameterDialog::dispose() + { if (m_aResetVisitFlag.IsActive()) m_aResetVisitFlag.Stop(); - + m_pAllParams.clear(); + m_pParam.clear(); + m_pTravelNext.clear(); + m_pOKBtn.clear(); + m_pCancelBtn.clear(); + ModalDialog::dispose(); } void OParameterDialog::Construct() diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index 1274a03bf9b2..a86bd6326e66 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -192,6 +192,23 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent, DlgFilterCrit::~DlgFilterCrit() { + disposeOnce(); +} + +void DlgFilterCrit::dispose() +{ + m_pLB_WHEREFIELD1.clear(); + m_pLB_WHERECOMP1.clear(); + m_pET_WHEREVALUE1.clear(); + m_pLB_WHERECOND2.clear(); + m_pLB_WHEREFIELD2.clear(); + m_pLB_WHERECOMP2.clear(); + m_pET_WHEREVALUE2.clear(); + m_pLB_WHERECOND3.clear(); + m_pLB_WHEREFIELD3.clear(); + m_pLB_WHERECOMP3.clear(); + m_pET_WHEREVALUE3.clear(); + ModalDialog::dispose(); } #define LbText(x) ((x).GetSelectEntry()) diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx index f58d3ad7f0c5..410598b5663e 100644 --- a/dbaccess/source/ui/dlg/queryorder.cxx +++ b/dbaccess/source/ui/dlg/queryorder.cxx @@ -127,6 +127,20 @@ DlgOrderCrit::DlgOrderCrit(vcl::Window * pParent, DlgOrderCrit::~DlgOrderCrit() { + disposeOnce(); +} + +void DlgOrderCrit::dispose() +{ + m_pLB_ORDERFIELD1.clear(); + m_pLB_ORDERVALUE1.clear(); + m_pLB_ORDERFIELD2.clear(); + m_pLB_ORDERVALUE2.clear(); + m_pLB_ORDERFIELD3.clear(); + m_pLB_ORDERVALUE3.clear(); + for (auto a : m_aColumnList) a.clear(); + for (auto a : m_aValueList) a.clear(); + ModalDialog::dispose(); } IMPL_LINK_INLINE_START( DlgOrderCrit, FieldListSelectHdl, ListBox *, /*pListBox*/ ) diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 70ba97341669..36341e32751f 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -292,8 +292,8 @@ namespace class OExceptionChainDialog : public ModalDialog { - SvTreeListBox* m_pExceptionList; - VclMultiLineEdit* m_pExceptionText; + VclPtr<SvTreeListBox> m_pExceptionList; + VclPtr<VclMultiLineEdit> m_pExceptionText; OUString m_sStatusLabel; OUString m_sErrorCodeLabel; @@ -302,6 +302,13 @@ class OExceptionChainDialog : public ModalDialog public: OExceptionChainDialog( vcl::Window* pParent, const ExceptionDisplayChain& _rExceptions ); + virtual ~OExceptionChainDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE + { + m_pExceptionList.clear(); + m_pExceptionText.clear(); + ModalDialog::dispose(); + } protected: DECL_LINK(OnExceptionSelected, void*); @@ -470,24 +477,24 @@ void OSQLMessageBox::impl_positionControls() } // image - lcl_positionInAppFont( *this, m_aInfoImage, OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE ); - m_aInfoImage.Show(); + lcl_positionInAppFont( *this, *m_aInfoImage.get(), OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE ); + m_aInfoImage->Show(); // primary text - lcl_positionInAppFont( *this, m_aTitle, TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 ); + lcl_positionInAppFont( *this, *m_aTitle.get(), TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 ); sPrimary = lcl_stripOOoBaseVendor( sPrimary ); - m_aTitle.SetText( sPrimary ); - m_aTitle.Show(); + m_aTitle->SetText( sPrimary ); + m_aTitle->Show(); - Rectangle aPrimaryRect( m_aTitle.GetPosPixel(), m_aTitle.GetSizePixel() ); + Rectangle aPrimaryRect( m_aTitle->GetPosPixel(), m_aTitle->GetSizePixel() ); // secondary text (if applicable) - m_aMessage.SetStyle( m_aMessage.GetStyle() | WB_NOLABEL ); + m_aMessage->SetStyle( m_aMessage->GetStyle() | WB_NOLABEL ); sSecondary = lcl_stripOOoBaseVendor( sSecondary ); - m_aMessage.SetText( sSecondary ); + m_aMessage->SetText( sSecondary ); - lcl_positionInAppFont( *this, m_aMessage, TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 ); - Rectangle aSecondaryRect( m_aMessage.GetPosPixel(), m_aMessage.GetSizePixel() ); + lcl_positionInAppFont( *this, *m_aMessage.get(), TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 ); + Rectangle aSecondaryRect( m_aMessage->GetPosPixel(), m_aMessage->GetSizePixel() ); bool bHaveSecondaryText = !sSecondary.isEmpty(); @@ -498,8 +505,8 @@ void OSQLMessageBox::impl_positionControls() aSecondaryRect.Bottom() = aSecondaryRect.Top() - 1; // adjust secondary control height accordingly - m_aMessage.SetSizePixel( aSecondaryRect.GetSize() ); - m_aMessage.Show( aSecondaryRect.GetHeight() > 0 ); + m_aMessage->SetSizePixel( aSecondaryRect.GetSize() ); + m_aMessage->Show( aSecondaryRect.GetHeight() > 0 ); // if there's no secondary text ... if ( !bHaveSecondaryText ) @@ -508,23 +515,23 @@ void OSQLMessageBox::impl_positionControls() aPrimaryRect.Right() = aPrimaryRect.Left() + aSuggestedRect.GetWidth(); aPrimaryRect.Bottom() = aPrimaryRect.Top() + aSuggestedRect.GetHeight(); // and center it horizontally - m_aTitle.SetStyle( ( m_aTitle.GetStyle() & ~WB_LEFT ) | WB_CENTER ); + m_aTitle->SetStyle( ( m_aTitle->GetStyle() & ~WB_LEFT ) | WB_CENTER ); - Rectangle aInfoRect( m_aInfoImage.GetPosPixel(), m_aInfoImage.GetSizePixel() ); + Rectangle aInfoRect( m_aInfoImage->GetPosPixel(), m_aInfoImage->GetSizePixel() ); // also, if it's not as high as the image ... - if ( aPrimaryRect.GetHeight() < m_aInfoImage.GetSizePixel().Height() ) + if ( aPrimaryRect.GetHeight() < m_aInfoImage->GetSizePixel().Height() ) { // ... make it fit the image height aPrimaryRect.Bottom() += aInfoRect.GetHeight() - aPrimaryRect.GetHeight(); // and center it vertically - m_aTitle.SetStyle( m_aTitle.GetStyle() | WB_VCENTER ); + m_aTitle->SetStyle( m_aTitle->GetStyle() | WB_VCENTER ); } else { // ... otherwise, center the image vertically, relative to the primary text aInfoRect.Move( 0, ( aPrimaryRect.GetHeight() - aInfoRect.GetHeight() ) / 2 ); - m_aInfoImage.SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() ); + m_aInfoImage->SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() ); } - m_aTitle.SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() ); + m_aTitle->SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() ); } // adjust dialog size accordingly @@ -546,16 +553,16 @@ void OSQLMessageBox::impl_initImage( MessageType _eImage ) OSL_FAIL( "OSQLMessageBox::impl_initImage: unsupported image type!" ); /* Fall through */ case Info: - m_aInfoImage.SetImage(InfoBox::GetStandardImage()); + m_aInfoImage->SetImage(InfoBox::GetStandardImage()); break; case Warning: - m_aInfoImage.SetImage(WarningBox::GetStandardImage()); + m_aInfoImage->SetImage(WarningBox::GetStandardImage()); break; case Error: - m_aInfoImage.SetImage(ErrorBox::GetStandardImage()); + m_aInfoImage->SetImage(ErrorBox::GetStandardImage()); break; case Query: - m_aInfoImage.SetImage(QueryBox::GetStandardImage()); + m_aInfoImage->SetImage(QueryBox::GetStandardImage()); break; } } @@ -606,7 +613,7 @@ void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle ) void OSQLMessageBox::impl_addDetailsButton() { - size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1; + size_t nFirstPageVisible = m_aMessage->IsVisible() ? 2 : 1; bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; if ( !bMoreDetailsAvailable ) @@ -664,9 +671,9 @@ void OSQLMessageBox::Construct( WinBits _nStyle, MessageType _eImage ) OSQLMessageBox::OSQLMessageBox(vcl::Window* _pParent, const SQLExceptionInfo& _rException, WinBits _nStyle, const OUString& _rHelpURL ) :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) - ,m_aInfoImage( this ) - ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) - ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) + ,m_aInfoImage( VclPtr<FixedImage>::Create(this) ) + ,m_aTitle( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) ) + ,m_aMessage( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) ) ,m_sHelpURL( _rHelpURL ) ,m_pImpl( new SQLMessageBox_Impl( _rException ) ) { @@ -675,9 +682,9 @@ OSQLMessageBox::OSQLMessageBox(vcl::Window* _pParent, const SQLExceptionInfo& _r OSQLMessageBox::OSQLMessageBox( vcl::Window* _pParent, const OUString& _rTitle, const OUString& _rMessage, WinBits _nStyle, MessageType _eType, const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo ) :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) - ,m_aInfoImage( this ) - ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) - ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) + ,m_aInfoImage( VclPtr<FixedImage>::Create(this) ) + ,m_aTitle( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) ) + ,m_aMessage( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) ) { SQLContext aError; aError.Message = _rTitle; @@ -692,12 +699,21 @@ OSQLMessageBox::OSQLMessageBox( vcl::Window* _pParent, const OUString& _rTitle, OSQLMessageBox::~OSQLMessageBox() { + disposeOnce(); +} + +void OSQLMessageBox::dispose() +{ + m_aInfoImage.disposeAndClear(); + m_aTitle.disposeAndClear(); + m_aMessage.disposeAndClear(); + ButtonDialog::dispose(); } IMPL_LINK( OSQLMessageBox, ButtonClickHdl, Button *, /*pButton*/ ) { - OExceptionChainDialog aDlg( this, m_pImpl->aDisplayInfo ); - aDlg.Execute(); + ScopedVclPtrInstance< OExceptionChainDialog > aDlg( this, m_pImpl->aDisplayInfo ); + aDlg->Execute(); return 0; } diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx index 59d9af9d75be..54ab0c3cecdf 100644 --- a/dbaccess/source/ui/dlg/tablespage.cxx +++ b/dbaccess/source/ui/dlg/tablespage.cxx @@ -99,13 +99,21 @@ namespace dbaui OTableSubscriptionPage::~OTableSubscriptionPage() { + disposeOnce(); + } + + void OTableSubscriptionPage::dispose() + { // just to make sure that our connection will be removed try { ::comphelper::disposeComponent(m_xCurrentConnection); } catch (RuntimeException&) { } - + m_pTables.clear(); + m_pTablesList.clear(); + m_pTablesDlg.clear(); + OGenericAdministrationPage::dispose(); } void OTableSubscriptionPage::StateChanged( StateChangedType nType ) @@ -319,8 +327,8 @@ namespace dbaui if (aErrorInfo.isValid()) { // establishing the connection failed. Show an error window and exit. - OSQLMessageBox aMessageBox( GetParentDialog(), aErrorInfo ); - aMessageBox.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aMessageBox( GetParentDialog(), aErrorInfo ); + aMessageBox->Execute(); m_pTables->Enable(false); m_pTablesList->Clear(); diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx index bd1568a82f36..a5dc8e8e9dbc 100644 --- a/dbaccess/source/ui/dlg/tablespage.hxx +++ b/dbaccess/source/ui/dlg/tablespage.hxx @@ -36,8 +36,8 @@ namespace dbaui :public OGenericAdministrationPage { private: - VclContainer* m_pTables; - OTableTreeListBox* m_pTablesList; + VclPtr<VclContainer> m_pTables; + VclPtr<OTableTreeListBox> m_pTablesList; OUString m_sCatalogSeparator; bool m_bCatalogAtStart : 1; @@ -46,7 +46,7 @@ namespace dbaui m_xCurrentConnection; /// valid as long as the page is active ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_xCollator; - OTableSubscriptionDialog* m_pTablesDlg; + VclPtr<OTableSubscriptionDialog> m_pTablesDlg; public: virtual bool FillItemSet(SfxItemSet* _rCoreAttrs) SAL_OVERRIDE; @@ -62,6 +62,7 @@ namespace dbaui OTableSubscriptionPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ,OTableSubscriptionDialog* _pTablesDlg); virtual ~OTableSubscriptionPage(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.cxx b/dbaccess/source/ui/dlg/textconnectionsettings.cxx index 11f84162318b..9fa798b1b096 100644 --- a/dbaccess/source/ui/dlg/textconnectionsettings.cxx +++ b/dbaccess/source/ui/dlg/textconnectionsettings.cxx @@ -34,13 +34,21 @@ namespace dbaui ,m_rItems( _rItems ) { get(m_pOK, "ok"); - m_pTextConnectionHelper.reset( new OTextConnectionHelper( get<VclVBox>("TextPageContainer"), TC_HEADER | TC_SEPARATORS | TC_CHARSET ) ); + m_pTextConnectionHelper.reset( VclPtr<OTextConnectionHelper>::Create( get<VclVBox>("TextPageContainer"), TC_HEADER | TC_SEPARATORS | TC_CHARSET ) ); m_pOK->SetClickHdl( LINK( this, TextConnectionSettingsDialog, OnOK ) ); } TextConnectionSettingsDialog::~TextConnectionSettingsDialog() { + disposeOnce(); + } + + void TextConnectionSettingsDialog::dispose() + { + m_pOK.clear(); + m_pTextConnectionHelper.disposeAndClear(); + ModalDialog::dispose(); } void TextConnectionSettingsDialog::bindItemStorages( SfxItemSet& _rSet, PropertyValues& _rValues ) diff --git a/dbaccess/source/ui/inc/CollectionView.hxx b/dbaccess/source/ui/inc/CollectionView.hxx index 704ea76c6068..f407b70bc918 100644 --- a/dbaccess/source/ui/inc/CollectionView.hxx +++ b/dbaccess/source/ui/inc/CollectionView.hxx @@ -34,12 +34,12 @@ namespace dbaui */ class OCollectionView : public ModalDialog { - FixedText* m_pFTCurrentPath; - PushButton* m_pNewFolder; - PushButton* m_pUp; - SvtFileView* m_pView; - Edit* m_pName; - PushButton* m_pPB_OK; + VclPtr<FixedText> m_pFTCurrentPath; + VclPtr<PushButton> m_pNewFolder; + VclPtr<PushButton> m_pUp; + VclPtr<SvtFileView> m_pView; + VclPtr<Edit> m_pName; + VclPtr<PushButton> m_pPB_OK; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xContent; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; bool m_bCreateForm; @@ -57,7 +57,7 @@ namespace dbaui ,const OUString& _sDefaultName ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext); virtual ~OCollectionView(); - + virtual void dispose() SAL_OVERRIDE; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> getSelectedFolder() const { return m_xContent;} OUString getName() const; }; diff --git a/dbaccess/source/ui/inc/ColumnControlWindow.hxx b/dbaccess/source/ui/inc/ColumnControlWindow.hxx index b09d6ff6e030..583481a7d7b2 100644 --- a/dbaccess/source/ui/inc/ColumnControlWindow.hxx +++ b/dbaccess/source/ui/inc/ColumnControlWindow.hxx @@ -55,7 +55,6 @@ namespace dbaui public: OColumnControlWindow(vcl::Window* pParent ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext); - virtual ~OColumnControlWindow(); void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xCon); diff --git a/dbaccess/source/ui/inc/ConnectionLine.hxx b/dbaccess/source/ui/inc/ConnectionLine.hxx index 6ae780d4705a..f5bef2a5d5d9 100644 --- a/dbaccess/source/ui/inc/ConnectionLine.hxx +++ b/dbaccess/source/ui/inc/ConnectionLine.hxx @@ -22,6 +22,7 @@ #include <tools/gen.hxx> #include "ConnectionLineData.hxx" #include <functional> +#include <vcl/vclptr.hxx> class OutputDevice; namespace dbaui @@ -38,7 +39,7 @@ namespace dbaui class OTableConnection; class OConnectionLine { - OTableConnection* m_pTabConn; + VclPtr<OTableConnection> m_pTabConn; OConnectionLineDataRef m_pData; Point m_aSourceConnPos, @@ -72,7 +73,7 @@ namespace dbaui /// draws a connectionline object on outputdevice struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void> { - OutputDevice* pDevice; + VclPtr<OutputDevice> pDevice; TConnectionLineDrawFunctor(OutputDevice* _pDevice) { pDevice = _pDevice; diff --git a/dbaccess/source/ui/inc/ConnectionLineAccess.hxx b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx index fb63317073f6..8df3cf848f34 100644 --- a/dbaccess/source/ui/inc/ConnectionLineAccess.hxx +++ b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <cppuhelper/implbase2.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <vcl/vclptr.hxx> namespace dbaui { @@ -35,7 +36,7 @@ namespace dbaui class OConnectionLineAccess : public VCLXAccessibleComponent , public OConnectionLineAccess_BASE { - const OTableConnection* m_pLine; // the window which I should give accessibility to + VclPtr<const OTableConnection> m_pLine; // the window which I should give accessibility to protected: /** this function is called upon disposing the component */ diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx index d8913ed932fa..983bfc6d2183 100644 --- a/dbaccess/source/ui/inc/FieldDescControl.hxx +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -65,40 +65,40 @@ namespace dbaui class OFieldDescControl : public TabPage { private: - OTableDesignHelpBar* pHelp; - vcl::Window* pLastFocusWindow; - vcl::Window* m_pActFocusWindow; - - FixedText* pDefaultText; - FixedText* pRequiredText; - FixedText* pAutoIncrementText; - FixedText* pTextLenText; - FixedText* pNumTypeText; - FixedText* pLengthText; - FixedText* pScaleText; - FixedText* pFormatText; - FixedText* pBoolDefaultText; - FixedText* m_pColumnNameText; - FixedText* m_pTypeText; - FixedText* m_pAutoIncrementValueText; - - OPropListBoxCtrl* pRequired; - OPropListBoxCtrl* pNumType; - OPropListBoxCtrl* pAutoIncrement; - OPropEditCtrl* pDefault; - OPropNumericEditCtrl* pTextLen; - OPropNumericEditCtrl* pLength; - OPropNumericEditCtrl* pScale; - OPropEditCtrl* pFormatSample; - OPropListBoxCtrl* pBoolDefault; - OPropColumnEditCtrl* m_pColumnName; - OPropListBoxCtrl* m_pType; - OPropEditCtrl* m_pAutoIncrementValue; - - PushButton* pFormat; - - ScrollBar* m_pVertScroll; - ScrollBar* m_pHorzScroll; + VclPtr<OTableDesignHelpBar> pHelp; + VclPtr<vcl::Window> pLastFocusWindow; + VclPtr<vcl::Window> m_pActFocusWindow; + + VclPtr<FixedText> pDefaultText; + VclPtr<FixedText> pRequiredText; + VclPtr<FixedText> pAutoIncrementText; + VclPtr<FixedText> pTextLenText; + VclPtr<FixedText> pNumTypeText; + VclPtr<FixedText> pLengthText; + VclPtr<FixedText> pScaleText; + VclPtr<FixedText> pFormatText; + VclPtr<FixedText> pBoolDefaultText; + VclPtr<FixedText> m_pColumnNameText; + VclPtr<FixedText> m_pTypeText; + VclPtr<FixedText> m_pAutoIncrementValueText; + + VclPtr<OPropListBoxCtrl> pRequired; + VclPtr<OPropListBoxCtrl> pNumType; + VclPtr<OPropListBoxCtrl> pAutoIncrement; + VclPtr<OPropEditCtrl> pDefault; + VclPtr<OPropNumericEditCtrl> pTextLen; + VclPtr<OPropNumericEditCtrl> pLength; + VclPtr<OPropNumericEditCtrl> pScale; + VclPtr<OPropEditCtrl> pFormatSample; + VclPtr<OPropListBoxCtrl> pBoolDefault; + VclPtr<OPropColumnEditCtrl> m_pColumnName; + VclPtr<OPropListBoxCtrl> m_pType; + VclPtr<OPropEditCtrl> m_pAutoIncrementValue; + + VclPtr<PushButton> pFormat; + + VclPtr<ScrollBar> m_pVertScroll; + VclPtr<ScrollBar> m_pHorzScroll; TOTypeInfoSP m_pPreviousType; short m_nPos; @@ -126,15 +126,15 @@ namespace dbaui void UpdateFormatSample(OFieldDescription* pFieldDescr); void ArrangeAggregates(); - void SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol ); + void SetPosSize( VclPtr<Control>& rControl, long nRow, sal_uInt16 nCol ); void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY); void ScrollAllAggregates(); bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const; void Contruct(); - OPropNumericEditCtrl* CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const OString& _sHelpId); - FixedText* CreateText(sal_uInt16 _nTextRes); + VclPtr<OPropNumericEditCtrl> CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const OString& _sHelpId); + VclPtr<FixedText> CreateText(sal_uInt16 _nTextRes); void InitializeControl(Control* _pControl,const OString& _sHelpId,bool _bAddChangeHandler); protected: @@ -175,6 +175,7 @@ namespace dbaui public: OFieldDescControl( vcl::Window* pParent, OTableDesignHelpBar* pHelpBar); virtual ~OFieldDescControl(); + virtual void dispose() SAL_OVERRIDE; void DisplayData(OFieldDescription* pFieldDescr ); diff --git a/dbaccess/source/ui/inc/JAccess.hxx b/dbaccess/source/ui/inc/JAccess.hxx index 2306dfef8d4b..11604c2e2fd3 100644 --- a/dbaccess/source/ui/inc/JAccess.hxx +++ b/dbaccess/source/ui/inc/JAccess.hxx @@ -21,6 +21,7 @@ #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <cppuhelper/implbase1.hxx> +#include <vcl/vclptr.hxx> namespace dbaui { @@ -32,7 +33,7 @@ namespace dbaui */ class OJoinDesignViewAccess : public VCLXAccessibleComponent, public OJoinDesignViewAccess_BASE { - OJoinTableView* m_pTableView; // the window which I should give accessibility to + VclPtr<OJoinTableView> m_pTableView; // the window which I should give accessibility to public: /** OJoinDesignViewAccess needs a valid view diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx index bfbfc560544b..4fd57a929b86 100644 --- a/dbaccess/source/ui/inc/JoinController.hxx +++ b/dbaccess/source/ui/inc/JoinController.hxx @@ -51,7 +51,7 @@ namespace dbaui Fraction m_aZoom; ::dbtools::SQLExceptionInfo m_aExceptionInfo; - OAddTableDlg* m_pAddTableDialog; + VclPtr<OAddTableDlg> m_pAddTableDialog; ::std::unique_ptr< AddTableDialogContext > m_pDialogContext; Point m_aMinimumTableViewSize; diff --git a/dbaccess/source/ui/inc/JoinDesignView.hxx b/dbaccess/source/ui/inc/JoinDesignView.hxx index 7b29ddde90af..da50da1e20ac 100644 --- a/dbaccess/source/ui/inc/JoinDesignView.hxx +++ b/dbaccess/source/ui/inc/JoinDesignView.hxx @@ -33,8 +33,8 @@ namespace dbaui class OJoinDesignView : public ODataView { protected: - OScrollWindowHelper* m_pScrollWindow; // contains only the scrollbars - OJoinTableView* m_pTableView; // presents the upper window + VclPtr<OScrollWindowHelper> m_pScrollWindow; // contains only the scrollbars + VclPtr<OJoinTableView> m_pTableView; // presents the upper window OJoinController& m_rController; public: @@ -42,6 +42,7 @@ namespace dbaui OJoinController& _rController, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); virtual ~OJoinDesignView(); + virtual void dispose() SAL_OVERRIDE; // set the view readonly or not virtual void setReadOnly(bool _bReadOnly); diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx b/dbaccess/source/ui/inc/JoinTableView.hxx index f43cdd254baf..608c2d82dc98 100644 --- a/dbaccess/source/ui/inc/JoinTableView.hxx +++ b/dbaccess/source/ui/inc/JoinTableView.hxx @@ -23,6 +23,7 @@ #include <vcl/timer.hxx> #include <vcl/idle.hxx> #include <vcl/scrbar.hxx> +#include <vcl/vclptr.hxx> #include <tools/rtti.hxx> #include <svtools/transfer.hxx> @@ -51,10 +52,10 @@ namespace dbaui class OJoinTableView; class OScrollWindowHelper : public vcl::Window { - ScrollBar m_aHScrollBar; - ScrollBar m_aVScrollBar; - vcl::Window* m_pCornerWindow; - OJoinTableView* m_pTableView; + VclPtr<ScrollBar> m_aHScrollBar; + VclPtr<ScrollBar> m_aVScrollBar; + VclPtr<vcl::Window> m_pCornerWindow; + VclPtr<OJoinTableView> m_pTableView; protected: virtual void Resize() SAL_OVERRIDE; @@ -62,14 +63,15 @@ namespace dbaui public: OScrollWindowHelper( vcl::Window* pParent); virtual ~OScrollWindowHelper(); + virtual void dispose() SAL_OVERRIDE; void setTableView(OJoinTableView* _pTableView); void resetRange(const Point& _aSize); // own methods - ScrollBar& GetHScrollBar() { return m_aHScrollBar; } - ScrollBar& GetVScrollBar() { return m_aVScrollBar; } + ScrollBar& GetHScrollBar() { return *m_aHScrollBar.get(); } + ScrollBar& GetVScrollBar() { return *m_aVScrollBar.get(); } }; @@ -80,11 +82,11 @@ namespace dbaui friend class OJoinMoveTabWinUndoAct; public: - typedef std::map<OUString, OTableWindow*> OTableWindowMap; + typedef std::map<OUString, VclPtr<OTableWindow> > OTableWindowMap; private: OTableWindowMap m_aTableMap; - ::std::vector<OTableConnection*> m_vTableConnection; + ::std::vector<VclPtr<OTableConnection> > m_vTableConnection; Idle m_aDragScrollIdle; Rectangle m_aDragRect; @@ -95,9 +97,9 @@ namespace dbaui Size m_aOutputSize; - OTableWindow* m_pDragWin; - OTableWindow* m_pSizingWin; - OTableConnection* m_pSelectedConn; + VclPtr<OTableWindow> m_pDragWin; + VclPtr<OTableWindow> m_pSizingWin; + VclPtr<OTableConnection> m_pSelectedConn; bool m_bTrackingInitiallyMoved; @@ -105,13 +107,14 @@ namespace dbaui DECL_LINK(OnDragScrollTimer, void*); protected: - OTableWindow* m_pLastFocusTabWin; - OJoinDesignView* m_pView; + VclPtr<OTableWindow> m_pLastFocusTabWin; + VclPtr<OJoinDesignView> m_pView; OJoinDesignViewAccess* m_pAccessible; public: OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView ); virtual ~OJoinTableView(); + virtual void dispose() SAL_OVERRIDE; // window override virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; @@ -180,7 +183,7 @@ namespace dbaui /** gives a read only access to the connection vector */ - const ::std::vector<OTableConnection*>& getTableConnections() const { return m_vTableConnection; } + const ::std::vector<VclPtr<OTableConnection> >& getTableConnections() const { return m_vTableConnection; } bool ExistsAConn(const OTableWindow* pFromWin) const; @@ -189,7 +192,7 @@ namespace dbaui @param _pFromWin the table for which connections should be found @return an iterator which can be used to travel all connections of the table */ - ::std::vector<OTableConnection*>::const_iterator getTableConnections(const OTableWindow* _pFromWin) const; + ::std::vector<VclPtr<OTableConnection> >::const_iterator getTableConnections(const OTableWindow* _pFromWin) const; /** how many connection belongs to single table @@ -290,7 +293,7 @@ namespace dbaui @param _pData The data corresponding to the window. @return The new TableWindow */ - virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData) = 0; + virtual VclPtr<OTableWindow> createWindow(const TTableWindowData::value_type& _pData) = 0; /** determines whether the classes Init method should accept a query name, or only table names */ diff --git a/dbaccess/source/ui/inc/LimitBox.hxx b/dbaccess/source/ui/inc/LimitBox.hxx index 5f9187a38bba..6ff436daa170 100644 --- a/dbaccess/source/ui/inc/LimitBox.hxx +++ b/dbaccess/source/ui/inc/LimitBox.hxx @@ -24,7 +24,6 @@ class LimitBox: public NumericBox { public: LimitBox( vcl::Window* pParent, WinBits nStyle ); - virtual ~LimitBox(); virtual OUString CreateFieldText( sal_Int64 nValue ) const SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx index 2baba04ac840..04d2724f94f1 100644 --- a/dbaccess/source/ui/inc/QueryDesignView.hxx +++ b/dbaccess/source/ui/inc/QueryDesignView.hxx @@ -64,18 +64,19 @@ namespace dbaui NONE }; - Splitter m_aSplitter; + VclPtr<Splitter> m_aSplitter; ::com::sun::star::lang::Locale m_aLocale; - OUString m_sDecimalSep; + OUString m_sDecimalSep; - OSelectionBrowseBox* m_pSelectionBox; // presents the lower window + VclPtr<OSelectionBrowseBox> m_pSelectionBox; // presents the lower window ChildFocusState m_eChildFocus; - bool m_bInSplitHandler; + bool m_bInSplitHandler; public: OQueryDesignView(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); virtual ~OQueryDesignView(); + virtual void dispose() SAL_OVERRIDE; virtual bool isCutAllowed() SAL_OVERRIDE; virtual bool isPasteAllowed() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx index 6b19daedb287..a083b4cca893 100644 --- a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx +++ b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx @@ -30,16 +30,16 @@ public: QueryPropertiesDialog( vcl::Window* pParent, const bool bDistinct, const sal_Int64 nLimit ); virtual ~QueryPropertiesDialog(); - + virtual void dispose() SAL_OVERRIDE; bool getDistinct() const; sal_Int64 getLimit() const; private: - RadioButton* m_pRB_Distinct; - RadioButton* m_pRB_NonDistinct; + VclPtr<RadioButton> m_pRB_Distinct; + VclPtr<RadioButton> m_pRB_NonDistinct; - LimitBox* m_pLB_Limit; + VclPtr<LimitBox> m_pLB_Limit; }; diff --git a/dbaccess/source/ui/inc/QueryTableView.hxx b/dbaccess/source/ui/inc/QueryTableView.hxx index 5bac4fb4d2b0..3b8d74618bd9 100644 --- a/dbaccess/source/ui/inc/QueryTableView.hxx +++ b/dbaccess/source/ui/inc/QueryTableView.hxx @@ -47,7 +47,7 @@ namespace dbaui virtual void ConnDoubleClicked(OTableConnection* pConnection) SAL_OVERRIDE; virtual void KeyInput(const KeyEvent& rEvt) SAL_OVERRIDE; - virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData) SAL_OVERRIDE; + virtual VclPtr<OTableWindow> createWindow(const TTableWindowData::value_type& _pData) SAL_OVERRIDE; /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no exception was thrown. @@ -58,7 +58,6 @@ namespace dbaui public: OQueryTableView(vcl::Window* pParent,OQueryDesignView* pView); - virtual ~OQueryTableView(); /// base class overwritten: create and delete windows /// (not really delete, as it becomes an UndoAction) diff --git a/dbaccess/source/ui/inc/QueryTextView.hxx b/dbaccess/source/ui/inc/QueryTextView.hxx index 5d9cff71e4e4..ff447f27a476 100644 --- a/dbaccess/source/ui/inc/QueryTextView.hxx +++ b/dbaccess/source/ui/inc/QueryTextView.hxx @@ -28,10 +28,11 @@ namespace dbaui class OQueryTextView : public vcl::Window { friend class OQueryViewSwitch; - OSqlEdit* m_pEdit; + VclPtr<OSqlEdit> m_pEdit; public: OQueryTextView( OQueryContainerWindow* pParent ); virtual ~OQueryTextView(); + virtual void dispose() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/QueryViewSwitch.hxx b/dbaccess/source/ui/inc/QueryViewSwitch.hxx index e6f936a57617..ccf45802c394 100644 --- a/dbaccess/source/ui/inc/QueryViewSwitch.hxx +++ b/dbaccess/source/ui/inc/QueryViewSwitch.hxx @@ -34,8 +34,8 @@ namespace dbaui class OQueryContainerWindow; class OQueryViewSwitch { - OQueryDesignView* m_pDesignView; - OQueryTextView* m_pTextView; + VclPtr<OQueryDesignView> m_pDesignView; + VclPtr<OQueryTextView> m_pTextView; bool m_bAddTableDialogWasVisible; // true if so public: OQueryViewSwitch(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); diff --git a/dbaccess/source/ui/inc/RelationControl.hxx b/dbaccess/source/ui/inc/RelationControl.hxx index a04c08d5f9ca..12973d55b9f5 100644 --- a/dbaccess/source/ui/inc/RelationControl.hxx +++ b/dbaccess/source/ui/inc/RelationControl.hxx @@ -32,10 +32,10 @@ namespace dbaui class OTableListBoxControl { - ListBox* m_pLeftTable; - ListBox* m_pRightTable; + VclPtr<ListBox> m_pLeftTable; + VclPtr<ListBox> m_pRightTable; - ORelationControl* m_pRC_Tables; + VclPtr<ORelationControl> m_pRC_Tables; const OJoinTableView::OTableWindowMap* m_pTableMap; IRelationControlInterface* m_pParentDialog; OUString m_strCurrentLeft; diff --git a/dbaccess/source/ui/inc/RelationDesignView.hxx b/dbaccess/source/ui/inc/RelationDesignView.hxx index f7a97a9687f5..7f1559427eb9 100644 --- a/dbaccess/source/ui/inc/RelationDesignView.hxx +++ b/dbaccess/source/ui/inc/RelationDesignView.hxx @@ -33,7 +33,6 @@ namespace dbaui { public: ORelationDesignView(vcl::Window* pParent, ORelationController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); - virtual ~ORelationDesignView(); // set the statement for representation /// late construction diff --git a/dbaccess/source/ui/inc/RelationDlg.hxx b/dbaccess/source/ui/inc/RelationDlg.hxx index 5950d64f7502..3435632c08f8 100644 --- a/dbaccess/source/ui/inc/RelationDlg.hxx +++ b/dbaccess/source/ui/inc/RelationDlg.hxx @@ -27,11 +27,11 @@ #include "JoinTableView.hxx" #include "RelControliFace.hxx" #include "moduledbu.hxx" +#include "RelationControl.hxx" namespace dbaui { class OJoinTableView; - class OTableListBoxControl; class ORelationDialog : public ModalDialog ,public IRelationControlInterface { @@ -39,16 +39,16 @@ namespace dbaui boost::scoped_ptr<OTableListBoxControl> m_xTableControl; OJoinTableView::OTableWindowMap* m_pTableMap; - RadioButton* m_pRB_NoCascUpd; - RadioButton* m_pRB_CascUpd; - RadioButton* m_pRB_CascUpdNull; - RadioButton* m_pRB_CascUpdDefault; - RadioButton* m_pRB_NoCascDel; - RadioButton* m_pRB_CascDel; - RadioButton* m_pRB_CascDelNull; - RadioButton* m_pRB_CascDelDefault; + VclPtr<RadioButton> m_pRB_NoCascUpd; + VclPtr<RadioButton> m_pRB_CascUpd; + VclPtr<RadioButton> m_pRB_CascUpdNull; + VclPtr<RadioButton> m_pRB_CascUpdDefault; + VclPtr<RadioButton> m_pRB_NoCascDel; + VclPtr<RadioButton> m_pRB_CascDel; + VclPtr<RadioButton> m_pRB_CascDelNull; + VclPtr<RadioButton> m_pRB_CascDelDefault; - OKButton* m_pPB_OK; + VclPtr<OKButton> m_pPB_OK; TTableConnectionData::value_type m_pConnData; TTableConnectionData::value_type m_pOrigConnData; @@ -61,6 +61,7 @@ namespace dbaui const TTableConnectionData::value_type& pConnectionData, bool bAllowTableSelect = false ); virtual ~ORelationDialog(); + virtual void dispose() SAL_OVERRIDE; virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() SAL_OVERRIDE { return m_xConnection; } diff --git a/dbaccess/source/ui/inc/RelationTableView.hxx b/dbaccess/source/ui/inc/RelationTableView.hxx index 9b38d8fb47b6..da09f88bf900 100644 --- a/dbaccess/source/ui/inc/RelationTableView.hxx +++ b/dbaccess/source/ui/inc/RelationTableView.hxx @@ -32,7 +32,7 @@ namespace dbaui public OJoinTableView, public ::comphelper::OContainerListener { - OTableConnection* m_pExistingConnection; ///< is set when a connection was draged on an existing connection + VclPtr<OTableConnection> m_pExistingConnection; ///< is set when a connection was draged on an existing connection TTableConnectionData::value_type m_pCurrentlyTabConnData; ///< set when we creating a connection with more than one keycolumn ::rtl::Reference< comphelper::OContainerListenerAdapter> m_pContainerListener; bool m_bInRemove; @@ -40,7 +40,7 @@ namespace dbaui virtual void ConnDoubleClicked( OTableConnection* pConnection ) SAL_OVERRIDE; virtual void AddTabWin(const OUString& _rComposedName, const OUString& rWinName, bool bNewTable = false) SAL_OVERRIDE; - virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData) SAL_OVERRIDE; + virtual VclPtr<OTableWindow> createWindow(const TTableWindowData::value_type& _pData) SAL_OVERRIDE; /** determines whether the classes Init method should accept a query name, or only table names */ @@ -54,6 +54,7 @@ namespace dbaui public: ORelationTableView( vcl::Window* pParent, ORelationDesignView* pView ); virtual ~ORelationTableView(); + virtual void dispose() SAL_OVERRIDE; virtual void RemoveTabWin( OTableWindow* pTabWin ) SAL_OVERRIDE; virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/TableConnection.hxx b/dbaccess/source/ui/inc/TableConnection.hxx index 76428fb60b24..a027fa033e5a 100644 --- a/dbaccess/source/ui/inc/TableConnection.hxx +++ b/dbaccess/source/ui/inc/TableConnection.hxx @@ -41,7 +41,7 @@ namespace dbaui ::std::vector<OConnectionLine*> m_vConnLine; TTableConnectionData::value_type m_pData; - OJoinTableView* m_pParent; + VclPtr<OJoinTableView> m_pParent; bool m_bSelected; @@ -65,6 +65,7 @@ namespace dbaui eventually. */ virtual ~OTableConnection(); + virtual void dispose() SAL_OVERRIDE; OTableConnection& operator=( const OTableConnection& rConn ); diff --git a/dbaccess/source/ui/inc/TableDesignControl.hxx b/dbaccess/source/ui/inc/TableDesignControl.hxx index 4cabf5d7dd7e..97acc014cf04 100644 --- a/dbaccess/source/ui/inc/TableDesignControl.hxx +++ b/dbaccess/source/ui/inc/TableDesignControl.hxx @@ -47,7 +47,6 @@ namespace dbaui public: OTableRowView(vcl::Window* pParent); - virtual ~OTableRowView(); virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo ) = 0; virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rNewData ) = 0; diff --git a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx index 900c32374754..bcc79095dec8 100644 --- a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx +++ b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx @@ -33,7 +33,7 @@ namespace dbaui { private: OUString m_sHelpText; - MultiLineEdit* m_pTextWin; + VclPtr<MultiLineEdit> m_pTextWin; protected: virtual void Resize() SAL_OVERRIDE; @@ -41,6 +41,7 @@ namespace dbaui public: OTableDesignHelpBar( vcl::Window* pParent ); virtual ~OTableDesignHelpBar(); + virtual void dispose() SAL_OVERRIDE; void SetHelpText( const OUString& rText ); OUString GetHelpText() const { return m_sHelpText; } diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx index 72ece65cf6cc..7a1016f6753f 100644 --- a/dbaccess/source/ui/inc/TableDesignView.hxx +++ b/dbaccess/source/ui/inc/TableDesignView.hxx @@ -32,9 +32,9 @@ namespace dbaui class OTableEditorCtrl; class OTableBorderWindow : public vcl::Window { - Splitter m_aHorzSplitter; - OTableFieldDescWin* m_pFieldDescWin; - OTableEditorCtrl* m_pEditorCtrl; + VclPtr<Splitter> m_aHorzSplitter; + VclPtr<OTableFieldDescWin> m_pFieldDescWin; + VclPtr<OTableEditorCtrl> m_pEditorCtrl; void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); void ArrangeChildren( long nSplitPos ,Rectangle& rRect); @@ -45,6 +45,7 @@ namespace dbaui OTableBorderWindow(vcl::Window* pParent); virtual ~OTableBorderWindow(); // Window overrides + virtual void dispose() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; @@ -62,7 +63,7 @@ namespace dbaui }; private: ::com::sun::star::lang::Locale m_aLocale; - OTableBorderWindow* m_pWin; + VclPtr<OTableBorderWindow> m_pWin; OTableController& m_rController; ChildFocusState m_eChildFocus; @@ -77,6 +78,7 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&, OTableController& _rController); virtual ~OTableDesignView(); + virtual void dispose() SAL_OVERRIDE; // Window overrides virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx index 9a6992bd732c..d8e5f3d524d2 100644 --- a/dbaccess/source/ui/inc/TableFieldDescription.hxx +++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx @@ -25,6 +25,7 @@ #include <rtl/ustring.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <rtl/ref.hxx> +#include <vcl/vclptr.hxx> #include <salhelper/simplereferenceobject.hxx> @@ -49,7 +50,7 @@ namespace dbaui OUString m_aFieldAlias; ///< column alias OUString m_aFunctionName;///< contains the function name (only if m_eFunctionType != FKT_NONE) - vcl::Window* m_pTabWindow; + VclPtr<vcl::Window> m_pTabWindow; sal_Int32 m_eDataType; sal_Int32 m_eFunctionType; diff --git a/dbaccess/source/ui/inc/TableGrantCtrl.hxx b/dbaccess/source/ui/inc/TableGrantCtrl.hxx index c16cba5d5568..5f80e75fcbf3 100644 --- a/dbaccess/source/ui/inc/TableGrantCtrl.hxx +++ b/dbaccess/source/ui/inc/TableGrantCtrl.hxx @@ -53,14 +53,15 @@ class OTableGrantControl : public ::svt::EditBrowseBox mutable TTablePrivilegeMap m_aPrivMap; OUString m_sUserName; - ::svt::CheckBoxControl* m_pCheckCell; - Edit* m_pEdit; + VclPtr<::svt::CheckBoxControl> m_pCheckCell; + VclPtr<Edit> m_pEdit; long m_nDataPos; ImplSVEvent * m_nDeactivateEvent; public: OTableGrantControl( vcl::Window* pParent, WinBits nBits); virtual ~OTableGrantControl(); + virtual void dispose() SAL_OVERRIDE; void UpdateTables(); void setUserName(const OUString& _sUserName); void setGrantUser(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable>& _xGrantUser); diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx index 004139a5cb95..2d1aac671a01 100644 --- a/dbaccess/source/ui/inc/TableWindow.hxx +++ b/dbaccess/source/ui/inc/TableWindow.hxx @@ -54,9 +54,9 @@ namespace dbaui friend class OTableWindowListBox; protected: // and the table itself (needed for me as I want to lock it as long as the window is alive) - FixedImage m_aTypeImage; - OTableWindowTitle m_aTitle; - OTableWindowListBox* m_pListBox; + VclPtr<FixedImage> m_aTypeImage; + VclPtr<OTableWindowTitle> m_aTitle; + VclPtr<OTableWindowListBox> m_pListBox; OTableWindowAccess* m_pAccessible; private: @@ -82,7 +82,7 @@ namespace dbaui virtual void MouseButtonDown( const MouseEvent& rEvt ) SAL_OVERRIDE; virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; - OTableWindowListBox* CreateListBox(); + VclPtr<OTableWindowListBox> CreateListBox(); // called at FIRST Init bool FillListBox(); // called at EACH Init @@ -125,6 +125,7 @@ namespace dbaui public: virtual ~OTableWindow(); + virtual void dispose() SAL_OVERRIDE; // late Constructor, see also CreateListbox and FillListbox virtual bool Init(); @@ -148,7 +149,7 @@ namespace dbaui OUString GetComposedName() const { return m_pData->GetComposedName(); } OTableWindowListBox* GetListBox() const { return m_pListBox; } TTableWindowData::value_type GetData() const { return m_pData; } - OTableWindowTitle& GetTitleCtrl() { return m_aTitle; } + OTableWindowTitle& GetTitleCtrl() { return *m_aTitle.get(); } /** returns the name which should be used when displaying join or relations @return diff --git a/dbaccess/source/ui/inc/TableWindowAccess.hxx b/dbaccess/source/ui/inc/TableWindowAccess.hxx index 305f89838f20..c03871c2b7ea 100644 --- a/dbaccess/source/ui/inc/TableWindowAccess.hxx +++ b/dbaccess/source/ui/inc/TableWindowAccess.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <cppuhelper/implbase2.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <vcl/vclptr.hxx> namespace dbaui { @@ -35,7 +36,7 @@ namespace dbaui class OTableWindowAccess : public VCLXAccessibleComponent , public OTableWindowAccess_BASE { - OTableWindow* m_pTable; // the window which I should give accessibility to + VclPtr<OTableWindow> m_pTable; // the window which I should give accessibility to ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getParentChild(sal_Int32 _nIndex); protected: diff --git a/dbaccess/source/ui/inc/TableWindowListBox.hxx b/dbaccess/source/ui/inc/TableWindowListBox.hxx index 13f30c6437fb..dfd8f4b39e21 100644 --- a/dbaccess/source/ui/inc/TableWindowListBox.hxx +++ b/dbaccess/source/ui/inc/TableWindowListBox.hxx @@ -30,7 +30,7 @@ namespace dbaui struct OJoinExchangeData { public: - OTableWindowListBox* pListBox; // the ListBox inside the same (you can get the TabWin and the WinName out of it) + VclPtr<OTableWindowListBox> pListBox; // the ListBox inside the same (you can get the TabWin and the WinName out of it) SvTreeListEntry* pEntry; // the entry, which was dragged or to which was dropped on OJoinExchangeData(OTableWindowListBox* pBox); @@ -56,7 +56,7 @@ namespace dbaui Timer m_aScrollTimer; Point m_aMousePos; - OTableWindow* m_pTabWin; + VclPtr<OTableWindow> m_pTabWin; ImplSVEvent * m_nDropEvent; ImplSVEvent * m_nUiEvent; OJoinDropData m_aDropInfo; @@ -78,6 +78,7 @@ namespace dbaui public: OTableWindowListBox(OTableWindow* pParent); virtual ~OTableWindowListBox(); + virtual void dispose() SAL_OVERRIDE; // DnD stuff virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx index 77ac0d4ce89f..3d009e3c603e 100644 --- a/dbaccess/source/ui/inc/TableWindowTitle.hxx +++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx @@ -26,7 +26,7 @@ namespace dbaui class OTableWindow; class OTableWindowTitle : public FixedText { - OTableWindow* m_pTabWin; + VclPtr<OTableWindow> m_pTabWin; protected: virtual void Command(const CommandEvent& rEvt) SAL_OVERRIDE; @@ -38,6 +38,7 @@ namespace dbaui public: OTableWindowTitle( OTableWindow* pParent ); virtual ~OTableWindowTitle(); + virtual void dispose() SAL_OVERRIDE; virtual void LoseFocus() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/TablesSingleDlg.hxx b/dbaccess/source/ui/inc/TablesSingleDlg.hxx index 7b0bf1651d2a..51977b928e4c 100644 --- a/dbaccess/source/ui/inc/TablesSingleDlg.hxx +++ b/dbaccess/source/ui/inc/TablesSingleDlg.hxx @@ -55,6 +55,7 @@ class ODbDataSourceAdministrationHelper; ,const ::com::sun::star::uno::Any& _aDataSourceName ); virtual ~OTableSubscriptionDialog(); + virtual void dispose() SAL_OVERRIDE; // forwards from ODbDataSourceAdministrationHelper void successfullyConnected(); diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx index 6e0cc172a7b7..35b81ad01ea4 100644 --- a/dbaccess/source/ui/inc/TokenWriter.hxx +++ b/dbaccess/source/ui/inc/TokenWriter.hxx @@ -196,7 +196,7 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xTargetRowUpdate; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData; - vcl::Window* m_pParent; + VclPtr<vcl::Window> m_pParent; bool m_bAlreadyAsked; bool insertNewRow(); diff --git a/dbaccess/source/ui/inc/UserAdminDlg.hxx b/dbaccess/source/ui/inc/UserAdminDlg.hxx index a003fe898e3e..cc2df632a9f5 100644 --- a/dbaccess/source/ui/inc/UserAdminDlg.hxx +++ b/dbaccess/source/ui/inc/UserAdminDlg.hxx @@ -60,6 +60,7 @@ namespace dbaui ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection); virtual ~OUserAdminDlg(); + virtual void dispose() SAL_OVERRIDE; virtual const SfxItemSet* getOutputSet() const SAL_OVERRIDE; virtual SfxItemSet* getWriteOutputSet() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/VertSplitView.hxx b/dbaccess/source/ui/inc/VertSplitView.hxx index 4a91f47e05d5..ac7bde548eed 100644 --- a/dbaccess/source/ui/inc/VertSplitView.hxx +++ b/dbaccess/source/ui/inc/VertSplitView.hxx @@ -27,9 +27,9 @@ namespace dbaui { class OSplitterView : public vcl::Window { - Splitter* m_pSplitter; - vcl::Window* m_pLeft; - vcl::Window* m_pRight; + VclPtr<Splitter> m_pSplitter; + VclPtr<vcl::Window> m_pLeft; + VclPtr<vcl::Window> m_pRight; bool m_bVertical; void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); @@ -40,6 +40,7 @@ namespace dbaui OSplitterView(vcl::Window* _pParent,bool _bVertical = true); virtual ~OSplitterView(); // Window overrides + virtual void dispose() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; void setSplitter(Splitter* _pSplitter); diff --git a/dbaccess/source/ui/inc/WCPage.hxx b/dbaccess/source/ui/inc/WCPage.hxx index e99fcf810529..008a9376ce01 100644 --- a/dbaccess/source/ui/inc/WCPage.hxx +++ b/dbaccess/source/ui/inc/WCPage.hxx @@ -34,19 +34,19 @@ namespace dbaui class OCopyTable : public OWizardPage { protected: - Edit* m_pEdTableName; - RadioButton* m_pRB_DefData; - RadioButton* m_pRB_Def; - RadioButton* m_pRB_View; - RadioButton* m_pRB_AppendData; - CheckBox* m_pCB_UseHeaderLine; - CheckBox* m_pCB_PrimaryColumn; - FixedText* m_pFT_KeyName; - Edit* m_pEdKeyName; + VclPtr<Edit> m_pEdTableName; + VclPtr<RadioButton> m_pRB_DefData; + VclPtr<RadioButton> m_pRB_Def; + VclPtr<RadioButton> m_pRB_View; + VclPtr<RadioButton> m_pRB_AppendData; + VclPtr<CheckBox> m_pCB_UseHeaderLine; + VclPtr<CheckBox> m_pCB_PrimaryColumn; + VclPtr<FixedText> m_pFT_KeyName; + VclPtr<Edit> m_pEdKeyName; sal_Int16 m_nOldOperation; - OWizColumnSelect* m_pPage2; - OWizNormalExtend* m_pPage3; + VclPtr<OWizColumnSelect> m_pPage2; + VclPtr<OWizNormalExtend> m_pPage3; bool m_bPKeyAllowed; bool m_bUseHeaderAllowed; @@ -66,6 +66,7 @@ namespace dbaui OCopyTable( vcl::Window * pParent ); virtual ~OCopyTable(); + virtual void dispose() SAL_OVERRIDE; bool IsOptionDefData() const { return m_pRB_DefData->IsChecked(); } bool IsOptionDef() const { return m_pRB_Def->IsChecked(); } diff --git a/dbaccess/source/ui/inc/WColumnSelect.hxx b/dbaccess/source/ui/inc/WColumnSelect.hxx index 98f029c6c665..9b08f6b97f0d 100644 --- a/dbaccess/source/ui/inc/WColumnSelect.hxx +++ b/dbaccess/source/ui/inc/WColumnSelect.hxx @@ -35,12 +35,12 @@ namespace dbaui class OWizColumnSelect : public OWizardPage { - ListBox* m_pOrgColumnNames; // left side - PushButton* m_pColumn_RH; - PushButton* m_pColumns_RH; - PushButton* m_pColumn_LH; - PushButton* m_pColumns_LH; - ListBox* m_pNewColumnNames; // right side + VclPtr<ListBox> m_pOrgColumnNames; // left side + VclPtr<PushButton> m_pColumn_RH; + VclPtr<PushButton> m_pColumns_RH; + VclPtr<PushButton> m_pColumn_LH; + VclPtr<PushButton> m_pColumns_LH; + VclPtr<ListBox> m_pNewColumnNames; // right side DECL_LINK( ButtonClickHdl, Button * ); DECL_LINK( ListDoubleClickHdl, ListBox * ); @@ -80,6 +80,7 @@ namespace dbaui OWizColumnSelect(vcl::Window* pParent); virtual ~OWizColumnSelect(); + virtual void dispose() SAL_OVERRIDE; }; } #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_WCOLUMNSELECT_HXX diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx index 32fa0a79e9cc..8a10f01cc795 100644 --- a/dbaccess/source/ui/inc/WCopyTable.hxx +++ b/dbaccess/source/ui/inc/WCopyTable.hxx @@ -238,11 +238,11 @@ namespace dbaui ODatabaseExport::TColumns m_vSourceColumns; ODatabaseExport::TColumnVector m_vSourceVec; - HelpButton* m_pbHelp; - CancelButton* m_pbCancel; - PushButton* m_pbPrev; - PushButton* m_pbNext; - PushButton* m_pbFinish; + VclPtr<HelpButton> m_pbHelp; + VclPtr<CancelButton> m_pbCancel; + VclPtr<PushButton> m_pbPrev; + VclPtr<PushButton> m_pbNext; + VclPtr<PushButton> m_pbFinish; OTypeInfoMap m_aTypeInfo; ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex; @@ -323,6 +323,7 @@ namespace dbaui ); virtual ~OCopyTableWizard(); + virtual void dispose() SAL_OVERRIDE; virtual bool DeactivatePage() SAL_OVERRIDE; OKButton& GetOKButton() { return static_cast<OKButton&>(*m_pbFinish); } diff --git a/dbaccess/source/ui/inc/WExtendPages.hxx b/dbaccess/source/ui/inc/WExtendPages.hxx index e9d19621457f..e51abe09a9bd 100644 --- a/dbaccess/source/ui/inc/WExtendPages.hxx +++ b/dbaccess/source/ui/inc/WExtendPages.hxx @@ -35,9 +35,7 @@ namespace dbaui { } - static OWizTypeSelect* Create( vcl::Window* _pParent, SvStream& _rInput ) { return new OWizHTMLExtend( _pParent, _rInput ); } - - virtual ~OWizHTMLExtend(){} + static VclPtr<OWizTypeSelect> Create( vcl::Window* _pParent, SvStream& _rInput ) { return VclPtr<OWizHTMLExtend>::Create( _pParent, _rInput ); } }; // Wizard Page: OWizRTFExtend class OWizRTFExtend : public OWizTypeSelect @@ -50,9 +48,7 @@ namespace dbaui { } - static OWizTypeSelect* Create( vcl::Window* _pParent, SvStream& _rInput ) { return new OWizRTFExtend( _pParent, _rInput ); } - - virtual ~OWizRTFExtend(){} + static VclPtr<OWizTypeSelect> Create( vcl::Window* _pParent, SvStream& _rInput ) { return VclPtr<OWizRTFExtend>::Create( _pParent, _rInput ); } }; // Wizard Page: OWizNormalExtend diff --git a/dbaccess/source/ui/inc/WNameMatch.hxx b/dbaccess/source/ui/inc/WNameMatch.hxx index 3feb7dc28e01..61f71b56ce47 100644 --- a/dbaccess/source/ui/inc/WNameMatch.hxx +++ b/dbaccess/source/ui/inc/WNameMatch.hxx @@ -50,16 +50,16 @@ namespace dbaui // Name matching for data appending class OWizNameMatching : public OWizardPage { - FixedText *m_pTABLE_LEFT; - FixedText *m_pTABLE_RIGHT; - OColumnTreeBox *m_pCTRL_LEFT; // left side - OColumnTreeBox *m_pCTRL_RIGHT; // right side - PushButton *m_pColumn_up; - PushButton *m_pColumn_down; - PushButton *m_pColumn_up_right; - PushButton *m_pColumn_down_right; - PushButton *m_pAll; - PushButton *m_pNone; + VclPtr<FixedText> m_pTABLE_LEFT; + VclPtr<FixedText> m_pTABLE_RIGHT; + VclPtr<OColumnTreeBox> m_pCTRL_LEFT; // left side + VclPtr<OColumnTreeBox> m_pCTRL_RIGHT; // right side + VclPtr<PushButton> m_pColumn_up; + VclPtr<PushButton> m_pColumn_down; + VclPtr<PushButton> m_pColumn_up_right; + VclPtr<PushButton> m_pColumn_down_right; + VclPtr<PushButton> m_pAll; + VclPtr<PushButton> m_pNone; OUString m_sSourceText; OUString m_sDestText; Image m_aImgUp; @@ -79,7 +79,7 @@ namespace dbaui OWizNameMatching(vcl::Window* pParent); virtual ~OWizNameMatching(); - + virtual void dispose() SAL_OVERRIDE; }; } #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_WNAMEMATCH_HXX diff --git a/dbaccess/source/ui/inc/WTabPage.hxx b/dbaccess/source/ui/inc/WTabPage.hxx index 9a30d7c311fb..6a5d3ab48eb1 100644 --- a/dbaccess/source/ui/inc/WTabPage.hxx +++ b/dbaccess/source/ui/inc/WTabPage.hxx @@ -29,12 +29,14 @@ namespace dbaui class OWizardPage : public TabPage { protected: - OCopyTableWizard* m_pParent; + VclPtr<OCopyTableWizard> m_pParent; bool m_bFirstTime; // Page wird das erste mal gerufen ; should be set in the reset methode OWizardPage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription ); public: + virtual ~OWizardPage(); + virtual void dispose() SAL_OVERRIDE; virtual void Reset ( ) = 0; virtual bool LeavePage() = 0; virtual OUString GetTitle() const = 0; diff --git a/dbaccess/source/ui/inc/WTypeSelect.hxx b/dbaccess/source/ui/inc/WTypeSelect.hxx index 5f587481e867..d86c70e5f07a 100644 --- a/dbaccess/source/ui/inc/WTypeSelect.hxx +++ b/dbaccess/source/ui/inc/WTypeSelect.hxx @@ -37,7 +37,7 @@ namespace dbaui class OWizTypeSelectControl : public OFieldDescControl { protected: - vcl::Window* m_pParentTabPage; + VclPtr<vcl::Window> m_pParentTabPage; virtual void ActivateAggregate( EControlType eType ) SAL_OVERRIDE; virtual void DeactivateAggregate( EControlType eType ) SAL_OVERRIDE; @@ -53,6 +53,7 @@ namespace dbaui public: OWizTypeSelectControl(vcl::Window* pParent, vcl::Window* pParentTabPage, OTableDesignHelpBar* pHelpBar=NULL); virtual ~OWizTypeSelectControl(); + virtual void dispose() SAL_OVERRIDE; virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() SAL_OVERRIDE; virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() SAL_OVERRIDE; @@ -69,13 +70,15 @@ namespace dbaui bool _bSet = false); protected: virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE; - vcl::Window* m_pParentTabPage; + VclPtr<vcl::Window> m_pParentTabPage; public: OWizTypeSelectList( vcl::Window* pParent, WinBits nStyle = WB_BORDER ) : MultiListBox(pParent,nStyle) , m_bPKey(false) , m_pParentTabPage(NULL) {} + virtual ~OWizTypeSelectList(); + virtual void dispose() SAL_OVERRIDE; void SetPKey(bool bPKey) { m_bPKey = bPKey; } void SetParentTabPage(vcl::Window* pParentTabPage) { m_pParentTabPage = pParentTabPage; } }; @@ -91,13 +94,13 @@ namespace dbaui DECL_LINK( ColumnSelectHdl, MultiListBox* ); DECL_LINK( ButtonClickHdl, Button * ); protected: - OWizTypeSelectList *m_pColumnNames; - FixedText *m_pColumns; - OWizTypeSelectControl *m_pTypeControl; - FixedText *m_pAutoType; - FixedText *m_pAutoFt; - NumericField *m_pAutoEt; - PushButton *m_pAutoPb; + VclPtr<OWizTypeSelectList> m_pColumnNames; + VclPtr<FixedText> m_pColumns; + VclPtr<OWizTypeSelectControl> m_pTypeControl; + VclPtr<FixedText> m_pAutoType; + VclPtr<FixedText> m_pAutoFt; + VclPtr<NumericField> m_pAutoEt; + VclPtr<PushButton> m_pAutoPb; Image m_imgPKey; SvStream* m_pParserStream; // stream to read the tokens from or NULL @@ -118,12 +121,13 @@ namespace dbaui OWizTypeSelect(vcl::Window* pParent, SvStream* _pStream = NULL ); virtual ~OWizTypeSelect(); + virtual void dispose() SAL_OVERRIDE; inline void setDisplayRow(sal_Int32 _nRow) { m_nDisplayRow = _nRow - 1; } inline void setDuplicateName(bool _bDuplicateName) { m_bDuplicateName = _bDuplicateName; } }; - typedef OWizTypeSelect* (*TypeSelectionPageFactory)( vcl::Window*, SvStream& ); + typedef VclPtr<OWizTypeSelect> (*TypeSelectionPageFactory)( vcl::Window*, SvStream& ); } #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_WTYPESELECT_HXX diff --git a/dbaccess/source/ui/inc/adtabdlg.hxx b/dbaccess/source/ui/inc/adtabdlg.hxx index 360ee70fa9eb..815f8c4d566a 100644 --- a/dbaccess/source/ui/inc/adtabdlg.hxx +++ b/dbaccess/source/ui/inc/adtabdlg.hxx @@ -58,15 +58,15 @@ namespace dbaui class OAddTableDlg : public ModelessDialog { - RadioButton* m_pCaseTables; - RadioButton* m_pCaseQueries; + VclPtr<RadioButton> m_pCaseTables; + VclPtr<RadioButton> m_pCaseQueries; - OTableTreeListBox* m_pTableList; - SvTreeListBox* m_pQueryList; + VclPtr<OTableTreeListBox> m_pTableList; + VclPtr<SvTreeListBox> m_pQueryList; boost::scoped_ptr< TableObjectListFacade > m_xCurrentList; - PushButton* m_pAddButton; - PushButton* m_pCloseButton; + VclPtr<PushButton> m_pAddButton; + VclPtr<PushButton> m_pCloseButton; IAddTableDialogContext& m_rContext; @@ -81,6 +81,7 @@ namespace dbaui vcl::Window* _pParent, IAddTableDialogContext& _rContext ); virtual ~OAddTableDlg(); + virtual void dispose() SAL_OVERRIDE; void DetermineAddTable() { m_pAddButton->Enable( impl_isAddAllowed() ); } void Update(); diff --git a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx index 108467ac78f8..2ba76b55466c 100644 --- a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx +++ b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx @@ -51,6 +51,7 @@ namespace dbaui ,const ::com::sun::star::uno::Any& _aDataSourceName); virtual ~AdvancedSettingsDialog(); + virtual void dispose() SAL_OVERRIDE; /// determines whether or not the given data source type has any advanced setting static bool doesHaveAnyAdvancedSettings( const OUString& _sURL ); diff --git a/dbaccess/source/ui/inc/brwview.hxx b/dbaccess/source/ui/inc/brwview.hxx index a214e462e08e..e68ff09847c4 100644 --- a/dbaccess/source/ui/inc/brwview.hxx +++ b/dbaccess/source/ui/inc/brwview.hxx @@ -46,10 +46,10 @@ namespace dbaui protected: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xGrid; // our grid's UNO representation ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xMe; // our own UNO representation - DBTreeView* m_pTreeView; - Splitter* m_pSplitter; - mutable SbaGridControl* m_pVclControl; // our grid's VCL representation - vcl::Window* m_pStatus; + VclPtr<DBTreeView> m_pTreeView; + VclPtr<Splitter> m_pSplitter; + mutable VclPtr<SbaGridControl> m_pVclControl; // our grid's VCL representation + VclPtr<vcl::Window> m_pStatus; DECL_LINK( SplitHdl, void* ); // attribute access @@ -62,6 +62,7 @@ namespace dbaui IController& _rController, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); virtual ~UnoDataBrowserView(); + virtual void dispose() SAL_OVERRIDE; /// late construction void Construct(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xModel); @@ -93,7 +94,7 @@ namespace dbaui class BrowserViewStatusDisplay { protected: - UnoDataBrowserView* m_pView; + VclPtr<UnoDataBrowserView> m_pView; public: BrowserViewStatusDisplay( UnoDataBrowserView* _pView, const OUString& _rStatus ); diff --git a/dbaccess/source/ui/inc/charsetlistbox.hxx b/dbaccess/source/ui/inc/charsetlistbox.hxx index 78f2da4f4a28..02641062174a 100644 --- a/dbaccess/source/ui/inc/charsetlistbox.hxx +++ b/dbaccess/source/ui/inc/charsetlistbox.hxx @@ -34,7 +34,6 @@ namespace dbaui { public: CharSetListBox( vcl::Window* _pParent, WinBits _nBits ); - virtual ~CharSetListBox(); void SelectEntryByIanaName( const OUString& _rIanaName ); bool StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId ); diff --git a/dbaccess/source/ui/inc/curledit.hxx b/dbaccess/source/ui/inc/curledit.hxx index cb9201328ada..4dff5e14ca9f 100644 --- a/dbaccess/source/ui/inc/curledit.hxx +++ b/dbaccess/source/ui/inc/curledit.hxx @@ -36,13 +36,14 @@ class OConnectionURLEdit : public Edit { ::dbaccess::ODsnTypeCollection* m_pTypeCollection; - FixedText* m_pForcedPrefix; + VclPtr<FixedText> m_pForcedPrefix; OUString m_sSaveValueNoPrefix; bool m_bShowPrefix; // when <TRUE> the prefix will be visible, otherwise not public: OConnectionURLEdit(vcl::Window* pParent, WinBits _nBits,bool _bShowPrefix = false); virtual ~OConnectionURLEdit(); + virtual void dispose() SAL_OVERRIDE; public: // Edit overridables diff --git a/dbaccess/source/ui/inc/datasourceconnector.hxx b/dbaccess/source/ui/inc/datasourceconnector.hxx index f5d64a0f48cd..c5459ecbe15b 100644 --- a/dbaccess/source/ui/inc/datasourceconnector.hxx +++ b/dbaccess/source/ui/inc/datasourceconnector.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> +#include <vcl/vclptr.hxx> namespace dbtools { @@ -38,10 +39,10 @@ namespace dbaui class ODatasourceConnector { protected: - vcl::Window* m_pErrorMessageParent; + VclPtr<vcl::Window> m_pErrorMessageParent; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > - m_xContext; - OUString m_sContextInformation; + m_xContext; + OUString m_sContextInformation; public: ODatasourceConnector( diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx index 7c437d6f1ab7..0510cd6fa10d 100644 --- a/dbaccess/source/ui/inc/dbadmin.hxx +++ b/dbaccess/source/ui/inc/dbadmin.hxx @@ -66,6 +66,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB ); virtual ~ODbAdminDialog(); + virtual void dispose() SAL_OVERRIDE; /** create and return an item set for use with the dialog. @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx index 0a5b71da3809..cbeb1b6e540f 100644 --- a/dbaccess/source/ui/inc/dbtreelistbox.hxx +++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx @@ -84,6 +84,7 @@ namespace dbaui ,WinBits nWinStyle=0 ,bool _bHandleEnterKey = false); virtual ~DBTreeListBox(); + virtual void dispose() SAL_OVERRIDE; void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; } void setContextMenuProvider( IContextMenuProvider* _pContextMenuProvider ) { m_pContextMenuProvider = _pContextMenuProvider; } diff --git a/dbaccess/source/ui/inc/dbwiz.hxx b/dbaccess/source/ui/inc/dbwiz.hxx index d86e027a0092..ce534eba107d 100644 --- a/dbaccess/source/ui/inc/dbwiz.hxx +++ b/dbaccess/source/ui/inc/dbwiz.hxx @@ -76,6 +76,7 @@ public: ,const ::com::sun::star::uno::Any& _aDataSourceName ); virtual ~ODbTypeWizDialog(); + virtual void dispose() SAL_OVERRIDE; virtual const SfxItemSet* getOutputSet() const SAL_OVERRIDE; virtual SfxItemSet* getWriteOutputSet() SAL_OVERRIDE; @@ -92,7 +93,7 @@ public: protected: /// to override to create new pages - virtual TabPage* createPage(WizardState _nState) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage(WizardState _nState) SAL_OVERRIDE; virtual WizardState determineNextState(WizardState _nCurrentState) const SAL_OVERRIDE; virtual bool leaveState(WizardState _nState) SAL_OVERRIDE; virtual ::svt::IWizardPageController* diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx index 734f967e7ef8..79926668b5d5 100644 --- a/dbaccess/source/ui/inc/dbwizsetup.hxx +++ b/dbaccess/source/ui/inc/dbwizsetup.hxx @@ -85,9 +85,9 @@ private: OUString m_sRM_FinalText; INetURLObject m_aDocURL; OUString m_sWorkPath; - OGeneralPageWizard* m_pGeneralPage; - OMySQLIntroPageSetup* m_pMySQLIntroPage; - OFinalDBPageSetup* m_pFinalPage; + VclPtr<OGeneralPageWizard> m_pGeneralPage; + VclPtr<OMySQLIntroPageSetup> m_pMySQLIntroPage; + VclPtr<OFinalDBPageSetup> m_pFinalPage; ::dbaccess::ODsnTypeCollection* m_pCollection; /// the DSN type collection instance @@ -102,6 +102,7 @@ public: ,const ::com::sun::star::uno::Any& _aDataSourceName ); virtual ~ODbTypeWizDialogSetup(); + virtual void dispose() SAL_OVERRIDE; virtual const SfxItemSet* getOutputSet() const SAL_OVERRIDE; virtual SfxItemSet* getWriteOutputSet() SAL_OVERRIDE; @@ -127,7 +128,7 @@ public: protected: /// to override to create new pages - virtual TabPage* createPage(WizardState _nState) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage(WizardState _nState) SAL_OVERRIDE; virtual bool leaveState(WizardState _nState) SAL_OVERRIDE; virtual void enterState(WizardState _nState) SAL_OVERRIDE; virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx index 401b46df7f8e..60a5d05f6b84 100644 --- a/dbaccess/source/ui/inc/directsql.hxx +++ b/dbaccess/source/ui/inc/directsql.hxx @@ -49,13 +49,13 @@ namespace dbaui OModuleClient m_aModuleClient; ::osl::Mutex m_aMutex; - MultiLineEditSyntaxHighlight* m_pSQL; - PushButton* m_pExecute; - ListBox* m_pSQLHistory; - VclMultiLineEdit* m_pStatus; - CheckBox* m_pShowOutput; - VclMultiLineEdit* m_pOutput; - PushButton* m_pClose; + VclPtr<MultiLineEditSyntaxHighlight> m_pSQL; + VclPtr<PushButton> m_pExecute; + VclPtr<ListBox> m_pSQLHistory; + VclPtr<VclMultiLineEdit> m_pStatus; + VclPtr<CheckBox> m_pShowOutput; + VclPtr<VclMultiLineEdit> m_pOutput; + VclPtr<PushButton> m_pClose; typedef ::std::deque< OUString > StringQueue; StringQueue m_aStatementHistory; // previous statements @@ -72,6 +72,7 @@ namespace dbaui vcl::Window* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn); virtual ~DirectSQLDialog(); + virtual void dispose() SAL_OVERRIDE; /// number of history entries sal_Int32 getHistorySize() const; diff --git a/dbaccess/source/ui/inc/dlgattr.hxx b/dbaccess/source/ui/inc/dlgattr.hxx index b6614cf62701..4bf07d1b3406 100644 --- a/dbaccess/source/ui/inc/dlgattr.hxx +++ b/dbaccess/source/ui/inc/dlgattr.hxx @@ -35,6 +35,7 @@ namespace dbaui public: SbaSbAttrDlg(vcl::Window * pParent, const SfxItemSet*, SvNumberFormatter*, bool bHasFormat, bool bRow = false); virtual ~SbaSbAttrDlg(); + virtual void dispose() SAL_OVERRIDE; virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) SAL_OVERRIDE; }; diff --git a/dbaccess/source/ui/inc/dlgsave.hxx b/dbaccess/source/ui/inc/dlgsave.hxx index 5217e1fcb0a0..38c0f5b7c2d8 100644 --- a/dbaccess/source/ui/inc/dlgsave.hxx +++ b/dbaccess/source/ui/inc/dlgsave.hxx @@ -66,6 +66,7 @@ namespace dbaui const IObjectNameCheck& _rObjectNameCheck, sal_Int32 _nFlags = SAD_DEFAULT | SAD_TITLE_STORE_AS); virtual ~OSaveAsDlg(); + virtual void dispose() SAL_OVERRIDE; OUString getName() const; OUString getCatalog() const; diff --git a/dbaccess/source/ui/inc/dlgsize.hxx b/dbaccess/source/ui/inc/dlgsize.hxx index e145cf7675ad..1d51ed11a534 100644 --- a/dbaccess/source/ui/inc/dlgsize.hxx +++ b/dbaccess/source/ui/inc/dlgsize.hxx @@ -39,11 +39,13 @@ namespace dbaui protected: DECL_LINK( CbClickHdl, Button * ); - MetricField* m_pMF_VALUE; - CheckBox* m_pCB_STANDARD; + VclPtr<MetricField> m_pMF_VALUE; + VclPtr<CheckBox> m_pCB_STANDARD; public: DlgSize( vcl::Window * pParent, sal_Int32 nVal, bool bRow, sal_Int32 _nAlternativeStandard = -1 ); + virtual ~DlgSize(); + virtual void dispose() SAL_OVERRIDE; sal_Int32 GetValue(); }; } // namespace dbaui diff --git a/dbaccess/source/ui/inc/indexdialog.hxx b/dbaccess/source/ui/inc/indexdialog.hxx index f204c8c3cf89..bd595e012263 100644 --- a/dbaccess/source/ui/inc/indexdialog.hxx +++ b/dbaccess/source/ui/inc/indexdialog.hxx @@ -85,15 +85,15 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; SvtViewOptions m_aGeometrySettings; - ToolBox *m_pActions; - DbaIndexList *m_pIndexList; - FixedText *m_pIndexDetails; - FixedText *m_pDescriptionLabel; - FixedText *m_pDescription; - CheckBox *m_pUnique; - FixedText *m_pFieldsLabel; - IndexFieldsControl *m_pFields; - PushButton *m_pClose; + VclPtr<ToolBox> m_pActions; + VclPtr<DbaIndexList> m_pIndexList; + VclPtr<FixedText> m_pIndexDetails; + VclPtr<FixedText> m_pDescriptionLabel; + VclPtr<FixedText> m_pDescription; + VclPtr<CheckBox> m_pUnique; + VclPtr<FixedText> m_pFieldsLabel; + VclPtr<IndexFieldsControl> m_pFields; + VclPtr<PushButton> m_pClose; OIndexCollection* m_pIndexes; SvTreeListEntry* m_pPreviousSelection; @@ -111,6 +111,7 @@ namespace dbaui sal_Int32 _nMaxColumnsInIndex ); virtual ~DbaIndexDialog(); + virtual void dispose() SAL_OVERRIDE; virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/indexfieldscontrol.hxx b/dbaccess/source/ui/inc/indexfieldscontrol.hxx index fb1347d2b3eb..3f262156d129 100644 --- a/dbaccess/source/ui/inc/indexfieldscontrol.hxx +++ b/dbaccess/source/ui/inc/indexfieldscontrol.hxx @@ -40,8 +40,8 @@ namespace dbaui Link m_aModifyHdl; - ::svt::ListBoxControl* m_pSortingCell; - ::svt::ListBoxControl* m_pFieldNameCell; + VclPtr<::svt::ListBoxControl> m_pSortingCell; + VclPtr<::svt::ListBoxControl> m_pFieldNameCell; OUString m_sAscendingText; OUString m_sDescendingText; @@ -52,6 +52,7 @@ namespace dbaui public: IndexFieldsControl( vcl::Window* _pParent, WinBits nWinStyle); virtual ~IndexFieldsControl(); + virtual void dispose() SAL_OVERRIDE; void Init(const ::com::sun::star::uno::Sequence< OUString >& _rAvailableFields, sal_Int32 _nMaxColumnsInIndex,bool _bAddIndexAppendix); diff --git a/dbaccess/source/ui/inc/linkeddocuments.hxx b/dbaccess/source/ui/inc/linkeddocuments.hxx index 7c597b24624e..a13383b71955 100644 --- a/dbaccess/source/ui/inc/linkeddocuments.hxx +++ b/dbaccess/source/ui/inc/linkeddocuments.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> #include <comphelper/namedvaluecollection.hxx> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } namespace dbaui @@ -49,7 +50,7 @@ namespace dbaui m_xConnection; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI > m_xDocumentUI; - vcl::Window* m_pDialogParent; + VclPtr<vcl::Window> m_pDialogParent; OUString m_sCurrentlyEditing; OUString m_sDataSourceName; diff --git a/dbaccess/source/ui/inc/marktree.hxx b/dbaccess/source/ui/inc/marktree.hxx index 2e10a99b82c6..f39d5281ffde 100644 --- a/dbaccess/source/ui/inc/marktree.hxx +++ b/dbaccess/source/ui/inc/marktree.hxx @@ -40,6 +40,7 @@ class OMarkableTreeListBox : public DBTreeListBox public: OMarkableTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 ); virtual ~OMarkableTreeListBox(); + virtual void dispose() SAL_OVERRIDE; virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE; virtual void CheckButtonHdl() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/paramdialog.hxx b/dbaccess/source/ui/inc/paramdialog.hxx index edc37862a366..11db9808841f 100644 --- a/dbaccess/source/ui/inc/paramdialog.hxx +++ b/dbaccess/source/ui/inc/paramdialog.hxx @@ -52,11 +52,11 @@ namespace dbaui { protected: // the controls - ListBox* m_pAllParams; - Edit* m_pParam; - PushButton* m_pTravelNext; - OKButton* m_pOKBtn; - CancelButton* m_pCancelBtn; + VclPtr<ListBox> m_pAllParams; + VclPtr<Edit> m_pParam; + VclPtr<PushButton> m_pTravelNext; + VclPtr<OKButton> m_pOKBtn; + VclPtr<CancelButton> m_pCancelBtn; sal_Int32 m_nCurrentlySelected; @@ -84,6 +84,7 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext); virtual ~OParameterDialog(); + virtual void dispose() SAL_OVERRIDE; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > getValues() const { return m_aFinalValues; } diff --git a/dbaccess/source/ui/inc/querycontainerwindow.hxx b/dbaccess/source/ui/inc/querycontainerwindow.hxx index 646c5e1488a9..5c1e151aedbe 100644 --- a/dbaccess/source/ui/inc/querycontainerwindow.hxx +++ b/dbaccess/source/ui/inc/querycontainerwindow.hxx @@ -42,14 +42,15 @@ namespace dbaui class OQueryContainerWindow : public ODataView { OQueryViewSwitch* m_pViewSwitch; - OBeamer* m_pBeamer; - Splitter* m_pSplitter; + VclPtr<OBeamer> m_pBeamer; + VclPtr<Splitter> m_pSplitter; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame2 > m_xBeamer; DECL_LINK( SplitHdl, void* ); public: OQueryContainerWindow(vcl::Window* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&); virtual ~OQueryContainerWindow(); + virtual void dispose() SAL_OVERRIDE; virtual void Construct() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx index b9d76cccca97..06cc9510080f 100644 --- a/dbaccess/source/ui/inc/queryfilter.hxx +++ b/dbaccess/source/ui/inc/queryfilter.hxx @@ -67,19 +67,19 @@ namespace dbaui ,public ::svxform::OParseContextClient { private: - ListBox* m_pLB_WHEREFIELD1; - ListBox* m_pLB_WHERECOMP1; - Edit* m_pET_WHEREVALUE1; + VclPtr<ListBox> m_pLB_WHEREFIELD1; + VclPtr<ListBox> m_pLB_WHERECOMP1; + VclPtr<Edit> m_pET_WHEREVALUE1; - ListBox* m_pLB_WHERECOND2; - ListBox* m_pLB_WHEREFIELD2; - ListBox* m_pLB_WHERECOMP2; - Edit* m_pET_WHEREVALUE2; + VclPtr<ListBox> m_pLB_WHERECOND2; + VclPtr<ListBox> m_pLB_WHEREFIELD2; + VclPtr<ListBox> m_pLB_WHERECOMP2; + VclPtr<Edit> m_pET_WHEREVALUE2; - ListBox* m_pLB_WHERECOND3; - ListBox* m_pLB_WHEREFIELD3; - ListBox* m_pLB_WHERECOMP3; - Edit* m_pET_WHEREVALUE3; + VclPtr<ListBox> m_pLB_WHERECOND3; + VclPtr<ListBox> m_pLB_WHEREFIELD3; + VclPtr<ListBox> m_pLB_WHERECOMP3; + VclPtr<Edit> m_pET_WHEREVALUE3; OUString m_aSTR_COMPARE_OPERATORS; @@ -113,6 +113,7 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols ); virtual ~DlgFilterCrit(); + virtual void dispose() SAL_OVERRIDE; void BuildWherePart(); diff --git a/dbaccess/source/ui/inc/queryorder.hxx b/dbaccess/source/ui/inc/queryorder.hxx index 007c42966a6a..46da94464b53 100644 --- a/dbaccess/source/ui/inc/queryorder.hxx +++ b/dbaccess/source/ui/inc/queryorder.hxx @@ -59,12 +59,12 @@ namespace dbaui class DlgOrderCrit : public ModalDialog { protected: - ListBox* m_pLB_ORDERFIELD1; - ListBox* m_pLB_ORDERVALUE1; - ListBox* m_pLB_ORDERFIELD2; - ListBox* m_pLB_ORDERVALUE2; - ListBox* m_pLB_ORDERFIELD3; - ListBox* m_pLB_ORDERVALUE3; + VclPtr<ListBox> m_pLB_ORDERFIELD1; + VclPtr<ListBox> m_pLB_ORDERVALUE1; + VclPtr<ListBox> m_pLB_ORDERFIELD2; + VclPtr<ListBox> m_pLB_ORDERVALUE2; + VclPtr<ListBox> m_pLB_ORDERFIELD3; + VclPtr<ListBox> m_pLB_ORDERVALUE3; OUString aSTR_NOENTRY; OUString m_sOrgOrder; @@ -72,8 +72,8 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; - ListBox* m_aColumnList[DOG_ROWS]; - ListBox* m_aValueList[DOG_ROWS]; + VclPtr<ListBox> m_aColumnList[DOG_ROWS]; + VclPtr<ListBox> m_aValueList[DOG_ROWS]; DECL_LINK( FieldListSelectHdl, ListBox * ); void EnableLines(); @@ -83,8 +83,9 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& _rxComposer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols); + virtual ~DlgOrderCrit(); + virtual void dispose() SAL_OVERRIDE; - virtual ~DlgOrderCrit(); void BuildOrderPart(); OUString GetOrderList( ) const; diff --git a/dbaccess/source/ui/inc/queryview.hxx b/dbaccess/source/ui/inc/queryview.hxx index 0a05a3153b40..645525ca8874 100644 --- a/dbaccess/source/ui/inc/queryview.hxx +++ b/dbaccess/source/ui/inc/queryview.hxx @@ -28,7 +28,6 @@ namespace dbaui { public: OQueryView(vcl::Window* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); - virtual ~OQueryView(); virtual bool isCutAllowed() = 0; virtual bool isPasteAllowed() = 0; diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx index 443ed2791a48..25292c90231e 100644 --- a/dbaccess/source/ui/inc/sbagrid.hxx +++ b/dbaccess/source/ui/inc/sbagrid.hxx @@ -127,7 +127,7 @@ namespace dbaui virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; protected: - virtual FmGridControl* imp_CreateControl(vcl::Window* pParent, WinBits nStyle) SAL_OVERRIDE; + virtual VclPtr<FmGridControl> imp_CreateControl(vcl::Window* pParent, WinBits nStyle) SAL_OVERRIDE; #ifdef _MSC_VER typedef ::com::sun::star::frame::XStatusListener xstlist_type; typedef ::com::sun::star::uno::Reference< xstlist_type > xlistener_type; @@ -231,6 +231,7 @@ namespace dbaui public: SbaGridControl(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >,Window* pParent, FmXGridPeer* _pPeer, WinBits nBits = WB_TABSTOP); virtual ~SbaGridControl(); + virtual void dispose() SAL_OVERRIDE; virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE; virtual void Select() SAL_OVERRIDE; @@ -273,7 +274,7 @@ namespace dbaui virtual void MouseButtonDown( const BrowserMouseEvent& rMEvt) SAL_OVERRIDE; // EditBrowseBox overridables - virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE; + virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE; virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol) SAL_OVERRIDE; // DbGridControl overridables diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx index c941bdfa4c6e..2e5ac221ee65 100644 --- a/dbaccess/source/ui/inc/sqledit.hxx +++ b/dbaccess/source/ui/inc/sqledit.hxx @@ -43,7 +43,7 @@ namespace dbaui Timer m_timerUndoActionCreation; Link m_lnkTextModifyHdl; OUString m_strOrigText; // is restored on undo - OQueryTextView* m_pView; + VclPtr<OQueryTextView> m_pView; bool m_bAccelAction; // is set on cut, copy, paste bool m_bStopTimer; svtools::ColorConfig m_ColorConfig; @@ -68,6 +68,7 @@ namespace dbaui public: OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle = WB_LEFT | WB_VSCROLL |WB_BORDER); virtual ~OSqlEdit(); + virtual void dispose() SAL_OVERRIDE; // Edit overridables virtual void SetText(const OUString& rNewText) SAL_OVERRIDE; diff --git a/dbaccess/source/ui/inc/sqlmessage.hxx b/dbaccess/source/ui/inc/sqlmessage.hxx index 1f4200c827ad..51cc296b5624 100644 --- a/dbaccess/source/ui/inc/sqlmessage.hxx +++ b/dbaccess/source/ui/inc/sqlmessage.hxx @@ -45,9 +45,9 @@ namespace dbaui struct SQLMessageBox_Impl; class OSQLMessageBox : public ButtonDialog { - FixedImage m_aInfoImage; - FixedText m_aTitle; - FixedText m_aMessage; + VclPtr<FixedImage> m_aInfoImage; + VclPtr<FixedText> m_aTitle; + VclPtr<FixedText> m_aMessage; OUString m_sHelpURL; ::std::unique_ptr< SQLMessageBox_Impl > m_pImpl; @@ -90,6 +90,7 @@ public: const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = NULL ); virtual ~OSQLMessageBox(); + virtual void dispose() SAL_OVERRIDE; private: void Construct( WinBits nStyle, MessageType eImage ); diff --git a/dbaccess/source/ui/inc/textconnectionsettings.hxx b/dbaccess/source/ui/inc/textconnectionsettings.hxx index 872b02e42734..89bcfc354e9c 100644 --- a/dbaccess/source/ui/inc/textconnectionsettings.hxx +++ b/dbaccess/source/ui/inc/textconnectionsettings.hxx @@ -39,6 +39,7 @@ namespace dbaui public: TextConnectionSettingsDialog( vcl::Window* _pParent, SfxItemSet& _rItems ); virtual ~TextConnectionSettingsDialog(); + virtual void dispose() SAL_OVERRIDE; /** initializes a set of PropertyStorage instaces, which are bound to the text-connection relevant items in our item sets @@ -48,8 +49,8 @@ namespace dbaui virtual short Execute() SAL_OVERRIDE; private: - ::std::unique_ptr< OTextConnectionHelper > m_pTextConnectionHelper; - OKButton *m_pOK; + VclPtr<OTextConnectionHelper> m_pTextConnectionHelper; + VclPtr<OKButton> m_pOK; SfxItemSet& m_rItems; private: diff --git a/dbaccess/source/ui/inc/undosqledit.hxx b/dbaccess/source/ui/inc/undosqledit.hxx index e9307c66c599..66a2f48795c3 100644 --- a/dbaccess/source/ui/inc/undosqledit.hxx +++ b/dbaccess/source/ui/inc/undosqledit.hxx @@ -21,6 +21,7 @@ #include "GeneralUndo.hxx" #include "dbu_control.hrc" +#include <vcl/vclptr.hxx> namespace dbaui { @@ -29,7 +30,7 @@ namespace dbaui class OSqlEditUndoAct : public OCommentUndoAction { protected: - OSqlEdit* m_pOwner; + VclPtr<OSqlEdit> m_pOwner; OUString m_strNextText; virtual void Undo() SAL_OVERRIDE { ToggleText(); } diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index a544a2a98fee..18cb4322295c 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -100,11 +100,11 @@ namespace dbaui OUString m_sQueryCommand; // the command of the query currently loaded (if any) //OUString m_sToBeLoaded; // contains the element name which should be loaded if any - DBTreeView* m_pTreeView; - Splitter* m_pSplitter; - SvTreeList* m_pTreeModel; // contains the datasources of the registry - SvTreeListEntry* m_pCurrentlyDisplayed; - ImplSVEvent * m_nAsyncDrop; + VclPtr<DBTreeView> m_pTreeView; + VclPtr<Splitter> m_pSplitter; + SvTreeList* m_pTreeModel; // contains the datasources of the registry + SvTreeListEntry* m_pCurrentlyDisplayed; + ImplSVEvent * m_nAsyncDrop; sal_Int16 m_nBorder; // sal_True when border should be shown diff --git a/dbaccess/source/ui/inc/unosqlmessage.hxx b/dbaccess/source/ui/inc/unosqlmessage.hxx index 7028db2c22e6..5a41729aee2c 100644 --- a/dbaccess/source/ui/inc/unosqlmessage.hxx +++ b/dbaccess/source/ui/inc/unosqlmessage.hxx @@ -71,7 +71,7 @@ protected: virtual sal_Bool SAL_CALL convertFastPropertyValue( com::sun::star::uno::Any& _rConvertedValue, com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const com::sun::star::uno::Any& _rValue) throw(com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE; // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index 0f16a402c1f1..67d464ada188 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -687,8 +687,8 @@ bool ODatabaseExport::executeWizard(const OUString& _rTableName, const Any& _aTe { bool bHaveDefaultTable = !m_sDefaultTableName.isEmpty(); OUString sTableName( bHaveDefaultTable ? m_sDefaultTableName : _rTableName ); - OCopyTableWizard aWizard( - NULL, + ScopedVclPtrInstance<OCopyTableWizard> aWizard( + nullptr, sTableName, bHaveDefaultTable ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData, m_aDestColumns, @@ -703,14 +703,14 @@ bool ODatabaseExport::executeWizard(const OUString& _rTableName, const Any& _aTe bool bError = false; try { - if (aWizard.Execute()) + if (aWizard->Execute()) { - switch(aWizard.getOperation()) + switch(aWizard->getOperation()) { case CopyTableOperation::CopyDefinitionAndData: case CopyTableOperation::AppendData: { - m_xTable = aWizard.createTable(); + m_xTable = aWizard->createTable(); bError = !m_xTable.is(); if(m_xTable.is()) { @@ -718,10 +718,10 @@ bool ODatabaseExport::executeWizard(const OUString& _rTableName, const Any& _aTe if(_aTextColor.hasValue()) m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,_aTextColor); } - m_bIsAutoIncrement = aWizard.shouldCreatePrimaryKey(); - m_vColumns = aWizard.GetColumnPositions(); - m_vColumnTypes = aWizard.GetColumnTypes(); - m_bAppendFirstLine = !aWizard.UseHeaderLine(); + m_bIsAutoIncrement = aWizard->shouldCreatePrimaryKey(); + m_vColumns = aWizard->GetColumnPositions(); + m_vColumnTypes = aWizard->GetColumnTypes(); + m_bAppendFirstLine = !aWizard->UseHeaderLine(); } break; default: @@ -736,7 +736,7 @@ bool ODatabaseExport::executeWizard(const OUString& _rTableName, const Any& _aTe } catch( const SQLException&) { - ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), &aWizard, m_xContext ); + ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), aWizard.get(), m_xContext ); bError = true; } catch( const Exception& ) @@ -754,9 +754,9 @@ void ODatabaseExport::showErrorDialog(const ::com::sun::star::sdbc::SQLException OUString aMsg(e.Message); aMsg += "\n"; aMsg += ModuleRes( STR_QRY_CONTINUE ); - OSQLWarningBox aBox( NULL, aMsg, WB_YES_NO | WB_DEF_NO ); + ScopedVclPtrInstance< OSQLWarningBox > aBox( nullptr, aMsg, WB_YES_NO | WB_DEF_NO ); - if (aBox.Execute() == RET_YES) + if (aBox->Execute() == RET_YES) m_bDontAskAgain = true; else m_bError = true; diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index 5a061ea0c448..1d2316ad3d02 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -241,8 +241,8 @@ bool ORowSetImportExport::insertNewRow() if(!m_bAlreadyAsked) { OUString sAskIfContinue = ModuleRes(STR_ERROR_OCCURRED_WHILE_COPYING); - OSQLWarningBox aDlg( m_pParent, sAskIfContinue, WB_YES_NO | WB_DEF_YES ); - if(aDlg.Execute() == RET_YES) + ScopedVclPtrInstance< OSQLWarningBox > aDlg( m_pParent, sAskIfContinue, WB_YES_NO | WB_DEF_YES ); + if(aDlg->Execute() == RET_YES) m_bAlreadyAsked = true; else return false; diff --git a/dbaccess/source/ui/misc/ToolBoxHelper.cxx b/dbaccess/source/ui/misc/ToolBoxHelper.cxx index ac5e461bd951..52f658e12aea 100644 --- a/dbaccess/source/ui/misc/ToolBoxHelper.cxx +++ b/dbaccess/source/ui/misc/ToolBoxHelper.cxx @@ -92,7 +92,7 @@ namespace dbaui } void OToolBoxHelper::setToolBox(ToolBox* _pTB) { - bool bFirstTime = (m_pToolBox == NULL); + bool bFirstTime = (m_pToolBox == nullptr); m_pToolBox = _pTB; if ( m_pToolBox ) { diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index e7dbf9c57e18..397f2a639663 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -852,12 +852,12 @@ bool callColumnFormatDialog(vcl::Window* _pParent, } { // want the dialog to be destroyed before our set - SbaSbAttrDlg aDlg(_pParent, pFormatDescriptor, _pFormatter, _bHasFormat); - if (RET_OK == aDlg.Execute()) + ScopedVclPtrInstance< SbaSbAttrDlg > aDlg(_pParent, pFormatDescriptor, _pFormatter, _bHasFormat); + if (RET_OK == aDlg->Execute()) { // ItemSet->UNO // UNO-properties - const SfxItemSet* pSet = aDlg.GetExampleSet(); + const SfxItemSet* pSet = aDlg->GetExampleSet(); // (of course we could put the modified items directly into the column, but then the UNO-model // won't reflect these changes, and why do we have a model, then ?) @@ -875,7 +875,7 @@ bool callColumnFormatDialog(vcl::Window* _pParent, bRet = true; } // deleted formats - const SfxItemSet* pResult = aDlg.GetOutputItemSet(); + const SfxItemSet* pResult = aDlg->GetOutputItemSet(); if (pResult) { const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO ); @@ -997,10 +997,10 @@ void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MAP_MM ) ); - DlgSize aColumnSizeDlg( _pBox, nColSize, false, aDefaultMM.Width() * 10 ); - if ( aColumnSizeDlg.Execute() ) + ScopedVclPtrInstance< DlgSize > aColumnSizeDlg( _pBox, nColSize, false, aDefaultMM.Width() * 10 ); + if ( aColumnSizeDlg->Execute() ) { - sal_Int32 nValue = aColumnSizeDlg.GetValue(); + sal_Int32 nValue = aColumnSizeDlg->GetValue(); if ( -1 == nValue ) { // default width nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) ); @@ -1286,13 +1286,13 @@ sal_Int32 askForUserAction(vcl::Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _ SolarMutexGuard aGuard; OUString aMsg = ModuleRes(_nText); aMsg = aMsg.replaceFirst("%1", _sName); - OSQLMessageBox aAsk(_pParent, ModuleRes(_nTitle ), aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query); + ScopedVclPtrInstance< OSQLMessageBox > aAsk(_pParent, ModuleRes(_nTitle ), aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query); if ( _bAll ) { - aAsk.AddButton(ModuleRes(STR_BUTTON_TEXT_ALL), RET_ALL, 0); - aAsk.GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL); + aAsk->AddButton(ModuleRes(STR_BUTTON_TEXT_ALL), RET_ALL, 0); + aAsk->GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL); } - return aAsk.Execute(); + return aAsk->Execute(); } namespace @@ -1431,17 +1431,18 @@ bool insertHierachyElement( vcl::Window* _pParent, const Reference< XComponentCo // here we have everything needed to create a new query object ... HierarchicalNameCheck aNameChecker( _xNames.get(), sName ); // ... ehm, except a new name - OSaveAsDlg aAskForName( _pParent, + ScopedVclPtrInstance<OSaveAsDlg> aAskForName( + _pParent, _rxContext, sTargetName, sLabel, aNameChecker, - SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS); - if ( RET_OK != aAskForName.Execute() ) + SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS ); + if ( RET_OK != aAskForName->Execute() ) // cancelled by the user return false; - sNewName = aAskForName.getName(); + sNewName = aAskForName->getName(); } } else if ( xNameAccess->hasByName(sNewName) ) diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 9856a3d8e185..0c99a437378d 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -19,6 +19,8 @@ #include "WCPage.hxx" #include "WCopyTable.hxx" +#include "WColumnSelect.hxx" +#include "WExtendPages.hxx" #include "defaultobjectnamecheck.hxx" #include <tools/debug.hxx> @@ -103,6 +105,23 @@ OCopyTable::OCopyTable(vcl::Window * pParent) OCopyTable::~OCopyTable() { + disposeOnce(); +} + +void OCopyTable::dispose() +{ + m_pEdTableName.clear(); + m_pRB_DefData.clear(); + m_pRB_Def.clear(); + m_pRB_View.clear(); + m_pRB_AppendData.clear(); + m_pCB_UseHeaderLine.clear(); + m_pCB_PrimaryColumn.clear(); + m_pFT_KeyName.clear(); + m_pEdKeyName.clear(); + m_pPage2.clear(); + m_pPage3.clear(); + OWizardPage::dispose(); } IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ ) diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx index 0df651f41212..d9ca01bf3565 100644 --- a/dbaccess/source/ui/misc/WColumnSelect.cxx +++ b/dbaccess/source/ui/misc/WColumnSelect.cxx @@ -50,6 +50,17 @@ OWizardPage::OWizardPage(vcl::Window* pParent, const OString& rID, const OUStrin { } +OWizardPage::~OWizardPage() +{ + disposeOnce(); +} + +void OWizardPage::dispose() +{ + m_pParent.clear(); + TabPage::dispose(); +} + // OWizColumnSelect OWizColumnSelect::OWizColumnSelect( vcl::Window* pParent) :OWizardPage( pParent, "ApplyColPage", "dbaccess/ui/applycolpage.ui") @@ -81,6 +92,11 @@ OWizColumnSelect::OWizColumnSelect( vcl::Window* pParent) OWizColumnSelect::~OWizColumnSelect() { + disposeOnce(); +} + +void OWizColumnSelect::dispose() +{ while ( m_pNewColumnNames->GetEntryCount() ) { void* pData = m_pNewColumnNames->GetEntryData(0); @@ -90,6 +106,13 @@ OWizColumnSelect::~OWizColumnSelect() m_pNewColumnNames->RemoveEntry(0); } m_pNewColumnNames->Clear(); + m_pOrgColumnNames.clear(); + m_pColumn_RH.clear(); + m_pColumns_RH.clear(); + m_pColumn_LH.clear(); + m_pColumns_LH.clear(); + m_pNewColumnNames.clear(); + OWizardPage::dispose(); } void OWizColumnSelect::Reset() diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 90f1894c41bc..9569788f759b 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -578,16 +578,16 @@ OCopyTableWizard::OCopyTableWizard( vcl::Window * pParent, const OUString& _rDef m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,false,::dbtools::eInTableDefinitions); } - OCopyTable* pPage1( new OCopyTable( this ) ); + VclPtrInstance<OCopyTable> pPage1( this ); pPage1->disallowUseHeaderLine(); if ( !bAllowViews ) pPage1->disallowViews(); pPage1->setCreateStyleAction(); AddWizardPage(pPage1); - AddWizardPage( new OWizNameMatching( this ) ); - AddWizardPage( new OWizColumnSelect( this ) ); - AddWizardPage( new OWizNormalExtend( this ) ); + AddWizardPage( VclPtr<OWizNameMatching>::Create( this ) ); + AddWizardPage( VclPtr<OWizColumnSelect>::Create( this ) ); + AddWizardPage( VclPtr<OWizNormalExtend>::Create( this ) ); ActivatePage(); } @@ -624,13 +624,13 @@ OCopyTableWizard::OCopyTableWizard( vcl::Window* pParent, const OUString& _rDefa m_xInteractionHandler.set( InteractionHandler::createWithParent(m_xContext, 0), UNO_QUERY ); - OCopyTable* pPage1( new OCopyTable( this ) ); + VclPtrInstance<OCopyTable> pPage1( this ); pPage1->disallowViews(); pPage1->setCreateStyleAction(); AddWizardPage( pPage1 ); - AddWizardPage( new OWizNameMatching( this ) ); - AddWizardPage( new OWizColumnSelect( this ) ); + AddWizardPage( VclPtr<OWizNameMatching>::Create( this ) ); + AddWizardPage( VclPtr<OWizColumnSelect>::Create( this ) ); AddWizardPage( (*_pTypeSelectionPageFactory)( this, _rTypeSelectionPageArg ) ); ActivatePage(); @@ -640,11 +640,11 @@ void OCopyTableWizard::construct() { SetSizePixel(Size(580, 350)); - AddButton( m_pbHelp = new HelpButton(this, WB_TABSTOP) ); - AddButton( m_pbCancel = new CancelButton(this, WB_TABSTOP) ); - AddButton( m_pbPrev = new PushButton(this, WB_TABSTOP)); - AddButton( m_pbNext = new PushButton(this, WB_TABSTOP)); - AddButton( m_pbFinish = new PushButton(this, WB_TABSTOP)); + AddButton( m_pbHelp = VclPtr<HelpButton>::Create(this, WB_TABSTOP) ); + AddButton( m_pbCancel = VclPtr<CancelButton>::Create(this, WB_TABSTOP) ); + AddButton( m_pbPrev = VclPtr<PushButton>::Create(this, WB_TABSTOP)); + AddButton( m_pbNext = VclPtr<PushButton>::Create(this, WB_TABSTOP)); + AddButton( m_pbFinish = VclPtr<PushButton>::Create(this, WB_TABSTOP)); m_pbHelp->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) ); m_pbCancel->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) ); @@ -686,13 +686,18 @@ void OCopyTableWizard::construct() OCopyTableWizard::~OCopyTableWizard() { + disposeOnce(); +} + +void OCopyTableWizard::dispose() +{ for ( ;; ) { - TabPage *pPage = GetPage(0); - if ( pPage == NULL ) + VclPtr<TabPage> pPage = GetPage(0); + if ( pPage == nullptr ) break; RemovePage( pPage ); - delete pPage; + pPage.disposeAndClear(); } if ( m_bDeleteSourceColumns ) @@ -705,11 +710,12 @@ OCopyTableWizard::~OCopyTableWizard() m_aTypeInfo.clear(); m_aDestTypeInfoIndex.clear(); - delete m_pbHelp; - delete m_pbCancel; - delete m_pbPrev; - delete m_pbNext; - delete m_pbFinish; + m_pbHelp.disposeAndClear(); + m_pbCancel.disposeAndClear(); + m_pbPrev.disposeAndClear(); + m_pbNext.disposeAndClear(); + m_pbFinish.disposeAndClear(); + WizardDialog::dispose(); } IMPL_LINK_NOARG(OCopyTableWizard, ImplPrevHdl) diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index aa35ed9d6c16..c533db6fce9f 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -74,6 +74,22 @@ OWizNameMatching::OWizNameMatching( vcl::Window* pParent) OWizNameMatching::~OWizNameMatching() { + disposeOnce(); +} + +void OWizNameMatching::dispose() +{ + m_pTABLE_LEFT.clear(); + m_pTABLE_RIGHT.clear(); + m_pCTRL_LEFT.clear(); + m_pCTRL_RIGHT.clear(); + m_pColumn_up.clear(); + m_pColumn_down.clear(); + m_pColumn_up_right.clear(); + m_pColumn_down_right.clear(); + m_pAll.clear(); + m_pNone.clear(); + OWizardPage::dispose(); } void OWizNameMatching::Reset() diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx index 40e2227fd3ea..e294f324b62a 100644 --- a/dbaccess/source/ui/misc/WTypeSelect.cxx +++ b/dbaccess/source/ui/misc/WTypeSelect.cxx @@ -45,13 +45,18 @@ using namespace ::com::sun::star::sdbc; OWizTypeSelectControl::OWizTypeSelectControl(vcl::Window* pParent, vcl::Window* pParentTabPage, OTableDesignHelpBar* pHelpBar) : OFieldDescControl(pParent, pHelpBar) { - m_pParentTabPage = pParentTabPage; } OWizTypeSelectControl::~OWizTypeSelectControl() { + disposeOnce(); +} +void OWizTypeSelectControl::dispose() +{ + m_pParentTabPage.clear(); + OFieldDescControl::dispose(); } void OWizTypeSelectControl::ActivateAggregate( EControlType eType ) @@ -87,7 +92,7 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId ) OSL_ENSURE(nRow == -1,"nRow muss -1 sein!"); (void)nRow; - MultiListBox *pListBox = static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pColumnNames; + MultiListBox *pListBox = static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pColumnNames; OFieldDescription* pCurFieldDescr = getCurrentFieldDescData(); @@ -137,13 +142,13 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId ) pWiz->showError(strMessage); pCurFieldDescr->SetName(sName); DisplayData(pCurFieldDescr); - static_cast<OWizTypeSelect*>(m_pParentTabPage)->setDuplicateName(true); + static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->setDuplicateName(true); return; } OUString sOldName = pCurFieldDescr->GetName(); pCurFieldDescr->SetName(sNewName); - static_cast<OWizTypeSelect*>(m_pParentTabPage)->setDuplicateName(false); + static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->setDuplicateName(false); // now we change the name OCopyTableWizard::TNameMapping::iterator aIter = pWiz->m_mNameMapping.begin(); @@ -172,48 +177,48 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId ) ::com::sun::star::lang::Locale OWizTypeSelectControl::GetLocale() const { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->GetLocale(); + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->GetLocale(); } Reference< XNumberFormatter > OWizTypeSelectControl::GetFormatter() const { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->GetFormatter(); + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->GetFormatter(); } TOTypeInfoSP OWizTypeSelectControl::getTypeInfo(sal_Int32 _nPos) { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->getDestTypeInfo(_nPos); + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->getDestTypeInfo(_nPos); } const OTypeInfoMap* OWizTypeSelectControl::getTypeInfo() const { - return &static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->getDestTypeInfo(); + return &static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->getDestTypeInfo(); } ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OWizTypeSelectControl::getMetaData() { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->m_xDestConnection->getMetaData(); + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->m_xDestConnection->getMetaData(); } ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OWizTypeSelectControl::getConnection() { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_pParent->m_xDestConnection; + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_pParent->m_xDestConnection; } bool OWizTypeSelectControl::isAutoIncrementValueEnabled() const { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_bAutoIncrementEnabled; + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_bAutoIncrementEnabled; } OUString OWizTypeSelectControl::getAutoIncrementValue() const { - return static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_sAutoIncrementValue; + return static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_sAutoIncrementValue; } #define IMG_PRIMARY_KEY 1 OWizTypeSelect::OWizTypeSelect( vcl::Window* pParent, SvStream* _pStream ) :OWizardPage( pParent, "TypeSelect", "dbaccess/ui/typeselectpage.ui") - ,m_pTypeControl(new OWizTypeSelectControl(get<VclVBox>("control_container"), this) ) + ,m_pTypeControl(VclPtr<OWizTypeSelectControl>::Create(get<VclVBox>("control_container"), this) ) ,m_pParserStream( _pStream ) ,m_nDisplayRow(0) ,m_bAutoIncrementEnabled(false) @@ -255,7 +260,19 @@ OWizTypeSelect::OWizTypeSelect( vcl::Window* pParent, SvStream* _pStream ) OWizTypeSelect::~OWizTypeSelect() { - delete m_pTypeControl; + disposeOnce(); +} + +void OWizTypeSelect::dispose() +{ + m_pTypeControl.disposeAndClear(); + m_pColumnNames.clear(); + m_pColumns.clear(); + m_pAutoType.clear(); + m_pAutoFt.clear(); + m_pAutoEt.clear(); + m_pAutoPb.clear(); + OWizardPage::dispose(); } OUString OWizTypeSelect::GetTitle() const @@ -344,6 +361,17 @@ IMPL_LINK( OWizTypeSelect, ButtonClickHdl, Button *, /*pButton*/ ) return 0; } +OWizTypeSelectList::~OWizTypeSelectList() +{ + disposeOnce(); +} + +void OWizTypeSelectList::dispose() +{ + m_pParentTabPage.clear(); + MultiListBox::dispose(); +} + bool OWizTypeSelectList::IsPrimaryKeyAllowed() const { sal_uInt16 nCount = GetSelectEntryCount(); @@ -364,7 +392,7 @@ void OWizTypeSelectList::setPrimaryKey(OFieldDescription* _pFieldDescr, sal_uInt RemoveEntry(_nPos); _pFieldDescr->SetPrimaryKey(_bSet); if( _bSet ) - InsertEntry(sColumnName, static_cast<OWizTypeSelect*>(m_pParentTabPage)->m_imgPKey,_nPos); + InsertEntry(sColumnName, static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->m_imgPKey,_nPos); else if( _pFieldDescr->getTypeInfo()->bNullable ) { _pFieldDescr->SetControlDefault(Any()); diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index cfe5df91130c..1903b0cd6029 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -308,8 +308,8 @@ namespace dbaui bool bReConnect = true; if ( _bUI ) { - MessageDialog aQuery(getView(), ModuleRes(STR_QUERY_CONNECTION_LOST), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - bReConnect = ( RET_YES == aQuery.Execute() ); + ScopedVclPtrInstance< MessageDialog > aQuery(getView(), ModuleRes(STR_QUERY_CONNECTION_LOST), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + bReConnect = ( RET_YES == aQuery->Execute() ); } // now really reconnect ... diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx index 3f55ef279a78..77408cdaf51a 100644 --- a/dbaccess/source/ui/misc/singledoccontroller.cxx +++ b/dbaccess/source/ui/misc/singledoccontroller.cxx @@ -18,6 +18,7 @@ */ #include <dbaccess/dbaundomanager.hxx> +#include <dbaccess/dataview.hxx> #include "singledoccontroller.hxx" #include "browserids.hxx" #include "dbu_misc.hrc" diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx index e58d60f183f3..9b584be0715b 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx @@ -82,10 +82,10 @@ namespace dbaui { // search the position of our table window in the table window map nIndex = m_pLine->GetParent()->GetTabWinMap().size(); - const ::std::vector<OTableConnection*>& rVec = m_pLine->GetParent()->getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aIter = rVec.begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = rVec.end(); - for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter) + const auto& rVec = m_pLine->GetParent()->getTableConnections(); + auto aIter = rVec.begin(); + auto aEnd = rVec.end(); + for (; aIter != aEnd && (*aIter).get() != m_pLine; ++nIndex,++aIter) ; nIndex = ( aIter != aEnd ) ? nIndex : -1; } @@ -169,8 +169,14 @@ namespace dbaui } OTableConnection::~OTableConnection() { + disposeOnce(); + } + void OTableConnection::dispose() + { // clear vector clearLineData(); + m_pParent.clear(); + vcl::Window::dispose(); } Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index 9e192e66b3ab..ac483039587c 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -170,10 +170,7 @@ OJoinDesignView* OJoinController::getJoinView() void OJoinController::disposing() { - { - boost::scoped_ptr< vcl::Window > pEnsureDelete( m_pAddTableDialog ); - m_pAddTableDialog = NULL; - } + m_pAddTableDialog = NULL; OJoinController_BASE::disposing(); @@ -225,7 +222,7 @@ FeatureState OJoinController::GetState(sal_uInt16 _nId) const case ID_BROWSER_ADDTABLE: aReturn.bEnabled = ( getView() != NULL ) && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed(); - aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != NULL && m_pAddTableDialog->IsVisible() ; + aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != nullptr && m_pAddTableDialog->IsVisible() ; if ( aReturn.bEnabled ) aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() ); break; @@ -272,7 +269,7 @@ void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& return; case ID_BROWSER_ADDTABLE: if ( !m_pAddTableDialog ) - m_pAddTableDialog = new OAddTableDlg( getView(), impl_getDialogContext() ); + m_pAddTableDialog = VclPtr<OAddTableDlg>::Create( getView(), impl_getDialogContext() ); if ( m_pAddTableDialog->IsVisible() ) { diff --git a/dbaccess/source/ui/querydesign/JoinDesignView.cxx b/dbaccess/source/ui/querydesign/JoinDesignView.cxx index b61a512c1de6..61e40284dd92 100644 --- a/dbaccess/source/ui/querydesign/JoinDesignView.cxx +++ b/dbaccess/source/ui/querydesign/JoinDesignView.cxx @@ -56,15 +56,19 @@ OJoinDesignView::OJoinDesignView(vcl::Window* _pParent, OJoinController& _rContr ,m_pTableView(NULL) ,m_rController( _rController ) { - m_pScrollWindow = new OScrollWindowHelper(this); + m_pScrollWindow = VclPtr<OScrollWindowHelper>::Create(this); } OJoinDesignView::~OJoinDesignView() { - boost::scoped_ptr<vcl::Window> aT3(m_pScrollWindow); - m_pScrollWindow = NULL; - boost::scoped_ptr<vcl::Window> aT2(m_pTableView); - m_pTableView = NULL; + disposeOnce(); +} + +void OJoinDesignView::dispose() +{ + m_pScrollWindow.disposeAndClear(); + m_pTableView.disposeAndClear(); + ODataView::dispose(); } void OJoinDesignView::Construct() diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 8b0c63d177b8..efc798032f18 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -65,9 +65,9 @@ using namespace ::com::sun::star::lang; #define TABWIN_HEIGHT_STD 120 OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParent) - ,m_aHScrollBar( this, WB_HSCROLL|WB_REPEAT|WB_DRAG ) - ,m_aVScrollBar( this, WB_VSCROLL|WB_REPEAT|WB_DRAG ) - ,m_pCornerWindow(new ScrollBarBox(this, WB_3DLOOK)) + ,m_aHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL|WB_REPEAT|WB_DRAG) ) + ,m_aVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL|WB_REPEAT|WB_DRAG) ) + ,m_pCornerWindow(VclPtr<ScrollBarBox>::Create(this, WB_3DLOOK)) ,m_pTableView(NULL) { @@ -89,9 +89,16 @@ OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParen OScrollWindowHelper::~OScrollWindowHelper() { - boost::scoped_ptr<vcl::Window> aTemp(m_pCornerWindow); - m_pCornerWindow = NULL; - m_pTableView = NULL; + disposeOnce(); +} + +void OScrollWindowHelper::dispose() +{ + m_aHScrollBar.disposeAndClear(); + m_aVScrollBar.disposeAndClear(); + m_pCornerWindow.disposeAndClear(); + m_pTableView.clear(); + vcl::Window::dispose(); } void OScrollWindowHelper::setTableView(OJoinTableView* _pTableView) @@ -174,6 +181,11 @@ OJoinTableView::OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView ) OJoinTableView::~OJoinTableView() { + disposeOnce(); +} + +void OJoinTableView::dispose() +{ if( m_pAccessible ) { m_pAccessible->clearTableView(); @@ -181,6 +193,12 @@ OJoinTableView::~OJoinTableView() } // delete lists clearLayoutInformation(); + m_pDragWin.clear(); + m_pSizingWin.clear(); + m_pSelectedConn.clear(); + m_pLastFocusTabWin.clear(); + m_pView.clear(); + vcl::Window::dispose(); } IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar ) @@ -246,9 +264,7 @@ bool OJoinTableView::RemoveConnection( OTableConnection* _pConn,bool _bDelete ) makeAny(_pConn->GetAccessible()), Any()); if ( _bDelete ) - { - delete _pConn; - } + _pConn->disposeOnce(); return true; } @@ -257,7 +273,7 @@ OTableWindow* OJoinTableView::GetTabWindow( const OUString& rName ) { OTableWindowMap::iterator aIter = m_aTableMap.find(rName); - return aIter == m_aTableMap.end() ? NULL : aIter->second; + return aIter == m_aTableMap.end() ? nullptr : aIter->second; } TTableWindowData::value_type OJoinTableView::createTableWindowData(const OUString& _rComposedName @@ -308,7 +324,7 @@ void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& r TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName )); // insert new window in window list - OTableWindow* pNewTabWin = createWindow( pNewTabWinData ); + VclPtr<OTableWindow> pNewTabWin = createWindow( pNewTabWinData ); if ( pNewTabWin->Init() ) { m_pView->getController().getTableWindowData().push_back( pNewTabWinData); @@ -330,7 +346,7 @@ void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& r else { pNewTabWin->clearListBox(); - delete pNewTabWin; + pNewTabWin.disposeAndClear(); } } @@ -340,7 +356,7 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) bool bRemove = true; TTableWindowData::value_type pData = pTabWin->GetData(); sal_Int32 nCount = m_vTableConnection.size(); - ::std::vector<OTableConnection*>::reverse_iterator aIter = m_vTableConnection.rbegin(); + auto aIter = m_vTableConnection.rbegin(); while(aIter != m_vTableConnection.rend() && bRemove) { OTableConnection* pTabConn = (*aIter); @@ -380,9 +396,9 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) m_pLastFocusTabWin = NULL; pTabWin->clearListBox(); - delete pTabWin; - + pTabWin->disposeOnce(); } + if ( (sal_Int32)m_vTableConnection.size() < (nCount-1) ) // if some connections could be removed modified(); } @@ -814,8 +830,8 @@ void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt ) { DeselectConn(GetSelectedConn()); - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + auto aIter = m_vTableConnection.begin(); + auto aEnd = m_vTableConnection.end(); for(;aIter != aEnd;++aIter) { if( (*aIter)->CheckHit(rEvt.GetPosPixel()) ) @@ -927,20 +943,21 @@ void OJoinTableView::Paint( const Rectangle& rRect ) void OJoinTableView::InvalidateConnections() { // draw Joins - ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(), - ::std::mem_fun(& OTableConnection::InvalidateConnection)); + for(auto & conn : m_vTableConnection) + conn->InvalidateConnection(); } void OJoinTableView::DrawConnections( const Rectangle& rRect ) { // draw Joins - ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),boost::bind( &OTableConnection::Draw, _1, boost::cref( rRect ))); + for(auto conn : m_vTableConnection) + conn->Draw(rRect); // finally redraw the selected one above all others if (GetSelectedConn()) GetSelectedConn()->Draw( rRect ); } -::std::vector<OTableConnection*>::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const +::std::vector<VclPtr<OTableConnection> >::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const { return ::std::find_if( m_vTableConnection.begin(), m_vTableConnection.end(), @@ -966,8 +983,8 @@ void OJoinTableView::ClearAll() HideTabWins(); // and the same with the Connections - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + auto aIter = m_vTableConnection.begin(); + auto aEnd = m_vTableConnection.end(); for(;aIter != aEnd;++aIter) RemoveConnection( *aIter ,true); m_vTableConnection.clear(); @@ -983,7 +1000,7 @@ void OJoinTableView::ClearAll() bool OJoinTableView::ScrollWhileDragging() { - OSL_ENSURE(m_pDragWin != NULL, "OJoinTableView::ScrollWhileDragging must not be called when a window is being dragged !"); + OSL_ENSURE(m_pDragWin != nullptr, "OJoinTableView::ScrollWhileDragging must not be called when a window is being dragged !"); // kill the timer if (m_aDragScrollIdle.IsActive()) @@ -1155,8 +1172,8 @@ void OJoinTableView::Command(const CommandEvent& rEvt) DeselectConn(pSelConnection); const Point& aMousePos = rEvt.GetMousePosPixel(); - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + auto aIter = m_vTableConnection.begin(); + auto aEnd = m_vTableConnection.end(); for(;aIter != aEnd;++aIter) { if( (*aIter)->CheckHit(aMousePos) ) @@ -1185,8 +1202,8 @@ OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTab { bool bFoundStart = _rpFirstAfter == nullptr; - ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = m_vTableConnection.end(); + auto aIter = m_vTableConnection.begin(); + auto aEnd = m_vTableConnection.end(); for(;aIter != aEnd;++aIter) { OTableConnection* pData = *aIter; @@ -1318,12 +1335,12 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) { // no active tab win -> travel the connections // find the currently selected conn within the conn list sal_Int32 i(0); - for ( ::std::vector<OTableConnection*>::iterator connectionIter = m_vTableConnection.begin(); + for ( auto connectionIter = m_vTableConnection.begin(); connectionIter != m_vTableConnection.end(); ++connectionIter, ++i ) { - if ( (*connectionIter) == GetSelectedConn() ) + if ( (*connectionIter).get() == GetSelectedConn() ) break; } if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward) @@ -1511,16 +1528,14 @@ void OJoinTableView::clearLayoutInformation() { if ( aIter->second ) aIter->second->clearListBox(); - boost::scoped_ptr<vcl::Window> aTemp(aIter->second); aIter->second = NULL; } m_aTableMap.clear(); - ::std::vector<OTableConnection*>::const_iterator aIter2 = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd2 = m_vTableConnection.end(); - for(;aIter2 != aEnd2;++aIter2) - delete *aIter2; + for(auto i = m_vTableConnection.begin(); + i != m_vTableConnection.end(); ++i) + i->disposeAndClear(); m_vTableConnection.clear(); } diff --git a/dbaccess/source/ui/querydesign/LimitBox.cxx b/dbaccess/source/ui/querydesign/LimitBox.cxx index 4f4175be859b..4cd42066f4a6 100644 --- a/dbaccess/source/ui/querydesign/LimitBox.cxx +++ b/dbaccess/source/ui/querydesign/LimitBox.cxx @@ -47,10 +47,6 @@ LimitBox::LimitBox( vcl::Window* pParent, WinBits nStyle ) SetSizePixel(aSize); } -LimitBox::~LimitBox() -{ -} - OUString LimitBox::CreateFieldText( sal_Int64 nValue ) const { if( nValue == ALL_INT ) @@ -114,8 +110,7 @@ void LimitBox::LoadDefaultLimits() extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeLimitBox( vcl::Window *pParent, VclBuilder::stringmap & ) { - LimitBox* pBox = new LimitBox( pParent, WB_DROPDOWN | WB_VSCROLL ); - return pBox; + return new LimitBox( pParent, WB_DROPDOWN | WB_VSCROLL ); } diff --git a/dbaccess/source/ui/querydesign/QTableConnection.cxx b/dbaccess/source/ui/querydesign/QTableConnection.cxx index 2789e7bc11aa..0f546066be32 100644 --- a/dbaccess/source/ui/querydesign/QTableConnection.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnection.cxx @@ -37,10 +37,6 @@ OQueryTableConnection::OQueryTableConnection(const OQueryTableConnection& rConn) // no own members, so base class functionality is sufficient } -OQueryTableConnection::~OQueryTableConnection() -{ -} - OQueryTableConnection& OQueryTableConnection::operator=(const OQueryTableConnection& rConn) { if (&rConn == this) diff --git a/dbaccess/source/ui/querydesign/QTableConnection.hxx b/dbaccess/source/ui/querydesign/QTableConnection.hxx index 414b805346e3..33f492fcc03b 100644 --- a/dbaccess/source/ui/querydesign/QTableConnection.hxx +++ b/dbaccess/source/ui/querydesign/QTableConnection.hxx @@ -32,7 +32,6 @@ namespace dbaui public: OQueryTableConnection(OQueryTableView* pContainer, const TTableConnectionData::value_type& pTabConnData); OQueryTableConnection(const OQueryTableConnection& rConn); - virtual ~OQueryTableConnection(); OQueryTableConnection& operator=(const OQueryTableConnection& rConn); bool operator==(const OQueryTableConnection& rCompare); diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx index 6c3ab2d64d18..607552ff2389 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.cxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx @@ -66,10 +66,6 @@ OQueryTableWindow::OQueryTableWindow( vcl::Window* pParent, const TTableWindowDa SetHelpId(HID_CTL_QRYDGNTAB); } -OQueryTableWindow::~OQueryTableWindow() -{ -} - bool OQueryTableWindow::Init() { bool bSuccess = OTableWindow::Init(); @@ -102,8 +98,8 @@ bool OQueryTableWindow::Init() SetAliasName(sAliasName); // SetAliasName passes it as WinName, hence it uses the base class // reset the title - m_aTitle.SetText( pWinData->GetWinName() ); - m_aTitle.Show(); + m_aTitle->SetText( pWinData->GetWinName() ); + m_aTitle->Show(); getTableView()->getDesignView()->getController().InvalidateFeature(ID_BROWSER_QUERY_EXECUTE); return bSuccess; @@ -148,7 +144,7 @@ void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry) bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDescRef& rInfo) { - OSL_ENSURE(m_pListBox != NULL, "OQueryTableWindow::ExistsField : doesn't have ::com::sun::star::form::ListBox !"); + OSL_ENSURE(m_pListBox != nullptr, "OQueryTableWindow::ExistsField : doesn't have ::com::sun::star::form::ListBox !"); OSL_ENSURE(rInfo.is(),"OQueryTableWindow::ExistsField: invalid argument for OTableFieldDescRef!"); Reference< XConnection> xConnection = getTableView()->getDesignView()->getController().getConnection(); bool bExists = false; diff --git a/dbaccess/source/ui/querydesign/QTableWindow.hxx b/dbaccess/source/ui/querydesign/QTableWindow.hxx index 95c674107e77..8f64918b4eb5 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.hxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.hxx @@ -32,7 +32,6 @@ namespace dbaui OUString m_strInitialAlias; public: OQueryTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData, sal_Unicode* pszInitialAlias = NULL ); - virtual ~OQueryTableWindow(); OUString GetAliasName() const { diff --git a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx index 61c7507d63f8..a009832b5624 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx @@ -30,7 +30,7 @@ namespace dbaui class OQueryDesignFieldUndoAct : public OCommentUndoAction { protected: - OSelectionBrowseBox* pOwner; + VclPtr<OSelectionBrowseBox> pOwner; sal_uInt16 m_nColumnPostion; virtual void Undo() SAL_OVERRIDE = 0; diff --git a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx index d74ce27e9fc7..9166a2e782c4 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx +++ b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx @@ -20,6 +20,7 @@ #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNUNDOACTION_HXX #include "GeneralUndo.hxx" +#include <vcl/vclptr.hxx> namespace dbaui { @@ -28,7 +29,7 @@ namespace dbaui class OQueryDesignUndoAction : public OCommentUndoAction { protected: - OJoinTableView* m_pOwner; // in this container it all happens + VclPtr<OJoinTableView> m_pOwner; // in this container it all happens public: OQueryDesignUndoAction(OJoinTableView* pOwner, sal_uInt16 nCommentID) : OCommentUndoAction(nCommentID), m_pOwner(pOwner) { } diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index dba71c0e72cb..61039e895f6b 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -159,10 +159,10 @@ namespace } } - OQueryTableConnection aInfo(pTableView, aInfoData); + ScopedVclPtrInstance< OQueryTableConnection > aInfo(pTableView, aInfoData); // Because OQueryTableConnection never takes ownership of the data passed to it, but only remembers the pointer, // this pointer to a local variable is not critical, as aInfoData and aInfo have the same lifetime - pTableView->NotifyTabConnection( aInfo ); + pTableView->NotifyTabConnection( *aInfo.get() ); } else { @@ -509,12 +509,12 @@ namespace pEntryConn->SetVisited(true); // first search for the "to" window - const ::std::vector<OTableConnection*>& rConnections = pEntryConn->GetParent()->getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aIter = rConnections.begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = rConnections.end(); + const auto& rConnections = pEntryConn->GetParent()->getTableConnections(); + auto aIter = rConnections.begin(); + auto aEnd = rConnections.end(); for(;aIter != aEnd;++aIter) { - OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter); + OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>((*aIter).get()); if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabTo || pNext->GetDestWin() == pEntryTabTo)) { OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabTo ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin()); @@ -532,7 +532,7 @@ namespace aIter = rConnections.begin(); for(;aIter != aEnd;++aIter) { - OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter); + OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>((*aIter).get()); if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabFrom || pNext->GetDestWin() == pEntryTabFrom)) { OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabFrom ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin()); @@ -666,7 +666,7 @@ namespace bool bFound = false; for(;!bFound && tableIter != tableEnd ;++tableIter) { - OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(tableIter->second); + OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(tableIter->second.get()); bFound = pTabWin->ExistsField( rFieldName, aInfo ); if ( bFound ) @@ -985,13 +985,13 @@ namespace void GenerateInnerJoinCriterias(const Reference< XConnection>& _xConnection, OUString& _rJoinCrit, - const ::std::vector<OTableConnection*>* _pConnList) + const ::std::vector<VclPtr<OTableConnection> >& _rConnList) { - ::std::vector<OTableConnection*>::const_iterator aIter = _pConnList->begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = _pConnList->end(); + auto aIter = _rConnList.begin(); + auto aEnd = _rConnList.end(); for(;aIter != aEnd;++aIter) { - const OQueryTableConnection* pEntryConn = static_cast<const OQueryTableConnection*>(*aIter); + const OQueryTableConnection* pEntryConn = static_cast<const OQueryTableConnection*>((*aIter).get()); OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get()); if ( pEntryConnData->GetJoinType() == INNER_JOIN && !pEntryConnData->isNatural() ) { @@ -1018,7 +1018,7 @@ namespace } OUString GenerateFromClause( const Reference< XConnection>& _xConnection, const OQueryTableView::OTableWindowMap* pTabList, - const ::std::vector<OTableConnection*>* pConnList + const ::std::vector<VclPtr<OTableConnection> >& rConnList ) { @@ -1027,14 +1027,14 @@ namespace tableNames_t aTableNames; // generate outer join clause in from - if(!pConnList->empty()) + if(!rConnList.empty()) { - ::std::vector<OTableConnection*>::const_iterator aIter = pConnList->begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = pConnList->end(); + auto aIter = rConnList.begin(); + auto aEnd = rConnList.end(); ::std::map<OTableWindow*,sal_Int32> aConnectionCount; for(;aIter != aEnd;++aIter) { - static_cast<OQueryTableConnection*>(*aIter)->SetVisited(false); + static_cast<OQueryTableConnection*>((*aIter).get())->SetVisited(false); ++aConnectionCount[(*aIter)->GetSourceWin()]; ++aConnectionCount[(*aIter)->GetDestWin()]; } @@ -1051,10 +1051,10 @@ namespace ::std::multimap<sal_Int32 , OTableWindow*>::reverse_iterator aREnd = aMulti.rend(); for(;aRIter != aREnd;++aRIter) { - ::std::vector<OTableConnection*>::const_iterator aConIter = aRIter->second->getTableView()->getTableConnections(aRIter->second); + auto aConIter = aRIter->second->getTableView()->getTableConnections(aRIter->second); for(;aConIter != aEnd;++aConIter) { - OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aConIter); + OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>((*aConIter).get()); if(!pEntryConn->IsVisited() && pEntryConn->GetSourceWin() == aRIter->second ) { OUString aJoin; @@ -1097,10 +1097,10 @@ namespace // "FROM tbl1, tbl2 WHERE tbl1.col1=tlb2.col2" // rather than // "FROM tbl1 INNER JOIN tbl2 ON tbl1.col1=tlb2.col2" - aIter = pConnList->begin(); + aIter = rConnList.begin(); for(;aIter != aEnd;++aIter) { - OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aIter); + OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>((*aIter).get()); if(!pEntryConn->IsVisited()) { searchAndAppendName(_xConnection, @@ -1120,7 +1120,7 @@ namespace OQueryTableView::OTableWindowMap::const_iterator aTabEnd = pTabList->end(); for(;aTabIter != aTabEnd;++aTabIter) { - const OQueryTableWindow* pEntryTab = static_cast<const OQueryTableWindow*>(aTabIter->second); + const OQueryTableWindow* pEntryTab = static_cast<const OQueryTableWindow*>(aTabIter->second.get()); if(!pEntryTab->ExistsAConn()) { aTableListStr += BuildTable(_xConnection,pEntryTab); @@ -1541,7 +1541,7 @@ namespace OJoinTableView::OTableWindowMap::iterator aTabEnd = rTabList.end(); for(;aIter != aTabEnd;++aIter) { - OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second.get()); if (pTabWin->ExistsField( OUString("*"), aDragLeft )) { aDragLeft->SetAlias(OUString()); @@ -1749,7 +1749,7 @@ namespace OJoinTableView::OTableWindowMap::const_iterator aEnd = _rTabList.end(); for ( ; aIter != aEnd; ++aIter ) { - OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( aIter->second ); + OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( aIter->second.get() ); if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) ) return pTabWin; } @@ -2105,7 +2105,7 @@ namespace OJoinTableView::OTableWindowMap::iterator aEnd = _pTabList->end(); for(;aIter != aEnd && eOk == eErrorCode ;++aIter) { - OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second.get()); OTableFieldDescRef aInfo = new OTableFieldDesc(); if (pTabWin->ExistsField( sAsterisk, aInfo )) { @@ -2202,7 +2202,7 @@ namespace const OJoinTableView::OTableWindowMap::const_iterator aEnd = pTabList->end(); for(;aIter != aEnd;++aIter) { - OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second.get()); if (pTabWin->ExistsField( OUString("*"), aInfo )) { aInfo->SetAlias(OUString()); @@ -2491,7 +2491,7 @@ OQueryDesignView::OQueryDesignView( OQueryContainerWindow* _pParent, OQueryController& _rController, const Reference< XComponentContext >& _rxContext) :OQueryView( _pParent, _rController, _rxContext ) - ,m_aSplitter( this ) + ,m_aSplitter( VclPtr<Splitter>::Create(this) ) ,m_eChildFocus(NONE) ,m_bInSplitHandler( false ) { @@ -2506,23 +2506,28 @@ OQueryDesignView::OQueryDesignView( OQueryContainerWindow* _pParent, { } - m_pSelectionBox = new OSelectionBrowseBox(this); + m_pSelectionBox = VclPtr<OSelectionBrowseBox>::Create(this); setNoneVisbleRow(static_cast<OQueryController&>(getController()).getVisibleRows()); m_pSelectionBox->Show(); // setup Splitter - m_aSplitter.SetSplitHdl(LINK(this, OQueryDesignView,SplitHdl)); - m_aSplitter.Show(); + m_aSplitter->SetSplitHdl(LINK(this, OQueryDesignView,SplitHdl)); + m_aSplitter->Show(); } OQueryDesignView::~OQueryDesignView() { + disposeOnce(); +} + +void OQueryDesignView::dispose() +{ if ( m_pTableView ) ::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - boost::scoped_ptr<vcl::Window> aTemp(m_pSelectionBox); - m_pSelectionBox = NULL; - + m_pSelectionBox.disposeAndClear(); + m_aSplitter.disposeAndClear(); + OQueryView::dispose(); } IMPL_LINK( OQueryDesignView, SplitHdl, void*, /*p*/ ) @@ -2530,8 +2535,8 @@ IMPL_LINK( OQueryDesignView, SplitHdl, void*, /*p*/ ) if (!getController().isReadOnly()) { m_bInSplitHandler = true; - m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),m_aSplitter.GetSplitPosPixel() ) ); - static_cast<OQueryController&>(getController()).setSplitPos(m_aSplitter.GetSplitPosPixel()); + m_aSplitter->SetPosPixel( Point( m_aSplitter->GetPosPixel().X(),m_aSplitter->GetSplitPosPixel() ) ); + static_cast<OQueryController&>(getController()).setSplitPos(m_aSplitter->GetSplitPosPixel()); static_cast<OQueryController&>(getController()).setModified( sal_True ); Resize(); m_bInSplitHandler = true; @@ -2541,7 +2546,7 @@ IMPL_LINK( OQueryDesignView, SplitHdl, void*, /*p*/ ) void OQueryDesignView::Construct() { - m_pTableView = new OQueryTableView(m_pScrollWindow,this); + m_pTableView = VclPtr<OQueryTableView>::Create(m_pScrollWindow,this); ::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::AddWindow)); OQueryView::Construct(); } @@ -2550,8 +2555,8 @@ void OQueryDesignView::initialize() { if(static_cast<OQueryController&>(getController()).getSplitPos() != -1) { - m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),static_cast<OQueryController&>(getController()).getSplitPos() ) ); - m_aSplitter.SetSplitPosPixel(static_cast<OQueryController&>(getController()).getSplitPos()); + m_aSplitter->SetPosPixel( Point( m_aSplitter->GetPosPixel().X(),static_cast<OQueryController&>(getController()).getSplitPos() ) ); + m_aSplitter->SetSplitPosPixel(static_cast<OQueryController&>(getController()).getSplitPos()); } m_pSelectionBox->initialize(); reset(); @@ -2572,7 +2577,7 @@ void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground) { // let the selection browse box determine an optimal size Size aSelectionBoxSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize ); - nSplitPos = aPlaygroundSize.Height() - aSelectionBoxSize.Height() - m_aSplitter.GetSizePixel().Height(); + nSplitPos = aPlaygroundSize.Height() - aSelectionBoxSize.Height() - m_aSplitter->GetSizePixel().Height(); // still an invalid size? if ( nSplitPos == -1 || nSplitPos >= aPlaygroundSize.Height() ) nSplitPos = sal_Int32(aPlaygroundSize.Height()*0.6); @@ -2587,13 +2592,13 @@ void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground) if ( aSelBoxSize.Height() ) { // keep the size of the sel box constant - nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxSize.Height(); + nSplitPos = aPlaygroundSize.Height() - m_aSplitter->GetSizePixel().Height() - aSelBoxSize.Height(); // and if the box is smaller than the optimal size, try to do something about it Size aSelBoxOptSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize ); if ( aSelBoxOptSize.Height() > aSelBoxSize.Height() ) { - nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxOptSize.Height(); + nSplitPos = aPlaygroundSize.Height() - m_aSplitter->GetSizePixel().Height() - aSelBoxOptSize.Height(); } static_cast< OQueryController& >(getController()).setSplitPos( nSplitPos ); @@ -2603,7 +2608,7 @@ void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground) // normalize the split pos Point aSplitPos = Point( _rPlayground.Left(), nSplitPos ); - Size aSplitSize = Size( _rPlayground.GetSize().Width(), m_aSplitter.GetSizePixel().Height() ); + Size aSplitSize = Size( _rPlayground.GetSize().Width(), m_aSplitter->GetSizePixel().Height() ); if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() )) aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height(); @@ -2620,8 +2625,8 @@ void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground) m_pSelectionBox->SetPosSizePixel( aPos, Size( aPlaygroundSize.Width(), aPlaygroundSize.Height() - aSplitSize.Height() - aTableViewSize.Height() )); // set the size of the splitter - m_aSplitter.SetPosSizePixel( aSplitPos, aSplitSize ); - m_aSplitter.SetDragRectPixel( _rPlayground ); + m_aSplitter->SetPosSizePixel( aSplitPos, aSplitSize ); + m_aSplitter->SetDragRectPixel( _rPlayground ); // just for completeness: there is no space left, we occupied it all ... _rPlayground.SetPos( _rPlayground.BottomRight() ); @@ -2746,7 +2751,7 @@ void OQueryDesignView::fillValidFields(const OUString& sAliasName, ComboBox* pFi OJoinTableView::OTableWindowMap::iterator aEnd = rTabWins.end(); for(;aIter != aEnd;++aIter) { - OQueryTableWindow* pCurrentWin = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pCurrentWin = static_cast<OQueryTableWindow*>(aIter->second.get()); if (bAllTables || (pCurrentWin->GetAliasName() == sAliasName)) { strCurrentPrefix = pCurrentWin->GetAliasName(); @@ -2846,9 +2851,9 @@ OUString OQueryDesignView::getStatement() // and trigger a error message // ----------------- Build table list ---------------------- - const ::std::vector<OTableConnection*>& rConnList = m_pTableView->getTableConnections(); + const auto& rConnList = m_pTableView->getTableConnections(); Reference< XConnection> xConnection = rController.getConnection(); - OUString aTableListStr(GenerateFromClause(xConnection,&rTabList,&rConnList)); + OUString aTableListStr(GenerateFromClause(xConnection,&rTabList,rConnList)); OSL_ENSURE(!aTableListStr.isEmpty(), "OQueryDesignView::getStatement() : unexpected : have Fields, but no Tables !"); // if fields exist now, these only can be created by inserting from an already existing table; if on the other hand // a table is deleted, also the belonging fields will be deleted -> therefore it CANNOT occur that fields @@ -2860,7 +2865,7 @@ OUString OQueryDesignView::getStatement() return OUString(); OUString aJoinCrit; - GenerateInnerJoinCriterias(xConnection,aJoinCrit,&rConnList); + GenerateInnerJoinCriterias(xConnection,aJoinCrit,rConnList); if(!aJoinCrit.isEmpty()) { OUString aTmp = "( " + aJoinCrit + " )"; @@ -2994,8 +2999,8 @@ void OQueryDesignView::SaveUIConfig() OQueryController& rCtrl = static_cast<OQueryController&>(getController()); rCtrl.SaveTabWinsPosSize( &m_pTableView->GetTabWinMap(), m_pScrollWindow->GetHScrollBar().GetThumbPos(), m_pScrollWindow->GetVScrollBar().GetThumbPos() ); rCtrl.setVisibleRows( m_pSelectionBox->GetNoneVisibleRows() ); - if ( m_aSplitter.GetSplitPosPixel() != 0 ) - rCtrl.setSplitPos( m_aSplitter.GetSplitPosPixel() ); + if ( m_aSplitter->GetSplitPosPixel() != 0 ) + rCtrl.setSplitPos( m_aSplitter->GetSplitPosPixel() ); } OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pEntry, diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx index 49060c1bc08e..b8c9f52ad0c1 100644 --- a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx @@ -31,7 +31,7 @@ namespace dbaui class OJoinMoveTabWinUndoAct : public OQueryDesignUndoAction { Point m_ptNextPosition; - OTableWindow* m_pTabWin; + VclPtr<OTableWindow> m_pTabWin; protected: void TogglePosition(); diff --git a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx index 4de742deb1d4..bd9381468ca0 100644 --- a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx @@ -31,7 +31,7 @@ namespace dbaui { Point m_ptNextPosition; Size m_szNextSize; - OTableWindow* m_pTabWin; + VclPtr<OTableWindow> m_pTabWin; protected: inline void ToggleSizePosition(); diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx index 16f8e0e4b7cd..02c59c3cb998 100644 --- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx @@ -19,6 +19,7 @@ #include "QueryTabConnUndoAction.hxx" #include "QTableConnection.hxx" +#include "QTableWindow.hxx" #include <tools/debug.hxx> #include "QueryTableView.hxx" #include "QueryAddTabConnUndoAction.hxx" @@ -32,7 +33,7 @@ OQueryTabConnUndoAction::~OQueryTabConnUndoAction() if (m_bOwnerOfConn) { // I have the connection -> delete m_pOwner->DeselectConn(m_pConnection); - delete m_pConnection; + m_pConnection.disposeAndClear(); } } @@ -50,13 +51,13 @@ OQueryAddTabConnUndoAction::OQueryAddTabConnUndoAction(OQueryTableView* pOwner) void OQueryAddTabConnUndoAction::Undo() { - static_cast<OQueryTableView*>(m_pOwner)->DropConnection(m_pConnection); + static_cast<OQueryTableView*>(m_pOwner.get())->DropConnection(m_pConnection); SetOwnership(true); } void OQueryAddTabConnUndoAction::Redo() { - static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection); + static_cast<OQueryTableView*>(m_pOwner.get())->GetConnection(m_pConnection); SetOwnership(false); } @@ -67,13 +68,13 @@ OQueryDelTabConnUndoAction::OQueryDelTabConnUndoAction(OQueryTableView* pOwner) void OQueryDelTabConnUndoAction::Undo() { - static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection); + static_cast<OQueryTableView*>(m_pOwner.get())->GetConnection(m_pConnection); SetOwnership(false); } void OQueryDelTabConnUndoAction::Redo() { - static_cast<OQueryTableView*>(m_pOwner)->DropConnection(m_pConnection); + static_cast<OQueryTableView*>(m_pOwner.get())->DropConnection(m_pConnection); SetOwnership(true); } @@ -88,13 +89,13 @@ OQueryTabWinShowUndoAct::~OQueryTabWinShowUndoAct() void OQueryTabWinShowUndoAct::Undo() { - static_cast<OQueryTableView*>(m_pOwner)->HideTabWin(m_pTabWin, this); + static_cast<OQueryTableView*>(m_pOwner.get())->HideTabWin(m_pTabWin, this); SetOwnership(true); } void OQueryTabWinShowUndoAct::Redo() { - static_cast<OQueryTableView*>(m_pOwner)->ShowTabWin(m_pTabWin, this,true); + static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin(m_pTabWin, this,true); SetOwnership(false); } @@ -109,13 +110,13 @@ OQueryTabWinDelUndoAct::~OQueryTabWinDelUndoAct() void OQueryTabWinDelUndoAct::Undo() { - static_cast<OQueryTableView*>(m_pOwner)->ShowTabWin( m_pTabWin, this,true ); + static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin( m_pTabWin, this,true ); SetOwnership(false); } void OQueryTabWinDelUndoAct::Redo() { - static_cast<OQueryTableView*>(m_pOwner)->HideTabWin( m_pTabWin, this ); + static_cast<OQueryTableView*>(m_pOwner.get())->HideTabWin( m_pTabWin, this ); SetOwnership(true); } diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx index 72b31532213d..6541a4ed5b42 100644 --- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx +++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx @@ -28,7 +28,7 @@ namespace dbaui class OQueryTabConnUndoAction : public OQueryDesignUndoAction { protected: - OQueryTableConnection* m_pConnection; + VclPtr<OQueryTableConnection> m_pConnection; bool m_bOwnerOfConn; // am I the only owner of the connection? (changes with every redo and undo) diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx index f7bee57ce37a..d898780b9d48 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx @@ -51,20 +51,20 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct() if (m_bOwnerOfObjects) { // I should take care to delete the window if I am the only owner - OSL_ENSURE(m_pTabWin != NULL, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein"); + OSL_ENSURE(m_pTabWin != nullptr, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein"); OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein"); if ( m_pTabWin ) m_pTabWin->clearListBox(); - delete m_pTabWin; + m_pTabWin.disposeAndClear(); // and of course the corresponding connections - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + auto aIter = m_vTableConnection.begin(); + auto aEnd = m_vTableConnection.end(); for(;aIter != aEnd;++aIter) { m_pOwner->DeselectConn(*aIter); - delete (*aIter); + aIter->disposeAndClear(); } m_vTableConnection.clear(); } diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx index 22c9921330a6..af22a64063d2 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx @@ -33,8 +33,8 @@ namespace dbaui class OQueryTabWinUndoAct : public OQueryDesignUndoAction { protected: - ::std::vector<OTableConnection*> m_vTableConnection; - OQueryTableWindow* m_pTabWin; + ::std::vector<VclPtr<OTableConnection> > m_vTableConnection; + VclPtr<OQueryTableWindow> m_pTabWin; bool m_bOwnerOfObjects; // am I the only owner of the managed objects? (changes with every redo or undo) @@ -54,7 +54,7 @@ namespace dbaui // access to the managed connections sal_uInt16 ConnCount() { return (sal_uInt16)m_vTableConnection.size(); } - ::std::vector<OTableConnection*>& GetTabConnList() { return m_vTableConnection; } + ::std::vector<VclPtr<OTableConnection> >& GetTabConnList() { return m_vTableConnection; } void InsertConnection( OTableConnection* pConnection ) { m_vTableConnection.push_back(pConnection); } void RemoveConnection( OTableConnection* pConnection ) diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index e3e92e2c3637..b39bf31e0cf0 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -118,11 +118,11 @@ namespace { OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData.get()); - DlgQryJoin aDlg(_pView,_pConnectionData,&_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables); - bool bOk = aDlg.Execute() == RET_OK; + ScopedVclPtrInstance< DlgQryJoin > aDlg(_pView,_pConnectionData,&_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables); + bool bOk = aDlg->Execute() == RET_OK; if( bOk ) { - pData->SetJoinType(aDlg.GetJoinType()); + pData->SetJoinType(aDlg->GetJoinType()); _pView->getDesignView()->getController().setModified(sal_True); } @@ -208,10 +208,10 @@ namespace pNewConnData->AppendConnLine(*pIter,sRelatedColumn); // now add the Conn itself - OQueryTableConnection aNewConn(_pView, aNewConnData); + ScopedVclPtrInstance< OQueryTableConnection > aNewConn(_pView, aNewConnData); // referring to the local variable is not important, as NotifyQueryTabConn creates a new copy // to add me (if not existent) - _pView->NotifyTabConnection(aNewConn, false); + _pView->NotifyTabConnection(*aNewConn.get(), false); // don't create an Undo-Action for the new connection : the connection is // covered by the Undo-Action for the tabwin, as the "Undo the insert" will // automatically remove all connections adjacent to the win. @@ -228,10 +228,6 @@ OQueryTableView::OQueryTableView( vcl::Window* pParent,OQueryDesignView* pView) SetHelpId(HID_CTL_QRYDGNTAB); } -OQueryTableView::~OQueryTableView() -{ -} - sal_Int32 OQueryTableView::CountTableAlias(const OUString& rName, sal_Int32& rMax) { sal_Int32 nRet = 0; @@ -263,7 +259,7 @@ void OQueryTableView::ReSync() for(;aIter != rTabWinDataList.rend();++aIter) { OQueryTableWindowData* pData = static_cast<OQueryTableWindowData*>(aIter->get()); - OTableWindow* pTabWin = createWindow(*aIter); + VclPtr<OTableWindow> pTabWin = createWindow(*aIter); // I dont't use ShowTabWin as this adds the window data to the list of documents. // This would be bad as I am getting them from there. @@ -273,7 +269,7 @@ void OQueryTableView::ReSync() // The initialisation has gone wrong, this TabWin is not available, so // I must clean up the data and the document pTabWin->clearListBox(); - delete pTabWin; + pTabWin.disposeAndClear(); arrInvalidTables.push_back(pData->GetAliasName()); rTabWinDataList.erase( ::std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), *aIter), rTabWinDataList.end()); @@ -310,7 +306,7 @@ void OQueryTableView::ReSync() } // adds a new connection to join view and notifies our accessible and invaldates the controller - addConnection(new OQueryTableConnection(this, *aConIter)); + addConnection(VclPtr<OQueryTableConnection>::Create(this, *aConIter)); } } @@ -322,35 +318,35 @@ void OQueryTableView::ClearAll() m_pView->getController().setModified(sal_True); } -OTableWindow* OQueryTableView::createWindow(const TTableWindowData::value_type& _pData) +VclPtr<OTableWindow> OQueryTableView::createWindow(const TTableWindowData::value_type& _pData) { - return new OQueryTableWindow(this,_pData); + return VclPtr<OQueryTableWindow>::Create(this,_pData); } void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, bool _bCreateUndoAction) { // let's first check if I have the connection already OQueryTableConnection* pTabConn = NULL; - const ::std::vector<OTableConnection*>& rConnections = getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aEnd = rConnections.end(); - ::std::vector<OTableConnection*>::const_iterator aIter = ::std::find( rConnections.begin(), - aEnd, - static_cast<const OTableConnection*>(&rNewConn) - ); + const auto& rConnections = getTableConnections(); + auto aEnd = rConnections.end(); + auto aIter = ::std::find( rConnections.begin(), + aEnd, + VclPtr<OTableConnection>(const_cast<OTableConnection*>(static_cast<const OTableConnection*>(&rNewConn))) + ); if(aIter == aEnd ) { aIter = rConnections.begin(); for(;aIter != aEnd;++aIter) { - if(*static_cast<OQueryTableConnection*>(*aIter) == rNewConn) + if(*static_cast<OQueryTableConnection*>((*aIter).get()) == rNewConn) { - pTabConn = static_cast<OQueryTableConnection*>(*aIter); + pTabConn = static_cast<OQueryTableConnection*>((*aIter).get()); break; } } } else - pTabConn = static_cast<OQueryTableConnection*>(*aIter); + pTabConn = static_cast<OQueryTableConnection*>((*aIter).get()); // no -> insert if (pTabConn == NULL) @@ -359,7 +355,7 @@ void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, OQueryTableConnectionData* pNewData = static_cast< OQueryTableConnectionData*>(rNewConn.GetData()->NewInstance()); pNewData->CopyFrom(*rNewConn.GetData()); TTableConnectionData::value_type aData(pNewData); - OQueryTableConnection* pNewConn = new OQueryTableConnection(this, aData); + VclPtrInstance<OQueryTableConnection> pNewConn(this, aData); GetConnection(pNewConn); connectionModified(this,pNewConn,_bCreateUndoAction); @@ -461,7 +457,7 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& // I do not need to add TabWinData to the DocShell list, ShowTabWin does that. // Create a new window - OQueryTableWindow* pNewTabWin = static_cast<OQueryTableWindow*>(createWindow(pNewTabWinData)); + VclPtr<OQueryTableWindow> pNewTabWin = static_cast<OQueryTableWindow*>(createWindow(pNewTabWinData).get()); // No need to initialize, as that happens in ShowTabWin // New UndoAction @@ -529,14 +525,14 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& { for(aIter = rTabWins.begin();aIter != aEnd;++aIter) { - OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second.get()); OSL_ENSURE( pTabWinTmp,"TableWindow is null!" ); if ( pTabWinTmp != pNewTabWin && pTabWinTmp->GetComposedName() == aReferencedTable ) break; } } - if ( aIter != aEnd && pNewTabWin != aIter->second ) - addConnections( this, *pNewTabWin, *static_cast<OQueryTableWindow*>(aIter->second), xFKeyColumns ); + if ( aIter != aEnd && pNewTabWin.get() != aIter->second.get() ) + addConnections( this, *pNewTabWin, *static_cast<OQueryTableWindow*>(aIter->second.get()), xFKeyColumns ); } break; @@ -547,7 +543,7 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& OTableWindowMap::const_iterator aEnd = rTabWins.end(); for(;aIter != aEnd;++aIter) { - OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second.get()); if ( pTabWinTmp == pNewTabWin ) continue; @@ -625,8 +621,8 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ pNewConnectionData->AppendConnLine( aSourceFieldName,aDestFieldName ); - OQueryTableConnection aNewConnection(this, aNewConnectionData); - NotifyTabConnection(aNewConnection); + ScopedVclPtrInstance< OQueryTableConnection > aNewConnection(this, aNewConnectionData); + NotifyTabConnection(*aNewConnection.get()); // As usual with NotifyTabConnection, using a local variable is fine because a copy is made } else @@ -660,8 +656,8 @@ void OQueryTableView::createNewConnection() if( openJoinDialog(this,pData,true) ) { OTableWindowMap& rMap = GetTabWinMap(); - OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>(rMap[pData->getReferencingTable()->GetWinName()]); - OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>(rMap[pData->getReferencedTable()->GetWinName()]); + OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>(rMap[pData->getReferencingTable()->GetWinName()].get()); + OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>(rMap[pData->getReferencedTable()->GetWinName()].get()); // first we have to look if the this connection already exists OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true); bool bNew = true; @@ -673,7 +669,7 @@ void OQueryTableView::createNewConnection() else { // create a new conenction and append it - OQueryTableConnection* pQConn = new OQueryTableConnection(this, pData); + VclPtrInstance<OQueryTableConnection> pQConn(this, pData); GetConnection(pQConn); pConn = pQConn; } @@ -708,7 +704,7 @@ OQueryTableWindow* OQueryTableView::FindTable(const OUString& rAliasName) // (it is harmless but does not make sense and indicates that there is probably an error in the caller) OTableWindowMap::const_iterator aIter = GetTabWinMap().find(rAliasName); if(aIter != GetTabWinMap().end()) - return static_cast<OQueryTableWindow*>(aIter->second); + return static_cast<OQueryTableWindow*>(aIter->second.get()); return NULL; } @@ -719,7 +715,7 @@ bool OQueryTableView::FindTableFromField(const OUString& rFieldName, OTableField OTableWindowMap::const_iterator aEnd = GetTabWinMap().end(); for(;aIter != aEnd;++aIter) { - if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo)) + if(static_cast<OQueryTableWindow*>(aIter->second.get())->ExistsField(rFieldName, rInfo)) ++rCnt; } @@ -838,11 +834,11 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // collect connections belonging to the window and pass to UndoAction sal_Int16 nCnt = 0; - const ::std::vector<OTableConnection*>& rTabConList = getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aIter2 = rTabConList.begin(); + const auto& rTabConList = getTableConnections(); + auto aIter2 = rTabConList.begin(); for(;aIter2 != rTabConList.end();)// the end may change { - OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>(*aIter2); + OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>((*aIter2).get()); OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!"); if( pTmpEntry->GetAliasName(JTCS_FROM) == pTabWin->GetAliasName() || pTmpEntry->GetAliasName(JTCS_TO) == pTabWin->GetAliasName() ) @@ -908,12 +904,9 @@ bool OQueryTableView::ShowTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // GetEntryPos, and then in turn by the Connection, when its starting point to the window must be determined. // the Connections - ::std::vector<OTableConnection*>& rTableCon = pUndoAction->GetTabConnList(); - ::std::vector<OTableConnection*>::iterator aIter = rTableCon.begin(); - ::std::vector<OTableConnection*>::iterator aEnd = rTableCon.end(); - - for(;aIter != aEnd;++aIter) - addConnection(*aIter); // add all connections from the undo action + auto rTableCon = pUndoAction->GetTabConnList(); + for(auto conn : rTableCon) + addConnection(conn); // add all connections from the undo action rTableCon.clear(); @@ -933,7 +926,7 @@ bool OQueryTableView::ShowTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // Initialisation failed // (for example when the Connection to the database is not available at the moment) pTabWin->clearListBox(); - delete pTabWin; + pTabWin->disposeOnce(); } } @@ -954,12 +947,9 @@ void OQueryTableView::InsertField(const OTableFieldDescRef& rInfo) bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) const { - const ::std::vector<OTableConnection*>& rList = getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aIter = rList.begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = rList.end(); - for(;aIter != aEnd;++aIter) + for(auto conn : getTableConnections()) { - OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(*aIter); + OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(conn.get()); if (pTemp->IsVisited() && (pFrom == static_cast< OQueryTableWindow*>(pTemp->GetSourceWin()) || pFrom == static_cast< OQueryTableWindow*>(pTemp->GetDestWin()))) return true; diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx index 107daa95ec2d..9c3e7412cc6a 100644 --- a/dbaccess/source/ui/querydesign/QueryTextView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx @@ -42,7 +42,7 @@ using namespace ::com::sun::star::frame; OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent) :Window(_pParent) { - m_pEdit = new OSqlEdit(this); + m_pEdit = VclPtr<OSqlEdit>::Create(this); m_pEdit->SetRightToLeft(false); m_pEdit->ClearModifyFlag(); m_pEdit->SaveValue(); @@ -52,8 +52,13 @@ OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent) OQueryTextView::~OQueryTextView() { - boost::scoped_ptr<vcl::Window> aTemp(m_pEdit); - m_pEdit = NULL; + disposeOnce(); +} + +void OQueryTextView::dispose() +{ + m_pEdit.disposeAndClear(); + vcl::Window::dispose(); } void OQueryTextView::GetFocus() diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx index cdc16fd0dea1..4baf60797154 100644 --- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx +++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx @@ -36,20 +36,12 @@ OQueryViewSwitch::OQueryViewSwitch(OQueryContainerWindow* _pParent, OQueryContro : m_bAddTableDialogWasVisible(false) { - m_pTextView = new OQueryTextView(_pParent); - m_pDesignView = new OQueryDesignView( _pParent, _rController, _rxContext ); + m_pTextView = VclPtr<OQueryTextView>::Create(_pParent); + m_pDesignView = VclPtr<OQueryDesignView>::Create( _pParent, _rController, _rxContext ); } OQueryViewSwitch::~OQueryViewSwitch() { - { - boost::scoped_ptr<vcl::Window> aTemp(m_pTextView); - m_pTextView = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pDesignView); - m_pDesignView = NULL; - } } void OQueryViewSwitch::Construct() diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index b628238191d9..05d3d05219db 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -117,12 +117,12 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) | BrowserMode::HLINES | BrowserMode::VLINES | BrowserMode::HEADERBAR_NEW ; - m_pTextCell = new Edit(&GetDataWindow(), 0); - m_pVisibleCell = new CheckBoxControl(&GetDataWindow()); - m_pTableCell = new ListBoxControl(&GetDataWindow()); m_pTableCell->SetDropDownLineCount( 20 ); - m_pFieldCell = new ComboBoxControl(&GetDataWindow()); m_pFieldCell->SetDropDownLineCount( 20 ); - m_pOrderCell = new ListBoxControl(&GetDataWindow()); - m_pFunctionCell = new ListBoxControl(&GetDataWindow()); m_pFunctionCell->SetDropDownLineCount( 20 ); + m_pTextCell = VclPtr<Edit>::Create(&GetDataWindow(), 0); + m_pVisibleCell = VclPtr<CheckBoxControl>::Create(&GetDataWindow()); + m_pTableCell = VclPtr<ListBoxControl>::Create(&GetDataWindow()); m_pTableCell->SetDropDownLineCount( 20 ); + m_pFieldCell = VclPtr<ComboBoxControl>::Create(&GetDataWindow()); m_pFieldCell->SetDropDownLineCount( 20 ); + m_pOrderCell = VclPtr<ListBoxControl>::Create(&GetDataWindow()); + m_pFunctionCell = VclPtr<ListBoxControl>::Create(&GetDataWindow()); m_pFunctionCell->SetDropDownLineCount( 20 ); m_pVisibleCell->SetHelpId(HID_QRYDGN_ROW_VISIBLE); m_pTableCell->SetHelpId(HID_QRYDGN_ROW_TABLE); @@ -154,13 +154,18 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) OSelectionBrowseBox::~OSelectionBrowseBox() { + disposeOnce(); +} - delete m_pTextCell; - delete m_pVisibleCell; - delete m_pFieldCell; - delete m_pTableCell; - delete m_pOrderCell; - delete m_pFunctionCell; +void OSelectionBrowseBox::dispose() +{ + m_pTextCell.disposeAndClear(); + m_pVisibleCell.disposeAndClear(); + m_pFieldCell.disposeAndClear(); + m_pTableCell.disposeAndClear(); + m_pOrderCell.disposeAndClear(); + m_pFunctionCell.disposeAndClear(); + ::svt::EditBrowseBox::dispose(); } void OSelectionBrowseBox::initialize() @@ -241,11 +246,13 @@ namespace { class OSelectionBrwBoxHeader : public ::svt::EditBrowserHeader { - OSelectionBrowseBox* m_pBrowseBox; + VclPtr<OSelectionBrowseBox> m_pBrowseBox; protected: virtual void Select() SAL_OVERRIDE; public: OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent); + virtual ~OSelectionBrwBoxHeader() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE { m_pBrowseBox.clear(); ::svt::EditBrowserHeader::dispose(); } }; OSelectionBrwBoxHeader::OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent) : ::svt::EditBrowserHeader(pParent,WB_BUTTONSTYLE|WB_DRAG) @@ -275,9 +282,9 @@ namespace } } -BrowserHeader* OSelectionBrowseBox::imp_CreateHeaderBar(BrowseBox* /*pParent*/) +VclPtr<BrowserHeader> OSelectionBrowseBox::imp_CreateHeaderBar(BrowseBox* /*pParent*/) { - return new OSelectionBrwBoxHeader(this); + return VclPtr<OSelectionBrwBoxHeader>::Create(this); } void OSelectionBrowseBox::ColumnMoved( sal_uInt16 nColId, bool _bCreateUndo ) @@ -491,7 +498,7 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon OJoinTableView::OTableWindowMap::iterator aEnd = rTabWinList.end(); for(;aIter != aEnd;++aIter) - m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second)->GetAliasName()); + m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second.get())->GetAliasName()); m_pTableCell->InsertEntry(OUString(ModuleRes(STR_QUERY_NOTABLE)), 0); if (!pEntry->GetAlias().isEmpty()) @@ -986,7 +993,7 @@ bool OSelectionBrowseBox::SaveModified() OJoinTableView::OTableWindowMap::iterator aIter = rTabWinList.find(aAliasName); if(aIter != rTabWinList.end()) { - OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second.get()); if (pEntryTab) { pEntry->SetTable(pEntryTab->GetTableName()); @@ -2603,7 +2610,7 @@ bool OSelectionBrowseBox::fillEntryTable(OTableFieldDescRef& _pEntry,const OUStr OJoinTableView::OTableWindowMap::iterator aIter = rTabWinList.find(_sTableName); if(aIter != rTabWinList.end()) { - OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second); + OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second.get()); if (pEntryTab) { _pEntry->SetTable(pEntryTab->GetTableName()); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index 6d3901e8d4ca..8c30610be159 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -56,12 +56,12 @@ namespace dbaui long m_nSeekRow; BrowserMode m_nMode; // remember the BrowseModes - Edit* m_pTextCell; - ::svt::CheckBoxControl* m_pVisibleCell; - ::svt::ComboBoxControl* m_pFieldCell; - ::svt::ListBoxControl* m_pFunctionCell; - ::svt::ListBoxControl* m_pTableCell; - ::svt::ListBoxControl* m_pOrderCell; + VclPtr<Edit> m_pTextCell; + VclPtr<::svt::CheckBoxControl> m_pVisibleCell; + VclPtr<::svt::ComboBoxControl> m_pFieldCell; + VclPtr<::svt::ListBoxControl> m_pFunctionCell; + VclPtr<::svt::ListBoxControl> m_pTableCell; + VclPtr<::svt::ListBoxControl> m_pOrderCell; OTableFieldDescRef m_pEmptyEntry; // default entry in the list may reference more than once @@ -80,6 +80,7 @@ namespace dbaui DECL_LINK(OnInvalidateTimer, void*); public: OSelectionBrowseBox( vcl::Window* pParent ); virtual ~OSelectionBrowseBox(); + virtual void dispose() SAL_OVERRIDE; void initialize(); OTableFieldDescRef InsertField( const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPosition = BROWSER_INVALIDID, bool bVis=true, bool bActivate=true ); @@ -205,7 +206,7 @@ namespace dbaui virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId) SAL_OVERRIDE; // if you want to have an own header ... - virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE; + virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE; void stopTimer(); void startTimer(); diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index 6d7864e06db7..457a58481c64 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -43,7 +43,7 @@ namespace dbaui Show(); } - OTableConnection::OTableConnection( const OTableConnection& _rConn ) : Window(_rConn.m_pParent) + OTableConnection::OTableConnection( const OTableConnection& _rConn ) : Window(_rConn.m_pParent.get()) ,m_pData(_rConn.GetData()->NewInstance()) ,m_pParent(NULL) { diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx index d27e3dadb494..db44c06a982b 100644 --- a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx +++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx @@ -23,6 +23,7 @@ #include <tools/debug.hxx> #include <com/sun/star/sdbc/DataType.hpp> #include <comphelper/namedvaluecollection.hxx> +#include <vcl/window.hxx> #include <functional> diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index 35888462af34..e0c1e5bf0ea3 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -69,8 +69,8 @@ namespace DatabaseObject = css::sdb::application::DatabaseObject; OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData ) : ::comphelper::OContainerListener(m_aMutex) ,Window( pParent, WB_3DLOOK|WB_MOVEABLE ) - ,m_aTypeImage( this ) - ,m_aTitle( this ) + ,m_aTypeImage( VclPtr<FixedImage>::Create(this) ) + ,m_aTitle( VclPtr<OTableWindowTitle>::Create(this) ) ,m_pListBox(NULL) ,m_pAccessible(NULL) ,m_pData( pTabWinData ) @@ -99,17 +99,23 @@ OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_ OTableWindow::~OTableWindow() { + disposeOnce(); +} +void OTableWindow::dispose() +{ if (m_pListBox) { OSL_ENSURE(m_pListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!"); - boost::scoped_ptr<vcl::Window> aTemp(m_pListBox); - m_pListBox = NULL; } + m_pListBox.disposeAndClear(); if ( m_pContainerListener.is() ) m_pContainerListener->dispose(); m_pAccessible = NULL; + m_aTypeImage.disposeAndClear(); + m_aTitle.disposeAndClear(); + vcl::Window::dispose(); } const OJoinTableView* OTableWindow::getTableView() const @@ -155,9 +161,9 @@ void OTableWindow::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SetSizePixel( rNewSize ); } -OTableWindowListBox* OTableWindow::CreateListBox() +VclPtr<OTableWindowListBox> OTableWindow::CreateListBox() { - return new OTableWindowListBox(this); + return VclPtr<OTableWindowListBox>::Create(this); } bool OTableWindow::FillListBox() @@ -263,8 +269,8 @@ void OTableWindow::impl_updateImage() return; } - m_aTypeImage.SetModeImage( aImage ); - m_aTypeImage.Show(); + m_aTypeImage->SetModeImage( aImage ); + m_aTypeImage->Show(); } bool OTableWindow::Init() @@ -273,13 +279,13 @@ bool OTableWindow::Init() if ( !m_pListBox ) { m_pListBox = CreateListBox(); - OSL_ENSURE( m_pListBox != NULL, "OTableWindow::Init() : CreateListBox returned NULL !" ); + OSL_ENSURE( m_pListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" ); m_pListBox->SetSelectionMode( MULTIPLE_SELECTION ); } // Set the title - m_aTitle.SetText( m_pData->GetWinName() ); - m_aTitle.Show(); + m_aTitle->SetText( m_pData->GetWinName() ); + m_aTitle->Show(); m_pListBox->Show(); @@ -456,15 +462,15 @@ void OTableWindow::Resize() long nPositionY = n5Pos; // position the image which indicates the type - m_aTypeImage.SetPosPixel( Point( nPositionX, nPositionY ) ); - Size aImageSize( m_aTypeImage.GetImage().GetSizePixel() ); - m_aTypeImage.SetSizePixel( aImageSize ); + m_aTypeImage->SetPosPixel( Point( nPositionX, nPositionY ) ); + Size aImageSize( m_aTypeImage->GetImage().GetSizePixel() ); + m_aTypeImage->SetSizePixel( aImageSize ); if ( nTitleHeight < aImageSize.Height() ) nTitleHeight = aImageSize.Height(); nPositionX += aImageSize.Width() + CalcZoom( 2 ); - m_aTitle.SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) ); + m_aTitle->SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) ); long nTitleToList = CalcZoom( 3 ); @@ -478,10 +484,10 @@ void OTableWindow::Resize() void OTableWindow::SetBoldTitle( bool bBold ) { - vcl::Font aFont = m_aTitle.GetFont(); + vcl::Font aFont = m_aTitle->GetFont(); aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL ); - m_aTitle.SetFont( aFont ); - m_aTitle.Invalidate(); + m_aTitle->SetFont( aFont ); + m_aTitle->Invalidate(); } void OTableWindow::GetFocus() @@ -559,7 +565,7 @@ void OTableWindow::StateChanged( StateChangedType nType ) aFont.Merge( GetControlFont() ); SetZoomedPointFont( aFont ); - m_aTitle.SetZoom(GetZoom()); + m_aTitle->SetZoom(GetZoom()); m_pListBox->SetZoom(GetZoom()); Resize(); Invalidate(); @@ -591,7 +597,7 @@ void OTableWindow::Command(const CommandEvent& rEvt) if ( pCurrent ) ptWhere = m_pListBox->GetEntryPosition(pCurrent); else - ptWhere = m_aTitle.GetPosPixel(); + ptWhere = m_aTitle->GetPosPixel(); } PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE)); @@ -746,7 +752,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) OUString OTableWindow::getTitle() const { - return m_aTitle.GetText(); + return m_aTitle->GetText(); } void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception) diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx index c122c96dc79d..82580fc83f02 100644 --- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx @@ -192,7 +192,7 @@ namespace dbaui if( m_pTable ) { OJoinTableView* pView = m_pTable->getTableView(); - ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable) + nIndex; + auto aIter = pView->getTableConnections(m_pTable) + nIndex; aRet.TargetSet.realloc(1); aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections().begin()); aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR; @@ -211,10 +211,10 @@ namespace dbaui if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable) { OJoinTableView* pView = m_pTable->getTableView(); - const ::std::vector<OTableConnection*>& rConnectionList = pView->getTableConnections(); + const auto& rConnectionList = pView->getTableConnections(); - ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable); - ::std::vector<OTableConnection*>::const_iterator aEnd = rConnectionList.end(); + auto aIter = pView->getTableConnections(m_pTable); + auto aEnd = rConnectionList.end(); ::std::vector< Reference<XInterface> > aRelations; aRelations.reserve(5); // just guessing for (; aIter != aEnd ; ++aIter ) diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx index 1796dcf8e574..2453bd292f67 100644 --- a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx @@ -68,13 +68,19 @@ void OTableWindowListBox::dragFinished( ) OTableWindowListBox::~OTableWindowListBox() { + disposeOnce(); +} + +void OTableWindowListBox::dispose() +{ if (m_nDropEvent) Application::RemoveUserEvent(m_nDropEvent); if (m_nUiEvent) Application::RemoveUserEvent(m_nUiEvent); if( m_aScrollTimer.IsActive() ) m_aScrollTimer.Stop(); - m_pTabWin = NULL; + m_pTabWin.clear(); + SvTreeListBox::dispose(); } SvTreeListEntry* OTableWindowListBox::GetEntryFromText( const OUString& rEntryText ) diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx index 79bcc29c871d..a0fba532d142 100644 --- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx @@ -55,7 +55,13 @@ OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) : OTableWindowTitle::~OTableWindowTitle() { - m_pTabWin = NULL; + disposeOnce(); +} + +void OTableWindowTitle::dispose() +{ + m_pTabWin.clear(); + FixedText::dispose(); } void OTableWindowTitle::GetFocus() @@ -130,10 +136,8 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView()); OSL_ENSURE(pView,"No OJoinTableView!"); - const ::std::vector<OTableConnection*>& rConns = pView->getTableConnections(); - ::std::for_each(rConns.begin(), - rConns.end(), - ::std::mem_fun(&OTableConnection::RecalcLines)); + for (auto conn : pView->getTableConnections()) + conn->RecalcLines(); pView->InvalidateConnections(); pView->getDesignView()->getController().setModified(sal_True); diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx index ad0c88866ed6..54a682e77482 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx @@ -34,7 +34,6 @@ class LimitBoxImpl: public LimitBox { public: LimitBoxImpl( vcl::Window* pParent, LimitBoxController* pCtrl ); - virtual ~LimitBoxImpl(); virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE; @@ -48,10 +47,6 @@ LimitBoxImpl::LimitBoxImpl( vcl::Window* pParent, LimitBoxController* pCtrl ) { } -LimitBoxImpl::~LimitBoxImpl() -{ -} - bool LimitBoxImpl::Notify( NotifyEvent& rNEvt ) { bool nHandled = false; @@ -144,8 +139,7 @@ throw (uno::RuntimeException, std::exception) svt::ToolboxController::dispose(); SolarMutexGuard aSolarMutexGuard; - delete m_pLimitBox; - m_pLimitBox = 0; + m_pLimitBox.disposeAndClear(); } /// XStatusListener @@ -206,7 +200,7 @@ uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createItemWindow( if ( pParent ) { SolarMutexGuard aSolarMutexGuard; - m_pLimitBox = new LimitBoxImpl(pParent, this); + m_pLimitBox = VclPtr<LimitBoxImpl>::Create(pParent, this); m_pLimitBox->SetSizePixel(m_pLimitBox->CalcBlockSize(6,1)); xItemWindow = VCLUnoHelper::GetInterface( m_pLimitBox ); } diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx index 1db59a8e6ebf..93401164eca1 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx @@ -13,6 +13,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <svtools/toolboxcontroller.hxx> #include <rtl/ustring.hxx> +#include <vcl/vclptr.hxx> #include "apitools.hxx" @@ -59,7 +60,7 @@ class LimitBoxController: public svt::ToolboxController, using svt::ToolboxController::dispatchCommand; private: - LimitBoxImpl* m_pLimitBox; + VclPtr<LimitBoxImpl> m_pLimitBox; }; } ///dbaui namespace diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx index 7372ec724d2a..9aa8ba3d6494 100644 --- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx +++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx @@ -49,20 +49,24 @@ namespace dbaui { m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rxContext ); - m_pSplitter = new Splitter(this,WB_VSCROLL); + m_pSplitter = VclPtr<Splitter>::Create(this,WB_VSCROLL); m_pSplitter->Hide(); m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) ); m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); } OQueryContainerWindow::~OQueryContainerWindow() { + disposeOnce(); + } + void OQueryContainerWindow::dispose() + { { boost::scoped_ptr<OQueryViewSwitch> aTemp(m_pViewSwitch); m_pViewSwitch = NULL; } if ( m_pBeamer ) ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pBeamer = NULL; + m_pBeamer.clear(); if ( m_xBeamer.is() ) { Reference< ::com::sun::star::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY); @@ -71,9 +75,8 @@ namespace dbaui xCloseable->close(sal_False); // false - holds the ownership of this frame } - boost::scoped_ptr<vcl::Window> aTemp(m_pSplitter); - m_pSplitter = NULL; - + m_pSplitter.disposeAndClear(); + ODataView::dispose(); } bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo ) { @@ -171,7 +174,7 @@ namespace dbaui { if(!m_pBeamer) { - m_pBeamer = new OBeamer(this); + m_pBeamer = VclPtr<OBeamer>::Create(this); ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::AddWindow)); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 92dde0c697a5..ad454569a103 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -763,9 +763,9 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& if ( pNode ) { vcl::Window* pView = getView(); - ModalDialog* pWindow = new ModalDialog( pView, WB_STDMODAL | WB_SIZEMOVE | WB_CENTER ); + ScopedVclPtrInstance<ModalDialog> pWindow( pView, WB_STDMODAL | WB_SIZEMOVE | WB_CENTER ); pWindow->SetSizePixel( ::Size( pView->GetSizePixel().Width() / 2, pView->GetSizePixel().Height() / 2 ) ); - SvTreeListBox* pTreeBox = new SvTreeListBox( pWindow, WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_VSCROLL ); + ScopedVclPtrInstance<SvTreeListBox> pTreeBox( pWindow, WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_VSCROLL ); pTreeBox->SetPosSizePixel( ::Point( 6, 6 ), ::Size( pWindow->GetSizePixel().Width() - 12, pWindow->GetSizePixel().Height() - 12 )); pTreeBox->SetNodeDefaultImages(); @@ -799,8 +799,6 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& pTreeBox->Show(); pWindow->Execute(); - delete pTreeBox; - delete pWindow; delete pNode; } break; @@ -987,8 +985,8 @@ void OQueryController::impl_initialize() OUString aTitle( ModuleRes( STR_QUERYDESIGN_NO_VIEW_SUPPORT ) ); OUString aMessage( ModuleRes( STR_QUERYDESIGN_NO_VIEW_ASK ) ); ODataView* pWindow = getView(); - OSQLMessageBox aDlg( pWindow, aTitle, aMessage, WB_YES_NO | WB_DEF_YES, OSQLMessageBox::Query ); - bClose = aDlg.Execute() == RET_NO; + ScopedVclPtrInstance< OSQLMessageBox > aDlg( pWindow, aTitle, aMessage, WB_YES_NO | WB_DEF_YES, OSQLMessageBox::Query ); + bClose = aDlg->Execute() == RET_NO; } if ( bClose ) throw VetoException(); @@ -1117,7 +1115,7 @@ bool OQueryController::Construct(vcl::Window* pParent) { // TODO: we have to check if we should create the text view or the design view - setView( * new OQueryContainerWindow( pParent, *this, getORB() ) ); + setView( VclPtr<OQueryContainerWindow>::Create( pParent, *this, getORB() ) ); return OJoinController::Construct(pParent); } @@ -1238,13 +1236,13 @@ void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollectio void OQueryController::execute_QueryPropDlg() { - QueryPropertiesDialog aQueryPropDlg( + ScopedVclPtrInstance<QueryPropertiesDialog> aQueryPropDlg( getContainer(), m_bDistinct, m_nLimit ); - if( aQueryPropDlg.Execute() == RET_OK ) + if( aQueryPropDlg->Execute() == RET_OK ) { - m_bDistinct = aQueryPropDlg.getDistinct(); - m_nLimit = aQueryPropDlg.getLimit(); + m_bDistinct = aQueryPropDlg->getDistinct(); + m_nLimit = aQueryPropDlg->getLimit(); InvalidateFeature( SID_QUERY_DISTINCT_VALUES ); InvalidateFeature( SID_QUERY_LIMIT, 0, true ); } @@ -1398,7 +1396,7 @@ bool OQueryController::askForNewName(const Reference<XNameAccess>& _xElements, b } DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY ); - OSaveAsDlg aDlg( + ScopedVclPtrInstance<OSaveAsDlg> aDlg( getView(), m_nCommandType, getORB(), @@ -1407,14 +1405,14 @@ bool OQueryController::askForNewName(const Reference<XNameAccess>& _xElements, b aNameChecker, SAD_DEFAULT ); - bRet = ( aDlg.Execute() == RET_OK ); + bRet = ( aDlg->Execute() == RET_OK ); if ( bRet ) { - m_sName = aDlg.getName(); + m_sName = aDlg->getName(); if ( editingView() ) { - m_sUpdateCatalogName = aDlg.getCatalog(); - m_sUpdateSchemaName = aDlg.getSchema(); + m_sUpdateCatalogName = aDlg->getCatalog(); + m_sUpdateSchemaName = aDlg->getSchema(); } } } @@ -1802,9 +1800,9 @@ short OQueryController::saveModified() ) { OUString sMessageText( lcl_getObjectResourceString( STR_QUERY_SAVEMODIFIED, m_nCommandType ) ); - QueryBox aQry( getView(), WB_YES_NO_CANCEL | WB_DEF_YES, sMessageText ); + ScopedVclPtrInstance< QueryBox > aQry( getView(), WB_YES_NO_CANCEL | WB_DEF_YES, sMessageText ); - nRet = aQry.Execute(); + nRet = aQry->Execute(); if ( ( nRet == RET_YES ) && !doSaveAsDoc( false ) ) @@ -1914,8 +1912,8 @@ void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings if ( !i_bForceCurrentControllerSettings && !editingView() ) { OUString aTitle(ModuleRes(STR_SVT_SQL_SYNTAX_ERROR)); - OSQLMessageBox aDlg(getView(),aTitle,aErrorMsg); - aDlg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aDlg(getView(),aTitle,aErrorMsg); + aDlg->Execute(); } bError = true; } diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx index 6263d0cd52a7..798fcaef3d80 100644 --- a/dbaccess/source/ui/querydesign/querydlg.cxx +++ b/dbaccess/source/ui/querydesign/querydlg.cxx @@ -139,7 +139,18 @@ DlgQryJoin::DlgQryJoin( OQueryTableView * pParent, DlgQryJoin::~DlgQryJoin() { + disposeOnce(); +} + +void DlgQryJoin::dispose() +{ delete m_pTableControl; + m_pML_HelpText.clear(); + m_pPB_OK.clear(); + m_pLB_JoinType.clear(); + m_pCBNatural.clear(); + m_pTableView.clear(); + ModalDialog::dispose(); } IMPL_LINK( DlgQryJoin, LBChangeHdl, ListBox*, /*pListBox*/ ) diff --git a/dbaccess/source/ui/querydesign/querydlg.hxx b/dbaccess/source/ui/querydesign/querydlg.hxx index e8ce875cbdea..ec31515d007e 100644 --- a/dbaccess/source/ui/querydesign/querydlg.hxx +++ b/dbaccess/source/ui/querydesign/querydlg.hxx @@ -39,14 +39,14 @@ namespace dbaui ,public IRelationControlInterface { protected: - FixedText* m_pML_HelpText; - OKButton* m_pPB_OK; - ListBox* m_pLB_JoinType; - CheckBox* m_pCBNatural; + VclPtr<FixedText> m_pML_HelpText; + VclPtr<OKButton> m_pPB_OK; + VclPtr<ListBox> m_pLB_JoinType; + VclPtr<CheckBox> m_pCBNatural; OTableListBoxControl* m_pTableControl; OJoinTableView::OTableWindowMap* m_pTableMap; - OQueryTableView* m_pTableView; + VclPtr<OQueryTableView> m_pTableView; EJoinType eJoinType; TTableConnectionData::value_type m_pConnData; // contains left and right table @@ -69,6 +69,7 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, bool _bAllowTableSelect); virtual ~DlgQryJoin(); + virtual void dispose() SAL_OVERRIDE; EJoinType GetJoinType() const { return eJoinType; }; /** getConnectionData returns the current connection data diff --git a/dbaccess/source/ui/querydesign/queryview.cxx b/dbaccess/source/ui/querydesign/queryview.cxx index a10a73045a0b..c18ef092d24d 100644 --- a/dbaccess/source/ui/querydesign/queryview.cxx +++ b/dbaccess/source/ui/querydesign/queryview.cxx @@ -30,9 +30,4 @@ OQueryView::OQueryView(vcl::Window* _pParent, OQueryController& _rController,con } -OQueryView::~OQueryView() -{ - -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx index 03a9b56c8826..1f18d83af39a 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx @@ -38,10 +38,6 @@ ORelationTableConnection::ORelationTableConnection( const ORelationTableConnecti // no own members, thus the base class functionality is enough } -ORelationTableConnection::~ORelationTableConnection() -{ -} - ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn ) { // this doesn't change anything, since the base class tests this, too and I don't have my own members to copy diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.hxx b/dbaccess/source/ui/relationdesign/RTableConnection.hxx index 24339b521a23..3ebea9b873f3 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnection.hxx +++ b/dbaccess/source/ui/relationdesign/RTableConnection.hxx @@ -31,7 +31,6 @@ namespace dbaui ORelationTableConnection( ORelationTableView* pContainer, const TTableConnectionData::value_type& pTabConnData ); ORelationTableConnection( const ORelationTableConnection& rConn ); // wichtiger Kommentar zum CopyConstructor siehe OTableConnection(const OTableConnection&) - virtual ~ORelationTableConnection(); ORelationTableConnection& operator=( const ORelationTableConnection& rConn ); diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index 2bc001a585bf..430d0a35aef0 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -205,8 +205,8 @@ void ORelationController::impl_initialize() { OUString sTitle(ModuleRes(STR_RELATIONDESIGN)); sTitle = sTitle.copy(3); - OSQLMessageBox aDlg(NULL,sTitle,ModuleRes(STR_RELATIONDESIGN_NOT_AVAILABLE)); - aDlg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aDlg(nullptr,sTitle,ModuleRes(STR_RELATIONDESIGN_NOT_AVAILABLE)); + aDlg->Execute(); } disconnect(); throw SQLException(); @@ -245,7 +245,7 @@ OUString ORelationController::getPrivateTitle( ) const bool ORelationController::Construct(vcl::Window* pParent) { - setView( * new ORelationDesignView( pParent, *this, getORB() ) ); + setView( VclPtr<ORelationDesignView>::Create( pParent, *this, getORB() ) ); OJoinController::Construct(pParent); return true; } @@ -255,9 +255,9 @@ short ORelationController::saveModified() short nSaved = RET_YES; if(haveDataSource() && isModified()) { - MessageDialog aQry(getView(), "DesignSaveModifiedDialog", - "dbaccess/ui/designsavemodifieddialog.ui"); - nSaved = aQry.Execute(); + ScopedVclPtrInstance<MessageDialog> aQry(getView(), "DesignSaveModifiedDialog", + "dbaccess/ui/designsavemodifieddialog.ui"); + nSaved = aQry->Execute(); if(nSaved == RET_YES) Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>()); } diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx index a27f4a5b2eb6..72e75deb07b9 100644 --- a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx @@ -50,13 +50,9 @@ ORelationDesignView::ORelationDesignView(vcl::Window* _pParent, ORelationControl { } -ORelationDesignView::~ORelationDesignView() -{ -} - void ORelationDesignView::Construct() { - m_pTableView = new ORelationTableView(m_pScrollWindow,this); + m_pTableView = VclPtr<ORelationTableView>::Create(m_pScrollWindow,this); OJoinDesignView::Construct(); } diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index 38ee81fb1715..06f5839c8483 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -73,8 +73,15 @@ ORelationTableView::ORelationTableView( vcl::Window* pParent, ORelationDesignVie ORelationTableView::~ORelationTableView() { + disposeOnce(); +} + +void ORelationTableView::dispose() +{ if ( m_pContainerListener.is() ) m_pContainerListener->dispose(); + m_pExistingConnection.clear(); + OJoinTableView::dispose(); } void ORelationTableView::ReSync() @@ -99,14 +106,14 @@ void ORelationTableView::ReSync() for(;aIter != rTabWinDataList.rend();++aIter) { TTableWindowData::value_type pData = *aIter; - OTableWindow* pTabWin = createWindow(pData); + VclPtr<OTableWindow> pTabWin = createWindow(pData); if (!pTabWin->Init()) { // initialisation failed, which means this TabWin is not available, therefore, // it should be cleaned up, including its data in the document pTabWin->clearListBox(); - delete pTabWin; + pTabWin.disposeAndClear(); arrInvalidTables.push_back(pData->GetTableName()); rTabWinDataList.erase( ::std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), *aIter), rTabWinDataList.end()); @@ -144,7 +151,7 @@ void ORelationTableView::ReSync() } } - addConnection( new ORelationTableConnection(this, *aConIter), false ); // don't add the data again + addConnection( VclPtr<ORelationTableConnection>::Create(this, *aConIter), false ); } if ( !GetTabWinMap().empty() ) @@ -164,8 +171,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OTableWindow* pSourceWin = jxdSource.pListBox->GetTabWin(); OTableWindow* pDestWin = jxdDest.pListBox->GetTabWin(); - ::std::vector<OTableConnection*>::const_iterator aIter = getTableConnections().begin(); - ::std::vector<OTableConnection*>::const_iterator aEnd = getTableConnections().end(); + auto aIter = getTableConnections().begin(); + auto aEnd = getTableConnections().end(); for(;aIter != aEnd;++aIter) { OTableConnection* pFirst = *aIter; @@ -200,7 +207,7 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const if( pTabConnData->Update() ) { // enter UI-object into ConnList - addConnection( new ORelationTableConnection( this, pTabConnData ) ); + addConnection( VclPtr<ORelationTableConnection>::Create( this, pTabConnData ) ); } } catch(const SQLException&) @@ -216,8 +223,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const void ORelationTableView::ConnDoubleClicked( OTableConnection* pConnection ) { - ORelationDialog aRelDlg( this, pConnection->GetData() ); - switch (aRelDlg.Execute()) + ScopedVclPtrInstance< ORelationDialog > aRelDlg( this, pConnection->GetData() ); + switch (aRelDlg->Execute()) { case RET_OK: // successfully updated @@ -244,14 +251,14 @@ void ORelationTableView::AddNewRelation() { TTableConnectionData::value_type pNewConnData( new ORelationTableConnectionData() ); - ORelationDialog aRelDlg(this, pNewConnData, true); + ScopedVclPtrInstance< ORelationDialog > aRelDlg(this, pNewConnData, true); - bool bSuccess = (aRelDlg.Execute() == RET_OK); + bool bSuccess = (aRelDlg->Execute() == RET_OK); if (bSuccess) { // already updated by the dialog // announce it to the document - addConnection( new ORelationTableConnection(this, pNewConnData) ); + addConnection( VclPtr<ORelationTableConnection>::Create(this, pNewConnData) ); } } @@ -293,7 +300,7 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin pNewTabWinData->ShowAll(false); // link new window into the window list - OTableWindow* pNewTabWin = createWindow( pNewTabWinData ); + VclPtr<OTableWindow> pNewTabWin = createWindow( pNewTabWinData ); if(pNewTabWin->Init()) { m_pView->getController().getTableWindowData().push_back( pNewTabWinData); @@ -313,14 +320,14 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin else { pNewTabWin->clearListBox(); - delete pNewTabWin; + pNewTabWin.disposeAndClear(); } } void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin ) { - OSQLWarningBox aDlg( this, ModuleRes( STR_QUERY_REL_DELETE_WINDOW ), WB_YES_NO | WB_DEF_YES ); - if ( m_bInRemove || aDlg.Execute() == RET_YES ) + ScopedVclPtrInstance< OSQLWarningBox > aDlg( this, ModuleRes( STR_QUERY_REL_DELETE_WINDOW ), WB_YES_NO | WB_DEF_YES ); + if ( m_bInRemove || aDlg->Execute() == RET_YES ) { m_pView->getController().ClearUndoManager(); OJoinTableView::RemoveTabWin( pTabWin ); @@ -337,13 +344,13 @@ void ORelationTableView::lookForUiActivities() { OUString sTitle(ModuleRes(STR_RELATIONDESIGN)); sTitle = sTitle.copy(3); - OSQLMessageBox aDlg(this,ModuleRes(STR_QUERY_REL_EDIT_RELATION),OUString(),0); - aDlg.SetText(sTitle); - aDlg.RemoveButton(aDlg.GetButtonId(0)); - aDlg.AddButton( ModuleRes(STR_QUERY_REL_EDIT), RET_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON); - aDlg.AddButton( ModuleRes(STR_QUERY_REL_CREATE), RET_YES, 0); - aDlg.AddButton( StandardButtonType::Cancel,RET_CANCEL,0); - sal_uInt16 nRet = aDlg.Execute(); + ScopedVclPtrInstance< OSQLMessageBox > aDlg(this,ModuleRes(STR_QUERY_REL_EDIT_RELATION),OUString(),0); + aDlg->SetText(sTitle); + aDlg->RemoveButton(aDlg->GetButtonId(0)); + aDlg->AddButton( ModuleRes(STR_QUERY_REL_EDIT), RET_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON); + aDlg->AddButton( ModuleRes(STR_QUERY_REL_CREATE), RET_YES, 0); + aDlg->AddButton( StandardButtonType::Cancel,RET_CANCEL,0); + sal_uInt16 nRet = aDlg->Execute(); if( nRet == RET_CANCEL) { m_pCurrentlyTabConnData.reset(); @@ -357,19 +364,19 @@ void ORelationTableView::lookForUiActivities() } if(m_pCurrentlyTabConnData) { - ORelationDialog aRelDlg( this, m_pCurrentlyTabConnData ); - if (aRelDlg.Execute() == RET_OK) + ScopedVclPtrInstance< ORelationDialog > aRelDlg( this, m_pCurrentlyTabConnData ); + if (aRelDlg->Execute() == RET_OK) { // already updated by the dialog - addConnection( new ORelationTableConnection( this, m_pCurrentlyTabConnData ) ); + addConnection( VclPtr<ORelationTableConnection>::Create( this, m_pCurrentlyTabConnData ) ); } m_pCurrentlyTabConnData.reset(); } } -OTableWindow* ORelationTableView::createWindow(const TTableWindowData::value_type& _pData) +VclPtr<OTableWindow> ORelationTableView::createWindow(const TTableWindowData::value_type& _pData) { - return new ORelationTableWindow(this,_pData); + return VclPtr<ORelationTableWindow>::Create(this,_pData); } bool ORelationTableView::allowQueries() const diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx index 94f646154b58..3252a5dd510a 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx @@ -31,15 +31,20 @@ using namespace dbaui; OFieldDescGenWin::OFieldDescGenWin( vcl::Window* pParent, OTableDesignHelpBar* pHelp ) : TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL ) { - m_pFieldControl = new OTableFieldControl(this,pHelp); + m_pFieldControl = VclPtr<OTableFieldControl>::Create(this,pHelp); m_pFieldControl->SetHelpId(HID_TAB_DESIGN_FIELDCONTROL); m_pFieldControl->Show(); } OFieldDescGenWin::~OFieldDescGenWin() { - boost::scoped_ptr<vcl::Window> aTemp(m_pFieldControl); - m_pFieldControl = NULL; + disposeOnce(); +} + +void OFieldDescGenWin::dispose() +{ + m_pFieldControl.disposeAndClear(); + TabPage::dispose(); } void OFieldDescGenWin::Init() @@ -74,7 +79,6 @@ void OFieldDescGenWin::SetControlText( sal_uInt16 nControlId, const OUString& rT void OFieldDescGenWin::DisplayData( OFieldDescription* pFieldDescr ) { - m_pFieldControl->DisplayData(pFieldDescr); } diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx index 1af0ffd68876..04011c61c340 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx +++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx @@ -32,13 +32,14 @@ namespace dbaui ,public IClipboardTest { - OTableFieldControl *m_pFieldControl; + VclPtr<OTableFieldControl> m_pFieldControl; protected: virtual void Resize() SAL_OVERRIDE; public: OFieldDescGenWin( vcl::Window* pParent, OTableDesignHelpBar* pHelpBar ); virtual ~OFieldDescGenWin(); + virtual void dispose() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; virtual void LoseFocus() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 5e1be232385e..d8321b173b39 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -210,19 +210,19 @@ void OTableEditorCtrl::InitCellController() OSL_FAIL("getMaxColumnNameLength"); } - pNameCell = new OSQLNameEdit(&GetDataWindow(), WB_LEFT, sExtraNameChars); + pNameCell = VclPtr<OSQLNameEdit>::Create(&GetDataWindow(), WB_LEFT, sExtraNameChars); pNameCell->SetMaxTextLen( nMaxTextLen ); pNameCell->setCheck( isSQL92CheckEnabled(xCon) ); // Cell type - pTypeCell = new ListBoxControl( &GetDataWindow() ); + pTypeCell = VclPtr<ListBoxControl>::Create( &GetDataWindow() ); pTypeCell->SetDropDownLineCount( 15 ); // Cell description - pDescrCell = new Edit( &GetDataWindow(), WB_LEFT ); + pDescrCell = VclPtr<Edit>::Create( &GetDataWindow(), WB_LEFT ); pDescrCell->SetMaxTextLen( MAX_DESCR_LEN ); - pHelpTextCell = new Edit( &GetDataWindow(), WB_LEFT ); + pHelpTextCell = VclPtr<Edit>::Create( &GetDataWindow(), WB_LEFT ); pHelpTextCell->SetMaxTextLen( MAX_DESCR_LEN ); pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL); @@ -253,6 +253,11 @@ void OTableEditorCtrl::ClearModified() OTableEditorCtrl::~OTableEditorCtrl() { + disposeOnce(); +} + +void OTableEditorCtrl::dispose() +{ // Reset the Undo-Manager GetUndoManager().Clear(); @@ -269,10 +274,12 @@ OTableEditorCtrl::~OTableEditorCtrl() Application::RemoveUserEvent( nInvalidateTypeEvent ); // Delete the control types - delete pNameCell; - delete pTypeCell; - delete pDescrCell; - delete pHelpTextCell; + pNameCell.disposeAndClear(); + pTypeCell.disposeAndClear(); + pDescrCell.disposeAndClear(); + pHelpTextCell.disposeAndClear(); + pDescrWin.clear(); + OTableRowView::dispose(); } bool OTableEditorCtrl::SetDataPtr( long nRow ) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx index bfae245eca31..03f9b4598c67 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.hxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx @@ -46,11 +46,11 @@ namespace dbaui ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList; ::std::vector< ::boost::shared_ptr<OTableRow> >* m_pRowList; - OSQLNameEdit* pNameCell; - ::svt::ListBoxControl* pTypeCell; - Edit* pHelpTextCell; - Edit* pDescrCell; - OTableFieldDescWin* pDescrWin; // properties of one column + VclPtr<OSQLNameEdit> pNameCell; + VclPtr<::svt::ListBoxControl> pTypeCell; + VclPtr<Edit> pHelpTextCell; + VclPtr<Edit> pDescrCell; + VclPtr<OTableFieldDescWin> pDescrWin; // properties of one column ::boost::shared_ptr<OTableRow> pActRow; @@ -71,7 +71,7 @@ namespace dbaui { private: AutoTimer m_aInvalidateTimer; - OTableEditorCtrl* m_pOwner; + VclPtr<OTableEditorCtrl> m_pOwner; public: ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl*); @@ -122,6 +122,7 @@ namespace dbaui public: OTableEditorCtrl(vcl::Window* pParentWin); virtual ~OTableEditorCtrl(); + virtual void dispose() SAL_OVERRIDE; virtual bool CursorMoving(long nNewRow, sal_uInt16 nNewCol) SAL_OVERRIDE; SfxUndoManager& GetUndoManager() const; diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index a242f10d5bbe..bb7df8cd65f8 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -285,7 +285,7 @@ bool OTableController::doSaveDoc(bool _bSaveAs) if (!xTablesSup.is()) { OUString aMessage(ModuleRes(STR_TABLEDESIGN_CONNECTION_MISSING)); - OSQLWarningBox( getView(), aMessage ).Execute(); + ScopedVclPtrInstance<OSQLWarningBox>(getView(), aMessage )->Execute(); return false; } @@ -318,13 +318,13 @@ bool OTableController::doSaveDoc(bool _bSaveAs) } DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::TABLE ); - OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), getConnection(), aDefaultName, aNameChecker ); - if ( aDlg.Execute() != RET_OK ) + ScopedVclPtrInstance< OSaveAsDlg > aDlg( getView(), CommandType::TABLE, getORB(), getConnection(), aDefaultName, aNameChecker ); + if ( aDlg->Execute() != RET_OK ) return false; - m_sName = aDlg.getName(); - sCatalog = aDlg.getCatalog(); - sSchema = aDlg.getSchema(); + m_sName = aDlg->getName(); + sCatalog = aDlg->getCatalog(); + sSchema = aDlg->getSchema(); } // did we get a name @@ -415,9 +415,9 @@ bool OTableController::doSaveDoc(bool _bSaveAs) { OUString sText( ModuleRes( STR_NAME_ALREADY_EXISTS ) ); sText = sText.replaceFirst( "#" , m_sName); - OSQLMessageBox aDlg( getView(), OUString( ModuleRes( STR_ERROR_DURING_CREATION ) ), sText, WB_OK, OSQLMessageBox::Error ); + ScopedVclPtrInstance< OSQLMessageBox > aDlg( getView(), OUString( ModuleRes( STR_ERROR_DURING_CREATION ) ), sText, WB_OK, OSQLMessageBox::Error ); - aDlg.Execute(); + aDlg->Execute(); bError = true; } catch( const Exception& ) @@ -447,8 +447,8 @@ void OTableController::doEditIndexes() // table needs to be saved before editing indexes if (m_bNew || isModified()) { - MessageDialog aAsk(getView(), ModuleRes(STR_QUERY_SAVE_TABLE_EDIT_INDEXES), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - if (RET_YES != aAsk.Execute()) + ScopedVclPtrInstance< MessageDialog > aAsk(getView(), ModuleRes(STR_QUERY_SAVE_TABLE_EDIT_INDEXES), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + if (RET_YES != aAsk->Execute()) return; if (!doSaveDoc(false)) @@ -490,8 +490,8 @@ void OTableController::doEditIndexes() if (!xIndexes.is()) return; - DbaIndexDialog aDialog(getView(), aFieldNames, xIndexes, getConnection(), getORB(), isConnected() && getConnection()->getMetaData().is() ? getConnection()->getMetaData()->getMaxColumnsInIndex() : 0); - if (RET_OK != aDialog.Execute()) + ScopedVclPtrInstance< DbaIndexDialog > aDialog(getView(), aFieldNames, xIndexes, getConnection(), getORB(), isConnected() && getConnection()->getMetaData().is() ? getConnection()->getMetaData()->getMaxColumnsInIndex() : 0); + if (RET_OK != aDialog->Execute()) return; } @@ -522,7 +522,7 @@ void OTableController::impl_initialize() } catch(const SQLException&) { - OSQLWarningBox( getView(), ModuleRes( STR_NO_TYPE_INFO_AVAILABLE ) ).Execute(); + ScopedVclPtrInstance<OSQLWarningBox>(getView(), ModuleRes( STR_NO_TYPE_INFO_AVAILABLE ))->Execute(); throw; } try @@ -540,7 +540,7 @@ void OTableController::impl_initialize() bool OTableController::Construct(vcl::Window* pParent) { - setView( * new OTableDesignView( pParent, getORB(), *this ) ); + setView( VclPtr<OTableDesignView>::Create( pParent, getORB(), *this ) ); OTableController_BASE::Construct(pParent); return true; } @@ -563,9 +563,9 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti ::boost::mem_fn(&OTableRow::isValid)); if ( aIter != m_vRowList.end() ) { - MessageDialog aQry(getView(), "TableDesignSaveModifiedDialog", - "dbaccess/ui/tabledesignsavemodifieddialog.ui"); - switch (aQry.Execute()) + ScopedVclPtrInstance<MessageDialog> aQry(getView(), "TableDesignSaveModifiedDialog", + "dbaccess/ui/tabledesignsavemodifieddialog.ui"); + switch (aQry->Execute()) { case RET_YES: Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>()); @@ -580,9 +580,9 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti } else if ( !m_bNew ) { - MessageDialog aQry(getView(), "DeleteAllRowsDialog", - "dbaccess/ui/deleteallrowsdialog.ui"); - switch (aQry.Execute()) + ScopedVclPtrInstance<MessageDialog> aQry(getView(), "DeleteAllRowsDialog", + "dbaccess/ui/deleteallrowsdialog.ui"); + switch (aQry->Execute()) { case RET_YES: { @@ -936,7 +936,7 @@ bool OTableController::checkColumns(bool _bNew) { OUString strMessage = ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME); strMessage = strMessage.replaceFirst("$column$", pFieldDesc->GetName()); - OSQLWarningBox( getView(), strMessage ).Execute(); + ScopedVclPtrInstance<OSQLWarningBox>(getView(), strMessage)->Execute(); return false; } } @@ -946,9 +946,9 @@ bool OTableController::checkColumns(bool _bNew) { OUString sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); OUString sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); - OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); + ScopedVclPtrInstance< OSQLMessageBox > aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); - switch ( aBox.Execute() ) + switch ( aBox->Execute() ) { case RET_YES: { @@ -1075,8 +1075,8 @@ void OTableController::alterColumns() aMessage = aMessage.replaceFirst( "$column$", pField->GetName() ); SQLExceptionInfo aError( ::cppu::getCaughtException() ); - OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES , &aError ); - bNotOk = aMsg.Execute() == RET_YES; + ScopedVclPtrInstance< OSQLWarningBox > aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES , &aError ); + bNotOk = aMsg->Execute() == RET_YES; } else throw; @@ -1131,8 +1131,8 @@ void OTableController::alterColumns() { OUString aMessage(ModuleRes(STR_TABLEDESIGN_ALTER_ERROR)); aMessage = aMessage.replaceFirst("$column$",pField->GetName()); - OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES ); - if ( aMsg.Execute() != RET_YES ) + ScopedVclPtrInstance< OSQLWarningBox > aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES ); + if ( aMsg->Execute() != RET_YES ) { Reference<XPropertySet> xNewColumn(xIdxColumns->getByIndex(nPos),UNO_QUERY_THROW); OUString sName; @@ -1198,8 +1198,8 @@ void OTableController::alterColumns() OUString aMsgT(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN)); aMsgT = aMsgT.replaceFirst("$column$",*pIter); OUString aTitle(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE)); - OSQLMessageBox aMsg(getView(),aTitle,aMsgT,WB_YES_NO| WB_DEF_YES); - if(aMsg.Execute() == RET_YES) + ScopedVclPtrInstance< OSQLMessageBox > aMsg(getView(),aTitle,aMsgT,WB_YES_NO| WB_DEF_YES); + if(aMsg->Execute() == RET_YES) { xKeyColumns = NULL; dropPrimaryKey(); diff --git a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx index a92af1c10353..81dfc575169d 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx @@ -48,11 +48,6 @@ OTableRowView::OTableRowView(vcl::Window* pParent) } -OTableRowView::~OTableRowView() -{ - -} - void OTableRowView::Init() { EditBrowseBox::Init(); diff --git a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx index a5f2010fb15d..5c1fcc11f340 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx @@ -29,7 +29,7 @@ using namespace dbaui; OTableDesignHelpBar::OTableDesignHelpBar( vcl::Window* pParent ) : TabPage( pParent, WB_3DLOOK ) { - m_pTextWin = new MultiLineEdit( this, WB_VSCROLL | WB_LEFT | WB_BORDER | WB_NOTABSTOP | WB_READONLY); + m_pTextWin = VclPtr<MultiLineEdit>::Create( this, WB_VSCROLL | WB_LEFT | WB_BORDER | WB_NOTABSTOP | WB_READONLY); m_pTextWin->SetHelpId(HID_TABLE_DESIGN_HELP_WINDOW); m_pTextWin->SetReadOnly(); m_pTextWin->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() ); @@ -38,8 +38,13 @@ OTableDesignHelpBar::OTableDesignHelpBar( vcl::Window* pParent ) : OTableDesignHelpBar::~OTableDesignHelpBar() { - boost::scoped_ptr<vcl::Window> aTemp(m_pTextWin); - m_pTextWin = NULL; + disposeOnce(); +} + +void OTableDesignHelpBar::dispose() +{ + m_pTextWin.disposeAndClear(); + TabPage::dispose(); } void OTableDesignHelpBar::SetHelpText( const OUString& rText ) diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx index 996a84c0e162..9b5598f11a9b 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx @@ -42,13 +42,13 @@ using namespace ::com::sun::star::beans; // class OTableBorderWindow OTableBorderWindow::OTableBorderWindow(vcl::Window* pParent) : Window(pParent,WB_BORDER) - ,m_aHorzSplitter( this ) + ,m_aHorzSplitter( VclPtr<Splitter>::Create(this) ) { ImplInitSettings( true, true, true ); // Children erzeugen - m_pEditorCtrl = new OTableEditorCtrl( this); - m_pFieldDescWin = new OTableFieldDescWin( this ); + m_pEditorCtrl = VclPtr<OTableEditorCtrl>::Create( this); + m_pFieldDescWin = VclPtr<OTableFieldDescWin>::Create( this ); m_pFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN); @@ -56,26 +56,25 @@ OTableBorderWindow::OTableBorderWindow(vcl::Window* pParent) : Window(pParent,WB m_pEditorCtrl->SetDescrWin(m_pFieldDescWin); // Splitter einrichten - m_aHorzSplitter.SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) ); - m_aHorzSplitter.Show(); + m_aHorzSplitter->SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) ); + m_aHorzSplitter->Show(); } OTableBorderWindow::~OTableBorderWindow() { + disposeOnce(); +} + +void OTableBorderWindow::dispose() +{ // Children zerstoeren // ::dbaui::notifySystemWindow(this,m_pFieldDescWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); m_pEditorCtrl->Hide(); m_pFieldDescWin->Hide(); - - { - boost::scoped_ptr<vcl::Window> aTemp(m_pEditorCtrl); - m_pEditorCtrl = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pFieldDescWin); - m_pFieldDescWin = NULL; - } - + m_pEditorCtrl.disposeAndClear(); + m_pFieldDescWin.disposeAndClear(); + m_aHorzSplitter.disposeAndClear(); + vcl::Window::dispose(); } void OTableBorderWindow::Resize() @@ -86,18 +85,18 @@ void OTableBorderWindow::Resize() Size aOutputSize( GetOutputSize() ); long nOutputWidth = aOutputSize.Width(); long nOutputHeight = aOutputSize.Height(); - long nSplitPos = m_aHorzSplitter.GetSplitPosPixel(); + long nSplitPos = m_aHorzSplitter->GetSplitPosPixel(); // Verschiebebereich Splitter mittleres Drittel des Outputs long nDragPosY = nOutputHeight/3; long nDragSizeHeight = nOutputHeight/3; - m_aHorzSplitter.SetDragRectPixel( Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this ); + m_aHorzSplitter->SetDragRectPixel( Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this ); if( (nSplitPos < nDragPosY) || (nSplitPos > (nDragPosY+nDragSizeHeight)) ) nSplitPos = nDragPosY+nDragSizeHeight-5; // Splitter setzen - m_aHorzSplitter.SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight)); - m_aHorzSplitter.SetSplitPosPixel( nSplitPos ); + m_aHorzSplitter->SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight)); + m_aHorzSplitter->SetSplitPosPixel( nSplitPos ); // Fenster setzen m_pEditorCtrl->SetPosSizePixel( Point(0, 0), Size(nOutputWidth , nSplitPos) ); @@ -108,9 +107,9 @@ void OTableBorderWindow::Resize() IMPL_LINK( OTableBorderWindow, SplitHdl, Splitter*, pSplit ) { - if(pSplit == &m_aHorzSplitter) + if(pSplit == m_aHorzSplitter.get()) { - m_aHorzSplitter.SetPosPixel( Point( m_aHorzSplitter.GetPosPixel().X(),m_aHorzSplitter.GetSplitPosPixel() ) ); + m_aHorzSplitter->SetPosPixel( Point( m_aHorzSplitter->GetPosPixel().X(),m_aHorzSplitter->GetSplitPosPixel() ) ); Resize(); } return 0; @@ -184,18 +183,20 @@ OTableDesignView::OTableDesignView( vcl::Window* pParent, { } - m_pWin = new OTableBorderWindow(this); + m_pWin = VclPtr<OTableBorderWindow>::Create(this); m_pWin->Show(); } OTableDesignView::~OTableDesignView() { - m_pWin->Hide(); + disposeOnce(); +} - { - boost::scoped_ptr<vcl::Window> aTemp(m_pWin); - m_pWin = NULL; - } +void OTableDesignView::dispose() +{ + m_pWin->Hide(); + m_pWin.disposeAndClear(); + ODataView::dispose(); } void OTableDesignView::initialize() diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx index 1cd013e008cf..e0b89dbfddbe 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx @@ -50,39 +50,36 @@ OTableFieldDescWin::OTableFieldDescWin( vcl::Window* pParent) , m_eChildFocus(NONE) { // Header - m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); // | WB_3DLOOK + m_pHeader = VclPtr<FixedText>::Create( this, WB_CENTER | WB_INFO ); m_pHeader->SetText( OUString(ModuleRes(STR_TAB_PROPERTIES)) ); m_pHeader->Show(); // HelpBar - m_pHelpBar = new OTableDesignHelpBar( this ); + m_pHelpBar = VclPtr<OTableDesignHelpBar>::Create( this ); m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME); m_pHelpBar->Show(); - m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar ); + m_pGenPage = VclPtr<OFieldDescGenWin>::Create( this, m_pHelpBar ); getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL ); getGenPage()->Show(); } OTableFieldDescWin::~OTableFieldDescWin() { + disposeOnce(); +} + +void OTableFieldDescWin::dispose() +{ // destroy children m_pHelpBar->Hide(); getGenPage()->Hide(); m_pHeader->Hide(); - { - boost::scoped_ptr<vcl::Window> aTemp(m_pGenPage); - m_pGenPage = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pHeader); - m_pHeader = NULL; - } - { - boost::scoped_ptr<vcl::Window> aTemp(m_pHelpBar); - m_pHelpBar = NULL; - } + m_pGenPage.disposeAndClear(); + m_pHeader.disposeAndClear(); + m_pHelpBar.disposeAndClear(); + TabPage::dispose(); } void OTableFieldDescWin::Init() diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx index f2092ff35a13..a8914fd42cb3 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx @@ -41,9 +41,9 @@ namespace dbaui NONE }; private: - OTableDesignHelpBar* m_pHelpBar; - OFieldDescGenWin* m_pGenPage; - FixedText* m_pHeader; + VclPtr<OTableDesignHelpBar> m_pHelpBar; + VclPtr<OFieldDescGenWin> m_pGenPage; + VclPtr<FixedText> m_pHeader; ChildFocusState m_eChildFocus; IClipboardTest* getActiveChild() const; @@ -55,6 +55,7 @@ namespace dbaui public: OTableFieldDescWin( vcl::Window* pParent); virtual ~OTableFieldDescWin(); + virtual void dispose() SAL_OVERRIDE; void Init(); diff --git a/dbaccess/source/ui/tabledesign/TableUndo.hxx b/dbaccess/source/ui/tabledesign/TableUndo.hxx index d16e55272fbd..7646684e3a09 100644 --- a/dbaccess/source/ui/tabledesign/TableUndo.hxx +++ b/dbaccess/source/ui/tabledesign/TableUndo.hxx @@ -26,6 +26,7 @@ #include <com/sun/star/uno/Any.h> #include "TypeInfo.hxx" +#include <vcl/vclptr.hxx> namespace dbaui { @@ -34,7 +35,7 @@ namespace dbaui class OTableDesignUndoAct : public OCommentUndoAction { protected: - OTableRowView* m_pTabDgnCtrl; + VclPtr<OTableRowView> m_pTabDgnCtrl; virtual void Undo() SAL_OVERRIDE; virtual void Redo() SAL_OVERRIDE; @@ -48,7 +49,7 @@ namespace dbaui class OTableEditorUndoAct : public OTableDesignUndoAct { protected: - OTableEditorCtrl* pTabEdCtrl; + VclPtr<OTableEditorCtrl> pTabEdCtrl; public: TYPEINFO_OVERRIDE(); @@ -136,7 +137,7 @@ namespace dbaui protected: MultiSelection m_aDelKeys, m_aInsKeys; - OTableEditorCtrl* m_pEditorCtrl; + VclPtr<OTableEditorCtrl> m_pEditorCtrl; virtual void Undo() SAL_OVERRIDE; virtual void Redo() SAL_OVERRIDE; diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx index 222903c1af58..3e2cb86fb94e 100644 --- a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx +++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx @@ -63,7 +63,7 @@ namespace dbaui virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; OAdvancedSettingsDialog::OAdvancedSettingsDialog(const Reference< XComponentContext >& _rxORB) @@ -119,10 +119,9 @@ namespace dbaui describeProperties(aProps); return new ::cppu::OPropertyArrayHelper(aProps); } - Dialog* OAdvancedSettingsDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> OAdvancedSettingsDialog::createDialog(vcl::Window* _pParent) { - AdvancedSettingsDialog* pDlg = new AdvancedSettingsDialog(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); - return pDlg; + return VclPtr<AdvancedSettingsDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); } } // namespace dbaui diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx index 1422c629b3a1..7a32f0b175f6 100644 --- a/dbaccess/source/ui/uno/ColumnPeer.cxx +++ b/dbaccess/source/ui/uno/ColumnPeer.cxx @@ -36,7 +36,7 @@ OColumnPeer::OColumnPeer(vcl::Window* _pParent,const Reference<XComponentContext { osl_atomic_increment( &m_refCount ); { - OColumnControlWindow* pFieldControl = new OColumnControlWindow(_pParent, _rxContext); + VclPtrInstance<OColumnControlWindow> pFieldControl(_pParent, _rxContext); pFieldControl->SetComponentInterface(this); pFieldControl->Show(); } @@ -46,19 +46,16 @@ OColumnPeer::OColumnPeer(vcl::Window* _pParent,const Reference<XComponentContext void OColumnPeer::setEditWidth(sal_Int32 _nWidth) { SolarMutexGuard aGuard; - - OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>(); if ( pFieldControl ) - { pFieldControl->setEditWidth(_nWidth); - } } void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn) { SolarMutexGuard aGuard; - OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>(); if ( pFieldControl ) { if ( m_pActFieldDescr ) @@ -105,7 +102,7 @@ void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn) void OColumnPeer::setConnection(const Reference< XConnection>& _xCon) { SolarMutexGuard aGuard; - OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() ); + VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>(); if ( pFieldControl ) pFieldControl->setConnection(_xCon); } @@ -131,7 +128,7 @@ void OColumnPeer::setProperty( const OUString& _rPropertyName, const Any& Value) Any OColumnPeer::getProperty( const OUString& _rPropertyName ) throw( RuntimeException, std::exception ) { Any aProp; - OFieldDescControl* pFieldControl = static_cast<OFieldDescControl*>( GetWindow() ); + VclPtr< OFieldDescControl > pFieldControl = GetAs< OFieldDescControl >(); if (pFieldControl && _rPropertyName == PROPERTY_COLUMN) { aProp <<= m_xColumn; diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx index 6c5d796872d1..a667d1f90e56 100644 --- a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx +++ b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx @@ -92,10 +92,9 @@ Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialog::getPropertySetInfo() thr return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* ODBTypeWizDialog::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> ODBTypeWizDialog::createDialog(vcl::Window* _pParent) { - ODbTypeWizDialog* pDlg = new ODbTypeWizDialog(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); - return pDlg; + return VclPtr<ODbTypeWizDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); } } // namespace dbaui diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.hxx b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx index 10df28c4e6dd..80e8830792b1 100644 --- a/dbaccess/source/ui/uno/DBTypeWizDlg.hxx +++ b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx @@ -55,7 +55,7 @@ public: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx index 4c46903fd03b..f13cc2e142e6 100644 --- a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx +++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx @@ -106,16 +106,16 @@ Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialogSetup::getPropertySetInfo( return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* ODBTypeWizDialogSetup::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> ODBTypeWizDialogSetup::createDialog(vcl::Window* _pParent) { - return new ODbTypeWizDialogSetup(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); + return VclPtr<ODbTypeWizDialogSetup>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); } void ODBTypeWizDialogSetup::executedDialog(sal_Int16 _nExecutionResult) { if ( _nExecutionResult == RET_OK ) { - const ODbTypeWizDialogSetup* pDialog = static_cast< ODbTypeWizDialogSetup* >( m_pDialog ); + const ODbTypeWizDialogSetup* pDialog = static_cast< ODbTypeWizDialogSetup* >( m_pDialog.get() ); m_bOpenDatabase = pDialog->IsDatabaseDocumentToBeOpened(); m_bStartTableWizard = pDialog->IsTableWizardToBeStarted(); } diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx index c0f6faeb86a1..2a7112678154 100644 --- a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx +++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx @@ -57,7 +57,7 @@ public: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; 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/dbaccess/source/ui/uno/TableFilterDlg.cxx b/dbaccess/source/ui/uno/TableFilterDlg.cxx index 475c66457157..813736d0ecbf 100644 --- a/dbaccess/source/ui/uno/TableFilterDlg.cxx +++ b/dbaccess/source/ui/uno/TableFilterDlg.cxx @@ -92,10 +92,9 @@ Reference<XPropertySetInfo> SAL_CALL OTableFilterDialog::getPropertySetInfo() t return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* OTableFilterDialog::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> OTableFilterDialog::createDialog(vcl::Window* _pParent) { - OTableSubscriptionDialog* pDlg = new OTableSubscriptionDialog(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); - return pDlg; + return VclPtr<OTableSubscriptionDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection); } } // namespace dbaui diff --git a/dbaccess/source/ui/uno/TableFilterDlg.hxx b/dbaccess/source/ui/uno/TableFilterDlg.hxx index 9acfe840ac87..f3798c29b2d6 100644 --- a/dbaccess/source/ui/uno/TableFilterDlg.hxx +++ b/dbaccess/source/ui/uno/TableFilterDlg.hxx @@ -55,7 +55,7 @@ public: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.cxx b/dbaccess/source/ui/uno/UserSettingsDlg.cxx index 55bab9fcb5a2..db51ea598542 100644 --- a/dbaccess/source/ui/uno/UserSettingsDlg.cxx +++ b/dbaccess/source/ui/uno/UserSettingsDlg.cxx @@ -92,10 +92,9 @@ Reference<XPropertySetInfo> SAL_CALL OUserSettingsDialog::getPropertySetInfo() return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* OUserSettingsDialog::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> OUserSettingsDialog::createDialog(vcl::Window* _pParent) { - OUserAdminDlg* pDlg = new OUserAdminDlg(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection, m_xActiveConnection); - return pDlg; + return VclPtr<OUserAdminDlg>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection, m_xActiveConnection); } } // namespace dbaui diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.hxx b/dbaccess/source/ui/uno/UserSettingsDlg.hxx index efc682601b62..f8aa793a279e 100644 --- a/dbaccess/source/ui/uno/UserSettingsDlg.hxx +++ b/dbaccess/source/ui/uno/UserSettingsDlg.hxx @@ -55,7 +55,7 @@ public: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/uno/admindlg.cxx b/dbaccess/source/ui/uno/admindlg.cxx index d6f7a98d3188..adfe04c33ebe 100644 --- a/dbaccess/source/ui/uno/admindlg.cxx +++ b/dbaccess/source/ui/uno/admindlg.cxx @@ -92,10 +92,9 @@ Reference<XPropertySetInfo> SAL_CALL ODataSourcePropertyDialog::getPropertySetI return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* ODataSourcePropertyDialog::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> ODataSourcePropertyDialog::createDialog(vcl::Window* _pParent) { - - ODbAdminDialog* pDialog = new ODbAdminDialog(_pParent, m_pDatasourceItems, m_aContext); + VclPtrInstance<ODbAdminDialog> pDialog(_pParent, m_pDatasourceItems, m_aContext); // the initial selection if ( m_aInitialSelection.hasValue() ) diff --git a/dbaccess/source/ui/uno/admindlg.hxx b/dbaccess/source/ui/uno/admindlg.hxx index d326ce1f3693..7c5737d99d5f 100644 --- a/dbaccess/source/ui/uno/admindlg.hxx +++ b/dbaccess/source/ui/uno/admindlg.hxx @@ -55,7 +55,7 @@ public: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE; protected: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; } // namespace dbaui diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx index 7404f5b4d5d3..a4b29d889ecf 100644 --- a/dbaccess/source/ui/uno/composerdialogs.cxx +++ b/dbaccess/source/ui/uno/composerdialogs.cxx @@ -77,7 +77,7 @@ namespace dbaui IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog ) - Dialog* ComposerDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> ComposerDialog::createDialog(vcl::Window* _pParent) { // obtain all the objects needed for the dialog Reference< XConnection > xConnection; @@ -140,9 +140,9 @@ namespace dbaui return static_cast< XServiceInfo* >(new RowsetFilterDialog( comphelper::getComponentContext(_rxORB))); } - Dialog* RowsetFilterDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) + VclPtr<Dialog> RowsetFilterDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) { - return new DlgFilterCrit( _pParent, m_aContext, _rxConnection, m_xComposer, _rxColumns ); + return VclPtr<DlgFilterCrit>::Create( _pParent, m_aContext, _rxConnection, m_xComposer, _rxColumns ); } void SAL_CALL RowsetFilterDialog::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException, std::exception) @@ -169,7 +169,7 @@ namespace dbaui ComposerDialog::executedDialog( _nExecutionResult ); if ( _nExecutionResult && m_pDialog ) - static_cast< DlgFilterCrit* >( m_pDialog )->BuildWherePart(); + static_cast< DlgFilterCrit* >( m_pDialog.get() )->BuildWherePart(); } // RowsetOrderDialog @@ -188,9 +188,9 @@ namespace dbaui return static_cast< XServiceInfo* >(new RowsetOrderDialog( comphelper::getComponentContext(_rxORB))); } - Dialog* RowsetOrderDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) + VclPtr<Dialog> RowsetOrderDialog::createComposerDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) { - return new DlgOrderCrit( _pParent, _rxConnection, m_xComposer, _rxColumns ); + return VclPtr<DlgOrderCrit>::Create( _pParent, _rxConnection, m_xComposer, _rxColumns ); } void SAL_CALL RowsetOrderDialog::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException, std::exception) @@ -216,9 +216,9 @@ namespace dbaui return; if ( _nExecutionResult ) - static_cast< DlgOrderCrit* >( m_pDialog )->BuildOrderPart(); + static_cast< DlgOrderCrit* >( m_pDialog.get() )->BuildOrderPart(); else if ( m_xComposer.is() ) - m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog )->GetOrignalOrder() ); + m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog.get() )->GetOrignalOrder() ); } } // namespace dbaui diff --git a/dbaccess/source/ui/uno/composerdialogs.hxx b/dbaccess/source/ui/uno/composerdialogs.hxx index 4eb6fe8c2de1..3423427d89af 100644 --- a/dbaccess/source/ui/uno/composerdialogs.hxx +++ b/dbaccess/source/ui/uno/composerdialogs.hxx @@ -62,7 +62,7 @@ namespace dbaui protected: // own overridables - virtual Dialog* createComposerDialog( + virtual VclPtr<Dialog> createComposerDialog( vcl::Window* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns @@ -70,7 +70,7 @@ namespace dbaui private: // OGenericUnoDialog overridables - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; }; // RowsetFilterDialog @@ -85,7 +85,7 @@ namespace dbaui protected: // own overridables - virtual Dialog* createComposerDialog( + virtual VclPtr<Dialog> createComposerDialog( vcl::Window* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns @@ -110,7 +110,7 @@ namespace dbaui protected: // own overridables - virtual Dialog* createComposerDialog( + virtual VclPtr<Dialog> createComposerDialog( vcl::Window* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index cbcadf4f7376..bf5a00634914 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -193,7 +193,7 @@ namespace dbaui virtual ~CopyTableWizard(); // 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; private: @@ -548,7 +548,7 @@ void SAL_CALL CopyTableWizard::setTitle( const OUString& _rTitle ) throw (Runtim OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() { - OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog ); + OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog.get() ); if ( !pWizard ) throw DisposedException( OUString(), *this ); return *pWizard; @@ -1514,12 +1514,12 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) return new ::cppu::OPropertyArrayHelper( aProps ); } -Dialog* CopyTableWizard::createDialog( vcl::Window* _pParent ) +VclPtr<Dialog> CopyTableWizard::createDialog( vcl::Window* _pParent ) { OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" ); // this should have been prevented in ::execute already - OCopyTableWizard* pWizard = new OCopyTableWizard( + VclPtrInstance<OCopyTableWizard> pWizard( _pParent, m_sDestinationTable, m_nOperation, diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx index 7087c3b04d13..dd2d477dfa84 100644 --- a/dbaccess/source/ui/uno/dbinteraction.cxx +++ b/dbaccess/source/ui/uno/dbinteraction.cxx @@ -127,8 +127,8 @@ namespace dbaui xParamCallback = Reference< XInteractionSupplyParameters >(_rContinuations[nParamPos], UNO_QUERY); OSL_ENSURE(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s"); - OParameterDialog aDlg(NULL, _rParamRequest.Parameters, _rParamRequest.Connection, m_xContext); - sal_Int16 nResult = aDlg.Execute(); + ScopedVclPtrInstance< OParameterDialog > aDlg(nullptr, _rParamRequest.Parameters, _rParamRequest.Connection, m_xContext); + sal_Int16 nResult = aDlg->Execute(); try { switch (nResult) @@ -136,7 +136,7 @@ namespace dbaui case RET_OK: if (xParamCallback.is()) { - xParamCallback->setParameters(aDlg.getValues()); + xParamCallback->setParameters(aDlg->getValues()); xParamCallback->select(); } break; @@ -182,9 +182,9 @@ namespace dbaui } // execute the dialog - OSQLMessageBox aDialog(NULL, _rSqlInfo, nDialogStyle); + ScopedVclPtrInstance< OSQLMessageBox > aDialog(nullptr, _rSqlInfo, nDialogStyle); // TODO: need a way to specify the parent window - sal_Int16 nResult = aDialog.Execute(); + sal_Int16 nResult = aDialog->Execute(); try { switch (nResult) @@ -256,8 +256,8 @@ namespace dbaui Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY); OSL_ENSURE(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s"); - OCollectionView aDlg(NULL, _rDocuRequest.Content, _rDocuRequest.Name, m_xContext); - sal_Int16 nResult = aDlg.Execute(); + ScopedVclPtrInstance< OCollectionView > aDlg(nullptr, _rDocuRequest.Content, _rDocuRequest.Name, m_xContext); + sal_Int16 nResult = aDlg->Execute(); try { switch (nResult) @@ -265,7 +265,7 @@ namespace dbaui case RET_OK: if (xCallback.is()) { - xCallback->setName(aDlg.getName(),aDlg.getSelectedFolder()); + xCallback->setName(aDlg->getName(), aDlg->getSelectedFolder()); xCallback->select(); } break; diff --git a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx index d0c4969b57fb..9744b5af026b 100644 --- a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx +++ b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx @@ -104,7 +104,7 @@ namespace dbaui 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; protected: using OTextConnectionSettingsDialog_BASE::getFastPropertyValue; @@ -204,9 +204,9 @@ namespace dbaui return new ::cppu::OPropertyArrayHelper( aProps ); } - Dialog* OTextConnectionSettingsDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> OTextConnectionSettingsDialog::createDialog(vcl::Window* _pParent) { - return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems ); + return VclPtr<TextConnectionSettingsDialog>::Create( _pParent, *m_pDatasourceItems ); } void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue) diff --git a/dbaccess/source/ui/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx index 9f752dac81d0..94b57f10f090 100644 --- a/dbaccess/source/ui/uno/unoDirectSql.cxx +++ b/dbaccess/source/ui/uno/unoDirectSql.cxx @@ -78,7 +78,7 @@ namespace dbaui IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog ) - Dialog* ODirectSQLDialog::createDialog(vcl::Window* _pParent) + VclPtr<Dialog> ODirectSQLDialog::createDialog(vcl::Window* _pParent) { // obtain all the objects needed for the dialog Reference< XConnection > xConnection = m_xActiveConnection; @@ -99,7 +99,7 @@ namespace dbaui // can't create the dialog if I have improper settings return NULL; - return new DirectSQLDialog( _pParent, xConnection); + return VclPtr<DirectSQLDialog>::Create( _pParent, xConnection ); } void ODirectSQLDialog::implInitialize(const Any& _rValue) { diff --git a/dbaccess/source/ui/uno/unoDirectSql.hxx b/dbaccess/source/ui/uno/unoDirectSql.hxx index 43844874009e..d3330170b538 100644 --- a/dbaccess/source/ui/uno/unoDirectSql.hxx +++ b/dbaccess/source/ui/uno/unoDirectSql.hxx @@ -57,7 +57,7 @@ namespace dbaui 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/dbaccess/source/ui/uno/unosqlmessage.cxx b/dbaccess/source/ui/uno/unosqlmessage.cxx index ec22c959d384..914974d9efed 100644 --- a/dbaccess/source/ui/uno/unosqlmessage.cxx +++ b/dbaccess/source/ui/uno/unosqlmessage.cxx @@ -141,13 +141,13 @@ Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() th return new ::cppu::OPropertyArrayHelper(aProps); } -Dialog* OSQLMessageDialog::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> OSQLMessageDialog::createDialog(vcl::Window* _pParent) { if ( m_aException.hasValue() ) - return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL ); + return VclPtr<OSQLMessageBox>::Create( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL ); OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!"); - return new OSQLMessageBox(_pParent, SQLException()); + return VclPtr<OSQLMessageBox>::Create(_pParent, SQLException()); } } // namespace dbaui |