X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FExternalSupport.cpp;h=6d009a5dd2b13814d9bd7c0c3fdc092d860e7476;hb=d044d6afa7192b2119784e1415e71dad644bc335;hp=368d57361b1bfca8d6d5df1156b53691a4b0dadb;hpb=e7bb71ff4ebf16351ab238b5cb7514173dd4f84d;p=lyx.git diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp index 368d57361b..6d009a5dd2 100644 --- a/src/insets/ExternalSupport.cpp +++ b/src/insets/ExternalSupport.cpp @@ -50,8 +50,8 @@ Template const * getTemplatePtr(InsetExternalParams const & params) void editExternal(InsetExternalParams const & params, Buffer const & buffer) { - formats.edit(buffer, params.filename, - formats.getFormatFromFile(params.filename)); + formats.edit(buffer, params.filename, + formats.getFormatFromFile(params.filename)); } @@ -88,11 +88,11 @@ string const doSubstitution(InsetExternalParams const & params, masterBuffer->temppath() : buffer.filePath(); string const filename = external_in_tmpdir ? - params.filename.mangledFilename() : - params.filename.outputFilename(parentpath); + params.filename.mangledFileName() : + params.filename.outputFileName(parentpath); string const basename = changeExtension( - onlyFilename(filename), string()); - string const absname = makeAbsPath(filename, parentpath).absFilename(); + onlyFileName(filename), string()); + string const absname = makeAbsPath(filename, parentpath).absFileName(); string result = s; if (what != ALL_BUT_PATHS) { @@ -130,7 +130,7 @@ string const doSubstitution(InsetExternalParams const & params, relToParentPath, use_latex_path, PROTECT_EXTENSION, ESCAPE_DOTS); - if (absolutePath(filename)) { + if (FileName::isAbsolute(filename)) { result = subst_path(result, "$$AbsOrRelPathMaster", abspath, use_latex_path, PROTECT_EXTENSION, @@ -160,9 +160,9 @@ string const doSubstitution(InsetExternalParams const & params, PROTECT_EXTENSION, ESCAPE_DOTS); result = subst_path(result, "$$Extension", '.' + getExtension(filename), use_latex_path); - result = subst_path(result, "$$Tempname", params.tempname().absFilename(), use_latex_path); + result = subst_path(result, "$$Tempname", params.tempname().absFileName(), use_latex_path); result = subst_path(result, "$$Sysdir", - package().system_support().absFilename(), use_latex_path); + package().system_support().absFileName(), use_latex_path); // Handle the $$Contents(filename) syntax if (contains(result, "$$Contents(\"")) { @@ -246,7 +246,7 @@ void updateExternal(InsetExternalParams const & params, // We copy the source file to the temp dir and do the conversion // there if necessary FileName const temp_file( - makeAbsPath(params.filename.mangledFilename(), + makeAbsPath(params.filename.mangledFileName(), masterBuffer->temppath())); if (!params.filename.empty() && !params.filename.isDirectory()) { unsigned long const from_checksum = params.filename.checksum(); @@ -296,7 +296,9 @@ void updateExternal(InsetExternalParams const & params, ALL_BUT_PATHS); // if file is a relative name, it is interpreted // relative to the master document. - exportdata.addExternalFile(rit->first, source, file); + if (makeAbsPath(file, masterBuffer->filePath()) != + params.filename.absFileName()) + exportdata.addExternalFile(rit->first, source, file); } } } @@ -331,23 +333,23 @@ string const substituteOptions(InsetExternalParams const & params, } // namespace anon -int writeExternal(InsetExternalParams const & params, - string const & format, - Buffer const & buffer, odocstream & os, - ExportData & exportdata, - bool external_in_tmpdir, - bool dryrun) +void writeExternal(InsetExternalParams const & params, + string const & format, + Buffer const & buffer, otexstream & os, + ExportData & exportdata, + bool external_in_tmpdir, + bool dryrun) { Template const * const et_ptr = getTemplatePtr(params); if (!et_ptr) - return 0; + return; Template const & et = *et_ptr; Template::Formats::const_iterator cit = et.formats.find(format); if (cit == et.formats.end()) { LYXERR(Debug::EXTERNAL, "External template format '" << format << "' not specified in template " << params.templatename()); - return 0; + return; } if (!dryrun || contains(cit->second.product, "$$Contents")) @@ -359,20 +361,29 @@ int writeExternal(InsetExternalParams const & params, use_latex_path, external_in_tmpdir); string const absname = makeAbsPath( - params.filename.outputFilename(buffer.filePath()), buffer.filePath()).absFilename(); - - if (!external_in_tmpdir && !isValidLaTeXFilename(absname)) { - lyx::frontend::Alert::warning(_("Invalid filename"), - _("The following filename is likely to cause trouble " - "when running the exported file through LaTeX: ") + - from_utf8(absname)); + params.filename.outputFileName(buffer.filePath()), buffer.filePath()).absFileName(); + + if (!dryrun && !external_in_tmpdir) { + if (!isValidLaTeXFileName(absname)) { + lyx::frontend::Alert::warning(_("Invalid filename"), + _("The following filename will cause troubles " + "when running the exported file through LaTeX: ") + + from_utf8(absname)); + } + if (!isValidDVIFileName(absname)) { + lyx::frontend::Alert::warning(_("Problematic filename for DVI"), + _("The following filename can cause troubles " + "when running the exported file through LaTeX " + "and opening the resulting DVI: ") + + from_utf8(absname), true); + } } str = substituteCommands(params, str, format); str = substituteOptions(params, str, format); // FIXME UNICODE os << from_utf8(str); - return int(count(str.begin(), str.end(),'\n')); + return; } namespace {