diff options
Diffstat (limited to 'sw/source/uibase/uiview')
-rw-r--r-- | sw/source/uibase/uiview/pview.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/uiview/srcview.cxx | 66 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 22 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 46 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewfunc.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewling.cxx | 41 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewmdi.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewprt.cxx | 23 |
9 files changed, 149 insertions, 122 deletions
diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 973cc9114358..aa2417c0f556 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -145,13 +145,15 @@ static void lcl_InvalidateZoomSlots(SfxBindings& rBindings) // At first the zoom dialog class SwPreviewZoomDlg : public SvxStandardDialog { - NumericField* m_pRowEdit; - NumericField* m_pColEdit; + VclPtr<NumericField> m_pRowEdit; + VclPtr<NumericField> m_pColEdit; virtual void Apply() SAL_OVERRIDE; public: SwPreviewZoomDlg( SwPagePreviewWin& rParent ); + virtual ~SwPreviewZoomDlg(); + virtual void dispose() SAL_OVERRIDE; }; SwPreviewZoomDlg::SwPreviewZoomDlg( SwPagePreviewWin& rParent ) @@ -164,6 +166,18 @@ SwPreviewZoomDlg::SwPreviewZoomDlg( SwPagePreviewWin& rParent ) m_pColEdit->SetValue( rParent.GetCol() ); } +SwPreviewZoomDlg::~SwPreviewZoomDlg() +{ + disposeOnce(); +} + +void SwPreviewZoomDlg::dispose() +{ + m_pRowEdit.clear(); + m_pColEdit.clear(); + SvxStandardDialog::dispose(); +} + void SwPreviewZoomDlg::Apply() { static_cast<SwPagePreviewWin*>(GetParent())->CalcWish( @@ -1145,12 +1159,12 @@ void SwPagePreview::Init(const SwViewOption * pPrefs) SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): SfxViewShell( pViewFrame, SWVIEWFLAGS ), - pViewWin( new SwPagePreviewWin(&(GetViewFrame())->GetWindow(), *this ) ), + pViewWin( VclPtr<SwPagePreviewWin>::Create(&(GetViewFrame())->GetWindow(), *this ) ), nNewPage(USHRT_MAX), sPageStr(SW_RES(STR_PAGE)), pHScrollbar(0), pVScrollbar(0), - pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(), + pScrollFill(VclPtr<ScrollBarBox>::Create( &pViewFrame->GetWindow(), pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )), mnPageCount( 0 ), mbResetFormDesignMode( false ), @@ -1224,11 +1238,12 @@ SwPagePreview::~SwPagePreview() SwViewShell* pVShell = pViewWin->GetViewShell(); pVShell->SetWin(0); delete pVShell; - delete pViewWin; - delete pScrollFill; - delete pHScrollbar; - delete pVScrollbar; + pViewWin.disposeAndClear(); + + pScrollFill.disposeAndClear(); + pHScrollbar.disposeAndClear(); + pVScrollbar.disposeAndClear(); } SwDocShell* SwPagePreview::GetDocShell() @@ -1239,20 +1254,20 @@ SwDocShell* SwPagePreview::GetDocShell() int SwPagePreview::_CreateScrollbar( bool bHori ) { vcl::Window *pMDI = &GetViewFrame()->GetWindow(); - SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar; + VclPtr<SwScrollbar>& ppScrollbar = bHori ? pHScrollbar : pVScrollbar; - assert(!*ppScrollbar); //check beforehand! + assert(!ppScrollbar.get()); //check beforehand! - *ppScrollbar = new SwScrollbar( pMDI, bHori ); + ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori ); ScrollDocSzChg(); - (*ppScrollbar)->EnableDrag( true ); - (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl )); + ppScrollbar->EnableDrag( true ); + ppScrollbar->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl )); - (*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl )); + ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl )); InvalidateBorder(); - (*ppScrollbar)->ExtendedShow(); + ppScrollbar->ExtendedShow(); return 1; } @@ -1694,8 +1709,8 @@ bool SwPagePreview::HasPrintOptionsPage() const return true; } -SfxTabPage* SwPagePreview::CreatePrintOptionsPage( vcl::Window *pParent, - const SfxItemSet &rOptions ) +VclPtr<SfxTabPage> SwPagePreview::CreatePrintOptionsPage( vcl::Window *pParent, + const SfxItemSet &rOptions ) { return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint ); } diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index bb5696ccc5ae..76f17325268f 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -218,7 +218,7 @@ static OUString lcl_ConvertTabsToSpaces( const OUString& sLine ) SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, SfxViewShell*) : SfxViewShell( pViewFrame, SWSRCVIEWFLAGS ), - aEditWin( &pViewFrame->GetWindow(), this ), + aEditWin( VclPtr<SwSrcEditWindow>::Create( &pViewFrame->GetWindow(), this ) ), pSearchItem(0), bSourceSaved(false), eLoadEncoding(RTL_TEXTENCODING_DONTKNOW) @@ -230,7 +230,7 @@ SwSrcView::~SwSrcView() { SwDocShell* pDocShell = GetDocShell(); OSL_ENSURE(PTR_CAST(SwWebDocShell, pDocShell), "Why no WebDocShell?"); - const TextSelection& rSel = aEditWin.GetTextView()->GetSelection(); + const TextSelection& rSel = aEditWin->GetTextView()->GetSelection(); static_cast<SwWebDocShell*>(pDocShell)->SetSourcePara( static_cast< sal_uInt16 >( rSel.GetStart().GetPara() ) ); uno::Reference<document::XDocumentPropertiesSupplier> xDPS( @@ -249,14 +249,14 @@ void SwSrcView::SaveContentTo(SfxMedium& rMed) { SvStream* pOutStream = rMed.GetOutStream(); pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding)); - aEditWin.Write( *pOutStream ); + aEditWin->Write( *pOutStream ); } void SwSrcView::Init() { SetHelpId(SW_SRC_VIEWSHELL); SetName(OUString("Source")); - SetWindow( &aEditWin ); + SetWindow( aEditWin.get() ); SwDocShell* pDocShell = GetDocShell(); // If the doc is still loading, then the DocShell must fire up // the Load if the loading is completed. @@ -264,7 +264,7 @@ void SwSrcView::Init() Load(pDocShell); else { - aEditWin.SetReadonly(true); + aEditWin->SetReadonly(true); } SetNewWindowAllowed( false ); @@ -282,13 +282,13 @@ void SwSrcView::SaveContent(const OUString& rTmpFile) SfxMedium aMedium( rTmpFile, StreamMode::WRITE); SvStream* pOutStream = aMedium.GetOutStream(); pOutStream->SetStreamCharSet( lcl_GetStreamCharSet(eLoadEncoding) ); - aEditWin.Write(*pOutStream); + aEditWin->Write(*pOutStream); aMedium.Commit(); } void SwSrcView::Execute(SfxRequest& rReq) { - TextView* pTextView = aEditWin.GetTextView(); + TextView* pTextView = aEditWin->GetTextView(); switch( rReq.GetSlot() ) { case SID_SAVEACOPY: @@ -328,7 +328,7 @@ void SwSrcView::Execute(SfxRequest& rReq) StreamMode::WRITE | StreamMode::SHARE_DENYNONE ); SvStream* pOutStream = aMedium.GetOutStream(); pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding)); - aEditWin.Write( *pOutStream ); + aEditWin->Write( *pOutStream ); aMedium.Commit(); } } @@ -351,12 +351,12 @@ void SwSrcView::Execute(SfxRequest& rReq) pOutStream->Seek(0); pOutStream->SetStreamSize(0); pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding)); - aEditWin.Write( *pOutStream ); + aEditWin->Write( *pOutStream ); pMed->CloseOutStream(); pMed->Commit(); pDocShell->GetDoc()->getIDocumentState().ResetModified(); SourceSaved(); - aEditWin.ClearModifyFlag(); + aEditWin->ClearModifyFlag(); } } break; @@ -369,7 +369,7 @@ void SwSrcView::Execute(SfxRequest& rReq) const SfxPoolItem& rItem = pTmpArgs->Get( nWhich ); SetSearchItem( static_cast<const SvxSearchItem&>(rItem)); StartSearchAndReplace( static_cast<const SvxSearchItem&>(rItem), false, rReq.IsAPI() ); - if(aEditWin.IsModified()) + if(aEditWin->IsModified()) GetDocShell()->GetDoc()->getIDocumentState().SetModified(); } break; @@ -379,7 +379,7 @@ void SwSrcView::Execute(SfxRequest& rReq) if(pSrchItem) { StartSearchAndReplace( *pSrchItem, false, rReq.IsAPI() ); - if(aEditWin.IsModified()) + if(aEditWin->IsModified()) GetDocShell()->GetDoc()->getIDocumentState().SetModified(); } } @@ -415,14 +415,14 @@ void SwSrcView::Execute(SfxRequest& rReq) pTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); break; } - aEditWin.Invalidate(); + aEditWin->Invalidate(); } void SwSrcView::GetState(SfxItemSet& rSet) { SfxWhichIter aIter(rSet); sal_uInt16 nWhich = aIter.FirstWhich(); - TextView* pTextView = aEditWin.GetTextView(); + TextView* pTextView = aEditWin->GetTextView(); while(nWhich) { @@ -471,7 +471,7 @@ void SwSrcView::GetState(SfxItemSet& rSet) if ( !pTextView->HasSelection() ) { const TextSelection& rSel = pTextView->GetSelection(); - sSelected = aEditWin.GetTextEngine()->GetWord( rSel.GetStart()); + sSelected = aEditWin->GetTextEngine()->GetWord( rSel.GetStart()); } else { @@ -538,7 +538,7 @@ void SwSrcView::GetState(SfxItemSet& rSet) { TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( - &aEditWin) ); + aEditWin.get()) ); bool bDisable = !aDataHelper.GetXTransferable().is() || 0 == aDataHelper.GetFormatCount(); if( bDisable ) @@ -570,7 +570,7 @@ sal_uInt16 SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, bool bApi, bool bRecursive) { - ExtTextView* pTextView = aEditWin.GetTextView(); + ExtTextView* pTextView = aEditWin->GetTextView(); TextSelection aSel; TextPaM aPaM; @@ -701,11 +701,11 @@ sal_Int32 SwSrcView::PrintSource( pOutDev->Push(); - TextEngine* pTextEngine = aEditWin.GetTextEngine(); + TextEngine* pTextEngine = aEditWin->GetTextEngine(); pOutDev->SetMapMode( MAP_100TH_MM ); - vcl::Font aFont( aEditWin.GetOutWin()->GetFont() ); + vcl::Font aFont( aEditWin->GetOutWin()->GetFont() ); Size aSize( aFont.GetSize() ); - aSize = aEditWin.GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM ); + aSize = aEditWin->GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM ); aFont.SetSize( aSize ); aFont.SetColor( COL_BLACK ); pOutDev->SetFont( aFont ); @@ -772,7 +772,7 @@ void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) pSimpleHint->GetId() == SFX_HINT_MODECHANGED || ( pSimpleHint->GetId() == SFX_HINT_TITLECHANGED && - !GetDocShell()->IsReadOnly() && aEditWin.IsReadonly() + !GetDocShell()->IsReadOnly() && aEditWin->IsReadonly() ) ) ) @@ -780,7 +780,7 @@ void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) // Broadcast only comes once! const SwDocShell* pDocSh = GetDocShell(); const bool bReadonly = pDocSh->IsReadOnly(); - aEditWin.SetReadonly(bReadonly); + aEditWin->SetReadonly(bReadonly); } SfxViewShell::Notify(rBC, rHint); } @@ -792,8 +792,8 @@ void SwSrcView::Load(SwDocShell* pDocShell) rtl_getBestMimeCharsetFromTextEncoding( rHtmlOptions.GetTextEncoding() ); rtl_TextEncoding eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet ); - aEditWin.SetReadonly(pDocShell->IsReadOnly()); - aEditWin.SetTextEncoding(eDestEnc); + aEditWin->SetReadonly(pDocShell->IsReadOnly()); + aEditWin->SetTextEncoding(eDestEnc); SfxMedium* pMedium = pDocShell->GetMedium(); const SfxFilter* pFilter = pMedium->GetFilter(); @@ -817,13 +817,13 @@ void SwSrcView::Load(SwDocShell* pDocShell) eDestEnc != eHeaderEnc ) { eDestEnc = eHeaderEnc; - aEditWin.SetTextEncoding(eDestEnc); + aEditWin->SetTextEncoding(eDestEnc); } pStream->SetStreamCharSet( eDestEnc ); pStream->Seek(0); - TextEngine* pTextEngine = aEditWin.GetTextEngine(); + TextEngine* pTextEngine = aEditWin->GetTextEngine(); pTextEngine->EnableUndo(false); - aEditWin.Read(*pStream); + aEditWin->Read(*pStream); pTextEngine->EnableUndo(true); } else @@ -851,17 +851,17 @@ void SwSrcView::Load(SwDocShell* pDocShell) if(nRes) { ErrorHandler::HandleError(ErrCode(nRes)); - aEditWin.SetReadonly(true); + aEditWin->SetReadonly(true); } aMedium.Commit(); SvStream* pInStream = aMedium.GetInStream(); pInStream->Seek(0); pInStream->SetStreamCharSet( eDestEnc ); - aEditWin.Read(*pInStream); + aEditWin->Read(*pInStream); } } - aEditWin.ClearModifyFlag(); + aEditWin->ClearModifyFlag(); eLoadEncoding = eDestEnc; @@ -871,9 +871,9 @@ void SwSrcView::Load(SwDocShell* pDocShell) pDocShell->SetAutoLoad(INetURLObject(), 0, false); OSL_ENSURE(PTR_CAST(SwWebDocShell, pDocShell), "Why no WebDocShell?"); sal_uInt16 nLine = static_cast<SwWebDocShell*>(pDocShell)->GetSourcePara(); - aEditWin.SetStartLine(nLine); - aEditWin.GetTextEngine()->ResetUndo(); - aEditWin.GetOutWin()->GrabFocus(); + aEditWin->SetStartLine(nLine); + aEditWin->GetTextEngine()->ResetUndo(); + aEditWin->GetOutWin()->GrabFocus(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 16e497b5c848..a3da88c0fcc7 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -692,14 +692,14 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) m_nNewPage(USHRT_MAX), m_nOldPageNum(0), m_pNumRuleNodeFromDoc(0), - m_pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ), + m_pEditWin( VclPtr<SwEditWin>::Create( &_pFrame->GetWindow(), *this ) ), m_pWrtShell(0), m_pShell(0), m_pFormShell(0), m_pHScrollbar(0), m_pVScrollbar(0), - m_pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )), - m_pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), m_pEditWin, + m_pScrollFill(VclPtr<ScrollBarBox>::Create( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )), + m_pVRuler(VclPtr<SvxRuler>::Create(&GetViewFrame()->GetWindow(), m_pEditWin, SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL| SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC, GetViewFrame()->GetBindings(), @@ -846,7 +846,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) } } SAL_INFO( "sw.ui", "after create WrtShell" ); - m_pHRuler = new SwCommentRuler(m_pWrtShell, &GetViewFrame()->GetWindow(), m_pEditWin, + m_pHRuler = VclPtr<SwCommentRuler>::Create(m_pWrtShell, &GetViewFrame()->GetWindow(), m_pEditWin, SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS | SVXRULER_SUPPORT_BORDERS | @@ -1050,18 +1050,18 @@ SwView::~SwView() m_pViewImpl->Invalidate(); EndListening(*GetViewFrame()); EndListening(*GetDocShell()); - delete m_pScrollFill; + m_pScrollFill.disposeAndClear(); delete m_pWrtShell; m_pWrtShell = 0; // Set to 0, so that it is not accessible by the following dtors cannot. m_pShell = 0; - delete m_pHScrollbar; - delete m_pVScrollbar; - delete m_pHRuler; - delete m_pVRuler; - delete m_pTogglePageBtn; + m_pHScrollbar.disposeAndClear(); + m_pVScrollbar.disposeAndClear(); + m_pHRuler.disposeAndClear(); + m_pVRuler.disposeAndClear(); + m_pTogglePageBtn.disposeAndClear(); delete m_pGlosHdl; delete m_pViewImpl; - delete m_pEditWin; + m_pEditWin.disposeAndClear(); delete m_pFormatClipboard; } diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index f052dbe1e2ea..83586ec227f1 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -240,8 +240,8 @@ int SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter, const sal_uInt16 aRotation = aMetadata.getRotation(); if (aRotation != 0) { - MessageDialog aQueryBox( GetWindow(),"QueryRotateIntoStandardOrientationDialog","modules/swriter/ui/queryrotateintostandarddialog.ui"); - if (aQueryBox.Execute() == RET_YES) + ScopedVclPtrInstance< MessageDialog > aQueryBox( GetWindow(),"QueryRotateIntoStandardOrientationDialog","modules/swriter/ui/queryrotateintostandarddialog.ui"); + if (aQueryBox->Execute() == RET_YES) { GraphicNativeTransform aTransform( aGraphic ); aTransform.rotate( aRotation ); @@ -439,8 +439,8 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) // really store as link only? if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() ) { - SvxLinkWarningDialog aWarnDlg(GetWindow(),pFileDlg->GetPath()); - if( aWarnDlg.Execute() != RET_OK ) + ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(GetWindow(),pFileDlg->GetPath()); + if( aWarnDlg->Execute() != RET_OK ) bAsLink=false; // don't store as link } } @@ -504,8 +504,8 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) { if( bShowError ) { - MessageDialog aInfoBox( GetWindow(), SW_RESSTR( nResId ), VCL_MESSAGE_INFO); - aInfoBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aInfoBox( GetWindow(), SW_RESSTR( nResId ), VCL_MESSAGE_INFO); + aInfoBox->Execute(); } rReq.Ignore(); } @@ -585,11 +585,11 @@ void SwView::Execute(SfxRequest &rReq) pParent = static_cast<const XWindowItem*>( pParentItem )->GetWindowPtr(); else pParent = &GetViewFrame()->GetWindow(); - SfxPasswordDialog aPasswdDlg( pParent ); - aPasswdDlg.SetMinLen( 1 ); + ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent ); + aPasswdDlg->SetMinLen( 1 ); //#i69751# the result of Execute() can be ignored - (void)aPasswdDlg.Execute(); - OUString sNewPasswd( aPasswdDlg.GetPassword() ); + (void)aPasswdDlg->Execute(); + OUString sNewPasswd( aPasswdDlg->GetPassword() ); Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword(); SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd)) @@ -623,14 +623,14 @@ void SwView::Execute(SfxRequest &rReq) pParent = static_cast<const XWindowItem*>( pParentItem )->GetWindowPtr(); else pParent = &GetViewFrame()->GetWindow(); - SfxPasswordDialog aPasswdDlg( pParent ); - aPasswdDlg.SetMinLen( 1 ); + ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent ); + aPasswdDlg->SetMinLen( 1 ); if(!aPasswd.getLength()) - aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); - if (aPasswdDlg.Execute()) + aPasswdDlg->ShowExtras(SfxShowExtras::CONFIRM); + if (aPasswdDlg->Execute()) { sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON; - OUString sNewPasswd( aPasswdDlg.GetPassword() ); + OUString sNewPasswd( aPasswdDlg->GetPassword() ); Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword(); SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); @@ -2286,11 +2286,11 @@ void SwView::GenerateFormLetter(bool bUseCurrentDocument) if ( lcl_NeedAdditionalDataSource( xDBContext ) ) { // no data sources are available - create a new one - MessageDialog aQuery(&GetViewFrame()->GetWindow(), + ScopedVclPtrInstance<MessageDialog> aQuery(&GetViewFrame()->GetWindow(), "DataSourcesUnavailableDialog", "modules/swriter/ui/datasourcesunavailabledialog.ui"); // no cancel allowed - if (RET_OK != aQuery.Execute()) + if (RET_OK != aQuery->Execute()) return; bCallAddressPilot = true; } @@ -2335,12 +2335,12 @@ void SwView::GenerateFormLetter(bool bUseCurrentDocument) OUString sSource; if(!GetWrtShell().IsFieldDataSourceAvailable(sSource)) { - MessageDialog aWarning(&GetViewFrame()->GetWindow(), + ScopedVclPtrInstance<MessageDialog> aWarning(&GetViewFrame()->GetWindow(), "WarnDataSourceDialog", "modules/swriter/ui/warndatasourcedialog.ui"); - OUString sTmp(aWarning.get_primary_text()); - aWarning.set_primary_text(sTmp.replaceFirst("%1", sSource)); - if (RET_OK == aWarning.Execute()) + OUString sTmp(aWarning->get_primary_text()); + aWarning->set_primary_text(sTmp.replaceFirst("%1", sSource)); + if (RET_OK == aWarning->Execute()) { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); if ( pFact ) @@ -2389,8 +2389,8 @@ void SwView::GenerateFormLetter(bool bUseCurrentDocument) SfxApplication* pSfxApp = SfxGetpApp(); vcl::Window* pTopWin = pSfxApp->GetTopWindow(); - SfxTemplateManagerDlg aDocTemplDlg; - int nRet = aDocTemplDlg.Execute(); + ScopedVclPtrInstance< SfxTemplateManagerDlg > aDocTemplDlg; + int nRet = aDocTemplDlg->Execute(); bool bNewWin = false; if ( nRet == RET_OK ) { diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 8ed2185dd44f..81e2ead3c251 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -177,9 +177,9 @@ void SwView::ExecDraw(SfxRequest& rReq) if ( pSdrView ) { SdrObject* pObj = NULL; - svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId ); - aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() ); - aDlg.Execute(); + ScopedVclPtrInstance< svx::FontWorkGalleryDialog > aDlg( pSdrView, pWin, nSlotId ); + aDlg->SetSdrObjectRef( &pObj, pSdrView->GetModel() ); + aDlg->Execute(); if ( pObj ) { Size aDocSize( m_pWrtShell->GetDocSize() ); diff --git a/sw/source/uibase/uiview/viewfunc.hxx b/sw/source/uibase/uiview/viewfunc.hxx index 4102270a1999..c66822e95a26 100644 --- a/sw/source/uibase/uiview/viewfunc.hxx +++ b/sw/source/uibase/uiview/viewfunc.hxx @@ -33,7 +33,7 @@ namespace vcl { class Window; } // The following functions are available in viewprt.cxx void SetPrinter( IDocumentDeviceAccess*, SfxPrinter*, bool bWeb ); -SfxTabPage* CreatePrintOptionsPage( vcl::Window*, const SfxItemSet& ); +VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window*, const SfxItemSet& ); void SetAppPrintOptions( SwViewShell* pSh, bool bWeb ); // The following functions are available in viewport.cxx diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index b0142b985c58..559b9ff747b7 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -459,8 +459,8 @@ void SwView::HyphenateDocument() // turned on no special area { // I want also in special areas hyphenation - MessageDialog aBox(&GetEditWin(), SW_RES(STR_QUERY_SPECIAL_FORCED), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - if( aBox.Execute() == RET_YES ) + ScopedVclPtrInstance< MessageDialog > aBox(&GetEditWin(), SW_RES(STR_QUERY_SPECIAL_FORCED), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + if( aBox->Execute() == RET_YES ) { bOther = true; if (xProp.is()) @@ -799,18 +799,20 @@ bool SwView::ExecSmartTagPopup( const Point& rPt ) class SwFieldDialog : public FloatingWindow { private: - ListBox aListBox; + VclPtr<ListBox> aListBox; IFieldmark *pFieldmark; DECL_LINK( MyListBoxHandler, ListBox * ); public: SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ); + virtual ~SwFieldDialog(); + virtual void dispose() SAL_OVERRIDE; }; SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) : FloatingWindow( parent, WB_BORDER | WB_SYSTEMWINDOW ), - aListBox(this), + aListBox(VclPtr<ListBox>::Create(this)), pFieldmark( fieldBM ) { if ( fieldBM != NULL ) @@ -827,7 +829,7 @@ SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) : pCurrent != vListEntries.getArray() + vListEntries.getLength(); ++pCurrent) { - aListBox.InsertEntry(*pCurrent); + aListBox->InsertEntry(*pCurrent); } } @@ -838,20 +840,31 @@ SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) : { sal_Int32 nSelection = -1; pResult->second >>= nSelection; - aListBox.SelectEntryPos( nSelection ); + aListBox->SelectEntryPos( nSelection ); } } - Size lbSize(aListBox.GetOptimalSize()); + Size lbSize(aListBox->GetOptimalSize()); lbSize.Width()+=50; lbSize.Height()+=20; - aListBox.SetSizePixel(lbSize); - aListBox.SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) ); - aListBox.Show(); + aListBox->SetSizePixel(lbSize); + aListBox->SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) ); + aListBox->Show(); SetSizePixel( lbSize ); } +SwFieldDialog::~SwFieldDialog() +{ + disposeOnce(); +} + +void SwFieldDialog::dispose() +{ + aListBox.disposeAndClear(); + FloatingWindow::dispose(); +} + IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox ) { short res = 0; @@ -875,11 +888,7 @@ IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox ) IMPL_LINK_NOARG(SwView, FieldPopupModeEndHdl) { - if ( m_pFieldPopup ) - { - delete m_pFieldPopup; - m_pFieldPopup = NULL; - } + m_pFieldPopup.disposeAndClear(); return 0; } @@ -887,7 +896,7 @@ void SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM ) { const Point aPixPos = GetEditWin().LogicToPixel( rPt ); - m_pFieldPopup = new SwFieldDialog( m_pEditWin, fieldBM ); + m_pFieldPopup = VclPtr<SwFieldDialog>::Create( m_pEditWin, fieldBM ); m_pFieldPopup->SetPopupModeEndHdl( LINK( this, SwView, FieldPopupModeEndHdl ) ); Rectangle aRect( m_pEditWin->OutputToScreenPixel( aPixPos ), Size( 0, 0 ) ); diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx index 8d63bcb4580a..b362b67520bf 100644 --- a/sw/source/uibase/uiview/viewmdi.cxx +++ b/sw/source/uibase/uiview/viewmdi.cxx @@ -290,25 +290,25 @@ IMPL_LINK( SwView, WindowChildEventListener, VclSimpleEvent*, pEvent ) int SwView::_CreateScrollbar( bool bHori ) { vcl::Window *pMDI = &GetViewFrame()->GetWindow(); - SwScrollbar** ppScrollbar = bHori ? &m_pHScrollbar : &m_pVScrollbar; + VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar; - assert(!*ppScrollbar); //check beforehand! + assert(!ppScrollbar.get()); //check beforehand! - *ppScrollbar = new SwScrollbar( pMDI, bHori ); + ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori ); UpdateScrollbars(); if(bHori) - (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl )); + ppScrollbar->SetScrollHdl( LINK( this, SwView, EndScrollHdl )); else - (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl )); - (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl )); + ppScrollbar->SetScrollHdl( LINK( this, SwView, ScrollHdl )); + ppScrollbar->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl )); - (*ppScrollbar)->EnableDrag( true ); + ppScrollbar->EnableDrag( true ); if(GetWindow()) InvalidateBorder(); if (!m_bShowAtResize) - (*ppScrollbar)->ExtendedShow(); + ppScrollbar->ExtendedShow(); return 1; } diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx index a9e63c363856..76cbdb39cdbe 100644 --- a/sw/source/uibase/uiview/viewprt.cxx +++ b/sw/source/uibase/uiview/viewprt.cxx @@ -147,8 +147,8 @@ bool SwView::HasPrintOptionsPage() const // TabPage for application-specific print options -SfxTabPage* SwView::CreatePrintOptionsPage(vcl::Window* pParent, - const SfxItemSet& rSet) +VclPtr<SfxTabPage> SwView::CreatePrintOptionsPage(vcl::Window* pParent, + const SfxItemSet& rSet) { return ::CreatePrintOptionsPage( pParent, rSet, false ); } @@ -175,10 +175,10 @@ void SwView::ExecutePrint(SfxRequest& rReq) } else { - MessageDialog aInfoBox(&GetEditWin(), SW_RES(STR_ERR_NO_FAX), VCL_MESSAGE_INFO); + ScopedVclPtrInstance< MessageDialog > aInfoBox(&GetEditWin(), SW_RES(STR_ERR_NO_FAX), VCL_MESSAGE_INFO); sal_uInt16 nResNo = bWeb ? STR_WEBOPTIONS : STR_TEXTOPTIONS; - aInfoBox.set_primary_text(aInfoBox.get_primary_text().replaceFirst("%1", OUString(SW_RES(nResNo)))); - aInfoBox.Execute(); + aInfoBox->set_primary_text(aInfoBox->get_primary_text().replaceFirst("%1", OUString(SW_RES(nResNo)))); + aInfoBox->Execute(); SfxUInt16Item aDefPage(SID_SW_EDITOPTIONS, TP_OPTPRINT_PAGE); GetViewFrame()->GetDispatcher()->Execute(SID_SW_EDITOPTIONS, SfxCallMode::SYNCHRON|SfxCallMode::RECORD, @@ -201,9 +201,9 @@ void SwView::ExecutePrint(SfxRequest& rReq) if(!bSilent && !bFromMerge && SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc()) { - MessageDialog aBox(&GetEditWin(), "PrintMergeDialog", + ScopedVclPtrInstance<MessageDialog> aBox(&GetEditWin(), "PrintMergeDialog", "modules/swriter/ui/printmergedialog.ui"); - short nRet = aBox.Execute(); + short nRet = aBox->Execute(); if(RET_YES == nRet) { SfxBoolItem aBool(FN_QRY_MERGE, true); @@ -245,8 +245,9 @@ void SwView::ExecutePrint(SfxRequest& rReq) // Create page printer/additions for SwView and SwPagePreview -SfxTabPage* CreatePrintOptionsPage( vcl::Window *pParent, - const SfxItemSet &rOptions, bool bPreview ) +VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent, + const SfxItemSet &rOptions, + bool bPreview ) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "No Print Dialog"); @@ -258,7 +259,9 @@ SfxTabPage* CreatePrintOptionsPage( vcl::Window *pParent, if (!fnCreatePage) return NULL; - SfxTabPage* pPage = (*fnCreatePage)(pParent, &rOptions); + VclPtr<SfxTabPage> pPage = + VclPtr<SfxTabPage>((*fnCreatePage)(pParent, &rOptions), + SAL_NO_ACQUIRE); OSL_ENSURE(pPage, "No page"); if (!pPage) return NULL; |