/* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright (C) 1995 Matthias Ettrich * Copyright (C) 1995-1998 The LyX Team. * *======================================================
*/
/* activates all lines and sets all widths to 0 */ void LyXTable::Init(int rows_arg, int columns_arg)
{ int i,j,cellno;
rows = rows_arg;
columns = columns_arg;
column_info = new columnstruct[columns];
row_info = new rowstruct[rows];
cell_info = new cellstruct*[rows];
for (i=0; i<columns;i++) {
column_info[i].left_line = true;
column_info[i].right_line = false;
column_info[i].alignment = LYX_ALIGN_CENTER; // set width_of_column to zero before it is used in // calculate_width_of_column() (thornley)
column_info[i].width_of_column = 0;
calculate_width_of_column(i);
}
column_info[i-1].right_line = true;
void LyXTable::AppendRow(int cell)
{ int row = row_of_cell(cell);
rowstruct *row_info2 = new rowstruct[rows+1];
cellstruct** cell_info2 = new cellstruct*[rows+1]; int i;
for (i=0; i <= row; i++) {
cell_info2[i] = cell_info[i];
row_info2[i] = row_info[i];
} for (i=rows-1; i >= row; i--) {
cell_info2[i+1] = cell_info[i];
row_info2[i+1] = row_info[i];
} for (i=row;row_info[i].is_cont_row;i--); if (((row+1)>=rows) || !row_info[row+1].is_cont_row)
row_info2[row+1].is_cont_row = false;
row_info2[row+1].top_line = row_info[i].top_line;
cell_info2[row+1] = new cellstruct[columns]; for (i=0; i<columns; i++) {
cell_info2[row+1][i].width_of_cell = 0;
cell_info2[row+1][i] = cell_info2[row][i];
}
void LyXTable::AppendColumn(int cell)
{ int i,j;
columnstruct *column_info2 = new columnstruct[columns+1]; int column = right_column_of_cell(cell);
for (i=0; i<=column; i++){
column_info2[i] = column_info[i];
} for (i=columns-1; i>=column; i--){
column_info2[i+1] = column_info[i];
}
delete[] column_info;
column_info = column_info2;
for (i=0; i<rows;i++){
cellstruct* tmp = cell_info[i];
cell_info[i] = new cellstruct[columns+1]; for (j=0; j<=column; j++){
cell_info[i][j]=tmp[j];
} for (j=column; j<columns; j++){
cell_info[i][j+1]=tmp[j];
} // care about multicolumns if (cell_info[i][column+1].multicolumn
==LyXTable::CELL_BEGIN_OF_MULTICOLUMN){
cell_info[i][column+1].multicolumn =
LyXTable::CELL_PART_OF_MULTICOLUMN;
} if (column + 1 == columns
|| cell_info[i][column+2].multicolumn
!=LyXTable::CELL_PART_OF_MULTICOLUMN){
cell_info[i][column+1].multicolumn =
LyXTable::CELL_NORMAL;
}
delete[] tmp;
}
columns++;
Reinit();
}
void LyXTable::Reinit()
{ int i,j;
for (i=0; i<rows;i++) { for (j=0; j<columns; j++) {
cell_info[i][j].width_of_cell = 0; if ((i+1 < rows) && !row_info[i+1].is_cont_row)
cell_info[i][j].has_cont_row = false;
}
}
for (i=0; i<columns;i++) {
calculate_width_of_column(i);
}
calculate_width_of_table();
set_row_column_number_info();
}
void LyXTable::set_row_column_number_info()
{ int row = 0; int c= 0; int column = 0;
numberofcells = -1; for (row=0; row<rows; ++row) { for (column=0; column<columns; ++column) { if (cell_info[row][column].multicolumn
!= LyXTable::CELL_PART_OF_MULTICOLUMN)
++numberofcells;
cell_info[row][column].cellno = numberofcells;
}
}
++numberofcells; // because this is one more than as we start from 0
row = 0;
column = 0;
if (rowofcell) delete [] rowofcell;
rowofcell = newint[numberofcells]; if (columnofcell) delete [] columnofcell;
columnofcell = newint[numberofcells];
int LyXTable::GetNumberOfCells()
{ return numberofcells;
}
int LyXTable::NumberOfCellsInRow(int cell)
{ int row = row_of_cell(cell); int i=0; int result = 0; for (i=0; i<columns; i++){ if (cell_info[row][i].multicolumn != LyXTable::CELL_PART_OF_MULTICOLUMN)
result++;
} return result;
}
int LyXTable::AppendCellAfterCell(int append_cell, int question_cell)
{ return (right_column_of_cell(append_cell) ==
right_column_of_cell(question_cell));
}
int LyXTable::DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell)
{ if (column_of_cell(delete_column_cell) == 0 &&
right_column_of_cell(delete_column_cell) == columns - 1) return 0; else return
(column_of_cell(cell) >= column_of_cell(delete_column_cell) &&
column_of_cell(cell) <= right_column_of_cell(delete_column_cell));
}
/* returns 1 if there is a topline, returns 0 if not */ bool LyXTable::TopLine(int cell)
{ int row=row_of_cell(cell);
if (IsContRow(cell)) return TopLine(cell_info[row-1][column_of_cell(cell)].cellno); if (IsMultiColumn(cell)) return cellinfo_of_cell(cell)->top_line; return row_info[row].top_line;
}
bool LyXTable::BottomLine(int cell)
{ int row=row_of_cell(cell);
if (RowHasContRow(cell)) return BottomLine(cell_info[row+1][column_of_cell(cell)].cellno); if (IsMultiColumn(cell)) return cellinfo_of_cell(cell)->bottom_line; return row_info[row_of_cell(cell)].bottom_line;
}
int LyXTable::AdditionalHeight(int cell)
{ int row = row_of_cell(cell); int top = 1; int bottom = 1; int column; if (row){ for (column=0;column < columns-1 && bottom;column++){ switch (cell_info[row-1][column].multicolumn){ case LyXTable::CELL_BEGIN_OF_MULTICOLUMN:
bottom = cell_info[row-1][column].bottom_line; break; case LyXTable::CELL_NORMAL:
bottom = row_info[row-1].bottom_line;
}
} for (column=0;column < columns-1 && top;column++){ switch (cell_info[row][column].multicolumn){ case LyXTable::CELL_BEGIN_OF_MULTICOLUMN:
top = cell_info[row][column].top_line; break; case LyXTable::CELL_NORMAL:
top = row_info[row].top_line;
}
} if (top && bottom) return WIDTH_OF_LINE;
} return 0;
}
int LyXTable::AdditionalWidth(int cell)
{ // internally already set in SetWidthOfCell // used to get it back in text.C int col = right_column_of_cell(cell); if (col < columns - 1 && column_info[col].right_line &&
column_info[col+1].left_line) return WIDTH_OF_LINE; else return 0;
}
// returns the maximum over all rows int LyXTable::WidthOfColumn(int cell)
{ int column1 = column_of_cell(cell); int column2 = right_column_of_cell(cell); int i; int result=0; for (i=column1; i<=column2;i++){
result += column_info[i].width_of_column;
} return result;
}
int LyXTable::WidthOfTable()
{ return width_of_table;
}
/* returns 1 if a complete update is necessary, otherwise 0 */ bool LyXTable::SetWidthOfMulticolCell(int cell, int new_width)
{ if (!IsMultiColumn(cell)) returnfalse;
int row = row_of_cell(cell); int column1 = column_of_cell(cell); int column2 = right_column_of_cell(cell); int i; int width=0;
// first set columns to 0 so we can calculate the right width for (i=column1; i<=column2;i++) {
cell_info[row][i].width_of_cell = 0;
} // set the width to MAX_WIDTH until width > 0
width = (new_width + 2*WIDTH_OF_LINE); for (i=column1; (i<column2) && (width > 0);i++){
cell_info[row][i].width_of_cell = column_info[i].width_of_column;
width -= column_info[i].width_of_column;
} if (i==column2) {
cell_info[row][i].width_of_cell = width;
} returntrue;
}
void LyXTable::recalculateMulticolCells(int cell, int new_width)
{ int
row = row_of_cell(cell),
column1 = column_of_cell(cell),
column2 = right_column_of_cell(cell),
i;
// first set columns to 0 so we can calculate the right width for (i=column1; i<=column2;++i)
cell_info[row][i].width_of_cell = 0; for(i=cell+1;(i<numberofcells) && (!IsMultiColumn(i));++i)
; if (i < numberofcells)
recalculateMulticolCells(i,GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
SetWidthOfMulticolCell(cell,new_width);
}
/* returns 1 if a complete update is necessary, otherwise 0 */ bool LyXTable::SetWidthOfCell(int cell, int new_width)
{ int row = row_of_cell(cell); int column1 = column_of_cell(cell); int tmp=0; int width=0;
LString LyXTable::GetAlignSpecial(int cell, int what)
{ if (what == SET_SPECIAL_MULTI) return cellinfo_of_cell(cell)->align_special; return column_info[column_of_cell(cell)].align_special;
}
int LyXTable::GetWidthOfCell(int cell)
{ int row = row_of_cell(cell); int column1 = column_of_cell(cell); int column2 = right_column_of_cell(cell); int i; int result=0; for (i=column1; i<=column2;i++){
result += cell_info[row][i].width_of_cell;
}
result += AdditionalWidth(cell);
return result;
}
int LyXTable::GetBeginningOfTextInCell(int cell)
{ int x = 0;
switch (GetAlignment(cell)){ case LYX_ALIGN_CENTER:
x += (WidthOfColumn(cell) - GetWidthOfCell(cell)) / 2; break; case LYX_ALIGN_RIGHT:
x += WidthOfColumn(cell) - GetWidthOfCell(cell) + AdditionalWidth(cell); break; default: /* LYX_ALIGN_LEFT: nothing :-) */ break;
}
// the LaTeX Way :-(
x += WIDTH_OF_LINE; return x;
}
#ifdef WITH_WARNINGS #warning Clean up this code in 0.13 (Jug) #endif void LyXTable::Read(FILE* file)
{ int version; int i,j; int rows_arg = 0; int columns_arg = 0; int is_long_table_arg = false; int rotate_arg = false;
LString s; int a = 0; int b = 0; int c = 0; int d = 0; int e = 0; int f = 0; int g = 0; int h = 0; char vtmp[100], stmp[100], atmp[100];
fscanf(file, "%s\n", vtmp);
s = vtmp; if (s.length() > 8)
version = atoi(s.c_str()+8); else
version = 1;
a=b=c=d=-1; if (version > 2) {
fgets(vtmp,sizeof(vtmp),file);
sscanf(vtmp, "%d %d %d %d %d %d %d %d\n", &rows_arg, &columns_arg,
&is_long_table_arg, &rotate_arg, &a, &b, &c, &d);
} else
fscanf(file, "%d %d\n",
&rows_arg, &columns_arg);
Init(rows_arg, columns_arg);
SetLongTable(is_long_table_arg);
SetRotateTable(rotate_arg);
endhead = a;
endfirsthead = b;
endfoot = c;
endlastfoot = d; for (i=0; i<rows; i++){
a=b=c=d=e=f=g=h=0;
fgets(vtmp,sizeof(vtmp),file);
sscanf(vtmp, "%d %d %d %d\n",
&a, &b, &c, &d);
row_info[i].top_line = a;
row_info[i].bottom_line = b;
row_info[i].is_cont_row = c;
row_info[i].newpage = d;
} for (i=0; i<columns; i++){
*stmp = 0;
*atmp = 0;
fgets(vtmp,sizeof(vtmp),file);
sscanf(vtmp, "%d %d %d %s %s", &a, &b, &c, stmp, atmp);
column_info[i].alignment = (char) a;
column_info[i].left_line = b;
column_info[i].right_line = c; if (*stmp == '"') { /* strip quotes if they exists */
*stmp = 0;
*atmp = 0; // there are quotes so I have to reread the string correctly // this is only because the old format did not have " // this means also that atmp is ONLY set here!!! if (stmp[1] == '"')
sscanf(vtmp, "%*d %*d %*d %*s \"%[^\"]\"", atmp); else// otherwise after the first empty "" read is aborded
sscanf(vtmp, "%*d %*d %*d \"%[^\"]\" \"%[^\"]\"", stmp, atmp);
column_info[i].p_width = stmp;
column_info[i].align_special = atmp;
} elseif (*stmp)
column_info[i].p_width = stmp;
} if (version == 1){ for (i=0; i<rows;i++){ for (j=0;j<columns;j++){
fscanf(file, "%d %d\n", &a, &b);
cell_info[i][j].multicolumn = (char) a;
cell_info[i][j].alignment = (char) b;
}
}
} elseif (version < 4) { for (i=0; i<rows;i++){ for (j=0;j<columns;j++){
fscanf(file, "%d %d %d %d\n", &a, &b, &c, &d);
cell_info[i][j].multicolumn = (char) a;
cell_info[i][j].alignment = (char) b;
cell_info[i][j].top_line = (char) c;
cell_info[i][j].bottom_line = (char) d;
}
}
} else { for (i=0; i<rows;i++){ for (j=0;j<columns;j++){
*stmp = 0;
*atmp = 0;
a=b=c=d=e=f=g=0;
fgets(vtmp,sizeof(vtmp),file);
sscanf(vtmp, "%d %d %d %d %d %d %d %s %s\n",
&a, &b, &c, &d, &e, &f, &g, stmp, atmp);
cell_info[i][j].multicolumn = (char) a;
cell_info[i][j].alignment = (char) b;
cell_info[i][j].top_line = (char) c;
cell_info[i][j].bottom_line = (char) d;
cell_info[i][j].has_cont_row = (bool) e;
cell_info[i][j].rotate = (bool) f;
cell_info[i][j].linebreaks = (bool) g; // this is only to see if I have an empty string first // this clause should be always TRUE!!! if (*stmp == '"') {
*stmp = 0;
*atmp = 0; if (stmp[1] == '"')
sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d %*s \"%[^\"]\"",
atmp); else// otherwise after the first empty "" read is aborded
sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d \"%[^\"]\" \"%[^\"]\"",
stmp, atmp);
cell_info[i][j].align_special = stmp;
cell_info[i][j].p_width = atmp;
} elseif (*stmp)
cell_info[i][j].align_special = stmp;
}
}
}
set_row_column_number_info();
}
// cell <0 will tex the preamble // returns the number of printed newlines int LyXTable::TexEndOfCell(LString& file, int cell)
{ int i; int ret = 0; int tmp; // tmp2; int fcell,nvcell; if (ShouldBeVeryLastCell(cell)) { // the very end at the very beginning if (Linebreaks(cell) &&
!column_info[column_of_cell(cell)].p_width.empty())
file += '}'; if (IsMultiColumn(cell))
file += '}'; if (RotateCell(cell)) {
file += "\n\\end{sideways}";
ret++;
}
file += "\\\\\n";
ret++;
tmp = 0;
fcell = cell; while (!IsFirstCell(fcell))fcell--; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i))
tmp++;
} if (tmp == NumberOfCellsInRow(fcell)){
file += "\\hline ";
} else {
tmp = 0; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){
file += "\\cline{";
file += column_of_cell(fcell+i)+1;
file += '-';
file += right_column_of_cell(fcell+i)+1;
file += "} ";
tmp = 1;
}
}
} if (tmp){
file += '\n';
ret++;
} if (is_long_table)
file += "\\end{longtable}"; else
file += "\\end{tabular}"; if (rotate) {
file += "\n\\end{sideways}";
ret++;
}
} else {
nvcell = NextVirtualCell(cell+1); if (cell < 0){ // preamble if (rotate) {
file += "\\begin{sideways}\n";
ret++;
} if (is_long_table)
file += "\\begin{longtable}{"; else
file += "\\begin{tabular}{"; for (i=0; i<columns;i++){ if (column_info[i].left_line)
file += '|'; if (!column_info[i].align_special.empty()) {
file += column_info[i].align_special.c_str();
} elseif (!column_info[i].p_width.empty()) {
file += "p{";
file += column_info[i].p_width;
file += '}';
} else { switch (column_info[i].alignment) { case LYX_ALIGN_LEFT:
file += 'l'; break; case LYX_ALIGN_RIGHT:
file += 'r'; break; default:
file += 'c'; break;
}
} if (column_info[i].right_line)
file += '|';
}
file += "}\n";
ret++;
tmp = 0; if (GetNumberOfCells()){
fcell = 0; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i))
tmp++;
} if (tmp == NumberOfCellsInRow(fcell)){
file += "\\hline ";
} else {
tmp = 0; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i)){
file += "\\cline{";
file += column_of_cell(fcell+i)+1;
file += '-';
file += right_column_of_cell(fcell+i)+1;
file += "} ";
tmp = 1;
}
}
} if (tmp){
file += '\n';
ret++;
}
} if (RotateCell(0)) {
file += "\\begin{sideways}\n";
ret++;
}
} else { // usual cells if (Linebreaks(cell) &&
!column_info[column_of_cell(cell)].p_width.empty())
file += "\\smallskip{}}"; if (IsMultiColumn(cell)){
file += '}';
} if (RotateCell(cell)) {
file += "\n\\end{sideways}";
ret++;
} if (IsLastCell(cell)) { int row = row_of_cell(cell);
LString hline1,hline2; bool print_hline = true; bool pr_top_hline,flag1,flag2;
flag1 = IsLongTable() &&
((row == endhead) || (row == endfirsthead) ||
(row == endfoot) || (row == endlastfoot));
row++;
flag2 = IsLongTable() &&
((row <= endhead) || (row <= endfirsthead) ||
(row <= endfoot) || (row <= endlastfoot));
row--; // print the bottom hline only if (otherwise it is doubled): // - is no LongTable // - there IS a first-header // - the next row is no special header/footer // & this row is no special header/footer // - the next row is a special header/footer // & this row is a special header/footer
pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
(endfirsthead == endhead);
file += "\\\\\n";
ret++;
tmp = 0;
fcell = cell; while (!IsFirstCell(fcell))
fcell--; for (i=0; i < NumberOfCellsInRow(cell); i++){ if (BottomLine(fcell+i))
tmp++;
} if (tmp == NumberOfCellsInRow(cell)){
file += "\\hline ";
hline1 = "\\hline ";
} else {
tmp = 0; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){
file += "\\cline{";
file += column_of_cell(fcell+i)+1;
file += '-';
file += right_column_of_cell(fcell+i)+1;
file += "} ";
hline1 += "\\cline{";
hline1 += column_of_cell(fcell+i)+1;
hline1 += '-';
hline1 += right_column_of_cell(fcell+i)+1;
hline1 += "} ";
tmp = 1;
}
}
} if (tmp){
file += '\n';
ret++;
} if (IsLongTable() && (row == endfoot)) {
file += "\\endfoot\n";
ret++;
print_hline = false; // no double line below footer
} if (IsLongTable() && (row == endlastfoot)) {
file += "\\endlastfoot\n";
ret++;
print_hline = false; // no double line below footer
} if (IsLongTable() && row_info[row].newpage) {
file += "\\newpage\n";
ret++;
print_hline = false; // no line below a \\newpage-command
}
tmp = 0; if ((cell < GetNumberOfCells()-1) &&
!ShouldBeVeryLastCell(cell)) {
fcell = nvcell; #if 0 // Now jump all ContRows while (IsContRow(fcell))
fcell++; while (!IsFirstCell(fcell))
fcell--; #endif for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i))
tmp++;
} if (tmp == NumberOfCellsInRow(fcell)){ if (print_hline)
file += "\\hline ";
hline2 = "\\hline ";
} else {
tmp = 0; for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i)){ if (print_hline) {
file += "\\cline{";
file += column_of_cell(fcell+i)+1;
file += '-';
file += right_column_of_cell(fcell+i)+1;
file += "} ";
}
hline2 += "\\cline{";
hline2 += column_of_cell(fcell+i)+1;
hline2 += '-';
hline2 += right_column_of_cell(fcell+i)+1;
hline2 += "} ";
tmp = 1;
}
}
} if (tmp && print_hline){
file += '\n';
ret++;
}
} // the order here is important as if one defines two // or more things in one line only the first entry is // displayed the other are set to an empty-row. This // is important if I have a footer and want that the // lastfooter is NOT displayed!!! bool sflag2 = (row == endhead) || (row == endfirsthead) ||
(row == endfoot) || (row == endlastfoot);
row--; // sflag2 = IsLongTable() && (row >= 0) && // (sflag2 || (row == endhead) || (row == endfirsthead));
row += 2; bool sflag1 = IsLongTable() && (row != endhead) &&
(row != endfirsthead) &&
((row == endfoot) || (row == endlastfoot));
row--; if (IsLongTable() && (row == endhead)) {
file += "\\endhead\n";
ret++;
} if (IsLongTable() && (row == endfirsthead)) {
file += "\\endfirsthead\n";
ret++;
} if (sflag1) { // add the \hline for next foot row if (!hline1.empty()) {
file += hline1 + '\n';
ret++;
}
} // add the \hline for the first row if (pr_top_hline && sflag2) { if (!hline2.empty()) {
file += hline2 + '\n';
ret++;
}
} if (RotateCell(nvcell)) {
file += "\\begin{sideways}\n";
ret++;
}
} else {
file += "&\n";
ret++; if (RotateCell(nvcell)) {
file += "\\begin{sideways}\n";
ret++;
}
}
} if (IsMultiColumn(nvcell)) {
file += "\\multicolumn{";
file += cells_in_multicolumn(nvcell);
file += "}{"; if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
file += cellinfo_of_cell(cell+1)->align_special;
file += "}{";
} else { if (LeftLine(nvcell))
file += '|'; if (!GetPWidth(nvcell).empty()) {
file += "p{";
file += GetPWidth(nvcell);
file += '}';
} else { switch (GetAlignment(nvcell)) { case LYX_ALIGN_LEFT: file += 'l'; break; case LYX_ALIGN_RIGHT: file += 'r'; break; default: file += 'c'; break;
}
} if (RightLine(nvcell))
file += '|'; //if (column_of_cell(cell+2)!=0 && LeftLine(cell+2)) if (((nvcell+1) < numberofcells) &&
(NextVirtualCell(nvcell+1) < numberofcells) &&
(column_of_cell(NextVirtualCell(nvcell+1))!=0) &&
LeftLine(NextVirtualCell(nvcell+1)))
file += '|';
file += "}{";
}
} if (Linebreaks(nvcell) &&
!column_info[column_of_cell(nvcell)].p_width.empty()) {
file += "\\parbox{";
file += GetPWidth(nvcell);
file += "}{\\smallskip{}";
}
} return ret;
}
// cell <0 will tex the preamble // returns the number of printed newlines int LyXTable::RoffEndOfCell(FILE* file, int cell)
{ int i,j; int ret = 0;
if (cell == GetNumberOfCells() - 1){ // the very end at the very beginning if (CellHasContRow(cell) >= 0) {
fprintf(file,"\nT}");
ret++;
}
fprintf(file, "\n");
ret++; if (row_info[row_of_cell(cell)].bottom_line) {
fprintf(file, "_\n");
ret++;
}
fprintf(file, ".TE\n.pl 1c");
} else { if (cell < 0){ int fcell=0; // preamble
fprintf(file, "\n.pl 500c\n.TS\n"); for (j=0; j<rows; j++) { for (i=0; i<columns;i++,fcell++) { if (column_info[i].left_line)
fprintf(file, " | "); if (cell_info[j][i].multicolumn==CELL_PART_OF_MULTICOLUMN)
fprintf(file, "s"); else { switch (column_info[i].alignment) { case LYX_ALIGN_LEFT:
fprintf(file, "l"); break; case LYX_ALIGN_RIGHT:
fprintf(file, "r"); break; default:
fprintf(file, "c"); break;
}
} if (!column_info[i].p_width.empty())
fprintf(file, "w(%s)", column_info[i].p_width.c_str()); if (column_info[i].right_line)
fprintf(file, " | ");
} if ((j+1) < rows) {
fprintf(file, "\n");
ret++;
}
}
fprintf(file, ".\n");
ret++; if (row_info[0].top_line) {
fprintf(file,"_\n");
ret++;
} if (CellHasContRow(0) >= 0) {
fprintf(file,"T{\n");
ret++;
}
} else { // usual cells if (CellHasContRow(cell) >= 0) {
fprintf(file,"\nT}");
ret++;
} if (right_column_of_cell(cell) == columns -1){
fprintf(file, "\n");
ret++; int row = row_of_cell(cell); if (row_info[row++].bottom_line) {
fprintf(file, "_\n");
ret++;
} if ((row < rows) && row_info[row].top_line) {
fprintf(file, "_\n");
ret++;
}
} else
fprintf(file, "\t"); if ((cell < GetNumberOfCells() - 1) &&
(CellHasContRow(cell+1) >= 0)) {
fprintf(file,"T{\n");
ret++;
}
}
} return ret;
}
bool LyXTable::NeedRotating()
{ if (rotate) returntrue; for (int i=0; i<rows;i++){ for (int j=0;j<columns;j++){ if (cell_info[i][j].rotate) returntrue;
}
} returnfalse;
}
void LyXTable::AppendContRow(int cell)
{ int row = row_of_cell(cell)+1;
int LyXTable::CellHasContRow(int cell)
{ int row = row_of_cell(cell);
if (VeryLastRow(cell)) return -1; if (cell_info[row][column_of_cell(cell)].has_cont_row) return cell_info[row+1][column_of_cell(cell)].cellno; return -1;
}
bool LyXTable::RowHasContRow(int cell)
{ int row = row_of_cell(cell) + 1;
if (row < rows) return row_info[row].is_cont_row; returnfalse;
}
int LyXTable::FirstVirtualCell(int cell)
{ if (!IsContRow(cell)) return cell; int row = row_of_cell(cell); int column = column_of_cell(cell); for(;(row>0) && IsContRow(cell_info[row][column].cellno); row--)
; return cell_info[row][column].cellno;
}
int LyXTable::NextVirtualCell(int cell)
{ if (!IsContRow(cell)) return cell; int row = row_of_cell(cell) + 1; for(;(row < rows) && IsContRow(cell_info[row][0].cellno); ++row); return cell_info[row - 1][0].cellno; // could the "- 1" be the fix??? (Lgb)
}
bool LyXTable::ShouldBeVeryLastCell(int cell)
{ int fcell = cell + 1;
if (cell == GetNumberOfCells() - 1) returntrue; // not really sure if I should return false here if (!IsContRow(fcell)) returnfalse; while((fcell < GetNumberOfCells() - 1) && IsContRow(fcell))
fcell++; if (fcell < GetNumberOfCells() - 1) returnfalse; returntrue;
}
bool LyXTable::ShouldBeVeryLastRow(int cell)
{ if (CellHasContRow(cell)>=0) returnfalse; int row = row_of_cell(cell)+1; int column = column_of_cell(cell); while((row < rows) && IsContRow(cell_info[row][column].cellno))
row++; if (row < rows) returnfalse; // found another valid row // I do not have any valid row after the actual returntrue;
}
int LyXTable::GetCellAbove(int cell)
{ int row = row_of_cell(cell);
if (row > 0) return cell_info[row-1][column_of_cell(cell)].cellno; return cell;
}
int LyXTable::GetCellNumber(int column, int row)
{ if (column >= columns)
column = columns - 1; elseif (column < 0)
column = 0; if (row >= rows)
row = rows - 1; elseif (row < 0)
row = 0;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.29Bemerkung:
Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.