]> git.lyx.org Git - lyx.git/blobdiff - src/Bullet.cpp
Account for old versions of Pygments
[lyx.git] / src / Bullet.cpp
index 5c0f91741991387208e4ee88454c91b94171ba45..1f4ef6af95ac601c06b0014c3f2ee17516fd33d8 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Allan Rae
  *
  * Full author contact details are available in file CREDITS.
 
 #include "Bullet.h"
 
-#include <boost/assert.hpp>
+#include "support/lassert.h"
 
-namespace lyx {
+using namespace std;
 
-using std::string;
+namespace lyx {
 
 
 /** The four LaTeX itemize environment default bullets
@@ -41,15 +41,12 @@ Bullet const ITEMIZE_DEFAULTS[4] = { Bullet(0, 8),//"\\(\\bullet\\)"
 Bullet::Bullet(int f, int c, int s)
        : font(f), character(c), size(s), user_text(0)
 {
-       if (f < MIN || f >= FONTMAX) {
+       if (f < MIN || f >= FONTMAX)
                font = MIN;
-       }
-       if (c < MIN || c >= CHARMAX) {
+       if (c < MIN || c >= CHARMAX)
                character = MIN;
-       }
-       if (s < MIN || s >= SIZEMAX) {
+       if (s < MIN || s >= SIZEMAX)
                size = MIN;
-       }
        generateText();
        testInvariant();
 }
@@ -65,11 +62,10 @@ Bullet::Bullet(docstring const & t)
 
 void Bullet::setCharacter(int c)
 {
-       if (c < MIN || c >= CHARMAX) {
+       if (c < MIN || c >= CHARMAX)
                character = MIN;
-       } else {
+       else
                character = c;
-       }
        user_text = 0;
        testInvariant();
 }
@@ -77,11 +73,10 @@ void Bullet::setCharacter(int c)
 
 void Bullet::setFont(int f)
 {
-       if (f < MIN || f >= FONTMAX) {
+       if (f < MIN || f >= FONTMAX)
                font = MIN;
-       } else {
+       else
                font = f;
-       }
        user_text = 0;
        testInvariant();
 }
@@ -89,11 +84,10 @@ void Bullet::setFont(int f)
 
 void Bullet::setSize(int s)
 {
-       if (s < MIN || s >= SIZEMAX) {
+       if (s < MIN || s >= SIZEMAX)
                size = MIN;
-       } else {
+       else
                size = s;
-       }
        user_text = 0;
        testInvariant();
 }
@@ -141,9 +135,8 @@ Bullet & Bullet::operator=(Bullet const & b)
 
 docstring const & Bullet::getText() const
 {
-       if (user_text == 0) {
+       if (user_text == 0)
                generateText();
-       }
        return text;
 }
 
@@ -154,12 +147,10 @@ bool operator==(const Bullet & b1, const Bullet & b2)
 
        if (b1.user_text && b2.user_text) {
                /* both have valid text */
-               if (b1.text == b2.text) {
+               if (b1.text == b2.text)
                        result = true;
-               }
-       } else if (((b1.character == b2.character) &&
-                         (b1.font == b2.font)) &&
-                        (b1.size == b2.size)) {
+       } else if (b1.character == b2.character && b1.font == b2.font &&
+                        b1.size == b2.size) {
                result = true;
        }
        return result;
@@ -185,9 +176,8 @@ void Bullet::generateText() const
 
        if ((font >= 0) && (character >= 0)) {
                text = bulletEntry(font, character);
-               if (size >= 0) {
+               if (size >= 0)
                        text = bulletSize(size) + text;
-               }
                user_text = -1;
                // text is now defined and doesn't need to be recalculated
                // unless font/character or text is modified
@@ -358,25 +348,25 @@ docstring const Bullet::bulletEntry(int f, int c)
 void Bullet::testInvariant() const
 {
 #ifdef ENABLE_ASSERTIONS
-       BOOST_ASSERT(font >= MIN);
-       BOOST_ASSERT(font < FONTMAX);
-       BOOST_ASSERT(character >= MIN);
-       BOOST_ASSERT(character < CHARMAX);
-       BOOST_ASSERT(size >= MIN);
-       BOOST_ASSERT(size < SIZEMAX);
-       BOOST_ASSERT(user_text >= -1);
-       BOOST_ASSERT(user_text <= 1);
+       LATTEST(font >= MIN);
+       LATTEST(font < FONTMAX);
+       LATTEST(character >= MIN);
+       LATTEST(character < CHARMAX);
+       LATTEST(size >= MIN);
+       LATTEST(size < SIZEMAX);
+       LATTEST(user_text >= -1);
+       LATTEST(user_text <= 1);
        // now some relational/operational tests
        if (user_text == 1) {
-               BOOST_ASSERT(font == -1 && (character == -1 && size == -1));
-               //        BOOST_ASSERT(!text.empty()); // this isn't necessarily an error
+               LATTEST(font == -1 && (character == -1 && size == -1));
+               //        LATTEST(!text.empty()); // this isn't necessarily an error
        }
        //      else if (user_text == -1) {
-       //        BOOST_ASSERT(!text.empty()); // this also isn't necessarily an error
+       //        LATTEST(!text.empty()); // this also isn't necessarily an error
        //      }
        //      else {
        //        // user_text == 0
-       //        BOOST_ASSERT(text.empty()); // not usually true
+       //        LATTEST(text.empty()); // not usually true
        //      }
 #endif
 }