mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
Fix bug 3067: Special column attributes can contain non-ascii characters,
so store them in a docstring. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16537 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0b995c888f
commit
31bc611f34
@ -173,7 +173,7 @@ void QTabular::update_contents()
|
||||
update_borders();
|
||||
|
||||
LyXLength pwidth;
|
||||
string special;
|
||||
docstring special;
|
||||
|
||||
if (multicol) {
|
||||
special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
|
||||
@ -424,8 +424,8 @@ void QTabular::closeGUI()
|
||||
width2 = llen.asString();
|
||||
|
||||
// apply the special alignment
|
||||
string const sa1 = fromqstr(dialog_->specialAlignmentED->text());
|
||||
string sa2;
|
||||
docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
|
||||
docstring sa2;
|
||||
|
||||
if (multicol)
|
||||
sa2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
|
||||
@ -434,9 +434,9 @@ void QTabular::closeGUI()
|
||||
|
||||
if (sa1 != sa2) {
|
||||
if (multicol)
|
||||
controller().set(LyXTabular::SET_SPECIAL_MULTI, sa1);
|
||||
controller().set(LyXTabular::SET_SPECIAL_MULTI, to_utf8(sa1));
|
||||
else
|
||||
controller().set(LyXTabular::SET_SPECIAL_COLUMN, sa1);
|
||||
controller().set(LyXTabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
|
||||
}
|
||||
|
||||
if (width != width2) {
|
||||
|
@ -355,7 +355,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
|
||||
docstring linebuf = trim(linebuf0);
|
||||
if (linebuf.empty())
|
||||
continue;
|
||||
if (prefixIs(linebuf, from_ascii("@"))) {
|
||||
if (prefixIs(linebuf, '@')) {
|
||||
linebuf = subst(linebuf, '{', '(');
|
||||
docstring tmp;
|
||||
linebuf = split(linebuf, tmp, '(');
|
||||
|
@ -1434,7 +1434,7 @@ void InsetTabular::tabularFeatures(LCursor & cur,
|
||||
|
||||
case LyXTabular::SET_SPECIAL_COLUMN:
|
||||
case LyXTabular::SET_SPECIAL_MULTI:
|
||||
tabular.setAlignSpecial(cur.idx(),value,feature);
|
||||
tabular.setAlignSpecial(cur.idx(), from_utf8(value), feature);
|
||||
break;
|
||||
|
||||
case LyXTabular::APPEND_ROW:
|
||||
|
@ -423,6 +423,14 @@ docstring const ascii_lowercase(docstring const & a)
|
||||
}
|
||||
|
||||
|
||||
bool prefixIs(docstring const & a, char_type c)
|
||||
{
|
||||
if (a.empty())
|
||||
return false;
|
||||
return a[0] == c;
|
||||
}
|
||||
|
||||
|
||||
bool prefixIs(string const & a, string const & pre)
|
||||
{
|
||||
string::size_type const prelen = pre.length();
|
||||
@ -459,6 +467,14 @@ bool suffixIs(string const & a, char c)
|
||||
}
|
||||
|
||||
|
||||
bool suffixIs(docstring const & a, char_type c)
|
||||
{
|
||||
if (a.empty())
|
||||
return false;
|
||||
return a[a.length() - 1] == c;
|
||||
}
|
||||
|
||||
|
||||
bool suffixIs(string const & a, string const & suf)
|
||||
{
|
||||
string::size_type const suflen = suf.length();
|
||||
|
@ -98,12 +98,16 @@ docstring const lowercase(docstring const &);
|
||||
///
|
||||
std::string const uppercase(std::string const &);
|
||||
|
||||
/// Does the string start with this prefix?
|
||||
bool prefixIs(docstring const &, char_type);
|
||||
|
||||
/// Does the std::string start with this prefix?
|
||||
bool prefixIs(std::string const &, std::string const &);
|
||||
bool prefixIs(lyx::docstring const &, lyx::docstring const &);
|
||||
bool prefixIs(docstring const &, docstring const &);
|
||||
|
||||
/// Does the string end with this char?
|
||||
bool suffixIs(std::string const &, char);
|
||||
bool suffixIs(docstring const &, char_type);
|
||||
|
||||
/// Does the std::string end with this suffix?
|
||||
bool suffixIs(std::string const &, std::string const &);
|
||||
|
@ -84,6 +84,13 @@ string const write_attribute(string const & name, string const & t)
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
string const write_attribute(string const & name, docstring const & t)
|
||||
{
|
||||
return t.empty() ? string() : " " + name + "=\"" + to_utf8(t) + "\"";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
string const write_attribute(string const & name, bool const & b)
|
||||
{
|
||||
@ -250,6 +257,15 @@ bool getTokenValue(string const & str, char const * token, string & ret)
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, char const * token, docstring & ret)
|
||||
{
|
||||
string tmp;
|
||||
bool const success = getTokenValue(str, token, tmp);
|
||||
ret = from_utf8(tmp);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
bool getTokenValue(string const & str, char const * token, int & num)
|
||||
{
|
||||
string tmp;
|
||||
@ -689,11 +705,11 @@ bool LyXTabular::leftLine(idx_type cell, bool wholecolumn) const
|
||||
{
|
||||
if (cellinfo_of_cell(cell).align_special.empty())
|
||||
return cellinfo_of_cell(cell).left_line;
|
||||
return prefixIs(ltrim(cellinfo_of_cell(cell).align_special), "|");
|
||||
return prefixIs(ltrim(cellinfo_of_cell(cell).align_special), '|');
|
||||
}
|
||||
if (column_info[column_of_cell(cell)].align_special.empty())
|
||||
return column_info[column_of_cell(cell)].left_line;
|
||||
return prefixIs(ltrim(column_info[column_of_cell(cell)].align_special), "|");
|
||||
return prefixIs(ltrim(column_info[column_of_cell(cell)].align_special), '|');
|
||||
}
|
||||
|
||||
|
||||
@ -706,11 +722,11 @@ bool LyXTabular::rightLine(idx_type cell, bool wholecolumn) const
|
||||
{
|
||||
if (cellinfo_of_cell(cell).align_special.empty())
|
||||
return cellinfo_of_cell(cell).right_line;
|
||||
return suffixIs(rtrim(cellinfo_of_cell(cell).align_special), "|");
|
||||
return suffixIs(rtrim(cellinfo_of_cell(cell).align_special), '|');
|
||||
}
|
||||
if (column_info[column_of_cell(cell)].align_special.empty())
|
||||
return column_info[right_column_of_cell(cell)].right_line;
|
||||
return suffixIs(rtrim(column_info[column_of_cell(cell)].align_special), "|");
|
||||
return suffixIs(rtrim(column_info[column_of_cell(cell)].align_special), '|');
|
||||
}
|
||||
|
||||
|
||||
@ -1006,7 +1022,7 @@ bool LyXTabular::setMColumnPWidth(LCursor & cur, idx_type cell,
|
||||
}
|
||||
|
||||
|
||||
void LyXTabular::setAlignSpecial(idx_type cell, string const & special,
|
||||
void LyXTabular::setAlignSpecial(idx_type cell, docstring const & special,
|
||||
LyXTabular::Feature what)
|
||||
{
|
||||
if (what == SET_SPECIAL_MULTI)
|
||||
@ -1101,7 +1117,7 @@ LyXLength const LyXTabular::getMColumnPWidth(idx_type cell) const
|
||||
}
|
||||
|
||||
|
||||
string const LyXTabular::getAlignSpecial(idx_type cell, int what) const
|
||||
docstring const LyXTabular::getAlignSpecial(idx_type cell, int what) const
|
||||
{
|
||||
if (what == SET_SPECIAL_MULTI)
|
||||
return cellinfo_of_cell(cell).align_special;
|
||||
@ -1907,8 +1923,7 @@ int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const
|
||||
if (isMultiColumn(cell)) {
|
||||
os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
|
||||
if (!cellinfo_of_cell(cell).align_special.empty()) {
|
||||
os << from_ascii(cellinfo_of_cell(cell).align_special)
|
||||
<< "}{";
|
||||
os << cellinfo_of_cell(cell).align_special << "}{";
|
||||
} else {
|
||||
if (leftLine(cell) &&
|
||||
(isFirstCellInRow(cell) ||
|
||||
@ -2212,7 +2227,7 @@ int LyXTabular::latex(Buffer const & buf, odocstream & os,
|
||||
os << "\\begin{tabular}{";
|
||||
for (col_type i = 0; i < columns_; ++i) {
|
||||
if (!column_info[i].align_special.empty()) {
|
||||
os << from_ascii(column_info[i].align_special);
|
||||
os << column_info[i].align_special;
|
||||
} else {
|
||||
if (!use_booktabs && column_info[i].left_line)
|
||||
os << '|';
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
///
|
||||
bool setMColumnPWidth(LCursor &, idx_type, LyXLength const &);
|
||||
///
|
||||
void setAlignSpecial(idx_type cell, std::string const & special,
|
||||
void setAlignSpecial(idx_type cell, docstring const & special,
|
||||
Feature what);
|
||||
///
|
||||
LyXAlignment getAlignment(idx_type cell,
|
||||
@ -279,7 +279,7 @@ public:
|
||||
///
|
||||
LyXLength const getMColumnPWidth(idx_type cell) const;
|
||||
///
|
||||
std::string const getAlignSpecial(idx_type cell, int what) const;
|
||||
docstring const getAlignSpecial(idx_type cell, int what) const;
|
||||
///
|
||||
int getWidthOfCell(idx_type cell) const;
|
||||
///
|
||||
@ -454,7 +454,7 @@ public:
|
||||
///
|
||||
bool rotate;
|
||||
///
|
||||
std::string align_special;
|
||||
docstring align_special;
|
||||
///
|
||||
LyXLength p_width; // this is only set for multicolumn!!!
|
||||
///
|
||||
@ -524,7 +524,7 @@ public:
|
||||
///
|
||||
LyXLength p_width;
|
||||
///
|
||||
std::string align_special;
|
||||
docstring align_special;
|
||||
};
|
||||
///
|
||||
typedef std::vector<columnstruct> column_vector;
|
||||
|
Loading…
Reference in New Issue
Block a user