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

Takeshi Abe tabe at fixedpoint.jp
Thu Feb 18 09:38:52 UTC 2016


 starmath/inc/rect.hxx        |    2 +-
 starmath/source/dialog.cxx   |    2 +-
 starmath/source/node.cxx     |   16 ++++++++--------
 starmath/source/parse.cxx    |   18 +++++++++---------
 starmath/source/unomodel.cxx |    8 ++++----
 5 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit d2f33d22836621506adec6814abf010fa2d683e6
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Feb 18 17:33:12 2016 +0900

    starmath: Avoid C-style cast
    
    Change-Id: Id54997718a61b1b5a488922f05374c559f1e4454
    Reviewed-on: https://gerrit.libreoffice.org/22460
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/starmath/inc/rect.hxx b/starmath/inc/rect.hxx
index 3ef8ec4..31b337c 100644
--- a/starmath/inc/rect.hxx
+++ b/starmath/inc/rect.hxx
@@ -39,7 +39,7 @@ bool SmIsMathAlpha(const OUString &rText);
 
 inline long SmFromTo(long nFrom, long nTo, double fRelDist)
 {
-    return nFrom + (long) (fRelDist * (nTo - nFrom));
+    return nFrom + static_cast<long>(fRelDist * (nTo - nFrom));
 }
 
 
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 3c23d9c..19b8d0d 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -1330,7 +1330,7 @@ void SmShowSymbolSetWindow::SetScrollBarRange()
 
 void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol)
 {
-    int v = (int) (m_pVScrollBar->GetThumbPos() * nColumns);
+    int v = static_cast<int>(m_pVScrollBar->GetThumbPos() * nColumns);
 
     if (nSelectSymbol != SYMBOL_NONE)
         Invalidate(Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen,
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 27c6755..7c16927 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -170,7 +170,7 @@ void SmNode::SetFontSize(const Fraction &rSize, FontSizeType nType)
     {
         Fraction  aVal (SmPtsTo100th_mm(rSize.GetNumerator()),
                         rSize.GetDenominator());
-        long      nHeight = (long)aVal;
+        long      nHeight = static_cast<long>(aVal);
 
         aFntSize = GetFont().GetFontSize();
         aFntSize.Width() = 0;
@@ -189,12 +189,12 @@ void SmNode::SetFontSize(const Fraction &rSize, FontSizeType nType)
                 break;
 
             case FontSizeType::MULTIPLY:
-                aFntSize.Height()   = (long) (Fraction(aFntSize.Height()) * rSize);
+                aFntSize.Height()   = static_cast<long>(Fraction(aFntSize.Height()) * rSize);
                 break;
 
             case FontSizeType::DIVIDE:
                 if (rSize != Fraction(0L))
-                    aFntSize.Height()   = (long) (Fraction(aFntSize.Height()) / rSize);
+                    aFntSize.Height()   = static_cast<long>(Fraction(aFntSize.Height()) / rSize);
                 break;
             default:
                 break;
@@ -1195,8 +1195,8 @@ sal_uInt16 GetLineIntersectionPoint(Point &rResult,
         double fLambda = (    (rPoint1.Y() - rPoint2.Y()) * rHeading2.X()
                             - (rPoint1.X() - rPoint2.X()) * rHeading2.Y())
                          / fDet;
-        rResult = Point(rPoint1.X() + (long) (fLambda * rHeading1.X()),
-                        rPoint1.Y() + (long) (fLambda * rHeading1.Y()));
+        rResult = Point(rPoint1.X() + static_cast<long>(fLambda * rHeading1.X()),
+                        rPoint1.Y() + static_cast<long>(fLambda * rHeading1.Y()));
     }
 
     return nRes;
@@ -1227,8 +1227,8 @@ void SmBinDiagonalNode::GetOperPosSize(Point &rPos, Size &rSize,
             nRectBottom = GetBottom();
     Point   aRightHdg     (100, 0),
             aDownHdg      (0, 100),
-            aDiagHdg      ( (long)(100.0 * cos(fAngleRad)),
-                            (long)(-100.0 * sin(fAngleRad)) );
+            aDiagHdg      ( static_cast<long>(100.0 * cos(fAngleRad)),
+                            static_cast<long>(-100.0 * sin(fAngleRad)) );
 
     long  nLeft, nRight, nTop, nBottom;     // margins of the rectangle for the diagonal
     Point aPoint;
@@ -1645,7 +1645,7 @@ void SmBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
         Size  aTmpSize (pLeft->GetFont().GetFontSize());
         OSL_ENSURE(pRight->GetFont().GetFontSize() == aTmpSize,
                     "Sm : different font sizes");
-        aTmpSize.Width() = std::min((long) nBraceHeight * 60L / 100L,
+        aTmpSize.Width() = std::min(nBraceHeight * 60L / 100L,
                             rFormat.GetBaseSize().Height() * 3L / 2L);
         // correction factor since change from StarMath to OpenSymbol font
         // because of the different font width in the FontMetric
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index c2c7e88..f5f5d91 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1243,14 +1243,14 @@ void SmParser::DoSubSup(sal_uLong nActiveGroup)
 
         switch (eType)
         {
-            case TRSUB :    nIndex = (int) RSUB;    break;
-            case TRSUP :    nIndex = (int) RSUP;    break;
+            case TRSUB :    nIndex = static_cast<int>(RSUB);    break;
+            case TRSUP :    nIndex = static_cast<int>(RSUP);    break;
             case TFROM :
-            case TCSUB :    nIndex = (int) CSUB;    break;
+            case TCSUB :    nIndex = static_cast<int>(CSUB);    break;
             case TTO :
-            case TCSUP :    nIndex = (int) CSUP;    break;
-            case TLSUB :    nIndex = (int) LSUB;    break;
-            case TLSUP :    nIndex = (int) LSUP;    break;
+            case TCSUP :    nIndex = static_cast<int>(CSUP);    break;
+            case TLSUB :    nIndex = static_cast<int>(LSUB);    break;
+            case TLSUP :    nIndex = static_cast<int>(LSUP);    break;
             default :
                 SAL_WARN( "starmath", "unknown case");
         }
@@ -2459,10 +2459,10 @@ const SmErrorDesc *SmParser::NextError()
 const SmErrorDesc *SmParser::PrevError()
 {
     if ( !m_aErrDescList.empty() )
-        if (m_nCurError < (int) (m_aErrDescList.size() - 1)) return m_aErrDescList[ ++m_nCurError ].get();
+        if (m_nCurError < static_cast<int>(m_aErrDescList.size() - 1)) return m_aErrDescList[ ++m_nCurError ].get();
         else
         {
-            m_nCurError = (int) (m_aErrDescList.size() - 1);
+            m_nCurError = static_cast<int>(m_aErrDescList.size() - 1);
             return m_aErrDescList[ m_nCurError ].get();
         }
     else return nullptr;
@@ -2474,7 +2474,7 @@ const SmErrorDesc *SmParser::GetError(size_t i)
     if ( i < m_aErrDescList.size() )
         return m_aErrDescList[ i ].get();
 
-    if ( (size_t)m_nCurError < m_aErrDescList.size() )
+    if ( static_cast<size_t>(m_nCurError) < m_aErrDescList.size() )
         return m_aErrDescList[ m_nCurError ].get();
 
     return nullptr;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 812cde5..07cf724 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1051,10 +1051,10 @@ void SAL_CALL SmModel::render(
                 {
                     aPrtPaperSize = lcl_GuessPaperSize();
                     // factors from Windows DIN A4
-                    aOutputSize    = Size( (long)(aPrtPaperSize.Width()  * 0.941),
-                                           (long)(aPrtPaperSize.Height() * 0.961));
-                    aPrtPageOffset = Point( (long)(aPrtPaperSize.Width()  * 0.0250),
-                                            (long)(aPrtPaperSize.Height() * 0.0214));
+                    aOutputSize    = Size( static_cast<long>(aPrtPaperSize.Width()  * 0.941),
+                                           static_cast<long>(aPrtPaperSize.Height() * 0.961));
+                    aPrtPageOffset = Point( static_cast<long>(aPrtPaperSize.Width()  * 0.0250),
+                                            static_cast<long>(aPrtPaperSize.Height() * 0.0214));
                 }
                 Point   aZeroPoint;
                 Rectangle OutputRect( aZeroPoint, aOutputSize );


More information about the Libreoffice-commits mailing list