[Libreoffice-commits] core.git: 10 commits - basic/source editeng/source framework/source hwpfilter/source i18npool/source svtools/source

Stephan Bergmann sbergman at redhat.com
Wed Oct 7 02:33:17 PDT 2015


 basic/source/comp/exprtree.cxx                            |    3 
 editeng/source/misc/svxacorr.cxx                          |    4 -
 framework/source/tabwin/tabwindow.cxx                     |    8 --
 hwpfilter/source/drawing.h                                |    3 
 hwpfilter/source/hwpreader.cxx                            |    3 
 i18npool/source/indexentry/indexentrysupplier_default.cxx |    2 
 i18npool/source/localedata/LocaleNode.cxx                 |    9 +-
 svtools/source/control/tabbar.cxx                         |   49 ++++----------
 svtools/source/svrtf/parrtf.cxx                           |   10 +-
 9 files changed, 35 insertions(+), 56 deletions(-)

New commits:
commit 687bba75dadf94b06d0e5d2888e7d312ed668a53
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 11:17:14 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: I2a500b3f376c2dfa073eb7c26978b949412d4dd8

diff --git a/framework/source/tabwin/tabwindow.cxx b/framework/source/tabwin/tabwindow.cxx
index fedbd74..5841126 100644
--- a/framework/source/tabwin/tabwindow.cxx
+++ b/framework/source/tabwin/tabwindow.cxx
@@ -606,15 +606,11 @@ throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::ex
     TabControl* pTabControl = impl_GetTabControl( m_xTabControlWindow );
     if ( pTabControl )
     {
-        sal_uInt16 nCurTabId = pTabControl->GetCurPageId();
         sal_uInt16 nPos      = pTabControl->GetPagePos( sal_uInt16( ID ));
         if ( nPos == TAB_PAGE_NOTFOUND )
             throw css::lang::IndexOutOfBoundsException();
-        else
-        {
-            pTabControl->RemovePage( sal_uInt16( ID ));
-            nCurTabId = pTabControl->GetCurPageId();
-        }
+        pTabControl->RemovePage( sal_uInt16( ID ));
+        sal_uInt16 nCurTabId = pTabControl->GetCurPageId();
         aLock.clear();
         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
 
commit 243fbdf426bcca9ff13053ee179bfe3cc44eb2c6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 11:13:20 2015 +0200

    Abstract out repeated code into a lambda
    
    ...to silence a clang-analyzer-deadcode.DeadStores on the last update of nX
    
    Change-Id: Ifeb2e5294b22270ba134a303fbe5aa1d50025c75

diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index a7f9fc5..b10f5d7 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -1318,52 +1318,37 @@ void TabBar::Resize()
     }
 
     // order the scroll buttons
-    long nHeight = aNewSize.Height();
+    long const nHeight = aNewSize.Height();
     // adapt font height?
     ImplInitSettings( true, false );
 
     long nButtonMargin = BUTTON_MARGIN * GetDPIScaleFactor();
 
     long nX = mbMirrored ? (aNewSize.Width() - nHeight - nButtonMargin) : nButtonMargin;
-    long nXDiff = mbMirrored ? -nHeight : nHeight;
+    long const nXDiff = mbMirrored ? -nHeight : nHeight;
 
     nButtonWidth += nButtonMargin;
 
-    Size aBtnSize( nHeight, nHeight );
-    if (mpImpl->mpFirstButton)
-    {
-        mpImpl->mpFirstButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
-        nX += nXDiff;
-        nButtonWidth += nHeight;
-    }
-    if (mpImpl->mpPrevButton)
-    {
-        mpImpl->mpPrevButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
-        nX += nXDiff;
-        nButtonWidth += nHeight;
-    }
-    if (mpImpl->mpNextButton)
-    {
-        mpImpl->mpNextButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
-        nX += nXDiff;
-        nButtonWidth += nHeight;
-    }
-    if (mpImpl->mpLastButton)
+    Size const aBtnSize( nHeight, nHeight );
+    auto setButton = [aBtnSize, nXDiff, nHeight, &nX, &nButtonWidth](
+        ScopedVclPtr<ImplTabButton> const & button)
     {
-        mpImpl->mpLastButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
-        nX += nXDiff;
-        nButtonWidth += nHeight;
-    }
+        if (button) {
+            button->SetPosSizePixel(Point(nX, 0), aBtnSize);
+            nX += nXDiff;
+            nButtonWidth += nHeight;
+        }
+    };
+
+    setButton(mpImpl->mpFirstButton);
+    setButton(mpImpl->mpPrevButton);
+    setButton(mpImpl->mpNextButton);
+    setButton(mpImpl->mpLastButton);
 
     nButtonWidth += nButtonMargin;
     nX += mbMirrored ? -nButtonMargin : nButtonMargin;
 
-    if (mpImpl->mpAddButton)
-    {
-        mpImpl->mpAddButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
-        nX += nXDiff;
-        nButtonWidth += nHeight;
-    }
+    setButton(mpImpl->mpAddButton);
 
     nButtonWidth += nButtonMargin;
 
commit a868478b2e7a7b74a2fa19b1dfedfa0eb6fe68d8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:55:36 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: I19650204f707c822f9f16a04e1bd1cd8e85a5c67

diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index 1691ed7..a907500 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -202,7 +202,7 @@ int SvRTFParser::_GetNextToken()
                                     if( '\\' == cAnsi &&
                                         '\'' == ( cAnsi = GetNextChar() ))
                                         // read on HexValue
-                                        cAnsi = GetHexValue();
+                                        GetHexValue();
                                     nNextCh = GetNextChar();
                                 }
                                 ScanText();
@@ -426,7 +426,7 @@ void SvRTFParser::ScanText( const sal_Unicode cBreak )
                                 if( '\\' == cAnsi &&
                                     '\'' == ( cAnsi = GetNextChar() ))
                                     // HexValue ueberlesen
-                                    cAnsi = GetHexValue();
+                                    GetHexValue();
                                 nNextCh = GetNextChar();
                             }
                             bNextCh = false;
commit 593df166e6dca29c005e2855d9366756a032f9eb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:55:10 2015 +0200

    Pull assignment out of switch condition
    
    Change-Id: I0a2d6488dcccfb643cb3fce542d013e3f981e657

diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index 562090d..1691ed7 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -64,7 +64,8 @@ int SvRTFParser::_GetNextToken()
         case '\\':
             {
                 // control charaters
-                switch( nNextCh = GetNextChar() )
+                nNextCh = GetNextChar();
+                switch( nNextCh )
                 {
                 case '{':
                 case '}':
@@ -316,7 +317,8 @@ void SvRTFParser::ScanText( const sal_Unicode cBreak )
         {
         case '\\':
             {
-                switch (nNextCh = GetNextChar())
+                nNextCh = GetNextChar();
+                switch (nNextCh)
                 {
                 case '\'':
                     {
commit 33dfe0729fecaf2f40a7d61a9fd8bdcbfba33255
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:53:54 2015 +0200

    Reduce variable scope
    
    Change-Id: I1269bd713bae10f9b6c1d3e797dd7043d24fa8d3

diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index a60588f..e3884dd 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -503,8 +503,7 @@ void LCCTYPENode::generateCode (const OFileWriter &of) const
         fprintf( stderr, "Warning: %s\n",
                 "QuotationEnd equals DoubleQuotationEnd. Not necessarily an issue, but unusual.");
     // Known good values, exclude ASCII single (U+0027, ') and double (U+0022, ") quotes.
-    int ic;
-    switch (ic = aQuoteStart.toChar())
+    switch (int ic = aQuoteStart.toChar())
     {
         case 0x2018:    // LEFT SINGLE QUOTATION MARK
         case 0x201a:    // SINGLE LOW-9 QUOTATION MARK
@@ -518,7 +517,7 @@ void LCCTYPENode::generateCode (const OFileWriter &of) const
             fprintf( stderr, "Warning: %s U+%04X %s\n",
                     "QuotationStart may be wrong:", ic, OSTR( aQuoteStart));
     }
-    switch (ic = aQuoteEnd.toChar())
+    switch (int ic = aQuoteEnd.toChar())
     {
         case 0x2019:    // RIGHT SINGLE QUOTATION MARK
         case 0x201a:    // SINGLE LOW-9 QUOTATION MARK
@@ -532,7 +531,7 @@ void LCCTYPENode::generateCode (const OFileWriter &of) const
             fprintf( stderr, "Warning: %s U+%04X %s\n",
                     "QuotationEnd may be wrong:", ic, OSTR( aQuoteEnd));
     }
-    switch (ic = aDoubleQuoteStart.toChar())
+    switch (int ic = aDoubleQuoteStart.toChar())
     {
         case 0x00ab:    // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
         case 0x00bb:    // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
@@ -546,7 +545,7 @@ void LCCTYPENode::generateCode (const OFileWriter &of) const
             fprintf( stderr, "Warning: %s U+%04X %s\n",
                     "DoubleQuotationStart may be wrong:", ic, OSTR( aDoubleQuoteStart));
     }
-    switch (ic = aDoubleQuoteEnd.toChar())
+    switch (int ic = aDoubleQuoteEnd.toChar())
     {
         case 0x00ab:    // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
         case 0x00bb:    // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
commit 835b6e21b8cb9f1af1e8f92dfeb379bb7cf04d9e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:53:33 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: Ia6bd32061e2ea826aa550a3da17d4147158ce7f8

diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx
index 69f5aeb..871a492 100644
--- a/i18npool/source/indexentry/indexentrysupplier_default.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx
@@ -218,7 +218,7 @@ void Index::makeIndexKeys(const lang::Locale &rLocale, const OUString &algorithm
             case sal_Unicode('('):
                 if (key_count > 0) {
                     sal_Int16 end = i+1;
-                    for (end=i+1; end < len && keyStr[end] != close; end++) ;
+                    for (; end < len && keyStr[end] != close; end++) ;
 
                     if (end >= len) // no found
                         throw RuntimeException();
commit f9e5b678ec02aaf62b73518b69b881ab1666937e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:52:17 2015 +0200

    Reduce variable scope
    
    Change-Id: I5d2d7e7991c3727ed6367fe22ebddd5c2e2e9265

diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
index 6ede0ea..2ccaa73 100644
--- a/hwpfilter/source/drawing.h
+++ b/hwpfilter/source/drawing.h
@@ -321,7 +321,6 @@ static HWPDrawingObject *LoadDrawingObject(void)
     fprintf(stderr, "LoadDrawingObject\n");
 
     HWPDrawingObject *hdo, *head, *prev;
-    int res;
 
     unsigned short link_info;
 
@@ -343,7 +342,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
         }
         else
         {
-            switch (res = HWPDOFunc(hdo, OBJFUNC_LOAD, NULL, 0))
+            switch (int res = HWPDOFunc(hdo, OBJFUNC_LOAD, NULL, 0))
             {
                 case OBJRET_FILE_ERROR:
                     goto error;
commit 41e2f345486f3e5acf7a240e52146fe9b2811c6f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:50:12 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    The code had been like this ever since 16cba77220efab8204eeecb49ccd3ec033efca38
    "#112673# initial checkin of HWP filter."  Assuming that the second line should
    rather read
    
      angle = 1800 - angle * 10;
    
    instead of
    
      angle = 1800 - prop->angle * 10;
    
    does not look too plausible:  It would keep mapping
    
       -1  ->  181
        0  ->  180
        1  ->  179
           :
      179  ->    1
    
    but then would discontinuously map
    
      180  ->  180
      181  ->  179
           :
    
    instead of continuously mapping
    
      180  ->    0
      181  ->   -1
           :
    
    Change-Id: I8cf97eeb53409b18bda6777b09a20331f3c8132a

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 46f8387..13bd651 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -648,8 +648,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
                 }
                 if( prop->angle > 0 && ( prop->gstyle == 1 || prop->gstyle == 4))
                 {
-                    int angle = prop->angle >= 180 ? prop->angle - 180 : prop->angle;
-                    angle = 1800 - prop->angle * 10;
+                    int angle = 1800 - prop->angle * 10;
                     padd( "draw:angle", sXML_CDATA,
                         ascii(Int2Str( angle, "%d", buf)));
                 }
commit 205f85749d4245ddb80657829af74fc1de23622c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:15:29 2015 +0200

    Reduce variable scope
    
    Change-Id: I6a8e4b8f132acff5d75859de570a969ad8c3fa4b

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 912968a..d032d4c 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -723,7 +723,7 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT
     //  at the beginning:   _ or * after Space with the folloeing !Space
     //  at the end:         _ or * before Space (word delimiter?)
 
-    sal_Unicode c, cInsChar = rTxt[ nEndPos ];  // underline or bold
+    sal_Unicode cInsChar = rTxt[ nEndPos ];  // underline or bold
     if( ++nEndPos != rTxt.getLength() &&
         !IsWordDelim( rTxt[ nEndPos ] ) )
         return false;
@@ -737,7 +737,7 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT
 
     while( nPos )
     {
-        switch( c = rTxt[ --nPos ] )
+        switch( sal_Unicode c = rTxt[ --nPos ] )
         {
         case '_':
         case '*':
commit 4d00131b677da3afd1779777dabb275c276221c8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 10:15:14 2015 +0200

    Reduce variable scope
    
    Change-Id: I87850db982f413b328976e043d8386b7577ba17c

diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 53dcfc5..5850072 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -501,10 +501,9 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
 SbiExprNode* SbiExpression::Operand( bool bUsedForTypeOf )
 {
     SbiExprNode *pRes;
-    SbiToken eTok;
 
     // test operand:
-    switch( eTok = pParser->Peek() )
+    switch( SbiToken eTok = pParser->Peek() )
     {
     case SYMBOL:
         pRes = Term();


More information about the Libreoffice-commits mailing list