diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-28 18:07:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-29 12:14:02 +0200 |
commit | a612d738a8c909e18ed89675432ca42b376ef624 (patch) | |
tree | 67729979d1f7b14726dce15f3d44faaf54e28bde /sd | |
parent | 415436ad27b4522102d3fbbb6003935871029fc6 (diff) |
loplugin:stringloop in sd
Change-Id: I5b0cd65b6e69490c79e0ac37c137283d19711787
Reviewed-on: https://gerrit.libreoffice.org/58252
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 17 | ||||
-rw-r--r-- | sd/source/filter/eppt/eppt.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx | 52 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationtag.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/framework/configuration/Configuration.cxx | 14 | ||||
-rw-r--r-- | sd/source/ui/framework/tools/FrameworkHelper.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/func/fulinend.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unolayer.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/view/DocumentRenderer.cxx | 3 |
10 files changed, 51 insertions, 72 deletions
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 5cd4c61cd185..aa72ae612206 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -1368,27 +1368,18 @@ bool isMasterPageLayoutNameUnique(const SdDrawDocument& rDoc, const OUString& rC OUString createNewMasterPageLayoutName(const SdDrawDocument& rDoc) { const OUString aBaseName(SdResId(STR_LAYOUT_DEFAULT_NAME)); - OUString aRetval; sal_uInt16 nCount(0); - - while (aRetval.isEmpty()) + for (;;) { - aRetval = aBaseName; - + OUString aRetval = aBaseName; if(nCount) { aRetval += OUString::number(nCount); } - + if (isMasterPageLayoutNameUnique(rDoc, aRetval)) + return aRetval; nCount++; - - if(!isMasterPageLayoutNameUnique(rDoc, aRetval)) - { - aRetval.clear(); - } } - - return aRetval; } void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index 395fb50b2677..28edf2321323 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -1046,7 +1046,7 @@ bool PPTWriter::ImplCreateMainNotes() static OUString getInitials( const OUString& rName ) { - OUString sInitials; + OUStringBuffer sInitials; const sal_Unicode * pStr = rName.getStr(); sal_Int32 nLength = rName.getLength(); @@ -1062,7 +1062,7 @@ static OUString getInitials( const OUString& rName ) // take letter if( nLength ) { - sInitials += OUStringLiteral1( *pStr ); + sInitials.append( *pStr ); nLength--; pStr++; } @@ -1073,7 +1073,7 @@ static OUString getInitials( const OUString& rName ) } } - return sInitials; + return sInitials.makeStringAndClear(); } void ImplExportComments( const uno::Reference< drawing::XDrawPage >& xPage, SvMemoryStream& rBinaryTagData10Atom ) diff --git a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx index b3f570c1193d..f4cc1a71b0b6 100644 --- a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx +++ b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx @@ -683,7 +683,7 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() ::osl::MutexGuard aGuard (maMutex); uno::Any anyAtrribute; - OUString sValue; + OUStringBuffer sValue; if (nullptr != dynamic_cast<const ::sd::DrawViewShell* > (mpViewShell)) { ::sd::DrawViewShell* pDrViewSh = static_cast< ::sd::DrawViewShell*>(mpViewShell); @@ -699,13 +699,11 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() sDisplay = sDisplay.replaceFirst( ",", "\\," ); sDisplay = sDisplay.replaceFirst( ":", "\\:" ); sValue = sName + sDisplay ; - sName = ";page-number:"; - sValue += sName; - sValue += OUString::number(static_cast<sal_Int16>(static_cast<sal_uInt16>((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) ; - sName = ";total-pages:"; - sValue += sName; - sValue += OUString::number(pDrViewSh->GetPageTabControl().GetPageCount()) ; - sValue += ";"; + sValue.append(";page-number:"); + sValue.append(OUString::number(static_cast<sal_Int16>(static_cast<sal_uInt16>((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) ); + sValue.append(";total-pages:"); + sValue.append(OUString::number(pDrViewSh->GetPageTabControl().GetPageCount()) ); + sValue.append(";"); if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #i87182# { sName = "page-name:"; @@ -731,14 +729,12 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() sDisplay = sDisplay.replaceFirst( ";", "\\;" ); sDisplay = sDisplay.replaceFirst( ",", "\\," ); sDisplay = sDisplay.replaceFirst( ":", "\\:" ); - sValue += sDisplay; - sName = ";page-number:"; - sValue += sName; - sValue += OUString::number(pDrViewSh->GetActiveTabLayerIndex()+1) ; - sName = ";total-pages:"; - sValue += sName; - sValue += OUString::number(pDrViewSh->GetLayerTabControl()->GetPageCount()) ; - sValue += ";"; + sValue.append(sDisplay); + sValue.append(";page-number:"); + sValue.append(OUString::number(pDrViewSh->GetActiveTabLayerIndex()+1) ); + sValue.append(";total-pages:"); + sValue.append(OUString::number(pDrViewSh->GetLayerTabControl()->GetPageCount()) ); + sValue.append(";"); } } if (dynamic_cast<const ::sd::PresentationViewShell* >(mpViewShell) != nullptr ) @@ -755,7 +751,7 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject(); if (pPara) { - sValue += "note:"; + sValue.append("note:"); const EditTextObject& rEdit = pPara->GetTextObject(); for (sal_Int32 i=0;i<rEdit.GetParagraphCount();i++) { @@ -765,8 +761,8 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() strNote = strNote.replaceFirst( ";", "\\;" ); strNote = strNote.replaceFirst( ",", "\\," ); strNote = strNote.replaceFirst( ":", "\\:" ); - sValue += strNote; - sValue += ";";//to divide each paragraph + sValue.append(strNote); + sValue.append(";");//to divide each paragraph } } } @@ -774,30 +770,26 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() } if (dynamic_cast<const ::sd::OutlineViewShell* >(mpViewShell ) != nullptr ) { - OUString sName; OUString sDisplay; SdPage* pCurrPge = mpViewShell->GetActualPage(); SdDrawDocument* pDoc = mpViewShell->GetDoc(); if(pCurrPge && pDoc) { - sName = "page-name:"; sDisplay = pCurrPge->GetName(); sDisplay = sDisplay.replaceFirst( "=", "\\=" ); sDisplay = sDisplay.replaceFirst( ";", "\\;" ); sDisplay = sDisplay.replaceFirst( ",", "\\," ); sDisplay = sDisplay.replaceFirst( ":", "\\:" ); - sValue = sName + sDisplay ; - sName = ";page-number:"; - sValue += sName; - sValue += OUString::number(static_cast<sal_Int16>(static_cast<sal_uInt16>((pCurrPge->GetPageNum()-1)>>1) + 1)) ; - sName = ";total-pages:"; - sValue += sName; - sValue += OUString::number(pDoc->GetSdPageCount(PageKind::Standard)) ; - sValue += ";"; + sValue = "page-name:" + sDisplay; + sValue.append(";page-number:"); + sValue.append(OUString::number(static_cast<sal_Int16>(static_cast<sal_uInt16>((pCurrPge->GetPageNum()-1)>>1) + 1)) ); + sValue.append(";total-pages:"); + sValue.append(OUString::number(pDoc->GetSdPageCount(PageKind::Standard)) ); + sValue.append(";"); } } if (sValue.getLength()) - anyAtrribute <<= sValue; + anyAtrribute <<= sValue.makeStringAndClear(); return anyAtrribute; } diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx index 4c6a53b3c1a2..2572ea40b0b2 100644 --- a/sd/source/ui/annotations/annotationtag.cxx +++ b/sd/source/ui/annotations/annotationtag.cxx @@ -60,7 +60,7 @@ static const int DRGPIX = 2; // Drag MinMove i static OUString getInitials( const OUString& rName ) { - OUString sInitials; + OUStringBuffer sInitials; const sal_Unicode * pStr = rName.getStr(); sal_Int32 nLength = rName.getLength(); @@ -76,7 +76,7 @@ static OUString getInitials( const OUString& rName ) // take letter if( nLength ) { - sInitials += OUStringLiteral1( *pStr ); + sInitials.append(*pStr); nLength--; pStr++; } @@ -87,7 +87,7 @@ static OUString getInitials( const OUString& rName ) } } - return sInitials; + return sInitials.makeStringAndClear(); } class AnnotationDragMove : public SdrDragMove diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx index ee9fa6622aaa..dec44f8ed01d 100644 --- a/sd/source/ui/framework/configuration/Configuration.cxx +++ b/sd/source/ui/framework/configuration/Configuration.cxx @@ -195,11 +195,11 @@ Reference<util::XCloneable> SAL_CALL Configuration::createClone() OUString SAL_CALL Configuration::getName() { ::osl::MutexGuard aGuard (maMutex); - OUString aString; + OUStringBuffer aString; if (rBHelper.bDisposed || rBHelper.bInDispose) - aString += "DISPOSED "; - aString += "Configuration["; + aString.append("DISPOSED "); + aString.append("Configuration["); ResourceContainer::const_iterator iResource; for (iResource=mpResourceContainer->begin(); @@ -207,12 +207,12 @@ OUString SAL_CALL Configuration::getName() ++iResource) { if (iResource != mpResourceContainer->begin()) - aString += ", "; - aString += FrameworkHelper::ResourceIdToString(*iResource); + aString.append(", "); + aString.append(FrameworkHelper::ResourceIdToString(*iResource)); } - aString += "]"; + aString.append("]"); - return aString; + return aString.makeStringAndClear(); } void SAL_CALL Configuration::setName (const OUString&) diff --git a/sd/source/ui/framework/tools/FrameworkHelper.cxx b/sd/source/ui/framework/tools/FrameworkHelper.cxx index aff76eeb6dcd..5a4af572f1af 100644 --- a/sd/source/ui/framework/tools/FrameworkHelper.cxx +++ b/sd/source/ui/framework/tools/FrameworkHelper.cxx @@ -750,21 +750,21 @@ void FrameworkHelper::UpdateConfiguration() OUString FrameworkHelper::ResourceIdToString (const Reference<XResourceId>& rxResourceId) { - OUString sString; + OUStringBuffer sString; if (rxResourceId.is()) { - sString += rxResourceId->getResourceURL(); + sString.append(rxResourceId->getResourceURL()); if (rxResourceId->hasAnchor()) { Sequence<OUString> aAnchorURLs (rxResourceId->getAnchorURLs()); for (sal_Int32 nIndex=0; nIndex < aAnchorURLs.getLength(); ++nIndex) { - sString += " | "; - sString += aAnchorURLs[nIndex]; + sString.append(" | "); + sString.append(aAnchorURLs[nIndex]); } } } - return sString; + return sString.makeStringAndClear(); } Reference<XResourceId> FrameworkHelper::CreateResourceId (const OUString& rsResourceURL) diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index a71502a61b45..92ea81841391 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -77,7 +77,7 @@ namespace OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescList ) { - OUString aExtensions; + OUStringBuffer aExtensions; ::std::vector< FilterDesc >::const_iterator aIter( rFilterDescList.begin() ); while (aIter != rFilterDescList.end()) @@ -87,14 +87,14 @@ OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescL if ( aExtensions.indexOf( sWildcard ) == -1 ) { if ( !aExtensions.isEmpty() ) - aExtensions += ";"; - aExtensions += sWildcard; + aExtensions.append(";"); + aExtensions.append(sWildcard); } ++aIter; } - return aExtensions; + return aExtensions.makeStringAndClear(); } void lcl_AddFilter ( ::std::vector< FilterDesc >& rFilterDescList, diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx index a4910d96dbac..64a7c78b3bbc 100644 --- a/sd/source/ui/func/fulinend.cxx +++ b/sd/source/ui/func/fulinend.cxx @@ -103,9 +103,7 @@ void FuLineEnd::DoExecute( SfxRequest& ) while( !bDifferent ) { - aName = aNewName; - aName += " "; - aName += OUString::number(j++); + aName = aNewName + " " + OUString::number(j++); bDifferent = true; for( long i = 0; i < nCount && bDifferent; i++ ) { diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx index c7cb0f0387aa..a55f913a9f84 100644 --- a/sd/source/ui/unoidl/unolayer.cxx +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -484,8 +484,7 @@ uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::insertNewByIndex( sal // Test for existing names while( aLayerName.isEmpty() || rLayerAdmin.GetLayer( aLayerName ) ) { - aLayerName = SdResId(STR_LAYER); - aLayerName += OUString::number(nLayer); + aLayerName = SdResId(STR_LAYER) + OUString::number(nLayer); ++nLayer; } diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 6c69c5e266fa..0b7820679956 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1925,8 +1925,7 @@ private: if (mpOptions->IsPrintPageName()) { - rInfo.msPageString = pPage->GetName(); - rInfo.msPageString += " "; + rInfo.msPageString = pPage->GetName() + " "; } else rInfo.msPageString.clear(); |