[Libreoffice-commits] core.git: starmath/inc starmath/source stoc/source svl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 16 06:16:31 UTC 2020


 starmath/inc/utility.hxx                  |    3 +--
 starmath/source/ElementsDockingWindow.cxx |   20 ++++++++++++++++----
 starmath/source/mathmlexport.cxx          |    5 ++++-
 starmath/source/mathtype.cxx              |    7 ++++++-
 starmath/source/node.cxx                  |   30 +++++++++++++++++-------------
 starmath/source/parse.cxx                 |    8 ++++++--
 starmath/source/view.cxx                  |    6 ++++--
 stoc/source/corereflection/crefl.cxx      |    6 ++++--
 stoc/source/typeconv/convert.cxx          |    3 ++-
 svl/source/items/itemset.cxx              |   16 ++++++++++++----
 svl/source/numbers/zforfind.cxx           |   19 ++++++++++++++-----
 svl/source/numbers/zformat.cxx            |   16 ++++++++++++----
 12 files changed, 98 insertions(+), 41 deletions(-)

New commits:
commit cd7471335a05e7dd7eca16ac0b181d96cfa7912b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 15 19:33:03 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Apr 16 08:15:54 2020 +0200

    loplugin:buriedassign in starmath..svl
    
    Change-Id: I979faf4c476a7de91a0b6e06dd8717cee25525f1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92313
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/starmath/inc/utility.hxx b/starmath/inc/utility.hxx
index 0ce2ff346079..2a462b98d727 100644
--- a/starmath/inc/utility.hxx
+++ b/starmath/inc/utility.hxx
@@ -46,8 +46,7 @@ inline Fraction Sm100th_mmToPts(long nNum100th_mm)
     // 'nNum100th_mm' (in 100th of mm).
 {
     SAL_WARN_IF( nNum100th_mm < 0, "starmath", "Ooops..." );
-    Fraction  aTmp (7227L, 254000L);
-    return aTmp *= Fraction(nNum100th_mm);
+    return Fraction(7227L, 254000L) * Fraction(nNum100th_mm);
 }
 
 
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index 8eca86c24077..ebaa6b9e4fdd 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -1016,7 +1016,10 @@ FactoryFunction SmElementsControl::GetUITestFactory() const
 
 bool SmElementsControl::itemIsSeparator(sal_uInt16 nPos) const
 {
-    if (nPos < m_nCurrentOffset || (nPos -= m_nCurrentOffset) >= maElementList.size())
+    if (nPos < m_nCurrentOffset)
+        return true;
+    nPos -= m_nCurrentOffset;
+    if (nPos >= maElementList.size())
         return true;
     return maElementList[nPos]->isSeparator();
 }
@@ -1033,7 +1036,10 @@ css::uno::Reference<css::accessibility::XAccessible> SmElementsControl::CreateAc
 
 bool SmElementsControl::itemTrigger(sal_uInt16 nPos)
 {
-    if (nPos < m_nCurrentOffset || (nPos -= m_nCurrentOffset) >= maElementList.size())
+    if (nPos < m_nCurrentOffset)
+        return false;
+    nPos -= m_nCurrentOffset;
+    if (nPos >= maElementList.size())
         return false;
 
     maSelectHdlLink.Call(*maElementList[nPos]);
@@ -1043,7 +1049,10 @@ bool SmElementsControl::itemTrigger(sal_uInt16 nPos)
 
 tools::Rectangle SmElementsControl::itemPosRect(sal_uInt16 nPos) const
 {
-    if (nPos < m_nCurrentOffset || (nPos -= m_nCurrentOffset) >= maElementList.size())
+    if (nPos < m_nCurrentOffset)
+        return tools::Rectangle();
+    nPos -= m_nCurrentOffset;
+    if (nPos >= maElementList.size())
         return tools::Rectangle();
 
     SmElement* pItem = maElementList[nPos].get();
@@ -1080,7 +1089,10 @@ void SmElementsControl::setItemHighlighted(sal_uInt16 nPos)
 
 OUString SmElementsControl::itemName(sal_uInt16 nPos) const
 {
-    if (nPos < m_nCurrentOffset || (nPos -= m_nCurrentOffset) >= maElementList.size())
+    if (nPos < m_nCurrentOffset)
+        return OUString();
+    nPos -= m_nCurrentOffset;
+    if (nPos >= maElementList.size())
         return OUString();
 
     return maElementList[nPos]->getHelpText();
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 7fc7243d7e19..c619f22f4dc1 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -1139,8 +1139,11 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
     int nItalic = -1;   // for the following variables: -1 = yet undefined; 0 = false; 1 = true;
     int nSansSerifFixed   = -1;
     SmTokenType eNodeType = TUNKNOWN;
-    while (lcl_HasEffectOnMathvariant( (eNodeType = pNode->GetToken().eType) ))
+    for (;;)
     {
+        eNodeType = pNode->GetToken().eType;
+        if (!lcl_HasEffectOnMathvariant(eNodeType))
+            break;
         switch (eNodeType)
         {
             case TBOLD      : nBold   = 1; break;
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 06655e112597..d0889ce393d8 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -684,8 +684,13 @@ bool MathType::HandleRecords(int nLevel, sal_uInt8 nSelector,
             {
                 sal_Unicode cChar = 0;
                 sal_Int32 nI = rRet.getLength()-1;
-                while (nI && ((cChar = rRet[nI]) == ' '))
+                while (nI)
+                {
+                    cChar = rRet[nI];
+                    if (cChar != ' ')
+                        break;
                     --nI;
+                }
                 if ((cChar == '=') || (cChar == '+') || (cChar == '-'))
                     rRet.append("{}");
             }
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index b70bdfef08a9..1ab81d10d0e4 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -322,20 +322,24 @@ const SmNode * SmNode::FindRectClosestTo(const Point &rPoint) const
             if (!pNode)
                 continue;
 
-            long  nTmp;
             const SmNode *pFound = pNode->FindRectClosestTo(rPoint);
-            if (pFound  &&  (nTmp = pFound->OrientedDist(rPoint)) < nDist)
-            {   nDist   = nTmp;
-                pResult = pFound;
-
-                // quit immediately if 'rPoint' is inside the *should not
-                // overlap with other rectangles* part.
-                // This (partly) serves for getting the attributes in eg
-                // "bar overstrike a".
-                // ('nDist < 0' is used as *quick shot* to avoid evaluation of
-                // the following expression, where the result is already determined)
-                if (nDist < 0  &&  pFound->IsInsideRect(rPoint))
-                    break;
+            if (pFound)
+            {
+                long nTmp = pFound->OrientedDist(rPoint);
+                if (nTmp < nDist)
+                {
+                    nDist   = nTmp;
+                    pResult = pFound;
+
+                    // quit immediately if 'rPoint' is inside the *should not
+                    // overlap with other rectangles* part.
+                    // This (partly) serves for getting the attributes in eg
+                    // "bar overstrike a".
+                    // ('nDist < 0' is used as *quick shot* to avoid evaluation of
+                    // the following expression, where the result is already determined)
+                    if (nDist < 0  &&  pFound->IsInsideRect(rPoint))
+                        break;
+                }
             }
         }
     }
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 2f0f908d4b7b..7a39233a762b 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1538,9 +1538,13 @@ std::unique_ptr<SmNode> SmParser::DoTerm(bool bGroupNumberIdent)
             {
                 std::stack<std::unique_ptr<SmStructureNode>> aStack;
                 bool    bIsAttr;
-                while ( (bIsAttr = TokenInGroup(TG::Attribute))
-                       ||  TokenInGroup(TG::FontAttr))
+                for (;;)
+                {
+                    bIsAttr = TokenInGroup(TG::Attribute);
+                    if (!bIsAttr && !TokenInGroup(TG::FontAttr))
+                        break;
                     aStack.push(bIsAttr ? DoAttribut() : DoFontAttribut());
+                }
 
                 auto xFirstNode = DoPower();
                 while (!aStack.empty())
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index d78aa25628cf..be02ccd488c2 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1582,7 +1582,8 @@ void SmViewShell::Execute(SfxRequest& rReq)
             SotClipboardFormatId nId = SOT_FORMAT_SYSTEM_START; //dummy initialize to avoid warning
             if  ( aDataHelper.GetTransferable().is() )
             {
-                if (aDataHelper.HasFormat(nId = SotClipboardFormatId::MATHML))
+                nId = SotClipboardFormatId::MATHML;
+                if (aDataHelper.HasFormat(nId))
                 {
                     xStrm = aDataHelper.GetInputStream(nId, "");
                     if (xStrm.is())
@@ -1599,7 +1600,8 @@ void SmViewShell::Execute(SfxRequest& rReq)
                 }
                 else
                 {
-                    if (aDataHelper.HasFormat(nId = SotClipboardFormatId::STRING))
+                    nId = SotClipboardFormatId::STRING;
+                    if (aDataHelper.HasFormat(nId))
                     {
                         // In case of FORMAT_STRING no stream exists, need to generate one
                         OUString aString;
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx
index 55b742d1a2fe..e4f879495c3f 100644
--- a/stoc/source/corereflection/crefl.cxx
+++ b/stoc/source/corereflection/crefl.cxx
@@ -200,7 +200,8 @@ Reference< XIdlClass > IdlReflectionServiceImpl::forName( const OUString & rType
         typelib_typedescription_getByName( &pTD, rTypeName.pData );
         if (pTD)
         {
-            if ((xRet = constructClass( pTD )).is())
+            xRet = constructClass( pTD );
+            if (xRet.is())
                 _aElements.setValue( rTypeName, makeAny( xRet ) ); // update
             typelib_typedescription_release( pTD );
         }
@@ -287,7 +288,8 @@ Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescriptio
     }
     else
     {
-        if ((xRet = constructClass( pTypeDescr )).is())
+        xRet = constructClass( pTypeDescr );
+        if (xRet.is())
             _aElements.setValue( aName, makeAny( xRet ) ); // update
     }
 
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index 933e89c24d87..554c13400fdd 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -507,7 +507,8 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
                 "value is not interface",
                 Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 );
         }
-        if (! (aRet = (*ifc)->queryInterface(aDestType )).hasValue())
+        aRet = (*ifc)->queryInterface(aDestType );
+        if (! aRet.hasValue())
         {
             throw CannotConvertException(
                 "value does not implement " + aDestType.getTypeName(),
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 364fb429c5d0..180c76a6a4a7 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -425,7 +425,10 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich,
                 pPtr += 2;
             }
         }
-    } while (bSrchInParent && nullptr != (pCurrentSet = pCurrentSet->m_pParent));
+        if (!bSrchInParent)
+            break;
+        pCurrentSet = pCurrentSet->m_pParent;
+    } while (nullptr != pCurrentSet);
     return eRet;
 }
 
@@ -695,10 +698,12 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo )
                      {return (lhs.first-1) <= rhs.second && (rhs.first-1) <= lhs.second;};
 
     std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator it = aRangesTable.begin();
-    std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator itNext;
     // we got at least one range
-    while ((itNext = std::next(it)) != aRangesTable.end())
+    for (;;)
     {
+        auto itNext = std::next(it);
+        if (itNext == aRangesTable.end())
+            break;
         // check neighbouring ranges, find first range which overlaps or adjoins a previous range
         if (needMerge(*it, *itNext))
         {
@@ -923,7 +928,10 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
 //TODO: Search until end of Range: What are we supposed to do now? To the Parent or Default??
 //      if( !*pPtr )            // Until the end of the search Range?
 //      break;
-    } while (bSrchInParent && nullptr != (pCurrentSet = pCurrentSet->m_pParent));
+        if (!bSrchInParent)
+            break;
+        pCurrentSet = pCurrentSet->m_pParent;
+    } while (nullptr != pCurrentSet);
 
     // Get the Default from the Pool and return
     SAL_WARN_IF(!m_pPool, "svl.items", "no Pool, but status is ambiguous, with ID/pos " << nWhich);
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 32b471a5df23..73a70c9efc1a 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -219,8 +219,11 @@ bool ImpSvNumberInputScan::NextNumberStringSymbol( const sal_Unicode*& pStr,
     const sal_Unicode* pHere = pStr;
     sal_Int32 nChars = 0;
 
-    while ( ((cToken = *pHere) != 0) && eState != SsStop)
+    for (;;)
     {
+        cToken = *pHere;
+        if (cToken == 0 || eState == SsStop)
+            break;
         pHere++;
         switch (eState)
         {
@@ -292,8 +295,11 @@ bool ImpSvNumberInputScan::SkipThousands( const sal_Unicode*& pStr,
     ScanState eState = SsStart;
     sal_Int32 nCounter = 0; // counts 3 digits
 
-    while ( ((cToken = *pHere) != 0) && eState != SsStop)
+    for (;;)
     {
+        cToken = *pHere;
+        if (cToken == 0 || eState == SsStop)
+            break;
         pHere++;
         switch (eState)
         {
@@ -1135,13 +1141,15 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
     switch (eDateOrder)
     {
         case DateOrder::DMY:               // "day" value out of range => ISO 8601 year
-            if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 31)
+            n = sStrArray[nNums[0]].toInt32();
+            if (n < 1 || n > 31)
             {
                 nCanForceToIso8601 = 2;
             }
         break;
         case DateOrder::MDY:               // "month" value out of range => ISO 8601 year
-            if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 12)
+            n = sStrArray[nNums[0]].toInt32();
+            if (n < 1 || n > 12)
             {
                 nCanForceToIso8601 = 2;
             }
@@ -1426,7 +1434,8 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt )
                                 do
                                 {
                                     ++nPos;
-                                } while ((c = rPat[--nPatCheck]) != 'Y' && c != 'M' && c != 'D');
+                                    c = rPat[--nPatCheck];
+                                } while (c != 'Y' && c != 'M' && c != 'D');
                             }
                     }
                 }
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index e522977afdff..0dbe9bc25b83 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1444,8 +1444,11 @@ sal_Int32 SvNumberformat::ImpGetNumber(OUStringBuffer& rString,
     sal_Unicode cToken;
     sal_Int32 nLen = rString.getLength();
     OUStringBuffer sBuffSymbol;
-    while ( nPos < nLen && ((cToken = rString[nPos]) != ']') )
+    while ( nPos < nLen )
     {
+        cToken = rString[nPos];
+        if (cToken == ']')
+            break;
         if (cToken == ' ')
         {                                               // delete spaces
             rString.remove(nPos,1);
@@ -1610,8 +1613,11 @@ SvNumberformat::LocaleType SvNumberformat::ImpGetLocaleType(const OUString& rStr
     sal_Unicode cToken = 0;
     sal_Int32 nStart = nPos;
     sal_Int32 nLen = rString.getLength();
-    while ( nPos < nLen && (nPos - nStart < 8) && ((cToken = rString[nPos]) != ']') )
+    while ( nPos < nLen && (nPos - nStart < 8) )
     {
+        cToken = rString[nPos];
+        if (cToken == ']')
+            break;
         if ( '0' <= cToken && cToken <= '9' )
         {
             nNum *= 16;
@@ -2010,15 +2016,17 @@ OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr )
             do
             {
                 nDash = rStr.indexOf( '-', ++nEnd );
+                nEnd = GetQuoteEnd( rStr, nDash );
             }
-            while ( (nEnd = GetQuoteEnd( rStr, nDash )) >= 0 );
+            while ( nEnd >= 0 );
             sal_Int32 nClose;
             nEnd = nStartPos - 1;
             do
             {
                 nClose = rStr.indexOf( ']', ++nEnd );
+                nEnd = GetQuoteEnd( rStr, nClose );
             }
-            while ( (nEnd = GetQuoteEnd( rStr, nClose )) >= 0 );
+            while ( nEnd >= 0 );
 
             if(nClose < 0)
             {


More information about the Libreoffice-commits mailing list