diff options
author | Noel Grandin <noel@peralex.com> | 2015-01-26 13:23:37 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-09 22:02:04 +0100 |
commit | 584e6c6051d8a8371941d61603672891a8aa3013 (patch) | |
tree | b1f050db216c528ac8a68521b045b39a051ecdfc /sw/source/uibase/uiview | |
parent | 45515c06d26d8a37e683f939b60198ee55343e55 (diff) |
vcl: VclPtr conversion in sw
Change-Id: Ie084a4b14f8371ff81fe6a95e73660e38cd376f2
Diffstat (limited to 'sw/source/uibase/uiview')
-rw-r--r-- | sw/source/uibase/uiview/srcview.cxx | 66 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewling.cxx | 29 |
2 files changed, 54 insertions, 41 deletions
diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 558210728968..b1a1c7e22300 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -219,7 +219,7 @@ static OUString lcl_ConvertTabsToSpaces( const OUString& sLine ) SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, SfxViewShell*) : SfxViewShell( pViewFrame, SWSRCVIEWFLAGS ), - aEditWin( &pViewFrame->GetWindow(), this ), + aEditWin( new SwSrcEditWindow( &pViewFrame->GetWindow(), this ) ), pSearchItem(0), bSourceSaved(false), eLoadEncoding(RTL_TEXTENCODING_DONTKNOW) @@ -231,7 +231,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( @@ -250,14 +250,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. @@ -265,7 +265,7 @@ void SwSrcView::Init() Load(pDocShell); else { - aEditWin.SetReadonly(true); + aEditWin->SetReadonly(true); } SetNewWindowAllowed( false ); @@ -283,13 +283,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: @@ -329,7 +329,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(); } } @@ -352,12 +352,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; @@ -370,7 +370,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; @@ -380,7 +380,7 @@ void SwSrcView::Execute(SfxRequest& rReq) if(pSrchItem) { StartSearchAndReplace( *pSrchItem, false, rReq.IsAPI() ); - if(aEditWin.IsModified()) + if(aEditWin->IsModified()) GetDocShell()->GetDoc()->getIDocumentState().SetModified(); } } @@ -416,14 +416,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) { @@ -472,7 +472,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 { @@ -539,7 +539,7 @@ void SwSrcView::GetState(SfxItemSet& rSet) { TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( - &aEditWin) ); + aEditWin.get()) ); bool bDisable = !aDataHelper.GetXTransferable().is() || 0 == aDataHelper.GetFormatCount(); if( bDisable ) @@ -571,7 +571,7 @@ sal_uInt16 SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, bool bApi, bool bRecursive) { - ExtTextView* pTextView = aEditWin.GetTextView(); + ExtTextView* pTextView = aEditWin->GetTextView(); TextSelection aSel; TextPaM aPaM; @@ -702,11 +702,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 ); @@ -773,7 +773,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() ) ) ) @@ -781,7 +781,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); } @@ -793,8 +793,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(); @@ -818,13 +818,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 @@ -852,17 +852,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; @@ -872,9 +872,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/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index b0142b985c58..7b3c95d25f2d 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -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(new ListBox(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() +{ + dispose(); +} + +void SwFieldDialog::dispose() +{ + aListBox.disposeAndClear(); + FloatingWindow::dispose(); +} + IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox ) { short res = 0; |