mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
handle special columns
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7232 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
83a3833d60
commit
6a970ad5d8
@ -13,6 +13,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -24,6 +25,8 @@ using std::ostringstream;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
// special columntypes
|
||||||
|
extern std::map<char, int> special_columns;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -127,8 +130,8 @@ void handle_package(string const & name, string const & options)
|
|||||||
|
|
||||||
void end_preamble(ostream & os)
|
void end_preamble(ostream & os)
|
||||||
{
|
{
|
||||||
os << "# tex2lyx 0.0.2 created this file\n"
|
os << "# tex2lyx 0.0.3 created this file\n"
|
||||||
<< "\\lyxformat 222\n"
|
<< "\\lyxformat 224\n"
|
||||||
<< "\\textclass " << h_textclass << "\n"
|
<< "\\textclass " << h_textclass << "\n"
|
||||||
<< "\\begin_preamble\n" << h_preamble.str() << "\n\\end_preamble\n";
|
<< "\\begin_preamble\n" << h_preamble.str() << "\n\\end_preamble\n";
|
||||||
if (h_options.size())
|
if (h_options.size())
|
||||||
@ -284,6 +287,23 @@ void parse_preamble(Parser & p, ostream & os)
|
|||||||
h_preamble << "\\def\\" << name << '{' << p.verbatim_item() << "}\n";
|
h_preamble << "\\def\\" << name << '{' << p.verbatim_item() << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (t.cs() == "newcolumntype") {
|
||||||
|
string const name = p.getArg('{', '}');
|
||||||
|
trim(name);
|
||||||
|
int nargs = 0;
|
||||||
|
string opts = p.getOpt();
|
||||||
|
if (opts.size()) {
|
||||||
|
istringstream is(string(opts, 1));
|
||||||
|
//cerr << "opt: " << is.str() << "\n";
|
||||||
|
is >> nargs;
|
||||||
|
}
|
||||||
|
special_columns[name[0]] = nargs;
|
||||||
|
h_preamble << "\\newcolumntype{" << name << "}";
|
||||||
|
if (nargs)
|
||||||
|
h_preamble << "[" << nargs << "]";
|
||||||
|
h_preamble << "{" << p.verbatim_item() << "}\n";
|
||||||
|
}
|
||||||
|
|
||||||
else if (t.cs() == "setcounter") {
|
else if (t.cs() == "setcounter") {
|
||||||
string const name = p.getArg('{', '}');
|
string const name = p.getArg('{', '}');
|
||||||
string const content = p.getArg('{', '}');
|
string const content = p.getArg('{', '}');
|
||||||
@ -303,7 +323,7 @@ void parse_preamble(Parser & p, ostream & os)
|
|||||||
else if (name == "parindent")
|
else if (name == "parindent")
|
||||||
h_paragraph_separation = "skip";
|
h_paragraph_separation = "skip";
|
||||||
else
|
else
|
||||||
h_preamble << "\\setlength{" + name + "}{" + content + "}\n";
|
h_preamble << "\\setlength{" << name << "}{" << content << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "par")
|
else if (t.cs() == "par")
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -21,9 +22,15 @@ using std::ostream;
|
|||||||
using std::ostringstream;
|
using std::ostringstream;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::map;
|
||||||
|
|
||||||
#include "mathed/math_gridinfo.h"
|
#include "mathed/math_gridinfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
// filled in preamble.C
|
||||||
|
std::map<char, int> special_columns;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int string2int(string const & s, int deflt = 0)
|
int string2int(string const & s, int deflt = 0)
|
||||||
@ -56,7 +63,6 @@ string read_hlines(Parser & p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* rather brutish way to code table structure in a string:
|
/* rather brutish way to code table structure in a string:
|
||||||
|
|
||||||
\begin{tabular}{ccc}
|
\begin{tabular}{ccc}
|
||||||
@ -125,7 +131,19 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if (special_columns.find(t.character()) != special_columns.end()) {
|
||||||
|
ColInfo ci;
|
||||||
|
ci.align = 'c';
|
||||||
|
ci.special += t.character();
|
||||||
|
int const nargs = special_columns[t.character()];
|
||||||
|
for (int i = 0; i < nargs; ++i)
|
||||||
|
ci.special += "{" + p.verbatim_item() + "}";
|
||||||
|
//cerr << "handling special column '" << t << "' " << nargs
|
||||||
|
// << " '" << ci.special << "'\n";
|
||||||
|
colinfo.push_back(ci);
|
||||||
|
} else {
|
||||||
cerr << "ignoring special separator '" << t << "'\n";
|
cerr << "ignoring special separator '" << t << "'\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user