From 9c54ee6f0dc726499841d8200ff3095092585c5d Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 3 Jan 2015 17:06:39 +0100 Subject: [PATCH] Handle unknown table column specifiers (bug #9311) Previously tex2lyx did ignore table columns if the column specifier was unknown. This can lead to data loss, and now it does not ignore these columns, but assumes that the column specifiers use only once character. This can still lead to data loss, but less often. --- src/tex2lyx/table.cpp | 10 +- src/tex2lyx/test/test-insets.lyx.lyx | 319 +++++++++++++++++++++++++++ src/tex2lyx/test/test-insets.tex | 18 ++ status.21x | 2 + 4 files changed, 346 insertions(+), 3 deletions(-) diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index eed7bb91c8..75a0317465 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -434,9 +434,13 @@ void handle_colalign(Parser & p, vector & colinfo, '}'; colinfo.push_back(next); next = ColInfo(); - } else - cerr << "Ignoring column specification" - " '" << t << "'." << endl; + } else { + // unknown column specifier, assume no arguments + ci2special(next); + next.special += t.character(); + colinfo.push_back(next); + next = ColInfo(); + } break; } } diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index 25f372b5dd..cadde5b483 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -4974,6 +4974,325 @@ in % of pixel size \end_inset +\end_layout + +\begin_layout Standard +A table using dcolumn: +\end_layout + +\begin_layout Standard + +\begin_inset Float table +wide false +sideways false +status open + + +\begin_layout Standard + +\begin_inset Tabular + + + + + + + + + +\begin_inset Text + +\begin_layout Standard +One +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +Two +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Three +\family default + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Four +\family default + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Five +\family default + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +one +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +two +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +three +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +four +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +five +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +He +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +2.77234 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +45672. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +0.69 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +C +\begin_inset Foot +status collapsed + + +\begin_layout Standard +Some tables require footnotes. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +C +\begin_inset Foot +status collapsed + + +\begin_layout Standard +Some tables need more than one footnote. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +12537.64 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +37.66345 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +86.37 +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\end_inset + + \end_layout \begin_layout Section diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index 5fd3930307..e6249fc665 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -34,6 +34,7 @@ \usepackage{booktabs} \usepackage{multirow} \usepackage{hhline} +\usepackage{dcolumn} \usepackage{pdfpages} \usepackage{textcomp} \usepackage{amssymb} @@ -452,6 +453,23 @@ in \% of pixel size & 76.3 & 95.9 & 92.3\tabularnewline \end{tabular} \end{table} +A table using dcolumn: + +\begin{table} +\begin{tabular}{ccddd} +One&Two& +\multicolumn{1}{c}{\textrm{Three}}& +\multicolumn{1}{c}{\textrm{Four}}& +\multicolumn{1}{c}{\textrm{Five}}\\ +\hline +one&two&\mbox{three}&\mbox{four}&\mbox{five}\\ +He&2& 2.77234 & 45672. & 0.69 \\ +C\footnote{Some tables require footnotes.} +&C\footnote{Some tables need more than one footnote.} +& 12537.64 & 37.66345 & 86.37 \\ +\end{tabular} +\end{table} + \section{Macros} diff --git a/status.21x b/status.21x index d83eb4b660..db7e55f411 100644 --- a/status.21x +++ b/status.21x @@ -182,6 +182,8 @@ What's new * TEX2LYX +- Do not ignore table columns with unknown column specifiers (bug 9311). + * ADVANCED FIND AND REPLACE -- 2.39.5