summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 19:33:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-16 08:15:54 +0200
commitcd7471335a05e7dd7eca16ac0b181d96cfa7912b (patch)
treeae91004516ef87f82c9a5300c0c4f2f0d7d2bddf /starmath
parenteca8526607d8e5b883989adf480780661380b12e (diff)
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@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/utility.hxx3
-rw-r--r--starmath/source/ElementsDockingWindow.cxx20
-rw-r--r--starmath/source/mathmlexport.cxx5
-rw-r--r--starmath/source/mathtype.cxx7
-rw-r--r--starmath/source/node.cxx30
-rw-r--r--starmath/source/parse.cxx8
-rw-r--r--starmath/source/view.cxx6
7 files changed, 54 insertions, 25 deletions
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;