X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetexternal.C;h=ec9047185275278363040ce066eaf3b49adf159f;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=1b44579265aa4f760311c489f7747b1515876919;hpb=743bb400616283262119244449746baea98adc1b;p=lyx.git diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 1b44579265..ec90471852 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -14,27 +14,32 @@ #pragma implementation #endif -#include -#include - #include "insetexternal.h" #include "ExternalTemplate.h" #include "BufferView.h" #include "buffer.h" #include "LyXView.h" -#include "frontends/Dialogs.h" #include "lyx_main.h" #include "LaTeXFeatures.h" +#include "gettext.h" +#include "debug.h" + +#include "frontends/Dialogs.h" + #include "support/filetools.h" #include "support/lstrings.h" #include "support/path.h" -#include "support/syscall.h" -#include "gettext.h" -#include "debug.h" +#include "support/systemcall.h" #include "support/FileInfo.h" +#include +#include + + +using std::ostream; using std::endl; + InsetExternal::InsetExternal() : view_(0) { @@ -85,10 +90,10 @@ void InsetExternal::edit(BufferView * bv, bool) } -void InsetExternal::write(Buffer const *, std::ostream & os) const +void InsetExternal::write(Buffer const *, ostream & os) const { - os << "External " << params_.templ.lyxName << ",\"" << params_.filename - << "\",\"" << params_.parameters << "\"\n"; + os << "External " << params_.templ.lyxName << ",\"" + << params_.filename << "\",\"" << params_.parameters << "\"\n"; } @@ -129,15 +134,15 @@ void InsetExternal::read(Buffer const *, LyXLex & lex) int InsetExternal::write(string const & format, - Buffer const * buf, std::ostream & os) const + Buffer const * buf, ostream & os) const { ExternalTemplate const & et = params_.templ; ExternalTemplate::Formats::const_iterator cit = et.formats.find(format); if (cit == et.formats.end()) { lyxerr << "External template format '" << format - << "' not specified in template " << params_.templ.lyxName - << endl; + << "' not specified in template " + << params_.templ.lyxName << endl; return 0; } @@ -148,25 +153,25 @@ int InsetExternal::write(string const & format, int InsetExternal::latex(Buffer const * buf, - std::ostream & os, bool, bool) const + ostream & os, bool, bool) const { return write("LaTeX", buf, os); } -int InsetExternal::ascii(Buffer const * buf, std::ostream & os, int) const +int InsetExternal::ascii(Buffer const * buf, ostream & os, int) const { return write("Ascii", buf, os); } -int InsetExternal::linuxdoc(Buffer const * buf, std::ostream & os) const +int InsetExternal::linuxdoc(Buffer const * buf, ostream & os) const { return write("LinuxDoc", buf, os); } -int InsetExternal::docbook(Buffer const * buf, std::ostream & os) const +int InsetExternal::docbook(Buffer const * buf, ostream & os) const { return write("DocBook", buf, os); } @@ -185,7 +190,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const features.require(cit->second.requirement); } if (!cit->second.preamble.empty()) { - features.externalPreambles += cit->second.preamble + "\n"; + features.addExternalPreamble(cit->second.preamble + "\n"); } } @@ -214,26 +219,24 @@ string const InsetExternal::getScreenLabel(Buffer const *) const void InsetExternal::executeCommand(string const & s, Buffer const * buffer) const { - string buf = MakeAbsPath(buffer->fileName()); - string path = OnlyPath(buf); - Path p(path); - Systemcalls one; + Path p(buffer->filePath()); + Systemcall one; if (lyxerr.debugging()) { lyxerr << "Executing '" << s << "' in '" - << path << "'" << endl; + << buffer->filePath() << "'" << endl; } - one.startscript(Systemcalls::Wait, s); + one.startscript(Systemcall::Wait, s); } string const InsetExternal::doSubstitution(Buffer const * buffer, - string const & s) const + string const & s) const { string result; string const basename = ChangeExtension(params_.filename, string()); - string filepath = ""; + string filepath; if (buffer && (!buffer->niceFile)) { - filepath = OnlyPath(MakeAbsPath(buffer->fileName())); + filepath = buffer->filePath(); } result = subst(s, "$$FName", params_.filename); result = subst(result, "$$Basename", basename); @@ -252,9 +255,7 @@ string const InsetExternal::doSubstitution(Buffer const * buffer, string contents; if (buffer) { // Make sure we are in the directory of the buffer - string const buf = MakeAbsPath(buffer->fileName()); - string const path = OnlyPath(buf); - Path p(path); + Path p(buffer->filePath()); contents = GetFileContents(file); } else { contents = GetFileContents(file);