diff options
Diffstat (limited to 'sw/source/uibase/ribbar')
-rw-r--r-- | sw/source/uibase/ribbar/inputwin.cxx | 81 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/tblctrl.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/tbxanchr.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/workctrl.cxx | 39 |
4 files changed, 75 insertions, 49 deletions
diff --git a/sw/source/uibase/ribbar/inputwin.cxx b/sw/source/uibase/ribbar/inputwin.cxx index 981fc7660cdb..c20543cdd59e 100644 --- a/sw/source/uibase/ribbar/inputwin.cxx +++ b/sw/source/uibase/ribbar/inputwin.cxx @@ -58,8 +58,8 @@ SFX_IMPL_POS_CHILDWINDOW_WITHID( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OB SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) : ToolBox( pParent , SW_RES( RID_TBX_FORMULA )), - aPos( this, SW_RES(ED_POS)), - aEdit( this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION), + aPos( VclPtr<Edit>::Create(this, SW_RES(ED_POS))), + aEdit( VclPtr<InputEdit>::Create(this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION)), aPopMenu( SW_RES(MN_CALC_POPUP)), pMgr(0), pWrtShell(0), @@ -75,7 +75,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) FreeResource(); - aEdit.SetSizePixel( aEdit.CalcMinimumSize() ); + aEdit->SetSizePixel( aEdit->CalcMinimumSize() ); SfxImageManager* pManager = SfxImageManager::GetImageManager( *SW_MOD() ); pManager->RegisterToolBox(this); @@ -83,15 +83,15 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) pView = ::GetActiveView(); pWrtShell = pView ? pView->GetWrtShellPtr() : 0; - InsertWindow( ED_POS, &aPos, ToolBoxItemBits::NONE, 0); + InsertWindow( ED_POS, aPos.get(), ToolBoxItemBits::NONE, 0); SetItemText(ED_POS, SW_RESSTR(STR_ACCESS_FORMULA_TYPE)); - aPos.SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TYPE)); + aPos->SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TYPE)); SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TOOLBAR)); InsertSeparator ( 1 ); InsertSeparator (); - InsertWindow( ED_FORMULA, &aEdit); + InsertWindow( ED_FORMULA, aEdit.get()); SetItemText(ED_FORMULA, SW_RESSTR(STR_ACCESS_FORMULA_TEXT)); - aEdit.SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TEXT)); + aEdit->SetAccessibleName(SW_RESSTR(STR_ACCESS_FORMULA_TEXT)); SetHelpId(ED_FORMULA, HID_EDIT_FORMULA); SetItemImage( FN_FORMULA_CALC, pManager->GetImage(FN_FORMULA_CALC )); @@ -102,7 +102,7 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) SetDropdownClickHdl( LINK( this, SwInputWindow, DropdownClickHdl )); Size aSizeTbx = CalcWindowSizePixel(); - Size aEditSize = aEdit.GetSizePixel(); + Size aEditSize = aEdit->GetSizePixel(); Rectangle aItemRect( GetItemRect(FN_FORMULA_CALC) ); long nMaxHeight = (aEditSize.Height() > aItemRect.GetHeight()) ? aEditSize.Height() : aItemRect.GetHeight(); if( nMaxHeight+2 > aSizeTbx.Height() ) @@ -112,21 +112,26 @@ SwInputWindow::SwInputWindow( vcl::Window* pParent, SfxBindings* pBind ) SetSizePixel( aSize ); // align edit and item vcentered - Size aPosSize = aPos.GetSizePixel(); + Size aPosSize = aPos->GetSizePixel(); aPosSize.Height() = nMaxHeight; aEditSize.Height() = nMaxHeight; - Point aPosPos = aPos.GetPosPixel(); - Point aEditPos = aEdit.GetPosPixel(); + Point aPosPos = aPos->GetPosPixel(); + Point aEditPos = aEdit->GetPosPixel(); aPosPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1; aEditPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1; - aPos.SetPosSizePixel( aPosPos, aPosSize ); - aEdit.SetPosSizePixel( aEditPos, aEditSize ); + aPos->SetPosSizePixel( aPosPos, aPosSize ); + aEdit->SetPosSizePixel( aEditPos, aEditSize ); aPopMenu.SetSelectHdl(LINK( this, SwInputWindow, MenuHdl )); } SwInputWindow::~SwInputWindow() { + disposeOnce(); +} + +void SwInputWindow::dispose() +{ SfxImageManager::GetImageManager( *SW_MOD() )->ReleaseToolBox(this); // wake rulers @@ -140,6 +145,10 @@ SwInputWindow::~SwInputWindow() pWrtShell->EndSelTblCells(); CleanupUglyHackWithUndo(); + + aPos.disposeAndClear(); + aEdit.disposeAndClear(); + ToolBox::dispose(); } void SwInputWindow::CleanupUglyHackWithUndo() @@ -179,12 +188,12 @@ void SwInputWindow::Resize() ToolBox::Resize(); long nWidth = GetSizePixel().Width(); - long nLeft = aEdit.GetPosPixel().X(); - Size aEditSize = aEdit.GetSizePixel(); + long nLeft = aEdit->GetPosPixel().X(); + Size aEditSize = aEdit->GetSizePixel(); aEditSize.Width() = std::max( ((long)(nWidth - nLeft - 5)), (long)0 ); - aEdit.SetSizePixel( aEditSize ); - aEdit.Invalidate(); + aEdit->SetSizePixel( aEditSize ); + aEdit->Invalidate(); } void SwInputWindow::ShowWin() @@ -210,11 +219,11 @@ void SwInputWindow::ShowWin() short nSrch = -1; while( (nPos = rPos.indexOf( ':',nPos + 1 ) ) != -1 ) nSrch = (short) nPos; - aPos.SetText( rPos.copy( ++nSrch ) ); + aPos->SetText( rPos.copy( ++nSrch ) ); aAktTableName = pWrtShell->GetTableFmt()->GetName(); } else - aPos.SetText(SW_RESSTR(STR_TBL_FORMULA)); + aPos->SetText(SW_RESSTR(STR_TBL_FORMULA)); // Edit current field OSL_ENSURE(pMgr == 0, "FieldManager not deleted"); @@ -273,15 +282,15 @@ void SwInputWindow::ShowWin() bFirst = false; - aEdit.SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl )); + aEdit->SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl )); - aEdit.SetText( sEdit ); - aEdit.SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) ); + aEdit->SetText( sEdit ); + aEdit->SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) ); sOldFml = sEdit; - aEdit.Invalidate(); - aEdit.Update(); - aEdit.GrabFocus(); + aEdit->Invalidate(); + aEdit->Update(); + aEdit->GrabFocus(); // For input cut the UserInterface pView->GetEditWin().LockKeyInput(true); @@ -326,7 +335,7 @@ static const char * const aStrArr[] = { { OUString aTmp( OUString::createFromAscii(aStrArr[nId - 1]) ); aTmp += " "; - aEdit.ReplaceSelected( aTmp ); + aEdit->ReplaceSelected( aTmp ); } return 0; } @@ -376,7 +385,7 @@ void SwInputWindow::ApplyFormula() pWrtShell->Pop( false ); // Formular should always begin with "=", so remove it here again - OUString sEdit(comphelper::string::strip(aEdit.GetText(), ' ')); + OUString sEdit(comphelper::string::strip(aEdit->GetText(), ' ')); if( !sEdit.isEmpty() && '=' == sEdit[0] ) sEdit = sEdit.copy( 1 ); SfxStringItem aParam(FN_EDIT_FORMULA, sEdit); @@ -422,11 +431,11 @@ IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller ) if( pTblFmt && aAktTableName != pTblFmt->GetName() ) sTblNm = pTblFmt->GetName(); - aEdit.UpdateRange( sBoxNms, sTblNm ); + aEdit->UpdateRange( sBoxNms, sTblNm ); OUString sNew; sNew += OUString(CH_LRE); - sNew += aEdit.GetText(); + sNew += aEdit->GetText(); sNew += OUString(CH_PDF); if( sNew != sOldFml ) @@ -449,7 +458,7 @@ IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller ) } } else - aEdit.GrabFocus(); + aEdit->GrabFocus(); return 0; } @@ -463,9 +472,9 @@ void SwInputWindow::SetFormula( const OUString& rFormula, bool bDelFlag ) else sEdit += rFormula; } - aEdit.SetText( sEdit ); - aEdit.SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) ); - aEdit.Invalidate(); + aEdit->SetText( sEdit ); + aEdit->SetSelection( Selection( sEdit.getLength(), sEdit.getLength() ) ); + aEdit->Invalidate(); bDelSel = bDelFlag; } @@ -477,7 +486,7 @@ IMPL_LINK_NOARG(SwInputWindow, ModifyHdl) DelBoxCntnt(); OUString sNew; sNew += OUString(CH_LRE); - sNew += aEdit.GetText(); + sNew += aEdit->GetText(); sNew += OUString(CH_PDF); pWrtShell->SwEditShell::Insert2( sNew ); pWrtShell->EndAllAction(); @@ -616,8 +625,8 @@ SwInputChild::SwInputChild(vcl::Window* _pParent, SfxChildWindow( _pParent, nId ) { pDispatch = pBindings->GetDispatcher(); - pWindow = new SwInputWindow( _pParent, pBindings ); - static_cast<SwInputWindow*>(pWindow)->ShowWin(); + pWindow = VclPtr<SwInputWindow>::Create( _pParent, pBindings ); + static_cast<SwInputWindow*>(pWindow.get())->ShowWin(); eChildAlignment = SfxChildAlignment::LOWESTTOP; } diff --git a/sw/source/uibase/ribbar/tblctrl.cxx b/sw/source/uibase/ribbar/tblctrl.cxx index b56e892c0da4..bcdc852aa382 100644 --- a/sw/source/uibase/ribbar/tblctrl.cxx +++ b/sw/source/uibase/ribbar/tblctrl.cxx @@ -41,7 +41,7 @@ SwTableOptimizeCtrl::~SwTableOptimizeCtrl() { } -SfxPopupWindow* SwTableOptimizeCtrl::CreatePopupWindow() +VclPtr<SfxPopupWindow> SwTableOptimizeCtrl::CreatePopupWindow() { createAndPositionSubToolBar("private:resource/toolbar/optimizetablebar"); return NULL; diff --git a/sw/source/uibase/ribbar/tbxanchr.cxx b/sw/source/uibase/ribbar/tbxanchr.cxx index 1b747b16daa9..b25dd8aa1b56 100644 --- a/sw/source/uibase/ribbar/tbxanchr.cxx +++ b/sw/source/uibase/ribbar/tbxanchr.cxx @@ -62,7 +62,7 @@ void SwTbxAnchor::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const } -SfxPopupWindow* SwTbxAnchor::CreatePopupWindow() +VclPtr<SfxPopupWindow> SwTbxAnchor::CreatePopupWindow() { SwTbxAnchor::Click(); return 0; diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index b04dd47f240e..ed6208ca7c06 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -122,7 +122,7 @@ void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/, } -SfxPopupWindow* SwTbxInsertCtrl::CreatePopupWindow() +VclPtr<SfxPopupWindow> SwTbxInsertCtrl::CreatePopupWindow() { if(GetSlotId() == FN_INSERT_CTRL) { @@ -176,7 +176,7 @@ SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl() DelPopup(); } -SfxPopupWindow* SwTbxAutoTextCtrl::CreatePopupWindow() +VclPtr<SfxPopupWindow> SwTbxAutoTextCtrl::CreatePopupWindow() { SwView* pView = ::GetActiveView(); if(pView && !pView->GetDocShell()->IsReadOnly() && @@ -288,7 +288,7 @@ SwTbxFieldCtrl::~SwTbxFieldCtrl() { } -SfxPopupWindow* SwTbxFieldCtrl::CreatePopupWindow() +VclPtr<SfxPopupWindow> SwTbxFieldCtrl::CreatePopupWindow() { SwView* pView = ::GetActiveView(); if(pView && !pView->GetDocShell()->IsReadOnly() && @@ -398,7 +398,7 @@ SwScrollNaviPopup::SwScrollNaviPopup(sal_uInt16 nId, const Reference< XFrame >& "modules/swriter/ui/floatingnavigation.ui", rFrame), aIList(SW_RES(IL_VALUES)) { - m_pToolBox = new SwScrollNaviToolBox(get<vcl::Window>("box"), this, 0); + m_pToolBox = VclPtr<SwScrollNaviToolBox>::Create(get<vcl::Window>("box"), this, 0); get(m_pInfoField, "label"); sal_uInt16 i; @@ -448,7 +448,14 @@ SwScrollNaviPopup::SwScrollNaviPopup(sal_uInt16 nId, const Reference< XFrame >& SwScrollNaviPopup::~SwScrollNaviPopup() { - delete m_pToolBox; + disposeOnce(); +} + +void SwScrollNaviPopup::dispose() +{ + m_pToolBox.disposeAndClear(); + m_pInfoField.clear(); + SfxPopupWindow::dispose(); } void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt ) @@ -470,9 +477,9 @@ void SwScrollNaviPopup::ApplyImageList() } } -SfxPopupWindow* SwScrollNaviPopup::Clone() const +VclPtr<SfxPopupWindow> SwScrollNaviPopup::Clone() const { - return new SwScrollNaviPopup( GetId(), GetFrame(), GetParent() ); + return VclPtr<SwScrollNaviPopup>::Create( GetId(), GetFrame(), GetParent() ); } IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet) @@ -503,6 +510,17 @@ IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet) return 0; } +SwScrollNaviToolBox::~SwScrollNaviToolBox() +{ + disposeOnce(); +} + +void SwScrollNaviToolBox::dispose() +{ + m_pNaviPopup.disposeAndClear(); + ToolBox::dispose(); +} + void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt ) { ToolBox::MouseButtonUp(rMEvt); @@ -515,7 +533,6 @@ void SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt ) SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(true)); SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(false)); ToolBox::RequestHelp( rHEvt ); - } OUString SwScrollNaviPopup::GetQuickHelpText(bool bNext) @@ -699,10 +716,10 @@ void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/, } } -vcl::Window* SwPreviewZoomControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> SwPreviewZoomControl::CreateItemWindow( vcl::Window *pParent ) { - SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY )); - return pRet; + VclPtrInstance<SwZoomBox_Impl> pRet( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY )); + return pRet.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |