]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetTabular.cpp
index 2908f2671b66865f8ada4ca3a1f222a75058d536..f69da2b74bf8f967929aea94691a48bce380343d 100644 (file)
 #include "Counters.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
-#include "support/debug.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "support/gettext.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "TextClass.h"
 #include "TextMetrics.h"
 
-#include "support/convert.h"
-#include "support/docstream.h"
-#include "support/FileName.h"
-#include "support/lstrings.h"
-
 #include "frontends/alert.h"
 #include "frontends/Clipboard.h"
 #include "frontends/Painter.h"
 #include "frontends/Selection.h"
 
+
+#include "support/convert.h"
+#include "support/debug.h"
+#include "support/docstream.h"
+#include "support/FileName.h"
+#include "support/gettext.h"
+#include "support/lstrings.h"
+
 #include <boost/scoped_ptr.hpp>
 
 #include <sstream>
 #include <iostream>
 #include <limits>
+#include <cstring>
 
 using namespace std;
 using namespace lyx::support;
@@ -483,7 +485,9 @@ Tabular::cellstruct::cellstruct(BufferParams const & bp)
          usebox(BOX_NONE),
          rotate(false),
          inset(new InsetText(bp))
-{}
+{
+       inset->paragraphs().back().layout(bp.getTextClass().emptyLayout());
+}
 
 
 Tabular::cellstruct::cellstruct(cellstruct const & cs)
@@ -1089,7 +1093,7 @@ void toggleFixedWidth(Cursor & cur, InsetText * inset, bool fixedWidth)
        cur.push(*inset);
        // undo information has already been recorded
        inset->getText(0)->setLayout(cur.bv().buffer(), 0, cur.lastpit() + 1,
-                       bp.getTextClass().defaultLayoutName());
+                       bp.getTextClass().emptyLayoutName());
        cur.pop();
 }
 
@@ -1960,7 +1964,8 @@ int Tabular::TeXTopHLine(odocstream & os, row_type row) const
                        ++tmp;
        }
        if (use_booktabs && row == 0) {
-               os << "\\toprule ";
+               if (topLine(fcell))
+                       os << "\\toprule ";
        } else if (tmp == n - fcell) {
                os << (use_booktabs ? "\\midrule " : "\\hline ");
        } else if (tmp) {
@@ -1996,7 +2001,8 @@ int Tabular::TeXBottomHLine(odocstream & os, row_type row) const
                        ++tmp;
        }
        if (use_booktabs && row == rowCount() - 1) {
-               os << "\\bottomrule";
+               if (bottomLine(fcell))
+                       os << "\\bottomrule";
        } else if (tmp == n - fcell) {
                os << (use_booktabs ? "\\midrule" : "\\hline");
        } else if (tmp) {
@@ -3150,13 +3156,13 @@ docstring const InsetTabular::editMessage() const
 }
 
 
-void InsetTabular::edit(Cursor & cur, bool left)
+void InsetTabular::edit(Cursor & cur, bool front, EntryDirection)
 {
        //lyxerr << "InsetTabular::edit: " << this << endl;
        cur.finishUndo();
        cur.selection() = false;
        cur.push(*this);
-       if (left) {
+       if (front) {
                if (isRightToLeft(cur))
                        cur.idx() = tabular.getLastCellInRow(0);
                else
@@ -4700,7 +4706,7 @@ void InsetTabular::rejectChanges(BufferParams const & bparams)
 }
 
 
-bool InsetTabular::forceDefaultParagraphs(idx_type cell) const
+bool InsetTabular::allowParagraphCustomization(idx_type cell) const
 {
        return tabular.getPWidth(cell).zero();
 }