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

Takeshi Abe tabe at fixedpoint.jp
Thu Apr 2 01:43:42 PDT 2015


 starmath/inc/node.hxx            |   22 ++++++++++++----------
 starmath/source/mathmlexport.cxx |    8 ++++----
 starmath/source/mathmlimport.cxx |    6 +++---
 starmath/source/node.cxx         |   24 ++++++++++++------------
 starmath/source/parse.cxx        |   14 +++++++-------
 starmath/source/visitors.cxx     |   10 +++++-----
 6 files changed, 43 insertions(+), 41 deletions(-)

New commits:
commit 11a52df2216bf96a3869ac894513959098dc14da
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Wed Apr 1 19:35:19 2015 +0900

    Replace FNTSIZ_* with a scoped enumeration FontSizeType
    
    Change-Id: Ia6bcaaac60c18abda803f6a40db8a5c5076b9427
    Reviewed-on: https://gerrit.libreoffice.org/15101
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index a6aae54..27b539a 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -36,11 +36,13 @@
 #define ATTR_ITALIC     0x0002
 
 
-#define FNTSIZ_ABSOLUT  1
-#define FNTSIZ_PLUS     2
-#define FNTSIZ_MINUS    3
-#define FNTSIZ_MULTIPLY 4
-#define FNTSIZ_DIVIDE   5
+enum class FontSizeType {
+  ABSOLUT  = 1,
+  PLUS     = 2,
+  MINUS    = 3,
+  MULTIPLY = 4,
+  DIVIDE   = 5
+};
 
 // flags to interdict respective status changes
 #define FLG_FONT        0x0001
@@ -143,7 +145,7 @@ public:
                   SmFace & GetFont()       { return aFace; };
 
             void SetFont(const SmFace &rFace);
-            void SetFontSize(const Fraction &rRelSize, sal_uInt16 nType);
+            void SetFontSize(const Fraction &rRelSize, FontSizeType nType);
             void SetSize(const Fraction &rScale);
 
     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
@@ -1247,20 +1249,20 @@ public:
  */
 class SmFontNode : public SmStructureNode
 {
-    sal_uInt16      nSizeType;
+    FontSizeType nSizeType;
     Fraction    aFontSize;
 
 public:
     SmFontNode(const SmToken &rNodeToken)
     :   SmStructureNode(NFONT, rNodeToken)
     {
-        nSizeType = FNTSIZ_MULTIPLY;
+        nSizeType = FontSizeType::MULTIPLY;
         aFontSize = Fraction(1L);
     }
 
-    void SetSizeParameter(const Fraction &rValue, sal_uInt16 nType);
+    void SetSizeParameter(const Fraction &rValue, FontSizeType nType);
     const Fraction & GetSizeParameter() const {return aFontSize;}
-    const sal_uInt16& GetSizeType() const {return nSizeType;}
+    const FontSizeType& GetSizeType() const {return nSizeType;}
 
     virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) SAL_OVERRIDE;
     virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat) SAL_OVERRIDE;
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 8cc9dc0..3466e51 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -1368,17 +1368,17 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
                 OUStringBuffer sStrBuf;
                 switch(pFontNode->GetSizeType())
                 {
-                    case FNTSIZ_MULTIPLY:
+                    case FontSizeType::MULTIPLY:
                         ::sax::Converter::convertDouble(sStrBuf,
                             static_cast<double>(aFrac*Fraction(100.00)));
                         sStrBuf.append('%');
                         break;
-                    case FNTSIZ_DIVIDE:
+                    case FontSizeType::DIVIDE:
                         ::sax::Converter::convertDouble(sStrBuf,
                             static_cast<double>(Fraction(100.00)/aFrac));
                         sStrBuf.append('%');
                         break;
-                    case FNTSIZ_ABSOLUT:
+                    case FontSizeType::ABSOLUT:
                         ::sax::Converter::convertDouble(sStrBuf,
                             static_cast<double>(aFrac));
                         sStrBuf.append(
@@ -1395,7 +1395,7 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
                             Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
                                 GetSize().Height());
 
-                            if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
+                            if (pFontNode->GetSizeType() == FontSizeType::MINUS)
                                 aTemp-=aFrac;
                             else
                                 aTemp+=aFrac;
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index d5ddd2e..0691339 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -710,13 +710,13 @@ void SmXMLContext_Helper::ApplyAttrs()
             {
                 if (nFontSize < 100.00)
                     pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
-                        FNTSIZ_DIVIDE);
+                        FontSizeType::DIVIDE);
                 else
                     pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
-                        FNTSIZ_MULTIPLY);
+                        FontSizeType::MULTIPLY);
             }
             else
-                pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
+                pFontNode->SetSizeParameter(Fraction(nFontSize),FontSizeType::ABSOLUT);
 
             pFontNode->SetSubNodes(0,popOrZero(rNodeStack));
             rNodeStack.push_front(pFontNode);
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 80bba2c..9f413ee 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -164,7 +164,7 @@ void SmNode::SetFont(const SmFace &rFace)
 }
 
 
-void SmNode::SetFontSize(const Fraction &rSize, sal_uInt16 nType)
+void SmNode::SetFontSize(const Fraction &rSize, FontSizeType nType)
     //! 'rSize' is in units of pts
 {
     Size  aFntSize;
@@ -179,23 +179,23 @@ void SmNode::SetFontSize(const Fraction &rSize, sal_uInt16 nType)
         aFntSize.Width() = 0;
         switch(nType)
         {
-            case FNTSIZ_ABSOLUT:
+            case FontSizeType::ABSOLUT:
                 aFntSize.Height() = nHeight;
                 break;
 
-            case FNTSIZ_PLUS:
+            case FontSizeType::PLUS:
                 aFntSize.Height() += nHeight;
                 break;
 
-            case FNTSIZ_MINUS:
+            case FontSizeType::MINUS:
                 aFntSize.Height() -= nHeight;
                 break;
 
-            case FNTSIZ_MULTIPLY:
+            case FontSizeType::MULTIPLY:
                 aFntSize.Height()   = (long) (Fraction(aFntSize.Height()) * rSize);
                 break;
 
-            case FNTSIZ_DIVIDE:
+            case FontSizeType::DIVIDE:
                 if (rSize != Fraction(0L))
                     aFntSize.Height()   = (long) (Fraction(aFntSize.Height()) / rSize);
                 break;
@@ -2038,19 +2038,19 @@ void SmFontNode::CreateTextFromNode(OUString &rText)
                 rText += "size ";
                 switch (nSizeType)
                 {
-                    case FNTSIZ_PLUS:
+                    case FontSizeType::PLUS:
                         rText += "+";
                         break;
-                    case FNTSIZ_MINUS:
+                    case FontSizeType::MINUS:
                         rText += "-";
                         break;
-                    case FNTSIZ_MULTIPLY:
+                    case FontSizeType::MULTIPLY:
                         rText += "*";
                         break;
-                    case FNTSIZ_DIVIDE:
+                    case FontSizeType::DIVIDE:
                         rText += "/";
                         break;
-                    case FNTSIZ_ABSOLUT:
+                    case FontSizeType::ABSOLUT:
                     default:
                         break;
                 }
@@ -2205,7 +2205,7 @@ void SmFontNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
 }
 
 
-void SmFontNode::SetSizeParameter(const Fraction& rValue, sal_uInt16 Type)
+void SmFontNode::SetSizeParameter(const Fraction& rValue, FontSizeType Type)
 {
     nSizeType = Type;
     aFontSize = rValue;
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index cb47ab9..5881c37 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1925,18 +1925,18 @@ void SmParser::FontSize()
 {
     OSL_ENSURE(m_aCurToken.eType == TSIZE, "Sm : Ooops...");
 
-    sal_uInt16   Type;
+    FontSizeType   Type;
     SmFontNode *pFontNode = new SmFontNode(m_aCurToken);
 
     NextToken();
 
     switch (m_aCurToken.eType)
     {
-        case TNUMBER:   Type = FNTSIZ_ABSOLUT;  break;
-        case TPLUS:     Type = FNTSIZ_PLUS;     break;
-        case TMINUS:    Type = FNTSIZ_MINUS;    break;
-        case TMULTIPLY: Type = FNTSIZ_MULTIPLY; break;
-        case TDIVIDEBY: Type = FNTSIZ_DIVIDE;   break;
+        case TNUMBER:   Type = FontSizeType::ABSOLUT;  break;
+        case TPLUS:     Type = FontSizeType::PLUS;     break;
+        case TMINUS:    Type = FontSizeType::MINUS;    break;
+        case TMULTIPLY: Type = FontSizeType::MULTIPLY; break;
+        case TDIVIDEBY: Type = FontSizeType::DIVIDE;   break;
 
         default:
             delete pFontNode;
@@ -1944,7 +1944,7 @@ void SmParser::FontSize()
             return;
     }
 
-    if (Type != FNTSIZ_ABSOLUT)
+    if (Type != FontSizeType::ABSOLUT)
     {
         NextToken();
         if (m_aCurToken.eType != TNUMBER)
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index ed1cf97..fc7decf 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2113,19 +2113,19 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
                 Append( "size " );
                 switch ( pNode->GetSizeType( ) )
                 {
-                    case FNTSIZ_PLUS:
+                    case FontSizeType::PLUS:
                         Append( "+" );
                         break;
-                    case FNTSIZ_MINUS:
+                    case FontSizeType::MINUS:
                         Append( "-" );
                         break;
-                    case FNTSIZ_MULTIPLY:
+                    case FontSizeType::MULTIPLY:
                         Append( "*" );
                         break;
-                    case FNTSIZ_DIVIDE:
+                    case FontSizeType::DIVIDE:
                         Append( "/" );
                         break;
-                    case FNTSIZ_ABSOLUT:
+                    case FontSizeType::ABSOLUT:
                     default:
                         break;
                 }


More information about the Libreoffice-commits mailing list