X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetinclude.C;h=1d28e3347b4e8ab3b3389c3a5a03c663182e5127;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=b9fdd55e03e7e8d46e0f9847ab9c354194f9f839;hpb=d6fa7c567c47f1af95f026174a83bf75dde08f84;p=lyx.git diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index b9fdd55e03..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,26 +332,16 @@ bool InsetInclude::loadIfNeeded() const } -int InsetInclude::Latex(ostream & os, signed char /*fragile*/) const +int InsetInclude::Latex(ostream & os, + bool /*fragile*/, bool /*fs*/) const { - string include_file; - signed char dummy = 0; - Latex(include_file, dummy); - os << include_file; - return 0; -} - - -int InsetInclude::Latex(string & file, signed char /*fragile*/) const -{ - string writefile, incfile; - // Do nothing if no file name has been specified if (contents.empty()) return 0; // Use += to force a copy of contents (JMarc) - incfile += contents; + // How does that force anything? (Lgb) + string incfile(contents); if (loadIfNeeded()) { Buffer * tmp = bufferlist.getBuffer(getFileName()); @@ -351,7 +358,7 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const } // write it to a file (so far the complete file) - writefile = ChangeExtension(getFileName(), ".tex", false); + string writefile = ChangeExtension(getFileName(), ".tex", false); if (!master->tmppath.empty() && !master->niceFile) { incfile = subst(incfile, '/','@'); @@ -373,29 +380,23 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const } if (isVerb()) { - file += '\\'; - file += command + '{'; - file += incfile + '}'; + os << '\\' << command << '{' << incfile << '}'; } else if (isInput()) { // \input wants file with extension (default is .tex) if (!IsLyXFilename(getFileName())) { - file += '\\'; - file += command + '{'; - file += incfile + '}'; + os << '\\' << command << '{' << incfile << '}'; } else { - file += '\\'; - file += command + '{'; - file += ChangeExtension(incfile, ".tex", false) - + '}'; + os << '\\' << command << '{' + << 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) - + '}'; + os << '\\' << command << '{' + << ChangeExtension(incfile, string(), false) + << '}'; } return 0;