X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FExternalSupport.cpp;h=aa6f51cbe919a1222a6157df140ee3dec00af6cd;hb=6b49b6b129af9417fea7ea907a44a46fbbd38340;hp=0ce66a42e7a176346173f7bc8c67c42badd8d887;hpb=9439b6e6e0cf950aafe8ce8d76d380c543110db7;p=lyx.git diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp index 0ce66a42e7..aa6f51cbe9 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 (FileName(filename).isAbsolute()) { + 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); } } } @@ -359,13 +361,22 @@ 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);