remove NEW_WAY stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@850 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-06-30 14:58:05 +00:00
parent 90c533ae7d
commit 2dbd47535d
9 changed files with 2 additions and 340 deletions

View File

@ -412,12 +412,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
+ textclasslist.NameOfClass(c1) + _(" to ") + textclasslist.NameOfClass(c1) + _(" to ")
+ textclasslist.NameOfClass(c2); + textclasslist.NameOfClass(c2);
InsetError * new_inset = new InsetError(s); InsetError * new_inset = new InsetError(s);
#ifdef NEW_WAY
par->InsertInset(0, new_inset); par->InsertInset(0, new_inset);
#else
par->InsertChar(0, LyXParagraph::META_INSET);
par->InsertInset(0, new_inset);
#endif
} }
par = par->next; par = par->next;

View File

@ -308,24 +308,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
if (token[0] != '\\') { if (token[0] != '\\') {
for (string::const_iterator cit = token.begin(); for (string::const_iterator cit = token.begin();
cit != token.end(); ++cit) { cit != token.end(); ++cit) {
#ifdef NEW_WAY
par->InsertChar(pos, (*cit), font); par->InsertChar(pos, (*cit), font);
#else
par->InsertChar(pos, (*cit));
par->SetFont(pos, font);
#endif
++pos; ++pos;
} }
} else if (token == "\\i") { } else if (token == "\\i") {
Inset * inset = new InsetLatexAccent; Inset * inset = new InsetLatexAccent;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (token == "\\layout") { } else if (token == "\\layout") {
if (!return_par) if (!return_par)
@ -424,13 +413,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
nylex.setStream(istr); nylex.setStream(istr);
inset->Read(this, nylex); inset->Read(this, nylex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
#endif #endif
} else if (token == "\\begin_deeper") { } else if (token == "\\begin_deeper") {
@ -816,178 +799,82 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
if (tmptok == "Quotes") { if (tmptok == "Quotes") {
Inset * inset = new InsetQuotes; Inset * inset = new InsetQuotes;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "External") { } else if (tmptok == "External") {
Inset * inset = new InsetExternal; Inset * inset = new InsetExternal;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "FormulaMacro") { } else if (tmptok == "FormulaMacro") {
Inset * inset = new InsetFormulaMacro; Inset * inset = new InsetFormulaMacro;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Formula") { } else if (tmptok == "Formula") {
Inset * inset = new InsetFormula; Inset * inset = new InsetFormula;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Figure") { } else if (tmptok == "Figure") {
Inset * inset = new InsetFig(100, 100, this); Inset * inset = new InsetFig(100, 100, this);
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Info") { } else if (tmptok == "Info") {
Inset * inset = new InsetInfo; Inset * inset = new InsetInfo;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Include") { } else if (tmptok == "Include") {
Inset * inset = new InsetInclude(string(), this); Inset * inset = new InsetInclude(string(), this);
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "ERT") { } else if (tmptok == "ERT") {
Inset * inset = new InsetERT; Inset * inset = new InsetERT;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Tabular") { } else if (tmptok == "Tabular") {
Inset * inset = new InsetTabular(this); Inset * inset = new InsetTabular(this);
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Text") { } else if (tmptok == "Text") {
Inset * inset = new InsetText; Inset * inset = new InsetText;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Foot") { } else if (tmptok == "Foot") {
Inset * inset = new InsetFoot; Inset * inset = new InsetFoot;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Marginal") { } else if (tmptok == "Marginal") {
Inset * inset = new InsetMarginal; Inset * inset = new InsetMarginal;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Minipage") { } else if (tmptok == "Minipage") {
Inset * inset = new InsetMinipage; Inset * inset = new InsetMinipage;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "Float") { } else if (tmptok == "Float") {
Inset * inset = new InsetFloat; Inset * inset = new InsetFloat;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "List") { } else if (tmptok == "List") {
Inset * inset = new InsetList; Inset * inset = new InsetList;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} else if (tmptok == "GRAPHICS") { } else if (tmptok == "GRAPHICS") {
Inset * inset = new InsetGraphics; Inset * inset = new InsetGraphics;
//inset->Read(this, lex); //inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
} else if (tmptok == "LatexCommand") { } else if (tmptok == "LatexCommand") {
InsetCommand inscmd; InsetCommand inscmd;
inscmd.Read(this, lex); inscmd.Read(this, lex);
@ -1031,13 +918,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
} }
if (inset) { if (inset) {
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
} }
} }
@ -1053,20 +934,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
lex.next(); lex.next();
next_token = lex.GetString(); next_token = lex.GetString();
if (next_token == "\\-") { if (next_token == "\\-") {
#ifdef NEW_WAY
par->InsertChar(pos, '-', font); par->InsertChar(pos, '-', font);
#else
par->InsertChar(pos, '-');
par->SetFont(pos, font);
#endif
} else if (next_token == "\\protected_separator" } else if (next_token == "\\protected_separator"
|| next_token == "~") { || next_token == "~") {
#ifdef NEW_WAY
par->InsertChar(pos, ' ', font); par->InsertChar(pos, ' ', font);
#else
par->InsertChar(pos, ' ');
par->SetFont(pos, font);
#endif
} else { } else {
lex.printError("Token `$$Token' " lex.printError("Token `$$Token' "
"is in free space " "is in free space "
@ -1077,45 +948,23 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
} else { } else {
Inset * inset = new InsetSpecialChar; Inset * inset = new InsetSpecialChar;
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
} }
++pos; ++pos;
} else if (token == "\\newline") { } else if (token == "\\newline") {
#ifdef NEW_WAY
par->InsertChar(pos, LyXParagraph::META_NEWLINE, font); par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
#else
par->InsertChar(pos, LyXParagraph::META_NEWLINE);
par->SetFont(pos, font);
#endif
++pos; ++pos;
} else if (token == "\\LyXTable") { } else if (token == "\\LyXTable") {
#ifdef USE_TABULAR_INSETS #ifdef USE_TABULAR_INSETS
Inset * inset = new InsetTabular(this); Inset * inset = new InsetTabular(this);
inset->Read(this, lex); inset->Read(this, lex);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
++pos; ++pos;
#else #else
par->table = new LyXTable(lex); par->table = new LyXTable(lex);
#endif #endif
} else if (token == "\\hfill") { } else if (token == "\\hfill") {
#ifdef NEW_WAY
par->InsertChar(pos, LyXParagraph::META_HFILL, font); par->InsertChar(pos, LyXParagraph::META_HFILL, font);
#else
par->InsertChar(pos, LyXParagraph::META_HFILL);
par->SetFont(pos, font);
#endif
++pos; ++pos;
} else if (token == "\\protected_separator") { // obsolete } else if (token == "\\protected_separator") { // obsolete
// This is a backward compability thingie. (Lgb) // This is a backward compability thingie. (Lgb)
@ -1126,21 +975,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->GetLayout()); par->GetLayout());
if (layout.free_spacing) { if (layout.free_spacing) {
#ifdef NEW_WAY
par->InsertChar(pos, ' ', font); par->InsertChar(pos, ' ', font);
#else
par->InsertChar(pos, ' ');
par->SetFont(pos, font);
#endif
} else { } else {
Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
#ifdef NEW_WAY
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
par->InsertInset(pos, inset);
#endif
} }
++pos; ++pos;
} else if (token == "\\bibitem") { // ale970302 } else if (token == "\\bibitem") { // ale970302
@ -1148,12 +986,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->bibkey = new InsetBibKey; par->bibkey = new InsetBibKey;
par->bibkey->Read(this, lex); par->bibkey->Read(this, lex);
}else if (token == "\\backslash") { }else if (token == "\\backslash") {
#ifdef NEW_WAY
par->InsertChar(pos, '\\', font); par->InsertChar(pos, '\\', font);
#else
par->InsertChar(pos, '\\');
par->SetFont(pos, font);
#endif
++pos; ++pos;
}else if (token == "\\the_end") { }else if (token == "\\the_end") {
the_end_read = true; the_end_read = true;
@ -1163,12 +996,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
"Inserting as text."); "Inserting as text.");
for(string::const_iterator cit = token.begin(); for(string::const_iterator cit = token.begin();
cit != token.end(); ++cit) { cit != token.end(); ++cit) {
#ifdef NEW_WAY
par->InsertChar(pos, (*cit), font); par->InsertChar(pos, (*cit), font);
#else
par->InsertChar(pos, (*cit));
par->SetFont(pos, font);
#endif
++pos; ++pos;
} }
} }
@ -2899,12 +2727,7 @@ void Buffer::LinuxDocError(LyXParagraph * par, int pos,
{ {
// insert an error marker in text // insert an error marker in text
InsetError * new_inset = new InsetError(message); InsetError * new_inset = new InsetError(message);
#ifdef NEW_WAY
par->InsertInset(pos, new_inset); par->InsertInset(pos, new_inset);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, new_inset);
#endif
} }
// This constant defines the maximum number of // This constant defines the maximum number of

View File

@ -959,12 +959,7 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
UpdatableInset * i = static_cast<UpdatableInset *>(inset); UpdatableInset * i = static_cast<UpdatableInset *>(inset);
i->setOwner(static_cast<UpdatableInset *>(this)); i->setOwner(static_cast<UpdatableInset *>(this));
} }
#ifdef NEW_WAY
cpar(bv)->InsertInset(cpos(bv), inset); cpar(bv)->InsertInset(cpos(bv), inset);
#else
cpar(bv)->InsertChar(cpos(bv), LyXParagraph::META_INSET);
cpar(bv)->InsertInset(cpos(bv), inset);
#endif
TEXT(bv)->selection = 0; TEXT(bv)->selection = 0;
UpdateLocal(bv, CURSOR_PAR, true); UpdateLocal(bv, CURSOR_PAR, true);
static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0); static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);

View File

@ -6,7 +6,8 @@
* Copyright 1995 Matthias Ettrich * Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team. * Copyright 1995-2000 The LyX Team.
* *
* ====================================================== */ * ======================================================
*/
#include <config.h> #include <config.h>

View File

@ -2643,13 +2643,8 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params); current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT, lang); LyXFont font(LyXFont::ALL_INHERIT, lang);
for (int i = 0; i < xsize * ysize - 1; ++i) { for (int i = 0; i < xsize * ysize - 1; ++i) {
#ifdef NEW_WAY
current_view->text->cursor.par() current_view->text->cursor.par()
->InsertChar(0, LyXParagraph::META_NEWLINE, font); ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
#else
current_view->text->cursor.par()->InsertChar(0, LyXParagraph::META_NEWLINE);
current_view->text->cursor.par()->SetFont(0, font);
#endif
} }
current_view->text->RedoParagraph(current_view); current_view->text->RedoParagraph(current_view);

View File

@ -26,8 +26,6 @@
#include "support/block.h" #include "support/block.h"
#include "language.h" #include "language.h"
#define NEW_WAY 1
class BufferParams; class BufferParams;
class LyXBuffer; class LyXBuffer;
class TexRow; class TexRow;
@ -424,16 +422,12 @@ public:
size_type endpos) const; size_type endpos) const;
/// ///
void InsertChar(size_type pos, char c); void InsertChar(size_type pos, char c);
#ifdef NEW_WAY
/// ///
void InsertChar(size_type pos, char c, LyXFont const &); void InsertChar(size_type pos, char c, LyXFont const &);
#endif
/// ///
void InsertInset(size_type pos, Inset * inset); void InsertInset(size_type pos, Inset * inset);
#ifdef NEW_WAY
/// ///
void InsertInset(size_type pos, Inset * inset, LyXFont const &); void InsertInset(size_type pos, Inset * inset, LyXFont const &);
#endif
/// ///
bool InsertInsetAllowed(Inset * inset); bool InsertInsetAllowed(Inset * inset);
/// ///

View File

@ -464,17 +464,10 @@ bool LyXParagraph::InsertFromMinibuffer(LyXParagraph::size_type pos)
if ((minibuffer_char == LyXParagraph::META_INSET) && if ((minibuffer_char == LyXParagraph::META_INSET) &&
!InsertInsetAllowed(minibuffer_inset)) !InsertInsetAllowed(minibuffer_inset))
return false; return false;
#ifdef NEW_WAY
if (minibuffer_char == LyXParagraph::META_INSET) if (minibuffer_char == LyXParagraph::META_INSET)
InsertInset(pos, minibuffer_inset, minibuffer_font); InsertInset(pos, minibuffer_inset, minibuffer_font);
else else
InsertChar(pos, minibuffer_char, minibuffer_font); InsertChar(pos, minibuffer_char, minibuffer_font);
#else
InsertChar(pos, minibuffer_char);
SetFont(pos, minibuffer_font);
if (minibuffer_char == LyXParagraph::META_INSET)
InsertInset(pos, minibuffer_inset);
#endif
return true; return true;
} }
@ -608,43 +601,11 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c) void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c)
{ {
#ifndef NEW_WAY
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
NextAfterFootnote()->InsertChar(pos - text.size() - 1,
c);
else
#endif
lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): "
"position does not exist." << endl;
return;
}
text.insert(text.begin() + pos, c);
// Update the font table.
for (FontList::iterator it = lower_bound(fontlist.begin(),
fontlist.end(),
pos, matchFT());
it != fontlist.end(); ++it)
++(*it).pos;
// Update the inset table.
for (InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
pos, matchIT());
it != insetlist.end(); ++it)
++(*it).pos;
#else
LyXFont f(LyXFont::ALL_INHERIT); LyXFont f(LyXFont::ALL_INHERIT);
InsertChar(pos, c, f); InsertChar(pos, c, f);
#endif
} }
#ifdef NEW_WAY
void LyXParagraph::InsertChar(LyXParagraph::size_type pos, void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
char c, LyXFont const & font) char c, LyXFont const & font)
{ {
@ -679,54 +640,16 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
SetFont(pos, font); SetFont(pos, font);
} }
#endif
void LyXParagraph::InsertInset(LyXParagraph::size_type pos, void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
Inset * inset) Inset * inset)
{ {
#ifdef NEW_WAY
LyXFont f(LyXFont::ALL_INHERIT); LyXFont f(LyXFont::ALL_INHERIT);
InsertInset(pos, inset, f); InsertInset(pos, inset, f);
#else
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
NextAfterFootnote()
->InsertInset(pos - text.size() - 1, inset);
else
#endif
lyxerr << "ERROR (LyXParagraph::InsertInset): "
"position does not exist: " << pos << endl;
return;
}
if (text[pos] != LyXParagraph::META_INSET) {
lyxerr << "ERROR (LyXParagraph::InsertInset): "
"there is no LyXParagraph::META_INSET" << endl;
return;
}
if (inset) {
// Add a new entry in the inset table.
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
pos, matchIT());
if (it != insetlist.end() && (*it).pos == pos)
lyxerr << "ERROR (LyXParagraph::InsertInset): "
"there is an inset in position: " << pos << endl;
else
insetlist.insert(it, InsetTable(pos,inset));
if (inset_owner)
inset->setOwner(inset_owner);
}
#endif
} }
#ifdef NEW_WAY
void LyXParagraph::InsertInset(LyXParagraph::size_type pos, void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
Inset * inset, LyXFont const & font) Inset * inset, LyXFont const & font)
{ {
@ -763,7 +686,6 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
if (inset_owner) if (inset_owner)
inset->setOwner(inset_owner); inset->setOwner(inset_owner);
} }
#endif
bool LyXParagraph::InsertInsetAllowed(Inset * inset) bool LyXParagraph::InsertInsetAllowed(Inset * inset)

View File

@ -2095,12 +2095,7 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params); Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang); LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) { for (int i = 0; i < number; ++i) {
#ifdef NEW_WAY
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font); cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
#endif
} }
/* append the row into the table */ /* append the row into the table */
@ -2138,12 +2133,7 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params); Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang); LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) { for (int i = 0; i < number; ++i) {
#ifdef NEW_WAY
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font); cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
#endif
} }
/* append the row into the table */ /* append the row into the table */
@ -2160,14 +2150,9 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
do{ do{
if (pos && (cursor.par()->IsNewline(pos-1))){ if (pos && (cursor.par()->IsNewline(pos-1))){
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) { if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
#ifdef NEW_WAY
cursor.par()->InsertChar(pos, cursor.par()->InsertChar(pos,
LyXParagraph::META_NEWLINE, LyXParagraph::META_NEWLINE,
font); font);
#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
#endif
if (pos <= cursor.pos()) if (pos <= cursor.pos())
cursor.pos(cursor.pos() + 1); cursor.pos(cursor.pos() + 1);
++pos; ++pos;
@ -2180,13 +2165,8 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
This saves one byte memory per table ;-) */ This saves one byte memory per table ;-) */
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) { if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
LyXParagraph::size_type last = cursor.par()->Last(); LyXParagraph::size_type last = cursor.par()->Last();
#ifdef NEW_WAY
cursor.par()->InsertChar(last, cursor.par()->InsertChar(last,
LyXParagraph::META_NEWLINE, font); LyXParagraph::META_NEWLINE, font);
#else
cursor.par()->InsertChar(last, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(last, font);
#endif
} }
/* append the column into the table */ /* append the column into the table */

View File

@ -2028,12 +2028,7 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset)
SetUndo(bview->buffer(), Undo::INSERT, SetUndo(bview->buffer(), Undo::INSERT,
cursor.par()->ParFromPos(cursor.pos())->previous, cursor.par()->ParFromPos(cursor.pos())->previous,
cursor.par()->ParFromPos(cursor.pos())->next); cursor.par()->ParFromPos(cursor.pos())->next);
#ifdef NEW_WAY
cursor.par()->InsertInset(cursor.pos(), inset); cursor.par()->InsertInset(cursor.pos(), inset);
#else
cursor.par()->InsertChar(cursor.pos(), LyXParagraph::META_INSET);
cursor.par()->InsertInset(cursor.pos(), inset);
#endif
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly. InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a * The character will not be inserted a
* second time */ * second time */
@ -2307,12 +2302,7 @@ void LyXText::ReplaceSelectionWithString(BufferView * bview, char const * str)
// Insert the new string // Insert the new string
for (int i = 0; str[i]; ++i) { for (int i = 0; str[i]; ++i) {
#ifdef NEW_WAY
sel_end_cursor.par()->InsertChar(pos, str[i], font); sel_end_cursor.par()->InsertChar(pos, str[i], font);
#else
sel_end_cursor.par()->InsertChar(pos, str[i]);
sel_end_cursor.par()->SetFont(pos, font);
#endif
++pos; ++pos;
} }
@ -2396,12 +2386,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
if (str[i] == ' ' if (str[i] == ' '
&& i + 1 < str.length() && str[i + 1] != ' ' && i + 1 < str.length() && str[i + 1] != ' '
&& pos && par->GetChar(pos - 1)!= ' ') { && pos && par->GetChar(pos - 1)!= ' ') {
#ifdef NEW_WAY
par->InsertChar(pos, ' ', current_font); par->InsertChar(pos, ' ', current_font);
#else
par->InsertChar(pos,' ');
par->SetFont(pos, current_font);
#endif
++pos; ++pos;
#ifndef NEW_TABLAR #ifndef NEW_TABLAR
} else if (par->table) { } else if (par->table) {
@ -2415,13 +2400,8 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
break; break;
} else if ((str[i] != 13) && } else if ((str[i] != 13) &&
((str[i] & 127) >= ' ')) { ((str[i] & 127) >= ' ')) {
#ifdef NEW_WAY
par->InsertChar(pos, str[i], par->InsertChar(pos, str[i],
current_font); current_font);
#else
par->InsertChar(pos, str[i]);
par->SetFont(pos, current_font);
#endif
++pos; ++pos;
} }
#endif #endif
@ -2429,14 +2409,8 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
InsetSpecialChar * new_inset = InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) { if (par->InsertInsetAllowed(new_inset)) {
#ifdef NEW_WAY
par->InsertInset(pos, new_inset, par->InsertInset(pos, new_inset,
current_font); current_font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
#endif
} else { } else {
delete new_inset; delete new_inset;
} }
@ -2446,14 +2420,8 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
InsetSpecialChar * new_inset = InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) { if (par->InsertInsetAllowed(new_inset)) {
#ifdef NEW_WAY
par->InsertInset(pos, new_inset, par->InsertInset(pos, new_inset,
current_font); current_font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
#endif
} else { } else {
delete new_inset; delete new_inset;
} }
@ -2462,12 +2430,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
} else if (str[i] != 13 && } else if (str[i] != 13 &&
// Ignore unprintables // Ignore unprintables
(str[i] & 127) >= ' ') { (str[i] & 127) >= ' ') {
#ifdef NEW_WAY
par->InsertChar(pos, str[i], current_font); par->InsertChar(pos, str[i], current_font);
#else
par->InsertChar(pos, str[i]);
par->SetFont(pos, current_font);
#endif
++pos; ++pos;
} }
} else { } else {
@ -2501,15 +2464,9 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
InsetSpecialChar * new_inset = InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) { if (par->InsertInsetAllowed(new_inset)) {
#ifdef NEW_WAY
par->InsertInset(pos, par->InsertInset(pos,
new_inset, new_inset,
current_font); current_font);
#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
#endif
} else { } else {
delete new_inset; delete new_inset;
} }