summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-05-02 17:53:27 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-04 13:57:07 +0200
commit2ddc66e6981a7d819cd6196a7ccbc811ca213be2 (patch)
treeab991ee652a9121ac18213f84d0df7855a2f2e29 /sw/source/uibase
parentdec6bb217dd3ae98bee8e48fab9f8e26b7645b2b (diff)
Use hasElements to check Sequence emptiness in sw
Similar to clang-tidy readability-container-size-empty Change-Id: If44f20a7aa678915e32d12101e1af71476f4b590 Reviewed-on: https://gerrit.libreoffice.org/71679 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/app/docsh.cxx8
-rw-r--r--sw/source/uibase/app/docshini.cxx2
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx10
-rw-r--r--sw/source/uibase/dbui/mmconfigitem.cxx5
-rw-r--r--sw/source/uibase/envelp/labelcfg.cxx2
-rw-r--r--sw/source/uibase/lingu/olmenu.cxx2
-rw-r--r--sw/source/uibase/misc/redlndlg.cxx4
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.cxx10
-rw-r--r--sw/source/uibase/uiview/uivwimp.cxx4
-rw-r--r--sw/source/uibase/uiview/view2.cxx10
-rw-r--r--sw/source/uibase/uiview/viewling.cxx6
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx2
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx2
-rw-r--r--sw/source/uibase/uno/unomailmerge.cxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx4
-rw-r--r--sw/source/uibase/uno/unotxvw.cxx2
16 files changed, 37 insertions, 38 deletions
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 7f13bbbfb63b..1486916cd181 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -659,7 +659,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium )
if(xLib.is())
{
Sequence<OUString> aModNames = xLib->getElementNames();
- if(aModNames.getLength())
+ if(aModNames.hasElements())
{
SetError(WARN_SWG_HTML_NO_MACROS);
break;
@@ -1362,7 +1362,7 @@ bool SwDocShell::HasChangeRecordProtection() const
{
if (!m_pWrtShell)
return false;
- return m_pWrtShell->getIDocumentRedlineAccess().GetRedlinePassword().getLength() > 0;
+ return m_pWrtShell->getIDocumentRedlineAccess().GetRedlinePassword().hasElements();
}
void SwDocShell::SetChangeRecording( bool bActivate )
@@ -1380,7 +1380,7 @@ void SwDocShell::SetProtectionPassword( const OUString &rNewPassword )
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
Sequence< sal_Int8 > aPasswd = rIDRA.GetRedlinePassword();
if (SfxItemState::SET == aSet.GetItemState(FN_REDLINE_PROTECT, false, &pItem)
- && static_cast<const SfxBoolItem*>(pItem)->GetValue() == (aPasswd.getLength() > 0))
+ && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswd.hasElements())
return;
if (!rNewPassword.isEmpty())
@@ -1408,7 +1408,7 @@ bool SwDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
const Sequence< sal_Int8 >& aPasswdHash( rIDRA.GetRedlinePassword() );
if (SfxItemState::SET == aSet.GetItemState(FN_REDLINE_PROTECT, false, &pItem)
- && static_cast<const SfxBoolItem*>(pItem)->GetValue() == (aPasswdHash.getLength() != 0))
+ && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswdHash.hasElements())
return false;
rPasswordHash = aPasswdHash;
bRes = true;
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
index d181b485602f..7428887c51b6 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -126,7 +126,7 @@ bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
{
SvxAsianConfig aAsian;
Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
- if (aLocales.getLength())
+ if (aLocales.hasElements())
{
const lang::Locale* pLocales = aLocales.getConstArray();
for(sal_Int32 i = 0; i < aLocales.getLength(); i++)
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 508c2760807d..99f24e7ca948 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -358,7 +358,7 @@ static bool lcl_MoveAbsolute(SwDSParam* pParam, long nAbsPos)
bool bRet = false;
try
{
- if(pParam->aSelection.getLength())
+ if(pParam->aSelection.hasElements())
{
if(pParam->aSelection.getLength() <= nAbsPos)
{
@@ -939,7 +939,7 @@ static bool lcl_SaveDoc(
if( pStoreToFilterOptions )
pDstMed->GetItemSet()->Put( SfxStringItem(SID_FILE_FILTEROPTIONS,
*pStoreToFilterOptions));
- if( pSaveToFilterData->getLength() )
+ if( pSaveToFilterData->hasElements() )
pDstMed->GetItemSet()->Put( SfxUnoAnyItem(SID_FILTER_DATA,
uno::makeAny(*pSaveToFilterData)));
}
@@ -2139,7 +2139,7 @@ bool SwDBManager::GetColumnCnt(const OUString& rSourceName, const OUString& rTab
if (!pFound)
return false;
//check validity of supplied record Id
- if(pFound->aSelection.getLength())
+ if(pFound->aSelection.hasElements())
{
//the destination has to be an element of the selection
const uno::Any* pSelection = pFound->aSelection.getConstArray();
@@ -2303,7 +2303,7 @@ static bool lcl_ToNextRecord( SwDSParam* pParam, const SwDBNextRecord action )
try
{
- if( pParam->aSelection.getLength() )
+ if( pParam->aSelection.hasElements() )
{
if( pParam->nSelectionIndex >= pParam->aSelection.getLength() )
pParam->bEndOfDB = true;
@@ -2479,7 +2479,7 @@ sal_uInt32 SwDBManager::GetSelectedRecordId(
{
try
{ //if a selection array is set the current row at the result set may not be set yet
- if(pFound->aSelection.getLength())
+ if(pFound->aSelection.hasElements())
{
sal_Int32 nSelIndex = pFound->nSelectionIndex;
if(nSelIndex >= pFound->aSelection.getLength())
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index 416b68b8dae8..41aa414233b8 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -291,7 +291,7 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
}
//read the list of data base assignments
Sequence<OUString> aAssignments = GetNodeNames(cAddressDataAssignments);
- if(aAssignments.getLength())
+ if(aAssignments.hasElements())
{
//create a list of property names to load the URLs of all data bases
const OUString* pAssignments = aAssignments.getConstArray();
@@ -327,7 +327,7 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
}
}
//check if the saved documents still exist
- if(m_aSavedDocuments.getLength())
+ if(m_aSavedDocuments.hasElements())
{
uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength());
OUString* pTempDocuments = aTempDocuments.getArray();
@@ -345,7 +345,6 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
m_aSavedDocuments.realloc(nIndex);
}
}
-
}
void SwMailMergeConfigItem_Impl::SetCurrentAddressBlockIndex( sal_Int32 nSet )
diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx
index f18d781fd08a..70e3cc8b54c5 100644
--- a/sw/source/uibase/envelp/labelcfg.cxx
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -282,7 +282,7 @@ void SwLabelConfig::SaveLabel( const OUString& rManufacturer,
OUString sFoundNode;
bool bManufacturerNodeFound;
if ( m_aLabels.find( rManufacturer ) == m_aLabels.end() ||
- GetNodeNames( rManufacturer ).getLength() == 0 )
+ !GetNodeNames( rManufacturer ).hasElements() )
{
bManufacturerNodeFound = false;
// manufacturer node does not exist, add (and also to m_aManufacturers)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 7f6be927500a..16a2920a6d77 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -174,7 +174,7 @@ void SwSpellPopup::fillLangPopupMenu(
if (xDocumentLanguages.is())
{
uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount ) );
- if (rLocales.getLength() > 0)
+ if (rLocales.hasElements())
{
for (sal_Int32 i = 0; i < rLocales.getLength(); ++i)
{
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index 1861bc292057..ddae90fd36a3 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -274,7 +274,7 @@ void SwRedlineAcceptDlg::InitAuthors()
pFilterPage->SelectAuthor(aStrings[0]);
weld::TreeView& rTreeView = m_pTable->GetWidget();
- bool bEnable = rTreeView.n_children() != 0 && !pSh->getIDocumentRedlineAccess().GetRedlinePassword().getLength();
+ bool bEnable = rTreeView.n_children() != 0 && !pSh->getIDocumentRedlineAccess().GetRedlinePassword().hasElements();
bool bSel = rTreeView.get_selected(nullptr);
rTreeView.selected_foreach([this, pSh, &bIsNotFormated](weld::TreeIter& rEntry){
@@ -978,7 +978,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, GotoHdl, Timer *, void)
}
}
- bool bEnable = !pSh->getIDocumentRedlineAccess().GetRedlinePassword().getLength();
+ bool bEnable = !pSh->getIDocumentRedlineAccess().GetRedlinePassword().hasElements();
m_pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ );
m_pTPView->EnableReject( bEnable && bSel /*&& !bReadonlySel*/ );
m_pTPView->EnableClearFormat( bEnable && bSel && !bIsNotFormated /*&& !bReadonlySel*/ );
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx
index 9b0e66da58dc..eae043554484 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.cxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.cxx
@@ -513,7 +513,7 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt.GetUserData();
OUString aTmp;
- if ( aSeq.getLength())
+ if ( aSeq.hasElements())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
m_nUserCustomPageLeftMargin = aWinData.toInt32();
@@ -525,7 +525,7 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
OUString aTmp;
- if ( aSeq.getLength())
+ if ( aSeq.hasElements())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
m_nUserCustomPageRightMargin = aWinData.toInt32();
@@ -537,7 +537,7 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
OUString aTmp;
- if ( aSeq.getLength() )
+ if ( aSeq.hasElements() )
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
m_nUserCustomPageTopMargin = aWinData.toInt32();
@@ -549,7 +549,7 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
OUString aTmp;
- if ( aSeq.getLength())
+ if ( aSeq.hasElements())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
m_nUserCustomPageBottomMargin = aWinData.toInt32();
@@ -561,7 +561,7 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
OUString aTmp;
- if ( aSeq.getLength())
+ if ( aSeq.hasElements())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
m_bUserCustomMirrored = aWinData.toInt32() != 0;
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index f2d9fdcf420f..737839eedeb9 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -123,7 +123,7 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq )
const Sequence< ScannerContext >
aContexts( xScanMgr->getAvailableScanners() );
- if( aContexts.getLength() )
+ if( aContexts.hasElements() )
{
Reference< XEventListener > xLstner = &rListener;
ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
@@ -155,7 +155,7 @@ void SwView_Impl::ExecuteScan( SfxRequest& rReq )
try
{
const Sequence< scanner::ScannerContext >aContexts( xScanMgr->getAvailableScanners() );
- if( aContexts.getLength() )
+ if( aContexts.hasElements() )
{
Reference< XEventListener > xLstner = &rListener;
xScanMgr->startScan( aContexts.getConstArray()[ 0 ], xLstner );
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index a4b5cd620fbe..7590d5e8b857 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -573,7 +573,7 @@ void SwView::Execute(SfxRequest &rReq)
{
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
- if( aPasswd.getLength() )
+ if( aPasswd.hasElements() )
{
OSL_ENSURE( !static_cast<const SfxBoolItem*>(pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
// xmlsec05: new password dialog
@@ -612,14 +612,14 @@ void SwView::Execute(SfxRequest &rReq)
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
if( pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )
- && static_cast<const SfxBoolItem*>(pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
+ && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswd.hasElements() )
break;
// xmlsec05: new password dialog
// message box for wrong password
SfxPasswordDialog aPasswdDlg(GetFrameWeld());
aPasswdDlg.SetMinLen(1);
- if (!aPasswd.getLength())
+ if (!aPasswd.hasElements())
aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
if (aPasswdDlg.run())
{
@@ -628,7 +628,7 @@ void SwView::Execute(SfxRequest &rReq)
Sequence <sal_Int8> aNewPasswd =
rIDRA.GetRedlinePassword();
SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
- if(!aPasswd.getLength())
+ if(!aPasswd.hasElements())
{
rIDRA.SetRedlinePassword(aNewPasswd);
}
@@ -2291,7 +2291,7 @@ namespace
{
Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
- return ( !aNames.getLength()
+ return ( !aNames.hasElements()
|| ( ( 1 == aNames.getLength() )
&& aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
)
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 72a68784be73..6d627a74fbac 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -679,7 +679,7 @@ bool SwView::ExecSpellPopup(const Point& rPt)
sal_Int32 nErrorInResult = -1;
uno::Sequence< OUString > aSuggestions;
bool bCorrectionRes = false;
- if (!xAlt.is() || xAlt->getAlternatives().getLength() == 0)
+ if (!xAlt.is() || !xAlt->getAlternatives().hasElements())
{
sal_Int32 nErrorPosInText = -1;
bCorrectionRes = m_pWrtShell->GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, &rPt, aToFill );
@@ -689,12 +689,12 @@ bool SwView::ExecSpellPopup(const Point& rPt)
// we like to use the grammar checking context menu if we either get
// some suggestions or at least a comment about the error found...
bUseGrammarContext = bCorrectionRes &&
- (aSuggestions.getLength() > 0 || !aMessageText.isEmpty());
+ (aSuggestions.hasElements() || !aMessageText.isEmpty());
}
// open respective context menu for spell check or grammar errors with correction suggestions...
if ((!bUseGrammarContext && xAlt.is()) ||
- (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.getLength() > 0))
+ (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.hasElements()))
{
// get paragraph text
OUString aParaText;
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index 909ba9a67225..bc771162bea2 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -404,7 +404,7 @@ void SwView::GetState(SfxItemSet &rSet)
case SID_DOCUMENT_COMPARE:
case SID_DOCUMENT_MERGE:
if( dynamic_cast<const SwGlobalDocShell* >(GetDocShell()) != nullptr||
- (SID_DOCUMENT_MERGE == nWhich && m_pWrtShell->getIDocumentRedlineAccess().GetRedlinePassword().getLength()))
+ (SID_DOCUMENT_MERGE == nWhich && m_pWrtShell->getIDocumentRedlineAccess().GetRedlinePassword().hasElements()))
rSet.DisableItem(nWhich);
break;
case SID_VIEW_DATA_SOURCE_BROWSER:
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 1e7bb75f04a5..924db95bb73e 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -641,7 +641,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
if(rValue >>= aNew)
{
mpDoc->getIDocumentRedlineAccess().SetRedlinePassword(aNew);
- if(aNew.getLength())
+ if(aNew.hasElements())
{
RedlineFlags eMode = mpDoc->getIDocumentRedlineAccess().GetRedlineFlags();
eMode |= RedlineFlags::On;
diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx
index f38cfba8782c..128b9a25765c 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -550,7 +550,7 @@ uno::Any SAL_CALL SwXMailMerge::execute(
// need to translate the selection: the API here requires a sequence of bookmarks, but the Merge
// method we will call below requires a sequence of indices.
- if ( aCurSelection.getLength() )
+ if ( aCurSelection.hasElements() )
{
Sequence< Any > aTranslated( aCurSelection.getLength() );
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 5b95045842a3..28b3958fc55f 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1764,7 +1764,7 @@ Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
Sequence< OUString > SwXTextDocument::getAvailableServiceNames()
{
static Sequence< OUString > aServices;
- if ( aServices.getLength() == 0 )
+ if ( !aServices.hasElements() )
{
Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
OUString* pRet = aRet.getArray();
@@ -1896,7 +1896,7 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
{
SwDoc* pDoc = pDocShell->GetDoc();
pDoc->getIDocumentRedlineAccess().SetRedlinePassword(aNew);
- if(aNew.getLength())
+ if(aNew.hasElements())
{
RedlineFlags eMode = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
eMode |= RedlineFlags::On;
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 2be21959a05a..12bc55ac579e 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -581,7 +581,7 @@ void SAL_CALL SwXTextView::setRubyList(
{
SolarMutexGuard aGuard;
- if(!GetView() || !rRubyList.getLength())
+ if(!GetView() || !rRubyList.hasElements())
throw RuntimeException();
SwWrtShell& rSh = m_pView->GetWrtShell();
ShellMode eSelMode = m_pView->GetShellMode();