]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/table.cpp
FindAdv: Comments
[lyx.git] / src / tex2lyx / table.cpp
index 217014c36ab7cdf03a4cead5d07b864b00db7f3c..b6d4bac84258c3c6c37cb5e6129204ea1189dcb5 100644 (file)
@@ -39,7 +39,7 @@ namespace {
 class ColInfo {
 public:
        ColInfo() : align('n'), valign('n'), rightlines(0), leftlines(0),
-               varwidth(false), decimal_point('\0') {}
+               varwidth(false), decimal_point('\0'), vcolumn(false) {}
        /// column alignment
        char align;
        /// vertical alignment
@@ -56,6 +56,8 @@ public:
        bool varwidth;
        /// decimal separator
        char decimal_point;
+       /// V column type
+       bool vcolumn;
 };
 
 
@@ -298,7 +300,9 @@ void ci2special(ColInfo & ci)
                        ci.special += ">{\\centering" + arraybackslash + "}";
                        break;
                }
-               if (ci.varwidth)
+               if (ci.vcolumn)
+                       ci.special += 'V';
+               else if (ci.varwidth)
                        ci.special += 'X';
                else if (ci.valign == 'n')
                        ci.special += 'p';
@@ -384,6 +388,21 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
                                colinfo.push_back(next);
                                next = ColInfo();
                                break;
+                       case 'V': {
+                               // V column type (varwidth package)
+                               string const s = trimSpaceAndEol(p.verbatim_item());
+                               // V{\linewidth} is treated as a normal column
+                               // (which allows for line breaks). The V type is
+                               // automatically set by LyX in this case
+                               if (s != "\\linewidth" || !next.special.empty()) {
+                                       next.vcolumn = true;
+                                       next.width = s;
+                                       ci2special(next);
+                               }
+                               colinfo.push_back(next);
+                               next = ColInfo();
+                               break;
+                       }
                        case 'p':
                        case 'b':
                        case 'm':
@@ -413,7 +432,7 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
                                                next.special += '|';
                                } else if (colinfo.back().special.empty())
                                        ++colinfo.back().rightlines;
-                               else if (next.special.empty())
+                               else if (next.special.empty() && p.next_token().cat() != catEnd)
                                        ++next.leftlines;
                                else
                                        colinfo.back().special += '|';
@@ -477,14 +496,14 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
                        case '@':
                                // text instead of the column spacing
                        case '!': {
-                                       // text in addition to the column spacing
-                                       string const arg =  p.verbatim_item();
-                                       next.special += t.character();
-                                       next.special += '{' + arg + '}';
-                                       string const sarg = arg.size() > 2 ? arg.substr(0, arg.size() - 1) : string();
-                                       if (t.character() == '@' && sarg == "\\extracolsep{0pt}")
-                                               next.decimal_point = arg.back();
-                                       break;
+                               // text in addition to the column spacing
+                               string const arg =  p.verbatim_item();
+                               next.special += t.character();
+                               next.special += '{' + arg + '}';
+                               string const sarg = arg.size() > 2 ? arg.substr(0, arg.size() - 1) : string();
+                               if (t.character() == '@' && sarg == "\\extracolsep{0pt}")
+                                       next.decimal_point = arg.back();
+                               break;
                        }
                        default: {
                                // try user defined column types