*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2000-2001 The LyX Team.
*
* @author: Jürgen Vigna
*
using std::endl;
using std::vector;
+#ifndef CXX_GLOBAL_CSTD
+using std::strlen;
+#endif
+
namespace {
int const WIDTH_OF_LINE = 5;
LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
{
owner_ = inset;
+ cur_cell = -1;
Init(rows_arg, columns_arg);
}
LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
{
owner_ = inset;
+ cur_cell = -1;
Init(lt.rows_, lt.columns_, <);
#if 0
#ifdef WITH_WARNINGS
LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
{
owner_ = inset;
+ cur_cell = -1;
Read(buf, lex);
}
LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
{
+#if 0
+#warning This while method should look like this: (Lgb)
+
+ LyXTabular tmp(lt);
+ tmp.swap(*this);
+#else
// If this and lt is not of the same size we have a serious bug
// So then it is ok to throw an exception, or for now
// call abort()
lyx::Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
-
+ cur_cell = -1;
cell_info = lt.cell_info;
row_info = lt.row_info;
column_info = lt.column_info;
rotate = lt.rotate;
Reinit();
-
+#endif
return *this;
}
-LyXTabular * LyXTabular::Clone(InsetTabular * inset)
+LyXTabular * LyXTabular::clone(InsetTabular * inset)
{
LyXTabular * result = new LyXTabular(inset, *this);
#if 0
}
-/* activates all lines and sets all widths to 0 */
+/* activates all lines and sets all widths to 0 */
void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
{
rows_ = rows_arg;
operator=(*lt);
return;
}
-
+
int cellno = 0;
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
cell_info[i][j].inset.setOwner(owner_);
- cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
+ cell_info[i][j].inset.setDrawFrame(0, InsetText::LOCKED);
cell_info[i][j].cellno = cellno++;
}
cell_info[i].back().right_line = true;
cell_info[row][column].right_line =
cell_info[row][column+cn-1].right_line;
}
- cell_info[row][column].inset.SetAutoBreakRows(
+ cell_info[row][column].inset.setAutoBreakRows(
!GetPWidth(GetCellNumber(row, column)).empty());
}
}
{
if (!row || row >= rows_)
return 0;
-
+
bool top = true;
bool bottom = true;
for (int i = 0; i < rows_; ++i) {
int c = GetCellNumber(i, j);
flag = !GetPWidth(c).empty(); // because of multicolumns!
- GetCellInset(c)->SetAutoBreakRows(flag);
+ GetCellInset(c)->setAutoBreakRows(flag);
}
return true;
}
cellinfo_of_cell(cell)->p_width = width;
if (IsMultiColumn(cell)) {
- GetCellInset(cell)->SetAutoBreakRows(flag);
+ GetCellInset(cell)->setAutoBreakRows(flag);
return true;
}
return false;
<< write_attribute("special", cell_info[i][j].align_special)
<< ">\n";
os << "\\begin_inset ";
- cell_info[i][j].inset.Write(buf, os);
+ cell_info[i][j].inset.write(buf, os);
os << "\n\\end_inset \n"
<< "</cell>\n";
}
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] != '=')
+ if (pos == string::npos || pos + token_length + 1 >= str.length()
+ || str[pos + token_length] != '=')
return false;
ret.erase();
pos += token_length + 1;
getTokenValue(line, "special", cell_info[i][j].align_special);
l_getline(is, line);
if (prefixIs(line, "\\begin_inset")) {
- cell_info[i][j].inset.Read(buf, lex);
+ cell_info[i][j].inset.read(buf, lex);
l_getline(is, line);
}
if (!prefixIs(line, "</cell>")) {
}
set_row_column_number_info(true);
- LyXParagraph * par = new LyXParagraph;
- LyXParagraph * return_par = 0;
-#ifndef NEW_INSETS
- LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
- LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
-#endif
+ Paragraph * par = new Paragraph;
+ Paragraph * return_par = 0;
+
string tmptok;
int pos = 0;
- char depth = 0;
+ Paragraph::depth_type depth = 0;
LyXFont font(LyXFont::ALL_INHERIT);
- font.setLanguage(owner_->BufferOwner()->GetLanguage());
+ font.setLanguage(owner_->bufferOwner()->getLanguage());
while (lex.IsOK()) {
lex.nextToken();
lex.pushToken(token);
break;
}
- if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
+ if (owner_->bufferOwner()->parseSingleLyXformat2Token(lex, par,
return_par,
token, pos,
- depth, font
-#ifndef NEW_INSETS
- ,
- footnoteflag,
- footnotekind
-#endif
- ))
- {
+ depth, font)) {
// the_end read
lex.pushToken(token);
break;
InsetText * inset = GetCellInset(cell);
int row;
-#ifndef NEW_INSETS
- for (int i = 0; i < par->Last(); ++i)
-#else
- for (int i = 0; i < par->size(); ++i)
-#endif
- {
- if (par->IsNewline(i)) {
+ for (int i = 0; i < par->size(); ++i) {
+ if (par->isNewline(i)) {
++cell;
if (cell > GetNumberOfCells()) {
lyxerr << "Some error in reading old table format occured!" <<
if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].usebox)
{
// insert a space instead
- par->Erase(i);
- par->InsertChar(i, ' ');
+ par->erase(i);
+ par->insertChar(i, ' ');
}
}
- par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
-#ifndef NEW_INSETS
- inset->par->InsertFromMinibuffer(inset->par->Last());
-#else
- inset->par->InsertFromMinibuffer(inset->par->size());
-#endif
+ par->copyIntoMinibuffer(*owner_->bufferOwner(), i);
+ inset->par->insertFromMinibuffer(inset->par->size());
}
delete par;
Reinit();
if (!cellinfo_of_cell(cell)->align_special.empty()) {
os << cellinfo_of_cell(cell)->align_special << "}{";
} else {
- if (LeftLine(cell))
+ if (LeftLine(cell) &&
+ (IsFirstCellInRow(cell) ||
+ (!IsMultiColumn(cell-1) && !LeftLine(cell, true) &&
+ !RightLine(cell-1, true))))
+ {
os << '|';
+ }
if (!GetPWidth(cell).empty()) {
switch (GetVAlignment(cell)) {
case LYX_VALIGN_TOP:
InsetText * inset = GetCellInset(cell);
bool rtl = inset->par->isRightToLeftPar(buf->params) &&
-#ifndef NEW_INSETS
- inset->par->Last() > 0 && GetPWidth(cell).empty();
-#else
- inset->par->size() > 0 && GetPWidth(cell).empty();
-#endif
+ inset->par->size() > 0 && GetPWidth(cell).empty();
+
if (rtl)
os << "\\R{";
- ret += inset->Latex(buf, os, fragile, fp);
+ ret += inset->latex(buf, os, fragile, fp);
if (rtl)
os << "}";
}
os << ">";
- ret += GetCellInset(cell)->DocBook(buf, os);
+ ret += GetCellInset(cell)->docBook(buf, os);
os << "</entry>";
++cell;
}
vector<unsigned int> const & clen) const
{
ostringstream sstr;
- int ret = GetCellInset(cell)->Ascii(buf, sstr, 0);
+ int ret = GetCellInset(cell)->ascii(buf, sstr, 0);
if (LeftLine(cell))
os << "| ";
if (IsMultiColumn(cell, true))
continue;
ostringstream sstr;
- GetCellInset(cell)->Ascii(buf, sstr, 0);
+ GetCellInset(cell)->ascii(buf, sstr, 0);
if (clen[j] < sstr.str().length())
clen[j] = sstr.str().length();
}
if (!IsMultiColumn(cell, true) || IsPartOfMultiColumn(i, j))
continue;
ostringstream sstr;
- GetCellInset(cell)->Ascii(buf, sstr, 0);
+ GetCellInset(cell)->ascii(buf, sstr, 0);
int len = int(sstr.str().length());
int const n = cells_in_multicolumn(cell);
for (int k = j; (len > 0) && (k < (j + n - 1)); ++k)
InsetText * LyXTabular::GetCellInset(int cell) const
{
+ cur_cell = cell;
return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
}
InsetText * LyXTabular::GetCellInset(int row, int column) const
{
- return GetCellInset(GetCellNumber(row, column));
+#ifdef WITH_WARNINGS
+#warning Juergen, should we check whether the row/column values are correct?
+// If we do not need to do that, the tests in GetCellNumber should be
+// changed to asserts.
+#endif
+ cur_cell = GetCellNumber(row, column);
+ return & cell_info[row][column].inset;
}
for (int cell = 0; !features.array && (cell < numberofcells); ++cell) {
if (GetVAlignment(cell) != LYX_VALIGN_TOP)
features.array = true;
- GetCellInset(cell)->Validate(features);
+ GetCellInset(cell)->validate(features);
}
}
}
-#ifndef NEW_INSETS
LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
{
- LyXParagraph * par = GetCellInset(cell)->par;
-
- for (; par; par = par->next_) {
- for (int i = 0; i < par->Last(); ++i) {
- if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
- return BOX_PARBOX;
- }
- }
- return BOX_NONE;
-}
-#else
-LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
-{
- LyXParagraph * par = GetCellInset(cell)->par;
+ Paragraph * par = GetCellInset(cell)->par;
for (; par; par = par->next()) {
for (int i = 0; i < par->size(); ++i) {
- if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
+ if (par->getChar(i) == Paragraph::META_NEWLINE)
return BOX_PARBOX;
}
}
return BOX_NONE;
}
-#endif
+
/* Emacs:
* Local variables:
* tab-width: 4