commit 20663fb3b8ef5d3e3b3fbe9fba25feae7f2f08e4
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Aug 24 09:39:46 2018 +0200

    tex2lyx: also support rotated xltabulars
---
 src/tex2lyx/Context.cpp |    2 +-
 src/tex2lyx/Context.h   |    4 ++--
 src/tex2lyx/table.cpp   |    5 +----
 src/tex2lyx/text.cpp    |   11 ++++++-----
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/tex2lyx/Context.cpp b/src/tex2lyx/Context.cpp
index 5112401..f28911a 100644
--- a/src/tex2lyx/Context.cpp
+++ b/src/tex2lyx/Context.cpp
@@ -85,7 +85,7 @@ Context::Context(bool need_layout_,
          new_layout_allowed(true), merging_hyphens_allowed(true),
          textclass(textclass_),
          layout(layout_), parent_layout(parent_layout_),
-         font(font_), rotlongtable(false)
+         font(font_), tablerotation(0)
 {
        if (!layout)
                layout = &textclass.defaultLayout();
diff --git a/src/tex2lyx/Context.h b/src/tex2lyx/Context.h
index 4fd1ff2..64d69e3 100644
--- a/src/tex2lyx/Context.h
+++ b/src/tex2lyx/Context.h
@@ -165,8 +165,8 @@ public:
        TeXFont font;
        /// font attributes of normal text
        static TeXFont normalfont;
-       /// A rotated longtable
-       bool rotlongtable;
+       /// Table rotation angle
+       int tablerotation;
 
 private:
        void begin_layout(std::ostream & os, Layout const * const & l);
diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp
index c432a2c..8beeb2d 100644
--- a/src/tex2lyx/table.cpp
+++ b/src/tex2lyx/table.cpp
@@ -1416,13 +1416,10 @@ void handle_tabular(Parser & p, ostream & os, string 
const & name,
 
        //cerr << "// output what we have\n";
        // output what we have
-       string rotate = "0";
-       if (is_long_tabular && context.rotlongtable)
-               rotate = "90";
        os << "\n<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
           << "\" columns=\"" << colinfo.size() << "\">\n";
        os << "<features"
-          << write_attribute("rotate", rotate)
+          << write_attribute("rotate", context.tablerotation)
           << write_attribute("booktabs", booktabs)
           << write_attribute("islongtable", is_long_tabular);
        if (is_long_tabular) {
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 3533a50..61d7a7b 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -1968,16 +1968,17 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
                        p.get_token();
                        p.get_token();
                        string envname = p.getArg('{', '}');
-                       if (envname == "longtable") {
+                       if (envname == "longtable" || envname == "xltabular") {
                                // Now we check if the longtable is the only 
content
                                // of the landscape environment
+                               string const ltenv = envname;
                                while (!found_end && !end_longtable && 
p.good()) {
                                        envname = p.next_token().cat() == 
catBegin
                                                        ? p.getArg('{', '}') : 
string();
                                        Token const & t = p.get_token();
                                        p.skip_spaces();
                                        end_longtable = t.asInput() != "\\end"
-                                                       && envname == 
"longtable";
+                                                       && envname == ltenv;
                                        found_end = t.asInput() == "\\end"
                                                        && envname == 
"landscape";
                                }
@@ -1990,10 +1991,10 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
                                if (only_longtable) {
                                        p.popPosition();
                                        p.skip_spaces();
-                                       bool const save_rotlongtable = 
parent_context.rotlongtable;
-                                       parent_context.rotlongtable = true;
+                                       int const save_tablerotation = 
parent_context.tablerotation;
+                                       parent_context.tablerotation = 90;
                                        parse_text(p, os, FLAG_END, outer, 
parent_context);
-                                       parent_context.rotlongtable = 
save_rotlongtable;
+                                       parent_context.tablerotation = 
save_tablerotation;
                                        p.skip_spaces();
                                        break;
                                }

Reply via email to