mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Move global variable to preamble
This will be needed in the future, when I need to parse the preamble twice for detecting japanese encoding (bug #8218).
This commit is contained in:
parent
41405babc5
commit
59b705dcd9
@ -39,9 +39,6 @@ using namespace lyx::support;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
// special columntypes
|
|
||||||
extern map<char, int> special_columns;
|
|
||||||
|
|
||||||
Preamble preamble;
|
Preamble preamble;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -402,6 +399,15 @@ Author const & Preamble::getAuthor(std::string const & name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Preamble::getSpecialTableColumnArguments(char c) const
|
||||||
|
{
|
||||||
|
map<char, int>::const_iterator it = special_columns_.find(c);
|
||||||
|
if (it == special_columns_.end())
|
||||||
|
return -1;
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Preamble::add_package(string const & name, vector<string> & options)
|
void Preamble::add_package(string const & name, vector<string> & options)
|
||||||
{
|
{
|
||||||
// every package inherits the global options
|
// every package inherits the global options
|
||||||
@ -1240,7 +1246,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
TeX2LyXDocClass & tc)
|
TeX2LyXDocClass & tc)
|
||||||
{
|
{
|
||||||
// initialize fixed types
|
// initialize fixed types
|
||||||
special_columns['D'] = 3;
|
special_columns_['D'] = 3;
|
||||||
bool is_full_document = false;
|
bool is_full_document = false;
|
||||||
bool is_lyx_file = false;
|
bool is_lyx_file = false;
|
||||||
bool in_lyx_preamble = false;
|
bool in_lyx_preamble = false;
|
||||||
@ -1705,7 +1711,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
istringstream is(string(opts, 1));
|
istringstream is(string(opts, 1));
|
||||||
is >> nargs;
|
is >> nargs;
|
||||||
}
|
}
|
||||||
special_columns[name[0]] = nargs;
|
special_columns_[name[0]] = nargs;
|
||||||
h_preamble << "\\newcolumntype{" << name << "}";
|
h_preamble << "\\newcolumntype{" << name << "}";
|
||||||
if (nargs)
|
if (nargs)
|
||||||
h_preamble << "[" << nargs << "]";
|
h_preamble << "[" << nargs << "]";
|
||||||
|
@ -85,6 +85,9 @@ public:
|
|||||||
void registerAuthor(std::string const & name);
|
void registerAuthor(std::string const & name);
|
||||||
/// Get author named \p name (must be registered first)
|
/// Get author named \p name (must be registered first)
|
||||||
Author const & getAuthor(std::string const & name) const;
|
Author const & getAuthor(std::string const & name) const;
|
||||||
|
/// Get number of arguments of special table column type \c or -1
|
||||||
|
/// if no column type \p c exists
|
||||||
|
int getSpecialTableColumnArguments(char c) const;
|
||||||
|
|
||||||
/// Parses the LaTeX preamble into internal data
|
/// Parses the LaTeX preamble into internal data
|
||||||
void parse(Parser & p, std::string const & forceclass,
|
void parse(Parser & p, std::string const & forceclass,
|
||||||
@ -214,7 +217,10 @@ private:
|
|||||||
///
|
///
|
||||||
void handle_if(Parser & p, bool in_lyx_preamble);
|
void handle_if(Parser & p, bool in_lyx_preamble);
|
||||||
|
|
||||||
|
///
|
||||||
AuthorList authors_;
|
AuthorList authors_;
|
||||||
|
/// special table column types
|
||||||
|
std::map<char, int> special_columns_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,9 +31,6 @@ using namespace std;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
// filled in preamble.cpp
|
|
||||||
map<char, int> special_columns;
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -420,30 +417,23 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
|
|||||||
next.special += t.character();
|
next.special += t.character();
|
||||||
next.special += '{' + p.verbatim_item() + '}';
|
next.special += '{' + p.verbatim_item() + '}';
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
// try user defined column types
|
// try user defined column types
|
||||||
if (special_columns.find(t.character()) !=
|
// unknown column types (nargs == -1) are
|
||||||
special_columns.end()) {
|
// assumed to consume no arguments
|
||||||
ci2special(next);
|
ci2special(next);
|
||||||
next.special += t.character();
|
next.special += t.character();
|
||||||
int const nargs =
|
int const nargs =
|
||||||
special_columns[t.character()];
|
preamble.getSpecialTableColumnArguments(t.character());
|
||||||
for (int i = 0; i < nargs; ++i)
|
for (int i = 0; i < nargs; ++i)
|
||||||
next.special += '{' +
|
next.special += '{' +
|
||||||
p.verbatim_item() +
|
p.verbatim_item() + '}';
|
||||||
'}';
|
|
||||||
colinfo.push_back(next);
|
colinfo.push_back(next);
|
||||||
next = ColInfo();
|
next = ColInfo();
|
||||||
} else {
|
|
||||||
// unknown column specifier, assume no arguments
|
|
||||||
ci2special(next);
|
|
||||||
next.special += t.character();
|
|
||||||
colinfo.push_back(next);
|
|
||||||
next = ColInfo();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Maybe we have some column separators that need to be added to the
|
// Maybe we have some column separators that need to be added to the
|
||||||
// last column?
|
// last column?
|
||||||
|
Loading…
Reference in New Issue
Block a user