diff options
Diffstat (limited to 'basic/source/runtime')
-rw-r--r-- | basic/source/runtime/inputbox.cxx | 65 | ||||
-rw-r--r-- | basic/source/runtime/iosys.cxx | 44 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 12 |
3 files changed, 71 insertions, 50 deletions
diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx index c15127d45146..97208770c0a1 100644 --- a/basic/source/runtime/inputbox.cxx +++ b/basic/source/runtime/inputbox.cxx @@ -30,10 +30,10 @@ class SvRTLInputBox : public ModalDialog { - Edit aEdit; - OKButton aOk; - CancelButton aCancel; - FixedText aPromptText; + VclPtr<Edit> aEdit; + VclPtr<OKButton> aOk; + VclPtr<CancelButton> aCancel; + VclPtr<FixedText> aPromptText; OUString aText; void PositionDialog( long nXTwips, long nYTwips, const Size& rDlgSize ); @@ -46,6 +46,8 @@ class SvRTLInputBox : public ModalDialog public: SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, const OUString& rTitle, const OUString& rDefault, long nXTwips = -1, long nYTwips = -1 ); + virtual ~SvRTLInputBox() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; OUString GetText() const SAL_OVERRIDE { return aText; } }; @@ -53,8 +55,8 @@ SvRTLInputBox::SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, const OUString& rTitle, const OUString& rDefault, long nXTwips, long nYTwips ) : ModalDialog( pParent,WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ), - aEdit( this, WB_LEFT | WB_BORDER ), - aOk( this ), aCancel( this ), aPromptText( this, WB_WORDBREAK ) + aEdit( VclPtr<Edit>::Create(this, WB_LEFT | WB_BORDER) ), + aOk( new OKButton(this) ), aCancel( new CancelButton(this) ), aPromptText( VclPtr<FixedText>::Create(this, WB_WORDBREAK) ) { SetMapMode( MapMode( MAP_APPFONT ) ); Size aDlgSizeApp( 280, 80 ); @@ -62,29 +64,38 @@ SvRTLInputBox::SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, InitButtons( aDlgSizeApp ); PositionEdit( aDlgSizeApp ); PositionPrompt( rPrompt, aDlgSizeApp ); - aOk.Show(); - aCancel.Show(); - aEdit.Show(); - aPromptText.Show(); + aOk->Show(); + aCancel->Show(); + aEdit->Show(); + aPromptText->Show(); SetText( rTitle ); vcl::Font aFont( GetFont()); Color aColor( GetBackground().GetColor() ); aFont.SetFillColor( aColor ); - aEdit.SetFont( aFont ); - aEdit.SetText( rDefault ); - aEdit.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); + aEdit->SetFont( aFont ); + aEdit->SetText( rDefault ); + aEdit->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); +} + +void SvRTLInputBox::dispose() +{ + aEdit.disposeAndClear(); + aOk.disposeAndClear(); + aCancel.disposeAndClear(); + aPromptText.disposeAndClear(); + ModalDialog::dispose(); } void SvRTLInputBox::InitButtons( const Size& rDlgSize ) { - aOk.SetSizePixel( LogicToPixel( Size( 45, 15) )); - aCancel.SetSizePixel( LogicToPixel( Size( 45, 15) )); + aOk->SetSizePixel( LogicToPixel( Size( 45, 15) )); + aCancel->SetSizePixel( LogicToPixel( Size( 45, 15) )); Point aPos( rDlgSize.Width()-45-10, 5 ); - aOk.SetPosPixel( LogicToPixel( Point(aPos) )); + aOk->SetPosPixel( LogicToPixel( Point(aPos) )); aPos.Y() += 16; - aCancel.SetPosPixel( LogicToPixel( Point(aPos) )); - aOk.SetClickHdl(LINK(this,SvRTLInputBox, OkHdl)); - aCancel.SetClickHdl(LINK(this,SvRTLInputBox,CancelHdl)); + aCancel->SetPosPixel( LogicToPixel( Point(aPos) )); + aOk->SetClickHdl(LINK(this,SvRTLInputBox, OkHdl)); + aCancel->SetClickHdl(LINK(this,SvRTLInputBox,CancelHdl)); } void SvRTLInputBox::PositionDialog(long nXTwips, long nYTwips, const Size& rDlgSize) @@ -99,8 +110,8 @@ void SvRTLInputBox::PositionDialog(long nXTwips, long nYTwips, const Size& rDlgS void SvRTLInputBox::PositionEdit( const Size& rDlgSize ) { - aEdit.SetPosPixel( LogicToPixel( Point( 5,rDlgSize.Height()-35))); - aEdit.SetSizePixel( LogicToPixel( Size(rDlgSize.Width()-15,12))); + aEdit->SetPosPixel( LogicToPixel( Point( 5,rDlgSize.Height()-35))); + aEdit->SetSizePixel( LogicToPixel( Size(rDlgSize.Width()-15,12))); } @@ -109,12 +120,12 @@ void SvRTLInputBox::PositionPrompt(const OUString& rPrompt,const Size& rDlgSize) if ( rPrompt.isEmpty() ) return; OUString aText_(convertLineEnd(rPrompt, LINEEND_CR)); - aPromptText.SetPosPixel( LogicToPixel(Point(5,5))); - aPromptText.SetText( aText_ ); + aPromptText->SetPosPixel( LogicToPixel(Point(5,5))); + aPromptText->SetText( aText_ ); Size aSize( rDlgSize ); aSize.Width() -= 70; aSize.Height() -= 50; - aPromptText.SetSizePixel( LogicToPixel(aSize)); + aPromptText->SetSizePixel( LogicToPixel(aSize)); } @@ -122,7 +133,7 @@ IMPL_LINK_INLINE_START( SvRTLInputBox, OkHdl, Button *, pButton ) { (void)pButton; - aText = aEdit.GetText(); + aText = aEdit->GetText(); EndDialog( 1 ); return 0; } @@ -172,8 +183,8 @@ RTLFUNC(InputBox) nX = rPar.Get(4)->GetLong(); nY = rPar.Get(5)->GetLong(); } - boost::scoped_ptr<SvRTLInputBox> pDlg(new SvRTLInputBox(Application::GetDefDialogParent(), - rPrompt,aTitle,aDefault,nX,nY)); + VclPtrInstance<SvRTLInputBox> pDlg(Application::GetDefDialogParent(), + rPrompt,aTitle,aDefault,nX,nY); pDlg->Execute(); rPar.Get(0)->PutString( pDlg->GetText() ); } diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index ae6d03e256fc..f4092002d4aa 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -66,25 +66,27 @@ using namespace com::sun::star::bridge; class SbiInputDialog : public ModalDialog { - Edit aInput; - OKButton aOk; - CancelButton aCancel; + VclPtr<Edit> aInput; + VclPtr<OKButton> aOk; + VclPtr<CancelButton> aCancel; OUString aText; DECL_LINK( Ok, vcl::Window * ); DECL_LINK( Cancel, vcl::Window * ); public: SbiInputDialog( vcl::Window*, const OUString& ); + virtual ~SbiInputDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; const OUString& GetInput() { return aText; } }; SbiInputDialog::SbiInputDialog( vcl::Window* pParent, const OUString& rPrompt ) :ModalDialog( pParent, WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ), - aInput( this, WB_3DLOOK | WB_LEFT | WB_BORDER ), - aOk( this ), aCancel( this ) + aInput( VclPtr<Edit>::Create(this, WB_3DLOOK | WB_LEFT | WB_BORDER) ), + aOk( new OKButton(this) ), aCancel( VclPtr<CancelButton>::Create(this) ) { SetText( rPrompt ); - aOk.SetClickHdl( LINK( this, SbiInputDialog, Ok ) ); - aCancel.SetClickHdl( LINK( this, SbiInputDialog, Cancel ) ); + aOk->SetClickHdl( LINK( this, SbiInputDialog, Ok ) ); + aCancel->SetClickHdl( LINK( this, SbiInputDialog, Cancel ) ); SetMapMode( MapMode( MAP_APPFONT ) ); Point aPt = LogicToPixel( Point( 50, 50 ) ); @@ -92,24 +94,32 @@ SbiInputDialog::SbiInputDialog( vcl::Window* pParent, const OUString& rPrompt ) SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 10, 10 ) ); aSz = LogicToPixel( Size( 120, 12 ) ); - aInput.SetPosSizePixel( aPt, aSz ); + aInput->SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 15, 30 ) ); aSz = LogicToPixel( Size( 45, 15) ); - aOk.SetPosSizePixel( aPt, aSz ); + aOk->SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 80, 30 ) ); aSz = LogicToPixel( Size( 45, 15) ); - aCancel.SetPosSizePixel( aPt, aSz ); + aCancel->SetPosSizePixel( aPt, aSz ); - aInput.Show(); - aOk.Show(); - aCancel.Show(); + aInput->Show(); + aOk->Show(); + aCancel->Show(); +} + +void SbiInputDialog::dispose() +{ + aInput.disposeAndClear(); + aOk.disposeAndClear(); + aCancel.disposeAndClear(); + ModalDialog::dispose(); } IMPL_LINK_INLINE_START( SbiInputDialog, Ok, vcl::Window *, pWindow ) { (void)pWindow; - aText = aInput.GetText(); + aText = aInput->GetText(); EndDialog( 1 ); return 0; } @@ -956,10 +966,10 @@ void SbiIoSystem::CloseAll() void SbiIoSystem::ReadCon(OString& rIn) { OUString aPromptStr(OStringToOUString(aPrompt, osl_getThreadTextEncoding())); - SbiInputDialog aDlg( NULL, aPromptStr ); - if( aDlg.Execute() ) + ScopedVclPtrInstance< SbiInputDialog > aDlg(nullptr, aPromptStr); + if( aDlg->Execute() ) { - rIn = OUStringToOString(aDlg.GetInput(), osl_getThreadTextEncoding()); + rIn = OUStringToOString(aDlg->GetInput(), osl_getThreadTextEncoding()); } else { diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 2cc26f78ea98..8b40e3643ef9 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4611,7 +4611,7 @@ RTLFUNC(MsgBox) } nType &= (16+32+64); - boost::scoped_ptr<MessBox> pBox; + VclPtr<MessBox> pBox; SolarMutexGuard aSolarGuard; @@ -4619,19 +4619,19 @@ RTLFUNC(MsgBox) switch( nType ) { case 16: - pBox.reset(new ErrorBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<ErrorBox>::Create( pParent, nWinBits, aMsg )); break; case 32: - pBox.reset(new QueryBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<QueryBox>::Create( pParent, nWinBits, aMsg )); break; case 48: - pBox.reset(new WarningBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<WarningBox>::Create( pParent, nWinBits, aMsg )); break; case 64: - pBox.reset(new InfoBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<InfoBox>::Create( pParent, nWinBits, aMsg )); break; default: - pBox.reset(new MessBox( pParent, nWinBits, aTitle, aMsg )); + pBox.reset(VclPtr<MessBox>::Create( pParent, nWinBits, aTitle, aMsg )); } pBox->SetText( aTitle ); short nRet = pBox->Execute(); |