X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbuffer.C;h=67d895c460b4c7c1058202fdde62755e360440dd;hb=32ef0d04c48a1751abbb5e3b17d1bec25f22c255;hp=152f7de180b9a29babbcf5eaaa0ab1dc60c33e76;hpb=adaef99e60e28eba8c413a3472cc71e234718af0;p=lyx.git
diff --git a/src/buffer.C b/src/buffer.C
index 152f7de180..67d895c460 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
*
* ======================================================
@@ -16,8 +16,12 @@
#include
#include
+#include
");
- break;
}
}
// Print an error message.
-void Buffer::LinuxDocError(LyXParagraph * par, int pos,
+void Buffer::linuxDocError(Paragraph * par, int pos,
string const & message)
{
// insert an error marker in text
InsetError * new_inset = new InsetError(message);
- par->InsertInset(pos, new_inset);
+ par->insertInset(pos, new_inset);
}
-// This constant defines the maximum number of
-// environment layouts that can be nesteded.
-// The same applies for command layouts.
-// These values should be more than enough.
-// José Matos (1999/07/22)
-
-enum { MAX_NEST_LEVEL = 25};
void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
{
- LyXParagraph * par = paragraph;
-
- niceFile = nice; // this will be used by Insetincludes.
+ ofstream ofs(fname.c_str());
+ if (!ofs) {
+ WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
+ return;
+ }
- string top_element= textclasslist.LatexnameOfClass(params.textclass);
- // Please use a real stack.
- string environment_stack[MAX_NEST_LEVEL];
- string environment_inner[MAX_NEST_LEVEL];
- // Please use a real stack.
- string command_stack[MAX_NEST_LEVEL];
- bool command_flag= false;
- int command_depth= 0, command_base= 0, cmd_depth= 0;
+ Paragraph * par = paragraph;
- string item_name, command_name;
- string c_depth, c_params, tmps;
+ niceFile = nice; // this will be used by Insetincludes.
- int depth = 0; // paragraph depth
LyXTextClass const & tclass =
textclasslist.TextClass(params.textclass);
LaTeXFeatures features(params, tclass.numLayouts());
validate(features);
-
- //if (nice)
- tex_code_break_column = lyxrc.ascii_linelen;
- //else
- //tex_code_break_column = 0;
-
- ofstream ofs(fname.c_str());
- if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
- return;
- }
texrow.reset();
+ string top_element = textclasslist.LatexnameOfClass(params.textclass);
+
if (!only_body) {
- string sgml_includedfiles=features.getIncludedFiles();
+ string sgml_includedfiles = features.getIncludedFiles(fname);
ofs << "\n\n";
+ }
- if (params.options.empty())
- sgmlOpenTag(ofs, 0, top_element);
- else {
- string top = top_element;
- top += " ";
- top += params.options;
- sgmlOpenTag(ofs, 0, top);
- }
+ string top = top_element;
+ top += " lang=\"";
+ top += params.language->code();
+ top += "\"";
+
+ if (!params.options.empty()) {
+ top += " ";
+ top += params.options;
}
+ sgmlOpenTag(ofs, 0, top);
ofs << "\n";
+ vector environment_stack(10);
+ vector environment_inner(10);
+ vector command_stack(10);
+
+ bool command_flag = false;
+ 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;
+
while (par) {
+ string sgmlparam;
+ string c_depth;
+ string c_params;
int desc_on = 0; // description mode
+
LyXLayout const & style =
textclasslist.Style(params.textclass,
par->layout);
// environment tag closing
- for (; depth > par->depth; --depth) {
+ for (; depth > par->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
- item_name= "listitem";
+ item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth,
item_name);
if (environment_inner[depth] == "varlistentry")
@@ -3046,7 +3090,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
environment_inner[depth].erase();
}
- if (depth == par->depth
+ if (depth == par->params().depth()
&& environment_stack[depth] != style.latexname()
&& !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
@@ -3069,51 +3113,47 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
// Write opening SGML tags.
switch (style.latextype) {
case LATEX_PARAGRAPH:
- if (style.latexname() != "dummy")
- sgmlOpenTag(ofs, depth+command_depth,
- style.latexname());
+ sgmlOpenTag(ofs, depth + command_depth,
+ style.latexname());
break;
case LATEX_COMMAND:
- if (depth!= 0)
- LinuxDocError(par, 0,
+ if (depth != 0)
+ linuxDocError(par, 0,
_("Error : Wrong depth for "
"LatexType Command.\n"));
command_name = style.latexname();
- tmps = style.latexparam();
- c_params = split(tmps, c_depth,'|');
+ sgmlparam = style.latexparam();
+ c_params = split(sgmlparam, c_depth,'|');
- cmd_depth= lyx::atoi(c_depth);
+ cmd_depth = lyx::atoi(c_depth);
if (command_flag) {
- if (cmd_depth= command_base; --j)
- if (!command_stack[j].empty())
- sgmlCloseTag(ofs, j, command_stack[j]);
- command_depth= command_base= cmd_depth;
+ if (cmd_depth < command_base) {
+ 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)
-
- if (!command_stack[j].empty())
- sgmlCloseTag(ofs, j, command_stack[j]);
- command_depth= cmd_depth;
+ for (int j = command_depth; j >= int(cmd_depth); --j)
+ sgmlCloseTag(ofs, j, command_stack[j]);
+ command_depth = cmd_depth;
} else
- command_depth= cmd_depth;
+ command_depth = cmd_depth;
} else {
command_depth = command_base = cmd_depth;
command_flag = true;
}
- command_stack[command_depth]= command_name;
+ if (command_stack.size() == command_depth + 1)
+ 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 (par->getChar(0) == Paragraph::META_INSET) {
+ 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();
@@ -3123,18 +3163,25 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
sgmlOpenTag(ofs, depth + command_depth, command_name);
- item_name = "title";
+ if (c_params.empty())
+ item_name = "title";
+ else
+ item_name = c_params;
sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
break;
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT:
- if (depth < par->depth) {
- depth = par->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) {
+ environment_stack.push_back("!-- --");
+ environment_inner.push_back("!-- --");
+ }
environment_stack[depth] = style.latexname();
environment_inner[depth] = "!-- --";
sgmlOpenTag(ofs, depth + command_depth,
@@ -3153,9 +3200,13 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
}
if (style.latextype == LATEX_ENVIRONMENT) {
- if (!style.latexparam().empty())
- sgmlOpenTag(ofs, depth + command_depth,
- style.latexparam());
+ if (!style.latexparam().empty()) {
+ if(style.latexparam() == "CDATA")
+ ofs << "next;
-#ifndef NEW_INSETS
- DocBookHandleFootnote(ofs, par,
- depth + 1 + command_depth);
- }
- while(par && par->IsDummy());
-#endif
+ string extra_par;
+ simpleDocBookOnePar(ofs, extra_par, par, desc_on,
+ depth + 1 + command_depth);
+ par = par->next();
+
string end_tag;
// write closing SGML tags
switch (style.latextype) {
case LATEX_COMMAND:
- end_tag = "title";
+ if (c_params.empty())
+ end_tag = "title";
+ else
+ end_tag = c_params;
sgmlCloseTag(ofs, depth + command_depth, end_tag);
break;
case LATEX_ENVIRONMENT:
- if (!style.latexparam().empty())
- sgmlCloseTag(ofs, depth + command_depth,
- style.latexparam());
+ if (!style.latexparam().empty()) {
+ if(style.latexparam() == "CDATA")
+ ofs << "]]>";
+ else
+ sgmlCloseTag(ofs, depth + command_depth,
+ style.latexparam());
+ }
break;
case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break;
@@ -3216,22 +3266,19 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag);
break;
case LATEX_PARAGRAPH:
- if (style.latexname() != "dummy")
- sgmlCloseTag(ofs, depth + command_depth,
- style.latexname());
+ sgmlCloseTag(ofs, depth + command_depth, style.latexname());
break;
default:
- sgmlCloseTag(ofs, depth + command_depth,
- style.latexname());
+ sgmlCloseTag(ofs, depth + command_depth, style.latexname());
break;
}
}
// 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";
+ item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth,
item_name);
if (environment_inner[depth] == "varlistentry")
@@ -3244,65 +3291,55 @@ 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]);
- if (!only_body) {
- ofs << "\n\n";
- sgmlCloseTag(ofs, 0, top_element);
- }
+ ofs << "\n\n";
+ sgmlCloseTag(ofs, 0, top_element);
ofs.close();
// How to check for successful close
}
-void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
- LyXParagraph * par, int & desc_on,
- int depth) const
+void Buffer::simpleDocBookOnePar(ostream & os, string & extra,
+ 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());
- LyXParagraph::size_type main_body;
- if (style.labeltype != LABEL_MANUAL)
- main_body = 0;
- else
- main_body = par->BeginningOfMainBody();
+ LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
- // gets paragraph main font
- LyXFont font1 = main_body > 0 ? style.labelfont : style.font;
-
int char_line_count = depth;
- if (!style.free_spacing)
- for (int j = 0; j < depth; ++j)
- os << ' ';
+ //if (!style.free_spacing)
+ // os << string(depth,' ');
// parsing main loop
- for (LyXParagraph::size_type i = 0;
+ for (Paragraph::size_type i = 0;
i < par->size(); ++i) {
- LyXFont font2 = par->getFont(params, i);
+ LyXFont font = par->getFont(params, i);
// handle tag
- if (font1.emph() != font2.emph() && i) {
- if (font2.emph() == LyXFont::ON) {
+ if (font_old.emph() != font.emph()) {
+ if (font.emph() == LyXFont::ON) {
os << "";
emph_flag = true;
- }else {
+ }else if(i) {
os << "";
emph_flag = false;
}
}
- char c = par->GetChar(i);
+ char c = par->getChar(i);
- if (c == LyXParagraph::META_INSET) {
- Inset * inset = par->GetInset(i);
- std::ostringstream ost;
- inset->DocBook(this, ost);
+ if (c == Paragraph::META_INSET) {
+ Inset * inset = par->getInset(i);
+ ostringstream ost;
+ inset->docBook(this, ost);
string tmp_out = ost.str().c_str();
//
@@ -3325,11 +3362,6 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
else
os << tmp_out;
}
- } else if (font2.latex() == LyXFont::ON) {
- // "TeX"-Mode on ==> SGML-Mode on.
- if (c != '\0')
- os << c;
- ++char_line_count;
} else {
string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
@@ -3348,25 +3380,19 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
os << sgml_string;
}
}
- font1 = font2;
+ font_old = font;
}
- // needed if there is an optional argument but no contents
- if (main_body > 0 && main_body == par->size()) {
- font1 = style.font;
- }
if (emph_flag) {
os << "";
}
// resets description flag correctly
- switch (desc_on){
- case 1:
+ if (desc_on == 1) {
// not closed...
os << "";
- break;
}
- os << '\n';
+ if(style.free_spacing) os << '\n';
}
@@ -3377,19 +3403,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 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();
@@ -3413,9 +3439,9 @@ int Buffer::runChktex()
// error insets after we ran chktex, this must be run:
if (removedErrorInsets || res){
users->redraw();
- users->fitCursor(users->text);
+ users->fitCursor();
}
- AllowInput(users);
+ users->owner()->allowInput();
return res;
}
@@ -3423,12 +3449,11 @@ 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));
@@ -3442,7 +3467,7 @@ void Buffer::validate(LaTeXFeatures & features) const
par->validate(features);
// and then the next paragraph
- par = par->next;
+ par = par->next();
}
// the bullet shapes are buffer level not paragraph level
@@ -3508,18 +3533,17 @@ 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->isInclude()
- && insetinc->isNoLoad()) {
+ if (insetinc->isIncludeOnly()) {
if (!lst.empty())
lst += delim;
- lst += OnlyFilename(ChangeExtension(insetinc->getContents(), string()));
+ lst += insetinc->getRelFileBaseName();
}
}
}
- lyxerr.debug() << "Includeonly(" << lst << ')' << endl;
+ lyxerr[Debug::INFO] << "Includeonly(" << lst << ')' << endl;
return lst;
}
@@ -3545,65 +3569,72 @@ vector const Buffer::getLabelList()
}
-vector > const Buffer::getTocList()
+Buffer::Lists const Buffer::getLists() const
{
- vector > l(4);
- LyXParagraph * par = paragraph;
+ Lists l;
+ Paragraph * par = paragraph;
+ bool found;
+ LyXTextClassList::size_type cap;
+ boost::tie(found, cap) = textclasslist
+ .NumberOfLayout(params.textclass, "Caption");
+
while (par) {
-#ifndef NEW_INSETS
- if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
- if (textclasslist.Style(params.textclass,
- par->GetLayout()).labeltype
- == LABEL_SENSITIVE) {
- TocItem tmp;
- tmp.par = par;
- tmp.depth = 0;
- tmp.str = par->String(this, false);
- switch (par->footnotekind) {
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- l[TOC_LOF].push_back(tmp);
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- l[TOC_LOT].push_back(tmp);
- break;
- case LyXParagraph::ALGORITHM:
- l[TOC_LOA].push_back(tmp);
- break;
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::MARGIN:
- break;
- }
- }
- } 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
- TocItem tmp;
- tmp.par = par;
- tmp.depth = max(0,
- labeltype -
- textclasslist.TextClass(params.textclass).maxcounter());
- tmp.str = par->String(this, true);
- l[TOC_TOC].push_back(tmp);
+ 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();
+
+ 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();
+ }
+ }
}
-#ifndef NEW_INSETS
+ } else {
+ lyxerr << "caption not found" << endl;
}
-#endif
- par = par->next;
+
+ par = par->next();
}
return l;
}
// This is also a buffer property (ale)
-vector > const Buffer::getBibkeyList()
+vector > const Buffer::getBibkeyList()
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990412]
@@ -3614,12 +3645,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)));
- par = par->next;
+ par->asString(this, false)));
+ par = par->next();
}
// Might be either using bibtex or a child has bibliography
@@ -3627,11 +3658,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());
@@ -3676,18 +3707,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) {
@@ -3702,66 +3733,99 @@ 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;
- for (; par; par = par->next) {
+ Paragraph * par = paragraph;
+ for (; par; par = par->next()) {
par->resizeInsetsLyXText(bv);
}
}
-void Buffer::ChangeLanguage(Language const * from, Language const * to)
+
+void Buffer::redraw()
+{
+ users->redraw();
+ users->fitCursor();
+}
+
+
+void Buffer::changeLanguage(Language const * from, Language const * to)
{
- LyXParagraph * par = paragraph;
+ Paragraph * par = paragraph;
while (par) {
- par->ChangeLanguage(params, from, to);
- par = par->next;
+ par->changeLanguage(params, from, to);
+ par = par->next();
}
}
bool Buffer::isMultiLingual()
{
- LyXParagraph * par = paragraph;
+ Paragraph * par = paragraph;
while (par) {
if (par->isMultiLingual(params))
return true;
- par = par->next;
+ par = par->next();
}
return false;
}
-Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph,
- LyXParagraph::size_type pos)
+Buffer::inset_iterator::inset_iterator(Paragraph * paragraph,
+ Paragraph::size_type pos)
: par(paragraph)
{
it = par->InsetIterator(pos);
if (it == par->inset_iterator_end()) {
- par = par->next;
- SetParagraph();
+ par = par->next();
+ 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;
- par = par->next;
+ par = par->next();
}
//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;
+}