mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
filetools.cpp: introduce a new method to be able to distinguish between valid LaTeX filenames and filenames causing troubles on some DVI viewers.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ea3e3a05cd
commit
b33182bc3d
@ -363,11 +363,20 @@ int writeExternal(InsetExternalParams const & params,
|
||||
string const absname = makeAbsPath(
|
||||
params.filename.outputFileName(buffer.filePath()), buffer.filePath()).absFileName();
|
||||
|
||||
if (!dryrun && !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));
|
||||
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);
|
||||
|
@ -281,12 +281,20 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
||||
<< "' to '" << out_file << "'"
|
||||
<< endl;
|
||||
}
|
||||
} else if (!runparams.inComment && runparams.nice && not_from_texmf &&
|
||||
!isValidLaTeXFileName(database)) {
|
||||
} else if (!runparams.inComment && runparams.nice && not_from_texmf) {
|
||||
if (!isValidLaTeXFileName(database)) {
|
||||
frontend::Alert::warning(_("Invalid filename"),
|
||||
_("The following filename is likely to cause trouble "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(database));
|
||||
_("The following filename will cause troubles "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(database));
|
||||
}
|
||||
if (!isValidDVIFileName(database)) {
|
||||
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(database), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (didone)
|
||||
|
@ -589,14 +589,26 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
|
||||
params().filename.outputFileName(masterBuffer->filePath()) :
|
||||
onlyFileName(temp_file.absFileName());
|
||||
|
||||
if (runparams.nice && !isValidLaTeXFileName(output_file)) {
|
||||
frontend::Alert::warning(_("Invalid filename"),
|
||||
_("The following filename is likely to cause trouble "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(output_file));
|
||||
if (runparams.nice ) {
|
||||
if (!isValidLaTeXFileName(output_file)) {
|
||||
frontend::Alert::warning(_("Invalid filename"),
|
||||
_("The following filename will cause troubles "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(output_file));
|
||||
}
|
||||
// only show DVI-specific warning when export format is plain latex
|
||||
if (!isValidDVIFileName(output_file)
|
||||
&& runparams.flavor == OutputParams::LATEX) {
|
||||
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(output_file), true);
|
||||
}
|
||||
}
|
||||
|
||||
FileName source_file = runparams.nice ? FileName(params().filename) : temp_file;
|
||||
// determine the export format
|
||||
string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
|
||||
"latex" : "pdflatex";
|
||||
|
||||
|
@ -510,9 +510,16 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
|
||||
incfile = mangled;
|
||||
else if (!isValidLaTeXFileName(incfile)) {
|
||||
frontend::Alert::warning(_("Invalid filename"),
|
||||
_("The following filename is likely to cause trouble "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(incfile));
|
||||
_("The following filename will cause troubles "
|
||||
"when running the exported file through LaTeX: ") +
|
||||
from_utf8(incfile));
|
||||
}
|
||||
else if (!isValidDVIFileName(incfile)) {
|
||||
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(incfile), true);
|
||||
}
|
||||
LYXERR(Debug::LATEX, "incfile:" << incfile);
|
||||
LYXERR(Debug::LATEX, "exportfile:" << exportfile);
|
||||
|
@ -74,7 +74,14 @@ bool isSGMLFileName(string const & filename)
|
||||
|
||||
bool isValidLaTeXFileName(string const & filename)
|
||||
{
|
||||
string const invalid_chars("#$%{}()[]\"^");
|
||||
string const invalid_chars("#%\"");
|
||||
return filename.find_first_of(invalid_chars) == string::npos;
|
||||
}
|
||||
|
||||
|
||||
bool isValidDVIFileName(string const & filename)
|
||||
{
|
||||
string const invalid_chars("${}()[]^");
|
||||
return filename.find_first_of(invalid_chars) == string::npos;
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,15 @@ bool isLyXFileName(std::string const & filename);
|
||||
///
|
||||
bool isSGMLFileName(std::string const & filename);
|
||||
|
||||
///
|
||||
/// check for characters in filenames not allowed by LaTeX
|
||||
bool isValidLaTeXFileName(std::string const & filename);
|
||||
|
||||
/** check for characters in filenames that might lead to
|
||||
problems when manually compiling the LaTeX export of LyX
|
||||
and opening the result with some older DVI-viewers
|
||||
*/
|
||||
bool isValidDVIFileName(std::string const & filename);
|
||||
|
||||
/** Returns the path of a library data file.
|
||||
Search the file name.ext in the subdirectory dir of
|
||||
-# user_lyxdir
|
||||
|
Loading…
Reference in New Issue
Block a user