Buffer::Buffer(string const & file, bool ronly)
- : paragraph(0), lyx_clean(true), bak_clean(true),
+ : paragraph(0), niceFile(true), lyx_clean(true), bak_clean(true),
unnamed(false), dep_clean(0), read_only(ronly),
filename_(file), users(0)
{
static int call_depth;
++call_depth;
bool checkminipage = false;
- static Paragraph * minipar;
+ static Paragraph * minipar = 0;
static Paragraph * parBeforeMinipage;
#endif
#endif
insertErtContents(par, pos);
#endif
lex.eatLine();
- string const layoutname = lex.getString();
+ string layoutname = lex.getString();
+
LyXTextClass const & tclass = textclasslist[params.textclass];
+
+ if (layoutname.empty()) {
+ layoutname = tclass.defaultLayoutName();
+ }
+
bool hasLayout = tclass.hasLayout(layoutname);
if (!hasLayout) {
lyxerr << "Layout '" << layoutname << "' does not"
<< " exist in textclass '" << tclass.name()
<< "'." << endl;
+ lyxerr << "Trying to use default layout instead."
+ << endl;
+ layoutname = tclass.defaultLayoutName();
}
#ifndef NO_COMPABILITY
the_end_read = true;
#ifndef NO_COMPABILITY
#ifndef NO_PEXTRA_REALLY
+ if (minipar == par)
+ par = 0;
minipar = parBeforeMinipage = 0;
#endif
#endif
if (checkminipage && (call_depth == 1)) {
checkminipage = false;
if (minipar && (minipar != par) &&
- (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) {
+ (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE))
+ {
lyxerr << "minipages in a row" << endl;
if (par->params().pextraStartMinipage()) {
lyxerr << "start new minipage" << endl;
mini->pageWidth(LyXLength(par->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
lyxerr << "WP:" << mini->pageWidth().asString() << endl;
- mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"p%"));
}
Paragraph * op = mini->firstParagraph();
mini->inset.paragraph(par);
mini->pageWidth(LyXLength(minipar->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
lyxerr << "WP:" << mini->pageWidth().asString() << endl;
- mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"p%"));
}
+
+ Paragraph * op = mini->firstParagraph();
mini->inset.paragraph(minipar);
+ //
+ // and free the old ones!
+ //
+ while(op) {
+ Paragraph * pp = op->next();
+ delete op;
+ op = pp;
+ }
// Insert the minipage last in the
// previous paragraph.
{
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
- niceFile = nice; // this will be used by Insetincludes.
-
- tex_code_break_column = lyxrc.ascii_linelen;
-
ofstream ofs(fname.c_str());
if (!ofs) {
Alert::err_alert(_("Error: Cannot open file: "), fname);
return;
}
+ niceFile = nice; // this will be used by Insetincludes.
+
+ tex_code_break_column = lyxrc.ascii_linelen;
+
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
LaTeXFeatures features(params);
texrow.newline();
}
if (!original_path.empty()) {
+ string inputpath = os::external_path(original_path);
+ subst(inputpath, "~", "\\string~");
ofs << "\\makeatletter\n"
<< "\\def\\input@path{{"
- << os::external_path(original_path) << "/}}\n"
+ << inputpath << "/}}\n"
<< "\\makeatother\n";
texrow.newline();
texrow.newline();
lyxerr[Debug::INFO] << "Finished making latex file." << endl;
lyxerr[Debug::INFO] << "Row count was " << texrow.rows()-1 << "." << endl;
+
+ // we want this to be true outside previews (for insetexternal)
+ niceFile = true;
}
ofs << "<!doctype linuxdoc system";
string preamble = params.preamble;
- preamble += features.getIncludedFiles(fname);
+ const string name = nice ? ChangeExtension(filename_, ".sgml")
+ : fname;
+ preamble += features.getIncludedFiles(name);
preamble += features.getLyXSGMLEntities();
if (!preamble.empty()) {
ofs.close();
// How to check for successful close
+
+ // we want this to be true outside previews (for insetexternal)
+ niceFile = true;
}
<< " PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\"";
string preamble = params.preamble;
- preamble += features.getIncludedFiles(fname);
+ const string name = nice ? ChangeExtension(filename_, ".sgml")
+ : fname;
+ preamble += features.getIncludedFiles(name);
preamble += features.getLyXSGMLEntities();
if (!preamble.empty()) {
ofs.close();
// How to check for successful close
+
+ // we want this to be true outside previews (for insetexternal)
+ niceFile = true;
}