X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftex2lyx%2Ftable.cpp;h=79781c74951dd5ef46d426a2fd87982082f12e64;hb=8e7b5eebf0ef9742e5f6983d8f55f563c12a31ab;hp=7ba5344d1324c9d6ba697ae4444022a26fe7d290;hpb=9236a93894f6a182eb17a219b216eff747e50a27;p=lyx.git diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index 7ba5344d13..79781c7495 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -209,6 +209,14 @@ string const write_attribute(string const & name, string const & s) } +string const write_attribute(string const & name, int const & i) +{ + // we write only true attribute values so we remove a bit of the + // file format bloat for tabulars. + return i ? write_attribute(name, convert(i)) : string(); +} + + /*! rather brutish way to code table structure in a string: \verbatim @@ -1156,8 +1164,20 @@ void handle_tabular(Parser & p, ostream & os, string const & name, cellinfo[row][col].content += os.str(); // add dummy cells for multicol - for (size_t i = 0; i < ncells - 1 && col < colinfo.size(); ++i) { + for (size_t i = 0; i < ncells - 1; ++i) { ++col; + if (col >= colinfo.size()) { + cerr << "The cell '" + << cells[cell] + << "' specifies " + << convert(ncells) + << " columns while the table has only " + << convert(colinfo.size()) + << " columns!" + << " Therefore the surplus columns will be ignored." + << endl; + break; + } cellinfo[row][col].multi = CELL_PART_OF_MULTICOLUMN; cellinfo[row][col].align = 'c'; } @@ -1194,11 +1214,43 @@ void handle_tabular(Parser & p, ostream & os, string const & name, for (size_t c = 1; c < colinfo.size(); ++c) cellinfo[row][c].multi = CELL_PART_OF_MULTICOLUMN; } else { + bool turn = false; + int rotate = 0; + if (p.next_token().cs() == "begin") { + p.pushPosition(); + p.get_token(); + string const env = p.getArg('{', '}'); + if (env == "sideways" || env == "turn") { + string angle = "90"; + if (env == "turn") { + turn = true; + angle = p.getArg('{', '}'); + } + active_environments.push_back(env); + p.verbatimEnvironment(env); + active_environments.pop_back(); + p.skip_spaces(); + if (!p.good() && support::isStrInt(angle)) + rotate = convert(angle); + } + p.popPosition(); + } cellinfo[row][col].leftlines = colinfo[col].leftlines; cellinfo[row][col].rightlines = colinfo[col].rightlines; cellinfo[row][col].align = colinfo[col].align; ostringstream os; - parse_text_in_inset(p, os, FLAG_CELL, false, context); + if (rotate != 0) { + cellinfo[row][col].rotate = rotate; + p.get_token(); + active_environments.push_back(p.getArg('{', '}')); + if (turn) + p.getArg('{', '}'); + parse_text_in_inset(p, os, FLAG_END, false, context); + active_environments.pop_back(); + preamble.registerAutomaticallyLoadedPackage("rotating"); + } else { + parse_text_in_inset(p, os, FLAG_CELL, false, context); + } cellinfo[row][col].content += os.str(); } } @@ -1269,10 +1321,11 @@ void handle_tabular(Parser & p, ostream & os, string const & name, //cerr << "// output what we have\n"; // output what we have + string const rotate = "0"; os << "\n\n"; os << "