if (token[0] != '\\') {
for (string::const_iterator cit = token.begin();
cit != token.end(); ++cit) {
-#ifdef NEW_WAY
par->InsertChar(pos, (*cit), font);
-#else
- par->InsertChar(pos, (*cit));
- par->SetFont(pos, font);
-#endif
++pos;
}
} else if (token == "\\i") {
Inset * inset = new InsetLatexAccent;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (token == "\\layout") {
if (!return_par)
nylex.setStream(istr);
inset->Read(this, nylex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
#endif
} else if (token == "\\begin_deeper") {
if (tmptok == "Quotes") {
Inset * inset = new InsetQuotes;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "External") {
Inset * inset = new InsetExternal;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "FormulaMacro") {
Inset * inset = new InsetFormulaMacro;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Formula") {
Inset * inset = new InsetFormula;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Figure") {
Inset * inset = new InsetFig(100, 100, this);
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Info") {
Inset * inset = new InsetInfo;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Include") {
Inset * inset = new InsetInclude(string(), this);
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "ERT") {
Inset * inset = new InsetERT;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Tabular") {
Inset * inset = new InsetTabular(this);
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Text") {
Inset * inset = new InsetText;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Foot") {
Inset * inset = new InsetFoot;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Marginal") {
Inset * inset = new InsetMarginal;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Minipage") {
Inset * inset = new InsetMinipage;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "Float") {
Inset * inset = new InsetFloat;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "List") {
Inset * inset = new InsetList;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
} else if (tmptok == "GRAPHICS") {
Inset * inset = new InsetGraphics;
//inset->Read(this, lex);
-#ifdef NEW_WAY
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") {
InsetCommand inscmd;
inscmd.Read(this, lex);
}
if (inset) {
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
}
}
lex.next();
next_token = lex.GetString();
if (next_token == "\\-") {
-#ifdef NEW_WAY
par->InsertChar(pos, '-', font);
-#else
- par->InsertChar(pos, '-');
- par->SetFont(pos, font);
-#endif
} else if (next_token == "\\protected_separator"
|| next_token == "~") {
-#ifdef NEW_WAY
par->InsertChar(pos, ' ', font);
-#else
- par->InsertChar(pos, ' ');
- par->SetFont(pos, font);
-#endif
} else {
lex.printError("Token `$$Token' "
"is in free space "
} else {
Inset * inset = new InsetSpecialChar;
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
}
++pos;
} else if (token == "\\newline") {
-#ifdef NEW_WAY
par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_NEWLINE);
- par->SetFont(pos, font);
-#endif
++pos;
} else if (token == "\\LyXTable") {
#ifdef USE_TABULAR_INSETS
Inset * inset = new InsetTabular(this);
inset->Read(this, lex);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
++pos;
#else
par->table = new LyXTable(lex);
#endif
} else if (token == "\\hfill") {
-#ifdef NEW_WAY
par->InsertChar(pos, LyXParagraph::META_HFILL, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_HFILL);
- par->SetFont(pos, font);
-#endif
++pos;
} else if (token == "\\protected_separator") { // obsolete
// This is a backward compability thingie. (Lgb)
par->GetLayout());
if (layout.free_spacing) {
-#ifdef NEW_WAY
par->InsertChar(pos, ' ', font);
-#else
- par->InsertChar(pos, ' ');
- par->SetFont(pos, font);
-#endif
} else {
Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
-#ifdef NEW_WAY
par->InsertInset(pos, inset, font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, font);
- par->InsertInset(pos, inset);
-#endif
}
++pos;
} else if (token == "\\bibitem") { // ale970302
par->bibkey = new InsetBibKey;
par->bibkey->Read(this, lex);
}else if (token == "\\backslash") {
-#ifdef NEW_WAY
par->InsertChar(pos, '\\', font);
-#else
- par->InsertChar(pos, '\\');
- par->SetFont(pos, font);
-#endif
++pos;
}else if (token == "\\the_end") {
the_end_read = true;
"Inserting as text.");
for(string::const_iterator cit = token.begin();
cit != token.end(); ++cit) {
-#ifdef NEW_WAY
par->InsertChar(pos, (*cit), font);
-#else
- par->InsertChar(pos, (*cit));
- par->SetFont(pos, font);
-#endif
++pos;
}
}
{
// insert an error marker in text
InsetError * new_inset = new InsetError(message);
-#ifdef NEW_WAY
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
if ((minibuffer_char == LyXParagraph::META_INSET) &&
!InsertInsetAllowed(minibuffer_inset))
return false;
-#ifdef NEW_WAY
if (minibuffer_char == LyXParagraph::META_INSET)
InsertInset(pos, minibuffer_inset, minibuffer_font);
else
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;
}
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);
InsertChar(pos, c, f);
-#endif
}
-#ifdef NEW_WAY
void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
char c, LyXFont const & font)
{
SetFont(pos, font);
}
-#endif
void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
Inset * inset)
{
-#ifdef NEW_WAY
LyXFont f(LyXFont::ALL_INHERIT);
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,
Inset * inset, LyXFont const & font)
{
if (inset_owner)
inset->setOwner(inset_owner);
}
-#endif
bool LyXParagraph::InsertInsetAllowed(Inset * inset)
SetUndo(bview->buffer(), Undo::INSERT,
cursor.par()->ParFromPos(cursor.pos())->previous,
cursor.par()->ParFromPos(cursor.pos())->next);
-#ifdef NEW_WAY
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.
* The character will not be inserted a
* second time */
// Insert the new string
for (int i = 0; str[i]; ++i) {
-#ifdef NEW_WAY
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;
}
if (str[i] == ' '
&& i + 1 < str.length() && str[i + 1] != ' '
&& pos && par->GetChar(pos - 1)!= ' ') {
-#ifdef NEW_WAY
par->InsertChar(pos, ' ', current_font);
-#else
- par->InsertChar(pos,' ');
- par->SetFont(pos, current_font);
-#endif
++pos;
#ifndef NEW_TABLAR
} else if (par->table) {
break;
} else if ((str[i] != 13) &&
((str[i] & 127) >= ' ')) {
-#ifdef NEW_WAY
par->InsertChar(pos, str[i],
current_font);
-#else
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
-#endif
++pos;
}
#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
-#ifdef NEW_WAY
par->InsertInset(pos, new_inset,
current_font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
-#endif
} else {
delete new_inset;
}
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
-#ifdef NEW_WAY
par->InsertInset(pos, new_inset,
current_font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
-#endif
} else {
delete new_inset;
}
} else if (str[i] != 13 &&
// Ignore unprintables
(str[i] & 127) >= ' ') {
-#ifdef NEW_WAY
par->InsertChar(pos, str[i], current_font);
-#else
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
-#endif
++pos;
}
} else {
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
-#ifdef NEW_WAY
par->InsertInset(pos,
new_inset,
current_font);
-#else
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
-#endif
} else {
delete new_inset;
}