[Libreoffice-commits] core.git: 6 commits - filter/source i18nutil/source reportdesign/source sd/inc sd/source sw/source vcl/unx

Caolán McNamara caolanm at redhat.com
Sun Sep 25 20:52:08 UTC 2016


 filter/source/graphicfilter/etiff/etiff.cxx           |   20 +++-----
 i18nutil/source/utility/unicode.cxx                   |    2 
 reportdesign/source/ui/inspection/GeometryHandler.cxx |    3 -
 sd/inc/OutlinerIterator.hxx                           |    5 +-
 sd/source/ui/view/OutlinerIterator.cxx                |   42 ++++++++++--------
 sw/source/core/bastyp/calc.cxx                        |   42 ++++++++++--------
 vcl/unx/generic/fontmanager/fontconfig.cxx            |   11 ++--
 7 files changed, 69 insertions(+), 56 deletions(-)

New commits:
commit 5b8d36d924ad32ecf83ac75dc2d4add7b78ab8c6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 21:23:21 2016 +0100

    avoid coverity#1371177 Missing move assignment operator
    
    Change-Id: Ib31f553915e6a0863a6b3dc53320b9287503a517

diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 6598a3c..8264cb4 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -213,8 +213,7 @@ OUString GeometryHandler::impl_convertToFormula( const uno::Any& _rControlValue
     if ( aParser.isValid() )
         return sName;
 
-    aParser = ReportFormula( impl_isDataField(sName) ? ReportFormula::Field : ReportFormula::Expression, sName );
-    return aParser.getCompleteFormula();
+    return ReportFormula(impl_isDataField(sName) ? ReportFormula::Field : ReportFormula::Expression, sName).getCompleteFormula();
 }
 
 GeometryHandler::GeometryHandler(uno::Reference< uno::XComponentContext > const & context)
commit 6bd3c2ca4b904abfe54509ff292a99a64e228ab8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 21:17:37 2016 +0100

    improve scoping
    
    Change-Id: I69019979b59929ea65bdca56a731ee764fbe3e08

diff --git a/filter/source/graphicfilter/etiff/etiff.cxx b/filter/source/graphicfilter/etiff/etiff.cxx
index 4214f0d..3300d4b 100644
--- a/filter/source/graphicfilter/etiff/etiff.cxx
+++ b/filter/source/graphicfilter/etiff/etiff.cxx
@@ -172,28 +172,26 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem* pFilterCo
     mnLatestIfdPos = m_rOStm.Tell();
     m_rOStm.WriteUInt32( 0 );
 
-    Animation   aAnimation;
-    Bitmap      aBmp;
-
     if( mbStatus )
     {
-        if ( rGraphic.IsAnimated() )
+        Animation aAnimation;
+
+        if (rGraphic.IsAnimated())
             aAnimation = rGraphic.GetAnimation();
         else
         {
-            AnimationBitmap aAnimationBitmap( rGraphic.GetBitmap(), Point(), Size() );
-            aAnimation.Insert( aAnimationBitmap );
+            AnimationBitmap aAnimationBitmap(rGraphic.GetBitmap(), Point(), Size());
+            aAnimation.Insert(aAnimationBitmap);
         }
 
-        sal_uInt16 i;
-        for ( i = 0; i < aAnimation.Count(); i++ )
-            mnSumOfAllPictHeight += aAnimation.Get( i ).aBmpEx.GetSizePixel().Height();
+        for (sal_uInt16 i = 0; i < aAnimation.Count(); ++i)
+            mnSumOfAllPictHeight += aAnimation.Get(i).aBmpEx.GetSizePixel().Height();
 
-        for ( i = 0; mbStatus && ( i < aAnimation.Count() ); i++ )
+        for (sal_uInt16 i = 0; mbStatus && i < aAnimation.Count(); ++i)
         {
             mnPalPos = 0;
             const AnimationBitmap& rAnimationBitmap = aAnimation.Get( i );
-            aBmp = rAnimationBitmap.aBmpEx.GetBitmap();
+            Bitmap aBmp = rAnimationBitmap.aBmpEx.GetBitmap();
             mpAcc = aBmp.AcquireReadAccess();
             if ( mpAcc )
             {
commit 88fe2590901b9c0955b97e0521b20dba9a8a97da
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 21:10:32 2016 +0100

    avoid coverity#1371166 Missing move assignment operator
    
    Change-Id: I0c5559c71f8a961bbab6fbd3a647aeca4a10b44f

diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index cf28e19..6633a1c 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -1220,29 +1220,35 @@ SwSbxValue SwCalc::Prim()
 
 SwSbxValue  SwCalc::Expr()
 {
-    SwSbxValue left = Term(), right;
+    SwSbxValue left = Term();
     m_nLastLeft = left;
     for(;;)
     {
         switch(m_eCurrOper)
         {
-        case CALC_PLUS:
-            GetToken();
-            left.MakeDouble();
-            ( right = Term() ).MakeDouble();
-            left.Compute( SbxPLUS, right );
-            m_nListPor++;
-            break;
-
-        case CALC_MINUS:
-            GetToken();
-            left.MakeDouble();
-            ( right = Term() ).MakeDouble();
-            left.Compute( SbxMINUS, right );
-            break;
-
-        default:
-            return left;
+            case CALC_PLUS:
+            {
+                GetToken();
+                left.MakeDouble();
+                SwSbxValue right(Term());
+                right.MakeDouble();
+                left.Compute(SbxPLUS, right);
+                m_nListPor++;
+                break;
+            }
+            case CALC_MINUS:
+            {
+                GetToken();
+                left.MakeDouble();
+                SwSbxValue right(Term());
+                right.MakeDouble();
+                left.Compute(SbxMINUS, right);
+                break;
+            }
+            default:
+            {
+                return left;
+            }
         }
     }
 }
commit be214eb2e193707f6bd4d1a279a6cadd1b734948
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 21:07:29 2016 +0100

    avoid coverity#1371161 Missing move assignment operator
    
    Change-Id: Ief3dd38ade3fca74ea35e2a1a71637cba3336b59

diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx
index 9c489b1..bb82bbf 100644
--- a/i18nutil/source/utility/unicode.cxx
+++ b/i18nutil/source/utility/unicode.cxx
@@ -976,7 +976,7 @@ OUString SAL_CALL unicode::formatPercent(double dNumber,
     // http://www.unicode.org/cldr/charts/24/by_type/numbers.number_formatting_patterns.html
     // so format using French which has the desired rules
     if (aLangTag.getLanguage() == "es" || aLangTag.getLanguage() == "sl")
-        aLangTag = LanguageTag("fr-FR");
+        aLangTag.reset("fr-FR");
 
     icu::Locale aLocale = LanguageTagIcu::getIcuLocale(aLangTag);
 
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 3f0571e..b0b1b16 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -866,15 +866,14 @@ namespace
         return bIsImpossible;
     }
 
-    LanguageTag getExemplarLangTagForCodePoint(sal_uInt32 currentChar)
+    OUString getExemplarLangTagForCodePoint(sal_uInt32 currentChar)
     {
         int32_t script = u_getIntPropertyValue(currentChar, UCHAR_SCRIPT);
         UScriptCode eScript = static_cast<UScriptCode>(script);
         OStringBuffer aBuf(unicode::getExemplarLanguageForUScriptCode(eScript));
-        const char* pScriptCode = uscript_getShortName(eScript);
-        if (pScriptCode)
+        if (const char* pScriptCode = uscript_getShortName(eScript))
             aBuf.append('-').append(pScriptCode);
-        return LanguageTag(OStringToOUString(aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
+        return OStringToOUString(aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
     }
 
 #if ENABLE_DBUS
@@ -977,7 +976,7 @@ void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
             //#i105784#/rhbz#527719  improve selection of fallback font
             if (aLangAttrib.isEmpty())
             {
-                aLangTag = getExemplarLangTagForCodePoint(nCode);
+                aLangTag.reset(getExemplarLangTagForCodePoint(nCode));
                 aLangAttrib = mapToFontConfigLangTag(aLangTag);
             }
         }
@@ -1109,7 +1108,7 @@ void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
                         //scripts to default to a given language.
                         for (sal_Int32 i = 0; i < nRemainingLen; ++i)
                         {
-                            LanguageTag aOurTag = getExemplarLangTagForCodePoint(pRemainingCodes[i]);
+                            LanguageTag aOurTag(getExemplarLangTagForCodePoint(pRemainingCodes[i]));
                             OString sTag = OUStringToOString(aOurTag.getBcp47(), RTL_TEXTENCODING_UTF8);
                             if (m_aPreviousLangSupportRequests.find(sTag) != m_aPreviousLangSupportRequests.end())
                                 continue;
commit c606f4bfa49b930ab50b98eacbfae9d6d73a180d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 20:55:52 2016 +0100

    coverity#1371240 Missing move assignment operator
    
    Change-Id: Icf7a55fb7c37b5642913b010a54a7690c0593474

diff --git a/sd/inc/OutlinerIterator.hxx b/sd/inc/OutlinerIterator.hxx
index 2fc5a6c..9adac49 100644
--- a/sd/inc/OutlinerIterator.hxx
+++ b/sd/inc/OutlinerIterator.hxx
@@ -81,6 +81,7 @@ public:
         implementation object.
     */
     Iterator (const Iterator& rIterator);
+    Iterator (Iterator&& rIterator);
 
     /** Create a new iterator with the implementation object being the
         provided one.
@@ -97,6 +98,8 @@ public:
             The iterator which to assign from.
     */
     Iterator& operator= (const Iterator& rIterator);
+    Iterator& operator= (Iterator&& rIterator);
+
     /** Return the current position of the iterator.
         @return
             Returns a reference to the current position.  Therefore this
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index 4fd8df0..33a615e 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -73,6 +73,11 @@ Iterator::Iterator (const Iterator& rIterator)
 {
 }
 
+Iterator::Iterator (Iterator&& rIterator)
+    : mxIterator(std::move(rIterator.mxIterator))
+{
+}
+
 Iterator::Iterator (IteratorImplBase* pObject)
     : mxIterator(pObject)
 {
@@ -94,6 +99,12 @@ Iterator& Iterator::operator= (const Iterator& rIterator)
     return *this;
 }
 
+Iterator& Iterator::operator= (Iterator&& rIterator)
+{
+    mxIterator = std::move(rIterator.mxIterator);
+    return *this;
+}
+
 const IteratorPosition& Iterator::operator* () const
 {
     DBG_ASSERT (mxIterator, "::sd::outliner::Iterator::operator* : missing implementation object");
commit 958f7a7b772cff53e441b02c322ffbd80decc9a0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Sep 25 20:49:17 2016 +0100

    impl this with a std::unique_ptr
    
    Change-Id: Ia2a7971bf67bac2ed2c5dd3ef48a17f4f3d59a5d

diff --git a/sd/inc/OutlinerIterator.hxx b/sd/inc/OutlinerIterator.hxx
index b261ed4..2fc5a6c 100644
--- a/sd/inc/OutlinerIterator.hxx
+++ b/sd/inc/OutlinerIterator.hxx
@@ -135,7 +135,7 @@ public:
 
 private:
     /// The implementation object to which most of the methods are forwarded.
-    IteratorImplBase* mpIterator;
+    std::unique_ptr<IteratorImplBase> mxIterator;
 };
 
 /** This class wraps the <type>Outliner</type> class and represents it as
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index 65e3fd1..4fd8df0 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -66,56 +66,53 @@ bool IteratorPosition::operator== (const IteratorPosition& aPosition) const
 
 Iterator::Iterator()
 {
-    mpIterator = nullptr;
 }
 
 Iterator::Iterator (const Iterator& rIterator)
+    : mxIterator(rIterator.mxIterator ? rIterator.mxIterator->Clone() : nullptr)
 {
-    mpIterator = rIterator.mpIterator ? rIterator.mpIterator->Clone() : nullptr;
 }
 
 Iterator::Iterator (IteratorImplBase* pObject)
+    : mxIterator(pObject)
 {
-    mpIterator = pObject;
 }
 
 Iterator::~Iterator()
 {
-    delete mpIterator;
 }
 
 Iterator& Iterator::operator= (const Iterator& rIterator)
 {
     if (this != &rIterator)
     {
-        delete mpIterator;
-        if (rIterator.mpIterator != nullptr)
-            mpIterator = rIterator.mpIterator->Clone();
+        if (rIterator.mxIterator)
+            mxIterator.reset(rIterator.mxIterator->Clone());
         else
-            mpIterator = nullptr;
+            mxIterator.reset();
     }
     return *this;
 }
 
 const IteratorPosition& Iterator::operator* () const
 {
-    DBG_ASSERT (mpIterator!=nullptr, "::sd::outliner::Iterator::operator* : missing implementation object");
-    return mpIterator->GetPosition();
+    DBG_ASSERT (mxIterator, "::sd::outliner::Iterator::operator* : missing implementation object");
+    return mxIterator->GetPosition();
 }
 
 Iterator& Iterator::operator++ ()
 {
-    if (mpIterator!=nullptr)
-        mpIterator->GotoNextText();
+    if (mxIterator)
+        mxIterator->GotoNextText();
     return *this;
 }
 
 bool Iterator::operator== (const Iterator& rIterator)
 {
-    if (mpIterator == nullptr || rIterator.mpIterator==nullptr)
-        return mpIterator == rIterator.mpIterator;
+    if (!mxIterator || !rIterator.mxIterator)
+        return mxIterator.get() == rIterator.mxIterator.get();
     else
-        return *mpIterator == *rIterator.mpIterator;
+        return *mxIterator == *rIterator.mxIterator;
 }
 
 bool Iterator::operator!= (const Iterator& rIterator)
@@ -125,8 +122,8 @@ bool Iterator::operator!= (const Iterator& rIterator)
 
 void Iterator::Reverse()
 {
-    if (mpIterator != nullptr)
-        mpIterator->Reverse();
+    if (mxIterator)
+        mxIterator->Reverse();
 }
 
 //===== IteratorFactory =======================================================


More information about the Libreoffice-commits mailing list