#include "include_form.h"
#include "support/FileInfo.h"
#include "layout.h"
+#include "lyxfunc.h"
+
+using std::ostream;
+using std::endl;
extern BufferView * current_view;
-extern LyXRC * lyxrc;
extern BufferList bufferlist;
else
ext = "*.lyx";
// launches dialog
- fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
+ fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
// Use by default the master's path
string filename = fileDlg.Select(_("Select Child Document"),
}
+bool InsetInclude::display() const
+{
+ return !isInput();
+}
+
+
string InsetInclude::getScreenLabel() const
{
string temp;
}
+void InsetInclude::setContents(string const & c)
+{
+ InsetCommand::setContents(c);
+ filename = MakeAbsPath(contents,
+ OnlyPath(getMasterFilename()));
+}
+
+
bool InsetInclude::loadIfNeeded() const
{
if (isNoLoad() || isVerb()) return false;
}
-int InsetInclude::Latex(ostream & os, signed char /*fragile*/) const
+int InsetInclude::Latex(ostream & os,
+ bool /*fragile*/, bool /*fs*/) const
{
-#ifdef USE_OSTREAM_ONLY
// Do nothing if no file name has been specified
if (contents.empty())
return 0;
<< '}';
}
- return 0;
-#else
- string include_file;
- signed char dummy = 0;
- Latex(include_file, dummy);
- os << include_file;
- return 0;
-#endif
-}
-
-
-#ifndef USE_OSTREAM_ONLY
-int InsetInclude::Latex(string & file, signed char /*fragile*/) const
-{
- // Do nothing if no file name has been specified
- if (contents.empty())
- return 0;
-
- // Use += to force a copy of contents (JMarc)
- string incfile += contents;
-
- if (loadIfNeeded()) {
- Buffer * tmp = bufferlist.getBuffer(getFileName());
-
- if (tmp->params.textclass != master->params.textclass) {
- lyxerr << "ERROR: Cannot handle include file `"
- << MakeDisplayPath(getFileName())
- << "' which has textclass `"
- << textclasslist.NameOfClass(tmp->params.textclass)
- << "' instead of `"
- << textclasslist.NameOfClass(master->params.textclass)
- << "'." << endl;
- return 0;
- }
-
- // write it to a file (so far the complete file)
- string writefile =
- ChangeExtension(getFileName(), ".tex", false);
- if (!master->tmppath.empty()
- && !master->niceFile) {
- incfile = subst(incfile, '/','@');
-#ifdef __EMX__
- incfile = subst(incfile, ':', '$');
-#endif
- writefile = AddName(master->tmppath, incfile);
- } else
- writefile = getFileName();
- writefile = ChangeExtension(writefile, ".tex", false);
- lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
- lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
-
- tmp->markDepClean(master->tmppath);
-
- tmp->makeLaTeXFile(writefile,
- OnlyPath(getMasterFilename()),
- master->niceFile, true);
- }
-
- if (isVerb()) {
- file += '\\';
- file += command + '{';
- file += incfile + '}';
- }
- else if (isInput()) {
- // \input wants file with extension (default is .tex)
- if (!IsLyXFilename(getFileName())) {
- file += '\\';
- file += command + '{';
- file += incfile + '}';
- } else {
- file += '\\';
- file += command + '{';
- file += ChangeExtension(incfile, ".tex", false)
- + '}';
- }
- } else {
- // \include don't want extension and demands that the
- // file really have .tex
- file += '\\';
- file += command + '{';
- file += ChangeExtension(incfile, string(), false)
- + '}';
- }
-
return 0;
}
-#endif
void InsetInclude::Validate(LaTeXFeatures & features) const