]> git.lyx.org Git - lyx.git/commitdiff
Minimise the ControlTabular interface in preparation for a move to the
authorAngus Leeming <leeming@lyx.org>
Sun, 9 Mar 2003 10:08:22 +0000 (10:08 +0000)
committerAngus Leeming <leeming@lyx.org>
Sun, 9 Mar 2003 10:08:22 +0000 (10:08 +0000)
Dialog-based scheme.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6396 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlTabular.C
src/frontends/controllers/ControlTabular.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QDialogView.h
src/frontends/qt2/QTabular.C
src/frontends/qt2/QTabularDialog.C
src/frontends/qt2/Qt2Base.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormTabular.C

index acc4c900525a5f3253df9bfb1a3379b116f39d87..326d6c5ec095ade3ef10de2d58131e41748d5a29 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-09  Angus Leeming  <leeming@lyx.org>
+
+       * ControlTabular.[Ch]: minimise the interface in preparation for
+       a move to the Dialog-based scheme.
+       (inset): removed; the views require only getActiveCell().
+       (tabular): return as a reference.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * ControlGraphics.[Ch]: rewrite to use the Dialog-based scheme.
index 4c4c5ea627e1b02971267f4e32162895f3253129..126bfa7c3d40d171f52ff69ba651292e38c589e3 100644 (file)
@@ -124,17 +124,10 @@ void ControlTabular::connectInset(InsetTabular * inset)
 }
 
 
-InsetTabular * ControlTabular::inset() const
+LyXTabular const & ControlTabular::tabular() const
 {
        lyx::Assert(inset_);
-       return inset_;
-}
-
-
-LyXTabular * ControlTabular::tabular() const
-{
-       lyx::Assert(inset_);
-       return inset_->tabular.get();
+       return *inset_->tabular.get();
 }
 
 
@@ -145,13 +138,14 @@ void ControlTabular::set(LyXTabular::Feature f, string const & arg)
 }
 
 
-bool ControlTabular::metric() const
+bool ControlTabular::useMetricUnits() const
 {
        return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
 }
 
-bool ControlTabular::isMulticolumnCell() const
+
+int ControlTabular::getActiveCell() const
 {
-       int cell(inset()->getActCell());
-       return tabular()->IsMultiColumn(cell);
+       lyx::Assert(inset_);
+       return inset_->getActCell();
 }
index 83226833de169d52be4c07e1cd589b5e83cfe0fb..962e805c11a34d48b859b063d3c3685bc8f0b95b 100644 (file)
@@ -29,11 +29,14 @@ public:
 
        ControlTabular(LyXView &, Dialogs &);
 
-       /// get the inset
-       InsetTabular * inset() const;
+       ///
+       int getActiveCell() const;
 
        /// get the contained tabular
-       LyXTabular * tabular() const;
+       LyXTabular const & tabular() const;
+
+       /// return true if units should default to metric
+       bool useMetricUnits() const;
 
        /// set a parameter
        void set(LyXTabular::Feature, string const & arg = string());
@@ -44,12 +47,6 @@ public:
        /// update inset
        void updateInset(InsetTabular *);
 
-       /// return true if units should default to metric
-       bool metric() const;
-
-       /// return true if actual cell is multicolumn
-       bool isMulticolumnCell() const;
-
 private:
 
        /// we can't do this ...
index 16639aeb426b8b7edcf754043da25591f81557fb..69b515367106dc29f1c34177f82bf2cd503a87fa 100644 (file)
@@ -1,3 +1,13 @@
+2003-03-09  Angus Leeming  <leeming@lyx.org>
+
+       * QDialogView.h: make controller methods of QController public to
+       enable the QXyzDialog classes to access the controller if need be.
+       * Qt2Base.h: ditto for the controller methods of Qt2CB.
+
+       * QTabular.C:
+       * QTabularDialog.C: changes due to the changed ControlTabular
+       interface.
+
 2003-03-07  Dekel Tsur  <dekelts@tau.ac.il>
 
        * QPrefs.C:
index 4fe4a816d821ff35d535ad4c0732693304a7da60..a4ae9b9177d46a8852697ac38643e295e4216e45 100644 (file)
@@ -155,6 +155,7 @@ class QController: public Base
 protected:
        ///
        QController(Dialog &, QString const &);
+public:
        /// The parent controller
        Controller & controller();
        /// The parent controller
index 25e4c0586714836dd0757b8489c87599c0cf66e3..bacfe2439df9a562ef4708ad954c6557f1b5f5bc 100644 (file)
@@ -85,36 +85,37 @@ bool QTabular::isValid()
 
 void QTabular::update_borders()
 {
-       LyXTabular * tabular(controller().tabular());
-       int cell(controller().inset()->getActCell());
+       LyXTabular const & tabular = controller().tabular();
+       int const cell = controller().getActiveCell();
+       bool const isMulticolumnCell = tabular.IsMultiColumn(cell);
 
-       if (!controller().isMulticolumnCell()) {
+       if (!isMulticolumnCell) {
                dialog_->borders->setLeftEnabled(true);
                dialog_->borders->setRightEnabled(true);
-               dialog_->borders->setTop(tabular->TopLine(cell, true));
-               dialog_->borders->setBottom(tabular->BottomLine(cell, true));
-               dialog_->borders->setLeft(tabular->LeftLine(cell, true));
-               dialog_->borders->setRight(tabular->RightLine(cell, true));
+               dialog_->borders->setTop(tabular.TopLine(cell, true));
+               dialog_->borders->setBottom(tabular.BottomLine(cell, true));
+               dialog_->borders->setLeft(tabular.LeftLine(cell, true));
+               dialog_->borders->setRight(tabular.RightLine(cell, true));
                // repaint the setborder widget
                dialog_->borders->repaint();
                return;
        }
 
-       dialog_->borders->setTop(tabular->TopLine(cell));
-       dialog_->borders->setBottom(tabular->BottomLine(cell));
+       dialog_->borders->setTop(tabular.TopLine(cell));
+       dialog_->borders->setBottom(tabular.BottomLine(cell));
        // pay attention to left/right lines: they are only allowed
        // to set if we are in first/last cell of row or if the left/right
        // cell is also a multicolumn.
-       if (tabular->IsFirstCellInRow(cell) || tabular->IsMultiColumn(cell - 1)) {
+       if (tabular.IsFirstCellInRow(cell) || tabular.IsMultiColumn(cell - 1)) {
                dialog_->borders->setLeftEnabled(true);
-               dialog_->borders->setLeft(tabular->LeftLine(cell));
+               dialog_->borders->setLeft(tabular.LeftLine(cell));
        } else {
                dialog_->borders->setLeft(false);
                dialog_->borders->setLeftEnabled(false);
        }
-       if (tabular->IsLastCellInRow(cell) || tabular->IsMultiColumn(cell + 1)) {
+       if (tabular.IsLastCellInRow(cell) || tabular.IsMultiColumn(cell + 1)) {
                dialog_->borders->setRightEnabled(true);
-               dialog_->borders->setRight(tabular->RightLine(cell));
+               dialog_->borders->setRight(tabular.RightLine(cell));
        } else {
                dialog_->borders->setRight(false);
                dialog_->borders->setRightEnabled(false);
@@ -126,23 +127,23 @@ void QTabular::update_borders()
 
 void QTabular::update_contents()
 {
-       LyXTabular * tabular(controller().tabular());
-       int cell(controller().inset()->getActCell());
+       LyXTabular const & tabular(controller().tabular());
+       int const cell = controller().getActiveCell();
 
-       int const row(tabular->row_of_cell(cell));
-       int const col(tabular->column_of_cell(cell));
+       int const row(tabular.row_of_cell(cell));
+       int const col(tabular.column_of_cell(cell));
 
        dialog_->tabularRowED->setText(toqstr(tostr(row + 1)));
        dialog_->tabularColumnED->setText(toqstr(tostr(col + 1)));
 
-       bool const multicol(controller().isMulticolumnCell());
+       bool const multicol(tabular.IsMultiColumn(cell));
 
        dialog_->multicolumnCB->setChecked(multicol);
 
-       dialog_->rotateCellCB->setChecked(tabular->GetRotateCell(cell));
-       dialog_->rotateTabularCB->setChecked(tabular->GetRotateTabular());
+       dialog_->rotateCellCB->setChecked(tabular.GetRotateCell(cell));
+       dialog_->rotateTabularCB->setChecked(tabular.GetRotateTabular());
 
-       dialog_->longTabularCB->setChecked(tabular->IsLongTabular());
+       dialog_->longTabularCB->setChecked(tabular.IsLongTabular());
 
        update_borders();
 
@@ -150,11 +151,11 @@ void QTabular::update_contents()
        string special;
 
        if (multicol) {
-               special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
-               pwidth = tabular->GetMColumnPWidth(cell);
+               special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+               pwidth = tabular.GetMColumnPWidth(cell);
        } else {
-               special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
-               pwidth = tabular->GetColumnPWidth(cell);
+               special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+               pwidth = tabular.GetColumnPWidth(cell);
        }
 
        dialog_->specialAlignmentED->setText(toqstr(special));
@@ -162,7 +163,7 @@ void QTabular::update_contents()
        bool const isReadonly = bc().bp().isReadOnly();
        dialog_->specialAlignmentED->setEnabled(!isReadonly);
 
-       LyXLength::UNIT default_unit = controller().metric() ? LyXLength::CM : LyXLength::IN;
+       LyXLength::UNIT default_unit = controller().useMetricUnits() ? LyXLength::CM : LyXLength::IN;
        if (!pwidth.zero()) {
                dialog_->widthED->setText(toqstr(tostr(pwidth.value())));
                dialog_->widthUnit->setCurrentItem(pwidth.unit());
@@ -181,7 +182,7 @@ void QTabular::update_contents()
                dialog_->hAlignCB->insertItem(qt_("Block"));
 
        int align = 0;
-       switch (tabular->GetAlignment(cell)) {
+       switch (tabular.GetAlignment(cell)) {
        case LYX_ALIGN_LEFT:
                align = 0;
                break;
@@ -204,7 +205,7 @@ void QTabular::update_contents()
        dialog_->hAlignCB->setCurrentItem(align);
 
        int valign = 0;
-       switch (tabular->GetVAlignment(cell)) {
+       switch (tabular.GetVAlignment(cell)) {
        case LyXTabular::LYX_VALIGN_TOP:
                valign = 0;
                break;
@@ -225,7 +226,7 @@ void QTabular::update_contents()
        dialog_->hAlignCB->setEnabled(true);
        dialog_->vAlignCB->setEnabled(!pwidth.zero());
 
-       if (!tabular->IsLongTabular()) {
+       if (!tabular.IsLongTabular()) {
                dialog_->headerStatusCB->setChecked(false);
                dialog_->headerBorderAboveCB->setChecked(false);
                dialog_->headerBorderBelowCB->setChecked(false);
@@ -246,7 +247,7 @@ void QTabular::update_contents()
 
        LyXTabular::ltType ltt;
        bool use_empty;
-       bool row_set = tabular->GetRowOfLTHead(row, ltt);
+       bool row_set = tabular.GetRowOfLTHead(row, ltt);
        dialog_->headerStatusCB->setChecked(row_set);
        if (ltt.set) {
                dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
@@ -262,7 +263,7 @@ void QTabular::update_contents()
                use_empty = false;
        }
 
-       row_set = tabular->GetRowOfLTFirstHead(row, ltt);
+       row_set = tabular.GetRowOfLTFirstHead(row, ltt);
        dialog_->firstheaderStatusCB->setChecked(row_set);
        if (ltt.set && (!ltt.empty || !use_empty)) {
                dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
@@ -279,7 +280,7 @@ void QTabular::update_contents()
                }
        }
 
-       row_set = tabular->GetRowOfLTFoot(row, ltt);
+       row_set = tabular.GetRowOfLTFoot(row, ltt);
        dialog_->footerStatusCB->setChecked(row_set);
        if (ltt.set) {
                dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
@@ -295,7 +296,7 @@ void QTabular::update_contents()
                use_empty = false;
        }
 
-       row_set = tabular->GetRowOfLTLastFoot(row, ltt);
+       row_set = tabular.GetRowOfLTLastFoot(row, ltt);
                dialog_->lastfooterStatusCB->setChecked(row_set);
        if (ltt.set && (!ltt.empty || !use_empty)) {
                dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
@@ -311,7 +312,7 @@ void QTabular::update_contents()
                                dialog_->lastfooterStatusCB->setEnabled(false);
                }
        }
-       dialog_->newpageCB->setChecked(tabular->GetLTNewPage(row));
+       dialog_->newpageCB->setChecked(tabular.GetLTNewPage(row));
 }
 
 
@@ -320,17 +321,16 @@ void QTabular::closeGUI()
        // ugly hack to auto-apply the stuff that hasn't been
        // yet. don't let this continue to exist ...
 
-       InsetTabular * inset(controller().inset());
-       LyXTabular * tabular(controller().tabular());
+       LyXTabular const & tabular(controller().tabular());
 
        // apply the fixed width values
-       int cell = inset->getActCell();
-       bool const multicol(controller().isMulticolumnCell());
+       int const cell = controller().getActiveCell();
+       bool const multicol(tabular.IsMultiColumn(cell));
        string str1 = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
        string str2;
 
-       LyXLength llen(tabular->GetColumnPWidth(cell));
-       LyXLength llenMulti(tabular->GetMColumnPWidth(cell));
+       LyXLength llen(tabular.GetColumnPWidth(cell));
+       LyXLength llenMulti(tabular.GetMColumnPWidth(cell));
 
        if (multicol && !llenMulti.zero())
                        str2 = llenMulti.asString();
@@ -347,9 +347,9 @@ void QTabular::closeGUI()
        // apply the special alignment
        str1 = fromqstr(dialog_->specialAlignmentED->text());
        if (multicol)
-               str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+               str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
        else
-               str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+               str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
 
        if (str1 != str2) {
                if (multicol)
index a1cac3fc8b9f45a264a9c7e5b835dfffd7c34bf8..88f52b2ec1d7c66ab4411a86581a6980b11fb8e9 100644 (file)
@@ -92,9 +92,21 @@ void QTabularDialog::borderUnset_clicked()
 }
 
 
+namespace {
+
+bool isMulticolumnCell(QTabular * form) 
+{
+       LyXTabular const & tabular = form->controller().tabular();
+       int const cell = form->controller().getActiveCell();
+       return tabular.IsMultiColumn(cell);
+}
+
+}
+
+
 void QTabularDialog::leftBorder_changed()
 {
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
        else
                form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
@@ -104,7 +116,7 @@ void QTabularDialog::leftBorder_changed()
 
 void QTabularDialog::rightBorder_changed()
 {
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
        else
                form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
@@ -114,7 +126,7 @@ void QTabularDialog::rightBorder_changed()
 
 void QTabularDialog::topBorder_changed()
 {
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
        else
                form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
@@ -124,7 +136,7 @@ void QTabularDialog::topBorder_changed()
 
 void QTabularDialog::bottomBorder_changed()
 {
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
        else
                form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
@@ -135,7 +147,7 @@ void QTabularDialog::bottomBorder_changed()
 void QTabularDialog::specialAlignment_changed()
 {
        string special = fromqstr(specialAlignmentED->text());
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
        else
                form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
@@ -147,7 +159,7 @@ void QTabularDialog::width_changed()
        string const width =
                LyXLength(widthED->text().toDouble(),
                        widthUnit->currentLengthItem()).asString();
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(LyXTabular::SET_MPWIDTH, width);
        else
                form_->controller().set(LyXTabular::SET_PWIDTH, width);
@@ -227,7 +239,7 @@ void QTabularDialog::hAlign_changed(int align)
                }
                }
        }
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(multi_num);
        else
                form_->controller().set(num);
@@ -259,7 +271,7 @@ void QTabularDialog::vAlign_changed(int align)
                        break;
                }
        }
-       if (form_->controller().isMulticolumnCell())
+       if (isMulticolumnCell(form_))
                form_->controller().set(multi_num);
        else
                form_->controller().set(num);
index f8d5469c6390f2bcc98e60ca115f626a810bb458..ca98ae6c420017c3ec160d7cc6bfd7b06e8c678d 100644 (file)
@@ -152,13 +152,14 @@ public:
                return controller().bufferIsReadonly();
        }
 
-protected:
-       ///
-       Qt2CB(QString const &);
        /// The parent controller
        Controller & controller();
        /// The parent controller
        Controller const & controller() const;
+
+protected:
+       ///
+       Qt2CB(QString const &);
 };
 
 
index 3cc072a820f6e3347a0ff549aa0924314ea41d23..2882d5b63cf5055816b0073fae364f11867b0595 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-09  Angus Leeming  <leeming@lyx.org>
+
+       * FormTabular.C: changes due to the changed ControlTabular
+       interface.
+
 2003-03-07  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.C:
index 9d219c1877ee5f416153f7192fabd423c364c332..ade140b4a3638e1b54f62c306cbdcfda9070a111 100644 (file)
@@ -131,17 +131,16 @@ void FormTabular::update()
        if (closing_)
                return;
 
-       LyXTabular * tabular = controller().tabular();
-       InsetTabular * inset = controller().inset();
+       LyXTabular const & tabular = controller().tabular();
 
        int align;
        char buf[12];
        LyXLength pwidth;
        string special;
 
-       int cell = inset->getActCell();
+       int const cell = controller().getActiveCell();
        actCell_ = cell;
-       int column = tabular->column_of_cell(cell) + 1;
+       int column = tabular.column_of_cell(cell) + 1;
        clearMessage();
        fl_activate_object(column_options_->input_special_alignment);
        fl_activate_object(cell_options_->input_special_multialign);
@@ -150,41 +149,41 @@ void FormTabular::update()
        sprintf(buf, "%d", column);
        fl_set_input(dialog_->input_tabular_column, buf);
        fl_deactivate_object(dialog_->input_tabular_column);
-       int row = tabular->row_of_cell(cell);
+       int row = tabular.row_of_cell(cell);
        sprintf(buf, "%d", row + 1);
        fl_set_input(dialog_->input_tabular_row, buf);
        fl_deactivate_object(dialog_->input_tabular_row);
-       if (tabular->IsMultiColumn(cell)) {
+       if (tabular.IsMultiColumn(cell)) {
                fl_set_button(cell_options_->check_multicolumn, 1);
                fl_set_button(cell_options_->check_border_top,
-                             tabular->TopLine(cell)?1:0);
+                             tabular.TopLine(cell)?1:0);
                setEnabled(cell_options_->check_border_top, true);
                fl_set_button(cell_options_->check_border_bottom,
-                             tabular->BottomLine(cell)?1:0);
+                             tabular.BottomLine(cell)?1:0);
                setEnabled(cell_options_->check_border_bottom, true);
                // pay attention to left/right lines they are only allowed
                // to set if we are in first/last cell of row or if the left/right
                // cell is also a multicolumn.
-               if (tabular->IsFirstCellInRow(cell) ||
-                   tabular->IsMultiColumn(cell-1)) {
+               if (tabular.IsFirstCellInRow(cell) ||
+                   tabular.IsMultiColumn(cell-1)) {
                        fl_set_button(cell_options_->check_border_left,
-                                     tabular->LeftLine(cell)?1:0);
+                                     tabular.LeftLine(cell)?1:0);
                        setEnabled(cell_options_->check_border_left, true);
                } else {
                        fl_set_button(cell_options_->check_border_left, 0);
                        setEnabled(cell_options_->check_border_left, false);
                }
-               if (tabular->IsLastCellInRow(cell) ||
-                   tabular->IsMultiColumn(cell+1)) {
+               if (tabular.IsLastCellInRow(cell) ||
+                   tabular.IsMultiColumn(cell+1)) {
                        fl_set_button(cell_options_->check_border_right,
-                                     tabular->RightLine(cell)?1:0);
+                                     tabular.RightLine(cell)?1:0);
                        setEnabled(cell_options_->check_border_right, true);
                } else {
                        fl_set_button(cell_options_->check_border_right, 0);
                        setEnabled(cell_options_->check_border_right, false);
                }
-               pwidth = tabular->GetMColumnPWidth(cell);
-               align = tabular->GetAlignment(cell);
+               pwidth = tabular.GetMColumnPWidth(cell);
+               align = tabular.GetAlignment(cell);
                // set the horiz. alignment, default is left here
                fl_set_button(cell_options_->radio_align_left, 0);
                fl_set_button(cell_options_->radio_align_right, 0);
@@ -196,7 +195,7 @@ void FormTabular::update()
                else
                        fl_set_button(cell_options_->radio_align_left, 1);
 
-               align = tabular->GetVAlignment(cell);
+               align = tabular.GetVAlignment(cell);
                fl_set_button(cell_options_->radio_valign_top, 0);
                fl_set_button(cell_options_->radio_valign_bottom, 0);
                fl_set_button(cell_options_->radio_valign_center, 0);
@@ -207,9 +206,9 @@ void FormTabular::update()
                else
                        fl_set_button(cell_options_->radio_valign_top, 1);
 
-               special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+               special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
                fl_set_input(cell_options_->input_special_multialign, special.c_str());
-               bool const metric(controller().metric());
+               bool const metric(controller().useMetricUnits());
                string const default_unit = metric ? "cm" : "in";
                updateWidgetsFromLength(cell_options_->input_mcolumn_width,
                                        cell_options_->choice_value_mcolumn_width,
@@ -268,34 +267,34 @@ void FormTabular::update()
                setEnabled(cell_options_->input_mcolumn_width, false);
                setEnabled(cell_options_->choice_value_mcolumn_width, false);
        }
-       if (tabular->GetRotateCell(cell))
+       if (tabular.GetRotateCell(cell))
                fl_set_button(cell_options_->check_rotate_cell, 1);
        else
                fl_set_button(cell_options_->check_rotate_cell, 0);
-       if (tabular->TopLine(cell, true))
+       if (tabular.TopLine(cell, true))
                fl_set_button(column_options_->check_border_top, 1);
        else
                fl_set_button(column_options_->check_border_top, 0);
-       if (tabular->BottomLine(cell, true))
+       if (tabular.BottomLine(cell, true))
                fl_set_button(column_options_->check_border_bottom, 1);
        else
                fl_set_button(column_options_->check_border_bottom, 0);
-       if (tabular->LeftLine(cell, true))
+       if (tabular.LeftLine(cell, true))
                fl_set_button(column_options_->check_border_left, 1);
        else
                fl_set_button(column_options_->check_border_left, 0);
-       if (tabular->RightLine(cell, true))
+       if (tabular.RightLine(cell, true))
                fl_set_button(column_options_->check_border_right, 1);
        else
                fl_set_button(column_options_->check_border_right, 0);
-       special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+       special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
        fl_set_input(column_options_->input_special_alignment, special.c_str());
 
        bool const isReadonly = bc().bp().isReadOnly();
        setEnabled(column_options_->input_special_alignment, !isReadonly);
 
-       pwidth = tabular->GetColumnPWidth(cell);
-       bool const metric = lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
+       pwidth = tabular.GetColumnPWidth(cell);
+       bool const metric = controller().useMetricUnits();
        string const default_unit = metric ? "cm" : "in";
        updateWidgetsFromLength(column_options_->input_column_width,
                                column_options_->choice_value_column_width,
@@ -305,14 +304,14 @@ void FormTabular::update()
 
        setEnabled(cell_options_->check_useminipage, !pwidth.zero());
        if (!pwidth.zero()) {
-               if (tabular->GetUsebox(cell) == 2)
+               if (tabular.GetUsebox(cell) == 2)
                        fl_set_button(cell_options_->check_useminipage, 1);
                else
                        fl_set_button(cell_options_->check_useminipage, 0);
        } else {
                fl_set_button(cell_options_->check_useminipage, 0);
        }
-       align = tabular->GetAlignment(cell, true);
+       align = tabular.GetAlignment(cell, true);
        fl_set_button(column_options_->radio_align_left, 0);
        fl_set_button(column_options_->radio_align_right, 0);
        fl_set_button(column_options_->radio_align_center, 0);
@@ -325,7 +324,7 @@ void FormTabular::update()
                fl_set_button(column_options_->radio_align_center, 1);
        else
                fl_set_button(column_options_->radio_align_block, 1);
-       align = tabular->GetVAlignment(cell, true);
+       align = tabular.GetVAlignment(cell, true);
        fl_set_button(column_options_->radio_valign_top, 0);
        fl_set_button(column_options_->radio_valign_bottom, 0);
        fl_set_button(column_options_->radio_valign_center, 0);
@@ -345,9 +344,9 @@ void FormTabular::update()
        setEnabled(column_options_->radio_valign_center, !pwidth.zero());
 
        fl_set_button(tabular_options_->check_longtable,
-                     tabular->IsLongTabular());
+                     tabular.IsLongTabular());
 
-       bool const enable = tabular->IsLongTabular();
+       bool const enable = tabular.IsLongTabular();
 
        setEnabled(longtable_options_->check_lt_firsthead, enable);
        setEnabled(longtable_options_->check_1head_2border_above, enable);
@@ -368,7 +367,7 @@ void FormTabular::update()
        if (enable) {
                LyXTabular::ltType ltt;
                bool use_empty;
-               bool row_set = tabular->GetRowOfLTHead(row, ltt);
+               bool row_set = tabular.GetRowOfLTHead(row, ltt);
                fl_set_button(longtable_options_->check_lt_head, row_set);
                if (ltt.set) {
                        fl_set_button(longtable_options_->check_head_2border_above,
@@ -386,7 +385,7 @@ void FormTabular::update()
                        use_empty = false;
                }
                //
-               row_set = tabular->GetRowOfLTFirstHead(row, ltt);
+               row_set = tabular.GetRowOfLTFirstHead(row, ltt);
                fl_set_button(longtable_options_->check_lt_firsthead, row_set);
                if (ltt.set && (!ltt.empty || !use_empty)) {
                        fl_set_button(longtable_options_->check_1head_2border_above,
@@ -405,7 +404,7 @@ void FormTabular::update()
                        }
                }
                //
-               row_set = tabular->GetRowOfLTFoot(row, ltt);
+               row_set = tabular.GetRowOfLTFoot(row, ltt);
                fl_set_button(longtable_options_->check_lt_foot, row_set);
                if (ltt.set) {
                        fl_set_button(longtable_options_->check_foot_2border_above,
@@ -423,7 +422,7 @@ void FormTabular::update()
                        use_empty = false;
                }
                //
-               row_set = tabular->GetRowOfLTLastFoot(row, ltt);
+               row_set = tabular.GetRowOfLTLastFoot(row, ltt);
                fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
                if (ltt.set && (!ltt.empty || !use_empty)) {
                        fl_set_button(longtable_options_->check_lastfoot_2border_above,
@@ -443,7 +442,7 @@ void FormTabular::update()
                        }
                }
                fl_set_button(longtable_options_->check_lt_newpage,
-                             tabular->GetLTNewPage(row));
+                             tabular.GetLTNewPage(row));
        } else {
                fl_set_button(longtable_options_->check_lt_firsthead, 0);
                fl_set_button(longtable_options_->check_1head_2border_above, 0);
@@ -462,7 +461,7 @@ void FormTabular::update()
                fl_set_button(longtable_options_->check_lt_newpage, 0);
        }
        fl_set_button(tabular_options_->check_rotate_tabular,
-                     tabular->GetRotateTabular());
+                     tabular.GetRotateTabular());
 }
 
 
@@ -472,10 +471,9 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
        LyXTabular::Feature num = LyXTabular::LAST_ACTION;
        string special;
 
-       InsetTabular * inset(controller().inset());
-       LyXTabular * tabular(controller().tabular());
+       LyXTabular const & tabular = controller().tabular();
 
-       int cell = inset->getActCell();
+       int const cell = controller().getActiveCell();
 
        // ugly hack to auto-apply the stuff that hasn't been
        // yet. don't let this continue to exist ...
@@ -485,14 +483,14 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
                        getLengthFromWidgets(column_options_->input_column_width,
                                             column_options_->choice_value_column_width);
                string str2;
-               LyXLength llen = tabular->GetColumnPWidth(cell);
+               LyXLength llen = tabular.GetColumnPWidth(cell);
                if (!llen.zero())
                        str2 = llen.asString();
                if (str1 != str2)
                        input(column_options_->input_column_width, 0);
                str1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
                                            cell_options_->choice_value_mcolumn_width);
-               llen = tabular->GetMColumnPWidth(cell);
+               llen = tabular.GetMColumnPWidth(cell);
                if (llen.zero())
                        str2 = "";
                else
@@ -500,11 +498,11 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
                if (str1 != str2)
                        input(cell_options_->input_mcolumn_width, 0);
                str1 = getString(column_options_->input_special_alignment);
-               str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+               str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
                if (str1 != str2)
                        input(column_options_->input_special_alignment, 0);
                str1 = getString(cell_options_->input_special_multialign);
-               str2 = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+               str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
                if (str1 != str2)
                        input(cell_options_->input_special_multialign, 0);