[Libreoffice-commits] core.git: vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 27 09:07:14 UTC 2018


 vcl/source/edit/textdoc.cxx              |    8 ++++----
 vcl/source/edit/texteng.cxx              |   19 +++++++++----------
 vcl/source/gdi/pdfwriter_impl.cxx        |    8 ++++----
 vcl/unx/generic/dtrans/X11_selection.cxx |    6 +++---
 vcl/unx/gtk/a11y/atkwrapper.cxx          |    6 ++++--
 vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx |   19 +++++++++----------
 6 files changed, 33 insertions(+), 33 deletions(-)

New commits:
commit 82a4ef72d6e34c2f5075069a1b353f7fd41c7595
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 26 15:04:06 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 27 11:06:44 2018 +0200

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

diff --git a/vcl/source/edit/textdoc.cxx b/vcl/source/edit/textdoc.cxx
index 68fa2e8f7398..d9b540ddf86d 100644
--- a/vcl/source/edit/textdoc.cxx
+++ b/vcl/source/edit/textdoc.cxx
@@ -403,17 +403,17 @@ OUString TextDoc::GetText( const sal_Unicode* pSep ) const
 {
     sal_uInt32 nNodes = static_cast<sal_uInt32>(maTextNodes.size());
 
-    OUString aASCIIText;
+    OUStringBuffer aASCIIText;
     const sal_uInt32 nLastNode = nNodes-1;
     for ( sal_uInt32 nNode = 0; nNode < nNodes; ++nNode )
     {
         TextNode* pNode = maTextNodes[ nNode ].get();
-        aASCIIText += pNode->GetText();
+        aASCIIText.append(pNode->GetText());
         if ( pSep && ( nNode != nLastNode ) )
-            aASCIIText += pSep;
+            aASCIIText.append(pSep);
     }
 
-    return aASCIIText;
+    return aASCIIText.makeStringAndClear();
 }
 
 OUString TextDoc::GetText( sal_uInt32 nPara ) const
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 17e1fe0de42e..3205651c6f05 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -262,7 +262,7 @@ OUString TextEngine::GetText( LineEnd aSeparator ) const
 
 OUString TextEngine::GetTextLines( LineEnd aSeparator ) const
 {
-    OUString aText;
+    OUStringBuffer aText;
     const sal_uInt32 nParas = mpTEParaPortions->Count();
     const sal_Unicode* pSep = static_getLineEndText( aSeparator );
     for ( sal_uInt32 nP = 0; nP < nParas; ++nP )
@@ -273,12 +273,12 @@ OUString TextEngine::GetTextLines( LineEnd aSeparator ) const
         for ( size_t nL = 0; nL < nLines; ++nL )
         {
             TextLine& rLine = pTEParaPortion->GetLines()[nL];
-            aText += pTEParaPortion->GetNode()->GetText().copy( rLine.GetStart(), rLine.GetEnd() - rLine.GetStart() );
+            aText.append( pTEParaPortion->GetNode()->GetText().copy( rLine.GetStart(), rLine.GetEnd() - rLine.GetStart() ) );
             if ( pSep && ( ( (nP+1) < nParas ) || ( (nL+1) < nLines ) ) )
-                aText += pSep;
+                aText.append(pSep);
         }
     }
-    return aText;
+    return aText.makeStringAndClear();
 }
 
 OUString TextEngine::GetText( sal_uInt32 nPara ) const
@@ -393,14 +393,13 @@ void TextEngine::ImpInitDoc()
 
 OUString TextEngine::GetText( const TextSelection& rSel, LineEnd aSeparator ) const
 {
-    OUString aText;
-
     if ( !rSel.HasRange() )
-        return aText;
+        return OUString();
 
     TextSelection aSel( rSel );
     aSel.Justify();
 
+    OUStringBuffer aText;
     const sal_uInt32 nStartPara = aSel.GetStart().GetPara();
     const sal_uInt32 nEndPara = aSel.GetEnd().GetPara();
     const sal_Unicode* pSep = static_getLineEndText( aSeparator );
@@ -415,11 +414,11 @@ OUString TextEngine::GetText( const TextSelection& rSel, LineEnd aSeparator ) co
         if ( nNode == nEndPara ) // may also be == nStart!
             nEndPos = aSel.GetEnd().GetIndex();
 
-        aText += pNode->GetText().copy( nStartPos, nEndPos-nStartPos );
+        aText.append(pNode->GetText().copy( nStartPos, nEndPos-nStartPos ));
         if ( nNode < nEndPara )
-            aText += pSep;
+            aText.append(pSep);
     }
-    return aText;
+    return aText.makeStringAndClear();
 }
 
 void TextEngine::ImpRemoveText()
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index b7b5546acafc..85d71d4c7844 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9160,14 +9160,14 @@ OString PDFWriterImpl::copyExternalResources(filter::PDFObjectElement& rPage, co
     }
 
     // Build the dictionary entry string.
-    OString sRet = "/" + rKind + "<<";
+    OStringBuffer sRet("/" + rKind + "<<");
     for (const auto& rPair : aRet)
     {
-        sRet += "/" + rPair.first + " " + OString::number(rPair.second) + " 0 R";
+        sRet.append("/").append(rPair.first).append(" ").append(OString::number(rPair.second)).append(" 0 R");
     }
-    sRet += ">>";
+    sRet.append(">>");
 
-    return sRet;
+    return sRet.makeStringAndClear();
 }
 
 void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index c2d8858d1c61..40455e4756b5 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -521,7 +521,7 @@ SelectionAdaptor* SelectionManager::getAdaptor( Atom selection )
 OUString SelectionManager::convertFromCompound( const char* pText, int nLen )
 {
     osl::MutexGuard aGuard( m_aMutex );
-    OUString aRet;
+    OUStringBuffer aRet;
     if( nLen < 0 )
         nLen = strlen( pText );
 
@@ -539,12 +539,12 @@ OUString SelectionManager::convertFromCompound( const char* pText, int nLen )
                                &nTexts );
     rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
     for( int i = 0; i < nTexts; i++ )
-        aRet += OStringToOUString( pTextList[i], aEncoding );
+        aRet.append(OStringToOUString( pTextList[i], aEncoding ));
 
     if( pTextList )
         XFreeStringList( pTextList );
 
-    return aRet;
+    return aRet.makeStringAndClear();
 }
 
 OString SelectionManager::convertToCompound( const OUString& rText )
diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx
index dc61baab503b..951c758eeac7 100644
--- a/vcl/unx/gtk/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk/a11y/atkwrapper.cxx
@@ -55,6 +55,7 @@
 #include <com/sun/star/beans/Property.hpp>
 
 #include <rtl/ref.hxx>
+#include <rtl/strbuf.hxx>
 #include <osl/diagnose.h>
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/queryinterface.hxx>
@@ -751,17 +752,18 @@ ensureTypeFor( uno::XInterface *pAccessible )
 {
     int i;
     bool bTypes[ aTypeTableSize ] = { false, };
-    OString aTypeName( "OOoAtkObj" );
+    OStringBuffer aTypeNameBuf( "OOoAtkObj" );
 
     for( i = 0; i < aTypeTableSize; i++ )
     {
         if( isOfType( pAccessible, aTypeTable[i].aGetUnoType() ) )
         {
-            aTypeName += aTypeTable[i].name;
+            aTypeNameBuf.append(aTypeTable[i].name);
             bTypes[i] = true;
         }
     }
 
+    OString aTypeName = aTypeNameBuf.makeStringAndClear();
     GType nType = g_type_from_name( aTypeName.getStr() );
     if( nType == G_TYPE_INVALID )
     {
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index e4f5ac395b8d..fd65f6b380d2 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -1844,7 +1844,7 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
     OString aFilterName = OUStringToOString( aShrunkName, RTL_TEXTENCODING_UTF8 );
     gtk_file_filter_set_name( filter, aFilterName.getStr() );
 
-    OUString aTokens;
+    OUStringBuffer aTokens;
 
     bool bAllGlob = rType == "*.*" || rType == "*";
     if (bAllGlob)
@@ -1852,10 +1852,9 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
     else
     {
         sal_Int32 nIndex = 0;
-        OUString aToken;
         do
         {
-            aToken = rType.getToken( 0, ';', nIndex );
+            OUString aToken = rType.getToken( 0, ';', nIndex );
             // Assume all have the "*.<extn>" syntax
             sal_Int32 nStarDot = aToken.lastIndexOf( "*." );
             if (nStarDot >= 0)
@@ -1863,8 +1862,8 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
             if (!aToken.isEmpty())
             {
                 if (!aTokens.isEmpty())
-                    aTokens += ",";
-                aTokens = aTokens += aToken;
+                    aTokens.append(",");
+                aTokens.append(aToken);
                 gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_URI,
                     case_insensitive_filter,
                     g_strdup( OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() ),
@@ -1892,7 +1891,7 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
         gtk_list_store_append (m_pFilterStore, &iter);
         gtk_list_store_set (m_pFilterStore, &iter,
             0, OUStringToOString(shrinkFilterName( rFilter, true ), RTL_TEXTENCODING_UTF8).getStr(),
-            1, OUStringToOString(aTokens, RTL_TEXTENCODING_UTF8).getStr(),
+            1, OUStringToOString(aTokens.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr(),
             2, aFilterName.getStr(),
             3, OUStringToOString(rType, RTL_TEXTENCODING_UTF8).getStr(),
             -1);
@@ -1938,15 +1937,15 @@ void SalGtkFilePicker::SetFilters()
         }
         if (aAllFormats.size() > 1)
         {
-            OUString sAllFilter;
+            OUStringBuffer sAllFilter;
             for (auto const& format : aAllFormats)
             {
                 if (!sAllFilter.isEmpty())
-                    sAllFilter += ";";
-                sAllFilter += format;
+                    sAllFilter.append(";");
+                sAllFilter.append(format);
             }
             sPseudoFilter = getResString(FILE_PICKER_ALLFORMATS);
-            m_pPseudoFilter = implAddFilter( sPseudoFilter, sAllFilter );
+            m_pPseudoFilter = implAddFilter( sPseudoFilter, sAllFilter.makeStringAndClear() );
         }
     }
 


More information about the Libreoffice-commits mailing list