]> git.lyx.org Git - features.git/commitdiff
some small tabular changes
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 5 May 2000 13:46:34 +0000 (13:46 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 5 May 2000 13:46:34 +0000 (13:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@723 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/lyxfont.C
src/tabular.C
src/tabular.h

index 56b963b452da5a17aaddd009514c7a3329c186e7..868fb2425315a610739a1d811e7bd3f0775716ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2000-05-05  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * src/lyxfont.C (stateText): guard against stupid c++libs.
+
        * src/tabular.C: add using std::vector
+       some whitespace changes, + removed som autogenerated code.
 
        * src/buffer.C (parseSingleLyXformat2Token): stupid bug.
 
index f805eec4f92eec0bc92010cc57fdc5ea7d341f6a..1fdc3a51859e76fee001274d9af334e8f0e53853 100644 (file)
@@ -412,7 +412,7 @@ string LyXFont::stateText() const
        //      ost << _("Default");
        unsigned int opos = ost.tellp();
        //lyxerr << "Opos: " << opos << endl;
-       if (opos == 0)
+       if (opos == 0 || opos == -1)
                ost << _("Default") << ", ";
        ost << _("Language: ") << _(language()->display.c_str());
 #ifdef HAVE_SSTREAM
index 1b9090f1a9db4d57e4932c36ba5c20e2b643cde7..2c284cf444033c9b326206bc675a9bf837a8d057 100644 (file)
@@ -50,13 +50,29 @@ LyXTabular::cellstruct::cellstruct()
     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;
+}
+
+
 LyXTabular::cellstruct & 
-  LyXTabular::cellstruct::operator=(cellstruct const & cs)
+LyXTabular::cellstruct::operator=(cellstruct const & cs)
 {
     cellno = cs.cellno;
     width_of_cell = cs.width_of_cell;
@@ -69,6 +85,7 @@ LyXTabular::cellstruct &
     return *this;
 }
 
+
 LyXTabular::rowstruct::rowstruct() 
 {
     top_line = true;
@@ -78,21 +95,23 @@ LyXTabular::rowstruct::rowstruct()
     newpage = false;
 }
 
+
 // Nothing to do, but gcc 2.7.2.3 wants one... (JMarc)
-LyXTabular::rowstruct::~rowstruct() 
-{
-}
+//LyXTabular::rowstruct::~rowstruct() 
+//{}
+
+
+//LyXTabular::rowstruct & 
+//  LyXTabular::rowstruct::operator=(rowstruct const & rs)
+//{
+//    top_line = rs.top_line;
+//    bottom_line = rs.bottom_line;
+//    ascent_of_row = rs.ascent_of_row;
+//    descent_of_row = rs.descent_of_row;
+//    newpage = rs.newpage;
+//    return *this;
+//}
 
-LyXTabular::rowstruct & 
-  LyXTabular::rowstruct::operator=(rowstruct const & rs)
-{
-    top_line = rs.top_line;
-    bottom_line = rs.bottom_line;
-    ascent_of_row = rs.ascent_of_row;
-    descent_of_row = rs.descent_of_row;
-    newpage = rs.newpage;
-    return *this;
-}
 
 LyXTabular::columnstruct::columnstruct() 
 {
@@ -102,21 +121,24 @@ LyXTabular::columnstruct::columnstruct()
     width_of_column = 0;
 }
 
-LyXTabular::columnstruct::~columnstruct() 
-{
-}
 
-LyXTabular::columnstruct & 
-  LyXTabular::columnstruct::operator=(columnstruct const & cs)
-{
-    left_line = cs.left_line;
-    right_line = cs.right_line;
-    alignment = cs.alignment;
-    width_of_column = cs.width_of_column;
-    p_width = cs.p_width;
-    align_special = cs.align_special;
-    return *this;
-}
+//LyXTabular::columnstruct::~columnstruct() 
+//{
+//}
+
+
+//LyXTabular::columnstruct & 
+//  LyXTabular::columnstruct::operator=(columnstruct const & cs)
+//{
+//    left_line = cs.left_line;
+//    right_line = cs.right_line;
+//    alignment = cs.alignment;
+//    width_of_column = cs.width_of_column;
+//    p_width = cs.p_width;
+//    align_special = cs.align_special;
+//    return *this;
+//}
+
 
 /* konstruktor */
 LyXTabular::LyXTabular(int rows_arg, int columns_arg, Buffer *buf)
@@ -134,6 +156,7 @@ LyXTabular::LyXTabular(LyXTabular const & lt, Buffer * buf)
     operator=(lt);
 }
 
+
 LyXTabular::LyXTabular(LyXLex & lex, Buffer *buf)
 {
     buffer = buf;
@@ -162,17 +185,23 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
     Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
 
     int row = 0, column = 0;
-    
+
+    // Why not just:
+    // cell_info = lt.cell_info;
     for (row = 0; row < rows_; ++row) {
         for (column = 0; column < columns_; ++column) {
             cell_info[row][column] = lt.cell_info[row][column];
         }
     }
-    
+
+    // why not just:
+    // row_info = lt.row_info;
     for (row = 0; row < rows_; ++row) {
         row_info[row] = lt.row_info[row];
     }
-    
+
+    // why not just:
+    // column_info = lt.column_info;
     for (column = 0; column < columns_; ++column) {
        column_info[column] = lt.column_info[column];
     }
@@ -184,6 +213,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
     return *this;
 }
 
+
 LyXTabular * LyXTabular::Clone(Buffer * buf)
 {
     LyXTabular * result = new LyXTabular(rows_, columns_, buf);
@@ -227,6 +257,7 @@ void LyXTabular::Init(Buffer * buf, int rows_arg, int columns_arg)
     cell_info = vector<vector<cellstruct> >
            (rows_, vector<cellstruct>(columns_, cellstruct()));
 
+    // Jürgen, use iterators.
     for (i = 0; i < rows_; ++i) {
         for (j = 0; j < columns_; ++j) {
             cell_info[i][j].inset = new InsetText(buf);
@@ -424,6 +455,8 @@ void LyXTabular::Reinit()
     int j;
 
     int i = 0;
+
+    // Jürgen, use iterators.
     for (; i < rows_; ++i) {
        for (j = 0; j < columns_; ++j) {
            cell_info[i][j].width_of_cell = 0;
@@ -478,6 +511,7 @@ void LyXTabular::set_row_column_number_info()
     }
 }
 
+
 int LyXTabular::GetNumberOfCells() const
 {
     return numberofcells;
@@ -658,6 +692,7 @@ int LyXTabular::GetWidthOfTabular() const
     return width_of_tabular;
 }
 
+
 /* returns 1 if a complete update is necessary, otherwise 0 */ 
 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
 {
@@ -747,6 +782,7 @@ bool LyXTabular::SetAlignment(int cell, char align)
     return true;
 }
 
+
 bool LyXTabular::SetPWidth(int cell, string width)
 {
     if (IsMultiColumn(cell)) {
@@ -759,6 +795,7 @@ bool LyXTabular::SetPWidth(int cell, string width)
     return true;
 }
 
+
 bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
 {
     if (what == SET_SPECIAL_MULTI)
@@ -768,6 +805,7 @@ bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
     return true;
 }
 
+
 bool LyXTabular::SetAllLines(int cell, bool line)
 {
     SetTopLine(cell, line);
@@ -777,6 +815,7 @@ bool LyXTabular::SetAllLines(int cell, bool line)
     return true;
 }
 
+
 bool LyXTabular::SetTopLine(int cell, bool line)
 {
     int row = row_of_cell(cell);
@@ -821,6 +860,7 @@ char LyXTabular::GetAlignment(int cell) const
        return column_info[column_of_cell(cell)].alignment;
 }
 
+
 string LyXTabular::GetPWidth(int cell) const
 {
     if (IsMultiColumn(cell))
@@ -828,6 +868,7 @@ string LyXTabular::GetPWidth(int cell) const
     return column_info[column_of_cell(cell)].p_width;
 }
 
+
 string LyXTabular::GetAlignSpecial(int cell, int what) const
 {
     if (what == SET_SPECIAL_MULTI)
@@ -835,6 +876,7 @@ string LyXTabular::GetAlignSpecial(int cell, int what) const
     return column_info[column_of_cell(cell)].align_special;
 }
 
+
 int LyXTabular::GetWidthOfCell(int cell) const
 {
     int row = row_of_cell(cell);
@@ -879,6 +921,7 @@ bool LyXTabular::IsFirstCellInRow(int cell) const
     return (column_of_cell(cell) == 0);
 }
 
+
 bool LyXTabular::IsLastCellInRow(int cell) const
 {
     return (right_column_of_cell(cell) == (columns_ - 1));
@@ -897,6 +940,7 @@ bool LyXTabular::calculate_width_of_column(int column)
     return (column_info[column].width_of_column != old_column_width);
 }
 
+
 bool LyXTabular::calculate_width_of_column_NMC(int column)
 {
     int old_column_width = column_info[column].width_of_column;
@@ -911,6 +955,7 @@ bool LyXTabular::calculate_width_of_column_NMC(int column)
     return (column_info[column].width_of_column != old_column_width);
 }
 
+
 void LyXTabular::calculate_width_of_tabular()
 {
     width_of_tabular = 0;
@@ -1000,7 +1045,9 @@ void LyXTabular::Write(ostream & os) const
     os << "</LyXTabular>" << endl;
 }
 
-static bool getTokenValue(string const str, const char * token, string & ret)
+
+static
+bool getTokenValue(string const str, const char * token, string & ret)
 {
     int pos = str.find(token);
     char ch = str[pos+strlen(token)];
@@ -1020,7 +1067,9 @@ static bool getTokenValue(string const str, const char * token, string & ret)
     return true;
 }
 
-static bool getTokenValue(string const str, const char * token, int & num)
+
+static
+bool getTokenValue(string const str, const char * token, int & num)
 {
     string ret;
     int pos = str.find(token);
@@ -1044,7 +1093,9 @@ static bool getTokenValue(string const str, const char * token, int & num)
     return true;
 }
 
-static bool getTokenValue(string const str, const char * token, bool & flag)
+
+static
+bool getTokenValue(string const str, const char * token, bool & flag)
 {
     string ret;
     int pos = str.find(token);
@@ -1068,6 +1119,7 @@ static bool getTokenValue(string const str, const char * token, bool & flag)
     return true;
 }
 
+
 void l_getline(istream & is, string & str)
 {
     getline(is, str);
@@ -1075,6 +1127,7 @@ void l_getline(istream & is, string & str)
        getline(is, str);
 }
 
+
 void LyXTabular::Read(LyXLex & lex)
 {
     string line;
@@ -1176,6 +1229,7 @@ void LyXTabular::Read(LyXLex & lex)
     set_row_column_number_info();
 }
 
+
 void LyXTabular::OldFormatRead(istream & is, string fl)
 {
     int version;
@@ -1716,13 +1770,14 @@ int LyXTabular::RoffEndOfCell(ostream & os, int cell)
 #endif
 
 
-char const *LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
+char const * LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
 {
-    int i;
-    if (isColumn)
-       i = cell;
-    else
-       i = column_of_cell(cell);
+       int i = isColumn ? cell : column_of_cell(cell);
+       
+       //if (isColumn)
+       //i = cell;
+       //else
+       //i = column_of_cell(cell);
     if (!isColumn && IsMultiColumn(cell)) {
        if (!cellinfo_of_cell(cell)->align_special.empty()) {
            return cellinfo_of_cell(cell)->align_special.c_str();
@@ -1890,7 +1945,7 @@ bool LyXTabular::IsMultiColumn(int cell) const
 }
 
 
-LyXTabular::cellstruct* LyXTabular::cellinfo_of_cell(int cell) const
+LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
 {
     int row = row_of_cell(cell);
     int column = column_of_cell(cell);
@@ -1931,7 +1986,7 @@ int LyXTabular::cells_in_multicolumn(int cell) const
 }
 
 
-int  LyXTabular::UnsetMultiColumn(int cell)
+int LyXTabular::UnsetMultiColumn(int cell)
 {
     int row = row_of_cell(cell);
     int column = column_of_cell(cell);
@@ -1967,26 +2022,31 @@ bool LyXTabular::IsLongTabular() const
     return is_long_tabular;
 }
 
+
 void LyXTabular::SetRotateTabular(int what)
 {
     rotate = what;
 }
 
+
 bool LyXTabular::GetRotateTabular() const
 {
     return rotate;
 }
 
+
 void LyXTabular::SetRotateCell(int cell, int what)
 {
     cellinfo_of_cell(cell)->rotate = what;
 }
 
+
 bool LyXTabular::GetRotateCell(int cell) const
 {
     return cellinfo_of_cell(cell)->rotate;
 }
 
+
 bool LyXTabular::NeedRotating() const
 {
     if (rotate)
@@ -2008,6 +2068,7 @@ bool LyXTabular::IsLastCell(int cell) const
     return true;
 }
 
+
 int LyXTabular::GetCellAbove(int cell) const
 {
     if (row_of_cell(cell) > 0)
@@ -2015,6 +2076,7 @@ int LyXTabular::GetCellAbove(int cell) const
     return cell;
 }
 
+
 int LyXTabular::GetCellNumber(int column, int row) const
 {
     if (column >= columns_)
@@ -2029,11 +2091,13 @@ int LyXTabular::GetCellNumber(int column, int row) const
     return cell_info[row][column].cellno;
 }
 
+
 void LyXTabular::SetLinebreaks(int cell, bool what)
 {
     cellinfo_of_cell(cell)->linebreaks = what;
 }
 
+
 bool LyXTabular::GetLinebreaks(int cell) const
 {
     if (column_info[column_of_cell(cell)].p_width.empty() &&
@@ -2042,6 +2106,7 @@ bool LyXTabular::GetLinebreaks(int cell) const
     return cellinfo_of_cell(cell)->linebreaks;
 }
 
+
 void LyXTabular::SetLTHead(int cell, bool first)
 {
     int row = row_of_cell(cell);
@@ -2059,6 +2124,7 @@ void LyXTabular::SetLTHead(int cell, bool first)
     }
 }
 
+
 bool LyXTabular::GetRowOfLTHead(int cell) const
 {
     if ((endhead+1) > rows_)
@@ -2066,6 +2132,7 @@ bool LyXTabular::GetRowOfLTHead(int cell) const
     return (row_of_cell(cell) == endhead);
 }
 
+
 bool LyXTabular::GetRowOfLTFirstHead(int cell) const
 {
     if ((endfirsthead+1) > rows_)
@@ -2073,6 +2140,7 @@ bool LyXTabular::GetRowOfLTFirstHead(int cell) const
     return (row_of_cell(cell) == endfirsthead);
 }
 
+
 void LyXTabular::SetLTFoot(int cell, bool last)
 {
     int row = row_of_cell(cell);
@@ -2090,6 +2158,7 @@ void LyXTabular::SetLTFoot(int cell, bool last)
     }
 }
 
+
 bool LyXTabular::GetRowOfLTFoot(int cell) const
 {
     if ((endfoot+1) > rows_)
@@ -2104,16 +2173,19 @@ bool LyXTabular::GetRowOfLTLastFoot(int cell) const
     return (row_of_cell(cell) == endlastfoot);
 }
 
+
 void LyXTabular::SetLTNewPage(int cell, bool what)
 {
     row_info[row_of_cell(cell)].newpage = what;
 }
 
+
 bool LyXTabular::GetLTNewPage(int cell) const
 {
     return row_info[row_of_cell(cell)].newpage;
 }
 
+
 void LyXTabular::SetAscentOfRow(int row, int height)
 {
     if (row >= rows_)
@@ -2121,6 +2193,7 @@ void LyXTabular::SetAscentOfRow(int row, int height)
     row_info[row].ascent_of_row = height;
 }
 
+
 void LyXTabular::SetDescentOfRow(int row, int height)
 {
     if (row >= rows_)
@@ -2128,6 +2201,7 @@ void LyXTabular::SetDescentOfRow(int row, int height)
     row_info[row].descent_of_row = height;
 }
 
+
 int LyXTabular::GetAscentOfRow(int row) const
 {
     if (row >= rows_)
@@ -2135,6 +2209,7 @@ int LyXTabular::GetAscentOfRow(int row) const
     return row_info[row].ascent_of_row;
 }
 
+
 int LyXTabular::GetDescentOfRow(int row) const
 {
     if (row >= rows_)
@@ -2142,18 +2217,18 @@ int LyXTabular::GetDescentOfRow(int row) const
     return row_info[row].descent_of_row;
 }
 
+
 int LyXTabular::GetHeightOfTabular() const
 {
-    int
-        height,
-        row;
+       int height = 0;
 
-    for(row=0,height=0;(row<rows_); ++row)
+    for(int row = 0; row < rows_; ++row)
         height += GetAscentOfRow(row) + GetDescentOfRow(row) +
-           GetAdditionalHeight(GetCellNumber(0,row));
+           GetAdditionalHeight(GetCellNumber(0, row));
     return height;
 }
 
+
 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
 {
     if ((row >= rows_) || (column >= columns_))
@@ -2161,11 +2236,13 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
     return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
 }
 
+
 int LyXTabular::Latex(ostream &) const
 {
     return 0;
 }
 
+
 InsetText * LyXTabular::GetCellInset(int cell) const
 {
     return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
index bb3bb9cb6033f568ec79f53879766507fd240199..6665a83768cdee86b086b0ea8f669058b486639d 100644 (file)
@@ -262,7 +262,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
        ~cellstruct();
        ///
-        cellstruct & operator=(cellstruct const &);
+        cellstruct(cellstruct const &);
+       ///
+       cellstruct & operator=(cellstruct const &);
        ///
        int cellno;
        ///
@@ -291,9 +293,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
         rowstruct();
        ///
-       ~rowstruct();
+           //~rowstruct();
        ///
-        rowstruct & operator=(rowstruct const &);
+           // rowstruct & operator=(rowstruct const &);
        ///
        bool top_line;
        bool bottom_line;
@@ -307,9 +309,9 @@ private: //////////////////////////////////////////////////////////////////
        ///
         columnstruct();
        ///
-       ~columnstruct();
+           //~columnstruct();
        ///
-        columnstruct & operator=(columnstruct const &);
+           //columnstruct & operator=(columnstruct const &);
        ///
        int alignment; // add approp. signedness
        bool left_line;
@@ -344,7 +346,7 @@ private: //////////////////////////////////////////////////////////////////
     int endfoot; // row of endfoot
     int endlastfoot; // row of endlastfoot
     ///
-    Buffer *buffer;
+    Buffer * buffer;
    
     ///
     void set_row_column_number_info();