]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
fix "make dist" target
[lyx.git] / src / tabular.C
index bd751ba08d3d6995839df5f04d89542da8dc0c1f..ce8d196ee99fd69dadf8f46032d4f1f77a8bb07f 100644 (file)
@@ -96,11 +96,13 @@ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
 LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
 {
        owner_ = inset;
-       Init(lt.rows_, lt.columns_);
+       Init(lt.rows_, lt.columns_, &lt);
+#if 0
 #ifdef WITH_WARNINGS
 #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
 #endif
        operator=(lt);
+#endif
 }
 
 
@@ -113,10 +115,16 @@ LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & 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()
-       Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
+       lyx::Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
 
        cell_info = lt.cell_info;
        row_info = lt.row_info;
@@ -132,7 +140,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
        rotate = lt.rotate;
 
        Reinit();
-       
+#endif
        return *this;
 }
 
@@ -140,6 +148,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
 LyXTabular * LyXTabular::Clone(InsetTabular * inset)
 {
        LyXTabular * result = new LyXTabular(inset, *this);
+#if 0
        // don't know if this is good but I need to Clone also
        // the text-insets here, this is for the Undo-facility!
        for (int i = 0; i < rows_; ++i) {
@@ -148,12 +157,13 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset)
                        result->cell_info[i][j].inset.setOwner(inset);
                }
        }
+#endif
        return result;
 }
 
 
 /* activates all lines and sets all widths to 0 */ 
-void LyXTabular::Init(int rows_arg, int columns_arg)
+void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
 {
        rows_ = rows_arg;
        columns_ = columns_arg;
@@ -161,6 +171,11 @@ void LyXTabular::Init(int rows_arg, int columns_arg)
        column_info = column_vector(columns_, columnstruct());
        cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
 
+       if (lt) {
+               operator=(*lt);
+               return;
+       }
+
        int cellno = 0;
        for (int i = 0; i < rows_; ++i) {
                for (int j = 0; j < columns_; ++j) {
@@ -428,10 +443,8 @@ bool LyXTabular::RightLine(int cell, bool onlycolumn) const
 
 bool LyXTabular::TopAlreadyDrawed(int cell) const
 {
-       if (GetAdditionalHeight(cell))
-               return false;
        int row = row_of_cell(cell);
-       if (row > 0) {
+       if ((row > 0) && !GetAdditionalHeight(row)) {
                int column = column_of_cell(cell);
                --row;
                while (column
@@ -469,10 +482,10 @@ bool LyXTabular::IsLastRow(int cell) const
 }
 
 
-int LyXTabular::GetAdditionalHeight(int cell) const
+int LyXTabular::GetAdditionalHeight(int row) const
 {
-       int const row = row_of_cell(cell);
-       if (!row) return 0;
+       if (!row || row >= rows_)
+               return 0;
 
        bool top = true;
        bool bottom = true;
@@ -668,7 +681,7 @@ bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
 
 
 bool LyXTabular::SetAlignSpecial(int cell, string const & special,
-                                LyXTabular::Feature what)
+                                 LyXTabular::Feature what)
 {
        if (what == SET_SPECIAL_MULTI)
                cellinfo_of_cell(cell)->align_special = special;
@@ -1468,10 +1481,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
 
        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
+
        string tmptok;
        int pos = 0;
        char depth = 0;
@@ -1492,14 +1502,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                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;
@@ -1517,12 +1520,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
        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
-       {
+       for (int i = 0; i < par->size(); ++i) {
                if (par->IsNewline(i)) {
                        ++cell;
                        if (cell > GetNumberOfCells()) {
@@ -1551,11 +1549,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                        }
                }
                par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
-#ifndef NEW_INSETS
-               inset->par->InsertFromMinibuffer(inset->par->Last());
-#else
                inset->par->InsertFromMinibuffer(inset->par->size());
-#endif
        }
        delete par;
        Reinit();
@@ -1881,7 +1875,7 @@ int LyXTabular::GetHeightOfTabular() const
 
        for (int row = 0; row < rows_; ++row)
                height += GetAscentOfRow(row) + GetDescentOfRow(row) +
-                       GetAdditionalHeight(GetCellNumber(row, 0));
+                       GetAdditionalHeight(row);
        return height;
 }
 
@@ -2158,11 +2152,8 @@ int LyXTabular::Latex(Buffer const * buf,
                        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);
@@ -2544,20 +2535,20 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
 }
 
 
-#ifndef NEW_INSETS
-LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
+std::vector<string> const LyXTabular::getLabelList() 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;
+       std::vector<string> label_list;
+       for (int i = 0; i < rows_; ++i)
+               for (int j = 0; j < columns_; ++j) {
+                       std::vector<string> const l =
+                               GetCellInset(i, j)->getLabelList();
+                       label_list.insert(label_list.end(),
+                                         l.begin(), l.end());
                }
-       }
-       return BOX_NONE;
+       return label_list;
 }
-#else
+
+                       
 LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
 {
        LyXParagraph * par = GetCellInset(cell)->par;
@@ -2570,4 +2561,10 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
        }
        return BOX_NONE;
 }
-#endif
+
+/* Emacs:
+ * Local variables:
+ * tab-width: 4
+ * End:
+ * vi:set tabstop=4:
+ */