]> git.lyx.org Git - lyx.git/commitdiff
Increase tex2lyx output format to 275.
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 12 Dec 2010 17:47:36 +0000 (17:47 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 12 Dec 2010 17:47:36 +0000 (17:47 +0000)
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

src/tex2lyx/tex2lyx.h
src/tex2lyx/text.cpp

index b51dd68f324e3fdeb84846a395d30ee16d0ff60e..8dfc16f228b8b59129c85e2bf34dddf52b61b713 100644 (file)
@@ -114,7 +114,7 @@ extern CommandMap known_math_environments;
 ///
 extern bool noweb_mode;
 /// LyX format that is created by tex2lyx
-int const LYX_FORMAT = 273;
+int const LYX_FORMAT = 275;
 
 /// path of the master .tex file
 extern std::string getMasterFilePath();
index 1fb49af13dfd825bed575860b64ec235fc3231fc..9784a3ab07bfdb38c17ee4c74beb473bc8fafcec 100644 (file)
@@ -199,19 +199,20 @@ char const * const known_coded_spaces[] = { "space{}", "space{}",
 "negthinspace{}", 0};
 
 
-/// splits "x=z, y=b" into a map
-map<string, string> split_map(string const & s)
+/// splits "x=z, y=b" into a map and an ordered keyword vector
+void split_map(string const & s, map<string, string> & res, vector<string> & keys)
 {
-       map<string, string> res;
        vector<string> v;
        split(s, v);
+       res.clear();
+       keys.resize(v.size());
        for (size_t i = 0; i < v.size(); ++i) {
                size_t const pos   = v[i].find('=');
-               string const index = v[i].substr(0, pos);
-               string const value = v[i].substr(pos + 1, string::npos);
-               res[trim(index)] = trim(value);
+               string const index = trim(v[i].substr(0, pos));
+               string const value = trim(v[i].substr(pos + 1, string::npos));
+               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() == "*";
                        if (clip)
                                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)
                                opts["clip"] = string();
                        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;
                                os << "\tscale " << val << '\n';
                        }
-                       if (opts.find("angle") != opts.end())
+                       if (opts.find("angle") != opts.end()) {
                                os << "\trotateAngle "
                                   << 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()) {
                                ostringstream ss;
                                string const opt = opts["origin"];