commit b1e5663333f7c9bd806c74fdb85419e45d3615e2
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon Sep 10 16:21:42 2018 +0200

    tex2lyx: Add support for horizontal longtabular alignment
---
 src/tex2lyx/TODO.txt  |    1 -
 src/tex2lyx/table.cpp |    5 ++++-
 src/tex2lyx/tex2lyx.h |    3 ++-
 src/tex2lyx/text.cpp  |   12 +++++++++++-
 status.23x            |    2 ++
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index c33b496..fa2bd7a 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -25,7 +25,6 @@ Format LaTeX feature                        LyX feature
        % !BIB program = 
        comment understood by some TeX editors
 358    custom makeindex command             \index_command
-363    horizontal longtable alignment       InsetTabular
 364    branch file name suffix              \filename_suffix
 371    automatic mhchem loading             \use_mhchem
 390    forward/reverse search               \forward_search, \forward_macro
diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp
index a3cabfd..d3392b0 100644
--- a/src/tex2lyx/table.cpp
+++ b/src/tex2lyx/table.cpp
@@ -847,7 +847,8 @@ void handle_hline_below(RowInfo & ri, vector<CellInfo> & ci)
 
 
 void handle_tabular(Parser & p, ostream & os, string const & name,
-                    string const & tabularwidth, Context & context)
+                    string const & tabularwidth, string const & halign,
+                    Context & context)
 {
        bool const is_long_tabular(name == "longtable");
        bool booktabs = false;
@@ -1417,6 +1418,8 @@ void handle_tabular(Parser & p, ostream & os, string 
const & name,
                   << write_attribute("lastFootTopDL", endlastfoot.topDL)
                   << write_attribute("lastFootBottomDL", endlastfoot.bottomDL)
                   << write_attribute("lastFootEmpty", endlastfoot.empty);
+               if (!halign.empty())
+                       os << write_attribute("longtabularalignment", halign);
        } else
                os << write_attribute("tabularvalignment", tabularvalignment)
                   << write_attribute("tabularwidth", tabularwidth);
diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h
index 1791c2f..968e157 100644
--- a/src/tex2lyx/tex2lyx.h
+++ b/src/tex2lyx/tex2lyx.h
@@ -81,7 +81,8 @@ void parse_math(Parser & p, std::ostream & os, unsigned 
flags, mode_type mode);
 
 /// in table.cpp
 void handle_tabular(Parser & p, std::ostream & os, std::string const & name,
-                    std::string const & width, Context & context);
+                    std::string const & width, std::string const & halign,
+                    Context & context);
 
 
 /// in tex2lyx.cpp
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index b85020d..85e2462 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -1638,13 +1638,23 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
        else if (unstarred_name == "tabular" || name == "longtable") {
                eat_whitespace(p, os, parent_context, false);
                string width = "0pt";
+               string halign;
+               if (name == "longtable" && p.hasOpt()) {
+                       string const opt = p.getArg('[', ']');
+                       if (opt == "c")
+                               halign = "center";
+                       else if (opt == "l")
+                               halign = "left";
+                       else if (opt == "r")
+                               halign = "right";
+               }
                if (name == "tabular*") {
                        width = lyx::translate_len(p.getArg('{', '}'));
                        eat_whitespace(p, os, parent_context, false);
                }
                parent_context.check_layout(os);
                begin_inset(os, "Tabular ");
-               handle_tabular(p, os, name, width, parent_context);
+               handle_tabular(p, os, name, width, halign, parent_context);
                end_inset(os);
                p.skip_spaces();
        }
diff --git a/status.23x b/status.23x
index 3a88190..2daf9c7 100644
--- a/status.23x
+++ b/status.23x
@@ -37,6 +37,8 @@ What's new
 
 - Improve import of titling commands other than \maketitle (bug 6461).
 
+- Add support for horizontal longtabular alignment.
+
 
 
 * USER INTERFACE

Reply via email to