bottom_line = false;
rotate = false;
linebreaks = false;
- inset = 0;
-}
-
-
-LyXTabular::cellstruct::~cellstruct()
-{
- delete inset;
-}
-
-
-LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
-{
- cellno = cs.cellno;
- width_of_cell = cs.width_of_cell;
- multicolumn = cs.multicolumn;
- alignment = cs.alignment;
- top_line = cs.top_line;
- bottom_line = cs.bottom_line;
- rotate = cs.rotate;
- linebreaks = cs.linebreaks;
- inset = 0;
-// if (cs.inset)
-// inset = static_cast<InsetText *>(cs.inset->Clone());
-}
-
-
-LyXTabular::cellstruct &
-LyXTabular::cellstruct::operator=(cellstruct const & cs)
-{
- cellno = cs.cellno;
- width_of_cell = cs.width_of_cell;
- multicolumn = cs.multicolumn;
- alignment = cs.alignment;
- top_line = cs.top_line;
- bottom_line = cs.bottom_line;
- rotate = cs.rotate;
- linebreaks = cs.linebreaks;
- if (cs.inset)
- inset = static_cast<InsetText *>(cs.inset->Clone());
- return *this;
}
}
-LyXTabular::LyXTabular(InsetTabular * inset, LyXLex & lex)
+LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
{
owner_ = inset;
- Read(lex);
+ Read(buf, lex);
}
int i,j;
for(i=0; i < rows_; ++i) {
for(j=0; j < columns_; ++j) {
- delete result->cell_info[i][j].inset;
- result->cell_info[i][j].inset=new InsetText(*cell_info[i][j].inset,
- inset->BufferOwner());
- result->cell_info[i][j].inset->setOwner(inset);
+ result->cell_info[i][j].inset = cell_info[i][j].inset;
+ result->cell_info[i][j].inset.setOwner(inset);
}
}
return result;
// Jürgen, use iterators.
for (i = 0; i < rows_; ++i) {
for (j = 0; j < columns_; ++j) {
- if (!cell_info[i][j].inset)
- cell_info[i][j].inset = new InsetText(owner_->BufferOwner());
- cell_info[i][j].inset->setOwner(owner_);
- cell_info[i][j].inset->SetDrawLockedFrame(true);
+ cell_info[i][j].inset.setOwner(owner_);
+ cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
cell_info[i][j].cellno = cellno++;
}
}
void LyXTabular::AppendRow(int cell )
{
-// cell_vector::iterator cit = cell_info.begin() + row;
-// cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
-// cell_info.insert(cell_info.begin(), vector<cellstruct>(columns_, cellstruct()));
-
++rows_;
-// row_vector r_info = row_vector(rows_, rowstruct());
-
- cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
- cellstruct()));
int row = row_of_cell(cell);
- int i;
row_vector::iterator rit = row_info.begin() + row;
row_info.insert(rit, rowstruct());
- for(i = 0; i <= row; ++i) {
-// r_info[i] = row_info[i];
+#if 0
+ cell_vvector::iterator cit = cell_info.begin() + row;
+ cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
+#else
+ cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
+ cellstruct()));
+
+ for(int i = 0; i <= row; ++i) {
for(int j = 0; j < columns_; ++j) {
c_info[i][j] = cell_info[i][j];
}
}
- for(i = row+1; i < rows_; ++i) {
-// r_info[i] = row_info[i-1];
+ for(int i = row+1; i < rows_; ++i) {
for(int j = 0; j < columns_; ++j) {
c_info[i][j] = cell_info[i-1][j];
}
}
-// row_info = r_info;
cell_info = c_info;
- for(i = 0; i < rows_; ++i) {
- for(int j = 0; j < columns_; ++j) {
- cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
- }
- }
++row;
for (int j = 0; j < columns_; ++j) {
- cell_info[row][j].inset->clear();
+ cell_info[row][j].inset.clear();
}
+#endif
Reinit();
}
}
}
cell_info = c_info;
- for(i = 0; i < rows_; ++i) {
- for(j = 0; j < columns_; ++j) {
- cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
- }
- }
++column;
for (i = 0; i < rows_; ++i) {
- cell_info[i][column].inset->clear();
+ cell_info[i][column].inset.clear();
}
Reinit();
}
for (; i < rows_; ++i) {
for (j = 0; j < columns_; ++j) {
cell_info[i][j].width_of_cell = 0;
+ cell_info[i][j].inset.setOwner(owner_);
}
}
for (column = 0; column<columns_; ++column) {
if (IsPartOfMultiColumn(row,column))
continue;
- cell_info[row][column].inset->SetAutoBreakRows(
+ cell_info[row][column].inset.SetAutoBreakRows(
!GetPWidth(GetCellNumber(row, column)).empty());
}
}
}
-void LyXTabular::Write(ostream & os) const
+void LyXTabular::Write(Buffer const * buf, ostream & os) const
{
int i, j;
"\" special=\"" << cell_info[i][j].align_special <<
"\">" << endl;
os << "\\begin_inset ";
- cell_info[i][j].inset->Write(os);
+ cell_info[i][j].inset.Write(buf, os);
os << "\n\\end_inset " << endl;
os << "</Cell>" << endl;
os << "</Column>" << endl;
}
-void LyXTabular::Read(LyXLex & lex)
+void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
{
string line;
istream & is = lex.getStream();
(void)getTokenValue(line, "special", cell_info[i][j].align_special);
l_getline(is, line);
if (prefixIs(line, "\\begin_inset")) {
- cell_info[i][j].inset->Read(lex);
+ cell_info[i][j].inset.Read(buf, lex);
l_getline(is, line);
}
if (line != "</Cell>") {
}
-void LyXTabular::SetAscentOfRow(int row, int height)
+bool LyXTabular::SetAscentOfRow(int row, int height)
{
- if (row >= rows_)
- return;
+ if ((row >= rows_) || (row_info[row].ascent_of_row == height))
+ return false;
row_info[row].ascent_of_row = height;
+ return true;
}
-void LyXTabular::SetDescentOfRow(int row, int height)
+bool LyXTabular::SetDescentOfRow(int row, int height)
{
- if (row >= rows_)
- return;
+ if ((row >= rows_) || (row_info[row].descent_of_row == height))
+ return false;
row_info[row].descent_of_row = height;
+ return true;
}
}
-int LyXTabular::Latex(ostream & os, bool fragile, bool fp) const
+int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
{
int ret = 0;
int i,j;
if (IsPartOfMultiColumn(i,j))
continue;
ret += TeXCellPreamble(os, cell);
- ret += GetCellInset(cell)->Latex(os, fragile, fp);
+ ret += GetCellInset(cell)->Latex(buf, os, fragile, fp);
ret += TeXCellPostamble(os, cell);
if (!IsLastCellInRow(cell)) { // not last cell in row
os << "&" << endl;
InsetText * LyXTabular::GetCellInset(int cell) const
{
- return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
+ return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
}
void LyXTabular::Validate(LaTeXFeatures & features) const