From 038e4b3b1e10d072b432cb06234521ae9a262a70 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Fri, 3 May 2019 19:51:47 +0300 Subject: Use hasElements to check Sequence emptiness in sax..sdext Similar to clang-tidy readability-container-size-empty Change-Id: If6a567708d3c59355d54933fad23c85195846624 Reviewed-on: https://gerrit.libreoffice.org/71763 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sd/source/filter/eppt/eppt.cxx | 2 +- sd/source/filter/eppt/pptexanimations.cxx | 6 +++--- sd/source/filter/eppt/pptx-animations.cxx | 2 +- sd/source/filter/eppt/pptx-epptooxml.cxx | 2 +- sd/source/filter/xml/sdxmlwrp.cxx | 2 +- sd/source/ui/app/optsitem.cxx | 4 ++-- sd/source/ui/dlg/PhotoAlbumDialog.cxx | 2 +- sd/source/ui/framework/factories/BasicPaneFactory.cxx | 2 +- sd/source/ui/framework/factories/BasicToolBarFactory.cxx | 2 +- sd/source/ui/framework/factories/BasicViewFactory.cxx | 2 +- sd/source/ui/framework/factories/PresentationFactory.cxx | 2 +- sd/source/ui/framework/module/CenterViewFocusModule.cxx | 2 +- sd/source/ui/framework/module/ModuleController.cxx | 2 +- sd/source/ui/framework/tools/FrameworkHelper.cxx | 2 +- sd/source/ui/presenter/PresenterPreviewCache.cxx | 2 +- sd/source/ui/presenter/SlideRenderer.cxx | 2 +- sd/source/ui/unoidl/unopage.cxx | 4 ++-- sd/source/ui/unoidl/unosrch.cxx | 2 +- sd/source/ui/view/drviews2.cxx | 4 ++-- 19 files changed, 24 insertions(+), 24 deletions(-) (limited to 'sd') diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index 7a378baa3bbf..92caecc4da3c 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -836,7 +836,7 @@ bool PPTWriter::ImplCreateDocument() if ( aXCont.is() ) { css::uno::Sequence< OUString> aNameSeq( aXCont->getElementNames() ); - if ( aNameSeq.getLength() ) + if ( aNameSeq.hasElements() ) { mpPptEscherEx->OpenContainer( EPP_NamedShows ); sal_uInt32 nCustomShowIndex = 0; diff --git a/sd/source/filter/eppt/pptexanimations.cxx b/sd/source/filter/eppt/pptexanimations.cxx index cf2ed32f21f2..ae0c3c8e6c32 100644 --- a/sd/source/filter/eppt/pptexanimations.cxx +++ b/sd/source/filter/eppt/pptexanimations.cxx @@ -749,7 +749,7 @@ bool AnimationExporter::GetNodeType( const Reference< XAnimationNode >& xNode, s { // trying to get the nodetype Sequence< NamedValue > aUserData = xNode->getUserData(); - if ( aUserData.getLength() ) + if ( aUserData.hasElements() ) { const NamedValue* p = aUserData.getConstArray(); sal_Int32 nLength = aUserData.getLength(); @@ -862,7 +862,7 @@ void AnimationExporter::GetUserData( const Sequence< NamedValue >& rUserData, co { // storing user data into pAny, to allow direct access later memset( pAny, 0, nLen ); - if ( !rUserData.getLength() ) + if ( !rUserData.hasElements() ) return; const NamedValue* p = rUserData.getConstArray(); @@ -1788,7 +1788,7 @@ void AnimationExporter::exportAnimateKeyPoints( SvStream& rStrm, const Reference Sequence< double > aKeyTimes( xAnimate->getKeyTimes() ); Sequence< Any > aValues( xAnimate->getValues() ); OUString aFormula( xAnimate->getFormula() ); - if ( !aKeyTimes.getLength() ) + if ( !aKeyTimes.hasElements() ) return; EscherExContainer aAnimKeyPoints( rStrm, DFF_msofbtAnimKeyPoints ); diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx index c1c86f46ae3a..1a35c7777e2a 100644 --- a/sd/source/filter/eppt/pptx-animations.cxx +++ b/sd/source/filter/eppt/pptx-animations.cxx @@ -195,7 +195,7 @@ void WriteAnimateTo(const FSHelperPtr& pFS, const Any& rValue, const OUString& r void WriteAnimateValues(const FSHelperPtr& pFS, const Reference& rXAnimate) { const Sequence aKeyTimes = rXAnimate->getKeyTimes(); - if (aKeyTimes.getLength() <= 0) + if (!aKeyTimes.hasElements()) return; const Sequence aValues = rXAnimate->getValues(); const OUString& sFormula = rXAnimate->getFormula(); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index a7d51cfcd57e..e6a1495ee4a5 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1769,7 +1769,7 @@ bool PowerPointExport::WriteColorSchemes(const FSHelperPtr& pFS, const OUString& aGrabBag.getValue(rThemePath) >>= aCurrentTheme; - if (!aCurrentTheme.getLength()) + if (!aCurrentTheme.hasElements()) return false; // Order is important diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index 9e3c9c579689..cedd642a65f3 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -358,7 +358,7 @@ ErrCode ReadThroughComponent( // set Base URL uno::Reference< beans::XPropertySet > xInfoSet; - if( rFilterArguments.getLength() > 0 ) + if( rFilterArguments.hasElements() ) rFilterArguments.getConstArray()[0] >>= xInfoSet; DBG_ASSERT( xInfoSet.is(), "missing property set" ); if( xInfoSet.is() ) diff --git a/sd/source/ui/app/optsitem.cxx b/sd/source/ui/app/optsitem.cxx index 8dec8fc79e2d..34e69ef7d6e8 100644 --- a/sd/source/ui/app/optsitem.cxx +++ b/sd/source/ui/app/optsitem.cxx @@ -113,7 +113,7 @@ void SdOptionsGeneric::Init() const const Sequence< OUString > aNames( GetPropertyNames() ); const Sequence< Any > aValues = mpCfgItem->GetProperties( aNames ); - if( aNames.getLength() && ( aValues.getLength() == aNames.getLength() ) ) + if( aNames.hasElements() && ( aValues.getLength() == aNames.getLength() ) ) { const Any* pValues = aValues.getConstArray(); @@ -134,7 +134,7 @@ void SdOptionsGeneric::Commit( SdOptionsItem& rCfgItem ) const const Sequence< OUString > aNames( GetPropertyNames() ); Sequence< Any > aValues( aNames.getLength() ); - if( aNames.getLength() && ( aValues.getLength() == aNames.getLength() ) ) + if( aNames.hasElements() && ( aValues.getLength() == aNames.getLength() ) ) { if( WriteData( aValues.getArray() ) ) rCfgItem.PutProperties( aNames, aValues ); diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx index 3f9b7cef8378..6381c22e663c 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx @@ -518,7 +518,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, weld::Button&, void) if ( aDlg.Execute() == ERRCODE_NONE ) { Sequence< OUString > aFilesArr = aDlg.GetSelectedFiles(); - if( aFilesArr.getLength() ) + if( aFilesArr.hasElements() ) { sUrl = aDlg.GetDisplayDirectory(); // Write out configuration diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index 7d009fa8548b..2754b71d369f 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -122,7 +122,7 @@ void SAL_CALL BasicPaneFactory::disposing() void SAL_CALL BasicPaneFactory::initialize (const Sequence& aArguments) { - if (aArguments.getLength() <= 0) + if (!aArguments.hasElements()) return; try diff --git a/sd/source/ui/framework/factories/BasicToolBarFactory.cxx b/sd/source/ui/framework/factories/BasicToolBarFactory.cxx index bb1ede4c63ea..b0cb5f05a43c 100644 --- a/sd/source/ui/framework/factories/BasicToolBarFactory.cxx +++ b/sd/source/ui/framework/factories/BasicToolBarFactory.cxx @@ -69,7 +69,7 @@ void BasicToolBarFactory::Shutdown() void SAL_CALL BasicToolBarFactory::initialize (const Sequence& aArguments) { - if (aArguments.getLength() <= 0) + if (!aArguments.hasElements()) return; try diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx index 71eb27ac19e7..fa3628550e99 100644 --- a/sd/source/ui/framework/factories/BasicViewFactory.cxx +++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx @@ -230,7 +230,7 @@ void SAL_CALL BasicViewFactory::releaseResource (const Reference& rxV void SAL_CALL BasicViewFactory::initialize (const Sequence& aArguments) { - if (aArguments.getLength() <= 0) + if (!aArguments.hasElements()) return; try diff --git a/sd/source/ui/framework/factories/PresentationFactory.cxx b/sd/source/ui/framework/factories/PresentationFactory.cxx index fe8d1331a7f9..42df2c979b6a 100644 --- a/sd/source/ui/framework/factories/PresentationFactory.cxx +++ b/sd/source/ui/framework/factories/PresentationFactory.cxx @@ -174,7 +174,7 @@ void PresentationFactoryProvider::disposing() void SAL_CALL PresentationFactoryProvider::initialize( const Sequence& aArguments) { - if (aArguments.getLength() <= 0) + if (!aArguments.hasElements()) return; try diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.cxx b/sd/source/ui/framework/module/CenterViewFocusModule.cxx index 8c7e6abbd2d6..d462489339a7 100644 --- a/sd/source/ui/framework/module/CenterViewFocusModule.cxx +++ b/sd/source/ui/framework/module/CenterViewFocusModule.cxx @@ -126,7 +126,7 @@ void CenterViewFocusModule::HandleNewView ( FrameworkHelper::msViewURLPrefix, AnchorBindingMode_DIRECT)); Reference xView; - if (xViewIds.getLength() > 0) + if (xViewIds.hasElements()) xView.set( mxConfigurationController->getResource(xViewIds[0]),UNO_QUERY); Reference xTunnel (xView, UNO_QUERY); if (xTunnel.is() && mpBase!=nullptr) diff --git a/sd/source/ui/framework/module/ModuleController.cxx b/sd/source/ui/framework/module/ModuleController.cxx index edfe932474f0..104cb91e152d 100644 --- a/sd/source/ui/framework/module/ModuleController.cxx +++ b/sd/source/ui/framework/module/ModuleController.cxx @@ -240,7 +240,7 @@ void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL) void SAL_CALL ModuleController::initialize (const Sequence& aArguments) { - if (aArguments.getLength() > 0) + if (aArguments.hasElements()) { try { diff --git a/sd/source/ui/framework/tools/FrameworkHelper.cxx b/sd/source/ui/framework/tools/FrameworkHelper.cxx index 9e7fb199b27a..5878aab82ffe 100644 --- a/sd/source/ui/framework/tools/FrameworkHelper.cxx +++ b/sd/source/ui/framework/tools/FrameworkHelper.cxx @@ -249,7 +249,7 @@ namespace Reference< XConfiguration > xConfiguration( i_rConfigController->getRequestedConfiguration(), UNO_SET_THROW ); Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources( i_rPaneId, FrameworkHelper::msViewURLPrefix, AnchorBindingMode_DIRECT ) ); - if ( aViewIds.getLength() > 0 ) + if ( aViewIds.hasElements() ) return i_rConfigController->getResource( aViewIds[0] ); } catch( const Exception& ) diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx index fafe1d9408b9..54fde4e3408b 100644 --- a/sd/source/ui/presenter/PresenterPreviewCache.cxx +++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx @@ -89,7 +89,7 @@ PresenterPreviewCache::~PresenterPreviewCache() void SAL_CALL PresenterPreviewCache::initialize (const Sequence& rArguments) { - if (rArguments.getLength() != 0) + if (rArguments.hasElements()) throw RuntimeException(); } diff --git a/sd/source/ui/presenter/SlideRenderer.cxx b/sd/source/ui/presenter/SlideRenderer.cxx index 9757b7d661a4..8a8d318209ed 100644 --- a/sd/source/ui/presenter/SlideRenderer.cxx +++ b/sd/source/ui/presenter/SlideRenderer.cxx @@ -53,7 +53,7 @@ void SAL_CALL SlideRenderer::initialize (const Sequence& rArguments) { ThrowIfDisposed(); - if (rArguments.getLength() != 0) + if (rArguments.hasElements()) { throw RuntimeException("SlideRenderer: invalid number of arguments", static_cast(this)); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 5c638c3125d5..a1ae1c4c3197 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2057,7 +2057,7 @@ Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throwIfDisposed(); - if( maTypeSequence.getLength() == 0 ) + if( !maTypeSequence.hasElements() ) { const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard; bool bPresPage = IsImpressDocument() && ePageKind != PageKind::Handout; @@ -2675,7 +2675,7 @@ Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throwIfDisposed(); - if( maTypeSequence.getLength() == 0 ) + if( !maTypeSequence.hasElements() ) { const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard; bool bPresPage = IsImpressDocument() && SvxFmDrawPage::mpPage && ePageKind != PageKind::Handout; diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx index 7417a781e369..ee6b482b19ab 100644 --- a/sd/source/ui/unoidl/unosrch.cxx +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -779,7 +779,7 @@ uno::Type SAL_CALL SdUnoFindAllAccess::getElementType() sal_Bool SAL_CALL SdUnoFindAllAccess::hasElements() { - return maSequence.getLength() > 0; + return maSequence.hasElements(); } // XIndexAccess diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 391bff60b99b..2c5df1abb7a1 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1712,7 +1712,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) const css::uno::Sequence< css::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() ); - if( aContexts.getLength() ) + if( aContexts.hasElements() ) { css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); mxScannerManager->configureScannerAndScan( aContext, mxScannerListener ); @@ -1738,7 +1738,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { const css::uno::Sequence< css::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() ); - if( aContexts.getLength() ) + if( aContexts.hasElements() ) { mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener ); bDone = true; -- cgit