Increase tex2lyx output format to 275.

Nothing to do for 274: tex2lyx did not implement the special whitespace
handling that would have been needed for the old format.
Use the scaleBeforeRotation keyword for graphics (275).
This fixes actually a bug with the old version, that implicitly converted
all graphics to scale before rotation.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36843 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2010-12-12 17:47:36 +00:00
parent 19c27cba66
commit 04233bf5eb
2 changed files with 25 additions and 10 deletions

View File

@ -114,7 +114,7 @@ extern CommandMap known_math_environments;
/// ///
extern bool noweb_mode; extern bool noweb_mode;
/// LyX format that is created by tex2lyx /// LyX format that is created by tex2lyx
int const LYX_FORMAT = 273; int const LYX_FORMAT = 275;
/// path of the master .tex file /// path of the master .tex file
extern std::string getMasterFilePath(); extern std::string getMasterFilePath();

View File

@ -199,19 +199,20 @@ char const * const known_coded_spaces[] = { "space{}", "space{}",
"negthinspace{}", 0}; "negthinspace{}", 0};
/// splits "x=z, y=b" into a map /// splits "x=z, y=b" into a map and an ordered keyword vector
map<string, string> split_map(string const & s) void split_map(string const & s, map<string, string> & res, vector<string> & keys)
{ {
map<string, string> res;
vector<string> v; vector<string> v;
split(s, v); split(s, v);
res.clear();
keys.resize(v.size());
for (size_t i = 0; i < v.size(); ++i) { for (size_t i = 0; i < v.size(); ++i) {
size_t const pos = v[i].find('='); size_t const pos = v[i].find('=');
string const index = v[i].substr(0, pos); string const index = trim(v[i].substr(0, pos));
string const value = v[i].substr(pos + 1, string::npos); string const value = trim(v[i].substr(pos + 1, string::npos));
res[trim(index)] = trim(value); res[index] = value;
keys[i] = index;
} }
return res;
} }
@ -1655,7 +1656,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
bool const clip = p.next_token().asInput() == "*"; bool const clip = p.next_token().asInput() == "*";
if (clip) if (clip)
p.get_token(); p.get_token();
map<string, string> opts = split_map(p.getArg('[', ']')); string const arg = p.getArg('[', ']');
map<string, string> opts;
vector<string> keys;
split_map(arg, opts, keys);
if (clip) if (clip)
opts["clip"] = string(); opts["clip"] = string();
string name = normalize_filename(p.verbatim_item()); string name = normalize_filename(p.verbatim_item());
@ -1715,9 +1719,20 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
val = val*100; val = val*100;
os << "\tscale " << val << '\n'; os << "\tscale " << val << '\n';
} }
if (opts.find("angle") != opts.end()) if (opts.find("angle") != opts.end()) {
os << "\trotateAngle " os << "\trotateAngle "
<< opts["angle"] << '\n'; << opts["angle"] << '\n';
vector<string>::const_iterator a =
find(keys.begin(), keys.end(), "angle");
vector<string>::const_iterator s =
find(keys.begin(), keys.end(), "width");
if (s == keys.end())
s = find(keys.begin(), keys.end(), "height");
if (s == keys.end())
s = find(keys.begin(), keys.end(), "scale");
if (s != keys.end() && distance(s, a) > 0)
os << "\tscaleBeforeRotation\n";
}
if (opts.find("origin") != opts.end()) { if (opts.find("origin") != opts.end()) {
ostringstream ss; ostringstream ss;
string const opt = opts["origin"]; string const opt = opts["origin"];