diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-25 16:23:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-29 06:45:42 +0000 |
commit | e6ffb539ee232ea0c679928ff456c1cf97429f63 (patch) | |
tree | e4b71a9bd49edba1a0f1c95f60f6da81433d1983 | |
parent | tdf#103975 docx import: don't lose column break (diff) | |
download | core-e6ffb539ee232ea0c679928ff456c1cf97429f63.tar.gz core-e6ffb539ee232ea0c679928ff456c1cf97429f63.zip |
loplugin:vclwidgets check for assigning from VclPt<T> to T*
Inspired by a recent bug report where we were assigning the result
of VclPtr<T>::Create to a raw pointer.
As a consequence, we also need to change various methods that were
returning newly created Window subclasses via raw pointer, to
instead return those via VclPtr
Change-Id: I8118e0195a5b2b4780e646cfb0e151692e54ae2b
Reviewed-on: https://gerrit.libreoffice.org/31318
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
97 files changed, 374 insertions, 280 deletions
diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx index 05e16b6e3d17..ade2d1b2960d 100644 --- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx +++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx @@ -176,7 +176,7 @@ vcl::Window* AccessibleDialogControlShape::GetWindow() const { Reference< awt::XControl > xControl( m_pDlgEdObj->GetControl(), UNO_QUERY ); if ( xControl.is() ) - pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() ); + pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() ).get(); } return pWindow; diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 417a987223d8..762b90b43b0a 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -309,9 +309,8 @@ void Shell::onDocumentClosed( const ScriptDocument& _rDocument ) } } // delete windows outside main loop so we don't invalidate the original iterator - for (auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it) + for (VclPtr<BaseWindow> const & pWin : aDeleteVec) { - BaseWindow* pWin = *it; pWin->StoreData(); if ( pWin == pCurWin ) bSetCurWindow = true; @@ -436,7 +435,7 @@ void Shell::OuterResizePixel( const Point &rPos, const Size &rSize ) IMPL_LINK( Shell, TabBarHdl, ::TabBar *, pCurTabBar, void ) { sal_uInt16 nCurId = pCurTabBar->GetCurPageId(); - BaseWindow* pWin = aWindowTable[ nCurId ]; + BaseWindow* pWin = aWindowTable[ nCurId ].get(); DBG_ASSERT( pWin, "Eintrag in TabBar passt zu keinem Fenster!" ); SetCurWindow( pWin ); } @@ -555,9 +554,8 @@ void Shell::CheckWindows() if ( pWin->GetStatus() & BASWIN_TOBEKILLED ) aDeleteVec.push_back( pWin ); } - for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( VclPtr<BaseWindow> const & pWin : aDeleteVec ) { - BaseWindow* pWin = *it; pWin->StoreData(); if ( pWin == pCurWin ) bSetCurWindow = true; @@ -578,9 +576,8 @@ void Shell::RemoveWindows( const ScriptDocument& rDocument, const OUString& rLib if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName ) aDeleteVec.push_back( pWin ); } - for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( VclPtr<BaseWindow> const & pWin : aDeleteVec ) { - BaseWindow* pWin = *it; if ( pWin == pCurWin ) bChangeCurWindow = true; pWin->StoreData(); @@ -733,7 +730,7 @@ void Shell::UpdateWindows() { if ( !pNextActiveWindow ) { - pNextActiveWindow = FindApplicationWindow(); + pNextActiveWindow = FindApplicationWindow().get(); } SetCurWindow( pNextActiveWindow, true ); } diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 11f834212b5e..c186b8fe8434 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -585,7 +585,7 @@ void TabBar::Sort() sal_uInt16 nId = GetPageId( i ); aTabBarSortHelper.nPageId = nId; aTabBarSortHelper.aPageText = GetPageText( nId ); - BaseWindow* pWin = aWindowTable[ nId ]; + BaseWindow* pWin = aWindowTable[ nId ].get(); if (dynamic_cast<ModulWindow*>(pWin)) { diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx index c1138a17e217..c800580f7af4 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx @@ -187,7 +187,7 @@ void CreationWizardUnoDlg::createDialogOnDemand() { VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParentWindow); if (pImplementation) - pParent = pImplementation->GetWindow(); + pParent = pImplementation->GetWindow().get(); } uno::Reference< XComponent > xComp( this ); if( m_xChartModel.is() ) diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index 40f2857859bb..3151d6c0acc0 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -396,7 +396,7 @@ IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, SvxLightCtl3 IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton, void ) { bool bIsAmbientLight = (pButton==m_pBtn_AmbientLight_Color); - SvxColorListBox* pListBox = ( bIsAmbientLight ? m_pLB_AmbientLight : m_pLB_LightSource); + SvxColorListBox* pListBox = bIsAmbientLight ? m_pLB_AmbientLight.get() : m_pLB_LightSource.get(); SvColorDialog aColorDlg( this ); aColorDlg.SetColor( pListBox->GetSelectEntryColor() ); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 5998cfd8343f..d40782f48920 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -460,7 +460,7 @@ void SAL_CALL ChartController::attachFrame( if (pParentComponent) pParentComponent->setVisible(true); - pParent = VCLUnoHelper::GetWindow( xContainerWindow ); + pParent = VCLUnoHelper::GetWindow( xContainerWindow ).get(); } if(m_pChartWindow) diff --git a/compilerplugins/clang/test/vclwidgets.cxx b/compilerplugins/clang/test/vclwidgets.cxx new file mode 100644 index 000000000000..c18c775c054a --- /dev/null +++ b/compilerplugins/clang/test/vclwidgets.cxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include <vcl/vclreferencebase.hxx> + +struct Widget : public VclReferenceBase +{ + VclPtr<Widget> mpParent; + + void widget1() // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} + { + // test that we ignore assignments from a member field + Widget* p = mpParent; + (void)p; + // test against false+ + p = true ? mpParent.get() : nullptr; + } + + ~Widget() override + { + disposeOnce(); + } + + void dispose() override + { + mpParent.clear(); + VclReferenceBase::dispose(); + } +}; + +VclPtr<Widget> f() +{ + return nullptr; +} + +Widget* g() +{ + return nullptr; +} + +// test the variable init detection +void bar() // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} +{ + Widget* p = f(); // expected-error {{assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you know that the RHS does not return a newly created T, then add a '.get()' to the RHS [loplugin:vclwidgets]}} + (void)p; + Widget* q = g(); + (void)q; + Widget* r = nullptr; + (void)r; +} + +// test the assignment detection +void bar2() // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} +{ + Widget* p; + p = nullptr; + p = f(); // expected-error {{assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you know that the RHS does not return a newly created T, then add a '.get()' to the RHS [loplugin:vclwidgets]}} + (void)p; + Widget* q; + q = g(); + (void)q; +} + + +// test against false+ + +template<class T> +T * get() { return nullptr; } + +void bar3() // expected-error {{Unreferenced externally visible function definition [loplugin:unreffun]}} +{ + Widget* p; + p = get<Widget>(); +} + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index d6007a65537b..b373d93cec98 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -46,7 +46,7 @@ public: bool VisitCXXConstructExpr(const CXXConstructExpr *); bool VisitBinaryOperator(const BinaryOperator *); private: - void checkAssignmentForVclPtrToRawConversion(const Type* lhsType, const Expr* rhs); + void checkAssignmentForVclPtrToRawConversion(const SourceLocation& sourceLoc, const Type* lhsType, const Expr* rhs); bool isDisposeCallingSuperclassDispose(const CXXMethodDecl* pMethodDecl); bool mbCheckingMemcpy = false; }; @@ -251,13 +251,15 @@ bool VCLWidgets::VisitBinaryOperator(const BinaryOperator * binaryOperator) if ( !binaryOperator->isAssignmentOp() ) { return true; } - checkAssignmentForVclPtrToRawConversion(binaryOperator->getLHS()->getType().getTypePtr(), binaryOperator->getRHS()); + SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( + binaryOperator->getLocStart()); + checkAssignmentForVclPtrToRawConversion(spellingLocation, binaryOperator->getLHS()->getType().getTypePtr(), binaryOperator->getRHS()); return true; } // Look for places where we are accidentally assigning a returned-by-value VclPtr<T> to a T*, which generally // ends up in a use-after-free. -void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const Type* lhsType, const Expr* rhs) +void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const SourceLocation& spellingLocation, const Type* lhsType, const Expr* rhs) { if (!lhsType || !isa<PointerType>(lhsType)) { return; @@ -265,32 +267,72 @@ void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const Type* lhsType, co if (!rhs) { return; } - // lots of null checking for something weird going in SW that tends to crash clang with: - // const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' - if (rhs->getType().getTypePtrOrNull()) { - if (const PointerType* pt = dyn_cast<PointerType>(rhs->getType())) { - const Type* pointeeType = pt->getPointeeType().getTypePtrOrNull(); - if (pointeeType && !isa<SubstTemplateTypeParmType>(pointeeType)) { - return; - } - } + StringRef filename = compiler.getSourceManager().getFilename(spellingLocation); + if (filename == SRCDIR "/include/rtl/ref.hxx") { + return; } const CXXRecordDecl* pointeeClass = lhsType->getPointeeType()->getAsCXXRecordDecl(); if (!isDerivedFromVclReferenceBase(pointeeClass)) { return; } - const ExprWithCleanups* exprWithCleanups = dyn_cast<ExprWithCleanups>(rhs); - if (!exprWithCleanups) { + + // if we have T* on the LHS and VclPtr<T> on the RHS, we expect to see either + // an ImplicitCastExpr + // or a ExprWithCleanups and then an ImplicitCastExpr + if (auto implicitCastExpr = dyn_cast<ImplicitCastExpr>(rhs)) { + if (implicitCastExpr->getCastKind() != CK_UserDefinedConversion) { + return; + } + rhs = rhs->IgnoreCasts(); + } else if (auto exprWithCleanups = dyn_cast<ExprWithCleanups>(rhs)) { + if (auto implicitCastExpr = dyn_cast<ImplicitCastExpr>(exprWithCleanups->getSubExpr())) { + if (implicitCastExpr->getCastKind() != CK_UserDefinedConversion) { + return; + } + rhs = exprWithCleanups->IgnoreCasts(); + } else { + return; + } + } else { + return; + } + if (isa<CXXNullPtrLiteralExpr>(rhs)) { return; } - const ImplicitCastExpr* implicitCast = dyn_cast<ImplicitCastExpr>(exprWithCleanups->getSubExpr()); - if (!implicitCast) { + if (isa<CXXThisExpr>(rhs)) { return; } - //rhs->getType().dump(); + + // ignore assignments from a member field to a local variable, to avoid unnecessary refcounting traffic + if (auto callExpr = dyn_cast<CXXMemberCallExpr>(rhs)) { + if (auto calleeMemberExpr = dyn_cast<MemberExpr>(callExpr->getCallee())) { + if ((calleeMemberExpr = dyn_cast<MemberExpr>(calleeMemberExpr->getBase()->IgnoreImpCasts()))) { + if (isa<FieldDecl>(calleeMemberExpr->getMemberDecl())) { + return; + } + } + } + } + + // ignore assignments from a local variable to a local variable, to avoid unnecessary refcounting traffic + if (auto callExpr = dyn_cast<CXXMemberCallExpr>(rhs)) { + if (auto calleeMemberExpr = dyn_cast<MemberExpr>(callExpr->getCallee())) { + if (auto declRefExpr = dyn_cast<DeclRefExpr>(calleeMemberExpr->getBase()->IgnoreImpCasts())) { + if (isa<VarDecl>(declRefExpr->getDecl())) { + return; + } + } + } + } + if (auto declRefExpr = dyn_cast<DeclRefExpr>(rhs->IgnoreImpCasts())) { + if (isa<VarDecl>(declRefExpr->getDecl())) { + return; + } + } + report( DiagnosticsEngine::Warning, - "assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr", + "assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you know that the RHS does not return a newly created T, then add a '.get()' to the RHS", rhs->getSourceRange().getBegin()) << rhs->getSourceRange(); } @@ -302,10 +344,12 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) { if (isa<ParmVarDecl>(pVarDecl)) { return true; } + SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( + pVarDecl->getLocStart()); if (pVarDecl->getInit()) { - checkAssignmentForVclPtrToRawConversion(pVarDecl->getType().getTypePtr(), pVarDecl->getInit()); + checkAssignmentForVclPtrToRawConversion(spellingLocation, pVarDecl->getType().getTypePtr(), pVarDecl->getInit()); } - StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(pVarDecl->getLocStart())); + StringRef aFileName = compiler.getSourceManager().getFilename(spellingLocation); if (aFileName == SRCDIR "/include/vcl/vclptr.hxx") return true; if (aFileName == SRCDIR "/vcl/source/window/layout.cxx") diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 27b6ea10a12e..c5588c055726 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -3728,7 +3728,7 @@ void ToolbarSaveInData::SetSystemStyle( if ( xUIElement.is() ) xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY ); - window = VCLUnoHelper::GetWindow( xWindow ); + window = VCLUnoHelper::GetWindow( xWindow ).get(); } if ( window != nullptr && window->GetType() == WINDOW_TOOLBOX ) diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index 2f6c5279eb7d..b4ffdc73c751 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -851,8 +851,8 @@ namespace svx if (!_bTryBothDirections) { - CheckBox *pBox = _ePrimaryConversionDirection == HHC::eHangulToHanja? - m_pHangulOnly : m_pHanjaOnly; + CheckBox *pBox = _ePrimaryConversionDirection == HHC::eHangulToHanja ? + m_pHangulOnly.get() : m_pHanjaOnly.get(); pBox->Check(); OnConversionDirectionClicked( pBox ); } diff --git a/cui/source/dialogs/passwdomdlg.cxx b/cui/source/dialogs/passwdomdlg.cxx index 21b88d5e4c78..92866f30d842 100644 --- a/cui/source/dialogs/passwdomdlg.cxx +++ b/cui/source/dialogs/passwdomdlg.cxx @@ -115,8 +115,8 @@ IMPL_LINK_NOARG( PasswordToOpenModifyDialog_Impl, OkBtnClickHdl, Button *, void ScopedVclPtrInstance< MessageDialog > aErrorBox(m_pParent, nMismatch == 1 ? m_aOneMismatch : m_aTwoMismatch); aErrorBox->Execute(); - Edit* pEdit = !bToOpenMatch ? m_pPasswdToOpenED : m_pPasswdToModifyED; - Edit* pRepeatEdit = !bToOpenMatch? m_pReenterPasswdToOpenED : m_pReenterPasswdToModifyED; + Edit* pEdit = !bToOpenMatch ? m_pPasswdToOpenED.get() : m_pPasswdToModifyED.get(); + Edit* pRepeatEdit = !bToOpenMatch? m_pReenterPasswdToOpenED.get() : m_pReenterPasswdToModifyED.get(); if (nMismatch == 1) { pEdit->SetText( "" ); diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index fb2d9a5b995b..5bb00f455dc9 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -3206,7 +3206,7 @@ void SvxCharTwoLinesPage::SelectCharacter( ListBox* pBox ) void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart ) { sal_Int32 nEntryPos = 0; - ListBox* pBox = bStart ? m_pStartBracketLB : m_pEndBracketLB; + ListBox* pBox = bStart ? m_pStartBracketLB.get() : m_pEndBracketLB.get(); if ( 0 == cBracket ) pBox->SelectEntryPos(0); else diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 43d95f5b129d..37324f46c139 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -1286,8 +1286,8 @@ IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox&, rLB, void ) IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox&, rLB, void ) { bool bHori = &rLB == m_pHoriLB; - ListBox *pRelLB = bHori ? m_pHoriToLB : m_pVertToLB; - FixedText *pRelFT = bHori ? m_pHoriToFT : m_pVertToFT; + ListBox *pRelLB = bHori ? m_pHoriToLB.get() : m_pVertToLB.get(); + FixedText *pRelFT = bHori ? m_pHoriToFT.get() : m_pVertToFT.get(); FrmMap *pMap = bHori ? m_pHMap : m_pVMap; diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 7a2db42f966f..512005e8f9a4 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -687,7 +687,7 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine OSL_ENSURE(_xContainer.is(),"Data source is NULL! -> GPF"); OSL_ENSURE( ( _eType >= E_TABLE ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OAppDetailPageHelper::fillNames: invalid type!" ); - DBTreeListBox* pList = m_pLists[ _eType ]; + DBTreeListBox* pList = m_pLists[ _eType ].get(); OSL_ENSURE( pList, "OAppDetailPageHelper::fillNames: you really should create the list before calling this!" ); if ( !pList ) return; @@ -809,7 +809,7 @@ void OAppDetailPageHelper::elementReplaced(ElementType _eType SvTreeListEntry* OAppDetailPageHelper::elementAdded(ElementType _eType,const OUString& _rName, const Any& _rObject ) { SvTreeListEntry* pRet = nullptr; - DBTreeListBox* pTreeView = m_pLists[_eType]; + DBTreeListBox* pTreeView = m_pLists[_eType].get(); if( _eType == E_TABLE && pTreeView ) { pRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rName ); diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index fb0a4d546c33..9b00cfa17a9b 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -452,7 +452,7 @@ namespace dbaui Reference< XWindow > xWindow = getTopMostContainerWindow(); vcl::Window* pWin = nullptr; if ( xWindow.is() ) - pWin = VCLUnoHelper::GetWindow(xWindow); + pWin = VCLUnoHelper::GetWindow(xWindow).get(); if ( !pWin ) pWin = getView()->Window::GetParent(); diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index d87cff6e5b79..f08beeefdb3a 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -892,8 +892,8 @@ void OJoinTableView::SelectConn(OTableConnection* pConn) OTableWindow* pConnDest = pConn->GetDestWin(); if (pConnSource && pConnDest) { - OTableWindowListBox* pSourceBox = pConnSource->GetListBox(); - OTableWindowListBox* pDestBox = pConnDest->GetListBox(); + OTableWindowListBox* pSourceBox = pConnSource->GetListBox().get(); + OTableWindowListBox* pDestBox = pConnDest->GetListBox().get(); if (pSourceBox && pDestBox) { pSourceBox->SelectAll(false); @@ -1200,12 +1200,8 @@ OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTab if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn())) { - auto aIter = m_vTableConnection.begin(); - auto aEnd = m_vTableConnection.end(); - for(;aIter != aEnd;++aIter) + for(VclPtr<OTableConnection> const & pData : m_vTableConnection) { - OTableConnection* pData = *aIter; - if ( ( (pData->GetSourceWin() == pLhs) && ( (pData->GetDestWin() == pRhs) || (nullptr == pRhs) @@ -1287,10 +1283,10 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) { if ((aIter->second == m_aTableMap.rbegin()->second) && bForward) // the last win is active and we're travelling forward -> select the first conn - pNextConn = *m_vTableConnection.begin(); + pNextConn = m_vTableConnection.begin()->get(); if ((aIter == m_aTableMap.begin()) && !bForward) // the first win is active an we're traveling backward -> select the last conn - pNextConn = *m_vTableConnection.rbegin(); + pNextConn = m_vTableConnection.rbegin()->get(); } if (!pNextConn) @@ -1343,11 +1339,11 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) // no win for any reason -> select the next or previous conn if (i < (sal_Int32)m_vTableConnection.size()) // there is a currently active conn - pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()]; + pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()].get(); else { // no tab win selected, no conn selected if (!m_vTableConnection.empty()) - pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1]; + pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1].get(); else if (!m_aTableMap.empty()) { if(bForward) diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index f0c4fbc75d0f..f0dd20842eb6 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -171,11 +171,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OTableWindow* pSourceWin = jxdSource.pListBox->GetTabWin(); OTableWindow* pDestWin = jxdDest.pListBox->GetTabWin(); - auto aIter = getTableConnections().begin(); - auto aEnd = getTableConnections().end(); - for(;aIter != aEnd;++aIter) + for(VclPtr<OTableConnection> const & pFirst : getTableConnections()) { - OTableConnection* pFirst = *aIter; if((pFirst->GetSourceWin() == pSourceWin && pFirst->GetDestWin() == pDestWin) || (pFirst->GetSourceWin() == pDestWin && pFirst->GetDestWin() == pSourceWin)) { diff --git a/dbaccess/source/ui/uno/ColumnControl.cxx b/dbaccess/source/ui/uno/ColumnControl.cxx index 580dc1ca6ec8..0fbe95b96031 100644 --- a/dbaccess/source/ui/uno/ColumnControl.cxx +++ b/dbaccess/source/ui/uno/ColumnControl.cxx @@ -70,7 +70,7 @@ void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit { VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer); if (pParent) - pParentWin = pParent->GetWindow(); + pParentWin = pParent->GetWindow().get(); } OColumnPeer* pPeer = new OColumnPeer( pParentWin, m_xContext ); diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 38ca3b11c6dc..abeb6fcdf8f4 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -58,7 +58,7 @@ namespace VDevBuffer(); virtual ~VDevBuffer() override; - VirtualDevice* alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome); + VclPtr<VirtualDevice> alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome); void free(VirtualDevice& rDevice); // Timer virtuals @@ -91,10 +91,10 @@ namespace } } - VirtualDevice* VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome) + VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome) { ::osl::MutexGuard aGuard(m_aMutex); - VirtualDevice* pRetval = nullptr; + VclPtr<VirtualDevice> pRetval; sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx index 698318bdae73..8be4a22e91e9 100644 --- a/extensions/source/dbpilots/gridwizard.cxx +++ b/extensions/source/dbpilots/gridwizard.cxx @@ -390,7 +390,7 @@ namespace dbp IMPL_LINK(OGridFieldsSelection, OnEntryDoubleClicked, ListBox&, _rList, void) { - PushButton* pSimulateButton = m_pExistFields == &_rList ? m_pSelectOne : m_pDeselectOne; + PushButton* pSimulateButton = m_pExistFields == &_rList ? m_pSelectOne.get() : m_pDeselectOne.get(); if (pSimulateButton->IsEnabled()) { OnMoveOneEntry( pSimulateButton ); diff --git a/extensions/source/propctrlr/defaulthelpprovider.cxx b/extensions/source/propctrlr/defaulthelpprovider.cxx index f85e849e39af..776dabfab267 100644 --- a/extensions/source/propctrlr/defaulthelpprovider.cxx +++ b/extensions/source/propctrlr/defaulthelpprovider.cxx @@ -154,7 +154,7 @@ namespace pcr try { Reference< XWindow > xControlWindow( _rxControl->getControlWindow(), UNO_QUERY_THROW ); - pControlWindow = VCLUnoHelper::GetWindow( xControlWindow ); + pControlWindow = VCLUnoHelper::GetWindow( xControlWindow ).get(); } catch( const Exception& ) { diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx index dfaf22fdae94..b665f7a090c0 100644 --- a/extensions/source/propctrlr/formlinkdialog.cxx +++ b/extensions/source/propctrlr/formlinkdialog.cxx @@ -122,7 +122,7 @@ namespace pcr void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames ) { - ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn : m_pMasterColumn; + ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get(); const OUString* pFieldName = _rFieldNames.getConstArray(); const OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength(); @@ -141,7 +141,7 @@ namespace pcr void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const OUString& _rName ) { - ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn : m_pMasterColumn; + ComboBox* pBox = ( _eWhich == eDetailField ) ? m_pDetailColumn.get() : m_pMasterColumn.get(); pBox->SetText( _rName ); } diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx index a4feb71ee2bd..d2e21a2dc5ac 100644 --- a/extensions/source/propctrlr/handlerhelper.cxx +++ b/extensions/source/propctrlr/handlerhelper.cxx @@ -287,7 +287,7 @@ namespace pcr try { Reference< XWindow > xInspectorWindow( _rContext->getValueByName( "DialogParentWindow" ), UNO_QUERY_THROW ); - pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow ); + pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow ).get(); } catch( const Exception& ) { diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx index a9f8775c415e..4d2916dee931 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -175,7 +175,7 @@ namespace frm { VCLXWindow* pParentXWin = VCLXWindow::GetImplementation( _rParentPeer ); if ( pParentXWin ) - pParentWin = pParentXWin->GetWindow(); + pParentWin = pParentXWin->GetWindow().get(); DBG_ASSERT( pParentWin, "ORichTextControl::createPeer: could not obtain the VCL-level parent window!" ); } diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index c12b0e289118..cd0f1c33fe47 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -126,7 +126,7 @@ namespace frm { VCLXWindow* pParentXWin = VCLXWindow::GetImplementation( _rParentPeer ); if ( pParentXWin ) - pParentWin = pParentXWin->GetWindow(); + pParentWin = pParentXWin->GetWindow().get(); DBG_ASSERT( pParentWin, "ONavigationBarControl::createPeer: could not obtain the VCL-level parent window!" ); } diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 83fc164c4805..756205886d34 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -711,7 +711,7 @@ void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UI // Retrieve output size from container Window SolarMutexGuard aGuard; - pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); + pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ).get(); if ( pContainerWindow ) aContainerWinSize = pContainerWindow->GetOutputSizePixel(); diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index b770fd8a86e0..98cbacebeb02 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -817,7 +817,7 @@ bool ToolbarLayoutManager::dockToolbar( const OUString& rResourceURL, ui::Dockin { SolarMutexGuard aGuard; - pWindow = VCLUnoHelper::GetWindow( xWindow ); + pWindow = VCLUnoHelper::GetWindow( xWindow ).get(); if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX ) { pToolBox = static_cast<ToolBox *>(pWindow); @@ -1410,7 +1410,7 @@ void ToolbarLayoutManager::implts_setElementData( UIElement& rElement, const uno { { SolarMutexGuard aGuard; - pWindow = VCLUnoHelper::GetWindow( xWindow ); + pWindow = VCLUnoHelper::GetWindow( xWindow ).get(); if ( pWindow ) { OUString aText = pWindow->GetText(); @@ -2251,7 +2251,7 @@ void ToolbarLayoutManager::implts_findNextDockingPos( ui::DockingArea DockingAre { // Retrieve output size from container Window SolarMutexGuard aGuard; - pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow ); + pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow ).get(); if ( pDockingWindow ) aDockingWinSize = pDockingWindow->GetOutputSizePixel(); } @@ -2589,7 +2589,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( SolarMutexResettableGuard aReadLock; uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow ); ::Size aContainerWinSize; - vcl::Window* pContainerWindow( nullptr ); + vcl::Window* pContainerWindow( nullptr ); ::Rectangle aDockingAreaOffsets( m_aDockingAreaOffsets ); aReadLock.clear(); @@ -2602,7 +2602,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( { // Retrieve output size from container Window SolarMutexGuard aGuard; - pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ).get(); aContainerWinSize = pContainerWindow->GetOutputSizePixel(); } @@ -2629,7 +2629,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( { SolarMutexGuard aGuard; - pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ); + pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get(); VclPtr<vcl::Window> pDockWindow = VCLUnoHelper::GetWindow( xWindow ); if ( pDockWindow && pDockWindow->GetType() == WINDOW_TOOLBOX ) pToolBox = static_cast<ToolBox *>(pDockWindow.get()); @@ -3067,7 +3067,7 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d vcl::Window* pDockingAreaWindow( nullptr ); { SolarMutexGuard aGuard; - pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ); + pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get(); VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); nDockPosY = pDockingAreaWindow->ScreenToOutputPixel( pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y(); } @@ -3262,7 +3262,7 @@ throw (uno::RuntimeException, std::exception) ::Point aMousePos; { SolarMutexGuard aGuard; - pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ).get(); aMousePos = pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y )); } @@ -3631,7 +3631,7 @@ throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; xWindow.set( e.Source, uno::UNO_QUERY ); - pWindow = VCLUnoHelper::GetWindow( xWindow ); + pWindow = VCLUnoHelper::GetWindow( xWindow ).get(); if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX ) pToolBox = static_cast<ToolBox *>(pWindow); diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx index 4de793340e67..0214754d0dca 100644 --- a/framework/source/uielement/addonstoolbarwrapper.cxx +++ b/framework/source/uielement/addonstoolbarwrapper.cxx @@ -105,7 +105,7 @@ void SAL_CALL AddonsToolBarWrapper::initialize( const Sequence< Any >& aArgument if ( xFrame.is() && m_aConfigData.getLength() > 0 ) { // Create VCL based toolbar which will be filled with settings data - ToolBox* pToolBar = nullptr; + VclPtr<ToolBox> pToolBar; AddonsToolBarManager* pToolBarManager = nullptr; { SolarMutexGuard aSolarMutexGuard; diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx index 8733666c047b..288294ada9ac 100644 --- a/framework/source/uielement/toolbarwrapper.cxx +++ b/framework/source/uielement/toolbarwrapper.cxx @@ -141,7 +141,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) th if ( xFrame.is() && m_xConfigSource.is() ) { // Create VCL based toolbar which will be filled with settings data - ToolBox* pToolBar = nullptr; + VclPtr<ToolBox> pToolBar; ToolBarManager* pToolBarManager = nullptr; { SolarMutexGuard aSolarMutexGuard; diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 313ae5384f9d..ca6f45786ae2 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -409,7 +409,7 @@ class VCL_DLLPUBLIC MenuBar : public Menu friend class MenuFloatingWindow; friend class SystemWindow; - SAL_DLLPRIVATE static vcl::Window* ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu); + SAL_DLLPRIVATE static VclPtr<vcl::Window> ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu); SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete); SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent); SAL_DLLPRIVATE bool ImplHandleCmdEvent(const CommandEvent& rCEvent); diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index da28331e5ab0..84dd2b9b336c 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -279,7 +279,7 @@ namespace rptui m_xCopy->removeByIndex( (sal_Int32)nOldConditionIndex ); Conditions::iterator aRemovePos( m_aConditions.begin() + nOldConditionIndex ); - pMovedCondition = *aRemovePos; + pMovedCondition = aRemovePos->get(); m_aConditions.erase( aRemovePos ); } catch( const Exception& ) diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index bdeaf0699dfd..03f3574cc48a 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -219,11 +219,8 @@ void OViewsWindow::resize(const OSectionWindow& _rSectionWindow) { bool bSet = false; Point aStartPoint; - TSectionsMap::const_iterator aIter = m_aSections.begin(); - TSectionsMap::const_iterator aEnd = m_aSections.end(); - for (;aIter != aEnd ; ++aIter) + for (VclPtr<OSectionWindow> const & pSectionWindow : m_aSections) { - OSectionWindow* pSectionWindow = (*aIter); if ( pSectionWindow == &_rSectionWindow ) { aStartPoint = pSectionWindow->GetPosPixel(); @@ -248,11 +245,8 @@ void OViewsWindow::Resize() { const Point aOffset(m_pParent->getThumbPos()); Point aStartPoint(0,-aOffset.Y()); - TSectionsMap::const_iterator aIter = m_aSections.begin(); - TSectionsMap::const_iterator aEnd = m_aSections.end(); - for (;aIter != aEnd ; ++aIter) + for (VclPtr<OSectionWindow> const & pSectionWindow : m_aSections) { - OSectionWindow* pSectionWindow = (*aIter); impl_resizeSectionWindow(*pSectionWindow,aStartPoint,true); } } @@ -420,13 +414,11 @@ OSectionWindow* OViewsWindow::getSectionWindow(const uno::Reference< report::XSe OSL_ENSURE(_xSection.is(),"Section is NULL!"); OSectionWindow* pSectionWindow = nullptr; - TSectionsMap::const_iterator aIter = m_aSections.begin(); - TSectionsMap::const_iterator aEnd = m_aSections.end(); - for (; aIter != aEnd ; ++aIter) + for (VclPtr<OSectionWindow> const & p : m_aSections) { - if ((*aIter)->getReportSection().getSection() == _xSection) + if (p->getReportSection().getSection() == _xSection) { - pSectionWindow = (*aIter); + pSectionWindow = p.get(); break; } } @@ -447,23 +439,23 @@ OSectionWindow* OViewsWindow::getMarkedSection(NearSectionAccess nsa) const { if (nsa == CURRENT) { - pRet = (*aIter); + pRet = aIter->get(); break; } else if ( nsa == PREVIOUS ) { if (nCurrentPosition > 0) { - pRet = (*(--aIter)); + pRet = (--aIter)->get(); if (pRet == nullptr) { - pRet = (*m_aSections.begin()); + pRet = m_aSections.begin()->get(); } } else { // if we are out of bounds return the first one - pRet = (*m_aSections.begin()); + pRet = m_aSections.begin()->get(); } break; } @@ -472,16 +464,16 @@ OSectionWindow* OViewsWindow::getMarkedSection(NearSectionAccess nsa) const sal_uInt32 nSize = m_aSections.size(); if ((nCurrentPosition + 1) < nSize) { - pRet = *(++aIter); + pRet = (++aIter)->get(); if (pRet == nullptr) { - pRet = (*(--aEnd)); + pRet = (--aEnd)->get(); } } else { // if we are out of bounds return the last one - pRet = (*(--aEnd)); + pRet = (--aEnd)->get(); } break; } @@ -946,7 +938,7 @@ OSectionWindow* OViewsWindow::getSectionWindow(const sal_uInt16 _nPos) const OSectionWindow* aReturn = nullptr; if ( _nPos < m_aSections.size() ) - aReturn = m_aSections[_nPos]; + aReturn = m_aSections[_nPos].get(); return aReturn; } diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 357bb05a00eb..f1b055697e94 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -465,7 +465,7 @@ void ScFilterDlg::UpdateValueList( size_t nList ) if (pDoc && nList > 0 && nList <= QUERY_ENTRY_COUNT) { - ComboBox* pValList = maValueEdArr[nList-1]; + ComboBox* pValList = maValueEdArr[nList-1].get(); const sal_Int32 nFieldSelPos = maFieldLbArr[nList-1]->GetSelectEntryPos(); sal_Int32 nListPos = 0; OUString aCurValue = pValList->GetText(); @@ -576,7 +576,7 @@ void ScFilterDlg::UpdateHdrInValueList( size_t nList ) if (nPos == INVALID_HEADER_POS) return; - ComboBox* pValList = maValueEdArr[nList-1]; + ComboBox* pValList = maValueEdArr[nList-1].get(); size_t nListPos = nPos + 2; // for "empty" and "non-empty" const ScTypedStrData& rHdrEntry = m_EntryLists[nColumn]->maList[nPos]; @@ -601,7 +601,7 @@ void ScFilterDlg::ClearValueList( size_t nList ) { if (nList > 0 && nList <= QUERY_ENTRY_COUNT) { - ComboBox* pValList = maValueEdArr[nList-1]; + ComboBox* pValList = maValueEdArr[nList-1].get(); pValList->Clear(); pValList->InsertEntry( aStrNotEmpty, 0 ); pValList->InsertEntry( aStrEmpty, 1 ); diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index 7c2b75631221..33e7dfe70927 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -294,7 +294,7 @@ void ScPivotFilterDlg::UpdateValueList( sal_uInt16 nList ) { if ( pDoc && nList>0 && nList<=3 ) { - ComboBox* pValList = aValueEdArr[nList-1]; + ComboBox* pValList = aValueEdArr[nList-1].get(); sal_Int32 nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos(); sal_Int32 nListPos = 0; OUString aCurValue = pValList->GetText(); @@ -338,7 +338,7 @@ void ScPivotFilterDlg::ClearValueList( sal_uInt16 nList ) { if ( nList>0 && nList<=3 ) { - ComboBox* pValList = aValueEdArr[nList-1]; + ComboBox* pValList = aValueEdArr[nList-1].get(); pValList->Clear(); pValList->InsertEntry( aStrNotEmpty, 0 ); pValList->InsertEntry( aStrEmpty, 1 ); diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index 5a9ad2b33621..942ec571fe27 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -702,7 +702,7 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou pRBtn = m_pRbSortMan; break; default: - pRBtn = maLabelData.maSortInfo.IsAscending ? m_pRbSortAsc : m_pRbSortDesc; + pRBtn = maLabelData.maSortInfo.IsAscending ? m_pRbSortAsc.get() : m_pRbSortDesc.get(); } pRBtn->Check(); RadioClickHdl( pRBtn ); diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 512af1b54b35..48a3449fb6f3 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -399,9 +399,8 @@ void ScFormulaReferenceHelper::RefInputDone( bool bForced ) pRefBtn->SetStartImage(); // All others: Show(); - for (auto aI = m_aHiddenWidgets.begin(); aI != m_aHiddenWidgets.end(); ++aI) + for (VclPtr<vcl::Window> const & pWindow : m_aHiddenWidgets) { - vcl::Window *pWindow = *aI; pWindow->Show(); } m_aHiddenWidgets.clear(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 7c3124930aca..7b61def5cb14 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1197,7 +1197,7 @@ static OutputDevice* lcl_GetRenderDevice( const uno::Sequence<beans::PropertyVal VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); if ( pDevice ) { - pRet = pDevice->GetOutputDevice(); + pRet = pDevice->GetOutputDevice().get(); pRet->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); } } diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 81ae3c778551..c05d098dcf21 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1715,7 +1715,7 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT; - ScGridWindow* pWin = pGridWin[eUsedPart]; + ScGridWindow* pWin = pGridWin[eUsedPart].get(); OSL_ENSURE( pWin, "Window not found" ); if (pWin) { @@ -1832,7 +1832,7 @@ Point ScTabView::GetChartDialogPos( const Size& rDialogSize, const Rectangle& rL if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT; - ScGridWindow* pWin = pGridWin[eUsedPart]; + ScGridWindow* pWin = pGridWin[eUsedPart].get(); OSL_ENSURE( pWin, "Window not found" ); if (pWin) { @@ -2181,7 +2181,7 @@ void ScTabView::SetNewVisArea() bool ScTabView::HasPageFieldDataAtCursor() const { - ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()].get(); SCCOL nCol = aViewData.GetCurX(); SCROW nRow = aViewData.GetCurY(); if (pWin) @@ -2192,7 +2192,7 @@ bool ScTabView::HasPageFieldDataAtCursor() const void ScTabView::StartDataSelect() { - ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()].get(); SCCOL nCol = aViewData.GetCurX(); SCROW nRow = aViewData.GetCurY(); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 7dce8524fec7..fb3d6b47ee50 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -717,7 +717,7 @@ void ScTabView::TestHintWindow() if ( pData && pData->GetInput( aTitle, aMessage ) && !aMessage.isEmpty() ) { ScSplitPos eWhich = aViewData.GetActivePart(); - ScGridWindow* pWin = pGridWin[eWhich]; + ScGridWindow* pWin = pGridWin[eWhich].get(); SCCOL nCol = aViewData.GetCurX(); SCROW nRow = aViewData.GetCurY(); Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich ); @@ -2112,7 +2112,7 @@ void ScTabView::KillEditView( bool bNoPaint ) auto lInvalidateWindows = [&rInvRect] (ScTabView* pTabView) { - for (ScGridWindow* pWin: pTabView->pGridWin) + for (VclPtr<ScGridWindow> const & pWin: pTabView->pGridWin) { if (pWin) pWin->Invalidate(rInvRect); @@ -2808,7 +2808,7 @@ void ScTabView::HideListBox() void ScTabView::UpdateInputContext() { - ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()].get(); if (pWin) pWin->UpdateInputContext(); @@ -2879,7 +2879,7 @@ void ScTabView::ZoomChanged() HideNoteMarker(); // AW: To not change too much, use pWin here - ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()].get(); if ( pWin && aViewData.HasEditView( aViewData.GetActivePart() ) ) { diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index fbb40fa31e5a..fdc633dfaa2e 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -442,7 +442,7 @@ void ScTabView::InvertHorizontal( ScVSplitPos eWhich, long nDragPos ) for (sal_uInt16 i=0; i<4; i++) if (WhichV((ScSplitPos)i)==eWhich) { - ScGridWindow* pWin = pGridWin[i]; + ScGridWindow* pWin = pGridWin[i].get(); if (pWin) { Rectangle aRect( 0,nDragPos, pWin->GetOutputSizePixel().Width()-1,nDragPos+HDR_SLIDERSIZE-1 ); @@ -457,7 +457,7 @@ void ScTabView::InvertVertical( ScHSplitPos eWhich, long nDragPos ) for (sal_uInt16 i=0; i<4; i++) if (WhichH((ScSplitPos)i)==eWhich) { - ScGridWindow* pWin = pGridWin[i]; + ScGridWindow* pWin = pGridWin[i].get(); if (pWin) { Rectangle aRect( nDragPos,0, nDragPos+HDR_SLIDERSIZE-1,pWin->GetOutputSizePixel().Height()-1 ); diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx index 5bf6eb97fa59..387dafc430ea 100644 --- a/sd/source/ui/framework/factories/BasicViewFactory.cxx +++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx @@ -153,7 +153,7 @@ Reference<XResource> SAL_CALL BasicViewFactory::createResource ( // Get Window pointer for XWindow of the pane. vcl::Window* pWindow = nullptr; if (xPane.is()) - pWindow = VCLUnoHelper::GetWindow(xPane->getWindow()); + pWindow = VCLUnoHelper::GetWindow(xPane->getWindow()).get(); // Get the view frame. SfxViewFrame* pFrame = nullptr; diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 9a20e3431b8e..fbb33d1a0321 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -390,8 +390,8 @@ protected: void DeleteActualPage(); void DeleteActualLayer(); - virtual SvxRuler* CreateHRuler(::sd::Window* pWin) override; - virtual SvxRuler* CreateVRuler(::sd::Window* pWin) override; + virtual VclPtr<SvxRuler> CreateHRuler(::sd::Window* pWin) override; + virtual VclPtr<SvxRuler> CreateVRuler(::sd::Window* pWin) override; virtual void UpdateHRuler() override; virtual void UpdateVRuler() override; virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY) override; diff --git a/sd/source/ui/inc/PresentationViewShell.hxx b/sd/source/ui/inc/PresentationViewShell.hxx index 3651222cceb2..f5dfc5090dc7 100644 --- a/sd/source/ui/inc/PresentationViewShell.hxx +++ b/sd/source/ui/inc/PresentationViewShell.hxx @@ -53,8 +53,8 @@ public: virtual void Resize() override; protected: - virtual SvxRuler* CreateHRuler(::sd::Window* pWin) override; - virtual SvxRuler* CreateVRuler(::sd::Window* pWin) override; + virtual VclPtr<SvxRuler> CreateHRuler(::sd::Window* pWin) override; + virtual VclPtr<SvxRuler> CreateVRuler(::sd::Window* pWin) override; private: Rectangle maOldVisArea; diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index ab3c480acac6..fa1a6962cece 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -513,8 +513,8 @@ protected: virtual void VirtVScrollHdl(ScrollBar* pVScroll); // virtual functions ruler handling - virtual SvxRuler* CreateHRuler(::sd::Window* pWin); - virtual SvxRuler* CreateVRuler(::sd::Window* pWin); + virtual VclPtr<SvxRuler> CreateHRuler(::sd::Window* pWin); + virtual VclPtr<SvxRuler> CreateVRuler(::sd::Window* pWin); virtual void UpdateHRuler(); virtual void UpdateVRuler(); diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index c66987be6f8d..1fa0e030875c 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -120,7 +120,7 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter) mnPaintEntranceCount(0), mbIsContextMenuOpen(false) { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); OSL_ASSERT(pWindow); if (pWindow) { @@ -483,7 +483,7 @@ void SlideSorterController::PostModelChange() mbPostModelChangePending = false; mrModel.Resync(); - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { GetCurrentSlideManager()->HandleModelChange(); @@ -527,7 +527,7 @@ IMPL_LINK(SlideSorterController, ApplicationEventHandler, VclSimpleEvent&, rEven IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent&, rEvent, void) { vcl::Window* pWindow = rEvent.GetWindow(); - sd::Window *pActiveWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pActiveWindow (mrSlideSorter.GetContentWindow().get()); switch (rEvent.GetId()) { case VCLEVENT_WINDOW_ACTIVATE: @@ -685,7 +685,7 @@ void SlideSorterController::Rearrange (bool bForce) else mbIsForcedRearrangePending = false; - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { if (bForce) @@ -832,7 +832,7 @@ void SlideSorterController::PageNameHasChanged (int nPageIndex, const OUString& // Get a pointer to the corresponding accessible object and notify // that of the name change. - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if ( ! pWindow) return; diff --git a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx index cbaf2dab436c..801e2a3c305b 100644 --- a/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx +++ b/sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx @@ -86,7 +86,7 @@ void DragAndDropContext::UpdatePosition ( // Convert window coordinates into model coordinates (we need the // window coordinates for auto-scrolling because that remains // constant while scrolling.) - sd::Window *pWindow (mpTargetSlideSorter->GetContentWindow()); + sd::Window *pWindow = mpTargetSlideSorter->GetContentWindow().get(); const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); std::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler ( mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()); diff --git a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx index 171b61226b75..f38ed105997c 100644 --- a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx @@ -175,7 +175,7 @@ void ScrollBarManager::PlaceFiller (const Rectangle& aArea) void ScrollBarManager::UpdateScrollBars(bool bUseScrolling) { Rectangle aModelArea (mrSlideSorter.GetView().GetModelArea()); - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); Size aWindowModelSize (pWindow->PixelToLogic(pWindow->GetSizePixel())); // The horizontal scroll bar is only shown when the window is @@ -275,7 +275,7 @@ void ScrollBarManager::SetWindowOrigin ( mnHorizontalPosition = nHorizontalPosition; mnVerticalPosition = nVerticalPosition; - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); Size aViewSize (pWindow->GetViewSize()); Point aOrigin ( (long int) (mnHorizontalPosition * aViewSize.Width()), @@ -431,7 +431,7 @@ int ScrollBarManager::GetHorizontalScrollBarHeight() const void ScrollBarManager::CalcAutoScrollOffset (const Point& rMouseWindowPosition) { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); int nDx = 0; int nDy = 0; diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx index 8c18d5683f9d..c2ea99198f71 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx @@ -1367,7 +1367,7 @@ void MultiSelectionModeHandler::UpdatePosition ( // Convert window coordinates into model coordinates (we need the // window coordinates for auto-scrolling because that remains // constant while scrolling.) - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition)); bool bDoAutoScroll = bAllowAutoScroll && mrSlideSorter.GetController().GetScrollBarManager().AutoScroll( diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx index 5af575cd4fdb..03e38021800e 100644 --- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx @@ -104,7 +104,7 @@ void VisibleAreaManager::MakeVisible() if (maVisibleRequests.empty()) return; - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if ( ! pWindow) return; const Point aCurrentTopLeft (pWindow->PixelToLogic(Point(0,0))); @@ -147,7 +147,7 @@ void VisibleAreaManager::MakeVisible() ::boost::optional<Point> VisibleAreaManager::GetRequestedTopLeft() const { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if ( ! pWindow) return ::boost::optional<Point>(); diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx index 0c7b22a441a5..98835c75fa7a 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx @@ -168,7 +168,7 @@ void SlideSorter::Init() SetupListeners (); // Initialize the window. - sd::Window *pContentWindow (GetContentWindow()); + sd::Window *pContentWindow = GetContentWindow().get(); if (pContentWindow) { vcl::Window* pParentWindow = pContentWindow->GetParent(); @@ -249,7 +249,7 @@ void SlideSorter::SetupControls (vcl::Window* ) void SlideSorter::SetupListeners() { - sd::Window *pWindow (GetContentWindow()); + sd::Window *pWindow = GetContentWindow().get(); if (pWindow) { vcl::Window* pParentWindow = pWindow->GetParent(); @@ -278,7 +278,7 @@ void SlideSorter::ReleaseListeners() { mpSlideSorterController->GetScrollBarManager().Disconnect(); - sd::Window *pWindow (GetContentWindow()); + sd::Window *pWindow (GetContentWindow().get()); if (pWindow) { pWindow->RemoveEventListener( diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx index 344b076386f0..681385ac93fe 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -180,7 +180,7 @@ void SlideSorterViewShell::Initialize() // the new view shell. (One is created earlier while the constructor // of the base class is executed. At that time the correct // accessibility object can not be constructed.) - sd::Window *pWindow (mpSlideSorter->GetContentWindow()); + sd::Window *pWindow (mpSlideSorter->GetContentWindow().get()); if (pWindow) { pWindow->Hide(); diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index e41790b0b2cb..222f2dfc0194 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -209,7 +209,7 @@ sal_Int32 SlideSorterView::GetPageIndexAtPoint (const Point& rWindowPosition) co { sal_Int32 nIndex (-1); - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { nIndex = mpLayouter->GetIndexAtPoint(pWindow->PixelToLogic(rWindowPosition), false, false); @@ -309,7 +309,7 @@ void SlideSorterView::Rearrange() if (mrModel.GetPageCount() <= 0) return; - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if ( ! pWindow) return; const Size aWindowSize (pWindow->GetSizePixel()); @@ -401,7 +401,7 @@ void SlideSorterView::UpdateOrientation() void SlideSorterView::Layout () { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { // Set the model area, i.e. the smallest rectangle that includes all @@ -443,7 +443,7 @@ void SlideSorterView::InvalidatePageObjectVisibilities() void SlideSorterView::DeterminePageObjectVisibilities() { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { // Set this flag to true here so that an invalidate during the @@ -538,7 +538,7 @@ bool SlideSorterView::SetOrientation (const Layouter::Orientation eOrientation) void SlideSorterView::RequestRepaint() { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { mpLayeredDevice->InvalidateAllLayers( @@ -557,7 +557,7 @@ void SlideSorterView::RequestRepaint (const model::SharedPageDescriptor& rpDescr void SlideSorterView::RequestRepaint (const Rectangle& rRepaintBox) { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { mpLayeredDevice->InvalidateAllLayers(rRepaintBox); @@ -567,7 +567,7 @@ void SlideSorterView::RequestRepaint (const Rectangle& rRepaintBox) void SlideSorterView::RequestRepaint (const vcl::Region& rRepaintRegion) { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow) { mpLayeredDevice->InvalidateAllLayers(rRepaintRegion); @@ -691,7 +691,7 @@ void SlideSorterView::ConfigurationChanged ( std::shared_ptr<cache::PageCache> const & SlideSorterView::GetPreviewCache() { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow && mpPreviewCache.get() == nullptr) { mpPreviewCache.reset( @@ -757,7 +757,7 @@ void SlideSorterView::UpdatePageUnderMouse () return; } - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (pWindow && pWindow->IsVisible() && ! pWindow->IsMouseCaptured()) { const Window::PointerState aPointerState (pWindow->GetPointerState()); diff --git a/sd/source/ui/slidesorter/view/SlsToolTip.cxx b/sd/source/ui/slidesorter/view/SlsToolTip.cxx index 33e08c10d1e4..4077e83068df 100644 --- a/sd/source/ui/slidesorter/view/SlsToolTip.cxx +++ b/sd/source/ui/slidesorter/view/SlsToolTip.cxx @@ -37,7 +37,7 @@ ToolTip::ToolTip (SlideSorter& rSlideSorter) maShowTimer(), maHiddenTimer() { - sd::Window *window = rSlideSorter.GetContentWindow(); + sd::Window *window = rSlideSorter.GetContentWindow().get(); const HelpSettings& rHelpSettings = window->GetSettings().GetHelpSettings(); maShowTimer.SetTimeout(rHelpSettings.GetTipDelay()); maShowTimer.SetTimeoutHdl(LINK(this, ToolTip, DelayTrigger)); @@ -104,7 +104,7 @@ void ToolTip::DoShow() return; } - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); if (!msCurrentHelpText.isEmpty() && pWindow) { Rectangle aBox ( @@ -141,7 +141,7 @@ bool ToolTip::Hide() { if (mnHelpWindowHandle>0) { - sd::Window *pWindow (mrSlideSorter.GetContentWindow()); + sd::Window *pWindow (mrSlideSorter.GetContentWindow().get()); Help::HidePopover(pWindow, mnHelpWindowHandle); mnHelpWindowHandle = 0; return true; diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx index 89a62ddd05b3..2f61531c714a 100644 --- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx +++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx @@ -414,7 +414,7 @@ throw (UnknownPropertyException, PropertyVetoException, SdOptionsPrintItem aOptionsPrintItem; - SfxPrinter* pPrinter = pDocSh->GetPrinter( false ); + VclPtr<SfxPrinter> pPrinter = pDocSh->GetPrinter( false ); if( pPrinter ) { SdOptionsPrintItem const * pPrinterOptions = nullptr; diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 02b965c35346..f17f1c11a175 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -500,9 +500,9 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive) * Generate horizontal ruler */ -SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin) +VclPtr<SvxRuler> DrawViewShell::CreateHRuler (::sd::Window* pWin) { - Ruler* pRuler; + VclPtr<Ruler> pRuler; WinBits aWBits; SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT; @@ -538,9 +538,9 @@ SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin) * Generate vertical ruler */ -SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin) +VclPtr<SvxRuler> DrawViewShell::CreateVRuler(::sd::Window* pWin) { - Ruler* pRuler; + VclPtr<SvxRuler> pRuler; WinBits aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER; SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT; diff --git a/sd/source/ui/view/presvish.cxx b/sd/source/ui/view/presvish.cxx index fd1c5c23f0ac..7d78cddacbcc 100644 --- a/sd/source/ui/view/presvish.cxx +++ b/sd/source/ui/view/presvish.cxx @@ -28,10 +28,9 @@ #include "sddll.hxx" #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> - #include <sfx2/objface.hxx> - #include <svx/svxids.hrc> +#include <svx/ruler.hxx> #include "FrameView.hxx" #include "sdresid.hxx" #include "DrawDocShell.hxx" @@ -107,12 +106,12 @@ void PresentationViewShell::FinishInitialization( FrameView* pFrameView ) GetActiveWindow()->GrabFocus(); } -SvxRuler* PresentationViewShell::CreateHRuler(::sd::Window*) +VclPtr<SvxRuler> PresentationViewShell::CreateHRuler(::sd::Window*) { return nullptr; } -SvxRuler* PresentationViewShell::CreateVRuler(::sd::Window*) +VclPtr<SvxRuler> PresentationViewShell::CreateVRuler(::sd::Window*) { return nullptr; } diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 4dcaa0f18af4..82b529e869d3 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -244,12 +244,12 @@ void ViewShell::VirtVScrollHdl(ScrollBar* pVScroll) } } -SvxRuler* ViewShell::CreateHRuler(::sd::Window* ) +VclPtr<SvxRuler> ViewShell::CreateHRuler(::sd::Window* ) { return nullptr; } -SvxRuler* ViewShell::CreateVRuler(::sd::Window* ) +VclPtr<SvxRuler> ViewShell::CreateVRuler(::sd::Window* ) { return nullptr; } diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index a8ad4dbf45a2..1c15d90bffe9 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -581,7 +581,7 @@ void SfxWorkWindow::DeleteControllers_Impl() // DockingWindows) for (size_t n=0; n<SFX_SPLITWINDOWS_MAX; n++ ) { - SfxSplitWindow *p = pSplit[n]; + VclPtr<SfxSplitWindow> const &p = pSplit[n]; if (p->GetWindowCount()) p->Lock(); } @@ -1162,7 +1162,7 @@ void SfxWorkWindow::UpdateObjectBars_Impl2() sal_uInt16 n; for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ ) { - SfxSplitWindow *p = pSplit[n]; + VclPtr<SfxSplitWindow> const & p = pSplit[n]; if (p->GetWindowCount()) p->Lock(); } @@ -1246,7 +1246,7 @@ void SfxWorkWindow::UpdateObjectBars_Impl2() // Unlock the SplitWindows again for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ ) { - SfxSplitWindow *p = pSplit[n]; + VclPtr<SfxSplitWindow> const & p = pSplit[n]; if (p->GetWindowCount()) p->Lock(false); } @@ -2383,7 +2383,7 @@ void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow *pActSplitWin ) // (not pinned, FadeIn). // Only the abandoned window may be invisible, because perhaps its // size is just being calculated before it is displayed. - SfxSplitWindow* pSplitWin = pSplit[n]; + VclPtr<SfxSplitWindow> const & pSplitWin = pSplit[n]; bool bDummyWindow = !pSplitWin->IsFadeIn(); vcl::Window *pDummy = pSplitWin->GetSplitWindow(); vcl::Window *pWin = bDummyWindow ? pDummy : pSplitWin; diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 15fa22588712..3afb9420b230 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -175,9 +175,8 @@ void BackingWindow::dispose() // deregister drag&drop helper if (mxDropTargetListener.is()) { - for (auto aI = maDndWindows.begin(), aEnd = maDndWindows.end(); aI != aEnd; ++aI) + for (auto const & pDndWin : maDndWindows) { - vcl::Window *pDndWin = *aI; css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = pDndWin->GetDropTarget(); if (xDropTarget.is()) @@ -499,9 +498,8 @@ void BackingWindow::setOwningFrame( const css::uno::Reference< css::frame::XFram // establish drag&drop mode mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame)); - for (auto aI = maDndWindows.begin(), aEnd = maDndWindows.end(); aI != aEnd; ++aI) + for (auto const & pDndWin : maDndWindows) { - vcl::Window *pDndWin = *aI; css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = pDndWin->GetDropTarget(); if (xDropTarget.is()) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 03b005fc4d11..7dcc6286271c 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1832,7 +1832,7 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod vcl::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel ) { - vcl::Window* pWin = nullptr; + VclPtr<vcl::Window> pWin; try { if ( xModel.is() ) { diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index f750d1ee74dd..c862ad74001c 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1659,7 +1659,7 @@ bool SfxObjectShell::AdjustMacroMode() vcl::Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium ) { - vcl::Window* pWindow = nullptr; + VclPtr<vcl::Window> pWindow; SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet(); const SfxUnoFrameItem* pUnoItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pSet, SID_FILLFRAME, false); if ( pUnoItem ) diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index d84f56b556a2..8887ca079ac6 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -313,7 +313,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SfxPrintHelper::getPrinter() thro void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue >& rPrinter, - SfxPrinter*& pPrinter, + VclPtr<SfxPrinter>& pPrinter, SfxPrinterChangeFlags& nChangeFlags, SfxViewShell*& pViewSh) @@ -457,7 +457,7 @@ void SAL_CALL SfxPrintHelper::setPrinter(const uno::Sequence< beans::PropertyVal SolarMutexGuard aGuard; SfxViewShell* pViewSh = nullptr; - SfxPrinter* pPrinter = nullptr; + VclPtr<SfxPrinter> pPrinter; SfxPrinterChangeFlags nChangeFlags = SfxPrinterChangeFlags::NONE; impl_setPrinter(rPrinter,pPrinter,nChangeFlags,pViewSh); // set new printer diff --git a/sfx2/source/doc/printhelper.hxx b/sfx2/source/doc/printhelper.hxx index aedd9e211b6c..a91e5b5c384c 100644 --- a/sfx2/source/doc/printhelper.hxx +++ b/sfx2/source/doc/printhelper.hxx @@ -62,7 +62,7 @@ private: osl::Mutex m_aMutex; IMPL_PrintListener_DataContainer* m_pData ; void impl_setPrinter(const css::uno::Sequence< css::beans::PropertyValue >& rPrinter, - SfxPrinter*& pPrinter, + VclPtr<SfxPrinter>& pPrinter, SfxPrinterChangeFlags& nChangeFlags, SfxViewShell*& pViewSh); } ; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 87179deafe99..9994b5825087 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -419,7 +419,7 @@ SfxOwnFramesLocker::~SfxOwnFramesLocker() vcl::Window* SfxOwnFramesLocker::GetVCLWindow( const Reference< frame::XFrame >& xFrame ) { - vcl::Window* pWindow = nullptr; + VclPtr<vcl::Window> pWindow; if ( xFrame.is() ) { diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index d6a51a01f2e9..97742b73b5fc 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -346,7 +346,7 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc) for ( SharedPanelContainer::iterator iPanel(rPanels.begin()), iEnd(rPanels.end()); iPanel!=iEnd; ++iPanel) { - Panel* aPanel = *iPanel; + VclPtr<Panel> const & aPanel = *iPanel; OUString panelId = aPanel->GetId(); std::shared_ptr<PanelDescriptor> xPanelDesc = GetPanelDescriptor(panelId); diff --git a/sfx2/source/sidebar/UnoPanel.cxx b/sfx2/source/sidebar/UnoPanel.cxx index 917a23692919..e696e32b0b88 100644 --- a/sfx2/source/sidebar/UnoPanel.cxx +++ b/sfx2/source/sidebar/UnoPanel.cxx @@ -98,7 +98,7 @@ void SAL_CALL SfxUnoPanel::expand( const sal_Bool bCollapseOther ) for ( SharedPanelContainer::iterator iPanel(aPanels.begin()), iEnd(aPanels.end()); iPanel!=iEnd; ++iPanel) { - Panel* aPanel = *iPanel; + VclPtr<Panel> const & aPanel = *iPanel; if (! aPanel->HasIdPredicate(mPanelId)) aPanel->SetExpanded(false); diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index 1258aa6339a2..8bae92443fa8 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -16,6 +16,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/oslendian-2 \ compilerplugins/clang/test/oslendian-3 \ compilerplugins/clang/test/salbool \ + compilerplugins/clang/test/vclwidgets \ )) # vim: set noet sw=4 ts=4: diff --git a/svtools/source/hatchwindow/hatchwindow.cxx b/svtools/source/hatchwindow/hatchwindow.cxx index 148ff37d0d9f..e7216d25f256 100644 --- a/svtools/source/hatchwindow/hatchwindow.cxx +++ b/svtools/source/hatchwindow/hatchwindow.cxx @@ -45,7 +45,7 @@ void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer > { SolarMutexGuard aGuard; - vcl::Window* pParent = nullptr; + VclPtr<vcl::Window> pParent; VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent ); if ( pParentComponent ) diff --git a/svtools/source/uno/genericunodialog.cxx b/svtools/source/uno/genericunodialog.cxx index 7f1b54b49fc5..1a6fab51fd62 100644 --- a/svtools/source/uno/genericunodialog.cxx +++ b/svtools/source/uno/genericunodialog.cxx @@ -168,7 +168,7 @@ bool OGenericUnoDialog::impl_ensureDialog_lck() // get the parameters for the dialog from the current settings // the parent window - vcl::Window* pParent = nullptr; + VclPtr<vcl::Window> pParent; VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParent); if (pImplementation) pParent = pImplementation->GetWindow(); diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index e080edc1d24f..5d6e3567308c 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -1600,7 +1600,7 @@ void SvxSearchDialog::Remember_Impl( const OUString &rStr, bool _bSearch ) return; std::vector<OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings; - ComboBox* pListBox = _bSearch ? m_pSearchLB : m_pReplaceLB; + ComboBox* pListBox = _bSearch ? m_pSearchLB.get() : m_pReplaceLB.get(); // ignore identical strings for (std::vector<OUString>::const_iterator i = pArr->begin(); i != pArr->end(); ++i) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 936b4f6fe924..57f359ea8001 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -479,7 +479,7 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< css::awt::XToolkit >& { VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer); if (pParent) - pParentWin = pParent->GetWindow(); + pParentWin = pParent->GetWindow().get(); } FmXGridPeer* pPeer = imp_CreatePeer(pParentWin); diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index 6ee7271a991c..e6811cc5866c 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -1814,7 +1814,7 @@ namespace svxform XFormsPage* DataNavigatorWindow::GetCurrentPage( sal_uInt16& rCurId ) { rCurId = m_pTabCtrl->GetCurPageId(); - XFormsPage* pPage = nullptr; + VclPtr<XFormsPage> pPage; OString sName(m_pTabCtrl->GetPageName(rCurId)); if (sName == "submissions") { diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 1110e8fc71f2..fc617478d000 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -491,7 +491,7 @@ namespace svx if ( _rxControl.is() ) xControlPeer = _rxControl->getPeer(); if ( xControlPeer.is() ) - pWindow = VCLUnoHelper::GetWindow( xControlPeer ); + pWindow = VCLUnoHelper::GetWindow( xControlPeer ).get(); } catch( const Exception& ) { diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index f1773ea316ca..0a946926297c 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -3513,7 +3513,7 @@ vcl::Window* FormController::getDialogParentWindow() { Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); - pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ); + pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ).get(); } catch( const Exception& ) { diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx index 0467ab6495dd..46897dfc1b9f 100644 --- a/svx/source/svdraw/sdrpaintwindow.cxx +++ b/svx/source/svdraw/sdrpaintwindow.cxx @@ -93,7 +93,7 @@ void CandidateMgr::PaintTransparentChildren(vcl::Window & rWindow, Rectangle con for (auto aI = m_aCandidates.begin(); aI != m_aCandidates.end(); ++aI) { - pCandidate = *aI; + pCandidate = aI->get(); if (m_aDeletedCandidates.find(pCandidate) != m_aDeletedCandidates.end()) continue; //rhbz#1007697 this can cause the window itself to be diff --git a/svx/source/tbxctrls/layctrl.cxx b/svx/source/tbxctrls/layctrl.cxx index b0e707f58cfe..c6acafaffbe0 100644 --- a/svx/source/tbxctrls/layctrl.cxx +++ b/svx/source/tbxctrls/layctrl.cxx @@ -731,7 +731,7 @@ SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl() VclPtr<SfxPopupWindow> SvxColumnsToolBoxControl::CreatePopupWindow() { - ColumnsWindow* pWin = nullptr; + VclPtr<ColumnsWindow> pWin; if(bEnabled) { pWin = VclPtr<ColumnsWindow>::Create( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), m_xFrame ); diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx index 2023bc6bc438..39f6079c8fe3 100644 --- a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx +++ b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx @@ -131,7 +131,7 @@ sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute() throw(uno::RuntimeExc { VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParentWindow); if (pImplementation) - pParent = pImplementation->GetWindow(); + pParent = pImplementation->GetWindow().get(); } uno::Reference< XComponent > xComp( this ); m_pDialog = VclPtr<ChineseTranslationDialog>::Create( pParent ); diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx index cf8b9f83e545..27086a9338f0 100644 --- a/sw/source/ui/dbui/createaddresslistdialog.cxx +++ b/sw/source/ui/dbui/createaddresslistdialog.cxx @@ -314,7 +314,7 @@ void SwAddressControl_Impl::SetCursorTo(sal_uInt32 nElement) { if(nElement < m_aEdits.size()) { - Edit* pEdit = m_aEdits[nElement]; + Edit* pEdit = m_aEdits[nElement].get(); pEdit->GrabFocus(); Rectangle aRect(pEdit->GetPosPixel(), pEdit->GetSizePixel()); MakeVisible(aRect); diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index 07526e03c151..8463afda22ce 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -404,7 +404,7 @@ void SwSelectAddressBlockDialog::SetSettings( RadioButton *pActive = m_pNeverRB; if(bIsCountry) { - pActive = !rCountry.isEmpty() ? m_pDependentRB : m_pAlwaysRB; + pActive = !rCountry.isEmpty() ? m_pDependentRB.get() : m_pAlwaysRB.get(); m_pCountryED->SetText(rCountry); } pActive->Check(); diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx index 54cddf71f813..5bd89925b656 100644 --- a/sw/source/ui/dbui/mmgreetingspage.cxx +++ b/sw/source/ui/dbui/mmgreetingspage.cxx @@ -112,7 +112,7 @@ IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, Button*, pButton, void) SwCustomizeAddressBlockDialog::GREETING_FEMALE )); if(RET_OK == pDlg->Execute()) { - ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB; + ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB.get() : m_pFemaleLB.get(); pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress())); if(m_bIsTabPage) { diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 1312236faf24..b9d850aed94a 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -1952,8 +1952,8 @@ IMPL_LINK_NOARG(SwFramePage, AnchorTypeHdl, Button*, void) IMPL_LINK( SwFramePage, PosHdl, ListBox&, rLB, void ) { bool bHori = &rLB == m_pHorizontalDLB; - ListBox *pRelLB = bHori ? m_pHoriRelationLB : m_pVertRelationLB; - FixedText *pRelFT = bHori ? m_pHoriRelationFT : m_pVertRelationFT; + ListBox *pRelLB = bHori ? m_pHoriRelationLB.get() : m_pVertRelationLB.get(); + FixedText *pRelFT = bHori ? m_pHoriRelationFT.get() : m_pVertRelationFT.get(); FrameMap *pMap = bHori ? m_pHMap : m_pVMap; const sal_Int32 nMapPos = GetMapPos(pMap, rLB); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index d050794b5287..450b5c21299e 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -2730,9 +2730,8 @@ void SwTokenWindow::setAllocation(const Size &rAllocation) return; Size aControlSize(m_pCtrlParentWin->GetSizePixel()); - for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) + for (VclPtr<Control> const & pControl : aControlList) { - Control* pControl = (*it); Size aSize(pControl->GetSizePixel()); aSize.Height() = aControlSize.Height(); pControl->SetSizePixel(aSize); @@ -2746,9 +2745,8 @@ SwTokenWindow::~SwTokenWindow() void SwTokenWindow::dispose() { - for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) + for (VclPtr<Control> & pControl : aControlList) { - VclPtr<Control> pControl = (*it); pControl->SetGetFocusHdl( Link<Control&,void>() ); pControl->SetLoseFocusHdl( Link<Control&,void>() ); pControl.disposeAndClear(); @@ -3194,7 +3192,7 @@ void SwTokenWindow::AdjustPositions() if(aControlList.size() > 1) { ctrl_iterator it = aControlList.begin(); - Control* pCtrl = *it; + Control* pCtrl = it->get(); ++it; Point aNextPos = pCtrl->GetPosPixel(); @@ -3202,7 +3200,7 @@ void SwTokenWindow::AdjustPositions() for(; it != aControlList.end(); ++it) { - pCtrl = *it; + pCtrl = it->get(); pCtrl->SetPosPixel(aNextPos); aNextPos.X() += pCtrl->GetSizePixel().Width(); } @@ -3214,10 +3212,8 @@ void SwTokenWindow::AdjustPositions() void SwTokenWindow::MoveControls(long nOffset) { // move the complete list - for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) + for (VclPtr<Control> const & pCtrl : aControlList) { - Control *pCtrl = *it; - Point aPos = pCtrl->GetPosPixel(); aPos.X() += nOffset; @@ -3281,10 +3277,8 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) //find all start/end positions and print it OUString sMessage("Space: " + OUString::number(nSpace) + " | "); - for (ctrl_const_iterator it = aControlList.begin(); it != aControlList.end(); ++it) + for (VclPtr<Control> const & pDebugCtrl : aControlList) { - Control *pDebugCtrl = *it; - long nDebugXPos = pDebugCtrl->GetPosPixel().X(); long nDebugWidth = pDebugCtrl->GetSizePixel().Width(); @@ -3300,7 +3294,7 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) //find the first completely visible control (left edge visible) for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) { - Control *pCtrl = *it; + Control *pCtrl = it->get(); long nXPos = pCtrl->GetPosPixel().X(); @@ -3316,7 +3310,7 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) //move the left neighbor to the start position ctrl_iterator itLeft = it; --itLeft; - Control *pLeft = *itLeft; + Control *pLeft = itLeft->get(); nMove = -pLeft->GetPosPixel().X(); } @@ -3330,7 +3324,7 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) //find the first completely visible control (right edge visible) for (ctrl_reverse_iterator it = aControlList.rbegin(); it != aControlList.rend(); ++it) { - Control *pCtrl = *it; + Control *pCtrl = it->get(); long nCtrlWidth = pCtrl->GetSizePixel().Width(); long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth; @@ -3342,7 +3336,7 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) //move the right neighbor to the right edge right aligned ctrl_reverse_iterator itRight = it; --itRight; - Control *pRight = *itRight; + Control *pRight = itRight->get(); nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width(); } @@ -3360,10 +3354,10 @@ IMPL_LINK(SwTokenWindow, ScrollHdl, Button*, pBtn, void ) Control *pCtrl = nullptr; - pCtrl = *(aControlList.begin()); + pCtrl = aControlList.begin()->get(); m_pLeftScrollWin->Enable(pCtrl->GetPosPixel().X() < 0); - pCtrl = *(aControlList.rbegin()); + pCtrl = aControlList.rbegin()->get(); m_pRightScrollWin->Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace); } } @@ -3472,7 +3466,7 @@ IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit&, rEdit, void) ctrl_iterator iterFocus = it; rEdit.IsNextControl() ? ++iterFocus : --iterFocus; - Control *pCtrlFocus = *iterFocus; + Control *pCtrlFocus = iterFocus->get(); pCtrlFocus->GrabFocus(); static_cast<SwTOXButton*>(pCtrlFocus)->Check(); @@ -3483,12 +3477,10 @@ IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit&, rEdit, void) IMPL_LINK(SwTokenWindow, TbxFocusHdl, Control&, rControl, void) { SwTOXEdit* pEdit = static_cast<SwTOXEdit*>(&rControl); - for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) + for (VclPtr<Control> const & pCtrl : aControlList) { - Control *pCtrl = *it; - if (pCtrl && pCtrl->GetType() != WINDOW_EDIT) - static_cast<SwTOXButton*>(pCtrl)->Check(false); + static_cast<SwTOXButton*>(pCtrl.get())->Check(false); } SetActiveControl(pEdit); @@ -3511,7 +3503,7 @@ IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton&, rBtn, void ) ctrl_iterator iterFocus = it; isNext ? ++iterFocus : --iterFocus; - Control *pCtrlFocus = *iterFocus; + Control *pCtrlFocus = iterFocus->get(); pCtrlFocus->GrabFocus(); Selection aSel(0,0); @@ -3536,7 +3528,7 @@ IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, Control&, rControl, void ) SwTOXButton* pBtn = static_cast<SwTOXButton*>(&rControl); for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) { - Control *pControl = *it; + Control *pControl = it->get(); if (pControl && WINDOW_EDIT != pControl->GetType()) static_cast<SwTOXButton*>(pControl)->Check(pBtn == pControl); diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index eff2461e784c..7c555b262c8e 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -640,7 +640,7 @@ void SwDocShell::Execute(SfxRequest& rReq) // the SourceView is not the 1 for SwWebDocShell sal_uInt16 nSlot = SID_VIEWSHELL1; bool bSetModified = false; - SfxPrinter* pSavePrinter = nullptr; + VclPtr<SfxPrinter> pSavePrinter; if( nullptr != pSrcView) { SfxPrinter* pTemp = GetDoc()->getIDocumentDeviceAccess().getPrinter( false ); diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 4199cc0f9792..8b2656a49c65 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -620,7 +620,7 @@ void SwPostItMgr::LayoutPostIts() for(SwSidebarItem_iterator i = pPage->mList->begin(); i != pPage->mList->end(); ++i) { SwSidebarItem* pItem = (*i); - SwSidebarWin* pPostIt = pItem->pPostIt; + VclPtr<SwSidebarWin> pPostIt = pItem->pPostIt; if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) { @@ -657,7 +657,7 @@ void SwPostItMgr::LayoutPostIts() if (mpAnswer) { if (pPostIt->CalcFollow()) //do we really have another note in front of this one - static_cast<sw::annotation::SwAnnotationWin*>(pPostIt)->InitAnswer(mpAnswer); + static_cast<sw::annotation::SwAnnotationWin*>(pPostIt.get())->InitAnswer(mpAnswer); delete mpAnswer; mpAnswer = nullptr; } diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx index 8410554d2612..86ab25ce80bb 100644 --- a/toolkit/source/awt/stylesettings.cxx +++ b/toolkit/source/awt/stylesettings.cxx @@ -134,7 +134,7 @@ namespace toolkit { sal_Int32 lcl_getStyleColor( WindowStyleSettings_Data& i_rData, Color const & (StyleSettings::*i_pGetter)() const ) { - const vcl::Window* pWindow = i_rData.pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = i_rData.pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return (aStyleSettings.*i_pGetter)().GetColor(); @@ -152,7 +152,7 @@ namespace toolkit FontDescriptor lcl_getStyleFont( WindowStyleSettings_Data& i_rData, vcl::Font const & (StyleSettings::*i_pGetter)() const ) { - const vcl::Window* pWindow = i_rData.pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = i_rData.pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return VCLUnoHelper::CreateFontDescriptor( (aStyleSettings.*i_pGetter)() ); @@ -385,7 +385,7 @@ namespace toolkit ::sal_Int32 SAL_CALL WindowStyleSettings::getFaceGradientColor() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetFaceGradientColor().GetColor(); @@ -675,7 +675,7 @@ namespace toolkit ::sal_Int32 SAL_CALL WindowStyleSettings::getSeparatorColor() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetSeparatorColor().GetColor(); @@ -741,7 +741,7 @@ namespace toolkit sal_Bool SAL_CALL WindowStyleSettings::getHighContrastMode() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetHighContrastMode(); diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 12948c3e8d67..116e77cb68ff 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -831,7 +831,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, OUString aServiceName( rDescriptor.WindowServiceName ); aServiceName = aServiceName.toAsciiLowerCase(); - vcl::Window* pNewWindow = nullptr; + VclPtr<vcl::Window> pNewWindow; sal_uInt16 nType = ImplGetComponentType( aServiceName ); bool bFrameControl = false; if ( aServiceName == "frame" ) @@ -886,7 +886,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_COMBOBOX: pNewWindow = VclPtr<ComboBox>::Create( pParent, nWinBits|WB_AUTOHSCROLL ); - static_cast<ComboBox*>(pNewWindow)->EnableAutoSize( false ); + static_cast<ComboBox*>(pNewWindow.get())->EnableAutoSize( false ); *ppNewComp = new VCLXComboBox; break; case WINDOW_CURRENCYBOX: @@ -894,18 +894,18 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_CURRENCYFIELD: pNewWindow = VclPtr<CurrencyField>::Create( pParent, nWinBits ); - static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<CurrencyField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow.get())) ); break; case WINDOW_DATEBOX: pNewWindow = VclPtr<DateBox>::Create( pParent, nWinBits ); break; case WINDOW_DATEFIELD: pNewWindow = VclPtr<DateField>::Create( pParent, nWinBits ); - static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<DateField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXDateField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow.get())) ); break; case WINDOW_DOCKINGAREA: pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent ); @@ -940,7 +940,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = VclPtr<GroupBox>::Create( pParent, nWinBits ); if ( bFrameControl ) { - GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow ); + GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow.get() ); *ppNewComp = new VCLXFrame; // Frame control needs to receive // Mouse events @@ -961,7 +961,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_LISTBOX: pNewWindow = VclPtr<ListBox>::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); - static_cast<ListBox*>(pNewWindow)->EnableAutoSize( false ); + static_cast<ListBox*>(pNewWindow.get())->EnableAutoSize( false ); *ppNewComp = new VCLXListBox; break; case WINDOW_LONGCURRENCYBOX: @@ -970,7 +970,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_LONGCURRENCYFIELD: pNewWindow = VclPtr<LongCurrencyField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXCurrencyField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<LongCurrencyField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<LongCurrencyField*>(pNewWindow.get())) ); break; case WINDOW_MENUBUTTON: pNewWindow = VclPtr<MenuButton>::Create( pParent, nWinBits ); @@ -986,7 +986,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_METRICFIELD: pNewWindow = VclPtr<MetricField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXMetricField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow.get())) ); break; case WINDOW_DIALOG: case WINDOW_MODALDIALOG: @@ -1020,9 +1020,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_NUMERICFIELD: pNewWindow = VclPtr<NumericField>::Create( pParent, nWinBits ); - static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<NumericField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<NumericField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<NumericField*>(pNewWindow.get())) ); break; case WINDOW_OKBUTTON: pNewWindow = VclPtr<OKButton>::Create( pParent, nWinBits ); @@ -1034,7 +1034,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_PATTERNFIELD: pNewWindow = VclPtr<PatternField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXPatternField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow.get())) ); break; case WINDOW_PUSHBUTTON: pNewWindow = VclPtr<PushButton>::Create( pParent, nWinBits ); @@ -1057,7 +1057,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // is not really valid: the controls are grouped after they have been created, but we're still in // the creation process, so the RadioButton::Check relies on invalid grouping information. // 07.08.2001 - #87254# - frank.schoenheit@sun.com - static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( false ); + static_cast<RadioButton*>(pNewWindow.get())->EnableRadioCheck( false ); break; case WINDOW_SCROLLBAR: pNewWindow = VclPtr<ScrollBar>::Create( pParent, nWinBits ); @@ -1105,9 +1105,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_TIMEFIELD: pNewWindow = VclPtr<TimeField>::Create( pParent, nWinBits ); - static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<TimeField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXTimeField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow.get())) ); break; case WINDOW_TOOLBOX: pNewWindow = VclPtr<ToolBox>::Create( pParent, nWinBits ); @@ -1256,7 +1256,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( css::uno::Reference< css::awt::XWindowPeer > xRef; - vcl::Window* pParent = nullptr; + VclPtr<vcl::Window> pParent; if ( rDescriptor.Parent.is() ) { VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent ); diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index f8b90098c78f..e4a449925886 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -2480,10 +2480,10 @@ sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (css::uno::RuntimeExceptio void SAL_CALL VCLXWindow::setOutputSize( const css::awt::Size& aSize ) throw (css::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - vcl::Window *pWindow; + VclPtr<vcl::Window> pWindow; if( (pWindow = GetWindow()) != nullptr ) { - DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow.get()); if( pDockingWindow ) pDockingWindow->SetOutputSizePixel( VCLSize( aSize ) ); else @@ -2494,10 +2494,10 @@ void SAL_CALL VCLXWindow::setOutputSize( const css::awt::Size& aSize ) throw (cs css::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) throw (css::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - vcl::Window *pWindow; + VclPtr<vcl::Window> pWindow; if( (pWindow = GetWindow()) != nullptr ) { - DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow.get()); if( pDockingWindow ) return AWTSize( pDockingWindow->GetOutputSizePixel() ); else diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index e6c8dfcbcdac..a1d977f53c68 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -152,7 +152,7 @@ css::uno::Reference< css::awt::XWindow> VCLUnoHelper::GetInterface( vcl::Window* OutputDevice* VCLUnoHelper::GetOutputDevice( const css::uno::Reference< css::awt::XDevice>& rxDevice ) { - OutputDevice* pOutDev = nullptr; + VclPtr<OutputDevice> pOutDev; VCLXDevice* pDev = VCLXDevice::GetImplementation( rxDevice ); if ( pDev ) pOutDev = pDev->GetOutputDevice(); diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index d63011b4cb2e..90f11d766732 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -502,7 +502,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHe if (rHelpText.isEmpty() && !pSVData->maHelpData.mbRequestingHelp) return; - HelpTextWindow* pHelpWin = pSVData->maHelpData.mpHelpWin; + VclPtr<HelpTextWindow> pHelpWin = pSVData->maHelpData.mpHelpWin; sal_uInt16 nDelayMode = HELPDELAY_NORMAL; if ( pHelpWin ) { diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index cb0cb8b3d68e..025c80f26cb1 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -2201,9 +2201,8 @@ void RadioButton::group(RadioButton &rOther) } //make all members of the group share the same button group - for (auto aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI) + for (VclPtr<RadioButton> const & pButton : *m_xGroup) { - RadioButton* pButton = *aI; pButton->m_xGroup = m_xGroup; } } @@ -2220,9 +2219,8 @@ std::vector< VclPtr<RadioButton> > RadioButton::GetRadioButtonGroup(bool bInclud if (bIncludeThis) return *m_xGroup; std::vector< VclPtr<RadioButton> > aGroup; - for (auto aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI) + for (VclPtr<RadioButton> const & pRadioButton : *m_xGroup) { - RadioButton *pRadioButton = *aI; if (pRadioButton == this) continue; aGroup.push_back(pRadioButton); diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index 55c9d3071d36..ab2ac82bee85 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -605,11 +605,10 @@ vcl::Window* Window::GetAccessibleRelationLabeledBy() const if (!aMnemonicLabels.empty()) { //if we have multiple labels, then prefer the first that is visible - for (auto aI = aMnemonicLabels.begin(), aEnd = aMnemonicLabels.end(); aI != aEnd; ++aI) + for (auto const & rCandidate : aMnemonicLabels) { - vcl::Window *pCandidate = *aI; - if (pCandidate->IsVisible()) - return pCandidate; + if (rCandidate->IsVisible()) + return rCandidate; } return aMnemonicLabels[0]; } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index a3d626964eaf..32bd8b8e9d29 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -472,11 +472,8 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr } //fdo#67378 merge the label into the disclosure button - for (auto aI = m_pParserState->m_aExpanderWidgets.begin(), - aEnd = m_pParserState->m_aExpanderWidgets.end(); aI != aEnd; ++aI) + for (VclPtr<VclExpander> const & pOne : m_pParserState->m_aExpanderWidgets) { - VclExpander *pOne = *aI; - vcl::Window *pChild = pOne->get_child(); vcl::Window* pLabel = pOne->GetWindow(GetWindowType::LastChild); if (pLabel && pLabel != pChild && pLabel->GetType() == WINDOW_FIXEDTEXT) @@ -2111,7 +2108,7 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader) { if (name.equals("object") || name.equals("placeholder")) { - pCurrentChild = handleObject(pParent, reader); + pCurrentChild = handleObject(pParent, reader).get(); bool bObjectInserted = pCurrentChild && pParent != pCurrentChild; diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 74d529c7d2c7..0727b30c1e5f 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2476,9 +2476,9 @@ void MenuBar::SetDisplayable( bool bDisplayable ) } } -vcl::Window* MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu) +VclPtr<vcl::Window> MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu) { - MenuBarWindow *pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow); + VclPtr<MenuBarWindow> pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow); if (!pMenuBarWindow) { pWindow = pMenuBarWindow = VclPtr<MenuBarWindow>::Create( pParent ); diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 938b2318a1bb..100f12120f1c 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -925,7 +925,7 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) { MenuBar* pOldMenuBar = mpMenuBar; vcl::Window* pOldWindow = nullptr; - vcl::Window* pNewWindow=nullptr; + VclPtr<vcl::Window> pNewWindow; mpMenuBar = pMenuBar; if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) ) diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx index b5d1738de2d8..0cd840779a5a 100644 --- a/vcl/source/window/taskpanelist.cxx +++ b/vcl/source/window/taskpanelist.cxx @@ -176,7 +176,7 @@ bool TaskPaneList::HandleKeyEvent(const KeyEvent& rKeyEvent) auto p = mTaskPanes.begin(); while( p != mTaskPanes.end() ) { - vcl::Window *pWin = *p; + vcl::Window *pWin = p->get(); if( pWin->HasChildPathFocus( true ) ) { // Ctrl-F6 goes directly to the document @@ -252,7 +252,7 @@ vcl::Window* TaskPaneList::FindNextSplitter( vcl::Window *pWindow ) p = mTaskPanes.begin(); if( (*p)->ImplIsSplitter() && (*p)->IsReallyVisible() && !(*p)->IsDialog() && (*p)->GetParent()->HasChildPathFocus() ) { - pWindow = *p; + pWindow = (*p).get(); break; } if( !pWindow ) // increment after test, otherwise first element is skipped @@ -291,7 +291,7 @@ vcl::Window* TaskPaneList::FindNextFloat( vcl::Window *pWindow, bool bForward ) if( (*p)->IsReallyVisible() && !(*p)->ImplIsSplitter() && ( (*p)->GetType() != WINDOW_MENUBARWINDOW || static_cast<MenuBarWindow*>(p->get())->CanGetFocus() ) ) { - pWindow = *p; + pWindow = (*p).get(); break; } if( !pWindow ) // increment after test, otherwise first element is skipped diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 029de6e45482..7d51ab3d1582 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -5591,7 +5591,7 @@ void ToolBox::ImplShowFocus() ImplToolItem* pItem = ImplGetItem( mnHighItemId ); if( pItem->mpWindow && !pItem->mpWindow->IsDisposed() ) { - vcl::Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow; + vcl::Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow.get() : pItem->mpWindow.get(); pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = true; pWin->Invalidate(); } @@ -5605,7 +5605,7 @@ void ToolBox::ImplHideFocus() ImplToolItem* pItem = ImplGetItem( mnHighItemId ); if( pItem && pItem->mpWindow ) { - vcl::Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow : pItem->mpWindow; + vcl::Window *pWin = pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow ? pItem->mpWindow->ImplGetWindowImpl()->mpBorderWindow.get() : pItem->mpWindow.get(); pWin->ImplGetWindowImpl()->mbDrawSelectionBackground = false; pWin->Invalidate(); } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 9e42f3ce36e3..e08fcd2b1a82 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1386,9 +1386,8 @@ void Window::queue_resize(StateChangedType eReason) if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VCL_SIZE_GROUP_NONE) { std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets(); - for (auto aI = rWindows.begin(), aEnd = rWindows.end(); aI != aEnd; ++aI) + for (VclPtr<vcl::Window> const & pOther : rWindows) { - vcl::Window *pOther = *aI; if (pOther == this) continue; queue_ungrouped_resize(pOther); |