diff options
Diffstat (limited to 'sc/source/ui/view')
26 files changed, 293 insertions, 241 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 2d7639f2e95a..1145e2bd5633 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1931,7 +1931,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) const ScPatternAttr* pPattern = pDoc->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab()); const std::vector<sal_uInt32>& rCondFormats = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData(); bool bContainsCondFormat = !rCondFormats.empty(); - boost::scoped_ptr<ScCondFormatDlg> pCondFormatDlg; + VclPtr<ScCondFormatDlg> pCondFormatDlg; if(bContainsCondFormat) { bool bContainsExistingCondFormat = false; @@ -1950,7 +1950,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) { // found a matching range, edit this conditional format nKey = pCondFormat->GetKey(); - pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) ); + pCondFormatDlg.reset( VclPtr<ScCondFormatDlg>::Create( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) ); break; } } @@ -1960,9 +1960,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) if(!pCondFormatDlg && bContainsExistingCondFormat) { - QueryBox aBox( pTabViewShell->GetDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ), + ScopedVclPtrInstance<QueryBox> aBox( pTabViewShell->GetDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ), ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS) ); - bool bEditExisting = aBox.Execute() == RET_YES; + bool bEditExisting = aBox->Execute() == RET_YES; if(bEditExisting) { // differentiate between ranges where one conditional format is defined @@ -1975,7 +1975,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) assert(pCondFormat); const ScRangeList& rCondFormatRange = pCondFormat->GetRange(); nKey = pCondFormat->GetKey(); - pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) ); + pCondFormatDlg.reset( VclPtr<ScCondFormatDlg>::Create( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) ); } else { @@ -2023,7 +2023,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) assert(false); break; } - pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), eType ) ); + pCondFormatDlg.reset( VclPtr<ScCondFormatDlg>::Create( pTabViewShell->GetDialogParent(), pDoc, nullptr, aRangeList, aRangeList.GetTopLeftCorner(), eType ) ); } sal_uInt16 nId = 1; @@ -2652,10 +2652,10 @@ void ScCellShell::ExecuteDataPilotDialog() { // confirm selection if it contains SubTotal cells - QueryBox aBox( pTabViewShell->GetDialogParent(), + ScopedVclPtrInstance<QueryBox> aBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) ); - if (aBox.Execute() == RET_NO) + if (aBox->Execute() == RET_NO) bOK = false; } if (bOK) @@ -2682,8 +2682,8 @@ void ScCellShell::ExecuteDataPilotDialog() if (nSrcErrorId) { // Error occurred during data creation. Launch an error and bail out. - InfoBox aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId)); - aBox.Execute(); + ScopedVclPtrInstance< InfoBox > aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId)); + aBox->Execute(); return; } diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 974c9a1eddc6..2b427c3023ca 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -740,15 +740,15 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) break; case SID_DATA_STREAMS: { - sc::DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() ); + ScopedVclPtrInstance< sc::DataStreamDlg > aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() ); ScDocument *pDoc = GetViewData()->GetDocument(); sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager(); sc::DataStream* pStrm = rMgr.getDataStream(); if (pStrm) - aDialog.Init(*pStrm); + aDialog->Init(*pStrm); - if (aDialog.Execute() == RET_OK) - aDialog.StartStream(); + if (aDialog->Execute() == RET_OK) + aDialog->StartStream(); } break; case SID_DATA_STREAMS_PLAY: diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 295ed340f94e..77be8cf171a4 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -422,9 +422,9 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else if( ! rReq.IsAPI() ) { - MessageDialog aErrorBox(pTabViewShell->GetDialogParent(), + ScopedVclPtrInstance<MessageDialog> aErrorBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(STR_NOAREASELECTED)); - aErrorBox.Execute(); + aErrorBox->Execute(); } } else diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx index b2099de5cb7b..83224c957fbb 100644 --- a/sc/source/ui/view/dbfunc.cxx +++ b/sc/source/ui/view/dbfunc.cxx @@ -383,9 +383,9 @@ void ScDBFunc::ToggleAutoFilter() } else { - MessageDialog aErrorBox(GetViewData().GetDialogParent(), + ScopedVclPtrInstance<MessageDialog> aErrorBox(GetViewData().GetDialogParent(), ScGlobal::GetRscString(STR_ERR_AUTOFILTER)); - aErrorBox.Execute(); + aErrorBox->Execute(); } } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index a39603115070..94f629c2f696 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -205,7 +205,7 @@ bool ScGridWindow::VisibleRange::set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO class ScFilterListBox : public ListBox { private: - ScGridWindow* pGridWin; + VclPtr<ScGridWindow> pGridWin; SCCOL nCol; SCROW nRow; bool bButtonDown; @@ -224,6 +224,7 @@ public: ScFilterListBox( vcl::Window* pParent, ScGridWindow* pGrid, SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ); virtual ~ScFilterListBox(); + virtual void dispose() SAL_OVERRIDE; virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE; virtual void Select() SAL_OVERRIDE; @@ -258,8 +259,15 @@ ScFilterListBox::ScFilterListBox( vcl::Window* pParent, ScGridWindow* pGrid, ScFilterListBox::~ScFilterListBox() { + disposeOnce(); +} + +void ScFilterListBox::dispose() +{ if (IsMouseCaptured()) ReleaseMouse(); + pGridWin.clear(); + ListBox::dispose(); } void ScFilterListBox::EndInit() @@ -337,6 +345,7 @@ class ScFilterFloatingWindow : public FloatingWindow public: ScFilterFloatingWindow( vcl::Window* pParent, WinBits nStyle = WB_STDFLOATWIN ); virtual ~ScFilterFloatingWindow(); + virtual void dispose() SAL_OVERRIDE; // required for System FloatingWindows that will not process KeyInput by themselves virtual vcl::Window* GetPreferredKeyInputWindow() SAL_OVERRIDE; }; @@ -347,7 +356,13 @@ ScFilterFloatingWindow::ScFilterFloatingWindow( vcl::Window* pParent, WinBits nS ScFilterFloatingWindow::~ScFilterFloatingWindow() { + disposeOnce(); +} + +void ScFilterFloatingWindow::dispose() +{ EndPopupMode(); + FloatingWindow::dispose(); } vcl::Window* ScFilterFloatingWindow::GetPreferredKeyInputWindow() @@ -522,6 +537,21 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos ScGridWindow::~ScGridWindow() { + disposeOnce(); +} + +void ScGridWindow::dispose() +{ + // #114409# + ImpDestroyOverlayObjects(); + + mpFilterBox.disposeAndClear(); + mpFilterFloat.disposeAndClear(); + mpNoteMarker.reset(); + mpAutoFilterPopup.disposeAndClear(); + mpDPFieldPopup.disposeAndClear(); + + vcl::Window::dispose(); } void ScGridWindow::ClickExtern() @@ -535,8 +565,8 @@ void ScGridWindow::ClickExtern() { break; } - mpFilterBox.reset(); - mpFilterFloat.reset(); + mpFilterBox.disposeAndClear(); + mpFilterFloat.disposeAndClear(); } while (false); @@ -612,7 +642,7 @@ struct AutoFilterData : public ScCheckListMenuWindow::ExtendedData class AutoFilterAction : public ScMenuFloatingWindow::Action { - ScGridWindow* mpWindow; + VclPtr<ScGridWindow> mpWindow; ScGridWindow::AutoFilterMode meMode; public: AutoFilterAction(ScGridWindow* p, ScGridWindow::AutoFilterMode eMode) : @@ -625,7 +655,7 @@ public: class AutoFilterPopupEndAction : public ScMenuFloatingWindow::Action { - ScGridWindow* mpWindow; + VclPtr<ScGridWindow> mpWindow; ScAddress maPos; public: AutoFilterPopupEndAction(ScGridWindow* p, const ScAddress& rPos) : @@ -673,7 +703,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) SCTAB nTab = pViewData->GetTabNo(); ScDocument* pDoc = pViewData->GetDocument(); - mpAutoFilterPopup.reset(new ScCheckListMenuWindow(this, pDoc)); + mpAutoFilterPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, pDoc)); mpAutoFilterPopup->setOKAction(new AutoFilterAction(this, Normal)); mpAutoFilterPopup->setPopupEndAction( new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab))); @@ -933,8 +963,8 @@ void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow ) void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange ) { - mpFilterBox.reset(); - mpFilterFloat.reset(); + mpFilterBox.disposeAndClear(); + mpFilterFloat.disposeAndClear(); SCCOL nCol = rScenRange.aEnd.Col(); // Zelle unterhalb des Buttons SCROW nRow = rScenRange.aStart.Row(); @@ -964,9 +994,9 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange ) // Die ListBox direkt unter der schwarzen Linie auf dem Zellgitter // (wenn die Linie verdeckt wird, sieht es komisch aus...) - mpFilterFloat.reset(new ScFilterFloatingWindow(this, WinBits(WB_BORDER))); + mpFilterFloat.reset(VclPtr<ScFilterFloatingWindow>::Create(this, WinBits(WB_BORDER))); mpFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); - mpFilterBox.reset(new ScFilterListBox(mpFilterFloat.get(), this, nCol, nRow, SC_FILTERBOX_SCENARIO)); + mpFilterBox.reset(VclPtr<ScFilterListBox>::Create(mpFilterFloat.get(), this, nCol, nRow, SC_FILTERBOX_SCENARIO)); if (bLayoutRTL) mpFilterBox->EnableMirroring(); @@ -1069,8 +1099,8 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange ) void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect ) { - mpFilterBox.reset(); - mpFilterFloat.reset(); + mpFilterBox.disposeAndClear(); + mpFilterFloat.disposeAndClear(); sal_uInt16 i; ScDocument* pDoc = pViewData->GetDocument(); @@ -1090,10 +1120,10 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelec aPos.X() -= 1; aPos.Y() += nSizeY - 1; - mpFilterFloat.reset(new ScFilterFloatingWindow(this, WinBits(WB_BORDER))); + mpFilterFloat.reset(VclPtr<ScFilterFloatingWindow>::Create(this, WinBits(WB_BORDER))); mpFilterFloat->SetPopupModeEndHdl(LINK( this, ScGridWindow, PopupModeEndHdl)); ScFilterBoxMode eFilterMode = bDataSelect ? SC_FILTERBOX_DATASELECT : SC_FILTERBOX_FILTER; - mpFilterBox.reset(new ScFilterListBox(mpFilterFloat.get(), this, nCol, nRow, eFilterMode)); + mpFilterBox.reset(VclPtr<ScFilterListBox>::Create(mpFilterFloat.get(), this, nCol, nRow, eFilterMode)); // Fix for bug fdo#44925 if (AllSettings::GetLayoutRTL() != bLayoutRTL) mpFilterBox->EnableMirroring(); @@ -1305,8 +1335,8 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelec if ( bEmpty ) { - mpFilterBox.reset(); - mpFilterFloat.reset(); + mpFilterBox.disposeAndClear(); + mpFilterFloat.disposeAndClear(); } else { diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index 60b27acf04d9..04194904e382 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -395,7 +395,7 @@ public: mpGridWindow->UpdateDPFromFieldPopupMenu(); } private: - ScGridWindow* mpGridWindow; + VclPtr<ScGridWindow> mpGridWindow; }; class PopupSortAction : public ScMenuFloatingWindow::Action @@ -455,7 +455,7 @@ void ScGridWindow::DPLaunchFieldPopupMenu( const ScDPLabelData& rLabelData = pDPData->maLabels; - mpDPFieldPopup.reset(new ScCheckListMenuWindow(this, pViewData->GetDocument())); + mpDPFieldPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, pViewData->GetDocument())); mpDPFieldPopup->setName("DataPilot field member popup"); mpDPFieldPopup->setExtendedData(pDPData.release()); mpDPFieldPopup->setOKAction(new DPFieldPopupOKAction(this)); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9a78d1067690..9c4f7c6fbd48 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -482,7 +482,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod aOutputData.SetMirrorWidth( nMirrorWidth ); // needed for RTL aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get()); - std::unique_ptr<VirtualDevice> xFmtVirtDev; + ScopedVclPtr< VirtualDevice > xFmtVirtDev; bool bLogicText = bTextWysiwyg; // call DrawStrings in logic MapMode? if ( bTextWysiwyg ) diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx index 4752e567f4de..5e5f46dfc892 100644 --- a/sc/source/ui/view/olinewin.cxx +++ b/sc/source/ui/view/olinewin.cxx @@ -71,10 +71,16 @@ ScOutlineWindow::ScOutlineWindow( vcl::Window* pParent, ScOutlineMode eMode, ScV ScOutlineWindow::~ScOutlineWindow() { + disposeOnce(); +} + +void ScOutlineWindow::dispose() +{ // remove the window from task pane list if( SystemWindow* pSysWin = GetSystemWindow() ) if( TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList() ) pTaskPaneList->RemoveWindow( this ); + vcl::Window::dispose(); } void ScOutlineWindow::SetHeaderSize( long nNewSize ) diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index 14e16b366e41..3267fb8a6296 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -143,8 +143,14 @@ ScPreview::ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell* ScPreview::~ScPreview() { + disposeOnce(); +} + +void ScPreview::dispose() +{ delete pDrawView; delete pLocationData; + vcl::Window::dispose(); } void ScPreview::UpdateDrawView() // nTab must be right diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 49500b78eaed..ef3ef07d8078 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -119,10 +119,10 @@ void ScPreviewShell::Construct( vcl::Window* pParent ) eZoom = SvxZoomType::WHOLEPAGE; - pCorner = new ScrollBarBox( pParent, WB_SIZEABLE ); + pCorner = VclPtr<ScrollBarBox>::Create( pParent, WB_SIZEABLE ); - pHorScroll = new ScrollBar(pParent, WB_HSCROLL ); - pVerScroll = new ScrollBar(pParent, WB_VSCROLL); + pHorScroll = VclPtr<ScrollBar>::Create(pParent, WB_HSCROLL ); + pVerScroll = VclPtr<ScrollBar>::Create(pParent, WB_VSCROLL); // SSA: --- RTL --- no mirroring for horizontal scrollbars pHorScroll->EnableRTL( false ); @@ -130,7 +130,7 @@ void ScPreviewShell::Construct( vcl::Window* pParent ) pHorScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) ); pVerScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) ); - pPreview = new ScPreview( pParent, pDocShell, this ); + pPreview = VclPtr<ScPreview>::Create( pParent, pDocShell, this ); SetPool( &SC_MOD()->GetPool() ); SetWindow( pPreview ); @@ -197,10 +197,10 @@ ScPreviewShell::~ScPreviewShell() EndListening(*pDocShell); SetWindow(0); - delete pPreview; - delete pHorScroll; - delete pVerScroll; - delete pCorner; + pPreview.disposeAndClear(); + pHorScroll.disposeAndClear(); + pVerScroll.disposeAndClear(); + pCorner.disposeAndClear(); // normal mode of operation is switching back to default view in the same frame, // so there's no need to activate any other window here anymore @@ -532,14 +532,15 @@ bool ScPreviewShell::HasPrintOptionsPage() const return true; } -SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions ) +VclPtr<SfxTabPage> ScPreviewShell::CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions ) { ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); - ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT ); + ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT ); if ( ScTpPrintOptionsCreate ) - return (*ScTpPrintOptionsCreate)( pParent, &rOptions); - return 0; + return VclPtr<SfxTabPage>((*ScTpPrintOptionsCreate)( pParent, &rOptions), + SAL_NO_ACQUIRE); + return VclPtr<SfxTabPage>(); } void ScPreviewShell::Activate(bool bMDI) diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 55bfb1d6b5a9..ff34a7b7a79e 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -231,7 +231,7 @@ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTa nTotalY(0), pPageData ( pData ) { - pDev = pPrinter; + pDev = pPrinter.get(); aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM ); Construct( pOptions ); } diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index d6a1258d14f4..3b0e96224d29 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -187,42 +187,42 @@ void ScSimpleRefDlgWrapper::SetAutoReOpen(bool bFlag) void ScSimpleRefDlgWrapper::SetRefString(const OUString& rStr) { - if(pWindow!=NULL) + if(pWindow!=nullptr) { - static_cast<ScSimpleRefDlg*>(pWindow)->SetRefString(rStr); + static_cast<ScSimpleRefDlg*>(pWindow.get())->SetRefString(rStr); } } void ScSimpleRefDlgWrapper::SetCloseHdl( const Link& rLink ) { - if(pWindow!=NULL) + if(pWindow!=nullptr) { - static_cast<ScSimpleRefDlg*>(pWindow)->SetCloseHdl( rLink ); + static_cast<ScSimpleRefDlg*>(pWindow.get())->SetCloseHdl( rLink ); } } void ScSimpleRefDlgWrapper::SetUnoLinks( const Link& rDone, const Link& rAbort, const Link& rChange ) { - if(pWindow!=NULL) + if(pWindow!=nullptr) { - static_cast<ScSimpleRefDlg*>(pWindow)->SetUnoLinks( rDone, rAbort, rChange ); + static_cast<ScSimpleRefDlg*>(pWindow.get())->SetUnoLinks( rDone, rAbort, rChange ); } } void ScSimpleRefDlgWrapper::SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ) { - if(pWindow!=NULL) + if(pWindow!=nullptr) { - static_cast<ScSimpleRefDlg*>(pWindow)->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); + static_cast<ScSimpleRefDlg*>(pWindow.get())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); } } void ScSimpleRefDlgWrapper::StartRefInput() { - if(pWindow!=NULL) + if(pWindow!=nullptr) { - static_cast<ScSimpleRefDlg*>(pWindow)->StartRefInput(); + static_cast<ScSimpleRefDlg*>(pWindow.get())->StartRefInput(); } } @@ -237,12 +237,13 @@ ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( vcl::Window* pParentP, ScTabViewShell* pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); OSL_ENSURE( pViewShell, "missing view shell :-(" ); - pWindow = pViewShell ? - new ScAcceptChgDlg( pBindings, this, pParentP, &pViewShell->GetViewData() ) : - NULL; - if(pWindow!=NULL) + if (pViewShell) + pWindow = VclPtr<ScAcceptChgDlg>::Create( pBindings, this, pParentP, &pViewShell->GetViewData() ); + else + pWindow = NULL; + if(pWindow!=nullptr) { - static_cast<ScAcceptChgDlg*>(pWindow)->Initialize( pInfo ); + static_cast<ScAcceptChgDlg*>(pWindow.get())->Initialize( pInfo ); } if (pViewShell && !pWindow) pViewShell->GetViewFrame()->SetChildWindow( nId, false ); @@ -254,9 +255,9 @@ void ScAcceptChgDlgWrapper::ReInitDlg() PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); OSL_ENSURE( pViewShell, "missing view shell :-(" ); - if(pWindow!=NULL && pViewShell) + if(pWindow!=nullptr && pViewShell) { - static_cast<ScAcceptChgDlg*>(pWindow)->ReInit(&pViewShell->GetViewData()); + static_cast<ScAcceptChgDlg*>(pWindow.get())->ReInit(&pViewShell->GetViewData()); } } @@ -289,7 +290,7 @@ ScValidityRefChildWin::ScValidityRefChildWin( vcl::Window* pParent { SetWantsFocus( false ); ScTabViewShell* pViewShell = - NULL != ( pWindow = ScValidationDlg::Find1AliveObject( pParentP ) ) ? static_cast<ScValidationDlg*>(pWindow)->GetTabViewShell() : + nullptr != ( pWindow = ScValidationDlg::Find1AliveObject( pParentP ) ) ? static_cast<ScValidationDlg*>(pWindow.get())->GetTabViewShell() : lcl_GetTabViewShell( p ); if (!pViewShell) pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index ad7e6bc54b1e..3ea3d0dfeafd 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -305,10 +305,10 @@ bool ScSpellingEngine::ShowTableWrapDialog() { vcl::Window* pParent = GetDialogParent(); ScWaitCursorOff aWaitOff( pParent ); - MessBox aMsgBox( pParent, WinBits( WB_YES_NO | WB_DEF_YES ), + ScopedVclPtrInstance<MessBox> aMsgBox( pParent, WinBits( WB_YES_NO | WB_DEF_YES ), ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), ScGlobal::GetRscString( STR_SPELLING_BEGIN_TAB) ); - return aMsgBox.Execute() == RET_YES; + return aMsgBox->Execute() == RET_YES; } void ScSpellingEngine::ShowFinishDialog() diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 706856f4cfe0..57b71dd50d08 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -199,13 +199,13 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pHdrSelEng( NULL ), aHdrFunc( &aViewData ), pDrawView( NULL ), - aVScrollTop( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), - aVScrollBottom( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), - aHScrollLeft( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), - aHScrollRight( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), - aCornerButton( pFrameWin, &aViewData, false ), - aTopButton( pFrameWin, &aViewData, true ), - aScrollBarBox( pFrameWin, WB_SIZEABLE ), + aVScrollTop( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ) ), + aVScrollBottom( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ) ), + aHScrollLeft( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ) ), + aHScrollRight( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ) ), + aCornerButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData, false ) ), + aTopButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData, true ) ), + aScrollBarBox( VclPtr<ScrollBarBox>::Create( pFrameWin, WB_SIZEABLE ) ), mpInputHintWindow( NULL ), pPageBreakData( NULL ), pBrushDocument( NULL ), @@ -280,7 +280,7 @@ IMPL_LINK_NOARG(ScTabView, TimerHdl) // --- Resize --------------------------------------------------------------------- static void lcl_SetPosSize( vcl::Window& rWindow, const Point& rPos, const Size& rSize, - long nTotalWidth, bool bLayoutRTL ) + long nTotalWidth, bool bLayoutRTL ) { Point aNewPos = rPos; if ( bLayoutRTL ) @@ -394,7 +394,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) } // window at the bottom right - lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ), + lcl_SetPosSize( *aScrollBarBox.get(), Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ), nTotalWidth, bLayoutRTL ); if (bHScroll) // Scrollbars horizontal @@ -458,39 +458,39 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) { Point aTabPoint(nPosX, nPosY + nSizeY); Size aTabSize(nTabSize, nBarY); - lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*pTabControl.get(), aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); pTabControl->SetSheetLayoutRTL(bLayoutRTL); Point aHScrollLeftPoint(nPosX + nTabSize, nPosY + nSizeY); Size aHScrollLeftSize(nSizeLt, nBarY); - lcl_SetPosSize(aHScrollLeft, aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*aHScrollLeft.get(), aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL); Point aHSplitterPoint(nPosX + nTabSize + nSizeLt, nPosY + nSizeY); Size aHSplitterSize(nSizeSp, nBarY); - lcl_SetPosSize(*pHSplitter, aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*pHSplitter.get(), aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL); Point aHScrollRightPoint(nPosX + nTabSize + nSizeLt + nSizeSp, nPosY + nSizeY); Size aHScrollRightSize(nSizeRt, nBarY); - lcl_SetPosSize(aHScrollRight, aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*aHScrollRight.get(), aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL); } else { Point aTabPoint(nPosX, nPosY + nSizeY + nScrollBarSize); Size aTabSize(nSizeX, nTabWidth); - lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*pTabControl.get(), aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); pTabControl->SetSheetLayoutRTL(bLayoutRTL); Point aHScrollLeftPoint(nPosX, nPosY + nSizeY); Size aHScrollLeftSize(nSizeLt, nScrollBarSize); - lcl_SetPosSize(aHScrollLeft, aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*aHScrollLeft.get(), aHScrollLeftPoint, aHScrollLeftSize, nTotalWidth, bLayoutRTL); Point aHSplitterPoint(nPosX + nSizeLt, nPosY + nSizeY); Size aHSplitterSize(nSizeSp, nScrollBarSize); - lcl_SetPosSize(*pHSplitter, aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*pHSplitter.get(), aHSplitterPoint, aHSplitterSize, nTotalWidth, bLayoutRTL); Point aHScrollRightPoint(nPosX + nSizeLt + nSizeSp, nPosY + nSizeY); Size aHScrollRightSize(nSizeRt, nScrollBarSize); - lcl_SetPosSize(aHScrollRight, aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL); + lcl_SetPosSize(*aHScrollRight.get(), aHScrollRightPoint, aHScrollRightSize, nTotalWidth, bLayoutRTL); } // SetDragRectPixel is done below } @@ -518,11 +518,11 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) } nSizeDn = nSizeY - nSizeUp - nSizeSp; - lcl_SetPosSize( aVScrollTop, Point(nPosX + nSizeX, nPosY), + lcl_SetPosSize( *aVScrollTop.get(), Point(nPosX + nSizeX, nPosY), Size(nBarX, nSizeUp), nTotalWidth, bLayoutRTL ); lcl_SetPosSize( *pVSplitter, Point( nPosX + nSizeX, nPosY+nSizeUp ), Size( nBarX, nSizeSp ), nTotalWidth, bLayoutRTL ); - lcl_SetPosSize( aVScrollBottom, Point(nPosX + nSizeX, + lcl_SetPosSize( *aVScrollBottom.get(), Point(nPosX + nSizeX, nPosY + nSizeUp + nSizeSp), Size(nBarX, nSizeDn), nTotalWidth, bLayoutRTL ); @@ -540,25 +540,25 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) if (bTabControl && ! bHScroll ) { - nBarY = aHScrollLeft.GetSizePixel().Height(); - nBarX = aVScrollBottom.GetSizePixel().Width(); + nBarY = aHScrollLeft->GetSizePixel().Height(); + nBarX = aVScrollBottom->GetSizePixel().Width(); long nSize1 = nSizeX; long nTabSize = nSize1; if (nTabSize < 0) nTabSize = 0; - lcl_SetPosSize( *pTabControl, Point(nPosX, nPosY+nSizeY-nBarY), + lcl_SetPosSize( *pTabControl.get(), Point(nPosX, nPosY+nSizeY-nBarY), Size(nTabSize, nBarY), nTotalWidth, bLayoutRTL ); nSizeY -= nBarY; - lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ), + lcl_SetPosSize( *aScrollBarBox.get(), Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ), nTotalWidth, bLayoutRTL ); if( bVScroll ) { - Size aVScrSize = aVScrollBottom.GetSizePixel(); + Size aVScrSize = aVScrollBottom->GetSizePixel(); aVScrSize.Height() -= nBarY; - aVScrollBottom.SetSizePixel( aVScrSize ); + aVScrollBottom->SetSizePixel( aVScrSize ); } } @@ -607,7 +607,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) { // Fixier-Splitter nicht mit Scrollbar/TabBar ueberlappen lassen if ( bHScroll ) - nSplitHeight -= aHScrollLeft.GetSizePixel().Height(); + nSplitHeight -= aHScrollLeft->GetSizePixel().Height(); else if ( bTabControl && pTabControl ) nSplitHeight -= pTabControl->GetSizePixel().Height(); } @@ -623,7 +623,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) { long nSplitWidth = rSize.Width(); if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && bVScroll ) - nSplitWidth -= aVScrollBottom.GetSizePixel().Width(); + nSplitWidth -= aVScrollBottom->GetSizePixel().Width(); nSplitPosY = aViewData.GetVSplitPos(); lcl_SetPosSize( *pVSplitter, Point( nOutPosX, nSplitPosY ), Size( nSplitWidth, nSplitSizeY ), nTotalWidth, bLayoutRTL ); @@ -672,11 +672,11 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) } if (bHOutline && bVOutline) { - lcl_SetPosSize( aTopButton, Point(nOutPosX,nOutPosY), Size(nOutlineX,nOutlineY), nTotalWidth, bLayoutRTL ); - aTopButton.Show(); + lcl_SetPosSize( *aTopButton.get(), Point(nOutPosX,nOutPosY), Size(nOutlineX,nOutlineY), nTotalWidth, bLayoutRTL ); + aTopButton->Show(); } else - aTopButton.Hide(); + aTopButton->Hide(); if (bHeaders) // Spalten/Zeilen-Header { @@ -692,14 +692,14 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) lcl_SetPosSize( *pRowBar[SC_SPLIT_BOTTOM], Point(nPosX-nBarX,nSplitPosY), Size(nBarX,nBottomSize), nTotalWidth, bLayoutRTL ); - lcl_SetPosSize( aCornerButton, Point(nPosX-nBarX,nPosY-nBarY), Size(nBarX,nBarY), nTotalWidth, bLayoutRTL ); - aCornerButton.Show(); + lcl_SetPosSize( *aCornerButton.get(), Point(nPosX-nBarX,nPosY-nBarY), Size(nBarX,nBarY), nTotalWidth, bLayoutRTL ); + aCornerButton->Show(); pColBar[SC_SPLIT_LEFT]->Show(); pRowBar[SC_SPLIT_BOTTOM]->Show(); } else { - aCornerButton.Hide(); + aCornerButton->Hide(); pColBar[SC_SPLIT_LEFT]->Hide(); // immer da pRowBar[SC_SPLIT_BOTTOM]->Hide(); } @@ -822,8 +822,8 @@ void ScTabView::GetBorderSize( SvBorder& rBorder, const Size& /* rSize */ ) if (bScrollBars) // Scrollbars horizontal oder vertikal { - rBorder.Right() += aVScrollBottom.GetSizePixel().Width(); - rBorder.Bottom() += aHScrollLeft.GetSizePixel().Height(); + rBorder.Right() += aVScrollBottom->GetSizePixel().Width(); + rBorder.Bottom() += aHScrollLeft->GetSizePixel().Height(); } // Outline-Controls @@ -1015,8 +1015,8 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) { ScHSplitPos eHPos = WhichH(ePos); ScVSplitPos eVPos = WhichV(ePos); - ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? &aHScrollLeft : &aHScrollRight; - ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? &aVScrollTop : &aVScrollBottom; + ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? aHScrollLeft.get() : aHScrollRight.get(); + ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? aVScrollTop.get() : aVScrollBottom.get(); if ( pGridWin[ePos] ) bDone = pGridWin[ePos]->HandleScrollCommand( rCEvt, pHScroll, pVScroll ); } @@ -1035,13 +1035,13 @@ IMPL_LINK_NOARG(ScTabView, EndScrollHdl) IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) { - bool bHoriz = ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight ); + bool bHoriz = ( pScroll == aHScrollLeft.get() || pScroll == aHScrollRight.get() ); long nViewPos; if ( bHoriz ) - nViewPos = aViewData.GetPosX( (pScroll == &aHScrollLeft) ? + nViewPos = aViewData.GetPosX( (pScroll == aHScrollLeft.get()) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT ); else - nViewPos = aViewData.GetPosY( (pScroll == &aVScrollTop) ? + nViewPos = aViewData.GetPosY( (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ); bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() ); @@ -1078,9 +1078,9 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) // get scrollbar scroll position for help text (row number/column name) long nScrollMin = 0; // RangeMin simulieren - if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight ) + if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == aHScrollRight.get() ) nScrollMin = aViewData.GetFixPosX(); - if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom ) + if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == aVScrollBottom.get() ) nScrollMin = aViewData.GetFixPosY(); long nScrollPos = GetScrollBarPos( *pScroll ) + nScrollMin; @@ -1123,17 +1123,17 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) nDelta = 1; break; case SCROLL_PAGEUP: - if ( pScroll == &aHScrollLeft ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT ); - if ( pScroll == &aHScrollRight ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT ); - if ( pScroll == &aVScrollTop ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP ); - if ( pScroll == &aVScrollBottom ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM ); + if ( pScroll == aHScrollLeft.get() ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT ); + if ( pScroll == aHScrollRight.get() ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT ); + if ( pScroll == aVScrollTop.get() ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP ); + if ( pScroll == aVScrollBottom.get() ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM ); if (nDelta==0) nDelta=-1; break; case SCROLL_PAGEDOWN: - if ( pScroll == &aHScrollLeft ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_LEFT ); - if ( pScroll == &aHScrollRight ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_RIGHT ); - if ( pScroll == &aVScrollTop ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_TOP ); - if ( pScroll == &aVScrollBottom ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); + if ( pScroll == aHScrollLeft.get() ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_LEFT ); + if ( pScroll == aHScrollRight.get() ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_RIGHT ); + if ( pScroll == aVScrollTop.get() ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_TOP ); + if ( pScroll == aVScrollBottom.get() ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); if (nDelta==0) nDelta=1; break; case SCROLL_DRAG: @@ -1142,9 +1142,9 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) // Bereiche herumzittern long nScrollMin = 0; // RangeMin simulieren - if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight ) + if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == aHScrollRight.get() ) nScrollMin = aViewData.GetFixPosX(); - if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom ) + if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == aVScrollBottom.get() ) nScrollMin = aViewData.GetFixPosY(); long nScrollPos = GetScrollBarPos( *pScroll ) + nScrollMin; @@ -1172,9 +1172,9 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) { bool bUpdate = ( eType != SCROLL_DRAG ); // bei Drag die Ranges nicht aendern if ( bHoriz ) - ScrollX( nDelta, (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate ); + ScrollX( nDelta, (pScroll == aHScrollLeft.get()) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate ); else - ScrollY( nDelta, (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate ); + ScrollY( nDelta, (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate ); } return 0; @@ -1433,7 +1433,7 @@ void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const SCROW* pPosY RepeatResize(); // auf VCL gibt's Update ohne Ende (jedes Update gilt fuer alle Fenster) - //aCornerButton.Update(); // der bekommt sonst nie ein Update + //aCornerButton->Update(); // der bekommt sonst nie ein Update bInUpdateHeader = false; } @@ -1466,44 +1466,44 @@ void ScTabView::UpdateShow() if (bShowH && !pGridWin[SC_SPLIT_BOTTOMRIGHT]) { - pGridWin[SC_SPLIT_BOTTOMRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMRIGHT ); + pGridWin[SC_SPLIT_BOTTOMRIGHT] = VclPtr<ScGridWindow>::Create( pFrameWin, &aViewData, SC_SPLIT_BOTTOMRIGHT ); DoAddWin( pGridWin[SC_SPLIT_BOTTOMRIGHT] ); } if (bShowV && !pGridWin[SC_SPLIT_TOPLEFT]) { - pGridWin[SC_SPLIT_TOPLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPLEFT ); + pGridWin[SC_SPLIT_TOPLEFT] = VclPtr<ScGridWindow>::Create( pFrameWin, &aViewData, SC_SPLIT_TOPLEFT ); DoAddWin( pGridWin[SC_SPLIT_TOPLEFT] ); } if (bShowH && bShowV && !pGridWin[SC_SPLIT_TOPRIGHT]) { - pGridWin[SC_SPLIT_TOPRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPRIGHT ); + pGridWin[SC_SPLIT_TOPRIGHT] = VclPtr<ScGridWindow>::Create( pFrameWin, &aViewData, SC_SPLIT_TOPRIGHT ); DoAddWin( pGridWin[SC_SPLIT_TOPRIGHT] ); } if (bHOutline && !pColOutline[SC_SPLIT_LEFT]) - pColOutline[SC_SPLIT_LEFT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMLEFT ); + pColOutline[SC_SPLIT_LEFT] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMLEFT ); if (bShowH && bHOutline && !pColOutline[SC_SPLIT_RIGHT]) - pColOutline[SC_SPLIT_RIGHT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMRIGHT ); + pColOutline[SC_SPLIT_RIGHT] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMRIGHT ); if (bVOutline && !pRowOutline[SC_SPLIT_BOTTOM]) - pRowOutline[SC_SPLIT_BOTTOM] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_BOTTOMLEFT ); + pRowOutline[SC_SPLIT_BOTTOM] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_BOTTOMLEFT ); if (bShowV && bVOutline && !pRowOutline[SC_SPLIT_TOP]) - pRowOutline[SC_SPLIT_TOP] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT ); + pRowOutline[SC_SPLIT_TOP] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT ); if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT]) - pColBar[SC_SPLIT_RIGHT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_RIGHT, + pColBar[SC_SPLIT_RIGHT] = VclPtr<ScColBar>::Create( pFrameWin, &aViewData, SC_SPLIT_RIGHT, &aHdrFunc, pHdrSelEng ); if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP]) - pRowBar[SC_SPLIT_TOP] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_TOP, + pRowBar[SC_SPLIT_TOP] = VclPtr<ScRowBar>::Create( pFrameWin, &aViewData, SC_SPLIT_TOP, &aHdrFunc, pHdrSelEng ); // Windows anzeigen - ShowHide( &aHScrollLeft, bHScrollMode ); - ShowHide( &aHScrollRight, bShowH && bHScrollMode ); - ShowHide( &aVScrollBottom, bVScrollMode ); - ShowHide( &aVScrollTop, bShowV && bVScrollMode ); - ShowHide( &aScrollBarBox, bVScrollMode || bHScrollMode ); + ShowHide( aHScrollLeft.get(), bHScrollMode ); + ShowHide( aHScrollRight.get(), bShowH && bHScrollMode ); + ShowHide( aVScrollBottom.get(), bVScrollMode ); + ShowHide( aVScrollTop.get(), bShowV && bVScrollMode ); + ShowHide( aScrollBarBox.get(), bVScrollMode || bHScrollMode ); ShowHide( pHSplitter, bHScrollMode || bShowH ); // immer angelegt ShowHide( pVSplitter, bVScrollMode || bShowV ); @@ -2221,27 +2221,27 @@ void ScTabView::StartDataSelect() void ScTabView::EnableRefInput(bool bFlag) { - aHScrollLeft.EnableInput(bFlag); - aHScrollRight.EnableInput(bFlag); - aVScrollBottom.EnableInput(bFlag); - aVScrollTop.EnableInput(bFlag); - aScrollBarBox.EnableInput(bFlag); + aHScrollLeft->EnableInput(bFlag); + aHScrollRight->EnableInput(bFlag); + aVScrollBottom->EnableInput(bFlag); + aVScrollTop->EnableInput(bFlag); + aScrollBarBox->EnableInput(bFlag); // ab hier dynamisch angelegte - if(pTabControl!=NULL) pTabControl->EnableInput(bFlag,true); + if(pTabControl!=nullptr) pTabControl->EnableInput(bFlag,true); - if(pGridWin[SC_SPLIT_BOTTOMLEFT]!=NULL) + if(pGridWin[SC_SPLIT_BOTTOMLEFT]!=nullptr) pGridWin[SC_SPLIT_BOTTOMLEFT]->EnableInput(bFlag,false); - if(pGridWin[SC_SPLIT_BOTTOMRIGHT]!=NULL) + if(pGridWin[SC_SPLIT_BOTTOMRIGHT]!=nullptr) pGridWin[SC_SPLIT_BOTTOMRIGHT]->EnableInput(bFlag,false); - if(pGridWin[SC_SPLIT_TOPLEFT]!=NULL) + if(pGridWin[SC_SPLIT_TOPLEFT]!=nullptr) pGridWin[SC_SPLIT_TOPLEFT]->EnableInput(bFlag,false); - if(pGridWin[SC_SPLIT_TOPRIGHT]!=NULL) + if(pGridWin[SC_SPLIT_TOPRIGHT]!=nullptr) pGridWin[SC_SPLIT_TOPRIGHT]->EnableInput(bFlag,false); - if(pColBar[SC_SPLIT_RIGHT]!=NULL) + if(pColBar[SC_SPLIT_RIGHT]!=nullptr) pColBar[SC_SPLIT_RIGHT]->EnableInput(bFlag,false); - if(pRowBar[SC_SPLIT_TOP]!=NULL) + if(pRowBar[SC_SPLIT_TOP]!=nullptr) pRowBar[SC_SPLIT_TOP]->EnableInput(bFlag,false); } diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 9e7d4d0b2809..6d355f70af20 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -1423,8 +1423,8 @@ void ScTabView::ErrorMessage( sal_uInt16 nGlobStrId ) } } - InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) ); - aBox.Execute(); + ScopedVclPtrInstance< InfoBox > aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) ); + aBox->Execute(); if (bFocus) pParent->GrabFocus(); } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index b0db92dc355b..ecc9e2b81624 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -623,7 +623,7 @@ void ScTabView::TestHintWindow() aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() ) { // HintWindow anlegen, bestimmt seine Groesse selbst - mpInputHintWindow.reset(new ScHintWindow(pWin, aTitle, aMessage)); + mpInputHintWindow.reset(VclPtr<ScHintWindow>::Create(pWin, aTitle, aMessage)); Size aHintWndSize = mpInputHintWindow->GetSizePixel(); long nCellSizeX = 0; long nCellSizeY = 0; diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index fba9ede166a2..8d21f9cd66bc 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -382,41 +382,41 @@ void ScTabView::UpdateScrollBars() nVisXL = aViewData.VisibleCellsX( SC_SPLIT_LEFT ); long nMaxXL = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_LEFT), nVisXL, MAXCOL, 0 ); - SetScrollBar( aHScrollLeft, nMaxXL, nVisXL, aViewData.GetPosX( SC_SPLIT_LEFT ), bLayoutRTL ); + SetScrollBar( *aHScrollLeft.get(), nMaxXL, nVisXL, aViewData.GetPosX( SC_SPLIT_LEFT ), bLayoutRTL ); nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); long nMaxYB = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, MAXROW, nStartY ); - SetScrollBar( aVScrollBottom, nMaxYB, nVisYB, aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY, bLayoutRTL ); + SetScrollBar( *aVScrollBottom.get(), nMaxYB, nVisYB, aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY, bLayoutRTL ); if (bRight) { nVisXR = aViewData.VisibleCellsX( SC_SPLIT_RIGHT ); long nMaxXR = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_RIGHT), nVisXR, MAXCOL, nStartX ); - SetScrollBar( aHScrollRight, nMaxXR, nVisXR, aViewData.GetPosX( SC_SPLIT_RIGHT ) - nStartX, bLayoutRTL ); + SetScrollBar( *aHScrollRight.get(), nMaxXR, nVisXR, aViewData.GetPosX( SC_SPLIT_RIGHT ) - nStartX, bLayoutRTL ); } if (bTop) { nVisYT = aViewData.VisibleCellsY( SC_SPLIT_TOP ); long nMaxYT = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_TOP), nVisYT, MAXROW, 0 ); - SetScrollBar( aVScrollTop, nMaxYT, nVisYT, aViewData.GetPosY( SC_SPLIT_TOP ), bLayoutRTL ); + SetScrollBar( *aVScrollTop.get(), nMaxYT, nVisYT, aViewData.GetPosY( SC_SPLIT_TOP ), bLayoutRTL ); } // Bereich testen - nDiff = lcl_UpdateBar( aHScrollLeft, nVisXL ); + nDiff = lcl_UpdateBar( *aHScrollLeft.get(), nVisXL ); if (nDiff) ScrollX( nDiff, SC_SPLIT_LEFT ); if (bRight) { - nDiff = lcl_UpdateBar( aHScrollRight, nVisXR ); + nDiff = lcl_UpdateBar( *aHScrollRight.get(), nVisXR ); if (nDiff) ScrollX( nDiff, SC_SPLIT_RIGHT ); } - nDiff = lcl_UpdateBar( aVScrollBottom, nVisYB ); + nDiff = lcl_UpdateBar( *aVScrollBottom.get(), nVisYB ); if (nDiff) ScrollY( nDiff, SC_SPLIT_BOTTOM ); if (bTop) { - nDiff = lcl_UpdateBar( aVScrollTop, nVisYT ); + nDiff = lcl_UpdateBar( *aVScrollTop.get(), nVisYT ); if (nDiff) ScrollY( nDiff, SC_SPLIT_TOP ); } diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 033fae392d3c..07262e175ce4 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -74,7 +74,7 @@ void ScTabView::Init() for (i=0; i<4; i++) pGridWin[i] = NULL; - pGridWin[SC_SPLIT_BOTTOMLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMLEFT ); + pGridWin[SC_SPLIT_BOTTOMLEFT] = VclPtr<ScGridWindow>::Create( pFrameWin, &aViewData, SC_SPLIT_BOTTOMLEFT ); pSelEngine = new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this, SC_SPLIT_BOTTOMLEFT ); @@ -82,23 +82,23 @@ void ScTabView::Init() pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc ); - pColBar[SC_SPLIT_LEFT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_LEFT, + pColBar[SC_SPLIT_LEFT] = VclPtr<ScColBar>::Create( pFrameWin, &aViewData, SC_SPLIT_LEFT, &aHdrFunc, pHdrSelEng ); pColBar[SC_SPLIT_RIGHT] = NULL; - pRowBar[SC_SPLIT_BOTTOM] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_BOTTOM, + pRowBar[SC_SPLIT_BOTTOM] = VclPtr<ScRowBar>::Create( pFrameWin, &aViewData, SC_SPLIT_BOTTOM, &aHdrFunc, pHdrSelEng ); pRowBar[SC_SPLIT_TOP] = NULL; for (i=0; i<2; i++) pColOutline[i] = pRowOutline[i] = NULL; - pHSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_HSCROLL ), &aViewData ); - pVSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_VSCROLL ), &aViewData ); + pHSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_HSCROLL ), &aViewData ); + pVSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_VSCROLL ), &aViewData ); // SSA: override default keyboard step size to allow snap to row/column pHSplitter->SetKeyboardStepSize( 1 ); pVSplitter->SetKeyboardStepSize( 1 ); - pTabControl = new ScTabControl(pFrameWin, &aViewData); + pTabControl = VclPtr<ScTabControl>::Create(pFrameWin, &aViewData); if (mbInlineWithScrollbar) pTabControl->SetStyle(pTabControl->GetStyle() | WB_SIZEABLE); @@ -108,10 +108,10 @@ void ScTabView::Init() explicitly because the parent frame window is already RTL disabled. */ pTabControl->EnableRTL( AllSettings::GetLayoutRTL() ); - InitScrollBar( aHScrollLeft, MAXCOL+1 ); - InitScrollBar( aHScrollRight, MAXCOL+1 ); - InitScrollBar( aVScrollTop, MAXROW+1 ); - InitScrollBar( aVScrollBottom, MAXROW+1 ); + InitScrollBar( *aHScrollLeft.get(), MAXCOL+1 ); + InitScrollBar( *aHScrollRight.get(), MAXCOL+1 ); + InitScrollBar( *aVScrollTop.get(), MAXROW+1 ); + InitScrollBar( *aVScrollBottom.get(), MAXROW+1 ); /* #i97900# scrollbars remain in correct RTL mode, needed mirroring etc. is now handled correctly at the respective places. */ @@ -176,24 +176,31 @@ ScTabView::~ScTabView() delete pSelEngine; // Delete this before the grid windows, since it's a child window of one of them. - mpInputHintWindow.reset(); + mpInputHintWindow.disposeAndClear(); for (i=0; i<4; i++) - delete pGridWin[i]; + pGridWin[i].disposeAndClear(); delete pHdrSelEng; for (i=0; i<2; i++) { - delete pColBar[i]; - delete pRowBar[i]; - delete pColOutline[i]; - delete pRowOutline[i]; + pColBar[i].disposeAndClear(); + pRowBar[i].disposeAndClear(); + pColOutline[i].disposeAndClear(); + pRowOutline[i].disposeAndClear(); } - delete pHSplitter; - delete pVSplitter; - - delete pTabControl; + aScrollBarBox.disposeAndClear(); + aCornerButton.disposeAndClear(); + aTopButton.disposeAndClear(); + aHScrollLeft.disposeAndClear(); + aHScrollRight.disposeAndClear(); + aVScrollTop.disposeAndClear(); + aVScrollBottom.disposeAndClear(); + + pHSplitter.disposeAndClear(); + pVSplitter.disposeAndClear(); + pTabControl.disposeAndClear(); } void ScTabView::MakeDrawView( TriState nForceDesignMode ) diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index e4f1b71d91ff..d4d3068818d1 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -975,7 +975,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { OUString aText(ScResId(SCSTR_PASSWORD)); - boost::scoped_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText)); + VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); pDlg->SetText( ScResId(SCSTR_UNPROTECTDOC) ); pDlg->SetMinLen( 0 ); pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() ); @@ -997,7 +997,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { OUString aText(ScResId(SCSTR_PASSWORDOPT)); - boost::scoped_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText)); + VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); pDlg->SetText( ScResId(SCSTR_PROTECTDOC) ); pDlg->SetMinLen( 0 ); pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() ); @@ -1043,7 +1043,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) if (pProtect && pProtect->isProtectedWithPass()) { OUString aText( ScResId(SCSTR_PASSWORDOPT) ); - boost::scoped_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText)); + VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) ); pDlg->SetMinLen( 0 ); pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand() ); @@ -1069,7 +1069,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { // Protect a current sheet. - boost::scoped_ptr<ScTableProtectionDlg> pDlg(new ScTableProtectionDlg(GetDialogParent())); + VclPtrInstance< ScTableProtectionDlg > pDlg(GetDialogParent()); ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); if (pProtect) diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 429314fd7a2e..71661bf301bb 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1063,14 +1063,15 @@ bool ScTabViewShell::HasPrintOptionsPage() const return true; } -SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions ) +VclPtr<SfxTabPage> ScTabViewShell::CreatePrintOptionsPage( vcl::Window *pParent, const SfxItemSet &rOptions ) { ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT ); if ( ScTpPrintOptionsCreate ) - return (*ScTpPrintOptionsCreate)( pParent, &rOptions); - return 0; + return VclPtr<SfxTabPage>((*ScTpPrintOptionsCreate)( pParent, &rOptions), + SAL_NO_ACQUIRE); + return VclPtr<SfxTabPage>(); } void ScTabViewShell::StopEditShell() diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 3108c34a9774..fbbfa248d74e 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -145,14 +145,14 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { if (!mbInSwitch) { - pResult = new ScNameDlg( pB, pCW, pParent, &GetViewData(), + pResult = VclPtr<ScNameDlg>::Create( pB, pCW, pParent, &GetViewData(), ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ) ); } else { - pResult = new ScNameDlg( pB, pCW, pParent, &GetViewData(), + pResult = VclPtr<ScNameDlg>::Create( pB, pCW, pParent, &GetViewData(), ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ), &maRangeMap); @@ -168,7 +168,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { std::map<OUString, ScRangeName*> aRangeMap; pDoc->GetRangeNameMap(aRangeMap); - pResult = new ScNameDefDlg( pB, pCW, pParent, &GetViewData(), aRangeMap, + pResult = VclPtr<ScNameDefDlg>::Create( pB, pCW, pParent, &GetViewData(), aRangeMap, ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ), true ); @@ -181,7 +181,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr->first, itr->second)); } - pResult = new ScNameDefDlg( pB, pCW, pParent, &GetViewData(), aRangeMap, + pResult = VclPtr<ScNameDefDlg>::Create( pB, pCW, pParent, &GetViewData(), aRangeMap, ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() ), false ); @@ -191,7 +191,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( case SID_DEFINE_COLROWNAMERANGES: { - pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScColRowNameRangesDlg>::Create( pB, pCW, pParent, &GetViewData() ); } break; @@ -229,7 +229,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) ); } - pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet ); + pResult = VclPtr<ScConsolidateDlg>::Create( pB, pCW, pParent, aArgSet ); } break; @@ -241,7 +241,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) MarkDataArea( false ); - pResult = new ScDbNameDlg( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScDbNameDlg>::Create( pB, pCW, pParent, &GetViewData() ); } break; @@ -270,7 +270,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( // aktuelle Tabelle merken (wg. RefInput im Dialog) GetViewData().SetRefTabNo( GetViewData().GetTabNo() ); - pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet ); + pResult = VclPtr<ScSpecialFilterDlg>::Create( pB, pCW, pParent, aArgSet ); } break; @@ -297,7 +297,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( // aktuelle Tabelle merken (wg. RefInput im Dialog) GetViewData().SetRefTabNo( GetViewData().GetTabNo() ); - pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet ); + pResult = VclPtr<ScFilterDlg>::Create( pB, pCW, pParent, aArgSet ); } break; @@ -309,7 +309,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( rViewData.GetTabNo(), false, false, false ); - pResult = new ScTabOpDlg( pB, pCW, pParent, rViewData.GetDocument(), aCurPos ); + pResult = VclPtr<ScTabOpDlg>::Create( pB, pCW, pParent, rViewData.GetDocument(), aCurPos ); } break; @@ -319,79 +319,79 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( ScAddress aCurPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo()); - pResult = new ScSolverDlg( pB, pCW, pParent, rViewData.GetDocument(), aCurPos ); + pResult = VclPtr<ScSolverDlg>::Create( pB, pCW, pParent, rViewData.GetDocument(), aCurPos ); } break; case SID_RANDOM_NUMBER_GENERATOR_DIALOG: { - pResult = new ScRandomNumberGeneratorDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScRandomNumberGeneratorDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_SAMPLING_DIALOG: { - pResult = new ScSamplingDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScSamplingDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_DESCRIPTIVE_STATISTICS_DIALOG: { - pResult = new ScDescriptiveStatisticsDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScDescriptiveStatisticsDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_ANALYSIS_OF_VARIANCE_DIALOG: { - pResult = new ScAnalysisOfVarianceDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScAnalysisOfVarianceDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_CORRELATION_DIALOG: { - pResult = new ScCorrelationDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScCorrelationDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_COVARIANCE_DIALOG: { - pResult = new ScCovarianceDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScCovarianceDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_EXPONENTIAL_SMOOTHING_DIALOG: { - pResult = new ScExponentialSmoothingDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScExponentialSmoothingDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_MOVING_AVERAGE_DIALOG: { - pResult = new ScMovingAverageDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScMovingAverageDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_TTEST_DIALOG: { - pResult = new ScTTestDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScTTestDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_FTEST_DIALOG: { - pResult = new ScFTestDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScFTestDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_ZTEST_DIALOG: { - pResult = new ScZTestDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScZTestDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; case SID_CHI_SQUARE_TEST_DIALOG: { - pResult = new ScChiSquareTestDialog( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScChiSquareTestDialog>::Create( pB, pCW, pParent, &GetViewData() ); } break; @@ -399,7 +399,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { ScViewData& rViewData = GetViewData(); ScAddress aCurPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo()); - pResult = new ScOptSolverDlg( pB, pCW, pParent, rViewData.GetDocShell(), aCurPos ); + pResult = VclPtr<ScOptSolverDlg>::Create( pB, pCW, pParent, rViewData.GetDocShell(), aCurPos ); } break; @@ -413,14 +413,14 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( ScViewData& rViewData = GetViewData(); rViewData.SetRefTabNo( rViewData.GetTabNo() ); ScDPObject* pObj = pDoc->GetDPAtCursor(rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo()); - pResult = new ScPivotLayoutDialog(pB, pCW, pParent, &rViewData, pDialogDPObject, pObj == NULL); + pResult = VclPtr<ScPivotLayoutDialog>::Create(pB, pCW, pParent, &rViewData, pDialogDPObject, pObj == nullptr); } } break; case SID_OPENDLG_EDIT_PRINTAREA: { - pResult = new ScPrintAreasDlg( pB, pCW, pParent ); + pResult = VclPtr<ScPrintAreasDlg>::Create( pB, pCW, pParent ); } break; @@ -428,14 +428,14 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { // Dialog schaut selber, was in der Zelle steht - pResult = new ScFormulaDlg( pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr() ); + pResult = VclPtr<ScFormulaDlg>::Create( pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr() ); } break; case SID_MANAGE_XML_SOURCE: { #if ENABLE_ORCUS - pResult = new ScXMLSourceDlg(pB, pCW, pParent, pDoc); + pResult = VclPtr<ScXMLSourceDlg>::Create(pB, pCW, pParent, pDoc); #endif } break; @@ -444,7 +444,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( { // Dialog schaut selber, was in der Zelle steht - pResult = new ScHighlightChgDlg( pB, pCW, pParent, &GetViewData() ); + pResult = VclPtr<ScHighlightChgDlg>::Create( pB, pCW, pParent, &GetViewData() ); } break; @@ -454,7 +454,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( ScViewData& rViewData = GetViewData(); rViewData.SetRefTabNo( rViewData.GetTabNo() ); - pResult = new ScSimpleRefDlg( pB, pCW, pParent ); + pResult = VclPtr<ScSimpleRefDlg>::Create( pB, pCW, pParent ); } break; diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx index c5264dd1da70..17dbaa8d2831 100644 --- a/sc/source/ui/view/tabvwshh.cxx +++ b/sc/source/ui/view/tabvwshh.cxx @@ -263,7 +263,7 @@ bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash) { ScDocument* pDoc = GetViewData().GetDocument(); - boost::scoped_ptr<ScRetypePassDlg> pDlg(new ScRetypePassDlg(GetDialogParent())); + VclPtrInstance< ScRetypePassDlg > pDlg(GetDialogParent()); pDlg->SetDataFromDocument(*pDoc); pDlg->SetDesiredHash(eDesiredHash); if (pDlg->Execute() != RET_OK) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 7f303eaf9815..db445ce55c91 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1074,11 +1074,11 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bRecord, bool bC { if (!bApi) { - MessBox aBox( GetViewData().GetDialogParent(), + ScopedVclPtrInstance<MessBox> aBox( GetViewData().GetDialogParent(), WinBits(WB_YES_NO_CANCEL | WB_DEF_NO), ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) ); - sal_uInt16 nRetVal = aBox.Execute(); + sal_uInt16 nRetVal = aBox->Execute(); if ( nRetVal == RET_YES ) rDoContents = true; @@ -1771,10 +1771,10 @@ void ScViewFunc::Solve( const ScSolveParam& rParam ) aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_4 ); } - MessBox aBox( GetViewData().GetDialogParent(), + ScopedVclPtrInstance<MessBox> aBox( GetViewData().GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_NO), ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr ); - sal_uInt16 nRetVal = aBox.Execute(); + sal_uInt16 nRetVal = aBox->Execute(); if ( RET_YES == nRetVal ) EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult ); diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 992e480dd22e..f1dd83099799 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -832,8 +832,8 @@ bool checkDestRangeForOverwrite(const ScRangeList& rDestRanges, const ScDocument if (!bIsEmpty) { - ScReplaceWarnBox aBox(pParentWnd); - if (aBox.Execute() != RET_YES) + ScopedVclPtrInstance< ScReplaceWarnBox > aBox(pParentWnd); + if (aBox->Execute() != RET_YES) { // changing the configuration is within the ScReplaceWarnBox return false; @@ -1041,9 +1041,9 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, { ScWaitCursorOff aWaitOff( GetFrameWin() ); OUString aMessage = ScGlobal::GetRscString( STR_PASTE_BIGGER ); - QueryBox aBox( GetViewData().GetDialogParent(), + ScopedVclPtrInstance<QueryBox> aBox( GetViewData().GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_NO), aMessage ); - if ( aBox.Execute() != RET_YES ) + if ( aBox->Execute() != RET_YES ) { return false; } @@ -1910,7 +1910,7 @@ bool ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, b void ScViewFunc::DataFormPutData( SCROW nCurrentRow , SCROW nStartRow , SCCOL nStartCol , SCROW nEndRow , SCCOL nEndCol , - boost::ptr_vector<boost::nullable<Edit> >& aEdits, + std::vector<VclPtr<Edit> >& aEdits, sal_uInt16 aColLength ) { ScDocument* pDoc = GetViewData().GetDocument(); @@ -1952,9 +1952,9 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow , for(sal_uInt16 i = 0; i < aColLength; i++) { - if (!aEdits.is_null(i)) + if (aEdits[i] != nullptr) { - OUString aFieldName=aEdits[i].GetText(); + OUString aFieldName=aEdits[i]->GetText(); pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName ); } } diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index 0317fa4d7201..0ccf18bd5b2b 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -99,8 +99,8 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow, if (pActWin) { pEngine->SetPaperSize(Size(100000,100000)); - vcl::Window aWin( pActWin ); - EditView aEditView( pEngine.get(), &aWin ); + VclPtrInstance< vcl::Window > aWin( pActWin ); + EditView aEditView( pEngine.get(), aWin.get() ); aEditView.SetOutputArea(Rectangle(0,0,100000,100000)); // same method now for clipboard or drag&drop @@ -387,8 +387,8 @@ void ScViewFunc::DoThesaurus( bool bRecord ) LanguageType eLnge = ScViewUtil::GetEffLanguage( &rDoc, ScAddress( nCol, nRow, nTab ) ); OUString aErr = SvtLanguageTable::GetLanguageString(eLnge); aErr += ScGlobal::GetRscString( STR_SPELLING_NO_LANG ); - InfoBox aBox( GetViewData().GetDialogParent(), aErr ); - aBox.Execute(); + ScopedVclPtrInstance< InfoBox > aBox( GetViewData().GetDialogParent(), aErr ); + aBox->Execute(); } if (pThesaurusEngine->IsModified()) { diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 92ddab74a3b1..d2c9d38ab3a3 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1403,9 +1403,9 @@ void ScViewFunc::RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ) ScDocShellModificator aModificator( *pDocSh ); - VirtualDevice aVirtDev; - aVirtDev.SetMapMode(MAP_PIXEL); - pDoc->StyleSheetChanged( pStyleSheet, true, &aVirtDev, + ScopedVclPtrInstance< VirtualDevice > pVirtDev; + pVirtDev->SetMapMode(MAP_PIXEL); + pDoc->StyleSheetChanged( pStyleSheet, true, pVirtDev, rViewData.GetPPTX(), rViewData.GetPPTY(), rViewData.GetZoomX(), @@ -1429,9 +1429,9 @@ void ScViewFunc::UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet ) ScDocShellModificator aModificator( *pDocSh ); - VirtualDevice aVirtDev; - aVirtDev.SetMapMode(MAP_PIXEL); - pDoc->StyleSheetChanged( pStyleSheet, false, &aVirtDev, + ScopedVclPtrInstance< VirtualDevice > pVirtDev; + pVirtDev->SetMapMode(MAP_PIXEL); + pDoc->StyleSheetChanged( pStyleSheet, false, pVirtDev, rViewData.GetPPTX(), rViewData.GetPPTY(), rViewData.GetZoomX(), |