[Libreoffice-commits] core.git: sfx2/source starmath/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 30 09:06:35 UTC 2018


 sfx2/source/appl/newhelp.cxx               |   23 ++++++++++++-----------
 sfx2/source/control/unoctitm.cxx           |    7 ++++---
 sfx2/source/dialog/filedlghelper.cxx       |    6 ++----
 sfx2/source/dialog/styledlg.cxx            |   12 +++++-------
 sfx2/source/dialog/templdlg.cxx            |   10 +++++-----
 sfx2/source/doc/docfilt.cxx                |    8 ++++----
 sfx2/source/view/lokhelper.cxx             |   14 ++++++++------
 starmath/source/mathtype.cxx               |   18 +++++++++---------
 starmath/source/mathtype.hxx               |    2 +-
 svx/source/dialog/ClassificationCommon.cxx |    8 ++++----
 svx/source/fmcomp/fmgridcl.cxx             |    8 ++------
 svx/source/form/fmobj.cxx                  |    3 +--
 svx/source/gallery2/galbrws1.cxx           |   12 +++---------
 13 files changed, 60 insertions(+), 71 deletions(-)

New commits:
commit 70bfdd828b01e9db0713b87645ffe39f3dc21c7e
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Jul 28 18:01:57 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 30 11:06:14 2018 +0200

    loplugin:stringloop in sfx2..svx
    
    Change-Id: Ie4ca2421f00259f974b6d94f883adfa11600b1fe
    Reviewed-on: https://gerrit.libreoffice.org/58251
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index c7bd7f9300ea..eebd30f46362 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -198,7 +198,7 @@ namespace sfx2
     OUString PrepareSearchString( const OUString& rSearchString,
                                 const Reference< XBreakIterator >& xBreak, bool bForSearch )
     {
-        OUString sSearchStr;
+        OUStringBuffer sSearchStr;
         sal_Int32 nStartPos = 0;
         const lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
         Boundary aBoundary = xBreak->getWordBoundary(
@@ -220,18 +220,18 @@ namespace sfx2
                     if ( !sSearchStr.isEmpty() )
                     {
                         if ( bForSearch )
-                            sSearchStr += " ";
+                            sSearchStr.append(" ");
                         else
-                            sSearchStr += "|";
+                            sSearchStr.append("|");
                     }
-                    sSearchStr += sSearchToken;
+                    sSearchStr.append(sSearchToken);
                 }
             }
             aBoundary = xBreak->nextWord( rSearchString, nStartPos,
                                           aLocale, WordType::ANYWORD_IGNOREWHITESPACES );
         }
 
-        return sSearchStr;
+        return sSearchStr.makeStringAndClear();
     }
 
 // namespace sfx2
@@ -954,20 +954,21 @@ SearchTabPage_Impl::~SearchTabPage_Impl()
 void SearchTabPage_Impl::dispose()
 {
     SvtViewOptions aViewOpt( EViewType::TabPage, CONFIGNAME_SEARCHPAGE );
-    OUString aUserData =
-        OUString::number( m_pFullWordsCB->IsChecked() ? 1 : 0 ) + ";" +
-        OUString::number( m_pScopeCB->IsChecked() ? 1 : 0 );
+    OUStringBuffer aUserData;
+    aUserData.append(OUString::number( m_pFullWordsCB->IsChecked() ? 1 : 0 ))
+        .append(";")
+        .append(OUString::number( m_pScopeCB->IsChecked() ? 1 : 0 ));
     sal_Int32 nCount = std::min( m_pSearchED->GetEntryCount(), sal_Int32(10) );  // save only 10 entries
 
     for ( sal_Int32 i = 0; i < nCount; ++i )
     {
-        aUserData += ";" + INetURLObject::encode(
+        aUserData.append(";").append(INetURLObject::encode(
             m_pSearchED->GetEntry(i),
             INetURLObject::PART_UNO_PARAM_VALUE,
-            INetURLObject::EncodeMechanism::All );
+            INetURLObject::EncodeMechanism::All ));
     }
 
-    Any aUserItem = makeAny( aUserData );
+    Any aUserItem = makeAny( aUserData.makeStringAndClear() );
     aViewOpt.SetUserItem( USERITEM_NAME, aUserItem );
 
     m_pSearchED.clear();
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 15e488fb1f87..2bf002844284 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -531,13 +531,14 @@ void UsageInfo::save()
 
     if( file.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) == osl::File::E_None )
     {
-        OString aUsageInfoMsg = "Document Type;Command;Count";
+        OStringBuffer aUsageInfoMsg("Document Type;Command;Count");
 
         for (auto const& elem : maUsage)
-            aUsageInfoMsg += "\n" + elem.first.toUtf8() + ";" + OString::number(elem.second);
+            aUsageInfoMsg.append("\n").append(elem.first.toUtf8()).append(";").append(OString::number(elem.second));
 
         sal_uInt64 written = 0;
-        file.write(aUsageInfoMsg.pData->buffer, aUsageInfoMsg.getLength(), written);
+        auto s = aUsageInfoMsg.makeStringAndClear();
+        file.write(s.getStr(), s.getLength(), written);
         file.close();
     }
 }
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 040dd203dbb8..8b73bd03d52f 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1862,10 +1862,9 @@ void FileDialogHelper_Impl::addGraphicFilter()
     for ( i = 0; i < nCount; i++ )
     {
         j = 0;
-        OUString sWildcard;
         while( true )
         {
-            sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
+            OUString sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
             if ( sWildcard.isEmpty() )
                 break;
             if ( aExtensions.indexOf( sWildcard ) == -1 )
@@ -1902,10 +1901,9 @@ void FileDialogHelper_Impl::addGraphicFilter()
         OUString aName = mpGraphicFilter->GetImportFormatName( i );
         OUString aExt;
         j = 0;
-        OUString sWildcard;
         while( true )
         {
-            sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
+            OUString sWildcard = mpGraphicFilter->GetImportWildcard( i, j++ );
             if ( sWildcard.isEmpty() )
                 break;
             if ( aExt.indexOf( sWildcard ) == -1 )
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
index 8cafb0ec0eba..baa1368d7c5b 100644
--- a/sfx2/source/dialog/styledlg.cxx
+++ b/sfx2/source/dialog/styledlg.cxx
@@ -133,15 +133,13 @@ IMPL_LINK_NOARG( SfxStyleDialog, CancelHdl, Button *, void )
 
 OUString SfxStyleDialog::GenerateUnusedName(SfxStyleSheetBasePool &rPool)
 {
-    OUString aNoName(SfxResId(STR_NONAME));
-    sal_uInt16 nNo = 1;
-    OUString aNo(aNoName);
-    aNoName += OUString::number(nNo);
+    OUString aNo(SfxResId(STR_NONAME));
+    sal_uInt16 i = 1;
+    OUString aNoName = aNo + OUString::number(i);
     while (rPool.Find(aNoName))
     {
-        ++nNo;
-        aNoName = aNo;
-        aNoName += OUString::number(nNo);
+        ++i;
+        aNoName = aNo + OUString::number(i);
     }
     return aNoName;
 }
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 118389f77427..4b68f20dd4e6 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1842,8 +1842,8 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
         SvTreeListEntry* pEntry = pTreeBox->IsVisible() ? pTreeBox->FirstSelected() : aFmtLb->FirstSelected();
         const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
 
-        OUString aMsg = SfxResId(STR_DELETE_STYLE_USED)
-                      + SfxResId(STR_DELETE_STYLE);
+        OUStringBuffer aMsg;
+        aMsg.append(SfxResId(STR_DELETE_STYLE_USED)).append(SfxResId(STR_DELETE_STYLE));
 
         while (pEntry)
         {
@@ -1856,8 +1856,8 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
             if ( pStyle->IsUsed() )  // pStyle is in use in the document?
             {
                 if (bUsedStyle) // add a separator for the second and later styles
-                    aMsg += ", ";
-                aMsg += aTemplName;
+                    aMsg.append(", ");
+                aMsg.append(aTemplName);
                 bUsedStyle = true;
             }
 
@@ -1871,7 +1871,7 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl()
         {
             std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
                                                                      VclMessageType::Question, VclButtonsType::YesNo,
-                                                                     aMsg));
+                                                                     aMsg.makeStringAndClear()));
             aApproved = xBox->run() == RET_YES;
         }
 
diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx
index c42de0b236f3..500b0ad224fc 100644
--- a/sfx2/source/doc/docfilt.cxx
+++ b/sfx2/source/doc/docfilt.cxx
@@ -68,16 +68,16 @@ SfxFilter::SfxFilter( const OUString &rName,
     mbEnabled(bEnabled)
 {
     OUString aExts = GetWildcard().getGlob();
-    OUString glob;
+    OUStringBuffer glob;
     OUString aRet;
     sal_uInt16 nPos = 0;
     while (!(aRet = aExts.getToken(nPos++, ';')).isEmpty() )
     {
         if (!glob.isEmpty())
-            glob += ";";
-        glob += aRet;
+            glob.append(";");
+        glob.append(aRet);
     }
-    aWildCard.setGlob(glob);
+    aWildCard.setGlob(glob.makeStringAndClear());
 }
 
 SfxFilter::~SfxFilter()
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index be2d5e3887a2..20481ac61e15 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -172,20 +172,22 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
     if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
         return;
 
-    OString aPayload = OString("{ \"id\": \"") + OString::number(nLOKWindowId) + OString("\"");
-    aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
+    OStringBuffer aPayload;
+    aPayload.append("{ \"id\": \"").append(OString::number(nLOKWindowId)).append("\"");
+    aPayload.append(", \"action\": \"").append(OUStringToOString(rAction, RTL_TEXTENCODING_UTF8)).append("\"");
 
     for (const auto& rItem: rPayload)
     {
         if (!rItem.first.isEmpty() && !rItem.second.isEmpty())
         {
-            aPayload += OString(", \"") + rItem.first + OString("\": \"") +
-                rItem.second + OString("\"");
+            aPayload.append(", \"").append(rItem.first).append("\": \"")
+                .append(rItem.second).append("\"");
         }
     }
-    aPayload += "}";
+    aPayload.append("}");
 
-    pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
+    auto s = aPayload.makeStringAndClear();
+    pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, s.getStr());
 }
 
 void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 611ea68d3019..af59301b8f80 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -2759,28 +2759,28 @@ void MathType::HandleEmblishments()
         case 0x05:
             if (!nPostSup)
             {
-                sPost += " sup {}";
+                sPost.append(" sup {}");
                 nPostSup = sPost.getLength();
             }
-            sPost = sPost.replaceAt(nPostSup-1,0," ' ");
+            sPost.insert(nPostSup-1," ' ");
             nPostSup += 3;
             break;
         case 0x06:
             if (!nPostSup)
             {
-                sPost += " sup {}";
+                sPost.append(" sup {}");
                 nPostSup = sPost.getLength();
             }
-            sPost = sPost.replaceAt(nPostSup-1,0," '' ");
+            sPost.insert(nPostSup-1," '' ");
             nPostSup += 4;
             break;
         case 0x07:
             if (!nPostlSup)
             {
-                sPost += " lsup {}";
+                sPost.append(" lsup {}");
                 nPostlSup = sPost.getLength();
             }
-            sPost = sPost.replaceAt(nPostlSup-1,0," ' ");
+            sPost.insert(nPostlSup-1," ' ");
             nPostlSup += 3;
             break;
         case 0x08:
@@ -2801,10 +2801,10 @@ void MathType::HandleEmblishments()
         case 0x12:
             if (!nPostSup)
             {
-                sPost += " sup {}";
+                sPost.append(" sup {}");
                 nPostSup = sPost.getLength();
             }
-            sPost = sPost.replaceAt(nPostSup-1,0," ''' ");
+            sPost.insert(nPostSup-1," ''' ");
             nPostSup += 5;
             break;
         case 0x14:
@@ -2882,7 +2882,7 @@ bool MathType::HandleChar(sal_Int32 &rTextStart, int &rSetSize, int nLevel,
         //follows the char and nPostSup and nPostlSup are the
         //indexes at which this class of emblishment is
         //collated together
-        sPost.clear();
+        sPost = "";
         nPostSup = nPostlSup = 0;
         int nOriglen=rRet.getLength()-rTextStart;
         rRet.append(" {");  // #i24340# make what would be "vec {A}_n" become "{vec {A}}_n"
diff --git a/starmath/source/mathtype.hxx b/starmath/source/mathtype.hxx
index f69ebccf7b19..1e3a744d7789 100644
--- a/starmath/source/mathtype.hxx
+++ b/starmath/source/mathtype.hxx
@@ -165,7 +165,7 @@ private:
     sal_Int16 nLastSize;
     sal_uInt8 nSpec;
     bool  bIsReInterpBrace;
-    OUString  sPost;
+    OUStringBuffer sPost;
     sal_Int32 nPostSup;
     sal_Int32 nPostlSup;
     sal_uInt8 nTypeFace;
diff --git a/svx/source/dialog/ClassificationCommon.cxx b/svx/source/dialog/ClassificationCommon.cxx
index 66d68ff66fa9..cd5dc7324d02 100644
--- a/svx/source/dialog/ClassificationCommon.cxx
+++ b/svx/source/dialog/ClassificationCommon.cxx
@@ -20,7 +20,7 @@ namespace classification
 {
 OUString convertClassificationResultToString(std::vector<svx::ClassificationResult> const& rResults)
 {
-    OUString sRepresentation = "";
+    OUStringBuffer sRepresentation;
 
     for (svx::ClassificationResult const& rResult : rResults)
     {
@@ -30,15 +30,15 @@ OUString convertClassificationResultToString(std::vector<svx::ClassificationResu
             case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
             case svx::ClassificationType::MARKING:
             case svx::ClassificationType::TEXT:
-                sRepresentation += rResult.msName;
+                sRepresentation.append(rResult.msName);
                 break;
 
             case svx::ClassificationType::PARAGRAPH:
-                sRepresentation += " ";
+                sRepresentation.append(" ");
                 break;
         }
     }
-    return sRepresentation;
+    return sRepresentation.makeStringAndClear();
 }
 
 OUString getProperty(uno::Reference<beans::XPropertyContainer> const& rxPropertyContainer,
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 2d957ad19c5c..9c6668fa0ea1 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -563,8 +563,6 @@ IMPL_LINK_NOARG( FmGridHeader, OnAsyncExecuteDrop, void*, void )
 
         if (bDateNTimeCol)
         {
-            OUString sRealName,sPurePostfix;
-
             OUString aPostfix[] = {
                 SvxResId(RID_STR_POSTFIX_DATE),
                 SvxResId(RID_STR_POSTFIX_TIME)
@@ -572,12 +570,10 @@ IMPL_LINK_NOARG( FmGridHeader, OnAsyncExecuteDrop, void*, void )
 
             for ( size_t i=0; i<2; ++i )
             {
-                sPurePostfix = comphelper::string::stripStart(aPostfix[i], ' ');
+                OUString sPurePostfix = comphelper::string::stripStart(aPostfix[i], ' ');
                 sPurePostfix = comphelper::string::stripStart(sPurePostfix, '(');
                 sPurePostfix = comphelper::string::stripEnd(sPurePostfix, ')');
-                sRealName = sFieldName;
-                sRealName += "_";
-                sRealName += sPurePostfix;
+                OUString sRealName = sFieldName + "_" + sPurePostfix;
                 if (i)
                     xSecondCol->setPropertyValue(FM_PROP_NAME, makeAny(sRealName));
                 else
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index cb9b4ca44c29..4b335e8b0e96 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -408,14 +408,13 @@ namespace
 
         // while the current content is a form
         OUString sReturn;
-        OUString sCurrentIndex;
         while (xChild.is())
         {
             // get the content's relative pos within its parent container
             sal_Int32 nPos = getElementPos(xParent, xChild);
 
             // prepend this current relative pos
-            sCurrentIndex = OUString::number(nPos);
+            OUString sCurrentIndex = OUString::number(nPos);
             if (!sReturn.isEmpty())
             {
                 sCurrentIndex += "\\";
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx
index a860ad8ac592..bce9abbdbb0b 100644
--- a/svx/source/gallery2/galbrws1.cxx
+++ b/svx/source/gallery2/galbrws1.cxx
@@ -293,9 +293,7 @@ void GalleryBrowser1::ImplEndGalleryThemeProperties(bool bCreateNew)
 
             while( mpGallery->HasTheme( aTitle ) && ( nCount++ < 16000 ) )
             {
-                aTitle = mpExchangeData->aEditedTitle;
-                aTitle += " ";
-                aTitle += OUString::number( nCount );
+                aTitle = mpExchangeData->aEditedTitle + " " + OUString::number( nCount );
             }
 
             mpGallery->RenameTheme( aName, aTitle );
@@ -375,9 +373,7 @@ void GalleryBrowser1::ImplExecute(const OString &rIdent)
 
                 while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
                 {
-                    aName = aNewName;
-                    aName += " ";
-                    aName += OUString::number( nCount );
+                    aName = aNewName + " " + OUString::number( nCount );
                 }
 
                 mpGallery->RenameTheme( aOldName, aName );
@@ -597,9 +593,7 @@ IMPL_LINK_NOARG(GalleryBrowser1, ClickNewThemeHdl, Button*, void)
 
     while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
     {
-        aName = aNewTheme;
-        aName += " ";
-        aName += OUString::number( nCount );
+        aName = aNewTheme + " " + OUString::number( nCount );
     }
 
     if( !mpGallery->HasTheme( aName ) && mpGallery->CreateTheme( aName ) )


More information about the Libreoffice-commits mailing list