]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/table.cpp
Fix #10778 (issue with CJK and language nesting)
[lyx.git] / src / tex2lyx / table.cpp
index 75a031746528e155b828dd72f33dae196b17d024..3cce03df4308561040fb9a1b93018fa64fbfb2ff 100644 (file)
@@ -22,6 +22,7 @@
 #include "support/convert.h"
 #include "support/lstrings.h"
 
+#include <algorithm>
 #include <iostream>
 #include <sstream>
 #include <vector>
@@ -31,9 +32,6 @@ using namespace std;
 
 namespace lyx {
 
-// filled in preamble.cpp
-map<char, int> special_columns;
-
 
 namespace {
 
@@ -147,7 +145,7 @@ public:
 class ltType {
 public:
        // constructor
-       ltType() : topDL(false), bottomDL(false), empty(false) {}
+       ltType() : set(false), topDL(false), bottomDL(false), empty(false) {}
        // we have this header type (is set in the getLT... functions)
        bool set;
        // double borders on top
@@ -420,29 +418,22 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
                                next.special += t.character();
                                next.special += '{' + p.verbatim_item() + '}';
                                break;
-                       default:
+                       default: {
                                // try user defined column types
-                               if (special_columns.find(t.character()) !=
-                                   special_columns.end()) {
-                                       ci2special(next);
-                                       next.special += t.character();
-                                       int const nargs =
-                                               special_columns[t.character()];
-                                       for (int i = 0; i < nargs; ++i)
-                                               next.special += '{' +
-                                                       p.verbatim_item() +
-                                                       '}';
-                                       colinfo.push_back(next);
-                                       next = ColInfo();
-                               } else {
-                                       // unknown column specifier, assume no arguments
-                                       ci2special(next);
-                                       next.special += t.character();
-                                       colinfo.push_back(next);
-                                       next = ColInfo();
-                               }
+                               // unknown column types (nargs == -1) are
+                               // assumed to consume no arguments
+                               ci2special(next);
+                               next.special += t.character();
+                               int const nargs =
+                                       preamble.getSpecialTableColumnArguments(t.character());
+                               for (int i = 0; i < nargs; ++i)
+                                       next.special += '{' +
+                                               p.verbatim_item() + '}';
+                               colinfo.push_back(next);
+                               next = ColInfo();
                                break;
                        }
+                       }
        }
 
        // Maybe we have some column separators that need to be added to the