X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBullet.cpp;h=4308189d92d4bb3442f802b5e0217ac4cb593a89;hb=48d9d01a826eb9f1c1e7c62edb664ec97f6a6e8d;hp=da946dcbdce4e9ed6391f16ae87622cebfcc2075;hpb=9383f4c3c6f9cfab2d658701ba66e2b54cd68bea;p=features.git diff --git a/src/Bullet.cpp b/src/Bullet.cpp index da946dcbdc..4308189d92 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -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. @@ -18,7 +18,7 @@ #include "Bullet.h" -#include +#include "support/lassert.h" using namespace std; @@ -54,7 +54,7 @@ Bullet::Bullet(int f, int c, int s) Bullet::Bullet(docstring const & t) - : font(MIN), character(MIN), size(MIN), user_text(1), text(t) + : font(MIN), character(MIN), size(MIN), user_text(1), text(t), label(t) { testInvariant(); } @@ -98,6 +98,7 @@ void Bullet::setText(docstring const & t) font = character = size = MIN; user_text = 1; text = t; + label = t; testInvariant(); } @@ -120,6 +121,15 @@ int Bullet::getSize() const } +FontSize Bullet::getFontSize() const +{ + if (size >= 0) + return bulletFontSize(size); + else + return INHERIT_SIZE; +} + + Bullet & Bullet::operator=(Bullet const & b) { b.testInvariant(); @@ -128,6 +138,7 @@ Bullet & Bullet::operator=(Bullet const & b) size = b.size; user_text = b.user_text; text = b.text; + label = b.label; this->testInvariant(); return *this; } @@ -141,6 +152,14 @@ docstring const & Bullet::getText() const } +docstring const & Bullet::getLabel() const +{ + if (user_text == 0) + generateText(); + return label; +} + + bool operator==(const Bullet & b1, const Bullet & b2) { bool result = false; @@ -176,6 +195,7 @@ void Bullet::generateText() const if ((font >= 0) && (character >= 0)) { text = bulletEntry(font, character); + label = bulletLabel(font, character); if (size >= 0) text = bulletSize(size) + text; user_text = -1; @@ -345,28 +365,175 @@ docstring const Bullet::bulletEntry(int f, int c) return from_ascii(BulletPanels[f][c]); } + +FontSize Bullet::bulletFontSize(int s) +{ + // see comment at bulletSize + static FontSize BulletFontSize[SIZEMAX] = { + TINY_SIZE, SCRIPT_SIZE, FOOTNOTE_SIZE, SMALL_SIZE, NORMAL_SIZE, + LARGE_SIZE, LARGER_SIZE, LARGEST_SIZE, HUGE_SIZE, HUGER_SIZE + }; + + return BulletFontSize[s]; +} + + +docstring const Bullet::bulletLabel(int f, int c) +{ + // see comment at bulletEntry + static int UnicodeBulletPanel0[CHARMAX] = { + /* standard */ + 0x02013, 0x22A2, + 0x022A3, 0x0266D, 0x0266E, + 0x0266F, 0x02217, 0x022C6, + 0x02022, 0x02218, 0x022C5, + 0x02020, 0x025B3, + 0x025BD, 0x025C3, + 0x025B9, 0x025C1, 0x025B7, + 0x02295, 0x02296, 0x02297, + 0x02298, 0x02299, 0x02660, + 0x022C4, 0x025C7, /* \square */ 0x025FB, + 0x02662, 0x02661, + 0x02663, 0x02192, 0x02933, + 0x021C0, 0x021C1, + 0x021D2, 0x0227B + }; + static int UnicodeBulletPanel1[CHARMAX] = { + /* amssymb */ + 0x021DB, 0x021A3, + 0x021A0, 0x021DD, + 0x021AC, 0x022B8, + 0x022A0, 0x0229E, 0x0229F, + 0x022A1, 0x022C7, 0x022AA, + 0x022D6, 0x022D7, 0x02720, + 0x02605, 0x02713, 0x022A9, + 0x0223D, 0x0223C, + 0x02B1D, 0x0229D, + 0x0229B, 0x025CE, + 0x022B2, 0x022B3, + 0x025B3, 0x025BD, + 0x025CA, 0x025FB, 0x025C0, + 0x025B6, 0x025B4, + 0x025BE, 0x029EB, + 0x025FC + }; + static int UnicodeBulletPanel2[CHARMAX] = { + /* psnfss1 */ + 0x025CF, 0x0274D, + 0x025D7, 0x02295, + 0x02297, 0x02022, + 0x02727, 0x02726, + 0x02756, 0x025C6, + 0x025CA, 0x022C5, + 0x02751, 0x02752, + 0x0274F, 0x02750, + 0x02206, 0x02207, + 0x02758, 0x02759, + 0x0275A, 0x025A0, + 0x025B2, 0x025BC, + 0x02217, 0x02723, + 0x02722, 0x02732, + 0x02731, 0x027A4, + 0x02762, 0x02763, + 0x02766, 0x02767, + 0x027A2, 0x027A3 + }; + static int UnicodeBulletPanel3[CHARMAX] = { + /* psnfss2 */ + 0x0260E, 0x02706, + 0x02702, 0x02704, + 0x02707, 0x02708, + 0x02709, 0x0261B, + 0x0261E, 0x0270C, + 0x0270D, 0x0270F, + 0x02715, 0x02716, + 0x0271B, 0x02719, + 0x0271E, 0x0271D, + 0x02717, 0x02718, + 0x0271A, 0x0271C, + 0x0271F, 0x02720, + 0x02713, 0x02714, + 0x02660, 0x02663, + 0x02666, 0x02665, + 0x02764, 0x02765, + 0x02660, 0x02663, + 0x02666, 0x02665 + }; + static int UnicodeBulletPanel4[CHARMAX] = { + /* psnfss3 */ + 0x02721, 0x0272C, + 0x0272B, 0x02B51, + 0x02730, 0x0272A, + 0x0272E, 0x0272D, + 0x0272F, 0x02735, + 0x0273A, 0x02742, + 0x02733, 0x02734, + 0x02736, 0x02737, + 0x02738, 0x02739, + 0x0273C, 0x0273B, + 0x0273D, 0x02749, + 0x0273E, 0x02743, + 0x02747, 0x02748, + 0x0274A, 0x0274B, + 0x02724, 0x02725, + 0x02744, 0x02745, + 0x02746, 0x02740, + 0x0273F, 0x02741 + }; + static int UnicodeBulletPanel5[CHARMAX] = { + /* psnfss4 */ + 0x0279F, 0x027A0, + 0x027A1, 0x027A8, + 0x027A5, 0x027A6, + 0x027AE, 0x027AD, + 0x027AC, 0x027AB, + 0x027AA, 0x027A9, + 0x027AF, 0x027B1, + 0x027BA, 0x027BB, + 0x02711, 0x02712, + 0x02799, 0x027B5, + 0x027B3, 0x027B8, + 0x027BC, 0x027BD, + 0x0279B, 0x02192, + 0x0279D, 0x0279E, + 0x0279C, 0x02794, + 0x02192, 0x021D2, + 0x027BE, 0x027B2, + 0x027A7, 0x02212 + }; /* string const BulletPanels[][] */ + + static int * UnicodeBulletPanels[FONTMAX] = { + UnicodeBulletPanel0, UnicodeBulletPanel1, + UnicodeBulletPanel2, UnicodeBulletPanel3, + UnicodeBulletPanel4, UnicodeBulletPanel5 + }; + + return docstring(1, char_type(UnicodeBulletPanels[f][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 }