X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbuffer.C;h=c42098707bacd16f6a317ccef77d38358371ece2;hb=a393cfc37c978985f534f9f00bdbbcfed07b3731;hp=02af8ca44ffb8598d3e5c1e3d02c9f752cb73feb;hpb=d1b90146494561edc89497bb1037efd6065f2c51;p=lyx.git
diff --git a/src/buffer.C b/src/buffer.C
index 02af8ca44f..c42098707b 100644
--- a/src/buffer.C
+++ b/src/buffer.C
@@ -4,9 +4,9 @@
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
- * This file is Copyright 1996-1999
+ * This file is Copyright 1996-2001
* Lars Gullik Bjønnes
*
* ======================================================
@@ -14,26 +14,8 @@
#include
-#include
-#include
-#include
";
@@ -2567,14 +2740,14 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT:
- if (depth == par->params.depth()
+ if (depth == par->params().depth()
&& environment_stack[depth] != style.latexname()) {
sgmlCloseTag(ofs, depth,
environment_stack[depth]);
environment_stack[depth].erase();
}
- if (depth < par->params.depth()) {
- depth = par->params.depth();
+ if (depth < par->params().depth()) {
+ depth = par->params().depth();
environment_stack[depth].erase();
}
if (environment_stack[depth] != style.latexname()) {
@@ -2605,19 +2778,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
break;
}
-#ifndef NEW_INSETS
- do {
- SimpleLinuxDocOnePar(ofs, par, depth);
-
- par = par->next_;
- linuxDocHandleFootnote(ofs, par, depth);
- }
- while(par && par->IsDummy());
-#else
- SimpleLinuxDocOnePar(ofs, par, depth);
+ simpleLinuxDocOnePar(ofs, par, depth);
par = par->next();
-#endif
ofs << "\n";
// write closing SGML tags
@@ -2649,158 +2812,11 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
}
-#ifndef NEW_INSETS
-void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par,
- int depth)
-{
- string const tag = "footnote";
-
- while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- sgmlOpenTag(os, depth + 1, tag);
- SimpleLinuxDocOnePar(os, par, 0, depth + 1);
- sgmlCloseTag(os, depth + 1, tag);
- par = par->next_;
- }
-}
-#endif
-
-
-void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
- int depth, int desc_on,
- LyXParagraph * & par)
-{
- LyXParagraph * tpar = par;
-#ifndef NEW_INSETS
- while (tpar
- && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE)
- && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
- "Caption").second))
- tpar = tpar->next_;
-#else
- while (tpar
- && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
- "Caption").second))
- tpar = tpar->next();
-#endif
- if (tpar &&
- tpar->layout == textclasslist.NumberOfLayout(params.textclass,
- "Caption").second) {
- sgmlOpenTag(os, depth + 1, inner_tag);
- string extra_par;
- SimpleDocBookOnePar(os, extra_par, tpar,
- desc_on, depth + 2);
- sgmlCloseTag(os, depth+1, inner_tag);
- if (!extra_par.empty())
- os << extra_par;
- }
-}
-
-
-#ifndef NEW_INSETS
-void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
- int depth)
-{
- string tag, inner_tag;
- string tmp_par, extra_par;
- bool inner_span = false;
- int desc_on = 4;
-
- // Someone should give this enum a proper name (Lgb)
- enum SOME_ENUM {
- NO_ONE,
- FOOTNOTE_LIKE,
- MARGIN_LIKE,
- FIG_LIKE,
- TAB_LIKE
- };
- SOME_ENUM last = NO_ONE;
- SOME_ENUM present = FOOTNOTE_LIKE;
-
- while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- if (last == present) {
- if (inner_span) {
- if (!tmp_par.empty()) {
- os << tmp_par;
- tmp_par.erase();
- sgmlCloseTag(os, depth + 1, inner_tag);
- sgmlOpenTag(os, depth + 1, inner_tag);
- }
- } else {
- os << "\n";
- }
- } else {
- os << tmp_par;
- if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
- inner_tag);
- if (!extra_par.empty()) os << extra_par;
- if (!tag.empty()) sgmlCloseTag(os, depth, tag);
- extra_par.erase();
-
- switch (par->footnotekind) {
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::ALGORITHM:
- tag = "footnote";
- inner_tag = "para";
- present = FOOTNOTE_LIKE;
- inner_span = true;
- break;
- case LyXParagraph::MARGIN:
- tag = "sidebar";
- inner_tag = "para";
- present = MARGIN_LIKE;
- inner_span = true;
- break;
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- tag = "figure";
- inner_tag = "title";
- present = FIG_LIKE;
- inner_span = false;
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- tag = "table";
- inner_tag = "title";
- present = TAB_LIKE;
- inner_span = false;
- break;
- }
- sgmlOpenTag(os, depth, tag);
- if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
- DocBookHandleCaption(os, inner_tag, depth,
- desc_on, par);
- inner_tag.erase();
- } else {
- sgmlOpenTag(os, depth + 1, inner_tag);
- }
- }
- // ignore all caption here, we processed them above!!!
- if (par->layout != textclasslist
- .NumberOfLayout(params.textclass,
- "Caption").second) {
- std::ostringstream ost;
- SimpleDocBookOnePar(ost, extra_par, par,
- desc_on, depth + 2);
- tmp_par += ost.str().c_str();
- }
- tmp_par = frontStrip(strip(tmp_par));
-
- last = present;
- par = par->next_;
- }
- os << tmp_par;
- if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag);
- if (!extra_par.empty()) os << extra_par;
- if (!tag.empty()) sgmlCloseTag(os, depth, tag);
-}
-#endif
-
-
// checks, if newcol chars should be put into this line
// writes newline, if necessary.
namespace {
-void linux_doc_line_break(ostream & os, string::size_type & colcount,
+void sgmlLineBreak(ostream & os, string::size_type & colcount,
string::size_type newcol)
{
colcount += newcol;
@@ -2845,21 +2861,20 @@ void operator|=(PAR_TAG & p1, PAR_TAG const & p2)
inline
void reset(PAR_TAG & p1, PAR_TAG const & p2)
{
- p1 = static_cast( p1 & ~p2);
+ p1 = static_cast(p1 & ~p2);
}
} // namespace anon
-
-
// Handle internal paragraph parsing -- layout already processed.
-void Buffer::SimpleLinuxDocOnePar(ostream & os,
- LyXParagraph * par, int /*depth*/)
+void Buffer::simpleLinuxDocOnePar(ostream & os,
+ Paragraph * par,
+ Paragraph::depth_type /*depth*/)
{
LyXLayout const & style = textclasslist.Style(params.textclass,
- par->GetLayout());
- string::size_type char_line_count = 5; // Heuristic choice ;-)
+ par->getLayout());
+ string::size_type char_line_count = 5; // Heuristic choice ;-)
// gets paragraph main font
LyXFont font_old;
@@ -2877,9 +2892,9 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os,
LyXFont::FONT_SHAPE shape_type = LyXFont::UP_SHAPE;
bool is_em = false;
- stack < PAR_TAG > tag_state;
+ stack tag_state;
// parsing main loop
- for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
+ for (pos_type i = 0; i < par->size(); ++i) {
PAR_TAG tag_close = NONE;
list < PAR_TAG > tag_open;
@@ -2971,7 +2986,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os,
}
list < PAR_TAG > temp;
- while(!tag_state.empty() && tag_close ) {
+ while (!tag_state.empty() && tag_close) {
PAR_TAG k = tag_state.top();
tag_state.pop();
os << "" << tag_name(k) << ">";
@@ -2993,34 +3008,35 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os,
os << "<" << tag_name(*j) << ">";
}
- char c = par->GetChar(i);
+ char c = par->getChar(i);
- if (c == LyXParagraph::META_INSET) {
- Inset * inset = par->GetInset(i);
- inset->Linuxdoc(this, os);
+ if (c == Paragraph::META_INSET) {
+ Inset * inset = par->getInset(i);
+ inset->linuxdoc(this, os);
font_old = font;
continue;
}
- if (font.latex() == LyXFont::ON || style.latexparam() == "CDATA") {
+ if (style.latexparam() == "CDATA") {
// "TeX"-Mode on == > SGML-Mode on.
if (c != '\0')
os << c;
++char_line_count;
} else {
string sgml_string;
- if (par->linuxDocConvertChar(c, sgml_string)
- && !style.free_spacing) {
+ if (par->sgmlConvertChar(c, sgml_string)
+ && !style.free_spacing && !par->isFreeSpacing())
+ {
// in freespacing mode, spaces are
// non-breaking characters
if (desc_on) {// if char is ' ' then...
++char_line_count;
- linux_doc_line_break(os, char_line_count, 6);
+ sgmlLineBreak(os, char_line_count, 6);
os << "";
desc_on = false;
} else {
- linux_doc_line_break(os, char_line_count, 1);
+ sgmlLineBreak(os, char_line_count, 1);
os << c;
}
} else {
@@ -3039,19 +3055,20 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os,
// resets description flag correctly
if (desc_on) {
// not closed...
- linux_doc_line_break(os, char_line_count, 6);
+ sgmlLineBreak(os, char_line_count, 6);
os << "";
}
}
// Print an error message.
-void Buffer::LinuxDocError(LyXParagraph * par, int pos,
- string const & message)
+void Buffer::sgmlError(Paragraph * par, int pos,
+ string const & message) const
{
// insert an error marker in text
InsetError * new_inset = new InsetError(message);
- par->InsertInset(pos, new_inset);
+ par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT,
+ params.language));
}
@@ -3059,11 +3076,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
{
ofstream ofs(fname.c_str());
if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
+ Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
- LyXParagraph * par = paragraph;
+ Paragraph * par = paragraph;
niceFile = nice; // this will be used by Insetincludes.
@@ -3078,16 +3095,17 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
string top_element = textclasslist.LatexnameOfClass(params.textclass);
if (!only_body) {
- string sgml_includedfiles = features.getIncludedFiles(fname);
+ ofs << "\n\n";
- else
- ofs << "\n [ " << params.preamble
- << sgml_includedfiles << " \n]>\n\n";
+ if (!preamble.empty()) {
+ ofs << "\n [ " << preamble << " ]";
+ }
+ ofs << ">\n\n";
}
string top = top_element;
@@ -3101,7 +3119,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
sgmlOpenTag(ofs, 0, top);
- ofs << "\n";
vector environment_stack(10);
@@ -3109,10 +3127,10 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
vector command_stack(10);
bool command_flag = false;
- int command_depth = 0;
- int command_base = 0;
- int cmd_depth = 0;
- int depth = 0; // paragraph depth
+ Paragraph::depth_type command_depth = 0;
+ Paragraph::depth_type command_base = 0;
+ Paragraph::depth_type cmd_depth = 0;
+ Paragraph::depth_type depth = 0; // paragraph depth
string item_name;
string command_name;
@@ -3128,7 +3146,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
par->layout);
// environment tag closing
- for (; depth > par->params.depth(); --depth) {
+ for (; depth > par->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth,
@@ -3143,7 +3161,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
environment_inner[depth].erase();
}
- if (depth == par->params.depth()
+ if (depth == par->params().depth()
&& environment_stack[depth] != style.latexname()
&& !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
@@ -3172,9 +3190,9 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
case LATEX_COMMAND:
if (depth != 0)
- LinuxDocError(par, 0,
- _("Error : Wrong depth for "
- "LatexType Command.\n"));
+ sgmlError(par, 0,
+ _("Error : Wrong depth for "
+ "LatexType Command.\n"));
command_name = style.latexname();
@@ -3185,11 +3203,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (command_flag) {
if (cmd_depth < command_base) {
- for (int j = command_depth; j >= command_base; --j)
+ for (Paragraph::depth_type j = command_depth; j >= command_base; --j)
sgmlCloseTag(ofs, j, command_stack[j]);
command_depth = command_base = cmd_depth;
} else if (cmd_depth <= command_depth) {
- for (int j = command_depth; j >= cmd_depth; --j)
+ for (int j = command_depth; j >= int(cmd_depth); --j)
sgmlCloseTag(ofs, j, command_stack[j]);
command_depth = cmd_depth;
} else
@@ -3199,15 +3217,17 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
command_flag = true;
}
if (command_stack.size() == command_depth + 1)
- command_stack.push_back("");
+ command_stack.push_back(string());
command_stack[command_depth] = command_name;
// treat label as a special case for
// more WYSIWYM handling.
- if (par->GetChar(0) == LyXParagraph::META_INSET) {
- Inset * inset = par->GetInset(0);
- Inset::Code lyx_code = inset->LyxCode();
- if (lyx_code == Inset::LABEL_CODE){
+ // This is a hack while paragraphs can't have
+ // attributes, like id in this case.
+ if (par->isInset(0)) {
+ Inset * inset = par->getInset(0);
+ Inset::Code lyx_code = inset->lyxCode();
+ if (lyx_code == Inset::LABEL_CODE) {
command_name += " id=\"";
command_name += (static_cast(inset))->getContents();
command_name += "\"";
@@ -3225,13 +3245,13 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT:
- if (depth < par->params.depth()) {
- depth = par->params.depth();
+ if (depth < par->params().depth()) {
+ depth = par->params().depth();
environment_stack[depth].erase();
}
if (environment_stack[depth] != style.latexname()) {
- if(environment_stack.size() == depth + 1) {
+ if (environment_stack.size() == depth + 1) {
environment_stack.push_back("!-- --");
environment_inner.push_back("!-- --");
}
@@ -3254,7 +3274,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (style.latextype == LATEX_ENVIRONMENT) {
if (!style.latexparam().empty()) {
- if(style.latexparam() == "CDATA")
+ if (style.latexparam() == "CDATA")
ofs << "next_;
- DocBookHandleFootnote(ofs, par,
- depth + 1 + command_depth);
- } while(par && par->IsDummy());
-#else
- string extra_par;
- SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
- depth + 1 + command_depth);
+ simpleDocBookOnePar(ofs, par, desc_on, depth+1+command_depth);
par = par->next();
-#endif
+
string end_tag;
// write closing SGML tags
switch (style.latextype) {
@@ -3316,7 +3324,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
break;
case LATEX_ENVIRONMENT:
if (!style.latexparam().empty()) {
- if(style.latexparam() == "CDATA")
+ if (style.latexparam() == "CDATA")
ofs << "]]>";
else
sgmlCloseTag(ofs, depth + command_depth,
@@ -3338,7 +3346,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
// Close open tags
- for (; depth >= 0; --depth) {
+ for (int d = depth; d >= 0; --d) {
if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
@@ -3354,7 +3362,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
}
- for (int j = command_depth; j >= command_base; --j)
+ for (int j = command_depth; j >= 0 ; --j)
if (!command_stack[j].empty())
sgmlCloseTag(ofs, j, command_stack[j]);
@@ -3366,24 +3374,23 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
-void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
- LyXParagraph * par, int & desc_on,
- int depth) const
+void Buffer::simpleDocBookOnePar(ostream & os,
+ Paragraph * par, int & desc_on,
+ Paragraph::depth_type depth) const
{
bool emph_flag = false;
LyXLayout const & style = textclasslist.Style(params.textclass,
- par->GetLayout());
+ par->getLayout());
LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
int char_line_count = depth;
- if (!style.free_spacing)
- os << string(depth,' ');
+ //if (!style.free_spacing)
+ // os << string(depth,' ');
// parsing main loop
- for (LyXParagraph::size_type i = 0;
- i < par->size(); ++i) {
+ for (pos_type i = 0; i < par->size(); ++i) {
LyXFont font = par->getFont(params, i);
// handle tag
@@ -3391,61 +3398,33 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
if (font.emph() == LyXFont::ON) {
os << "";
emph_flag = true;
- }else if(i) {
+ } else if (i) {
os << "";
emph_flag = false;
}
}
- char c = par->GetChar(i);
- if (c == LyXParagraph::META_INSET) {
- Inset * inset = par->GetInset(i);
- std::ostringstream ost;
- inset->DocBook(this, ost);
- string tmp_out = ost.str().c_str();
-
- //
- // This code needs some explanation:
- // Two insets are treated specially
- // label if it is the first element in a command paragraph
- // desc_on == 3
- // graphics inside tables or figure floats can't go on
- // title (the equivalente in latex for this case is caption
- // and title should come first
- // desc_on == 4
- //
- if (desc_on!= 3 || i!= 0) {
- if (!tmp_out.empty() && tmp_out[0] == '@') {
- if (desc_on == 4)
- extra += frontStrip(tmp_out, '@');
- else
- os << frontStrip(tmp_out, '@');
- }
- else
- os << tmp_out;
- }
- } else if (font.latex() == LyXFont::ON) {
- // "TeX"-Mode on ==> SGML-Mode on.
- if (c != '\0')
- os << c;
- ++char_line_count;
+ if (par->isInset(i)) {
+ Inset * inset = par->getInset(i);
+ // don't print the inset in position 0 if desc_on == 3 (label)
+ if (i || desc_on != 3)
+ inset->docbook(this, os);
} else {
+ char c = par->getChar(i);
string sgml_string;
- if (par->linuxDocConvertChar(c, sgml_string)
- && !style.free_spacing) { // in freespacing
- // mode, spaces are
- // non-breaking characters
- // char is ' '
- if (desc_on == 1) {
- ++char_line_count;
- os << "\n";
- desc_on = 2;
- } else {
- os << c;
- }
+ par->sgmlConvertChar(c, sgml_string);
+
+ if (style.pass_thru) {
+ os << c;
+ } else if (style.free_spacing || par->isFreeSpacing() || c != ' ') {
+ os << sgml_string;
+ } else if (desc_on ==1) {
+ ++char_line_count;
+ os << "\n";
+ desc_on = 2;
} else {
- os << sgml_string;
+ os << ' ';
}
}
font_old = font;
@@ -3460,7 +3439,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
// not closed...
os << "";
}
- os << '\n';
+ if (style.free_spacing) os << '\n';
}
@@ -3471,19 +3450,19 @@ int Buffer::runChktex()
{
if (!users->text) return 0;
- ProhibitInput(users);
+ users->owner()->prohibitInput();
// get LaTeX-Filename
string const name = getLatexName();
- string path = OnlyPath(filename);
+ string path = filePath();
string const org_path = path;
- if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
path = tmppath;
}
Path p(path); // path to LaTeX file
- users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
+ users->owner()->message(_("Running chktex..."));
// Remove all error insets
bool const removedErrorInsets = users->removeAutoInsets();
@@ -3492,11 +3471,11 @@ int Buffer::runChktex()
makeLaTeXFile(name, org_path, false);
TeXErrors terr;
- Chktex chktex(lyxrc.chktex_command, name, filepath);
+ Chktex chktex(lyxrc.chktex_command, name, filePath());
int res = chktex.run(terr); // run chktex
if (res == -1) {
- WriteAlert(_("chktex did not work!"),
+ Alert::alert(_("chktex did not work!"),
_("Could not run with file:"), name);
} else if (res > 0) {
// Insert all errors as errors boxes
@@ -3505,11 +3484,11 @@ int Buffer::runChktex()
// if we removed error insets before we ran chktex or if we inserted
// error insets after we ran chktex, this must be run:
- if (removedErrorInsets || res){
+ if (removedErrorInsets || res) {
users->redraw();
- users->fitCursor(users->text);
+ users->fitCursor();
}
- AllowInput(users);
+ users->owner()->allowInput();
return res;
}
@@ -3517,14 +3496,13 @@ int Buffer::runChktex()
void Buffer::validate(LaTeXFeatures & features) const
{
- LyXParagraph * par = paragraph;
+ Paragraph * par = paragraph;
LyXTextClass const & tclass =
textclasslist.TextClass(params.textclass);
// AMS Style is at document level
-
- features.amsstyle = (params.use_amsmath ||
- tclass.provides(LyXTextClass::amsmath));
+ if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
+ features.require("amsmath");
while (par) {
// We don't use "lyxerr.debug" because of speed. (Asger)
@@ -3536,11 +3514,7 @@ void Buffer::validate(LaTeXFeatures & features) const
par->validate(features);
// and then the next paragraph
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
// the bullet shapes are buffer level not paragraph level
@@ -3557,12 +3531,12 @@ void Buffer::validate(LaTeXFeatures & features) const
|| c == 25
|| c == 26
|| c == 31) {
- features.latexsym = true;
+ features.require("latexsym");
}
} else if (font == 1) {
- features.amssymb = true;
+ features.require("amssymb");
} else if ((font >= 2 && font <= 5)) {
- features.pifont = true;
+ features.require("pifont");
}
}
}
@@ -3573,40 +3547,13 @@ void Buffer::validate(LaTeXFeatures & features) const
}
-void Buffer::setPaperStuff()
-{
- params.papersize = BufferParams::PAPER_DEFAULT;
- char const c1 = params.paperpackage;
- if (c1 == BufferParams::PACKAGE_NONE) {
- char const c2 = params.papersize2;
- if (c2 == BufferParams::VM_PAPER_USLETTER)
- params.papersize = BufferParams::PAPER_USLETTER;
- else if (c2 == BufferParams::VM_PAPER_USLEGAL)
- params.papersize = BufferParams::PAPER_LEGALPAPER;
- else if (c2 == BufferParams::VM_PAPER_USEXECUTIVE)
- params.papersize = BufferParams::PAPER_EXECUTIVEPAPER;
- else if (c2 == BufferParams::VM_PAPER_A3)
- params.papersize = BufferParams::PAPER_A3PAPER;
- else if (c2 == BufferParams::VM_PAPER_A4)
- params.papersize = BufferParams::PAPER_A4PAPER;
- else if (c2 == BufferParams::VM_PAPER_A5)
- params.papersize = BufferParams::PAPER_A5PAPER;
- else if ((c2 == BufferParams::VM_PAPER_B3) || (c2 == BufferParams::VM_PAPER_B4) ||
- (c2 == BufferParams::VM_PAPER_B5))
- params.papersize = BufferParams::PAPER_B5PAPER;
- } else if ((c1 == BufferParams::PACKAGE_A4) || (c1 == BufferParams::PACKAGE_A4WIDE) ||
- (c1 == BufferParams::PACKAGE_WIDEMARGINSA4))
- params.papersize = BufferParams::PAPER_A4PAPER;
-}
-
-
// This function should be in Buffer because it's a buffer's property (ale)
string const Buffer::getIncludeonlyList(char delim)
{
string lst;
for (inset_iterator it = inset_iterator_begin();
it != inset_iterator_end(); ++it) {
- if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
+ if ((*it)->lyxCode() == Inset::INCLUDE_CODE) {
InsetInclude * insetinc =
static_cast(*it);
if (insetinc->isIncludeOnly()) {
@@ -3616,7 +3563,7 @@ string const Buffer::getIncludeonlyList(char delim)
}
}
}
- lyxerr.debug() << "Includeonly(" << lst << ')' << endl;
+ lyxerr[Debug::INFO] << "Includeonly(" << lst << ')' << endl;
return lst;
}
@@ -3645,102 +3592,73 @@ vector const Buffer::getLabelList()
Buffer::Lists const Buffer::getLists() const
{
Lists l;
- LyXParagraph * par = paragraph;
-#ifdef NEW_INSETS
+ Paragraph * par = paragraph;
+
+#if 1
+ std::pair const tmp =
+ textclasslist.NumberOfLayout(params.textclass, "Caption");
+ bool const found = tmp.first;
+ textclass_type const cap = tmp.second;
+
+#else
+ // This is the prefered way to to this, but boost::tie can break
+ // some compilers
bool found;
- LyXTextClassList::size_type cap;
+ textclass_type cap;
boost::tie(found, cap) = textclasslist
.NumberOfLayout(params.textclass, "Caption");
#endif
while (par) {
-#ifndef NEW_INSETS
- if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- if (textclasslist.Style(params.textclass,
- par->GetLayout()).labeltype
- == LABEL_SENSITIVE) {
- string type;
- switch (par->footnotekind) {
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- type = "LOF";
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- type = "LOT";
- break;
- case LyXParagraph::ALGORITHM:
- type = "LOA";
- break;
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::MARGIN:
- break;
- }
- if (!type.empty()) {
- SingleList & item = l[type];
- string const str =
- tostr(item.size()+1) + ". " + par->String(this, false);
- item.push_back(TocItem(par, 0, str));
- }
- }
- } else if (!par->IsDummy()) {
-#endif
- char const labeltype =
- textclasslist.Style(params.textclass,
- par->GetLayout()).labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
+ char const labeltype =
+ textclasslist.Style(params.textclass,
+ par->getLayout()).labeltype;
+
+ if (labeltype >= LABEL_COUNTER_CHAPTER
+ && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
// insert this into the table of contents
- SingleList & item = l["TOC"];
- int depth = max(0,
- labeltype -
- textclasslist.TextClass(params.textclass).maxcounter());
- item.push_back(TocItem(par, depth, par->String(this, true)));
- }
-#ifdef NEW_INSETS
- // For each paragrph, traverse its insets and look for
- // FLOAT_CODE
+ SingleList & item = l["TOC"];
+ int depth = max(0,
+ labeltype -
+ textclasslist.TextClass(params.textclass).maxcounter());
+ item.push_back(TocItem(par, depth, par->asString(this, true)));
+ }
+ // For each paragrph, traverse its insets and look for
+ // FLOAT_CODE
+
+ if (found) {
+ Paragraph::inset_iterator it =
+ par->inset_iterator_begin();
+ Paragraph::inset_iterator end =
+ par->inset_iterator_end();
- if (found) {
- LyXParagraph::inset_iterator it =
- par->inset_iterator_begin();
- LyXParagraph::inset_iterator end =
- par->inset_iterator_end();
-
- for (; it != end; ++it) {
- if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
- InsetFloat * il =
- static_cast(*it);
-
- string const type = il->type();
-
- // Now find the caption in the float...
- // We now tranverse the paragraphs of
- // the inset...
- LyXParagraph * tmp = il->inset.par;
- while (tmp) {
- if (tmp->layout == cap) {
- SingleList & item = l[type];
- string const str =
- tostr(item.size()+1) + ". " + tmp->String(this, false);
- item.push_back(TocItem(tmp, 0 , str));
- }
- tmp = tmp->next();
+ for (; it != end; ++it) {
+ if ((*it)->lyxCode() == Inset::FLOAT_CODE) {
+ InsetFloat * il =
+ static_cast(*it);
+
+ string const type = il->type();
+
+ // Now find the caption in the float...
+ // We now tranverse the paragraphs of
+ // the inset...
+ Paragraph * tmp = il->inset.paragraph();
+ while (tmp) {
+ if (tmp->layout == cap) {
+ SingleList & item = l[type];
+ string const str =
+ tostr(item.size()+1) + ". " + tmp->asString(this, false);
+ item.push_back(TocItem(tmp, 0 , str));
}
+ tmp = tmp->next();
}
}
- } else {
- lyxerr << "caption not found" << endl;
}
-
-#endif
-#ifndef NEW_INSETS
+ } else {
+ lyxerr << "caption not found" << endl;
}
- par = par->next_;
-#else
+
par = par->next();
-#endif
}
return l;
}
@@ -3758,16 +3676,12 @@ vector > const Buffer::getBibkeyList()
}
vector > keys;
- LyXParagraph * par = paragraph;
+ Paragraph * par = paragraph;
while (par) {
if (par->bibkey)
keys.push_back(pair(par->bibkey->getContents(),
- par->String(this, false)));
-#ifndef NEW_INSETS
- par = par->next_;
-#else
+ par->asString(this, false)));
par = par->next();
-#endif
}
// Might be either using bibtex or a child has bibliography
@@ -3775,11 +3689,11 @@ vector > const Buffer::getBibkeyList()
for (inset_iterator it = inset_iterator_begin();
it != inset_iterator_end(); ++it) {
// Search for Bibtex or Include inset
- if ((*it)->LyxCode() == Inset::BIBTEX_CODE) {
+ if ((*it)->lyxCode() == Inset::BIBTEX_CODE) {
vector > tmp =
static_cast(*it)->getKeys(this);
keys.insert(keys.end(), tmp.begin(), tmp.end());
- } else if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
+ } else if ((*it)->lyxCode() == Inset::INCLUDE_CODE) {
vector > const tmp =
static_cast(*it)->getKeys();
keys.insert(keys.end(), tmp.begin(), tmp.end());
@@ -3824,18 +3738,18 @@ void Buffer::markDepClean(string const & name)
}
-bool Buffer::Dispatch(string const & command)
+bool Buffer::dispatch(string const & command)
{
// Split command string into command and argument
string cmd;
string line = frontStrip(command);
string const arg = strip(frontStrip(split(line, cmd, ' ')));
- return Dispatch(lyxaction.LookupFunc(cmd), arg);
+ return dispatch(lyxaction.LookupFunc(cmd), arg);
}
-bool Buffer::Dispatch(int action, string const & argument)
+bool Buffer::dispatch(int action, string const & argument)
{
bool dispatched = true;
switch (action) {
@@ -3850,89 +3764,107 @@ bool Buffer::Dispatch(int action, string const & argument)
}
-void Buffer::resize()
-{
- /// resize the BufferViews!
- if (users)
- users->resize();
-}
-
-
void Buffer::resizeInsets(BufferView * bv)
{
/// then remove all LyXText in text-insets
- LyXParagraph * par = paragraph;
-#ifndef NEW_INSETS
- for (; par; par = par->next_) {
- par->resizeInsetsLyXText(bv);
- }
-#else
+ Paragraph * par = paragraph;
for (; par; par = par->next()) {
par->resizeInsetsLyXText(bv);
}
-#endif
}
-void Buffer::ChangeLanguage(Language const * from, Language const * to)
+void Buffer::redraw()
{
+ users->redraw();
+ users->fitCursor();
+}
- LyXParagraph * par = paragraph;
- while (par) {
- par->ChangeLanguage(params, from, to);
-#ifndef NEW_INSETS
- par = par->next_;
-#else
- par = par->next();
-#endif
- }
+
+void Buffer::changeLanguage(Language const * from, Language const * to)
+{
+
+ ParIterator end = par_iterator_end();
+ for (ParIterator it = par_iterator_begin(); it != end; ++it)
+ (*it)->changeLanguage(params, from, to);
}
bool Buffer::isMultiLingual()
{
- LyXParagraph * par = paragraph;
- while (par) {
- if (par->isMultiLingual(params))
+ ParIterator end = par_iterator_end();
+ for (ParIterator it = par_iterator_begin(); it != end; ++it)
+ if ((*it)->isMultiLingual(params))
return true;
-#ifndef NEW_INSETS
- par = par->next_;
-#else
- par = par->next();
-#endif
- }
+
return false;
}
-Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph,
- LyXParagraph::size_type pos)
+Buffer::inset_iterator::inset_iterator(Paragraph * paragraph, pos_type pos)
: par(paragraph)
{
it = par->InsetIterator(pos);
if (it == par->inset_iterator_end()) {
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
- SetParagraph();
+ setParagraph();
}
}
-void Buffer::inset_iterator::SetParagraph()
+void Buffer::inset_iterator::setParagraph()
{
while (par) {
it = par->inset_iterator_begin();
if (it != par->inset_iterator_end())
return;
-#ifndef NEW_INSETS
- par = par->next_;
-#else
par = par->next();
-#endif
}
//it = 0;
// We maintain an invariant that whenever par = 0 then it = 0
}
+
+
+Inset * Buffer::getInsetFromID(int id_arg) const
+{
+ for (inset_iterator it = inset_const_iterator_begin();
+ it != inset_const_iterator_end(); ++it)
+ {
+ if ((*it)->id() == id_arg)
+ return *it;
+ Inset * in = (*it)->getInsetFromID(id_arg);
+ if (in)
+ return in;
+ }
+ return 0;
+}
+
+
+Paragraph * Buffer::getParFromID(int id) const
+{
+ if (id < 0) return 0;
+ Paragraph * par = paragraph;
+ while (par) {
+ if (par->id() == id) {
+ return par;
+ }
+ Paragraph * tmp = par->getParFromID(id);
+ if (tmp) {
+ return tmp;
+ }
+ par = par->next();
+ }
+ return 0;
+}
+
+
+ParIterator Buffer::par_iterator_begin()
+{
+ return ParIterator(paragraph);
+}
+
+
+ParIterator Buffer::par_iterator_end()
+{
+ return ParIterator();
+}