mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +00:00
require file extension for included graphics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8706 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
306248fe6c
commit
b36c13278b
@ -1,6 +1,11 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2004-04-29 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* format incremented to 233.
|
||||
* insetgraphics does not allow filenames without extension anymore.
|
||||
The complete filename has to be given.
|
||||
|
||||
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2004-04-29 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* lyx_1_4.py (convert_graphics): new, convert graphics filenames
|
||||
* lyx_1_4.py (revert, convert): handle format 233
|
||||
* lyx2lyx: up the format to 233.
|
||||
|
||||
2004-04-19 José Matos <jamatos@lyx.orrg>
|
||||
* parser_tools.py (chain): fix the detection of the last format for
|
||||
revertions.
|
||||
|
@ -18,9 +18,12 @@
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
import re
|
||||
from os import access, F_OK
|
||||
import os.path
|
||||
from parser_tools import find_token, find_end_of_inset, get_next_paragraph, \
|
||||
get_paragraph, get_value, del_token, is_nonempty_line,\
|
||||
find_tokens, find_end_of
|
||||
find_tokens, find_end_of, find_token2
|
||||
from sys import stdin
|
||||
from string import replace, split, find, strip, join
|
||||
|
||||
##
|
||||
@ -1115,6 +1118,46 @@ def revert_float(lines, opt):
|
||||
del_token(lines, 'sideways', i, j)
|
||||
i = i + 1
|
||||
|
||||
def convert_graphics(lines, opt):
|
||||
""" Add extension to filenames of insetgraphics if necessary.
|
||||
"""
|
||||
if opt.input == stdin:
|
||||
dir = ""
|
||||
else:
|
||||
dir = os.path.dirname(os.path.abspath(opt.input.name))
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Graphics", i)
|
||||
if i == -1:
|
||||
return
|
||||
|
||||
j = find_token2(lines, "filename", i)
|
||||
if j == -1:
|
||||
return
|
||||
i = i + 1
|
||||
filename = split(lines[j])[1]
|
||||
absname = os.path.normpath(os.path.join(dir, filename))
|
||||
if opt.input == stdin and not os.path.isabs(filename):
|
||||
# We don't know the directory and cannot check the file.
|
||||
# We could use a heuristic and take the current directory,
|
||||
# and we could try to find out if filename has an extension,
|
||||
# but that would be just guesses and could be wrong.
|
||||
opt.warning("""Warning: Can not determine wether file
|
||||
%s
|
||||
needs an extension when reading from standard input.
|
||||
You may need to correct the file manually or run
|
||||
lyx2lyx again with the .lyx file as commandline argument.""" % filename)
|
||||
continue
|
||||
# This needs to be the same algorithm as in pre 233 insetgraphics
|
||||
if access(absname, F_OK):
|
||||
continue
|
||||
if access(absname + ".ps", F_OK):
|
||||
lines[j] = replace(lines[j], filename, filename + ".ps")
|
||||
continue
|
||||
if access(absname + ".eps", F_OK):
|
||||
lines[j] = replace(lines[j], filename, filename + ".eps")
|
||||
|
||||
|
||||
##
|
||||
# Convertion hub
|
||||
#
|
||||
@ -1177,8 +1220,17 @@ def convert(header, body, opt):
|
||||
if opt.format < 232:
|
||||
convert_bibtopic(header, opt)
|
||||
opt.format = 232
|
||||
if opt.end == opt.format: return
|
||||
|
||||
if opt.format < 233:
|
||||
convert_graphics(body, opt)
|
||||
opt.format = 233
|
||||
|
||||
def revert(header, body, opt):
|
||||
if opt.format > 232:
|
||||
opt.format = 232
|
||||
if opt.end == opt.format: return
|
||||
|
||||
if opt.format > 231:
|
||||
revert_bibtopic(header, opt)
|
||||
opt.format = 231
|
||||
|
@ -242,7 +242,7 @@ def set_version(lines, version):
|
||||
format_re = re.compile(r"(\d)[\.,]?(\d\d)")
|
||||
fileformat = re.compile(r"\\lyxformat\s*(\S*)")
|
||||
lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227, 228, 229,
|
||||
230, 231, 232]
|
||||
230, 231, 232, 233]
|
||||
|
||||
format_relation = [("0_10", [210], ["0.10.7","0.10"]),
|
||||
("0_12", [215], ["0.12","0.12.1","0.12"]),
|
||||
@ -254,7 +254,7 @@ format_relation = [("0_10", [210], ["0.10.7","0.10"]),
|
||||
("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
|
||||
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
|
||||
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3"]),
|
||||
("1_4", [223,224,225,226,227,228,229,230,231,232], ["1.4.0cvs","1.4"])]
|
||||
("1_4", [223,224,225,226,227,228,229,230,231,232,233], ["1.4.0cvs","1.4"])]
|
||||
|
||||
def lyxformat(format, opt):
|
||||
result = format_re.match(format)
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-04-29 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* buffer.C: increment format to 233.
|
||||
|
||||
2004-04-28 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* BufferView.[Ch] (c-tor):
|
||||
|
@ -135,7 +135,7 @@ extern BufferList bufferlist;
|
||||
|
||||
namespace {
|
||||
|
||||
const int LYX_FORMAT = 232;
|
||||
const int LYX_FORMAT = 233;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-04-29 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* insetgraphics.C: require file extension (file format change!)
|
||||
* insetgraphics.C (latex): handle zipped files for "nice" export
|
||||
|
||||
2004-04-26 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* insetgraphics.C (latex): strip the extension and replace dots in
|
||||
|
@ -110,10 +110,6 @@ using std::ostringstream;
|
||||
|
||||
namespace {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
int const VersionNumber = 1;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This function is a utility function
|
||||
// ... that should be with ChangeExtension ...
|
||||
inline
|
||||
@ -540,21 +536,12 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
|
||||
string const relative_file =
|
||||
params().filename.relFilename(buf.filePath());
|
||||
|
||||
// A missing (e)ps-extension is no problem for LaTeX, so
|
||||
// we have to test three different cases
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning uh, but can our cache handle it ? no.
|
||||
#endif
|
||||
string const file_ = params().filename.absFilename();
|
||||
bool const file_exists =
|
||||
!file_.empty() &&
|
||||
(IsFileReadable(file_) || // original
|
||||
IsFileReadable(file_ + ".eps") || // original.eps
|
||||
IsFileReadable(file_ + ".ps")); // original.ps
|
||||
bool const file_exists = !file_.empty() && IsFileReadable(file_);
|
||||
string const message = file_exists ?
|
||||
string() : string("bb = 0 0 200 100, draft, type=eps");
|
||||
// if !message.empty() than there was no existing file
|
||||
// "filename(.(e)ps)" found. In this case LaTeX
|
||||
// "filename" found. In this case LaTeX
|
||||
// draws only a rectangle with the above bb and the
|
||||
// not found filename in it.
|
||||
lyxerr[Debug::GRAPHICS]
|
||||
@ -596,7 +583,8 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
|
||||
// Remove the extension so the LaTeX will use whatever
|
||||
// is appropriate (when there are several versions in
|
||||
// different formats)
|
||||
if (!(IsFileReadable(file_ + ".eps") || IsFileReadable(file_ + ".ps")))
|
||||
basename = RemoveExtension(basename);
|
||||
if(params().filename.isZipped())
|
||||
basename = RemoveExtension(basename);
|
||||
// This works only if the filename contains no dots besides
|
||||
// the just removed one. We can fool here by replacing all
|
||||
|
Loading…
Reference in New Issue
Block a user