#include "converter.h"
#include "BufferView.h"
#include "ParagraphParameters.h"
+#include "iterators.h"
using std::ostream;
using std::ofstream;
ErtComp ert_comp;
#endif
-} // anon
-
-
#warning And _why_ is this here? (Lgb)
int unknown_layouts;
+} // anon
+
+
// candidate for move to BufferView
// (at least some parts in the beginning of the func)
//
pos = 0;
if (pp.first) {
par->layout = pp.second;
+#ifndef NO_COMPABILITY
+ } else if (ert_comp.active) {
+ par->layout = 0;
+#endif
} else {
// layout not found
// use default layout "Standard" (0)
if (tmptok == "footnote") {
inset = new InsetFoot;
+ old_float << "collapsed true\n";
} else if (tmptok == "margin") {
inset = new InsetMarginal;
+ old_float << "collapsed true\n";
} else if (tmptok == "fig") {
inset = new InsetFloat("figure");
old_float << "placement htbp\n"
- << "wide false\n";
+ << "wide false\n"
+ << "collapsed false\n";
} else if (tmptok == "tab") {
inset = new InsetFloat("table");
old_float << "placement htbp\n"
- << "wide false\n";
+ << "wide false\n"
+ << "collapsed false\n";
} else if (tmptok == "alg") {
inset = new InsetFloat("algorithm");
old_float << "placement htbp\n"
- << "wide false\n";
+ << "wide false\n"
+ << "collapsed false\n";
} else if (tmptok == "wide-fig") {
inset = new InsetFloat("figure");
//InsetFloat * tmp = new InsetFloat("figure");
//tmp->wide(true);
//inset = tmp;
old_float << "placement htbp\n"
- << "wide true\n";
+ << "wide true\n"
+ << "collapsed false\n";
} else if (tmptok == "wide-tab") {
inset = new InsetFloat("table");
//InsetFloat * tmp = new InsetFloat("table");
//tmp->wide(true);
//inset = tmp;
old_float << "placement htbp\n"
- << "wide true\n";
+ << "wide true\n"
+ << "collapsed false\n";
}
if (!inset) {
#endif
return false; // no end read yet
}
-
- old_float << "collapsed true\n";
// Here we need to check for \end_deeper and handle that
// before we do the footnote parsing.
// needed to insert the selection
void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
- LyXFont const & font,
- string const & str) const
+ LyXFont const & fn,string const & str) const
{
LyXLayout const & layout = textclasslist.Style(params.textclass,
- par->getLayout());
+ par->getLayout());
+ LyXFont font = fn;
+
+ (void)par->checkInsertChar(font);
// insert the string, don't insert doublespace
bool space_inserted = true;
for(string::const_iterator cit = str.begin();
if (*cit == '\n') {
if (par->size() || layout.keepempty) {
par->breakParagraph(params, pos,
- layout.isEnvironment());
+ layout.isEnvironment());
par = par->next();
pos = 0;
space_inserted = true;
continue;
}
// do not insert consecutive spaces if !free_spacing
- } else if ((*cit == ' ' || *cit == '\t')
- && space_inserted && !layout.free_spacing) {
+ } else if ((*cit == ' ' || *cit == '\t') &&
+ space_inserted && !layout.free_spacing)
+ {
continue;
} else if (*cit == '\t') {
if (!layout.free_spacing) {
++pos;
space_inserted = true;
} else {
- const Paragraph::value_type nb = 8 - pos % 8;
+ const Paragraph::size_type nb = 8 - pos % 8;
for (Paragraph::size_type a = 0;
a < nb ; ++a) {
par->insertChar(pos, ' ', font);
// The top of the file should not be written by params.
// write out a comment in the top of the file
- ofs << '#' << LYX_DOCVERSION
+ ofs << '#' << lyx_docversion
<< " created this file. For more info see http://www.lyx.org/\n"
<< "\\lyxformat " << LYX_FORMAT << "\n";
Paragraph::depth_type depth = 0;
int ltype = 0;
Paragraph::depth_type ltype_depth = 0;
- unsigned int currlinelen = 0;
+ string::size_type currlinelen = 0;
bool ref_printed = false;
int noparbreak = 0;
case Paragraph::META_HFILL:
buffer << "\t";
break;
-
- case '\\':
- buffer << "\\";
- break;
-
+
default:
if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
(c == ' ') && ((i + 2) < par->size()))
buffer << " ";
currlinelen += (ltype_depth-depth)*2;
}
- } else if (c != '\0')
+ } else if (c != '\0') {
buffer << c;
- else if (c == '\0')
+ ++currlinelen;
+ } else
lyxerr[Debug::INFO] << "writeAsciiFile: NULL char in structure." << endl;
- ++currlinelen;
break;
}
}
texrow.start(paragraph, 0);
if (!only_body && nice) {
- ofs << "%% " LYX_DOCVERSION " created this file. "
+ ofs << "%% " << lyx_docversion << " created this file. "
"For more info, see http://www.lyx.org/.\n"
"%% Do not edit unless you really know what "
"you are doing.\n";
texrow.newline();
}
- // We try to load babel late, in case it interferes
- // with other packages.
- if (use_babel) {
- string tmp = lyxrc.language_package;
- if (!lyxrc.language_global_options
- && tmp == "\\usepackage{babel}")
- tmp = string("\\usepackage[") +
- language_options.str().c_str() +
- "]{babel}";
- ofs << tmp << "\n";
- texrow.newline();
- }
-
if (params.secnumdepth != tclass.secnumdepth()) {
ofs << "\\setcounter{secnumdepth}{"
<< params.secnumdepth
ofs << preamble;
+ // We try to load babel late, in case it interferes
+ // with other packages.
+ if (use_babel) {
+ string tmp = lyxrc.language_package;
+ if (!lyxrc.language_global_options
+ && tmp == "\\usepackage{babel}")
+ tmp = string("\\usepackage[") +
+ language_options.str().c_str() +
+ "]{babel}";
+ ofs << tmp << "\n";
+ texrow.newline();
+ }
+
// make the body.
ofs << "\\begin{document}\n";
texrow.newline();
string top_element = textclasslist.LatexnameOfClass(params.textclass);
if (!body_only) {
- string sgml_includedfiles=features.getIncludedFiles(fname);
+ ofs << "<!doctype linuxdoc system";
- if (params.preamble.empty() && sgml_includedfiles.empty()) {
- ofs << "<!doctype linuxdoc system>\n\n";
- } else {
- ofs << "<!doctype linuxdoc system [ "
- << params.preamble << sgml_includedfiles << " \n]>\n\n";
+ string preamble = params.preamble;
+ preamble += features.getIncludedFiles(fname);
+ preamble += features.getLyXSGMLEntities();
+
+ if (!preamble.empty()) {
+ ofs << " [ " << preamble << " ]";
}
+ ofs << ">\n\n";
if (params.options.empty())
sgmlOpenTag(ofs, 0, top_element);
}
}
- ofs << "<!-- " << LYX_DOCVERSION
+ ofs << "<!-- " << lyx_docversion
<< " created this file. For more info see http://www.lyx.org/"
<< " -->\n";
}
-void Buffer::docBookHandleCaption(ostream & os, string & inner_tag,
- Paragraph::depth_type depth, int desc_on,
- Paragraph * & par)
-{
- Paragraph * tpar = par;
- while (tpar
- && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
- "Caption").second))
- tpar = tpar->next();
-
- 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;
- }
-}
-
-
// checks, if newcol chars should be put into this line
// writes newline, if necessary.
namespace {
} // namespace anon
-
-
// Handle internal paragraph parsing -- layout already processed.
void Buffer::simpleLinuxDocOnePar(ostream & os,
Paragraph * par,
string top_element = textclasslist.LatexnameOfClass(params.textclass);
if (!only_body) {
- string sgml_includedfiles = features.getIncludedFiles(fname);
+ ofs << "<!DOCTYPE " << top_element
+ << " PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\"";
- ofs << "<!doctype " << top_element
- << " public \"-//OASIS//DTD DocBook V3.1//EN\"";
+ string preamble = params.preamble;
+ preamble += features.getIncludedFiles(fname);
+ preamble += features.getLyXSGMLEntities();
- if (params.preamble.empty() && sgml_includedfiles.empty())
- 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;
}
sgmlOpenTag(ofs, 0, top);
- ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION
+ ofs << "<!-- DocBook file was created by " << lyx_docversion
<< "\n See http://www.lyx.org/ for more information -->\n";
vector<string> environment_stack(10);
if (c == Paragraph::META_INSET) {
Inset * inset = par->getInset(i);
ostringstream ost;
- inset->docBook(this, ost);
+ inset->docbook(this, ost);
string tmp_out = ost.str().c_str();
//
}
} else {
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</term><listitem><para>";
- desc_on = 2;
- } else {
- os << c;
- }
+ par->linuxDocConvertChar(c, sgml_string);
+
+ if (style.pass_thru) {
+ os << c;
+ } else if(style.free_spacing || c != ' ') {
+ os << sgml_string;
+ } else if (desc_on ==1) {
+ ++char_line_count;
+ os << "\n</term><listitem><para>";
+ desc_on = 2;
} else {
- os << sgml_string;
+ os << ' ';
}
}
font_old = font;
{
Lists l;
Paragraph * par = paragraph;
+
+#if 1
+ std::pair<bool, LyXTextClassList::size_type> const tmp =
+ textclasslist.NumberOfLayout(params.textclass, "Caption");
+ bool const found = tmp.first;
+ LyXTextClassList::size_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;
boost::tie(found, cap) = textclasslist
.NumberOfLayout(params.textclass, "Caption");
+#endif
while (par) {
char const labeltype =
void Buffer::changeLanguage(Language const * from, Language const * to)
{
- Paragraph * par = paragraph;
- while (par) {
- par->changeLanguage(params, from, to);
- par = par->next();
- }
+ ParIterator end = par_iterator_end();
+ for (ParIterator it = par_iterator_begin(); it != end; ++it)
+ (*it)->changeLanguage(params, from, to);
}
bool Buffer::isMultiLingual()
{
- Paragraph * 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;
- par = par->next();
- }
+
return false;
}
}
return 0;
}
+
+
+ParIterator Buffer::par_iterator_begin()
+{
+ return ParIterator(paragraph);
+}
+
+
+ParIterator Buffer::par_iterator_end()
+{
+ return ParIterator();
+}