X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftable.C;h=bd6ff67a1d2d83b9e7546bcfa4bb83b98b720692;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=c7c3eb24f4fd9a0db51760ceee1867be70d1c890;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/table.C b/src/table.C index c7c3eb24f4..bd6ff67a1d 100644 --- a/src/table.C +++ b/src/table.C @@ -9,22 +9,19 @@ *====================================================== */ -#include +#include + +#include #include "table.h" #include "vspace.h" #include "layout.h" - -// $Id: table.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $ - -#if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: table.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $"; -#endif /* lint */ +#include "support/lstrings.h" #ifdef __GNUG__ #pragma implementation #endif -extern void addNewlineAndDepth(LString &file, int const depth); // Jug 990923 +extern void addNewlineAndDepth(string &file, int const depth); // Jug 990923 #define WIDTH_OF_LINE 5 @@ -130,8 +127,8 @@ void LyXTable::Init(int rows_arg, int columns_arg) calculate_width_of_table(); - rowofcell = NULL; - columnofcell = NULL; + rowofcell = 0; + columnofcell = 0; set_row_column_number_info(); is_long_table = false; rotate = 0; @@ -594,7 +591,7 @@ bool LyXTable::SetAlignment(int cell, char align) return true; } -bool LyXTable::SetPWidth(int cell, LString width) +bool LyXTable::SetPWidth(int cell, string width) { int fvcell = FirstVirtualCell(cell); @@ -604,12 +601,13 @@ bool LyXTable::SetPWidth(int cell, LString width) cellinfo_of_cell(fvcell)->p_width = width; } else { column_info[column_of_cell(fvcell)].p_width = width; - SetAlignment(cell,LYX_ALIGN_LEFT); + if (!width.empty()) // do this only if there is a width + SetAlignment(cell,LYX_ALIGN_LEFT); } return true; } -bool LyXTable::SetAlignSpecial(int cell, LString special, int what) +bool LyXTable::SetAlignSpecial(int cell, string special, int what) { if (what == SET_SPECIAL_MULTI) cellinfo_of_cell(cell)->align_special = special; @@ -677,7 +675,7 @@ char LyXTable::GetAlignment(int cell) return column_info[column_of_cell(cell)].alignment; } -LString LyXTable::GetPWidth(int cell) +string LyXTable::GetPWidth(int cell) { int fvcell = FirstVirtualCell(cell); @@ -686,7 +684,7 @@ LString LyXTable::GetPWidth(int cell) return column_info[column_of_cell(fvcell)].p_width; } -LString LyXTable::GetAlignSpecial(int cell, int what) +string LyXTable::GetAlignSpecial(int cell, int what) { if (what == SET_SPECIAL_MULTI) return cellinfo_of_cell(cell)->align_special; @@ -858,7 +856,7 @@ void LyXTable::Read(FILE* file) int columns_arg = 0; int is_long_table_arg = false; int rotate_arg = false; - LString s; + string s; int a = 0; int b = 0; int c = 0; @@ -981,7 +979,7 @@ void LyXTable::Read(FILE* file) // cell <0 will tex the preamble // returns the number of printed newlines -int LyXTable::TexEndOfCell(LString& file, int cell) +int LyXTable::TexEndOfCell(string& file, int cell) { int i; int ret = 0; @@ -1014,9 +1012,9 @@ int LyXTable::TexEndOfCell(LString& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; tmp = 1; } @@ -1087,9 +1085,9 @@ int LyXTable::TexEndOfCell(LString& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (TopLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; tmp = 1; } @@ -1117,7 +1115,7 @@ int LyXTable::TexEndOfCell(LString& file, int cell) } if (IsLastCell(cell)) { int row = row_of_cell(cell); - LString hline1,hline2; + string hline1,hline2; bool print_hline = true; bool pr_top_hline,flag1,flag2; flag1 = IsLongTable() && @@ -1155,14 +1153,14 @@ int LyXTable::TexEndOfCell(LString& file, int cell) for (i=0; i < NumberOfCellsInRow(fcell); i++){ if (BottomLine(fcell+i)){ file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; hline1 += "\\cline{"; - hline1 += column_of_cell(fcell+i)+1; + hline1 += tostr(column_of_cell(fcell+i)+1); hline1 += '-'; - hline1 += right_column_of_cell(fcell+i)+1; + hline1 += tostr(right_column_of_cell(fcell+i)+1); hline1 += "} "; tmp = 1; } @@ -1213,15 +1211,15 @@ int LyXTable::TexEndOfCell(LString& file, int cell) if (TopLine(fcell+i)){ if (print_hline) { file += "\\cline{"; - file += column_of_cell(fcell+i)+1; + file += tostr(column_of_cell(fcell+i)+1); file += '-'; - file += right_column_of_cell(fcell+i)+1; + file += tostr(right_column_of_cell(fcell+i)+1); file += "} "; } hline2 += "\\cline{"; - hline2 += column_of_cell(fcell+i)+1; + hline2 += tostr(column_of_cell(fcell+i)+1); hline2 += '-'; - hline2 += right_column_of_cell(fcell+i)+1; + hline2 += tostr(right_column_of_cell(fcell+i)+1); hline2 += "} "; tmp = 1; } @@ -1283,7 +1281,7 @@ int LyXTable::TexEndOfCell(LString& file, int cell) } if (nvcell < numberofcells && IsMultiColumn(nvcell)) { file += "\\multicolumn{"; - file += cells_in_multicolumn(nvcell); + file += tostr(cells_in_multicolumn(nvcell)); file += "}{"; if (!cellinfo_of_cell(cell+1)->align_special.empty()) { file += cellinfo_of_cell(cell+1)->align_special; @@ -1418,7 +1416,7 @@ int LyXTable::RoffEndOfCell(FILE* file, int cell) return ret; } -const char *LyXTable::getDocBookAlign(int cell, bool isColumn=false) +const char *LyXTable::getDocBookAlign(int cell, bool isColumn) { int i; if (isColumn) @@ -1464,12 +1462,12 @@ const char *LyXTable::getDocBookAlign(int cell, bool isColumn=false) // cell <0 will tex the preamble // returns the number of printed newlines -int LyXTable::DocBookEndOfCell(LString& file, int cell, int &depth) +int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth) { int i; int ret = 0; - int tmp; // tmp2; - int fcell,nvcell; + //int tmp; // tmp2; // unused + int nvcell; // fcell; // unused if (ShouldBeVeryLastCell(cell)) { #if 0 // the very end at the very beginning @@ -1539,7 +1537,7 @@ int LyXTable::DocBookEndOfCell(LString& file, int cell, int &depth) else file += "