#include "insets/insetindex.h"
#include "insets/insetinclude.h"
#include "insets/insettoc.h"
-#include "insets/insetlof.h"
-#include "insets/insetlot.h"
-#include "insets/insetloa.h"
#include "insets/insetparent.h"
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "lyx_gui_misc.h" // WarnReadonly()
#include "frontends/Dialogs.h"
#include "encoding.h"
+#include "exporter.h"
using std::ostream;
using std::ofstream;
// all these externs should eventually be removed.
extern BufferList bufferlist;
+#ifndef NEW_EXPORT
extern void MenuExport(Buffer *, string const &);
+#endif
extern LyXAction lyxaction;
-static const float LYX_FORMAT = 2.16;
+static const float LYX_FORMAT = 2.17;
extern int tex_code_break_column;
//lyxerr << "float body: " << old_float << endl;
#ifdef HAVE_SSTREAM
- istringstream istr(old_float.c_str());
+ istringstream istr(old_float);
#else
istrstream istr(old_float.c_str());
#endif
if (pp.first) {
params.textclass = pp.second;
} else {
- lex.printError("Unknown textclass `$$Token'");
+ lex.printError("Unknown textclass `$$Token'");
params.textclass = 0;
}
if (!textclasslist.Load(params.textclass)) {
// But insets should read it, it is a part of
// the inset isn't it? Lgb.
} else if (token == "\\begin_inset") {
-#if 1
readInset(lex, par, pos, font);
-#else
- // Should be moved out into its own function/method. (Lgb)
- lex.next();
- string tmptok = lex.GetString();
- last_inset_read = tmptok;
- // test the different insets
- if (tmptok == "Quotes") {
- Inset * inset = new InsetQuotes;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "External") {
- Inset * inset = new InsetExternal;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "FormulaMacro") {
- Inset * inset = new InsetFormulaMacro;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Formula") {
- Inset * inset = new InsetFormula;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Figure") {
- Inset * inset = new InsetFig(100, 100, this);
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Info") {
- Inset * inset = new InsetInfo;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Include") {
- Inset * inset = new InsetInclude(string(), this);
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "ERT") {
- Inset * inset = new InsetERT;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Tabular") {
- Inset * inset = new InsetTabular(this);
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Text") {
- Inset * inset = new InsetText;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Foot") {
- Inset * inset = new InsetFoot;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Marginal") {
- Inset * inset = new InsetMarginal;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Minipage") {
- Inset * inset = new InsetMinipage;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Float") {
- lex.next();
- string tmptok = lex.GetString();
- Inset * inset = new InsetFloat(tmptok);
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "List") {
- Inset * inset = new InsetList;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Theorem") {
- Inset * inset = new InsetList;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "Caption") {
- Inset * inset = new InsetCaption;
- inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- ++pos;
- } else if (tmptok == "GRAPHICS") {
- Inset * inset = new InsetGraphics;
- //inset->Read(this, lex);
- par->InsertInset(pos, inset, font);
- } else if (tmptok == "LatexCommand") {
- InsetCommand inscmd;
- inscmd.Read(this, lex);
- Inset * inset = 0;
- if (inscmd.getCmdName() == "cite") {
- inset = new InsetCitation(inscmd.params());
- } else if (inscmd.getCmdName() == "bibitem") {
- lex.printError("Wrong place for bibitem");
- inset = inscmd.Clone();
- } else if (inscmd.getCmdName() == "BibTeX") {
- inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this);
- } else if (inscmd.getCmdName() == "index") {
- inset = new InsetIndex(inscmd.getContents());
- } else if (inscmd.getCmdName() == "include") {
- inset = new InsetInclude(inscmd.getContents(), this);
- } else if (inscmd.getCmdName() == "label") {
- inset = new InsetLabel(inscmd.getCommand());
- } else if (inscmd.getCmdName() == "url"
- || inscmd.getCmdName() == "htmlurl") {
- inset = new InsetUrl(inscmd.params());
- } else if (inscmd.getCmdName() == "ref"
- || inscmd.getCmdName() == "pageref"
- || inscmd.getCmdName() == "vref"
- || inscmd.getCmdName() == "vpageref"
- || inscmd.getCmdName() == "prettyref") {
- if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) {
- inset = new InsetRef(inscmd, this);
- }
- } else if (inscmd.getCmdName() == "tableofcontents") {
- inset = new InsetTOC(this);
- } else if (inscmd.getCmdName() == "listoffigures") {
- inset = new InsetLOF(this);
- } else if (inscmd.getCmdName() == "listofalgorithms") {
- inset = new InsetLOA(this);
- } else if (inscmd.getCmdName() == "listoftables") {
- inset = new InsetLOT(this);
- } else if (inscmd.getCmdName() == "printindex") {
- inset = new InsetPrintIndex(this);
- } else if (inscmd.getCmdName() == "lyxparent") {
- inset = new InsetParent(inscmd.getContents(), this);
- }
-
- if (inset) {
- par->InsertInset(pos, inset, font);
- ++pos;
- }
- }
-#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =
textclasslist.Style(params.textclass,
}
++pos;
} else if (token == "\\bibitem") { // ale970302
- if (!par->bibkey)
- par->bibkey = new InsetBibKey;
+ if (!par->bibkey) {
+ InsetCommandParams p( "bibitem" );
+ par->bibkey = new InsetBibKey(p);
+ }
par->bibkey->Read(this, lex);
- }else if (token == "\\backslash") {
+ } else if (token == "\\backslash") {
par->InsertChar(pos, '\\', font);
++pos;
- }else if (token == "\\the_end") {
+ } else if (token == "\\the_end") {
the_end_read = true;
} else {
// This should be insurance for the future: (Asger)
lex.printError("Unknown token `$$Token'. "
"Inserting as text.");
- for(string::const_iterator cit = token.begin();
- cit != token.end(); ++cit) {
+ string::const_iterator cit = token.begin();
+ string::const_iterator end = token.end();
+ for(; cit != end; ++cit) {
par->InsertChar(pos, (*cit), font);
++pos;
}
par->InsertInset(pos, inset, font);
++pos;
} else if (tmptok == "Include") {
- Inset * inset = new InsetInclude(string(), this);
+ InsetCommandParams p( "Include" );
+ Inset * inset = new InsetInclude(p, this);
inset->Read(this, lex);
par->InsertInset(pos, inset, font);
++pos;
++pos;
} else if (tmptok == "GRAPHICS") {
Inset * inset = new InsetGraphics;
- //inset->Read(this, lex);
+ inset->Read(this, lex);
par->InsertInset(pos, inset, font);
+ ++pos;
} else if (tmptok == "LatexCommand") {
- InsetCommand inscmd;
- inscmd.Read(this, lex);
+ InsetCommandParams inscmd;
+ inscmd.Read(lex);
Inset * inset = 0;
if (inscmd.getCmdName() == "cite") {
- inset = new InsetCitation(inscmd.params());
+ inset = new InsetCitation(inscmd);
} else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem");
- inset = inscmd.Clone();
+ inset = new InsetBibKey(inscmd);
} else if (inscmd.getCmdName() == "BibTeX") {
- inset = new InsetBibtex(inscmd.getContents(),
- inscmd.getOptions(), this);
+ inset = new InsetBibtex(inscmd, this);
} else if (inscmd.getCmdName() == "index") {
- inset = new InsetIndex(inscmd.getContents());
+ inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") {
- inset = new InsetInclude(inscmd.getContents(), this);
+ inset = new InsetInclude(inscmd, this);
} else if (inscmd.getCmdName() == "label") {
- inset = new InsetLabel(inscmd.getCommand());
+ inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") {
- inset = new InsetUrl(inscmd.params());
+ inset = new InsetUrl(inscmd);
} else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref"
|| inscmd.getCmdName() == "prettyref") {
if (!inscmd.getOptions().empty()
|| !inscmd.getContents().empty()) {
- inset = new InsetRef(inscmd, this);
+ inset = new InsetRef(inscmd);
}
- } else if (inscmd.getCmdName() == "tableofcontents") {
- inset = new InsetTOC(this);
- } else if (inscmd.getCmdName() == "listoffigures") {
- inset = new InsetLOF(this);
- } else if (inscmd.getCmdName() == "listofalgorithms") {
- inset = new InsetLOA(this);
- } else if (inscmd.getCmdName() == "listoftables") {
- inset = new InsetLOT(this);
+ } else if (inscmd.getCmdName() == "tableofcontents"
+ || inscmd.getCmdName() == "listofalgorithms"
+ || inscmd.getCmdName() == "listoffigures"
+ || inscmd.getCmdName() == "listoftables") {
+ inset = new InsetTOC(inscmd);
} else if (inscmd.getCmdName() == "printindex") {
- inset = new InsetPrintIndex(this);
+ inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") {
- inset = new InsetParent(inscmd.getContents(), this);
+ inset = new InsetParent(inscmd, this);
}
if (inset) {
bool Buffer::readFile(LyXLex & lex, LyXParagraph * par)
{
- string token;
-
if (lex.IsOK()) {
lex.next();
- token = lex.GetString();
+ string token(lex.GetString());
if (token == "\\lyxformat") { // the first token _must_ be...
lex.next();
format = lex.GetFloat();
if (format > 1) {
if (LYX_FORMAT - format > 0.05) {
+
printf(_("Warning: need lyxformat %.2f but found %.2f\n"),
LYX_FORMAT, format);
}
if (writeFile(fileName(), false)) {
markLyxClean();
-
- // now delete the autosavefile
- string a = OnlyPath(fileName());
- a += '#';
- a += OnlyFilename(fileName());
- a += '#';
- FileInfo fileinfo(a);
- if (fileinfo.exist()) {
- if (::remove(a.c_str()) != 0) {
- WriteFSAlert(_("Could not delete "
- "auto-save file!"), a);
- }
- }
+ removeAutosaveFile(fileName());
} else {
// Saving failed, so backup is not backup
if (lyxrc.make_backup) {
int Buffer::runLaTeX()
{
+#ifndef NEW_EXPORT
+
if (!users->text) return 0;
ProhibitInput(users);
AllowInput(users);
return latex.getNumErrors();
+#else
+ return 0;
+#endif
}
users->owner()->getMiniBuffer()->Set(_("Running Literate..."));
// Remove all error insets
- bool a = users->removeAutoInsets();
+ bool removedErrorInsets = users->removeAutoInsets();
// generate the Literate file if necessary
makeLaTeXFile(lit_name, org_path, false);
// if we removed error insets before we ran LaTeX or if we inserted
// error insets after we ran LaTeX this must be run:
- if (a || (res & Literate::ERRORS)){
+ if (removedErrorInsets || (res & Literate::ERRORS)){
users->redraw();
users->fitCursor();
//users->updateScrollbar();
users->owner()->getMiniBuffer()->Set(_("Building Program..."));
// Remove all error insets
- bool a = users->removeAutoInsets();
+ bool removedErrorInsets = users->removeAutoInsets();
// generate the LaTeX file if necessary
- if (!isNwClean() || a) {
+ if (!isNwClean() || removedErrorInsets) {
makeLaTeXFile(lit_name, org_path, false);
markNwDirty();
}
// if we removed error insets before we ran Literate/Build or
// if we inserted error insets after we ran Literate/Build this
// must be run:
- if (a || (res & Literate::ERRORS)){
+ if (removedErrorInsets || (res & Literate::ERRORS)){
users->redraw();
users->fitCursor();
//users->updateScrollbar();
bool dispatched = true;
switch (action) {
case LFUN_EXPORT:
+#ifdef NEW_EXPORT
+ Exporter::Export(this, argument, false);
+#else
MenuExport(this, argument);
+#endif
break;
default: