2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file tabular.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
|
* \author Jos<EFBFBD> Matos
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-04-21 15:16:22 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "tabular.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2005-11-28 11:52:03 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "cursor.h"
|
2000-04-21 15:16:22 +00:00
|
|
|
|
#include "debug.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-07-21 11:01:29 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2005-11-28 11:52:03 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetTabular.h"
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2000-04-21 15:16:22 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::prefixIs;
|
|
|
|
|
using support::ltrim;
|
|
|
|
|
using support::rtrim;
|
|
|
|
|
using support::suffixIs;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
using boost::shared_ptr;
|
|
|
|
|
using boost::dynamic_pointer_cast;
|
|
|
|
|
|
2002-06-10 07:57:39 +00:00
|
|
|
|
using std::abs;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::endl;
|
2000-05-04 10:57:00 +00:00
|
|
|
|
using std::getline;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
using std::max;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
|
|
|
|
|
using std::istream;
|
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::ostringstream;
|
2000-05-05 12:39:38 +00:00
|
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2001-06-01 10:53:24 +00:00
|
|
|
|
#ifndef CXX_GLOBAL_CSTD
|
|
|
|
|
using std::strlen;
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
int const WIDTH_OF_LINE = 5;
|
2006-07-03 19:13:56 +00:00
|
|
|
|
int const default_line_space = 10;
|
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2003-07-28 14:09:05 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
string const write_attribute(string const & name, T const & t)
|
|
|
|
|
{
|
|
|
|
|
string const s = tostr(t);
|
|
|
|
|
return s.empty() ? s : " " + name + "=\"" + s + "\"";
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <>
|
2003-07-21 11:01:29 +00:00
|
|
|
|
string const write_attribute(string const & name, string const & t)
|
|
|
|
|
{
|
|
|
|
|
return t.empty() ? t : " " + name + "=\"" + t + "\"";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-05 17:11:32 +00:00
|
|
|
|
template <>
|
|
|
|
|
string const write_attribute(string const & name, docstring const & t)
|
|
|
|
|
{
|
|
|
|
|
return t.empty() ? string() : " " + name + "=\"" + to_utf8(t) + "\"";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <>
|
2003-07-21 11:01:29 +00:00
|
|
|
|
string const write_attribute(string const & name, bool const & b)
|
|
|
|
|
{
|
|
|
|
|
// we write only true attribute values so we remove a bit of the
|
|
|
|
|
// file format bloat for tabulars.
|
2005-01-06 15:40:49 +00:00
|
|
|
|
return b ? write_attribute(name, convert<string>(b)) : string();
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <>
|
2003-07-21 11:01:29 +00:00
|
|
|
|
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.
|
2005-01-06 15:40:49 +00:00
|
|
|
|
return i ? write_attribute(name, convert<string>(i)) : string();
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <>
|
2004-12-03 13:57:50 +00:00
|
|
|
|
string const write_attribute(string const & name, LyXTabular::idx_type const & i)
|
|
|
|
|
{
|
|
|
|
|
// we write only true attribute values so we remove a bit of the
|
|
|
|
|
// file format bloat for tabulars.
|
2005-01-06 15:40:49 +00:00
|
|
|
|
return i ? write_attribute(name, convert<string>(i)) : string();
|
2004-12-03 13:57:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <>
|
2003-07-21 11:01:29 +00:00
|
|
|
|
string const write_attribute(string const & name, LyXLength const & value)
|
|
|
|
|
{
|
|
|
|
|
// we write only the value if we really have one same reson as above.
|
|
|
|
|
return value.zero() ? string() : write_attribute(name, value.asString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const tostr(LyXAlignment const & num)
|
|
|
|
|
{
|
|
|
|
|
switch (num) {
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
return "none";
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
return "block";
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
return "left";
|
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
|
return "center";
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
return "right";
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
return "layout";
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
return "special";
|
|
|
|
|
}
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const tostr(LyXTabular::VAlignment const & num)
|
|
|
|
|
{
|
|
|
|
|
switch (num) {
|
|
|
|
|
case LyXTabular::LYX_VALIGN_TOP:
|
|
|
|
|
return "top";
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LyXTabular::LYX_VALIGN_MIDDLE:
|
|
|
|
|
return "middle";
|
2003-07-21 11:01:29 +00:00
|
|
|
|
case LyXTabular::LYX_VALIGN_BOTTOM:
|
|
|
|
|
return "bottom";
|
|
|
|
|
}
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const tostr(LyXTabular::BoxType const & num)
|
|
|
|
|
{
|
|
|
|
|
switch (num) {
|
|
|
|
|
case LyXTabular::BOX_NONE:
|
|
|
|
|
return "none";
|
|
|
|
|
case LyXTabular::BOX_PARBOX:
|
|
|
|
|
return "parbox";
|
|
|
|
|
case LyXTabular::BOX_MINIPAGE:
|
|
|
|
|
return "minipage";
|
|
|
|
|
}
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-06 14:10:59 +00:00
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
// I would have liked a fromstr template a lot better. (Lgb)
|
|
|
|
|
bool string2type(string const str, LyXAlignment & num)
|
|
|
|
|
{
|
|
|
|
|
if (str == "none")
|
|
|
|
|
num = LYX_ALIGN_NONE;
|
|
|
|
|
else if (str == "block")
|
|
|
|
|
num = LYX_ALIGN_BLOCK;
|
|
|
|
|
else if (str == "left")
|
|
|
|
|
num = LYX_ALIGN_LEFT;
|
|
|
|
|
else if (str == "center")
|
|
|
|
|
num = LYX_ALIGN_CENTER;
|
|
|
|
|
else if (str == "right")
|
|
|
|
|
num = LYX_ALIGN_RIGHT;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool string2type(string const str, LyXTabular::VAlignment & num)
|
|
|
|
|
{
|
|
|
|
|
if (str == "top")
|
|
|
|
|
num = LyXTabular::LYX_VALIGN_TOP;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
else if (str == "middle" )
|
|
|
|
|
num = LyXTabular::LYX_VALIGN_MIDDLE;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
else if (str == "bottom")
|
|
|
|
|
num = LyXTabular::LYX_VALIGN_BOTTOM;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool string2type(string const str, LyXTabular::BoxType & num)
|
|
|
|
|
{
|
|
|
|
|
if (str == "none")
|
|
|
|
|
num = LyXTabular::BOX_NONE;
|
|
|
|
|
else if (str == "parbox")
|
|
|
|
|
num = LyXTabular::BOX_PARBOX;
|
|
|
|
|
else if (str == "minipage")
|
|
|
|
|
num = LyXTabular::BOX_MINIPAGE;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool string2type(string const str, bool & num)
|
|
|
|
|
{
|
|
|
|
|
if (str == "true")
|
|
|
|
|
num = true;
|
|
|
|
|
else if (str == "false")
|
|
|
|
|
num = false;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, string & ret)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
ret.erase();
|
|
|
|
|
size_t token_length = strlen(token);
|
|
|
|
|
string::size_type pos = str.find(token);
|
|
|
|
|
|
|
|
|
|
if (pos == string::npos || pos + token_length + 1 >= str.length()
|
|
|
|
|
|| str[pos + token_length] != '=')
|
|
|
|
|
return false;
|
|
|
|
|
pos += token_length + 1;
|
|
|
|
|
char ch = str[pos];
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (ch != '"' && ch != '\'') { // only read till next space
|
2003-07-21 11:01:29 +00:00
|
|
|
|
ret += ch;
|
|
|
|
|
ch = ' ';
|
|
|
|
|
}
|
2003-10-06 14:10:59 +00:00
|
|
|
|
while (pos < str.length() - 1 && str[++pos] != ch)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
ret += str[pos];
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-05 17:11:32 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, int & num)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
string tmp;
|
|
|
|
|
num = 0;
|
|
|
|
|
if (!getTokenValue(str, token, tmp))
|
|
|
|
|
return false;
|
2005-01-27 21:05:44 +00:00
|
|
|
|
num = convert<int>(tmp);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, LyXAlignment & num)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
string tmp;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return getTokenValue(str, token, tmp) && string2type(tmp, num);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token,
|
2003-07-21 11:01:29 +00:00
|
|
|
|
LyXTabular::VAlignment & num)
|
|
|
|
|
{
|
|
|
|
|
string tmp;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return getTokenValue(str, token, tmp) && string2type(tmp, num);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token,
|
2003-07-21 11:01:29 +00:00
|
|
|
|
LyXTabular::BoxType & num)
|
|
|
|
|
{
|
|
|
|
|
string tmp;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return getTokenValue(str, token, tmp) && string2type(tmp, num);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, bool & flag)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
// set the flag always to false as this should be the default for bools
|
|
|
|
|
// not in the file-format.
|
|
|
|
|
flag = false;
|
|
|
|
|
string tmp;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return getTokenValue(str, token, tmp) && string2type(tmp, flag);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, LyXLength & len)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
{
|
|
|
|
|
// set the lenght to be zero() as default as this it should be if not
|
|
|
|
|
// in the file format.
|
|
|
|
|
len = LyXLength();
|
|
|
|
|
string tmp;
|
2003-12-01 13:35:49 +00:00
|
|
|
|
return getTokenValue(str, token, tmp) && isValidLength(tmp, &len);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-03 19:13:56 +00:00
|
|
|
|
bool getTokenValue(string const & str, char const * token, LyXLength & len, bool & flag)
|
|
|
|
|
{
|
|
|
|
|
len = LyXLength();
|
|
|
|
|
flag = false;
|
|
|
|
|
string tmp;
|
|
|
|
|
if (!getTokenValue(str, token, tmp))
|
|
|
|
|
return false;
|
|
|
|
|
if (tmp == "default") {
|
|
|
|
|
flag = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return isValidLength(tmp, &len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
void l_getline(istream & is, string & str)
|
|
|
|
|
{
|
|
|
|
|
str.erase();
|
|
|
|
|
while (str.empty()) {
|
|
|
|
|
getline(is, str);
|
|
|
|
|
if (!str.empty() && str[str.length() - 1] == '\r')
|
|
|
|
|
str.erase(str.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-03-20 01:22:46 +00:00
|
|
|
|
|
|
|
|
|
} // namespace
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
|
|
|
|
/// Define a few methods for the inner structs
|
|
|
|
|
|
2006-03-29 10:13:40 +00:00
|
|
|
|
LyXTabular::cellstruct::cellstruct(BufferParams const & bp)
|
2004-11-23 23:04:52 +00:00
|
|
|
|
: cellno(0),
|
|
|
|
|
width_of_cell(0),
|
|
|
|
|
multicolumn(LyXTabular::CELL_NORMAL),
|
|
|
|
|
alignment(LYX_ALIGN_CENTER),
|
|
|
|
|
valignment(LYX_VALIGN_TOP),
|
|
|
|
|
top_line(true),
|
|
|
|
|
bottom_line(false),
|
|
|
|
|
left_line(true),
|
|
|
|
|
right_line(false),
|
|
|
|
|
usebox(BOX_NONE),
|
|
|
|
|
rotate(false),
|
|
|
|
|
inset(new InsetText(bp))
|
2006-03-29 10:13:40 +00:00
|
|
|
|
{}
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
|
|
|
|
|
: cellno(cs.cellno),
|
|
|
|
|
width_of_cell(cs.width_of_cell),
|
|
|
|
|
multicolumn(cs.multicolumn),
|
|
|
|
|
alignment(cs.alignment),
|
|
|
|
|
valignment(cs.valignment),
|
|
|
|
|
top_line(cs.top_line),
|
|
|
|
|
bottom_line(cs.bottom_line),
|
|
|
|
|
left_line(cs.left_line),
|
|
|
|
|
right_line(cs.right_line),
|
|
|
|
|
usebox(cs.usebox),
|
|
|
|
|
rotate(cs.rotate),
|
|
|
|
|
align_special(cs.align_special),
|
|
|
|
|
p_width(cs.p_width),
|
|
|
|
|
inset(dynamic_cast<InsetText*>(cs.inset->clone().release()))
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LyXTabular::cellstruct &
|
|
|
|
|
LyXTabular::cellstruct::operator=(cellstruct cs)
|
|
|
|
|
{
|
|
|
|
|
swap(cs);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
LyXTabular::cellstruct::swap(cellstruct & rhs)
|
|
|
|
|
{
|
|
|
|
|
std::swap(cellno, rhs.cellno);
|
|
|
|
|
std::swap(width_of_cell, rhs.width_of_cell);
|
|
|
|
|
std::swap(multicolumn, rhs.multicolumn);
|
|
|
|
|
std::swap(alignment, rhs.alignment);
|
|
|
|
|
std::swap(valignment, rhs.valignment);
|
|
|
|
|
std::swap(top_line, rhs.top_line);
|
|
|
|
|
std::swap(bottom_line, rhs.bottom_line);
|
|
|
|
|
std::swap(left_line, rhs.left_line);
|
|
|
|
|
std::swap(right_line, rhs.right_line);
|
|
|
|
|
std::swap(usebox, rhs.usebox);
|
|
|
|
|
std::swap(rotate, rhs.rotate);
|
|
|
|
|
std::swap(align_special, rhs.align_special);
|
|
|
|
|
p_width.swap(rhs.p_width);
|
|
|
|
|
inset.swap(rhs.inset);
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXTabular::rowstruct::rowstruct()
|
2004-11-23 23:04:52 +00:00
|
|
|
|
: ascent_of_row(0),
|
|
|
|
|
descent_of_row(0),
|
|
|
|
|
top_line(true),
|
|
|
|
|
bottom_line(false),
|
2006-07-03 19:13:56 +00:00
|
|
|
|
top_space_default(false),
|
|
|
|
|
bottom_space_default(false),
|
|
|
|
|
interline_space_default(false),
|
2004-11-23 23:04:52 +00:00
|
|
|
|
endhead(false),
|
|
|
|
|
endfirsthead(false),
|
|
|
|
|
endfoot(false),
|
|
|
|
|
endlastfoot(false),
|
|
|
|
|
newpage(false)
|
|
|
|
|
{}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXTabular::columnstruct::columnstruct()
|
2004-11-23 23:04:52 +00:00
|
|
|
|
: alignment(LYX_ALIGN_CENTER),
|
|
|
|
|
valignment(LYX_VALIGN_TOP),
|
|
|
|
|
left_line(true),
|
|
|
|
|
right_line(false),
|
|
|
|
|
width_of_column(0)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 15:01:06 +00:00
|
|
|
|
LyXTabular::ltType::ltType()
|
2004-11-23 23:04:52 +00:00
|
|
|
|
: topDL(false),
|
|
|
|
|
bottomDL(false),
|
|
|
|
|
empty(false)
|
|
|
|
|
{}
|
2001-10-24 15:07:39 +00:00
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::LyXTabular(BufferParams const & bp, row_type rows_arg,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type columns_arg)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-03-29 10:13:40 +00:00
|
|
|
|
init(bp, rows_arg, columns_arg);
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
// activates all lines and sets all widths to 0
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::init(BufferParams const & bp, row_type rows_arg,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type columns_arg)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-10-08 14:29:16 +00:00
|
|
|
|
rows_ = rows_arg;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
columns_ = columns_arg;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
row_info = row_vector(rows_);
|
|
|
|
|
column_info = column_vector(columns_);
|
2006-03-29 10:13:40 +00:00
|
|
|
|
cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
|
2003-10-08 14:29:16 +00:00
|
|
|
|
row_info.reserve(10);
|
|
|
|
|
column_info.reserve(10);
|
|
|
|
|
cell_info.reserve(100);
|
|
|
|
|
fixCellNums();
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2003-10-08 14:29:16 +00:00
|
|
|
|
cell_info[i].back().right_line = true;
|
|
|
|
|
row_info.back().bottom_line = true;
|
|
|
|
|
row_info.front().bottom_line = true;
|
|
|
|
|
column_info.back().right_line = true;
|
|
|
|
|
is_long_tabular = false;
|
|
|
|
|
rotate = false;
|
2006-07-03 19:13:56 +00:00
|
|
|
|
use_booktabs = false;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
2003-10-08 14:29:16 +00:00
|
|
|
|
|
|
|
|
|
void LyXTabular::fixCellNums()
|
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type cellno = 0;
|
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2004-08-14 15:55:22 +00:00
|
|
|
|
// When debugging it can be nice to set
|
|
|
|
|
// this to true.
|
2004-11-23 23:04:52 +00:00
|
|
|
|
cell_info[i][j].inset->setDrawFrame(false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[i][j].cellno = cellno++;
|
|
|
|
|
}
|
|
|
|
|
cell_info[i].back().right_line = true;
|
|
|
|
|
}
|
2003-10-08 14:29:16 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
set_row_column_number_info();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++rows_;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row_vector::iterator rit = row_info.begin() + row;
|
|
|
|
|
row_info.insert(rit, rowstruct());
|
|
|
|
|
// now set the values of the row before
|
2002-03-03 20:25:07 +00:00
|
|
|
|
row_info[row] = row_info[row + 1];
|
2000-05-26 13:09:14 +00:00
|
|
|
|
|
2003-10-08 14:29:16 +00:00
|
|
|
|
cell_vvector old(rows_ - 1);
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_ - 1; ++i)
|
2003-10-08 14:29:16 +00:00
|
|
|
|
swap(cell_info[i], old[i]);
|
2003-10-06 14:10:59 +00:00
|
|
|
|
|
2006-03-29 10:13:40 +00:00
|
|
|
|
cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i <= row; ++i)
|
2003-10-08 14:29:16 +00:00
|
|
|
|
swap(cell_info[i], old[i]);
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = row + 2; i < rows_; ++i)
|
2003-10-08 14:29:16 +00:00
|
|
|
|
swap(cell_info[i], old[i - 1]);
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2006-10-06 18:53:35 +00:00
|
|
|
|
if (bp.trackChanges)
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j)
|
2006-10-20 09:29:19 +00:00
|
|
|
|
cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED));
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2003-10-08 14:29:16 +00:00
|
|
|
|
set_row_column_number_info();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::deleteRow(row_type const row)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
// Not allowed to delete last row
|
|
|
|
|
if (rows_ == 1)
|
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
row_info.erase(row_info.begin() + row);
|
|
|
|
|
cell_info.erase(cell_info.begin() + row);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
--rows_;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
fixCellNums();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-27 16:28:09 +00:00
|
|
|
|
void LyXTabular::copyRow(BufferParams const & bp, row_type const row)
|
|
|
|
|
{
|
|
|
|
|
++rows_;
|
|
|
|
|
|
|
|
|
|
row_info.insert(row_info.begin() + row, row_info[row]);
|
|
|
|
|
cell_info.insert(cell_info.begin() + row, cell_info[row]);
|
|
|
|
|
|
2006-10-06 18:53:35 +00:00
|
|
|
|
if (bp.trackChanges)
|
2006-09-27 16:28:09 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j)
|
2006-10-20 09:29:19 +00:00
|
|
|
|
cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED));
|
2006-09-27 16:28:09 +00:00
|
|
|
|
|
|
|
|
|
set_row_column_number_info();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++columns_;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type const column = column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_vector::iterator cit = column_info.begin() + column + 1;
|
|
|
|
|
column_info.insert(cit, columnstruct());
|
|
|
|
|
// set the column values of the column before
|
2002-03-03 20:25:07 +00:00
|
|
|
|
column_info[column + 1] = column_info[column];
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2006-03-29 10:13:40 +00:00
|
|
|
|
cell_info[i].insert(cell_info[i].begin() + column + 1, cellstruct(bp));
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// care about multicolumns
|
2003-10-10 09:01:23 +00:00
|
|
|
|
if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
|
|
|
|
|
cell_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
|
|
|
|
if (column + 2 >= columns_
|
2003-10-10 09:01:23 +00:00
|
|
|
|
|| cell_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
cell_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
//++column;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2005-09-07 10:37:05 +00:00
|
|
|
|
cell_info[i][column + 1].inset->clear();
|
2006-10-06 18:53:35 +00:00
|
|
|
|
if (bp.trackChanges)
|
2006-10-20 09:29:19 +00:00
|
|
|
|
cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED));
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2003-10-08 14:29:16 +00:00
|
|
|
|
fixCellNums();
|
2000-05-05 12:14:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::deleteColumn(col_type const column)
|
2000-05-05 12:14:16 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
// Not allowed to delete last column
|
|
|
|
|
if (columns_ == 1)
|
|
|
|
|
return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info.erase(column_info.begin() + column);
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[i].erase(cell_info[i].begin() + column);
|
|
|
|
|
--columns_;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
fixCellNums();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-27 16:28:09 +00:00
|
|
|
|
void LyXTabular::copyColumn(BufferParams const & bp, col_type const column)
|
|
|
|
|
{
|
|
|
|
|
++columns_;
|
|
|
|
|
|
|
|
|
|
column_info.insert(column_info.begin() + column, column_info[column]);
|
|
|
|
|
|
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
|
|
|
|
cell_info[i].insert(cell_info[i].begin() + column, cell_info[i][column]);
|
|
|
|
|
|
2006-10-06 18:53:35 +00:00
|
|
|
|
if (bp.trackChanges)
|
2006-09-27 16:28:09 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2006-10-20 09:29:19 +00:00
|
|
|
|
cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED));
|
2006-09-27 16:28:09 +00:00
|
|
|
|
fixCellNums();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-08 14:29:16 +00:00
|
|
|
|
void LyXTabular::set_row_column_number_info()
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
numberofcells = 0;
|
|
|
|
|
for (row_type row = 0; row < rows_; ++row) {
|
|
|
|
|
for (col_type column = 0; column < columns_; ++column) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell_info[row][column].multicolumn
|
|
|
|
|
!= LyXTabular::CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
++numberofcells;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
if (numberofcells == 0)
|
|
|
|
|
// FIXME: Is this intended?
|
|
|
|
|
cell_info[row][column].cellno = npos;
|
|
|
|
|
else
|
|
|
|
|
cell_info[row][column].cellno =
|
|
|
|
|
numberofcells - 1;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rowofcell.resize(numberofcells);
|
|
|
|
|
columnofcell.resize(numberofcells);
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type row = 0;
|
|
|
|
|
col_type column = 0;
|
|
|
|
|
for (idx_type c = 0;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
c < numberofcells && row < rows_ && column < columns_;) {
|
|
|
|
|
rowofcell[c] = row;
|
|
|
|
|
columnofcell[c] = column;
|
|
|
|
|
++c;
|
|
|
|
|
do {
|
|
|
|
|
++column;
|
|
|
|
|
} while (column < columns_ &&
|
|
|
|
|
cell_info[row][column].multicolumn
|
|
|
|
|
== LyXTabular::CELL_PART_OF_MULTICOLUMN);
|
2003-08-11 09:09:01 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (column == columns_) {
|
|
|
|
|
column = 0;
|
|
|
|
|
++row;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type row = 0; row < rows_; ++row) {
|
|
|
|
|
for (col_type column = 0; column < columns_; ++column) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isPartOfMultiColumn(row,column))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
continue;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
cell_info[row][column].inset->setAutoBreakRows(
|
2003-06-12 11:52:44 +00:00
|
|
|
|
!getPWidth(getCellNumber(row, column)).zero());
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getNumberOfCells() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return numberofcells;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::numberOfCellsInRow(idx_type const cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
idx_type result = 0;
|
|
|
|
|
for (col_type i = 0; i < columns_; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
++result;
|
|
|
|
|
return result;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
bool LyXTabular::topLine(idx_type const cell, bool const wholerow) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (!wholerow && isMultiColumn(cell) &&
|
2006-07-03 19:13:56 +00:00
|
|
|
|
!(use_booktabs && row_of_cell(cell) == 0))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).top_line;
|
|
|
|
|
return row_info[row_of_cell(cell)].top_line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
bool LyXTabular::bottomLine(idx_type const cell, bool wholerow) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (!wholerow && isMultiColumn(cell) &&
|
2006-07-03 19:13:56 +00:00
|
|
|
|
!(use_booktabs && isLastRow(cell)))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).bottom_line;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return row_info[row_of_cell(cell)].bottom_line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
bool LyXTabular::leftLine(idx_type cell, bool wholecolumn) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (use_booktabs)
|
|
|
|
|
return false;
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (!wholecolumn && isMultiColumn(cell) &&
|
2003-06-12 11:52:44 +00:00
|
|
|
|
(isFirstCellInRow(cell) || isMultiColumn(cell-1)))
|
2002-03-18 15:27:41 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (cellinfo_of_cell(cell).align_special.empty())
|
|
|
|
|
return cellinfo_of_cell(cell).left_line;
|
2007-01-05 17:11:32 +00:00
|
|
|
|
return prefixIs(ltrim(cellinfo_of_cell(cell).align_special), '|');
|
2001-08-08 13:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
if (column_info[column_of_cell(cell)].align_special.empty())
|
|
|
|
|
return column_info[column_of_cell(cell)].left_line;
|
2007-01-05 17:11:32 +00:00
|
|
|
|
return prefixIs(ltrim(column_info[column_of_cell(cell)].align_special), '|');
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
bool LyXTabular::rightLine(idx_type cell, bool wholecolumn) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (use_booktabs)
|
|
|
|
|
return false;
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (!wholecolumn && isMultiColumn(cell) &&
|
2003-10-06 14:10:59 +00:00
|
|
|
|
(isLastCellInRow(cell) || isMultiColumn(cell + 1)))
|
2002-03-18 15:27:41 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (cellinfo_of_cell(cell).align_special.empty())
|
|
|
|
|
return cellinfo_of_cell(cell).right_line;
|
2007-01-05 17:11:32 +00:00
|
|
|
|
return suffixIs(rtrim(cellinfo_of_cell(cell).align_special), '|');
|
2001-08-08 13:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
if (column_info[column_of_cell(cell)].align_special.empty())
|
|
|
|
|
return column_info[right_column_of_cell(cell)].right_line;
|
2007-01-05 17:11:32 +00:00
|
|
|
|
return suffixIs(rtrim(column_info[column_of_cell(cell)].align_special), '|');
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::topAlreadyDrawn(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type row = row_of_cell(cell);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (row > 0 && !getAdditionalHeight(row)) {
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type column = column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
--row;
|
|
|
|
|
while (column
|
|
|
|
|
&& cell_info[row][column].multicolumn
|
|
|
|
|
== LyXTabular::CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
--column;
|
|
|
|
|
if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
|
|
|
|
|
return row_info[row].bottom_line;
|
|
|
|
|
else
|
|
|
|
|
return cell_info[row][column].bottom_line;
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::leftAlreadyDrawn(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type column = column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (column > 0) {
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type row = row_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
while (--column &&
|
|
|
|
|
(cell_info[row][column].multicolumn ==
|
|
|
|
|
LyXTabular::CELL_PART_OF_MULTICOLUMN));
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getAdditionalWidth(cell_info[row][column].cellno))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return false;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
return rightLine(cell_info[row][column].cellno);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
return false;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isLastRow(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-10-08 14:29:16 +00:00
|
|
|
|
return row_of_cell(cell) == rows_ - 1;
|
2000-05-04 08:14:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getAdditionalHeight(row_type row) const
|
2000-05-04 08:14:34 +00:00
|
|
|
|
{
|
2001-04-27 14:03:25 +00:00
|
|
|
|
if (!row || row >= rows_)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
bool top = true;
|
|
|
|
|
bool bottom = true;
|
2000-05-04 08:14:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type column = 0; column < columns_ && bottom; ++column) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
switch (cell_info[row - 1][column].multicolumn) {
|
|
|
|
|
case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
|
|
|
|
|
bottom = cell_info[row - 1][column].bottom_line;
|
|
|
|
|
break;
|
|
|
|
|
case LyXTabular::CELL_NORMAL:
|
|
|
|
|
bottom = row_info[row - 1].bottom_line;
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type column = 0; column < columns_ && top; ++column) {
|
2002-02-16 15:59:55 +00:00
|
|
|
|
switch (cell_info[row][column].multicolumn) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
|
|
|
|
|
top = cell_info[row][column].top_line;
|
|
|
|
|
break;
|
|
|
|
|
case LyXTabular::CELL_NORMAL:
|
|
|
|
|
top = row_info[row].top_line;
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
2006-07-03 19:13:56 +00:00
|
|
|
|
int const interline_space = row_info[row - 1].interline_space_default ?
|
|
|
|
|
default_line_space :
|
|
|
|
|
row_info[row - 1].interline_space.inPixels(width_of_tabular);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (top && bottom)
|
2006-07-03 19:13:56 +00:00
|
|
|
|
return interline_space + WIDTH_OF_LINE;
|
|
|
|
|
return interline_space;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getAdditionalWidth(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
// internally already set in setWidthOfCell
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// used to get it back in text.C
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type const col = right_column_of_cell(cell);
|
|
|
|
|
row_type const row = row_of_cell(cell);
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (col < columns_ - 1 && rightLine(cell) &&
|
|
|
|
|
leftLine(cell_info[row][col+1].cellno)) // column_info[col+1].left_line)
|
2001-08-08 13:29:13 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return WIDTH_OF_LINE;
|
2001-08-08 13:29:13 +00:00
|
|
|
|
}
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return 0;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// returns the maximum over all rows
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getWidthOfColumn(idx_type cell) const
|
2000-05-04 08:14:34 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type const column1 = column_of_cell(cell);
|
|
|
|
|
col_type const column2 = right_column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int result = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = column1; i <= column2; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
result += column_info[i].width_of_column;
|
|
|
|
|
return result;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
int LyXTabular::getWidthOfTabular() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return width_of_tabular;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
// returns true if a complete update is necessary, otherwise false
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::setWidthOfMulticolCell(idx_type cell, int new_width)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isMultiColumn(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type const column1 = column_of_cell(cell);
|
|
|
|
|
col_type const column2 = right_column_of_cell(cell);
|
2002-03-01 16:04:10 +00:00
|
|
|
|
int const old_val = cell_info[row][column2].width_of_cell;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// first set columns to 0 so we can calculate the right width
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = column1; i <= column2; ++i) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[row][i].width_of_cell = 0;
|
|
|
|
|
}
|
|
|
|
|
// set the width to MAX_WIDTH until width > 0
|
2003-07-21 11:01:29 +00:00
|
|
|
|
int width = new_width + 2 * WIDTH_OF_LINE;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type i = column1;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
for (; i < column2 && width > column_info[i].width_of_column; ++i) {
|
|
|
|
|
cell_info[row][i].width_of_cell = column_info[i].width_of_column;
|
|
|
|
|
width -= column_info[i].width_of_column;
|
|
|
|
|
}
|
|
|
|
|
if (width > 0) {
|
|
|
|
|
cell_info[row][i].width_of_cell = width;
|
|
|
|
|
}
|
2002-03-01 16:04:10 +00:00
|
|
|
|
if (old_val != cell_info[row][column2].width_of_cell) {
|
|
|
|
|
// in this case we have to recalculate all multicolumn cells which
|
|
|
|
|
// have this column as one of theirs but not as last one
|
2002-03-04 11:26:17 +00:00
|
|
|
|
calculate_width_of_column_NMC(i);
|
2002-03-01 16:04:10 +00:00
|
|
|
|
recalculateMulticolumnsOfColumn(i);
|
2002-03-04 11:26:17 +00:00
|
|
|
|
calculate_width_of_column(i);
|
2002-03-01 16:04:10 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return true;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::recalculateMulticolumnsOfColumn(col_type column)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2002-03-01 16:04:10 +00:00
|
|
|
|
// the last column does not have to be recalculated because all
|
|
|
|
|
// multicolumns will have here there last multicolumn cell which
|
|
|
|
|
// always will have the whole rest of the width of the cell.
|
2005-07-17 16:38:28 +00:00
|
|
|
|
if (columns_ < 2 || column > (columns_ - 2))
|
2002-03-01 16:04:10 +00:00
|
|
|
|
return;
|
2005-07-17 14:23:33 +00:00
|
|
|
|
for (row_type row = 0; row < rows_; ++row) {
|
2002-03-01 16:04:10 +00:00
|
|
|
|
int mc = cell_info[row][column].multicolumn;
|
|
|
|
|
int nmc = cell_info[row][column+1].multicolumn;
|
|
|
|
|
// we only have to update multicolumns which do not have this
|
|
|
|
|
// column as their last column!
|
|
|
|
|
if (mc == CELL_BEGIN_OF_MULTICOLUMN ||
|
2003-07-21 11:01:29 +00:00
|
|
|
|
(mc == CELL_PART_OF_MULTICOLUMN &&
|
|
|
|
|
nmc == CELL_PART_OF_MULTICOLUMN))
|
2002-03-01 16:04:10 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const cellno = cell_info[row][column].cellno;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
setWidthOfMulticolCell(cellno,
|
2003-07-21 11:01:29 +00:00
|
|
|
|
getWidthOfCell(cellno) - 2 * WIDTH_OF_LINE);
|
2002-03-01 16:04:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setWidthOfCell(idx_type cell, int new_width)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type const column1 = column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
bool tmp = false;
|
|
|
|
|
int width = 0;
|
2001-08-08 13:29:13 +00:00
|
|
|
|
int add_width = 0;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (rightLine(cell_info[row][column1].cellno, true) &&
|
2003-07-21 11:01:29 +00:00
|
|
|
|
column1 < columns_ - 1 &&
|
2003-06-12 11:52:44 +00:00
|
|
|
|
leftLine(cell_info[row][column1+1].cellno, true))
|
2001-08-08 13:29:13 +00:00
|
|
|
|
{
|
|
|
|
|
add_width = WIDTH_OF_LINE;
|
|
|
|
|
}
|
2003-07-31 12:25:36 +00:00
|
|
|
|
|
|
|
|
|
if (getWidthOfCell(cell) == new_width + 2 * WIDTH_OF_LINE + add_width)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (isMultiColumnReal(cell)) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
tmp = setWidthOfMulticolCell(cell, new_width);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
width = new_width + 2 * WIDTH_OF_LINE + add_width;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[row][column1].width_of_cell = width;
|
|
|
|
|
tmp = calculate_width_of_column_NMC(column1);
|
2002-03-01 16:04:10 +00:00
|
|
|
|
if (tmp)
|
|
|
|
|
recalculateMulticolumnsOfColumn(column1);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
if (tmp) {
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = 0; i < columns_; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
calculate_width_of_column(i);
|
|
|
|
|
calculate_width_of_tabular();
|
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setAlignment(idx_type cell, LyXAlignment align,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
bool onlycolumn)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isMultiColumn(cell) || onlycolumn)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info[column_of_cell(cell)].alignment = align;
|
|
|
|
|
if (!onlycolumn)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).alignment = align;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setVAlignment(idx_type cell, VAlignment align,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
bool onlycolumn)
|
2000-07-17 14:31:07 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isMultiColumn(cell) || onlycolumn)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info[column_of_cell(cell)].valignment = align;
|
|
|
|
|
if (!onlycolumn)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).valignment = align;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-11-28 11:52:03 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Allow line and paragraph breaks for fixed width cells or disallow them,
|
|
|
|
|
* merge cell paragraphs and reset layout to standard for variable width
|
|
|
|
|
* cells.
|
|
|
|
|
*/
|
|
|
|
|
void toggleFixedWidth(LCursor & cur, InsetText * inset, bool fixedWidth)
|
|
|
|
|
{
|
|
|
|
|
inset->setAutoBreakRows(fixedWidth);
|
|
|
|
|
if (fixedWidth)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// merge all paragraphs to one
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
BufferParams const & bp = cur.bv().buffer()->params();
|
2005-11-28 11:52:03 +00:00
|
|
|
|
while (inset->paragraphs().size() > 1)
|
|
|
|
|
mergeParagraph(bp, inset->paragraphs(), 0);
|
|
|
|
|
|
|
|
|
|
// reset layout
|
|
|
|
|
cur.push(*inset);
|
2005-12-29 10:03:38 +00:00
|
|
|
|
// undo information has already been recorded
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
|
inset->getText(0)->setLayout(*cur.bv().buffer(), 0, cur.lastpit() + 1,
|
2005-12-29 10:03:38 +00:00
|
|
|
|
bp.getLyXTextClass().defaultLayoutName());
|
2005-11-28 11:52:03 +00:00
|
|
|
|
cur.pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXTabular::setColumnPWidth(LCursor & cur, idx_type cell,
|
|
|
|
|
LyXLength const & width)
|
2000-07-17 14:31:07 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type const j = column_of_cell(cell);
|
2000-07-17 14:31:07 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info[j].p_width = width;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
|
|
|
|
idx_type const cell = getCellNumber(i, j);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
// because of multicolumns
|
2005-11-28 11:52:03 +00:00
|
|
|
|
toggleFixedWidth(cur, getCellInset(cell).get(),
|
2006-04-05 23:56:29 +00:00
|
|
|
|
!getPWidth(cell).zero());
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2005-11-28 11:52:03 +00:00
|
|
|
|
// cur paragraph can become invalid after paragraphs were merged
|
|
|
|
|
if (cur.pit() > cur.lastpit())
|
|
|
|
|
cur.pit() = cur.lastpit();
|
|
|
|
|
// cur position can become invalid after newlines were removed
|
|
|
|
|
if (cur.pos() > cur.lastpos())
|
|
|
|
|
cur.pos() = cur.lastpos();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2005-11-28 11:52:03 +00:00
|
|
|
|
bool LyXTabular::setMColumnPWidth(LCursor & cur, idx_type cell,
|
|
|
|
|
LyXLength const & width)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (!isMultiColumn(cell))
|
|
|
|
|
return false;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).p_width = width;
|
2005-11-28 11:52:03 +00:00
|
|
|
|
toggleFixedWidth(cur, getCellInset(cell).get(), !width.zero());
|
|
|
|
|
// cur paragraph can become invalid after paragraphs were merged
|
|
|
|
|
if (cur.pit() > cur.lastpit())
|
|
|
|
|
cur.pit() = cur.lastpit();
|
|
|
|
|
// cur position can become invalid after newlines were removed
|
|
|
|
|
if (cur.pos() > cur.lastpos())
|
|
|
|
|
cur.pos() = cur.lastpos();
|
2003-10-06 14:10:59 +00:00
|
|
|
|
return true;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2007-01-05 17:11:32 +00:00
|
|
|
|
void LyXTabular::setAlignSpecial(idx_type cell, docstring const & special,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXTabular::Feature what)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (what == SET_SPECIAL_MULTI)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).align_special = special;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
else
|
|
|
|
|
column_info[column_of_cell(cell)].align_special = special;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setAllLines(idx_type cell, bool line)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
setTopLine(cell, line);
|
|
|
|
|
setBottomLine(cell, line);
|
|
|
|
|
setRightLine(cell, line);
|
|
|
|
|
setLeftLine(cell, line);
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
void LyXTabular::setTopLine(idx_type cell, bool line, bool wholerow)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (wholerow || !isMultiColumn(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row_info[row].top_line = line;
|
|
|
|
|
else
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).top_line = line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
void LyXTabular::setBottomLine(idx_type cell, bool line, bool wholerow)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (wholerow || !isMultiColumn(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row_info[row_of_cell(cell)].bottom_line = line;
|
|
|
|
|
else
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).bottom_line = line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
void LyXTabular::setLeftLine(idx_type cell, bool line, bool wholecolumn)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (wholecolumn || !isMultiColumn(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info[column_of_cell(cell)].left_line = line;
|
|
|
|
|
else
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).left_line = line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-15 09:17:40 +00:00
|
|
|
|
void LyXTabular::setRightLine(idx_type cell, bool line, bool wholecolumn)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2006-11-15 09:17:40 +00:00
|
|
|
|
if (wholecolumn || !isMultiColumn(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
column_info[right_column_of_cell(cell)].right_line = line;
|
|
|
|
|
else
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).right_line = line;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXAlignment LyXTabular::getAlignment(idx_type cell, bool onlycolumn) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!onlycolumn && isMultiColumn(cell))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).alignment;
|
|
|
|
|
return column_info[column_of_cell(cell)].alignment;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2000-10-30 21:53:29 +00:00
|
|
|
|
LyXTabular::VAlignment
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::getVAlignment(idx_type cell, bool onlycolumn) const
|
2000-07-17 14:31:07 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!onlycolumn && isMultiColumn(cell))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).valignment;
|
|
|
|
|
return column_info[column_of_cell(cell)].valignment;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXLength const LyXTabular::getPWidth(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isMultiColumn(cell))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).p_width;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return column_info[column_of_cell(cell)].p_width;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXLength const LyXTabular::getColumnPWidth(idx_type cell) const
|
2000-07-17 14:31:07 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return column_info[column_of_cell(cell)].p_width;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXLength const LyXTabular::getMColumnPWidth(idx_type cell) const
|
2000-07-17 14:31:07 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isMultiColumn(cell))
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).p_width;
|
2001-12-11 17:26:52 +00:00
|
|
|
|
return LyXLength();
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-05 17:11:32 +00:00
|
|
|
|
docstring const LyXTabular::getAlignSpecial(idx_type cell, int what) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (what == SET_SPECIAL_MULTI)
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).align_special;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return column_info[column_of_cell(cell)].align_special;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getWidthOfCell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type const column1 = column_of_cell(cell);
|
|
|
|
|
col_type const column2 = right_column_of_cell(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int result = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = column1; i <= column2; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
result += cell_info[row][i].width_of_cell;
|
|
|
|
|
return result;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getBeginningOfTextInCell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int x = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getAlignment(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
case LYX_ALIGN_CENTER:
|
2003-06-12 11:52:44 +00:00
|
|
|
|
x += (getWidthOfColumn(cell) - getWidthOfCell(cell)) / 2;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
2003-06-12 11:52:44 +00:00
|
|
|
|
x += getWidthOfColumn(cell) - getWidthOfCell(cell);
|
|
|
|
|
// + getAdditionalWidth(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
default:
|
|
|
|
|
// LYX_ALIGN_LEFT: nothing :-)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// the LaTeX Way :-(
|
|
|
|
|
x += WIDTH_OF_LINE;
|
|
|
|
|
return x;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isFirstCellInRow(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return column_of_cell(cell) == 0;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getFirstCellInRow(row_type row) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (row > rows_ - 1)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row = rows_ - 1;
|
|
|
|
|
return cell_info[row][0].cellno;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isLastCellInRow(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return right_column_of_cell(cell) == columns_ - 1;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getLastCellInRow(row_type row) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (row > rows_ - 1)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row = rows_ - 1;
|
|
|
|
|
return cell_info[row][columns_-1].cellno;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::calculate_width_of_column(col_type column)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int maximum = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
maximum = max(cell_info[i][column].width_of_cell, maximum);
|
|
|
|
|
column_info[column].width_of_column = maximum;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
//
|
2002-03-04 11:26:17 +00:00
|
|
|
|
// Calculate the columns regarding ONLY the normal cells and if this
|
|
|
|
|
// column is inside a multicolumn cell then use it only if its the last
|
2003-07-21 11:01:29 +00:00
|
|
|
|
// column of this multicolumn cell as this gives an added width to the
|
2002-03-04 11:26:17 +00:00
|
|
|
|
// column, all the rest should be adapted!
|
2000-09-14 17:53:12 +00:00
|
|
|
|
//
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::calculate_width_of_column_NMC(col_type column)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int const old_column_width = column_info[column].width_of_column;
|
|
|
|
|
int max = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
|
|
|
|
idx_type cell = getCellNumber(i, column);
|
2003-10-06 14:10:59 +00:00
|
|
|
|
bool ismulti = isMultiColumnReal(cell);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if ((!ismulti || column == right_column_of_cell(cell)) &&
|
|
|
|
|
cell_info[i][column].width_of_cell > max)
|
2002-03-04 11:26:17 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
max = cell_info[i][column].width_of_cell;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
column_info[column].width_of_column = max;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return column_info[column].width_of_column != old_column_width;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2000-04-21 15:16:22 +00:00
|
|
|
|
void LyXTabular::calculate_width_of_tabular()
|
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
width_of_tabular = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = 0; i < columns_; ++i)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
width_of_tabular += column_info[i].width_of_column;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::row_type LyXTabular::row_of_cell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell >= numberofcells)
|
|
|
|
|
return rows_ - 1;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
if (cell == npos)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return 0;
|
|
|
|
|
return rowofcell[cell];
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::col_type LyXTabular::column_of_cell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell >= numberofcells)
|
|
|
|
|
return columns_ - 1;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
if (cell == npos)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return 0;
|
|
|
|
|
return columnofcell[cell];
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::col_type LyXTabular::right_column_of_cell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type column = column_of_cell(cell);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
while (column < columns_ - 1 &&
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[row][column + 1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
++column;
|
|
|
|
|
return column;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void LyXTabular::write(Buffer const & buf, ostream & os) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// header line
|
|
|
|
|
os << "<lyxtabular"
|
2001-12-19 21:25:34 +00:00
|
|
|
|
<< write_attribute("version", 3)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< write_attribute("rows", rows_)
|
|
|
|
|
<< write_attribute("columns", columns_)
|
2001-01-09 16:23:48 +00:00
|
|
|
|
<< ">\n";
|
2001-04-02 14:02:58 +00:00
|
|
|
|
// global longtable options
|
|
|
|
|
os << "<features"
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("rotate", rotate)
|
2006-07-03 19:13:56 +00:00
|
|
|
|
<< write_attribute("booktabs", use_booktabs)
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("islongtable", is_long_tabular)
|
|
|
|
|
<< write_attribute("firstHeadTopDL", endfirsthead.topDL)
|
|
|
|
|
<< write_attribute("firstHeadBottomDL", endfirsthead.bottomDL)
|
|
|
|
|
<< write_attribute("firstHeadEmpty", endfirsthead.empty)
|
|
|
|
|
<< write_attribute("headTopDL", endhead.topDL)
|
|
|
|
|
<< write_attribute("headBottomDL", endhead.bottomDL)
|
|
|
|
|
<< write_attribute("footTopDL", endfoot.topDL)
|
|
|
|
|
<< write_attribute("footBottomDL", endfoot.bottomDL)
|
|
|
|
|
<< write_attribute("lastFootTopDL", endlastfoot.topDL)
|
|
|
|
|
<< write_attribute("lastFootBottomDL", endlastfoot.bottomDL)
|
|
|
|
|
<< write_attribute("lastFootEmpty", endlastfoot.empty)
|
2000-10-30 21:53:29 +00:00
|
|
|
|
<< ">\n";
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2001-01-10 18:18:30 +00:00
|
|
|
|
os << "<column"
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("alignment", column_info[j].alignment)
|
|
|
|
|
<< write_attribute("valignment", column_info[j].valignment)
|
|
|
|
|
<< write_attribute("leftline", column_info[j].left_line)
|
|
|
|
|
<< write_attribute("rightline", column_info[j].right_line)
|
2001-12-11 17:26:52 +00:00
|
|
|
|
<< write_attribute("width", column_info[j].p_width.asString())
|
2000-10-30 21:53:29 +00:00
|
|
|
|
<< write_attribute("special", column_info[j].align_special)
|
|
|
|
|
<< ">\n";
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "<row"
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("topline", row_info[i].top_line)
|
2006-07-03 19:13:56 +00:00
|
|
|
|
<< write_attribute("bottomline", row_info[i].bottom_line);
|
|
|
|
|
static const string def("default");
|
|
|
|
|
if (row_info[i].top_space_default)
|
|
|
|
|
os << write_attribute("topspace", def);
|
|
|
|
|
else
|
|
|
|
|
os << write_attribute("topspace", row_info[i].top_space);
|
|
|
|
|
if (row_info[i].bottom_space_default)
|
|
|
|
|
os << write_attribute("bottomspace", def);
|
|
|
|
|
else
|
|
|
|
|
os << write_attribute("bottomspace", row_info[i].bottom_space);
|
|
|
|
|
if (row_info[i].interline_space_default)
|
|
|
|
|
os << write_attribute("interlinespace", def);
|
|
|
|
|
else
|
|
|
|
|
os << write_attribute("interlinespace", row_info[i].interline_space);
|
|
|
|
|
os << write_attribute("endhead", row_info[i].endhead)
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("endfirsthead", row_info[i].endfirsthead)
|
|
|
|
|
<< write_attribute("endfoot", row_info[i].endfoot)
|
|
|
|
|
<< write_attribute("endlastfoot", row_info[i].endlastfoot)
|
|
|
|
|
<< write_attribute("newpage", row_info[i].newpage)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< ">\n";
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "<cell"
|
|
|
|
|
<< write_attribute("multicolumn", cell_info[i][j].multicolumn)
|
2002-02-26 08:24:48 +00:00
|
|
|
|
<< write_attribute("alignment", cell_info[i][j].alignment)
|
|
|
|
|
<< write_attribute("valignment", cell_info[i][j].valignment)
|
|
|
|
|
<< write_attribute("topline", cell_info[i][j].top_line)
|
|
|
|
|
<< write_attribute("bottomline", cell_info[i][j].bottom_line)
|
|
|
|
|
<< write_attribute("leftline", cell_info[i][j].left_line)
|
|
|
|
|
<< write_attribute("rightline", cell_info[i][j].right_line)
|
|
|
|
|
<< write_attribute("rotate", cell_info[i][j].rotate)
|
|
|
|
|
<< write_attribute("usebox", cell_info[i][j].usebox)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< write_attribute("width", cell_info[i][j].p_width)
|
|
|
|
|
<< write_attribute("special", cell_info[i][j].align_special)
|
|
|
|
|
<< ">\n";
|
|
|
|
|
os << "\\begin_inset ";
|
2004-11-23 23:04:52 +00:00
|
|
|
|
cell_info[i][j].inset->write(buf, os);
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\end_inset\n"
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< "</cell>\n";
|
|
|
|
|
}
|
|
|
|
|
os << "</row>\n";
|
|
|
|
|
}
|
|
|
|
|
os << "</lyxtabular>\n";
|
2000-05-04 08:14:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void LyXTabular::read(Buffer const & buf, LyXLex & lex)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
{
|
2003-06-12 14:29:45 +00:00
|
|
|
|
string line;
|
|
|
|
|
istream & is = lex.getStream();
|
|
|
|
|
|
|
|
|
|
l_getline(is, line);
|
|
|
|
|
if (!prefixIs(line, "<lyxtabular ")
|
|
|
|
|
&& !prefixIs(line, "<LyXTabular ")) {
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
2003-06-12 14:29:45 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int version;
|
|
|
|
|
if (!getTokenValue(line, "version", version))
|
|
|
|
|
return;
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(version >= 2);
|
2003-06-12 14:29:45 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int rows_arg;
|
|
|
|
|
if (!getTokenValue(line, "rows", rows_arg))
|
|
|
|
|
return;
|
|
|
|
|
int columns_arg;
|
|
|
|
|
if (!getTokenValue(line, "columns", columns_arg))
|
|
|
|
|
return;
|
2006-03-29 10:13:40 +00:00
|
|
|
|
init(buf.params(), rows_arg, columns_arg);
|
2001-01-09 16:23:48 +00:00
|
|
|
|
l_getline(is, line);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (!prefixIs(line, "<features")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected <features ...> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-01-09 16:23:48 +00:00
|
|
|
|
return;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
getTokenValue(line, "rotate", rotate);
|
2006-07-03 19:13:56 +00:00
|
|
|
|
getTokenValue(line, "booktabs", use_booktabs);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
getTokenValue(line, "islongtable", is_long_tabular);
|
2004-12-03 18:33:19 +00:00
|
|
|
|
getTokenValue(line, "firstHeadTopDL", endfirsthead.topDL);
|
|
|
|
|
getTokenValue(line, "firstHeadBottomDL", endfirsthead.bottomDL);
|
|
|
|
|
getTokenValue(line, "firstHeadEmpty", endfirsthead.empty);
|
|
|
|
|
getTokenValue(line, "headTopDL", endhead.topDL);
|
|
|
|
|
getTokenValue(line, "headBottomDL", endhead.bottomDL);
|
|
|
|
|
getTokenValue(line, "footTopDL", endfoot.topDL);
|
|
|
|
|
getTokenValue(line, "footBottomDL", endfoot.bottomDL);
|
|
|
|
|
getTokenValue(line, "lastFootTopDL", endlastfoot.topDL);
|
|
|
|
|
getTokenValue(line, "lastFootBottomDL", endlastfoot.bottomDL);
|
|
|
|
|
getTokenValue(line, "lastFootEmpty", endlastfoot.empty);
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
l_getline(is,line);
|
|
|
|
|
if (!prefixIs(line,"<column")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected <column ...> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
getTokenValue(line, "alignment", column_info[j].alignment);
|
|
|
|
|
getTokenValue(line, "valignment", column_info[j].valignment);
|
|
|
|
|
getTokenValue(line, "leftline", column_info[j].left_line);
|
|
|
|
|
getTokenValue(line, "rightline", column_info[j].right_line);
|
|
|
|
|
getTokenValue(line, "width", column_info[j].p_width);
|
|
|
|
|
getTokenValue(line, "special", column_info[j].align_special);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-01-09 16:23:48 +00:00
|
|
|
|
l_getline(is, line);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (!prefixIs(line, "<row")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected <row ...> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
getTokenValue(line, "topline", row_info[i].top_line);
|
|
|
|
|
getTokenValue(line, "bottomline", row_info[i].bottom_line);
|
2006-07-03 19:13:56 +00:00
|
|
|
|
getTokenValue(line, "topspace", row_info[i].top_space,
|
|
|
|
|
row_info[i].top_space_default);
|
|
|
|
|
getTokenValue(line, "bottomspace", row_info[i].bottom_space,
|
|
|
|
|
row_info[i].bottom_space_default);
|
|
|
|
|
getTokenValue(line, "interlinespace", row_info[i].interline_space,
|
|
|
|
|
row_info[i].interline_space_default);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
getTokenValue(line, "endfirsthead", row_info[i].endfirsthead);
|
|
|
|
|
getTokenValue(line, "endhead", row_info[i].endhead);
|
|
|
|
|
getTokenValue(line, "endfoot", row_info[i].endfoot);
|
|
|
|
|
getTokenValue(line, "endlastfoot", row_info[i].endlastfoot);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
getTokenValue(line, "newpage", row_info[i].newpage);
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
l_getline(is, line);
|
|
|
|
|
if (!prefixIs(line, "<cell")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected <cell ...> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
|
|
|
|
|
getTokenValue(line, "alignment", cell_info[i][j].alignment);
|
|
|
|
|
getTokenValue(line, "valignment", cell_info[i][j].valignment);
|
|
|
|
|
getTokenValue(line, "topline", cell_info[i][j].top_line);
|
|
|
|
|
getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
|
|
|
|
|
getTokenValue(line, "leftline", cell_info[i][j].left_line);
|
|
|
|
|
getTokenValue(line, "rightline", cell_info[i][j].right_line);
|
|
|
|
|
getTokenValue(line, "rotate", cell_info[i][j].rotate);
|
|
|
|
|
getTokenValue(line, "usebox", cell_info[i][j].usebox);
|
|
|
|
|
getTokenValue(line, "width", cell_info[i][j].p_width);
|
|
|
|
|
getTokenValue(line, "special", cell_info[i][j].align_special);
|
|
|
|
|
l_getline(is, line);
|
|
|
|
|
if (prefixIs(line, "\\begin_inset")) {
|
2004-11-23 23:04:52 +00:00
|
|
|
|
cell_info[i][j].inset->read(buf, lex);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
l_getline(is, line);
|
|
|
|
|
}
|
|
|
|
|
if (!prefixIs(line, "</cell>")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected </cell> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
l_getline(is, line);
|
|
|
|
|
if (!prefixIs(line, "</row>")) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr << "Wrong tabular format (expected </row> got"
|
|
|
|
|
<< line << ')' << endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2001-01-09 16:23:48 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
while (!prefixIs(line, "</lyxtabular>")) {
|
|
|
|
|
l_getline(is, line);
|
2001-01-09 16:23:48 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
set_row_column_number_info();
|
2001-01-09 16:23:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isMultiColumn(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-10-06 14:10:59 +00:00
|
|
|
|
return cellinfo_of_cell(cell).multicolumn != LyXTabular::CELL_NORMAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isMultiColumnReal(idx_type cell) const
|
2003-10-06 14:10:59 +00:00
|
|
|
|
{
|
|
|
|
|
return column_of_cell(cell) != right_column_of_cell(cell) &&
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).multicolumn != LyXTabular::CELL_NORMAL;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::cellstruct & LyXTabular::cellinfo_of_cell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cell_info[row_of_cell(cell)][column_of_cell(cell)];
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
2000-09-26 13:54:57 +00:00
|
|
|
|
|
2000-04-21 15:16:22 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setMultiColumn(Buffer * buffer, idx_type cell,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
idx_type number)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellstruct & cs = cellinfo_of_cell(cell);
|
|
|
|
|
cs.multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
|
|
|
|
|
cs.alignment = column_info[column_of_cell(cell)].alignment;
|
|
|
|
|
cs.top_line = row_info[row_of_cell(cell)].top_line;
|
|
|
|
|
cs.bottom_line = row_info[row_of_cell(cell)].bottom_line;
|
2005-07-20 00:10:56 +00:00
|
|
|
|
cs.left_line = column_info[column_of_cell(cell)].left_line;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cs.right_line = column_info[column_of_cell(cell+number-1)].right_line;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = 1; i < number; ++i) {
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellstruct & cs1 = cellinfo_of_cell(cell + i);
|
|
|
|
|
cs1.multicolumn = CELL_PART_OF_MULTICOLUMN;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
cs.inset->appendParagraphs(buffer, cs1.inset->paragraphs());
|
2005-09-07 10:37:05 +00:00
|
|
|
|
cs1.inset->clear();
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
set_row_column_number_info();
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::cells_in_multicolumn(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type column = column_of_cell(cell);
|
|
|
|
|
idx_type result = 1;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++column;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
while (column < columns_ &&
|
2001-04-02 14:02:58 +00:00
|
|
|
|
cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
|
|
|
|
|
{
|
|
|
|
|
++result;
|
|
|
|
|
++column;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::unsetMultiColumn(idx_type cell)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
row_type const row = row_of_cell(cell);
|
|
|
|
|
col_type column = column_of_cell(cell);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type result = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell_info[row][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
|
|
|
|
|
cell_info[row][column].multicolumn = CELL_NORMAL;
|
|
|
|
|
++column;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
while (column < columns_ &&
|
|
|
|
|
cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
{
|
|
|
|
|
cell_info[row][column].multicolumn = CELL_NORMAL;
|
|
|
|
|
++column;
|
|
|
|
|
++result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set_row_column_number_info();
|
|
|
|
|
return result;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-03 19:13:56 +00:00
|
|
|
|
void LyXTabular::setBookTabs(bool what)
|
|
|
|
|
{
|
|
|
|
|
use_booktabs = what;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXTabular::useBookTabs() const
|
|
|
|
|
{
|
|
|
|
|
return use_booktabs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
void LyXTabular::setLongTabular(bool what)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
is_long_tabular = what;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
bool LyXTabular::isLongTabular() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return is_long_tabular;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
void LyXTabular::setRotateTabular(bool flag)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
rotate = flag;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
bool LyXTabular::getRotateTabular() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return rotate;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setRotateCell(idx_type cell, bool flag)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).rotate = flag;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getRotateCell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cellinfo_of_cell(cell).rotate;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
bool LyXTabular::needRotating() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (rotate)
|
|
|
|
|
return true;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
|
|
|
|
for (col_type j = 0; j < columns_; ++j)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (cell_info[i][j].rotate)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isLastCell(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (cell + 1 < numberofcells)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getCellAbove(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (row_of_cell(cell) > 0)
|
|
|
|
|
return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
|
|
|
|
|
return cell;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getCellBelow(idx_type cell) const
|
2000-05-22 15:20:02 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (row_of_cell(cell) + 1 < rows_)
|
|
|
|
|
return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
|
|
|
|
|
return cell;
|
2000-05-22 15:20:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getLastCellAbove(idx_type cell) const
|
2000-05-26 13:09:14 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
if (row_of_cell(cell) == 0)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return cell;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isMultiColumn(cell))
|
|
|
|
|
return getCellAbove(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return cell_info[row_of_cell(cell) - 1][right_column_of_cell(cell)].cellno;
|
2000-05-26 13:09:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getLastCellBelow(idx_type cell) const
|
2000-05-26 13:09:14 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (row_of_cell(cell) + 1 >= rows_)
|
|
|
|
|
return cell;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isMultiColumn(cell))
|
|
|
|
|
return getCellBelow(cell);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return cell_info[row_of_cell(cell) + 1][right_column_of_cell(cell)].cellno;
|
2000-05-26 13:09:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type LyXTabular::getCellNumber(row_type row,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type column) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
BOOST_ASSERT(column != npos && column < columns_ &&
|
2006-04-05 23:56:29 +00:00
|
|
|
|
row != npos && row < rows_);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return cell_info[row][column].cellno;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setUsebox(idx_type cell, BoxType type)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
cellinfo_of_cell(cell).usebox = type;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::BoxType LyXTabular::getUsebox(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-12-11 17:26:52 +00:00
|
|
|
|
if (column_info[column_of_cell(cell)].p_width.zero() &&
|
2003-07-21 11:01:29 +00:00
|
|
|
|
!(isMultiColumn(cell) && !cellinfo_of_cell(cell).p_width.zero()))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return BOX_NONE;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (cellinfo_of_cell(cell).usebox > 1)
|
|
|
|
|
return cellinfo_of_cell(cell).usebox;
|
2003-06-12 11:52:44 +00:00
|
|
|
|
return useParbox(cell);
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-12-20 14:52:15 +00:00
|
|
|
|
///
|
|
|
|
|
// This are functions used for the longtable support
|
|
|
|
|
///
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setLTHead(row_type row, bool flag, ltType const & hd,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
bool first)
|
2001-10-24 15:07:39 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (first) {
|
2001-10-24 15:07:39 +00:00
|
|
|
|
endfirsthead = hd;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (hd.set)
|
|
|
|
|
row_info[row].endfirsthead = flag;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2001-10-24 15:07:39 +00:00
|
|
|
|
endhead = hd;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (hd.set)
|
|
|
|
|
row_info[row].endhead = flag;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getRowOfLTHead(row_type row, ltType & hd) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-10-24 15:07:39 +00:00
|
|
|
|
hd = endhead;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
hd.set = haveLTHead();
|
2001-12-19 21:25:34 +00:00
|
|
|
|
return row_info[row].endhead;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getRowOfLTFirstHead(row_type row, ltType & hd) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-10-24 15:07:39 +00:00
|
|
|
|
hd = endfirsthead;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
hd.set = haveLTFirstHead();
|
2001-12-19 21:25:34 +00:00
|
|
|
|
return row_info[row].endfirsthead;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setLTFoot(row_type row, bool flag, ltType const & fd,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
bool last)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (last) {
|
2001-10-24 15:07:39 +00:00
|
|
|
|
endlastfoot = fd;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (fd.set)
|
|
|
|
|
row_info[row].endlastfoot = flag;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2001-10-24 15:07:39 +00:00
|
|
|
|
endfoot = fd;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (fd.set)
|
|
|
|
|
row_info[row].endfoot = flag;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getRowOfLTFoot(row_type row, ltType & fd) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-10-24 15:07:39 +00:00
|
|
|
|
fd = endfoot;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
fd.set = haveLTFoot();
|
2001-12-19 21:25:34 +00:00
|
|
|
|
return row_info[row].endfoot;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getRowOfLTLastFoot(row_type row, ltType & fd) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-10-24 15:07:39 +00:00
|
|
|
|
fd = endlastfoot;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
fd.set = haveLTLastFoot();
|
2001-12-19 21:25:34 +00:00
|
|
|
|
return row_info[row].endlastfoot;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setLTNewPage(row_type row, bool what)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-12-19 16:13:21 +00:00
|
|
|
|
row_info[row].newpage = what;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::getLTNewPage(row_type row) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-12-19 16:13:21 +00:00
|
|
|
|
return row_info[row].newpage;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2001-12-20 14:52:15 +00:00
|
|
|
|
bool LyXTabular::haveLTHead() const
|
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endhead)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXTabular::haveLTFirstHead() const
|
|
|
|
|
{
|
|
|
|
|
if (endfirsthead.empty)
|
|
|
|
|
return false;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endfirsthead)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXTabular::haveLTFoot() const
|
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endfoot)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXTabular::haveLTLastFoot() const
|
|
|
|
|
{
|
|
|
|
|
if (endlastfoot.empty)
|
|
|
|
|
return false;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i)
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endlastfoot)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// end longtable support functions
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setAscentOfRow(row_type row, int height)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (row >= rows_ || row_info[row].ascent_of_row == height)
|
2003-07-31 12:25:36 +00:00
|
|
|
|
return;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row_info[row].ascent_of_row = height;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
void LyXTabular::setDescentOfRow(row_type row, int height)
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (row >= rows_ || row_info[row].descent_of_row == height)
|
2003-07-31 12:25:36 +00:00
|
|
|
|
return;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
row_info[row].descent_of_row = height;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getAscentOfRow(row_type row) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (row >= rows_)
|
|
|
|
|
return 0;
|
|
|
|
|
return row_info[row].ascent_of_row;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
int LyXTabular::getDescentOfRow(row_type row) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-08-14 21:28:59 +00:00
|
|
|
|
BOOST_ASSERT(row < rows_);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return row_info[row].descent_of_row;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
int LyXTabular::getHeightOfTabular() const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int height = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type row = 0; row < rows_; ++row)
|
2003-06-12 11:52:44 +00:00
|
|
|
|
height += getAscentOfRow(row) + getDescentOfRow(row) +
|
|
|
|
|
getAdditionalHeight(row);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return height;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isPartOfMultiColumn(row_type row, col_type column) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-08-14 21:28:59 +00:00
|
|
|
|
BOOST_ASSERT(row < rows_);
|
|
|
|
|
BOOST_ASSERT(column < columns_);
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXTopHLine(odocstream & os, row_type row) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
// FIXME: assert or return 0 as in TeXBottomHLine()?
|
|
|
|
|
BOOST_ASSERT(row != npos);
|
2004-08-14 21:28:59 +00:00
|
|
|
|
BOOST_ASSERT(row < rows_);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const fcell = getFirstCellInRow(row);
|
|
|
|
|
idx_type const n = numberOfCellsInRow(fcell) + fcell;
|
|
|
|
|
idx_type tmp = 0;
|
2001-01-09 16:23:48 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (topLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
}
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (use_booktabs && row == 0) {
|
|
|
|
|
os << "\\toprule ";
|
|
|
|
|
} else if (tmp == n - fcell) {
|
|
|
|
|
os << (use_booktabs ? "\\midrule " : "\\hline ");
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else if (tmp) {
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (topLine(i)) {
|
2006-07-03 19:13:56 +00:00
|
|
|
|
os << (use_booktabs ? "\\cmidrule{" : "\\cline{")
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< column_of_cell(i) + 1
|
|
|
|
|
<< '-'
|
|
|
|
|
<< right_column_of_cell(i) + 1
|
|
|
|
|
<< "} ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
os << "\n";
|
|
|
|
|
return 1;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-05 13:46:34 +00:00
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXBottomHLine(odocstream & os, row_type row) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
// FIXME: return 0 or assert as in TeXTopHLine()?
|
|
|
|
|
if (row == npos || row >= rows_)
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const fcell = getFirstCellInRow(row);
|
|
|
|
|
idx_type const n = numberOfCellsInRow(fcell) + fcell;
|
|
|
|
|
idx_type tmp = 0;
|
2001-01-09 16:23:48 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (bottomLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
}
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (use_booktabs && row == rows_ - 1) {
|
|
|
|
|
os << "\\bottomrule";
|
|
|
|
|
} else if (tmp == n - fcell) {
|
|
|
|
|
os << (use_booktabs ? "\\midrule" : "\\hline");
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else if (tmp) {
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (bottomLine(i)) {
|
2006-07-03 19:13:56 +00:00
|
|
|
|
os << (use_booktabs ? "\\cmidrule{" : "\\cline{")
|
2001-04-02 14:02:58 +00:00
|
|
|
|
<< column_of_cell(i) + 1
|
|
|
|
|
<< '-'
|
|
|
|
|
<< right_column_of_cell(i) + 1
|
|
|
|
|
<< "} ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
os << "\n";
|
|
|
|
|
return 1;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXCellPreamble(odocstream & os, idx_type cell) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int ret = 0;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getRotateCell(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "\\begin{sideways}\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isMultiColumn(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (!cellinfo_of_cell(cell).align_special.empty()) {
|
2007-01-05 17:11:32 +00:00
|
|
|
|
os << cellinfo_of_cell(cell).align_special << "}{";
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (leftLine(cell) &&
|
|
|
|
|
(isFirstCellInRow(cell) ||
|
2003-07-21 11:01:29 +00:00
|
|
|
|
(!isMultiColumn(cell - 1) && !leftLine(cell, true) &&
|
|
|
|
|
!rightLine(cell - 1, true))))
|
2001-05-28 15:11:24 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << '|';
|
2001-05-28 15:11:24 +00:00
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!getPWidth(cell).zero()) {
|
|
|
|
|
switch (getVAlignment(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
case LYX_VALIGN_TOP:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'p';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LYX_VALIGN_MIDDLE:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'm';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
|
|
|
|
case LYX_VALIGN_BOTTOM:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'b';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '{'
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(getPWidth(cell).asLatexString())
|
2002-11-27 10:30:28 +00:00
|
|
|
|
<< '}';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getAlignment(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
os << 'l';
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
os << 'r';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
os << 'c';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (rightLine(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << '|';
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (((cell + 1) < numberofcells) && !isFirstCellInRow(cell+1) &&
|
|
|
|
|
leftLine(cell+1))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << '|';
|
|
|
|
|
os << "}{";
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getUsebox(cell) == BOX_PARBOX) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "\\parbox[";
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getVAlignment(cell)) {
|
2000-07-17 14:31:07 +00:00
|
|
|
|
case LYX_VALIGN_TOP:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 't';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LYX_VALIGN_MIDDLE:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'c';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
case LYX_VALIGN_BOTTOM:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'b';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << "]{" << from_ascii(getPWidth(cell).asLatexString())
|
2006-10-19 16:51:30 +00:00
|
|
|
|
<< "}{";
|
2003-06-12 11:52:44 +00:00
|
|
|
|
} else if (getUsebox(cell) == BOX_MINIPAGE) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "\\begin{minipage}[";
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getVAlignment(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
case LYX_VALIGN_TOP:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 't';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LYX_VALIGN_MIDDLE:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'm';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
|
|
|
|
case LYX_VALIGN_BOTTOM:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'b';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
break;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << "]{" << from_ascii(getPWidth(cell).asLatexString())
|
2006-10-19 16:51:30 +00:00
|
|
|
|
<< "}\n";
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXCellPostamble(odocstream & os, idx_type cell) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
|
|
// usual cells
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getUsebox(cell) == BOX_PARBOX)
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '}';
|
2003-06-12 11:52:44 +00:00
|
|
|
|
else if (getUsebox(cell) == BOX_MINIPAGE) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "%\n\\end{minipage}";
|
|
|
|
|
ret += 2;
|
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isMultiColumn(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << '}';
|
|
|
|
|
}
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getRotateCell(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "%\n\\end{sideways}";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXLongtableHeaderFooter(odocstream & os, Buffer const & buf,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-12-20 14:52:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (!is_long_tabular)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
|
// output header info
|
|
|
|
|
if (haveLTHead()) {
|
|
|
|
|
if (endhead.topDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endhead) {
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXRow(os, i, buf, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (endhead.bottomDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
os << "\\endhead\n";
|
|
|
|
|
++ret;
|
|
|
|
|
if (endfirsthead.empty) {
|
|
|
|
|
os << "\\endfirsthead\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// output firstheader info
|
|
|
|
|
if (haveLTFirstHead()) {
|
|
|
|
|
if (endfirsthead.topDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endfirsthead) {
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXRow(os, i, buf, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (endfirsthead.bottomDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
os << "\\endfirsthead\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
// output footer info
|
|
|
|
|
if (haveLTFoot()) {
|
|
|
|
|
if (endfoot.topDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endfoot) {
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXRow(os, i, buf, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (endfoot.bottomDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
os << "\\endfoot\n";
|
|
|
|
|
++ret;
|
|
|
|
|
if (endlastfoot.empty) {
|
|
|
|
|
os << "\\endlastfoot\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// output lastfooter info
|
|
|
|
|
if (haveLTLastFoot()) {
|
|
|
|
|
if (endlastfoot.topDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (row_info[i].endlastfoot) {
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXRow(os, i, buf, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (endlastfoot.bottomDL) {
|
|
|
|
|
os << "\\hline\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
os << "\\endlastfoot\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
bool LyXTabular::isValidRow(row_type row) const
|
2001-12-20 14:52:15 +00:00
|
|
|
|
{
|
|
|
|
|
if (!is_long_tabular)
|
|
|
|
|
return true;
|
2003-10-06 14:10:59 +00:00
|
|
|
|
return !row_info[row].endhead && !row_info[row].endfirsthead &&
|
|
|
|
|
!row_info[row].endfoot && !row_info[row].endlastfoot;
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::TeXRow(odocstream & os, row_type i, Buffer const & buf,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-12-20 14:52:15 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type cell = getCellNumber(i, 0);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
int ret = TeXTopHLine(os, i);
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (row_info[i].top_space_default) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace\n";
|
|
|
|
|
else
|
|
|
|
|
os << "\\noalign{\\vskip\\doublerulesep}\n";
|
2007-02-27 10:42:34 +00:00
|
|
|
|
++ret;
|
2006-07-03 19:13:56 +00:00
|
|
|
|
} else if(!row_info[i].top_space.zero()) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace["
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(row_info[i].top_space.asLatexString())
|
2006-10-19 16:51:30 +00:00
|
|
|
|
<< "]\n";
|
2006-07-03 19:13:56 +00:00
|
|
|
|
else {
|
|
|
|
|
os << "\\noalign{\\vskip"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(row_info[i].top_space.asLatexString())
|
2006-10-19 16:51:30 +00:00
|
|
|
|
<< "}\n";
|
2006-07-03 19:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (isPartOfMultiColumn(i, j))
|
2001-12-20 14:52:15 +00:00
|
|
|
|
continue;
|
|
|
|
|
ret += TeXCellPreamble(os, cell);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
shared_ptr<InsetText> inset = getCellInset(cell);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
Paragraph const & par = inset->paragraphs().front();
|
2004-03-21 10:16:39 +00:00
|
|
|
|
bool rtl = par.isRightToLeftPar(buf.params())
|
2004-03-25 09:16:36 +00:00
|
|
|
|
&& !par.empty()
|
2004-02-16 11:58:51 +00:00
|
|
|
|
&& getPWidth(cell).zero();
|
2001-12-20 14:52:15 +00:00
|
|
|
|
|
|
|
|
|
if (rtl)
|
|
|
|
|
os << "\\R{";
|
2004-11-23 23:04:52 +00:00
|
|
|
|
ret += inset->latex(buf, os, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (rtl)
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '}';
|
2001-12-20 14:52:15 +00:00
|
|
|
|
|
|
|
|
|
ret += TeXCellPostamble(os, cell);
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (!isLastCellInRow(cell)) { // not last cell in row
|
2006-10-27 09:54:56 +00:00
|
|
|
|
os << " & ";
|
2001-12-20 14:52:15 +00:00
|
|
|
|
}
|
|
|
|
|
++cell;
|
|
|
|
|
}
|
2006-07-03 19:13:56 +00:00
|
|
|
|
os << "\\tabularnewline";
|
|
|
|
|
if (row_info[i].bottom_space_default) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace";
|
|
|
|
|
else
|
|
|
|
|
os << "[\\doublerulesep]";
|
|
|
|
|
} else if (!row_info[i].bottom_space.zero()) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace";
|
2006-10-19 16:51:30 +00:00
|
|
|
|
os << '['
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(row_info[i].bottom_space.asLatexString())
|
2006-10-19 16:51:30 +00:00
|
|
|
|
<< ']';
|
2006-07-03 19:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
os << '\n';
|
2001-12-20 14:52:15 +00:00
|
|
|
|
++ret;
|
|
|
|
|
ret += TeXBottomHLine(os, i);
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (row_info[i].interline_space_default) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace\n";
|
|
|
|
|
else
|
|
|
|
|
os << "\\noalign{\\vskip\\doublerulesep}\n";
|
2007-02-27 10:42:34 +00:00
|
|
|
|
++ret;
|
2006-07-03 19:13:56 +00:00
|
|
|
|
} else if (!row_info[i].interline_space.zero()) {
|
|
|
|
|
if (use_booktabs)
|
|
|
|
|
os << "\\addlinespace["
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(row_info[i].interline_space.asLatexString())
|
2006-07-03 19:13:56 +00:00
|
|
|
|
<< "]\n";
|
|
|
|
|
else
|
|
|
|
|
os << "\\noalign{\\vskip"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(row_info[i].interline_space.asLatexString())
|
2006-07-03 19:13:56 +00:00
|
|
|
|
<< "}\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2001-12-20 14:52:15 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int LyXTabular::latex(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-05-15 14:49:36 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int ret = 0;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ first the opening preamble +
|
|
|
|
|
//+---------------------------------------------------------------------
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (rotate) {
|
|
|
|
|
os << "\\begin{sideways}\n";
|
2000-07-17 14:31:07 +00:00
|
|
|
|
++ret;
|
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (is_long_tabular)
|
|
|
|
|
os << "\\begin{longtable}{";
|
|
|
|
|
else
|
|
|
|
|
os << "\\begin{tabular}{";
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = 0; i < columns_; ++i) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (!column_info[i].align_special.empty()) {
|
2007-01-05 17:11:32 +00:00
|
|
|
|
os << column_info[i].align_special;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
} else {
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (!use_booktabs && column_info[i].left_line)
|
2001-08-08 13:29:13 +00:00
|
|
|
|
os << '|';
|
2001-12-11 17:26:52 +00:00
|
|
|
|
if (!column_info[i].p_width.zero()) {
|
2003-01-08 09:03:32 +00:00
|
|
|
|
switch (column_info[i].alignment) {
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
os << ">{\\raggedright}";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
os << ">{\\raggedleft}";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
|
os << ">{\\centering}";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_NONE:
|
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
|
case LYX_ALIGN_LAYOUT:
|
|
|
|
|
case LYX_ALIGN_SPECIAL:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2001-08-08 13:29:13 +00:00
|
|
|
|
switch (column_info[i].valignment) {
|
|
|
|
|
case LYX_VALIGN_TOP:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'p';
|
2001-08-08 13:29:13 +00:00
|
|
|
|
break;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LYX_VALIGN_MIDDLE:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'm';
|
2001-08-08 13:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case LYX_VALIGN_BOTTOM:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'b';
|
2001-08-08 13:29:13 +00:00
|
|
|
|
break;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '{'
|
2006-10-21 00:16:43 +00:00
|
|
|
|
<< from_ascii(column_info[i].p_width.asLatexString())
|
2001-08-08 13:29:13 +00:00
|
|
|
|
<< '}';
|
|
|
|
|
} else {
|
|
|
|
|
switch (column_info[i].alignment) {
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
os << 'l';
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << 'r';
|
|
|
|
|
break;
|
2001-08-08 13:29:13 +00:00
|
|
|
|
default:
|
|
|
|
|
os << 'c';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (!use_booktabs && column_info[i].right_line)
|
2001-08-08 13:29:13 +00:00
|
|
|
|
os << '|';
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-07-17 14:31:07 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "}\n";
|
|
|
|
|
++ret;
|
|
|
|
|
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXLongtableHeaderFooter(os, buf, runparams);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ the single row and columns (cells) +
|
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (isValidRow(i)) {
|
2003-05-23 08:59:47 +00:00
|
|
|
|
ret += TeXRow(os, i, buf, runparams);
|
2001-12-20 14:52:15 +00:00
|
|
|
|
if (is_long_tabular && row_info[i].newpage) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "\\newpage\n";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ the closing of the tabular +
|
|
|
|
|
//+---------------------------------------------------------------------
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (is_long_tabular)
|
|
|
|
|
os << "\\end{longtable}";
|
|
|
|
|
else
|
|
|
|
|
os << "\\end{tabular}";
|
|
|
|
|
if (rotate) {
|
|
|
|
|
os << "\n\\end{sideways}";
|
|
|
|
|
++ret;
|
|
|
|
|
}
|
2000-05-15 14:49:36 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return ret;
|
2000-10-27 10:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int LyXTabular::docbookRow(Buffer const & buf, odocstream & os, row_type row,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-10-24 07:43:34 +00:00
|
|
|
|
{
|
|
|
|
|
int ret = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type cell = getFirstCellInRow(row);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-10-24 07:43:34 +00:00
|
|
|
|
os << "<row>\n";
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isPartOfMultiColumn(row, j))
|
2001-10-24 07:43:34 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
os << "<entry align=\"";
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getAlignment(cell)) {
|
2001-10-24 07:43:34 +00:00
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
os << "left";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
os << "right";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
os << "center";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
os << "\" valign=\"";
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getVAlignment(cell)) {
|
2001-10-24 07:43:34 +00:00
|
|
|
|
case LYX_VALIGN_TOP:
|
|
|
|
|
os << "top";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_VALIGN_BOTTOM:
|
|
|
|
|
os << "bottom";
|
|
|
|
|
break;
|
2003-08-14 15:45:09 +00:00
|
|
|
|
case LYX_VALIGN_MIDDLE:
|
2001-10-24 07:43:34 +00:00
|
|
|
|
os << "middle";
|
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '"';
|
2001-10-24 07:43:34 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isMultiColumn(cell)) {
|
2001-10-24 07:43:34 +00:00
|
|
|
|
os << " namest=\"col" << j << "\" ";
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << "nameend=\"col" << j + cells_in_multicolumn(cell) - 1<< '"';
|
2001-10-24 07:43:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '>';
|
2004-11-23 23:04:52 +00:00
|
|
|
|
ret += getCellInset(cell)->docbook(buf, os, runparams);
|
2001-10-24 07:43:34 +00:00
|
|
|
|
os << "</entry>\n";
|
|
|
|
|
++cell;
|
|
|
|
|
}
|
|
|
|
|
os << "</row>\n";
|
|
|
|
|
return ret;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2001-10-24 07:43:34 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int LyXTabular::docbook(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-10-27 10:04:51 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int ret = 0;
|
2000-10-27 10:04:51 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ first the opening preamble +
|
|
|
|
|
//+---------------------------------------------------------------------
|
2000-10-27 10:04:51 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "<tgroup cols=\"" << columns_
|
|
|
|
|
<< "\" colsep=\"1\" rowsep=\"1\">\n";
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type i = 0; i < columns_; ++i) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "<colspec colname=\"col" << i << "\" align=\"";
|
|
|
|
|
switch (column_info[i].alignment) {
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
os << "left";
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
os << "right";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
os << "center";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-08-13 13:07:02 +00:00
|
|
|
|
os << '"';
|
|
|
|
|
if (runparams.flavor == OutputParams::XML)
|
|
|
|
|
os << '/';
|
|
|
|
|
os << ">\n";
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++ret;
|
2000-10-27 10:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
2001-10-24 07:43:34 +00:00
|
|
|
|
//+ Long Tabular case +
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
2000-10-27 10:04:51 +00:00
|
|
|
|
|
2002-02-21 15:55:49 +00:00
|
|
|
|
// output header info
|
|
|
|
|
if (haveLTHead() || haveLTFirstHead()) {
|
|
|
|
|
os << "<thead>\n";
|
|
|
|
|
++ret;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2002-02-21 15:55:49 +00:00
|
|
|
|
if (row_info[i].endhead || row_info[i].endfirsthead) {
|
2003-10-31 18:45:43 +00:00
|
|
|
|
ret += docbookRow(buf, os, i, runparams);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2001-10-24 07:43:34 +00:00
|
|
|
|
}
|
2002-05-03 11:56:49 +00:00
|
|
|
|
os << "</thead>\n";
|
2002-02-21 15:55:49 +00:00
|
|
|
|
++ret;
|
|
|
|
|
}
|
|
|
|
|
// output footer info
|
|
|
|
|
if (haveLTFoot() || haveLTLastFoot()) {
|
|
|
|
|
os << "<tfoot>\n";
|
|
|
|
|
++ret;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2002-02-21 15:55:49 +00:00
|
|
|
|
if (row_info[i].endfoot || row_info[i].endlastfoot) {
|
2003-10-31 18:45:43 +00:00
|
|
|
|
ret += docbookRow(buf, os, i, runparams);
|
2001-10-24 07:43:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-21 15:55:49 +00:00
|
|
|
|
os << "</tfoot>\n";
|
|
|
|
|
++ret;
|
2001-10-24 07:43:34 +00:00
|
|
|
|
}
|
2002-02-21 15:55:49 +00:00
|
|
|
|
|
2001-10-24 07:43:34 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ the single row and columns (cells) +
|
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
os << "<tbody>\n";
|
2002-02-21 15:55:49 +00:00
|
|
|
|
++ret;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2002-02-21 15:55:49 +00:00
|
|
|
|
if (isValidRow(i)) {
|
2003-10-31 18:45:43 +00:00
|
|
|
|
ret += docbookRow(buf, os, i, runparams);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
os << "</tbody>\n";
|
2002-02-21 15:55:49 +00:00
|
|
|
|
++ret;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
//+ the closing of the tabular +
|
|
|
|
|
//+---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
os << "</tgroup>";
|
|
|
|
|
++ret;
|
|
|
|
|
|
|
|
|
|
return ret;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
|
2007-02-18 18:50:08 +00:00
|
|
|
|
bool LyXTabular::plaintextTopHLine(odocstream & os, row_type row,
|
|
|
|
|
vector<unsigned int> const & clen) const
|
2000-10-10 10:38:11 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const fcell = getFirstCellInRow(row);
|
|
|
|
|
idx_type const n = numberOfCellsInRow(fcell) + fcell;
|
|
|
|
|
idx_type tmp = 0;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (topLine(i)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-01-02 16:06:14 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (!tmp)
|
2007-02-18 18:50:08 +00:00
|
|
|
|
return false;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
char_type ch;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (topLine(i)) {
|
|
|
|
|
if (leftLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "+-";
|
|
|
|
|
else
|
|
|
|
|
os << "--";
|
|
|
|
|
ch = '-';
|
|
|
|
|
} else {
|
|
|
|
|
os << " ";
|
|
|
|
|
ch = ' ';
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type column = column_of_cell(i);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int len = clen[column];
|
2004-10-05 10:11:42 +00:00
|
|
|
|
while (column < columns_ - 1
|
2004-08-16 00:32:04 +00:00
|
|
|
|
&& isPartOfMultiColumn(row, ++column))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
len += clen[column] + 4;
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(len, ch);
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (topLine(i)) {
|
|
|
|
|
if (rightLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "-+";
|
|
|
|
|
else
|
|
|
|
|
os << "--";
|
|
|
|
|
} else {
|
|
|
|
|
os << " ";
|
|
|
|
|
}
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << endl;
|
2007-02-18 18:50:08 +00:00
|
|
|
|
return true;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-18 18:50:08 +00:00
|
|
|
|
bool LyXTabular::plaintextBottomHLine(odocstream & os, row_type row,
|
|
|
|
|
vector<unsigned int> const & clen) const
|
2000-10-10 10:38:11 +00:00
|
|
|
|
{
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const fcell = getFirstCellInRow(row);
|
|
|
|
|
idx_type const n = numberOfCellsInRow(fcell) + fcell;
|
|
|
|
|
idx_type tmp = 0;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (bottomLine(i)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-01-02 16:06:14 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (!tmp)
|
2007-02-18 18:50:08 +00:00
|
|
|
|
return false;
|
2001-01-02 16:06:14 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
char_type ch;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type i = fcell; i < n; ++i) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (bottomLine(i)) {
|
|
|
|
|
if (leftLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "+-";
|
|
|
|
|
else
|
|
|
|
|
os << "--";
|
|
|
|
|
ch = '-';
|
|
|
|
|
} else {
|
|
|
|
|
os << " ";
|
|
|
|
|
ch = ' ';
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
col_type column = column_of_cell(i);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
int len = clen[column];
|
2004-08-16 00:32:04 +00:00
|
|
|
|
while (column < columns_ -1
|
|
|
|
|
&& isPartOfMultiColumn(row, ++column))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
len += clen[column] + 4;
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(len, ch);
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (bottomLine(i)) {
|
|
|
|
|
if (rightLine(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "-+";
|
|
|
|
|
else
|
|
|
|
|
os << "--";
|
|
|
|
|
} else {
|
|
|
|
|
os << " ";
|
|
|
|
|
}
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << endl;
|
2007-02-18 18:50:08 +00:00
|
|
|
|
return true;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-18 18:50:08 +00:00
|
|
|
|
void LyXTabular::plaintextPrintCell(Buffer const & buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type cell, row_type row, col_type column,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
vector<unsigned int> const & clen,
|
|
|
|
|
bool onlydata) const
|
2001-04-02 14:02:58 +00:00
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream sstr;
|
2007-02-18 18:50:08 +00:00
|
|
|
|
getCellInset(cell)->plaintext(buf, sstr, runparams);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
|
2001-12-27 15:54:25 +00:00
|
|
|
|
if (onlydata) {
|
|
|
|
|
os << sstr.str();
|
2007-02-18 18:50:08 +00:00
|
|
|
|
return;
|
2001-12-27 15:54:25 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (leftLine(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << "| ";
|
|
|
|
|
else
|
|
|
|
|
os << " ";
|
|
|
|
|
|
|
|
|
|
unsigned int len1 = sstr.str().length();
|
|
|
|
|
unsigned int len2 = clen[column];
|
2004-08-16 00:32:04 +00:00
|
|
|
|
while (column < columns_ -1
|
|
|
|
|
&& isPartOfMultiColumn(row, ++column))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
len2 += clen[column] + 4;
|
2000-10-10 10:38:11 +00:00
|
|
|
|
len2 -= len1;
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
switch (getAlignment(cell)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
default:
|
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
|
len1 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
|
len1 = len2;
|
|
|
|
|
len2 = 0;
|
|
|
|
|
break;
|
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
|
len1 = len2 / 2;
|
|
|
|
|
len2 -= len1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(len1, ' ') << sstr.str()
|
|
|
|
|
<< docstring(len2, ' ');
|
2003-06-11 15:45:55 +00:00
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (rightLine(cell))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
os << " |";
|
|
|
|
|
else
|
|
|
|
|
os << " ";
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-18 18:50:08 +00:00
|
|
|
|
void LyXTabular::plaintext(Buffer const & buf, odocstream & os,
|
|
|
|
|
OutputParams const & runparams, int const depth,
|
|
|
|
|
bool onlydata, unsigned char delim) const
|
2000-10-10 10:38:11 +00:00
|
|
|
|
{
|
2003-06-11 15:40:11 +00:00
|
|
|
|
// first calculate the width of the single columns
|
2001-04-02 14:02:58 +00:00
|
|
|
|
vector<unsigned int> clen(columns_);
|
2000-10-10 10:38:11 +00:00
|
|
|
|
|
2001-12-27 15:54:25 +00:00
|
|
|
|
if (!onlydata) {
|
|
|
|
|
// first all non (real) multicolumn cells!
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2001-12-27 15:54:25 +00:00
|
|
|
|
clen[j] = 0;
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
|
|
|
|
idx_type cell = getCellNumber(i, j);
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (isMultiColumnReal(cell))
|
2001-12-27 15:54:25 +00:00
|
|
|
|
continue;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream sstr;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
getCellInset(cell)->plaintext(buf, sstr, runparams);
|
2001-12-27 15:54:25 +00:00
|
|
|
|
if (clen[j] < sstr.str().length())
|
|
|
|
|
clen[j] = sstr.str().length();
|
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2001-12-27 15:54:25 +00:00
|
|
|
|
// then all (real) multicolumn cells!
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
|
|
|
|
idx_type cell = getCellNumber(i, j);
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (!isMultiColumnReal(cell) || isPartOfMultiColumn(i, j))
|
2001-12-27 15:54:25 +00:00
|
|
|
|
continue;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream sstr;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
getCellInset(cell)->plaintext(buf, sstr, runparams);
|
2001-12-27 15:54:25 +00:00
|
|
|
|
int len = int(sstr.str().length());
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type const n = cells_in_multicolumn(cell);
|
|
|
|
|
for (col_type k = j; len > 0 && k < j + n - 1; ++k)
|
2001-12-27 15:54:25 +00:00
|
|
|
|
len -= clen[k];
|
|
|
|
|
if (len > int(clen[j + n - 1]))
|
|
|
|
|
clen[j + n - 1] = len;
|
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-12-03 13:57:50 +00:00
|
|
|
|
idx_type cell = 0;
|
|
|
|
|
for (row_type i = 0; i < rows_; ++i) {
|
2007-01-15 22:49:14 +00:00
|
|
|
|
if (!onlydata && plaintextTopHLine(os, i, clen))
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(depth * 2, ' ');
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (col_type j = 0; j < columns_; ++j) {
|
2003-07-21 11:01:29 +00:00
|
|
|
|
if (isPartOfMultiColumn(i, j))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
continue;
|
2001-12-27 15:54:25 +00:00
|
|
|
|
if (onlydata && j > 0)
|
|
|
|
|
os << delim;
|
2007-02-18 18:50:08 +00:00
|
|
|
|
plaintextPrintCell(buf, os, runparams,
|
|
|
|
|
cell, i, j, clen, onlydata);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
++cell;
|
|
|
|
|
}
|
|
|
|
|
os << endl;
|
2001-12-27 15:54:25 +00:00
|
|
|
|
if (!onlydata) {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(depth * 2, ' ');
|
2007-01-15 22:49:14 +00:00
|
|
|
|
if (plaintextBottomHLine(os, i, clen))
|
2006-10-11 19:40:50 +00:00
|
|
|
|
os << docstring(depth * 2, ' ');
|
2001-12-27 15:54:25 +00:00
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-10-10 10:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
shared_ptr<InsetText> LyXTabular::getCellInset(idx_type cell) const
|
2000-04-21 15:16:22 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
|
2000-04-21 15:16:22 +00:00
|
|
|
|
}
|
2000-05-19 10:32:05 +00:00
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
shared_ptr<InsetText> LyXTabular::getCellInset(row_type row,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
col_type column) const
|
2001-01-03 16:04:05 +00:00
|
|
|
|
{
|
2003-07-21 11:01:29 +00:00
|
|
|
|
return cell_info[row][column].inset;
|
2001-01-03 16:04:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-12 12:22:39 +00:00
|
|
|
|
void LyXTabular::setCellInset(row_type row, col_type column,
|
|
|
|
|
shared_ptr<InsetText> ins) const
|
|
|
|
|
{
|
|
|
|
|
cell_info[row][column].inset = ins;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::idx_type
|
|
|
|
|
LyXTabular::getCellFromInset(InsetBase const * inset) const
|
2002-01-20 16:07:42 +00:00
|
|
|
|
{
|
|
|
|
|
// is this inset part of the tabular?
|
2003-10-06 14:10:59 +00:00
|
|
|
|
if (!inset) {
|
2003-07-31 10:48:50 +00:00
|
|
|
|
lyxerr << "Error: this is not a cell of the tabular!" << endl;
|
2004-02-13 16:22:53 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
2002-01-20 16:07:42 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type cell = 0, n = getNumberOfCells(); cell < n; ++cell)
|
2004-11-23 23:04:52 +00:00
|
|
|
|
if (getCellInset(cell).get() == inset) {
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INSETTEXT) << "LyXTabular::getCellFromInset: "
|
2003-10-06 14:10:59 +00:00
|
|
|
|
<< "cell=" << cell << endl;
|
|
|
|
|
return cell;
|
2002-01-20 16:07:42 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-10-06 14:10:59 +00:00
|
|
|
|
// We should have found a cell at this point
|
2003-11-04 12:36:59 +00:00
|
|
|
|
lyxerr << "LyXTabular::getCellFromInset: Cell of inset "
|
|
|
|
|
<< inset << " not found!" << endl;
|
2004-02-13 16:22:53 +00:00
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
|
// shut up compiler
|
|
|
|
|
return 0;
|
2002-01-20 16:07:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 11:52:44 +00:00
|
|
|
|
void LyXTabular::validate(LaTeXFeatures & features) const
|
2000-05-19 10:32:05 +00:00
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
features.require("NeedTabularnewline");
|
2006-07-03 19:13:56 +00:00
|
|
|
|
if (useBookTabs())
|
|
|
|
|
features.require("booktabs");
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (isLongTabular())
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.require("longtable");
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (needRotating())
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.require("rotating");
|
2004-12-03 13:57:50 +00:00
|
|
|
|
for (idx_type cell = 0; cell < numberofcells; ++cell) {
|
2003-06-12 11:52:44 +00:00
|
|
|
|
if (getVAlignment(cell) != LYX_VALIGN_TOP ||
|
|
|
|
|
(!getPWidth(cell).zero() && !isMultiColumn(cell)))
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.require("array");
|
2004-11-23 23:04:52 +00:00
|
|
|
|
getCellInset(cell)->validate(features);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-05-19 10:32:05 +00:00
|
|
|
|
}
|
2000-08-07 15:21:05 +00:00
|
|
|
|
|
|
|
|
|
|
2004-12-03 13:57:50 +00:00
|
|
|
|
LyXTabular::BoxType LyXTabular::useParbox(idx_type cell) const
|
2000-08-07 15:21:05 +00:00
|
|
|
|
{
|
2004-11-23 23:04:52 +00:00
|
|
|
|
ParagraphList const & parlist = getCellInset(cell)->paragraphs();
|
2003-05-27 22:41:04 +00:00
|
|
|
|
ParagraphList::const_iterator cit = parlist.begin();
|
|
|
|
|
ParagraphList::const_iterator end = parlist.end();
|
2000-08-07 15:21:05 +00:00
|
|
|
|
|
2003-07-21 11:01:29 +00:00
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
|
for (int i = 0; i < cit->size(); ++i)
|
2003-03-12 19:16:42 +00:00
|
|
|
|
if (cit->isNewline(i))
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return BOX_PARBOX;
|
2003-07-21 11:01:29 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return BOX_NONE;
|
2000-08-07 15:21:05 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|