X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetinclude.C;h=1d28e3347b4e8ab3b3389c3a5a03c663182e5127;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=49df77bd3325426da57e6c034c30edf6d4d4a357;hpb=132fe5e1322fbc86a32692df51eba78d6b4e479c;p=lyx.git diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 49df77bd33..1d28e3347b 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -21,10 +21,13 @@ #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; @@ -107,7 +110,7 @@ extern "C" void include_cb(FL_OBJECT *, long arg) 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"), @@ -281,6 +284,12 @@ void InsetInclude::Read(LyXLex & lex) } +bool InsetInclude::display() const +{ + return !isInput(); +} + + string InsetInclude::getScreenLabel() const { string temp; @@ -301,6 +310,14 @@ string InsetInclude::getScreenLabel() const } +void InsetInclude::setContents(string const & c) +{ + InsetCommand::setContents(c); + filename = MakeAbsPath(contents, + OnlyPath(getMasterFilename())); +} + + bool InsetInclude::loadIfNeeded() const { if (isNoLoad() || isVerb()) return false; @@ -315,9 +332,9 @@ bool InsetInclude::loadIfNeeded() const } -int InsetInclude::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) 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; @@ -382,93 +399,8 @@ int InsetInclude::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) cons << '}'; } - return 0; -#else - string include_file; - signed char dummy = 0; - Latex(include_file, dummy, 0); - os << include_file; - return 0; -#endif -} - - -#ifndef USE_OSTREAM_ONLY -int InsetInclude::Latex(string & file, signed char /*fragile*/, bool /*fs*/) 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