move more support functions into namespace lyx, small other changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1949 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-04-24 15:25:26 +00:00
parent 2a3b89c6f1
commit 47910a7a67
51 changed files with 239 additions and 182 deletions

View File

@ -985,7 +985,7 @@ bool BufferView::ChangeCitationsIfUnique(string const & from, string const & to)
vector<pair<string,string> > keys = buffer()->getBibkeyList();
if (count_if(keys.begin(), keys.end(),
equal_1st_in_pair<string,string>(from))
lyx::equal_1st_in_pair<string,string>(from))
> 1)
return false;

View File

@ -252,7 +252,7 @@ void BufferView::Pimpl::redraw()
bool BufferView::Pimpl::fitCursor(LyXText * text)
{
Assert(screen_.get());
lyx::Assert(screen_.get());
bool ret = screen_->FitCursor(text, bv_);
if (ret)
@ -1432,7 +1432,7 @@ Inset * BufferView::Pimpl::getInsetByCode(Inset::Code code)
find_if(Buffer::inset_iterator(
cursor.par(), cursor.pos()),
buffer_->inset_iterator_end(),
compare_memfun(&Inset::LyxCode, code)
lyx::compare_memfun(&Inset::LyxCode, code)
);
return it != buffer_->inset_iterator_end() ? (*it) : 0;
}

View File

@ -56,17 +56,17 @@ protected:
#ifdef ENABLE_ASSERTIONS
///
void testInvariant() const {
Assert(font >= MIN);
Assert(font < FONTMAX);
Assert(character >= MIN);
Assert(character < CHARMAX);
Assert(size >= MIN);
Assert(size < SIZEMAX);
Assert(user_text >= -1);
Assert(user_text <= 1);
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);
// now some relational/operational tests
if (user_text == 1) {
Assert(font == -1 && (character == -1 && size == -1));
lyx::Assert(font == -1 && (character == -1 && size == -1));
// Assert(!text.empty()); // this isn't necessarily an error
}
// else if (user_text == -1) {

View File

@ -1,3 +1,31 @@
2001-04-24 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxparagraph.h (size): move up int file
(GetLayout): ditto
* adjust all uses of Assert to lyx::Assert.
* BufferView2.C (ChangeCitationsIfUnique): adjust for
lyxfunctional in namespace lyx
* layout.C (hasLayout): ditto
(GetLayout): ditto
(GetLayout): ditto
(delete_layout): ditto
(NumberOfClass): ditto
* converter.C (GetFormat): ditto
(GetNumber): ditto
(Add): ditto
(Delete): ditto
(SetViewer): ditto
* bufferlist.C (getFileNames): ditto
(emergencyWriteAll): ditto
(exists): ditto
(getBuffer): ditto
* MenuBackend.C (hasSubmenu): ditto
(hasMenu): ditto
(getMenu): ditto
* BufferView_pimpl.C (getInsetByCode): ditto
2001-04-18 Juergen Vigna <jug@sad.it>
* vspace.C (asLatexString): fixed the 100% problem.

View File

@ -169,7 +169,7 @@ void LColor::setColor(LColor::color col, string const & x11name)
return;
}
lyxerr << "LyX internal error: color and such.\n";
Assert(false);
lyx::Assert(false);
}

View File

@ -334,7 +334,7 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
bool Menu::hasSubmenu(string const & name) const
{
return find_if(begin(), end(),
compare_memfun(&MenuItem::submenu, name)) != end();
lyx::compare_memfun(&MenuItem::submenu, name)) != end();
}
@ -469,23 +469,24 @@ void MenuBackend::add(Menu const & menu)
bool MenuBackend::hasMenu(string const & name) const
{
return find_if(begin(), end(),
compare_memfun(&Menu::name, name)) != end();
lyx::compare_memfun(&Menu::name, name)) != end();
}
Menu const & MenuBackend::getMenu(string const & name) const
{
const_iterator cit = find_if(begin(), end(),
compare_memfun(&Menu::name, name));
Assert(cit != end());
lyx::compare_memfun(&Menu::name, name));
lyx::Assert(cit != end());
return (*cit);
}
Menu & MenuBackend::getMenu(string const & name)
{
MenuList::iterator it = find_if(menulist_.begin(), menulist_.end(),
compare_memfun(&Menu::name, name));
Assert(it != menulist_.end());
MenuList::iterator it =
find_if(menulist_.begin(), menulist_.end(),
lyx::compare_memfun(&Menu::name, name));
lyx::Assert(it != menulist_.end());
return (*it);
}

View File

@ -94,22 +94,23 @@ struct PrinterParams {
#ifdef ENABLE_ASSERTIONS
if (!from_page.empty()) {
// Assert(from_page == number or empty)
Assert(containsOnly(from_page, "1234567890"));
lyx::Assert(containsOnly(from_page,
"1234567890"));
}
if (to_page) {
// Assert(to_page == empty
// or number iff from_page set)
Assert(!from_page.empty());
lyx::Assert(!from_page.empty());
}
switch (target) {
case PRINTER:
// Assert(!printer_name.empty());
break;
case FILE:
Assert(!file_name.empty());
lyx::Assert(!file_name.empty());
break;
default:
Assert(false);
lyx::Assert(false);
break;
}
switch (which_pages) {
@ -118,7 +119,7 @@ struct PrinterParams {
case EVEN:
break;
default:
Assert(false);
lyx::Assert(false);
break;
}
#endif

View File

@ -18,7 +18,7 @@ class UpdateInset {
public:
///
void push(Inset * inset) {
Assert(inset);
lyx::Assert(inset);
insetqueue.push(inset);
}
///

View File

@ -54,6 +54,7 @@ extern BufferView * current_view;
void BufferStorage::release(Buffer * buf)
{
lyx::Assert(buf);
Container::iterator it = find(container.begin(), container.end(), buf);
if (it != container.end()) {
// Make sure that we don't store a LyXText in
@ -168,6 +169,8 @@ void BufferList::resize()
bool BufferList::close(Buffer * buf)
{
lyx::Assert(buf);
// CHECK
// Trace back why we need to use buf->getUser here.
// Perhaps slight rewrite is in order? (Lgb)
@ -223,7 +226,7 @@ vector<string> const BufferList::getFileNames() const
{
vector<string> nvec;
std::copy(bstore.begin(), bstore.end(),
back_inserter_fun(nvec, &Buffer::fileName));
lyx::back_inserter_fun(nvec, &Buffer::fileName));
return nvec;
}
@ -244,7 +247,9 @@ Buffer * BufferList::getBuffer(unsigned int choice)
int BufferList::unlockInset(UpdatableInset * inset)
{
if (!inset) return 1;
lyx::Assert(inset);
//if (!inset) return 1;
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
if ((*it)->getUser()
@ -276,12 +281,14 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
void BufferList::emergencyWriteAll()
{
for_each(bstore.begin(), bstore.end(),
class_fun(*this, &BufferList::emergencyWrite));
lyx::class_fun(*this, &BufferList::emergencyWrite));
}
void BufferList::emergencyWrite(Buffer * buf)
{
assert(buf); // use c assert to avoid a loop
// No need to save if the buffer has not changed.
if (buf->isLyxClean()) return;
@ -405,12 +412,15 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
bool BufferList::exists(string const & s) const
{
return find_if(bstore.begin(), bstore.end(),
compare_memfun(&Buffer::fileName, s)) != bstore.end();
lyx::compare_memfun(&Buffer::fileName, s))
!= bstore.end();
}
bool BufferList::isLoaded(Buffer const * b) const
{
lyx::Assert(b);
BufferStorage::const_iterator cit =
find(bstore.begin(), bstore.end(), b);
return cit != bstore.end();
@ -421,7 +431,7 @@ Buffer * BufferList::getBuffer(string const & s)
{
BufferStorage::iterator it =
find_if(bstore.begin(), bstore.end(),
compare_memfun(&Buffer::fileName, s));
lyx::compare_memfun(&Buffer::fileName, s));
return it != bstore.end() ? (*it) : 0;
}

View File

@ -108,7 +108,7 @@ public:
Buffer * readFile(string const &, bool ro);
/// Make a new file (buffer) using a template
Buffer * newFile(string const &, string, bool isNamed=false);
Buffer * newFile(string const &, string, bool isNamed = false);
/// returns a vector with all the buffers filenames
std::vector<string> const getFileNames() const;

View File

@ -86,7 +86,7 @@ Format const * Formats::GetFormat(string const & name) const
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
compare_memfun(&Format::name, name));
lyx::compare_memfun(&Format::name, name));
if (cit != formatlist.end())
return &(*cit);
else
@ -98,7 +98,7 @@ int Formats::GetNumber(string const & name) const
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
compare_memfun(&Format::name, name));
lyx::compare_memfun(&Format::name, name));
if (cit != formatlist.end())
return cit - formatlist.begin();
else
@ -118,7 +118,7 @@ void Formats::Add(string const & name, string const & extension,
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
compare_memfun(&Format::name, name));
lyx::compare_memfun(&Format::name, name));
if (it == formatlist.end())
formatlist.push_back(Format(name, extension, prettyname,
shortcut, ""));
@ -133,7 +133,7 @@ void Formats::Delete(string const & name)
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
compare_memfun(&Format::name, name));
lyx::compare_memfun(&Format::name, name));
if (it != formatlist.end())
formatlist.erase(it);
}
@ -150,7 +150,7 @@ void Formats::SetViewer(string const & name, string const & command)
Add(name);
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
compare_memfun(&Format::name, name));
lyx::compare_memfun(&Format::name, name));
if (it != formatlist.end())
it->setViewer(command);
}

View File

@ -175,7 +175,7 @@ private:
inline void Dialogs::add(DialogBase * ptr)
{
Assert(ptr);
lyx::Assert(ptr);
dialogs_.push_back(db_ptr(ptr));
}

View File

@ -158,7 +158,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
void setMinibuffer(LyXView * lv, string const & msg)
{
Assert(lv);
lyx::Assert(lv);
lv->message(msg);
}

View File

@ -189,7 +189,7 @@ void ControlInset<Inset, Params>::apply()
template <class Inset, class Params>
Params & ControlInset<Inset, Params>::params() const
{
Assert(params_);
lyx::Assert(params_);
return *params_;
}
@ -197,7 +197,7 @@ Params & ControlInset<Inset, Params>::params() const
template <class Inset, class Params>
Inset * ControlInset<Inset, Params>::inset() const
{
Assert(inset_);
lyx::Assert(inset_);
return inset_;
}

View File

@ -43,7 +43,7 @@ void ControlPreamble::apply()
string & ControlPreamble::params() const
{
Assert(params_);
lyx::Assert(params_);
return *params_;
}

View File

@ -57,7 +57,7 @@ void ControlPrint::apply()
PrinterParams & ControlPrint::params() const
{
Assert(params_);
lyx::Assert(params_);
return *params_;
}

View File

@ -67,7 +67,7 @@ vector<string> const getKeys(InfoMap const & map)
string const getInfo(InfoMap const & map, string const & key)
{
Assert(!map.empty());
lyx::Assert(!map.empty());
string result;

View File

@ -33,7 +33,7 @@ LyXImage::~LyXImage()
Pixmap
LyXImage::getPixmap() const
{
Assert(pixmapInitialized);
lyx::Assert(pixmapInitialized);
return pixmap_;
}

View File

@ -101,7 +101,7 @@ namespace {
FormBase * GetForm(FL_OBJECT * ob)
{
Assert(ob && ob->form && ob->form->u_vdata);
lyx::Assert(ob && ob->form && ob->form->u_vdata);
FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
return pre;
}
@ -109,10 +109,11 @@ FormBase * GetForm(FL_OBJECT * ob)
} // namespace anon
extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
extern "C"
int C_FormBaseWMHideCB(FL_FORM * form, void *)
{
// Close the dialog cleanly, even if the WM is used to do so.
Assert(form && form->u_vdata);
lyx::Assert(form && form->u_vdata);
FormBase * pre = static_cast<FormBase *>(form->u_vdata);
pre->CancelButton();
return FL_CANCEL;

View File

@ -56,7 +56,7 @@ FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
string const & t)
: lv_(lv), d_(d), h_(0), r_(0), title_(t), minw_(0), minh_(0)
{
Assert(lv && d);
lyx::Assert(lv && d);
}
@ -133,12 +133,12 @@ void FormBaseDeprecated::hide()
int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
{
Assert(form);
lyx::Assert(form);
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the dialog.
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->hide();
pre->bc().hide();
return FL_CANCEL;
@ -147,10 +147,10 @@ int FormBaseDeprecated::WMHideCB(FL_FORM * form, void *)
void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
lyx::Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->apply();
pre->bc().apply();
}
@ -158,10 +158,10 @@ void FormBaseDeprecated::ApplyCB(FL_OBJECT * ob, long)
void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
lyx::Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->ok();
pre->bc().ok();
}
@ -169,10 +169,10 @@ void FormBaseDeprecated::OKCB(FL_OBJECT * ob, long)
void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
lyx::Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->cancel();
pre->bc().cancel();
}
@ -180,20 +180,20 @@ void FormBaseDeprecated::CancelCB(FL_OBJECT * ob, long)
void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data)
{
Assert(ob && ob->form);
lyx::Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->bc().valid(pre->input(ob, data));
}
void FormBaseDeprecated::RestoreCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form);
lyx::Assert(ob && ob->form);
FormBaseDeprecated * pre =
static_cast<FormBaseDeprecated*>(ob->form->u_vdata);
Assert(pre);
lyx::Assert(pre);
pre->bc().restore();
pre->restore();
}

View File

@ -55,7 +55,7 @@ FL_FORM * FormMathsBitmap::form() const
void FormMathsBitmap::build()
{
Assert(bitmaps_.size() > 0);
lyx::Assert(bitmaps_.size() > 0);
h_+= 50; // Allow room for a Close button

View File

@ -25,12 +25,13 @@
static char h_align_str[80] = "c";
static char v_align_c[] = "tcb";
extern "C" int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
extern "C"
int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
char const * cur, int c)
{
Assert(ob);
lyx::Assert(ob);
FormMathsMatrix * pre = static_cast<FormMathsMatrix *>(ob->u_vdata);
Assert(pre);
lyx::Assert(pre);
return pre->AlignFilter(cur, c);
}

View File

@ -296,7 +296,7 @@ void FormPreferences::apply()
void FormPreferences::feedback(FL_OBJECT * ob)
{
Assert(ob);
lyx::Assert(ob);
string str;
@ -335,7 +335,7 @@ void FormPreferences::feedback(FL_OBJECT * ob)
bool FormPreferences::input(FL_OBJECT * ob, long)
{
Assert(ob);
lyx::Assert(ob);
// whatever checks you need to ensure the user hasn't entered
// some totally ridiculous value somewhere. Change activate to suit.
@ -3000,7 +3000,7 @@ int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
// Note that the return value is important in the pre-emptive handler.
// Don't return anything other than 0.
Assert(ob);
lyx::Assert(ob);
// Don't Assert this one, as it can happen quite reasonably when things
// are being deleted in the d-tor.
//Assert(ob->form);
@ -3016,7 +3016,7 @@ int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
// preemptive handler for feedback messages
void FormPreferences::Feedback(FL_OBJECT * ob, int event)
{
Assert(ob);
lyx::Assert(ob);
switch (event) {
case FL_ENTER:
@ -3037,6 +3037,6 @@ void FormPreferences::Feedback(FL_OBJECT * ob, int event)
void FormPreferences::setPreHandler(FL_OBJECT * ob)
{
Assert(ob);
lyx::Assert(ob);
fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);
}

View File

@ -21,18 +21,20 @@
#include "form_splash.h"
#include "support/LAssert.h"
extern "C" int C_FormSplashCloseCB(FL_FORM * form, void *)
extern "C"
int C_FormSplashCloseCB(FL_FORM * form, void *)
{
Assert(form && form->u_vdata);
lyx::Assert(form && form->u_vdata);
FormSplash * pre = static_cast<FormSplash *>(form->u_vdata);
pre->Hide();
return FL_CANCEL;
}
extern "C" void C_FormSplashCB(FL_OBJECT * ob, long)
extern "C"
void C_FormSplashCB(FL_OBJECT * ob, long)
{
Assert(ob && ob->form && ob->form->u_vdata);
lyx::Assert(ob && ob->form && ob->form->u_vdata);
FormSplash * pre = static_cast<FormSplash*>(ob->form->u_vdata);
pre->Hide();
}

View File

@ -602,7 +602,7 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
}
// Paranoia check
Assert(item->kind() == MenuItem::Submenu);
lyx::Assert(item->kind() == MenuItem::Submenu);
// set tabstop length
fl_set_tabstop(menu_tabstop);

View File

@ -73,11 +73,12 @@ GraphicsCacheItem::imageConverted(int retval)
namespace {
string const findTargetFormat(string const & from)
{
typedef ImageLoader::FormatList FormatList;
FormatList formats = ImageLoaderXPM().loadableFormats();
Assert(formats.size() > 0); // There must be a format to load from.
lyx::Assert(formats.size() > 0); // There must be a format to load from.
FormatList::const_iterator iter = formats.begin();
FormatList::const_iterator end = formats.end();

View File

@ -86,7 +86,7 @@ ImageLoaderXPM::runImageLoader(string const & filename)
}
// This should have been set by the XpmReadFileToPixmap call!
Assert(attrib.valuemask & XpmSize);
lyx::Assert(attrib.valuemask & XpmSize);
setImage(new LyXImage(pixmap, attrib.width, attrib.height));

View File

@ -256,7 +256,7 @@ void ExternalTemplate::readTemplate(LyXLex & lex)
default:
lex.printError("ExternalTemplate::readTemplate: "
"Wrong tag: $$Token");
Assert(false);
lyx::Assert(false);
break;
}
}

View File

@ -180,8 +180,8 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
}
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
void UpdatableInset::scroll(BufferView * bv, int offset) const

View File

@ -196,6 +196,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
if (!owner())
x += static_cast<float>(scroll());
#endif
if (!cleared && (inset.need_update == InsetText::FULL ||
inset.need_update == InsetText::INIT ||
top_x != int(x) ||
@ -208,11 +209,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
bv->text->status = LyXText::CHANGED_IN_DRAW;
return;
#else
int w = owner() ? width(bv, f) : pain.paperWidth();
int w = owner() ? width(bv, f) : pain.paperWidth();
int h = ascent(bv, f) + descent(bv, f);
int const tx = (needFullRow() && !owner()) ? 0 : int(x);
int const ty = max(0, baseline - ascent(bv, f));
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
if ((top_x + w) > pain.paperWidth())
@ -402,7 +403,7 @@ bool InsetCollapsable::UnlockInsetInInset(BufferView * bv, UpdatableInset * in,
bv->unlockInset(this);
return true;
}
bool ret = inset.UnlockInsetInInset(bv, in, lr);
bool const ret = inset.UnlockInsetInInset(bv, in, lr);
return ret;
}
@ -500,6 +501,7 @@ bool InsetCollapsable::nodraw() const
return inset.nodraw();
}
int InsetCollapsable::scroll(bool recursive) const
{
int sx = UpdatableInset::scroll(false);

View File

@ -146,34 +146,34 @@ void InsetGraphicsParams::testInvariant() const
// Filename might be empty (when the dialog is first created).
// Assert(!filename.empty());
Assert(display == COLOR ||
lyx::Assert(display == COLOR ||
display == MONOCHROME ||
display == GRAYSCALE ||
display == NONE
);
Assert(widthResize == DEFAULT_SIZE ||
lyx::Assert(widthResize == DEFAULT_SIZE ||
widthResize == CM ||
widthResize == INCH ||
widthResize == PERCENT_PAGE ||
widthResize == PERCENT_COLUMN
);
Assert(heightResize == DEFAULT_SIZE ||
lyx::Assert(heightResize == DEFAULT_SIZE ||
heightResize == CM ||
heightResize == INCH ||
heightResize == PERCENT_PAGE
);
Assert(widthSize >= 0.0);
Assert(heightSize >= 0.0);
lyx::Assert(widthSize >= 0.0);
lyx::Assert(heightSize >= 0.0);
// Angle is in degrees and ranges -360 < angle < 360
// The reason for this is that in latex there is a meaning for the
// different angles and they are not necessarliy interchangeable,
// it depends on the rotation origin.
Assert(rotateAngle < 360);
Assert(rotateAngle > -360);
lyx::Assert(rotateAngle < 360);
lyx::Assert(rotateAngle > -360);
}

View File

@ -151,6 +151,7 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
}
#ifdef WITH_WARNINGS
#warning Remove me before final 1.2.0 (Jug)
#warning Can we please remove this as soon as possible? (Lgb)
#endif
// this is only for compatibility to the intermediate format and should
// vanish till the final 1.2.0!

View File

@ -226,10 +226,10 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
if (nodraw())
return;
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
return;
return;
// lyxerr << "InsetTabular::draw(" << need_update << ")\n";
Painter & pain = bv->painter();
int i;
int j;
@ -2315,6 +2315,7 @@ bool InsetTabular::nodraw() const
return UpdatableInset::nodraw();
}
int InsetTabular::scroll(bool recursive) const
{
int sx = UpdatableInset::scroll(false);
@ -2325,6 +2326,7 @@ int InsetTabular::scroll(bool recursive) const
return sx;
}
bool InsetTabular::doClearArea() const
{
return !locked || (need_update & (FULL|INIT));

View File

@ -385,6 +385,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
#ifdef WITH_WARNINGS
#warning Jürgen, why is this a block of its own? (Lgb)
#warning because you told me to define variables only in local context (Jug)!
#warning then make it a function/method of its own. (Lgb)
#endif
{
int y = 0;
@ -1546,10 +1547,8 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int button)
{
int dummyx, dummyy;
dummyx = x = x - drawTextXOffset;
dummyy = y + insetAscent;
int dummyx = x = x - drawTextXOffset;
int dummyy = y + insetAscent;
Inset * inset = bv->checkInsetHit(TEXT(bv), dummyx, dummyy, button);
if (inset) {
@ -1864,6 +1863,7 @@ void InsetText::removeNewlines()
}
}
bool InsetText::nodraw() const
{
if (the_locking_inset)
@ -1871,6 +1871,7 @@ bool InsetText::nodraw() const
return UpdatableInset::nodraw();
}
int InsetText::scroll(bool recursive) const
{
int sx = UpdatableInset::scroll(false);
@ -1881,6 +1882,7 @@ int InsetText::scroll(bool recursive) const
return sx;
}
bool InsetText::doClearArea() const
{
return !locked || (need_update & (FULL|INIT));

View File

@ -239,7 +239,6 @@ public:
return scx;
return 0;
}
protected:
///
mutable int top_x;
@ -308,10 +307,8 @@ public:
return b ? DISPATCHED : FINISHED;
}
///
UpdatableInset() : cursor_visible_(false), block_drawing_(false) {}
///
virtual EDITABLE Editable() const;
@ -384,7 +381,6 @@ public:
virtual bool nodraw() const {
return block_drawing_;
}
protected:
///
void toggleCursorVisible() const {

View File

@ -1152,7 +1152,7 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
bool LyXTextClass::hasLayout(string const & name) const
{
return find_if(layoutlist.begin(), layoutlist.end(),
compare_memfun(&LyXLayout::name, name))
lyx::compare_memfun(&LyXLayout::name, name))
!= layoutlist.end();
}
@ -1162,8 +1162,8 @@ LyXLayout const & LyXTextClass::GetLayout (string const & name) const
LayoutList::const_iterator cit =
find_if(layoutlist.begin(),
layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
Assert(cit != layoutlist.end()); // we require the name to exist
lyx::compare_memfun(&LyXLayout::name, name));
lyx::Assert(cit != layoutlist.end()); // we require the name to exist
return (*cit);
}
@ -1173,8 +1173,8 @@ LyXLayout & LyXTextClass::GetLayout(string const & name)
LayoutList::iterator it =
find_if(layoutlist.begin(),
layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
Assert(it != layoutlist.end()); // we require the name to exist
lyx::compare_memfun(&LyXLayout::name, name));
lyx::Assert(it != layoutlist.end()); // we require the name to exist
return (*it);
}
@ -1183,7 +1183,7 @@ bool LyXTextClass::delete_layout(string const & name)
{
LayoutList::iterator it =
remove_if(layoutlist.begin(), layoutlist.end(),
compare_memfun(&LyXLayout::name, name));
lyx::compare_memfun(&LyXLayout::name, name));
LayoutList::iterator end = layoutlist.end();
bool const ret = (it != end);
layoutlist.erase(it, end);
@ -1218,7 +1218,7 @@ LyXTextClassList::NumberOfClass(string const & textclass) const
{
ClassList::const_iterator cit =
find_if(classlist.begin(), classlist.end(),
compare_memfun(&LyXTextClass::name, textclass));
lyx::compare_memfun(&LyXTextClass::name, textclass));
return cit != classlist.end() ?
make_pair(true, size_type(cit - classlist.begin())) :
make_pair(false, size_type(0));
@ -1274,7 +1274,7 @@ LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const
if (classlist.size() == 0) {
return dummy;
}
Assert(number < classlist.size());
lyx::Assert(number < classlist.size());
return classlist[number].name();
}
@ -1288,7 +1288,7 @@ LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const
if (classlist.size() == 0) {
return dummy;
}
Assert(number < classlist.size());
lyx::Assert(number < classlist.size());
return classlist[number].latexname();
}
@ -1301,7 +1301,7 @@ LyXTextClassList::DescOfClass(LyXTextClassList::size_type number) const
if (classlist.size() == 0) {
return dummy;
}
Assert(number < classlist.size());
lyx::Assert(number < classlist.size());
return classlist[number].description();
}

View File

@ -747,7 +747,7 @@ string const LyXFunc::Dispatch(int ac,
}
}
Assert(action != LFUN_SELECT_FILE_SYNC);
lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
switch (action) {
// --- Misc -------------------------------------------
@ -813,7 +813,7 @@ string const LyXFunc::Dispatch(int ac,
std::transform(lyxaction.func_begin(), lyxaction.func_end(),
std::back_inserter(allCmds), lyx::firster());
static std::vector<string> hist;
owner->getMiniBuffer()->getString(MiniBuffer::nospaces,
owner->getMiniBuffer()->getString(MiniBuffer::spaces,
allCmds, hist);
}
break;

View File

@ -644,12 +644,19 @@ public:
};
inline
LyXParagraph::size_type LyXParagraph::size() const
{
return text.size();
}
#ifdef NEW_INSETS
inline
LyXParagraph::value_type
LyXParagraph::GetChar(LyXParagraph::size_type pos) const
{
Assert(pos <= size());
lyx::Assert(pos <= size());
// This is stronger, and I belive that this is the assertion
// that we should really use. (Lgb)
//Assert(pos < size());
@ -675,6 +682,17 @@ void LyXParagraph::id(int id_arg)
}
inline
LyXTextClass::size_type LyXParagraph::GetLayout() const
{
#ifndef NEW_INSETS
return FirstPhysicalPar()->layout;
#else
return layout;
#endif
}
inline
bool LyXParagraph::IsFirstInSequence() const
{
@ -692,13 +710,6 @@ Inset * LyXParagraph::InInset()
}
inline
LyXParagraph::size_type LyXParagraph::size() const
{
return text.size();
}
inline
void LyXParagraph::clearContents()
{
@ -734,17 +745,6 @@ void LyXParagraph::SetChar(size_type pos, value_type c)
}
inline
LyXTextClass::size_type LyXParagraph::GetLayout() const
{
#ifndef NEW_INSETS
return FirstPhysicalPar()->layout;
#else
return layout;
#endif
}
inline
LyXParagraph::inset_iterator LyXParagraph::inset_iterator_begin()
{

View File

@ -42,7 +42,7 @@ MathMacroTable::getTemplate(string const & name) const
void
MathMacroTable::addTemplate(boost::shared_ptr<MathMacroTemplate> const & m)
{
Assert(m.get());
lyx::Assert(m.get());
macro_table[m->GetName()] = m;
}

View File

@ -145,7 +145,7 @@ MathParInset * MathMacroTemplate::getMacroPar(int i) const
if (i >= 0 && i < nargs_) {
MathParInset * p = const_cast<MathParInset *>
(static_cast<MathParInset const *>(&args_[i]));
Assert(p);
lyx::Assert(p);
return p;
} else
return 0;

View File

@ -100,19 +100,19 @@ bool MathedRowContainer::empty() const
void MathedRowContainer::insert(iterator const & it)
{
Assert(it.st_ == this);
lyx::Assert(it.st_ == this);
data_.insert(data_.begin() + it.pos_, MathedRowStruct());
}
void MathedRowContainer::erase(iterator & it)
{
Assert(it.st_ == this);
lyx::Assert(it.st_ == this);
data_.erase(data_.begin() + it.pos_);
}
MathedRowStruct & MathedRowContainer::back()
{
Assert(data_.size());
lyx::Assert(data_.size());
return data_.back();
}
@ -148,25 +148,25 @@ MathedRowContainer::iterator::operator void *() const
MathedRowStruct * MathedRowContainer::iterator::operator->()
{
Assert(st_);
lyx::Assert(st_);
return &st_->data_[pos_];
}
MathedRowStruct const * MathedRowContainer::iterator::operator->() const
{
Assert(st_);
lyx::Assert(st_);
return &st_->data_[pos_];
}
void MathedRowContainer::iterator::operator++()
{
Assert(st_);
lyx::Assert(st_);
++pos_;
}
bool MathedRowContainer::iterator::is_last() const
{
Assert(st_);
lyx::Assert(st_);
return pos_ == st_->size() - 1;
}

View File

@ -38,7 +38,7 @@ MathParInset * MathedXIter::getPar() const
MathedRowContainer & MathedXIter::container()
{
Assert(p_);
lyx::Assert(p_);
return p_->getRowSt();
}

View File

@ -524,7 +524,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
return;
}
#else
Assert(pos < size());
lyx::Assert(pos < size());
#endif
#ifndef NEW_INSETS
if (pos < size()) { // last is free for insertation, but should be empty
@ -618,7 +618,7 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
return;
}
#else
Assert(pos <= size());
lyx::Assert(pos <= size());
#endif
text.insert(text.begin() + pos, c);
@ -653,7 +653,7 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
Inset * inset, LyXFont const & font)
{
Assert(inset);
lyx::Assert(inset);
#ifndef NEW_INSETS
// > because last is the next unused position, and you can
@ -670,11 +670,11 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
return;
}
#else
Assert(pos <= size());
lyx::Assert(pos <= size());
#endif
InsertChar(pos, META_INSET, font);
Assert(text[pos] == META_INSET);
lyx::Assert(text[pos] == META_INSET);
// Add a new entry in the inset table.
InsetTable search_inset(pos, 0);
@ -717,7 +717,7 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
return 0;
}
#else
Assert(pos < size());
lyx::Assert(pos < size());
#endif
// Find the inset.
InsetTable search_inset(pos, 0);
@ -756,7 +756,7 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const
return 0;
}
#else
Assert(pos < size());
lyx::Assert(pos < size());
#endif
// Find the inset.
InsetTable search_inset(pos, 0);
@ -820,7 +820,7 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
LyXParagraph::size_type pos) const
{
Assert(pos <= size());
lyx::Assert(pos <= size());
FontTable search_font(pos, LyXFont());
FontList::const_iterator cit = lower_bound(fontlist.begin(),
fontlist.end(),
@ -941,7 +941,7 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos,
LyXParagraph::value_type
LyXParagraph::GetChar(LyXParagraph::size_type pos) const
{
Assert(pos >= 0);
lyx::Assert(pos >= 0);
if (pos < size()) {
return text[pos];
@ -958,7 +958,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
"position does not exist."
<< pos << " (" << static_cast<int>(pos)
<< ")\n";
Assert(false);
lyx::Assert(false);
}
return '\0';
} else {
@ -991,7 +991,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
//LyXParagraph::value_type
//LyXParagraph::GetChar(LyXParagraph::size_type pos) const
//{
// Assert(pos <= size());
// lyx::Assert(pos <= size());
// if (!size() || pos == size()) return '\0';
//
// return text[pos];
@ -1044,7 +1044,7 @@ LyXParagraph::GetUChar(BufferParams const & bparams,
// return an string of the current word, and the end of the word in lastpos.
string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
{
Assert(lastpos >= 0);
lyx::Assert(lastpos >= 0);
// the current word is defined as starting at the first character
// from the immediate left of lastpospos which meets the definition
@ -1160,7 +1160,7 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
return;
}
#else
Assert(pos <= size());
lyx::Assert(pos <= size());
#endif
// First, reduce font against layout/label font

View File

@ -1,3 +1,10 @@
2001-04-24 Lars Gullik Bjønnes <larsbj@birdstep.com>
* LAssert.h (Assert): put into namespace lyx
* lyxfunctional.h: put into namespace lyx
* translator.h: adjust
2001-04-17 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxalgo.h: put into namespace lyx, add firster and copy_if

View File

@ -4,12 +4,12 @@
#include "support/lyxlib.h"
//namespace LyX {
extern void emergencySave();
namespace lyx {
#ifdef ENABLE_ASSERTIONS
extern void emergencySave();
/** Live assertion.
This is a debug tool to ensure that the assertion holds. If it don't hole
we run #emergencySave()# and then #lyx::abort".
@ -36,5 +36,6 @@ void Assert(A /*assertion*/) {}
#endif /* ENABLE_ASSERTIONS */
//} // end of namespace LyX
} // end of namespace LyX
#endif /* LASSERT_H */

View File

@ -231,7 +231,7 @@ string const uppercase(string const & a)
bool prefixIs(string const & a, char const * pre)
{
Assert(pre);
lyx::Assert(pre);
size_t const l = strlen(pre);
string::size_type const alen = a.length();
@ -279,7 +279,7 @@ bool suffixIs(string const & a, char c)
bool suffixIs(string const & a, char const * suf)
{
Assert(suf);
lyx::Assert(suf);
size_t const suflen = strlen(suf);
string::size_type const alen = a.length();
@ -322,7 +322,7 @@ bool suffixIs(string const & a, string const & suf)
bool contains(char const * a, string const & b)
{
Assert(a);
lyx::Assert(a);
string const at(a);
return contains(at, b);
}
@ -330,7 +330,7 @@ bool contains(char const * a, string const & b)
bool contains(string const & a, char const * b)
{
Assert(b);
lyx::Assert(b);
string const bt(b);
return contains(a, bt);
}
@ -354,7 +354,7 @@ bool contains(string const & a, char b)
bool contains(char const * a, char const * b)
{
Assert(a && b);
lyx::Assert(a && b);
string const at(a);
string const bt(b);
return contains(at, bt);
@ -363,7 +363,7 @@ bool contains(char const * a, char const * b)
bool containsOnly(string const & s, char const * cset)
{
Assert(cset);
lyx::Assert(cset);
return s.find_first_not_of(cset) == string::npos;
}
@ -377,7 +377,7 @@ bool containsOnly(string const & s, string const & cset)
bool containsOnly(char const * s, char const * cset)
{
Assert(s && cset);
lyx::Assert(s && cset);
return string(s).find_first_not_of(cset) == string::npos;
}
@ -385,7 +385,7 @@ bool containsOnly(char const * s, char const * cset)
bool containsOnly(char const * s, string const & cset)
{
Assert(s);
lyx::Assert(s);
return string(s).find_first_not_of(cset) == string::npos;
}
@ -475,7 +475,7 @@ string const subst(string const & a, char oldchar, char newchar)
string const subst(string const & a,
char const * oldstr, string const & newstr)
{
Assert(oldstr);
lyx::Assert(oldstr);
string lstr(a);
string::size_type i = 0;
@ -527,7 +527,7 @@ string const strip(string const & a, char c)
string const frontStrip(string const & a, char const * p)
{
Assert(p);
lyx::Assert(p);
if (a.empty() || !*p) return a;
string tmp(a);

View File

@ -12,7 +12,7 @@
#include <iterator>
//namespace lyx {
namespace lyx {
template<class R, class C, class A>
@ -251,6 +251,5 @@ private:
T2 const & value_;
};
// } // end of namespace lyx
} // end of namespace lyx
#endif

View File

@ -49,12 +49,12 @@ public:
/// Find the mapping for the first argument
T2 const & find(T1 const & first) const {
Assert(!map.empty());
lyx::Assert(!map.empty());
// For explanation see the next find() function.
Map::const_iterator it =
std::find_if(map.begin(), map.end(),
equal_1st_in_pair<T1, T2>(first)
lyx::equal_1st_in_pair<T1, T2>(first)
);
if (it != map.end()) {
@ -66,7 +66,7 @@ public:
/// Find the mapping for the second argument
T1 const & find(T2 const & second) const {
Assert(!map.empty());
lyx::Assert(!map.empty());
// The idea is as follows:
// find_if() will try to compare the data in the vector with
@ -81,7 +81,7 @@ public:
// equal_to( select2nd(pair) , second)
Map::const_iterator it =
std::find_if(map.begin(), map.end(),
equal_2nd_in_pair<T1, T2>(second)
lyx::equal_2nd_in_pair<T1, T2>(second)
);
if (it != map.end())

View File

@ -118,7 +118,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
// If this and lt is not of the same size we have a serious bug
// So then it is ok to throw an exception, or for now
// call abort()
Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
lyx::Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
cell_info = lt.cell_info;
row_info = lt.row_info;
@ -156,7 +156,7 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset)
}
/* activates all lines and sets all widths to 0 */
/* activates all lines and sets all widths to 0 */
void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
{
rows_ = rows_arg;
@ -169,7 +169,7 @@ void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
operator=(*lt);
return;
}
int cellno = 0;
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
@ -480,7 +480,7 @@ int LyXTabular::GetAdditionalHeight(int row) const
{
if (!row || row >= rows_)
return 0;
bool top = true;
bool bottom = true;

View File

@ -180,9 +180,10 @@ public:
bool LeftAlreadyDrawed(int cell) const;
///
bool IsLastRow(int cell) const;
///
int GetAdditionalHeight(int row) const;
///
int GetAdditionalWidth(int cell) const;
@ -490,7 +491,7 @@ private:
int endlastfoot;
///
InsetTabular * owner_;
///
void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0);
///

View File

@ -1665,7 +1665,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
float x, dummy;
float x;
float dummy;
PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
row_ptr->width(int(maxwidth + x));
if (inset_owner) {