]> git.lyx.org Git - lyx.git/blobdiff - src/Bullet.C
add config.h
[lyx.git] / src / Bullet.C
index 3d66257cbdac24935febc24b63bbf5243a12d41f..4104ee60f49fd8cfddf21c8d854ed2a7c3933b3f 100644 (file)
@@ -1,21 +1,29 @@
+/**
+ * \file Bullet.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Allan Rae
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 /* Completes the implementation of the Bullet class
  * It defines the various LaTeX commands etc. required to
  * generate the bullets in the bullet-panel's.
- *
- * This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *           Copyright 1997-1998 Allan Rae
- *           and the LyX Team
- *
- * ====================================================== */
+ */
 
 #include <config.h>
 
 #include "Bullet.h"
-#include "support/LAssert.h"
+
+#include <boost/assert.hpp>
+
+namespace lyx {
+
+using std::string;
+
 
 /** The four LaTeX itemize environment default bullets
  */
@@ -31,7 +39,7 @@ 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)
+       : font(f), character(c), size(s), user_text(0)
 {
        if (f < MIN || f >= FONTMAX) {
                font = MIN;
@@ -43,19 +51,15 @@ Bullet::Bullet(int f, int c, int s)
                size = MIN;
        }
        generateText();
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
 
-Bullet::Bullet(string const & t)
-       :  font(MIN), character(MIN), size(MIN), user_text(1), text(t)
+Bullet::Bullet(docstring const & t)
+       : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
 {
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
@@ -67,9 +71,7 @@ void Bullet::setCharacter(int c)
                character = c;
        }
        user_text = 0;
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
@@ -81,9 +83,7 @@ void Bullet::setFont(int f)
                font = f;
        }
        user_text = 0;
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
@@ -95,20 +95,16 @@ void Bullet::setSize(int s)
                size = s;
        }
        user_text = 0;
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
-void Bullet::setText(string const & t)
+void Bullet::setText(docstring const & t)
 {
        font = character = size = MIN;
        user_text = 1;
        text = t;
-#ifdef ENABLE_ASSERTIONS
        testInvariant();
-#endif
 }
 
 
@@ -132,22 +128,18 @@ int Bullet::getSize() const
 
 Bullet & Bullet::operator=(Bullet const & b)
 {
-#ifdef ENABLE_ASSERTIONS
        b.testInvariant();
-#endif
        font = b.font;
        character = b.character;
        size = b.size;
        user_text = b.user_text;
        text = b.text;
-#ifdef ENABLE_ASSERTIONS
        this->testInvariant();
-#endif
        return *this;
 }
 
 
-string const & Bullet::getText() const
+docstring const & Bullet::getText() const
 {
        if (user_text == 0) {
                generateText();
@@ -203,7 +195,7 @@ void Bullet::generateText() const
 }
 
 
-string const Bullet::bulletSize(int s)
+docstring const Bullet::bulletSize(int s)
 {
        // use a parameter rather than hard code `size' in here
        // in case some future function may want to retrieve
@@ -215,11 +207,11 @@ string const Bullet::bulletSize(int s)
                "\\large", "\\Large",      "\\LARGE",        "\\huge",  "\\Huge"
        };
 
-       return BulletSize[s];
+       return from_ascii(BulletSize[s]);
 }
 
 
-string const Bullet::bulletEntry(int f, int c)
+docstring const Bullet::bulletEntry(int f, int c)
 {
        // Despite how this may at first appear the static local variables
        // are only initialized once..
@@ -360,30 +352,34 @@ string const Bullet::bulletEntry(int f, int c)
                BulletPanel4, BulletPanel5
        };
 
-       return BulletPanels[f][c];
+       return from_ascii(BulletPanels[f][c]);
 }
 
+void Bullet::testInvariant() const
+{
 #ifdef ENABLE_ASSERTIONS
-void Bullet::testInvariant() const {
-       lyx::Assert(font >= MIN);
-       lyx::Assert(font < FONTMAX);
-       lyx::Assert(character >= MIN);
-       lyx::Assert(character < CHARMAX);
-       lyx::Assert(size >= MIN);
-       lyx::Assert(size < SIZEMAX);
-       lyx::Assert(user_text >= -1);
-       lyx::Assert(user_text <= 1);
+       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);
        // now some relational/operational tests
        if (user_text == 1) {
-               lyx::Assert(font == -1 && (character == -1 && size == -1));
-               //        Assert(!text.empty()); // this isn't necessarily an error
+               BOOST_ASSERT(font == -1 && (character == -1 && size == -1));
+               //        BOOST_ASSERT(!text.empty()); // this isn't necessarily an error
        }
        //      else if (user_text == -1) {
-       //        Assert(!text.empty()); // this also isn't necessarily an error
+       //        BOOST_ASSERT(!text.empty()); // this also isn't necessarily an error
        //      }
        //      else {
        //        // user_text == 0
-       //        Assert(text.empty()); // not usually true
+       //        BOOST_ASSERT(text.empty()); // not usually true
        //      }
-}
 #endif
+}
+
+
+} // namespace lyx