diff options
author | Noel Grandin <noel@peralex.com> | 2015-07-13 16:17:00 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-08-03 06:37:16 +0000 |
commit | 2660d24a07866e083c5135ea263030f3e3a2e729 (patch) | |
tree | 0089d6018d4fc33a7fde955e585e77191cdd258b /sc/source | |
parent | baba1d14766282bd2c592bffd79ed69f9078cfe1 (diff) |
new loplugin: refcounting
This was a feature requested by mmeeks, as a result of
tdf#92611.
It validates that things that extend XInterface are not
directly heap/stack-allocated, but have their lifecycle managed
via css::uno::Reference or rtl::Reference.
Change-Id: I28e3b8b236f6a4a56d0a6d6f26ad54e44b36e692
Reviewed-on: https://gerrit.libreoffice.org/16924
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/dbgui/csvcontrol.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/csvgrid.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/dbgui/csvruler.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/csvtablebox.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/csvcontrol.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/csvgrid.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/csvruler.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/csvtablebox.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/vba/vbafont.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/vba/vbawindow.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/vba/vbawindows.cxx | 4 |
14 files changed, 45 insertions, 44 deletions
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx index b53b5bc5549d..583b5101b9b2 100644 --- a/sc/source/ui/dbgui/csvcontrol.cxx +++ b/sc/source/ui/dbgui/csvcontrol.cxx @@ -300,7 +300,7 @@ ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd ) ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible() { - mxAccessible = ImplCreateAccessible(); + mxAccessible = ImplCreateAccessible().get(); return XAccessibleRef(mxAccessible.get()); } diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index 069edcf44f5a..71301e0e4b9a 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -1357,11 +1357,11 @@ void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex ) // accessibility ============================================================== -ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible() +rtl::Reference<ScAccessibleCsvControl> ScCsvGrid::ImplCreateAccessible() { - std::unique_ptr<ScAccessibleCsvControl> pControl(new ScAccessibleCsvGrid( *this )); + rtl::Reference<ScAccessibleCsvControl> pControl(new ScAccessibleCsvGrid( *this )); pControl->Init(); - return pControl.release(); + return pControl; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index d6ad878320b8..abe53759067c 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -654,7 +654,7 @@ void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos ) // accessibility ============================================================== -ScAccessibleCsvControl* ScCsvRuler::ImplCreateAccessible() +rtl::Reference<ScAccessibleCsvControl> ScCsvRuler::ImplCreateAccessible() { return new ScAccessibleCsvRuler( *this ); } diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx index 785cb91b71d3..9ecbfb06a234 100644 --- a/sc/source/ui/dbgui/csvtablebox.cxx +++ b/sc/source/ui/dbgui/csvtablebox.cxx @@ -22,6 +22,7 @@ #include <vcl/lstbox.hxx> #include <vcl/settings.hxx> #include "editutil.hxx" +#include "AccessibleCsvControl.hxx" ScCsvTableBox::ScCsvTableBox( vcl::Window* pParent, WinBits nBits ) : ScCsvControl( pParent, maData, nBits ), @@ -426,9 +427,9 @@ ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible() return Control::CreateAccessible(); } -ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible() +rtl::Reference<ScAccessibleCsvControl> ScCsvTableBox::ImplCreateAccessible() { - return NULL; // not used, see CreateAccessible() + return rtl::Reference<ScAccessibleCsvControl>(); // not used, see CreateAccessible() } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx index 0c9edb80da2c..82cad60856b4 100644 --- a/sc/source/ui/inc/csvcontrol.hxx +++ b/sc/source/ui/inc/csvcontrol.hxx @@ -383,7 +383,7 @@ public: protected: /** Derived classes create a new accessible object here. */ - virtual ScAccessibleCsvControl* ImplCreateAccessible() = 0; + virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() = 0; }; #endif diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx index 85c71c1fcabc..4dc3e0ea8002 100644 --- a/sc/source/ui/inc/csvgrid.hxx +++ b/sc/source/ui/inc/csvgrid.hxx @@ -323,7 +323,7 @@ private: // accessibility ---------------------------------------------------------- protected: /** Creates a new accessible object. */ - virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE; + virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE; }; #endif diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx index 44f8a765bddb..ab2fb01c997f 100644 --- a/sc/source/ui/inc/csvruler.hxx +++ b/sc/source/ui/inc/csvruler.hxx @@ -176,7 +176,7 @@ private: // accessibility ---------------------------------------------------------- protected: /** Creates a new accessible object. */ - virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE; + virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE; }; #endif diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx index 4386d78da164..e7bfd347b653 100644 --- a/sc/source/ui/inc/csvtablebox.hxx +++ b/sc/source/ui/inc/csvtablebox.hxx @@ -134,7 +134,7 @@ public: protected: /** Creates a new accessible object. */ - virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE; + virtual rtl::Reference<ScAccessibleCsvControl> ImplCreateAccessible() SAL_OVERRIDE; }; #endif diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 6f0a83569789..f2f8193fd663 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5660,27 +5660,27 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation? ScDocShell* pDocSh = GetDocShell(); - ScFilterDescriptor aImpl(pDocSh); + uno::Reference<ScFilterDescriptor> xImpl(new ScFilterDescriptor(pDocSh)); uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY ); if ( xDescriptor2.is() ) { - aImpl.setFilterFields2( xDescriptor2->getFilterFields2() ); + xImpl->setFilterFields2( xDescriptor2->getFilterFields2() ); } else { - aImpl.setFilterFields( xDescriptor->getFilterFields() ); + xImpl->setFilterFields( xDescriptor->getFilterFields() ); } // Rest sind jetzt Properties... uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY ); if (xPropSet.is()) - lcl_CopyProperties( aImpl, *xPropSet.get() ); + lcl_CopyProperties( *xImpl.get(), *xPropSet.get() ); // ausfuehren... if (pDocSh) { - ScQueryParam aParam = aImpl.GetParam(); + ScQueryParam aParam = xImpl->GetParam(); // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aRange.aStart.Col()) : diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 755b7aa8477f..bc67a5b5c977 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -3359,9 +3359,9 @@ uno::Reference< util::XCloneable > SAL_CALL ScChart2DataSequence::createClone() } } - unique_ptr<ScChart2DataSequence> p(new ScChart2DataSequence(m_pDocument, m_xDataProvider, pTokensNew.release(), m_bIncludeHiddenCells)); + uno::Reference<ScChart2DataSequence> p(new ScChart2DataSequence(m_pDocument, m_xDataProvider, pTokensNew.release(), m_bIncludeHiddenCells)); p->CopyData(*this); - Reference< util::XCloneable > xClone(p.release()); + Reference< util::XCloneable > xClone(p); return xClone; } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index fd9cb632d381..979edea06012 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1910,17 +1910,17 @@ void SAL_CALL ScModelObj::consolidate( // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren: //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation? - ScConsolidationDescriptor aImpl; - aImpl.setFunction( xDescriptor->getFunction() ); - aImpl.setSources( xDescriptor->getSources() ); - aImpl.setStartOutputPosition( xDescriptor->getStartOutputPosition() ); - aImpl.setUseColumnHeaders( xDescriptor->getUseColumnHeaders() ); - aImpl.setUseRowHeaders( xDescriptor->getUseRowHeaders() ); - aImpl.setInsertLinks( xDescriptor->getInsertLinks() ); + uno::Reference< ScConsolidationDescriptor > xImpl(new ScConsolidationDescriptor); + xImpl->setFunction( xDescriptor->getFunction() ); + xImpl->setSources( xDescriptor->getSources() ); + xImpl->setStartOutputPosition( xDescriptor->getStartOutputPosition() ); + xImpl->setUseColumnHeaders( xDescriptor->getUseColumnHeaders() ); + xImpl->setUseRowHeaders( xDescriptor->getUseRowHeaders() ); + xImpl->setInsertLinks( xDescriptor->getInsertLinks() ); if (pDocShell) { - const ScConsolidateParam& rParam = aImpl.GetParam(); + const ScConsolidateParam& rParam = xImpl->GetParam(); pDocShell->DoConsolidate( rParam, true ); pDocShell->GetDocument().SetConsolidateDlgData( &rParam ); } diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 7d3cde109188..eddb2f392611 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -84,8 +84,8 @@ ScVbaFont::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeExceptio for ( sal_Int32 row = 0; row < nRows; ++row ) { uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW ); - ScVbaFont aFont( getParent(), mxContext, mPalette, xProps ); - aFont.setSuperscript( aValue ); + uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) ); + aFont->setSuperscript( aValue ); } } return; @@ -124,10 +124,10 @@ ScVbaFont::getSuperscript() throw ( uno::RuntimeException, std::exception ) for ( sal_Int32 row = 0; row < nRows; ++row ) { uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW ); - ScVbaFont aFont( getParent(), mxContext, mPalette, xProps ); + uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) ); if ( !col && !row ) - aRes = aFont.getSuperscript(); - else if ( aRes != aFont.getSuperscript() ) + aRes = aFont->getSuperscript(); + else if ( aRes != aFont->getSuperscript() ) return aNULL(); } } @@ -156,8 +156,8 @@ ScVbaFont::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException, for ( sal_Int32 row = 0; row < nRows; ++row ) { uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW ); - ScVbaFont aFont( getParent(), mxContext, mPalette, xProps ); - aFont.setSubscript( aValue ); + uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) ); + aFont->setSubscript( aValue ); } } return; @@ -198,10 +198,10 @@ ScVbaFont::getSubscript() throw ( uno::RuntimeException, std::exception ) for ( sal_Int32 row = 0; row < nRows; ++row ) { uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW ); - ScVbaFont aFont( getParent(), mxContext, mPalette, xProps ); + uno::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) ); if ( !col && !row ) - aRes = aFont.getSubscript(); - else if ( aRes != aFont.getSubscript() ) + aRes = aFont->getSubscript(); + else if ( aRes != aFont->getSubscript() ) return aNULL(); } } diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index 57adf47664e6..6ed0c840c697 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -315,8 +315,8 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException, std::exception) if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() ) { sTitle = sTitle.copy( 0, nCrudIndex ); - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); - OUString sName = workbook.getName(); + uno::Reference< ScVbaWorkbook > workbook( new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ) ); + OUString sName = workbook->getName(); // rather bizarre hack to make sure the name behavior // is like XL // if the adjusted title == workbook name, use name @@ -447,16 +447,16 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE void ScVbaWindow::Activate() throw (css::uno::RuntimeException, std::exception) { - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); + uno::Reference<ScVbaWorkbook> workbook( new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ) ); - workbook.Activate(); + workbook->Activate(); } void ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException, std::exception) { - ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); - workbook.Close(SaveChanges, FileName, RouteWorkBook ); + uno::Reference< ScVbaWorkbook > workbook( new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ) ); + workbook->Close(SaveChanges, FileName, RouteWorkBook ); } uno::Reference< excel::XPane > SAL_CALL diff --git a/sc/source/ui/vba/vbawindows.cxx b/sc/source/ui/vba/vbawindows.cxx index e70809a51f88..3d4f573ca786 100644 --- a/sc/source/ui/vba/vbawindows.cxx +++ b/sc/source/ui/vba/vbawindows.cxx @@ -128,9 +128,9 @@ public: // !! TODO !! iterate over all controllers uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); uno::Reference< XHelperInterface > xTemp; // temporary needed for g++ 3.3.5 - ScVbaWindow window( xTemp, m_xContext, xModel, xController ); + uno::Reference< ScVbaWindow > window( new ScVbaWindow( xTemp, m_xContext, xModel, xController ) ); OUString sCaption; - window.getCaption() >>= sCaption; + window->getCaption() >>= sCaption; namesToIndices[ sCaption ] = nIndex++; } } |