Kaydet (Commit) ccb2a1f6 authored tarafından Noel Grandin's avatar Noel Grandin

clang-tidy readability-redundant-smartptr-get

redundant get() call on smart pointer

Change-Id: Icb5a03bbc15e79a30d3d135a507d22914d15c2bd
Reviewed-on: https://gerrit.libreoffice.org/61837
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst da5c3a1e
......@@ -1421,7 +1421,7 @@ void SAL_CALL Document::disposing()
{
m_aEngineListener.endListening();
m_aViewListener.endListening();
if (m_xParagraphs.get() != nullptr)
if (m_xParagraphs != nullptr)
disposeParagraphs();
VCLXAccessibleComponent::disposing();
}
......@@ -1609,7 +1609,7 @@ IMPL_LINK(Document, WindowEventHandler, ::VclWindowEvent&, rEvent, void)
void Document::init()
{
if (m_xParagraphs.get() == nullptr)
if (m_xParagraphs == nullptr)
{
const sal_uInt32 nCount = m_rEngine.GetParagraphCount();
m_xParagraphs.reset(new Paragraphs);
......
......@@ -397,13 +397,13 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
}
}
if( !xRet.is() && !xGraphic.get() )
if (!xRet.is() && !xGraphic)
{
const BitmapEx aBmpEx(AVMEDIA_BMP_EMPTYLOGO);
xGraphic.reset( new Graphic( aBmpEx ) );
}
if( xGraphic.get() )
if (xGraphic)
xRet = xGraphic->GetXGraphic();
return xRet;
......
......@@ -631,14 +631,14 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
}
const SfxUnoAnyItem* pDocModelItem = rReq.GetArg<SfxUnoAnyItem>(SID_BASICIDE_ARG_DOCUMENT_MODEL);
if ( !pDocument.get() && pDocModelItem )
if (!pDocument && pDocModelItem)
{
uno::Reference< frame::XModel > xModel( pDocModelItem->GetValue(), UNO_QUERY );
if ( xModel.is() )
pDocument.reset( new ScriptDocument( xModel ) );
}
if ( !pDocument.get() )
if (!pDocument)
break;
const SfxStringItem* pLibNameItem = rReq.GetArg<SfxStringItem>(SID_BASICIDE_ARG_LIBNAME);
......
......@@ -302,7 +302,7 @@ namespace basctl
m_xDocModify.clear();
m_xScriptAccess.clear();
if ( m_pDocListener.get() )
if (m_pDocListener)
m_pDocListener->dispose();
}
......
......@@ -1013,7 +1013,7 @@ void BasicManager::CheckModules( StarBASIC* pLib, bool bReference )
for ( const auto& pModule: pLib->GetModules() )
{
DBG_ASSERT( pModule.get(), "Module not received!" );
DBG_ASSERT(pModule, "Module not received!");
if ( !pModule->IsCompiled() && !StarBASIC::GetErrorCode() )
{
pModule->Compile();
......
......@@ -2546,7 +2546,7 @@ void SbUserFormModule::Unload()
m_xDialog.clear(); //release ref to the uno object
SbxValues aVals;
bool bWaitForDispose = true; // assume dialog is showing
if ( m_DialogListener.get() )
if (m_DialogListener)
{
bWaitForDispose = m_DialogListener->isShowing();
SAL_INFO("basic", "Showing " << bWaitForDispose );
......
......@@ -607,7 +607,8 @@ bool Bridge::makeCall(
decrementActiveCalls();
decrementCalls();
}
if (resp.get() == nullptr) {
if (resp == nullptr)
{
throw css::lang::DisposedException(
"Binary URP bridge disposed during call",
static_cast< cppu::OWeakObject * >(this));
......
......@@ -78,8 +78,7 @@ void ElapsedTime::adjustTimer( double fOffset )
double ElapsedTime::getCurrentTime() const
{
return m_pTimeBase.get() == nullptr
? getSystemTime() : m_pTimeBase->getElapsedTimeImpl();
return m_pTimeBase == nullptr ? getSystemTime() : m_pTimeBase->getElapsedTimeImpl();
}
double ElapsedTime::getElapsedTime() const
......
......@@ -86,7 +86,7 @@ namespace canvas
bool PropertySetHelper::isPropertyName( const OUString& aPropertyName ) const
{
if( !mpMap.get() )
if (!mpMap)
return false;
Callbacks aDummy;
......@@ -104,9 +104,7 @@ namespace canvas
const uno::Any& aValue )
{
Callbacks aCallbacks;
if( !mpMap.get() ||
!mpMap->lookup( aPropertyName,
aCallbacks ) )
if (!mpMap || !mpMap->lookup(aPropertyName, aCallbacks))
{
throwUnknown( aPropertyName );
}
......@@ -120,9 +118,7 @@ namespace canvas
uno::Any PropertySetHelper::getPropertyValue( const OUString& aPropertyName ) const
{
Callbacks aCallbacks;
if( !mpMap.get() ||
!mpMap->lookup( aPropertyName,
aCallbacks ) )
if (!mpMap || !mpMap->lookup(aPropertyName, aCallbacks))
{
throwUnknown( aPropertyName );
}
......
......@@ -558,7 +558,7 @@ void DataBrowser::clearHeaders()
void DataBrowser::RenewTable()
{
if( ! m_apDataBrowserModel.get())
if (!m_apDataBrowserModel)
return;
long nOldRow = GetCurRow();
......@@ -636,7 +636,7 @@ void DataBrowser::RenewTable()
OUString DataBrowser::GetColString( sal_Int32 nColumnId ) const
{
OSL_ASSERT( m_apDataBrowserModel.get());
OSL_ASSERT(m_apDataBrowserModel);
if( nColumnId > 0 )
return m_apDataBrowserModel->getRoleOfColumn( nColumnId - 1 );
return OUString();
......@@ -1119,14 +1119,14 @@ void DataBrowser::InitController(
bool DataBrowser::CellContainsNumbers( sal_uInt16 nCol ) const
{
if( ! m_apDataBrowserModel.get())
if (!m_apDataBrowserModel)
return false;
return m_apDataBrowserModel->getCellType( lcl_getColumnInData( nCol )) == DataBrowserModel::NUMBER;
}
sal_uInt32 DataBrowser::GetNumberFormatKey( sal_uInt16 nCol ) const
{
if( ! m_apDataBrowserModel.get())
if (!m_apDataBrowserModel)
return 0;
return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ) );
}
......
......@@ -279,7 +279,7 @@ private:
void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
{
OSL_ASSERT( m_apDialogModel.get());
OSL_ASSERT(m_apDialogModel);
Reference< chart2::XInternalDataProvider > xDataProvider(
m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
......@@ -400,7 +400,7 @@ void DataBrowserModel::insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex )
{
//create a new text column for complex categories
OSL_ASSERT( m_apDialogModel.get());
OSL_ASSERT(m_apDialogModel);
Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
if (!xDataProvider.is())
return;
......@@ -438,7 +438,7 @@ void DataBrowserModel::removeComplexCategoryLevel( sal_Int32 nAtColumnIndex )
void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex )
{
OSL_ASSERT( m_apDialogModel.get());
OSL_ASSERT(m_apDialogModel);
if (nAtColumnIndex < 0 || static_cast<size_t>(nAtColumnIndex) >= m_aColumns.size())
// Out of bound.
return;
......@@ -507,7 +507,7 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu
void DataBrowserModel::swapDataSeries( sal_Int32 nFirstColumnIndex )
{
OSL_ASSERT( m_apDialogModel.get());
OSL_ASSERT(m_apDialogModel);
if( static_cast< tDataColumnVector::size_type >( nFirstColumnIndex ) < m_aColumns.size() - 1 )
{
Reference< chart2::XDataSeries > xSeries( m_aColumns[nFirstColumnIndex].m_xDataSeries );
......@@ -521,7 +521,7 @@ void DataBrowserModel::swapDataSeries( sal_Int32 nFirstColumnIndex )
void DataBrowserModel::swapDataPointForAllSeries( sal_Int32 nFirstIndex )
{
OSL_ASSERT( m_apDialogModel.get());
OSL_ASSERT(m_apDialogModel);
Reference< chart2::XInternalDataProvider > xDataProvider(
m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
// lockControllers
......
......@@ -42,7 +42,7 @@ TimerTriggeredControllerLock::~TimerTriggeredControllerLock()
void TimerTriggeredControllerLock::startTimer()
{
if(!m_apControllerLockGuard.get())
if (!m_apControllerLockGuard)
m_apControllerLockGuard.reset( new ControllerLockGuardUNO(m_xModel) );
m_aTimer.Start();
}
......
......@@ -192,7 +192,7 @@ void ErrorBarResources::SetChartDocumentForRangeChoosing(
m_apRangeSelectionHelper.reset( new RangeSelectionHelper( xChartDocument ));
// has internal data provider => rename "cell range" to "from data"
OSL_ASSERT( m_apRangeSelectionHelper.get());
OSL_ASSERT(m_apRangeSelectionHelper);
if( m_bHasInternalDataProvider )
{
m_xRbRange->set_label(m_xUIStringRbRange->get_label());
......@@ -435,8 +435,8 @@ IMPL_LINK_NOARG(ErrorBarResources, IndicatorChanged, weld::ToggleButton&, void)
IMPL_LINK(ErrorBarResources, ChooseRange, weld::Button&, rButton, void)
{
OSL_ASSERT( m_apRangeSelectionHelper.get());
if( ! m_apRangeSelectionHelper.get())
OSL_ASSERT(m_apRangeSelectionHelper);
if (!m_apRangeSelectionHelper)
return;
OSL_ASSERT( m_pCurrentRangeChoosingField == nullptr );
......@@ -665,8 +665,8 @@ void ErrorBarResources::FillValueSets()
void ErrorBarResources::listeningFinished(
const OUString & rNewRange )
{
OSL_ASSERT( m_apRangeSelectionHelper.get());
if( ! m_apRangeSelectionHelper.get())
OSL_ASSERT(m_apRangeSelectionHelper);
if (!m_apRangeSelectionHelper)
return;
// rNewRange becomes invalid after removing the listener
......@@ -697,8 +697,8 @@ void ErrorBarResources::listeningFinished(
void ErrorBarResources::disposingRangeSelection()
{
OSL_ASSERT( m_apRangeSelectionHelper.get());
if( m_apRangeSelectionHelper.get())
OSL_ASSERT(m_apRangeSelectionHelper);
if (m_apRangeSelectionHelper)
m_apRangeSelectionHelper->stopRangeListening( false );
}
......
......@@ -432,7 +432,7 @@ SplineResourceGroup::SplineResourceGroup(weld::Builder* pBuilder, TabPageParent
SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog()
{
if( !m_xSplinePropertiesDialog.get() )
if (!m_xSplinePropertiesDialog)
{
m_xSplinePropertiesDialog.reset(new SplinePropertiesDialog(m_pParent.GetFrameWeld()));
}
......
......@@ -167,7 +167,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co
SdrPage* pPage = new SdrPage( *pModel, false );
pPage->SetSize(Size(1000,1000));
pModel->InsertPage( pPage, 0 );
std::unique_ptr<SdrView> pView( new SdrView( *pModel.get(), pVDev ) );
std::unique_ptr<SdrView> pView(new SdrView(*pModel, pVDev));
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
......
......@@ -59,7 +59,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel )
if(!pTextObj)
return;
OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
OSL_PRECOND(!m_pTextActionUndoGuard,
"ChartController::StartTextEdit: already have a TextUndoGuard!?");
m_pTextActionUndoGuard.reset( new UndoGuard(
SchResId( STR_ACTION_EDIT_TEXT ), m_xUndoManager ) );
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
......@@ -135,8 +136,8 @@ bool ChartController::EndTextEdit()
TitleHelper::setCompleteString( aString, uno::Reference<
css::chart2::XTitle >::query( xPropSet ), m_xCC );
OSL_ENSURE( m_pTextActionUndoGuard.get(), "ChartController::EndTextEdit: no TextUndoGuard!" );
if ( m_pTextActionUndoGuard.get() )
OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
if (m_pTextActionUndoGuard)
m_pTextActionUndoGuard->commit();
}
m_pTextActionUndoGuard.reset();
......
......@@ -246,7 +246,7 @@ void ChartController::executeDispatch_ScaleText()
ControllerLockGuardUNO aCtlLockGuard( getModel() );
std::unique_ptr<ReferenceSizeProvider> pRefSizeProv(impl_createReferenceSizeProvider());
OSL_ASSERT( pRefSizeProv.get());
OSL_ASSERT(pRefSizeProv);
if (pRefSizeProv)
pRefSizeProv->toggleAutoResizeState();
......
......@@ -1315,11 +1315,11 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
return bReturn;
// handle accelerators
if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() )
if (!m_apAccelExecute && m_xFrame.is() && m_xCC.is())
{
m_apAccelExecute = ::svt::AcceleratorExecute::createAcceleratorHelper();
OSL_ASSERT( m_apAccelExecute.get());
if( m_apAccelExecute.get() )
OSL_ASSERT(m_apAccelExecute);
if (m_apAccelExecute)
m_apAccelExecute->init( m_xCC, m_xFrame );
}
......@@ -1328,7 +1328,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
bool bAlternate = aKeyCode.IsMod2();
bool bCtrl = aKeyCode.IsMod1();
if( m_apAccelExecute.get() )
if (m_apAccelExecute)
bReturn = m_apAccelExecute->execute( aKeyCode );
if( bReturn )
return bReturn;
......
......@@ -522,8 +522,8 @@ void ControllerCommandDispatch::fireStatusEventForURLImpl(
void ControllerCommandDispatch::updateCommandAvailability()
{
bool bModelStateIsValid = ( m_apModelState.get() != nullptr );
bool bControllerStateIsValid = ( m_apControllerState.get() != nullptr );
bool bModelStateIsValid = (m_apModelState != nullptr);
bool bControllerStateIsValid = (m_apControllerState != nullptr);
// Model and controller states exist.
OSL_ASSERT( bModelStateIsValid );
OSL_ASSERT( bControllerStateIsValid );
......
......@@ -614,13 +614,11 @@ void ChartModel::impl_loadGraphics(
::utl::UcbStreamHelper::CreateStream(
xElementStream, true ) );
if( apIStm.get() )
if (apIStm)
{
Graphic aGraphic;
if( !GraphicConverter::Import(
*apIStm.get(),
aGraphic ) )
if (!GraphicConverter::Import(*apIStm, aGraphic))
{
m_aGraphicObjectVector.emplace_back(aGraphic );
}
......
......@@ -118,14 +118,14 @@ void ConfigColorScheme::retrieveConfigColors()
return;
// create config item if necessary
if( ! m_apChartConfigItem.get())
if (!m_apChartConfigItem)
{
m_apChartConfigItem.reset(
new impl::ChartConfigItem( *this ));
m_apChartConfigItem->addPropertyNotification( aSeriesPropName );
}
OSL_ASSERT( m_apChartConfigItem.get());
if( ! m_apChartConfigItem.get())
OSL_ASSERT(m_apChartConfigItem);
if (!m_apChartConfigItem)
return;
// retrieve colors
......
......@@ -56,8 +56,8 @@ OPropertySet::OPropertySet( const OPropertySet & rOther, ::osl::Mutex & par_rMut
m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault(false)
{
MutexGuard aGuard( m_rMutex );
if( rOther.m_pImplProperties.get())
m_pImplProperties.reset( new impl::ImplOPropertySet( * rOther.m_pImplProperties.get()));
if (rOther.m_pImplProperties)
m_pImplProperties.reset(new impl::ImplOPropertySet(*rOther.m_pImplProperties));
}
void OPropertySet::SetNewValuesExplicitlyEvenIfTheyEqualDefault()
......
......@@ -1557,12 +1557,12 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
if( nTextLevel>0 )
{
lcl_shiftLabels( *apTickIter.get(), aCummulatedLabelsDistance );
lcl_shiftLabels(*apTickIter, aCummulatedLabelsDistance);
fRotationAngleDegree = 0.0;
}
aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get()
, pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties )
, fRotationAngleDegree );
aCummulatedLabelsDistance += lcl_getLabelsDistance(
*apTickIter, pTickFactory2D->getDistanceAxisTickToText(m_aAxisProperties),
fRotationAngleDegree);
}
}
}
......@@ -1611,7 +1611,7 @@ void VCartesianAxis::createLabels()
{
if(nTextLevel==0)
{
nScreenDistanceBetweenTicks = TickFactory2D::getTickScreenDistance( *apTickIter.get() );
nScreenDistanceBetweenTicks = TickFactory2D::getTickScreenDistance(*apTickIter);
if( nTextLevelCount>1 )
nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
}
......@@ -1624,7 +1624,8 @@ void VCartesianAxis::createLabels()
}
AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties;
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) )
while (!createTextShapes(m_xTextTarget, *apTickIter, rAxisLabelProperties,
pTickFactory2D, nScreenDistanceBetweenTicks))
{
};
}
......@@ -1666,7 +1667,8 @@ void VCartesianAxis::createMaximumLabels()
std::unique_ptr< TickIter > apTickIter(createMaximumLabelTickIterator( nTextLevel ));
if(apTickIter)
{
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) )
while (!createTextShapes(m_xTextTarget, *apTickIter, aAxisLabelProperties,
pTickFactory2D, -1))
{
};
}
......@@ -1802,7 +1804,9 @@ void VCartesianAxis::createShapes()
if( apTickIter )
{
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ), fRotationAngleDegree ) );
B2DVector aLabelsDistance(lcl_getLabelsDistance(
*apTickIter, pTickFactory2D->getDistanceAxisTickToText(m_aAxisProperties),
fRotationAngleDegree));
sal_Int32 nCurrentLength = static_cast<sal_Int32>(aLabelsDistance.getLength());
aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0 ) );
nOffset += nCurrentLength;
......
......@@ -212,7 +212,7 @@ void VCartesianGrid::createShapes()
//create all scaled tickmark values
std::unique_ptr< TickFactory > apTickFactory( createTickFactory() );
TickFactory& aTickFactory = *apTickFactory.get();
TickFactory& aTickFactory = *apTickFactory;
TickInfoArraysType aAllTickInfos;
aTickFactory.getAllTicks( aAllTickInfos );
......
......@@ -364,7 +364,7 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries const & rDataSeries
{
OUString aNumber;
if( m_apNumberFormatterWrapper.get())
if (m_apNumberFormatterWrapper)
{
sal_Int32 nNumberFormatKey = 0;
if( rDataSeries.hasExplicitNumberFormat(nPointIndex,bAsPercentage) )
......@@ -1334,7 +1334,7 @@ void VSeriesPlotter::createRegressionCurveEquationShapes(
bResizeEquation = false;
if( bShowEquation )
{
if( m_apNumberFormatterWrapper.get())
if (m_apNumberFormatterWrapper)
{ // iteration 0: default representation (no wrap)
// iteration 1: expected width (nFormulaWidth) is calculated
aFormula = xRegressionCurveCalculator->getFormattedRepresentation(
......@@ -1356,7 +1356,7 @@ void VSeriesPlotter::createRegressionCurveEquationShapes(
{
aFormula.append( "R" ).append( OUStringLiteral1( aSuperscriptFigures[2] ) ).append( " = " );
double fR( xRegressionCurveCalculator->getCorrelationCoefficient());
if( m_apNumberFormatterWrapper.get())
if (m_apNumberFormatterWrapper)
{
Color nLabelCol;
bool bColChanged;
......@@ -1459,7 +1459,7 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis()
{
const std::vector< double >& rDateCategories = m_pExplicitCategoriesProvider->getDateCategories();
Date aNullDate(30,12,1899);
if( m_apNumberFormatterWrapper.get() )
if (m_apNumberFormatterWrapper)
aNullDate = m_apNumberFormatterWrapper->getNullDate();
if( !rDateCategories.empty() )
{
......
......@@ -945,7 +945,7 @@ DataPointLabel* VDataSeries::getDataPointLabel( sal_Int32 index ) const
if( isAttributedDataPoint( index ) )
{
adaptPointCache( index );
if( !m_apLabel_AttributedPoint.get() )
if (!m_apLabel_AttributedPoint)
m_apLabel_AttributedPoint
= getDataPointLabelFromPropertySet(getPropertiesOfPoint(index));
pRet = m_apLabel_AttributedPoint.get();
......
......@@ -178,8 +178,7 @@ codemaker::UnoType::Sort TypeManager::decompose(
switch (s) {
case codemaker::UnoType::Sort::Typedef:
if (resolveTypedefs) {
n = dynamic_cast<unoidl::TypedefEntity&>(*ent.get()).
getType();
n = dynamic_cast<unoidl::TypedefEntity&>(*ent).getType();
while (n.startsWith("[]")) {
++k; //TODO: overflow
n = n.copy(std::strlen("[]"));
......
......@@ -736,9 +736,7 @@ OUString CppuType::getTypeClass(OUString const & name, bool cStyle)
? OUString("typelib_TypeClass_INTERFACE")
: OUString("::css::uno::TypeClass_INTERFACE");
case codemaker::UnoType::Sort::Typedef:
return getTypeClass(
dynamic_cast<unoidl::TypedefEntity&>(*ent.get()).getType(),