From 60cb88d2ef37fa34bf0f247205bd77f6cd6dbef9 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 21 Apr 2008 13:47:01 +0000 Subject: [PATCH] Tabular de-spaghettization, step 2: move functions to where they are used. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24414 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiTabular.cpp | 47 +++++++++++++++++++++++++------- src/frontends/qt4/GuiWorkArea.h | 2 +- src/insets/InsetTabular.cpp | 22 --------------- src/insets/InsetTabular.h | 6 ---- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 5161e7bf04..dccad356a5 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -567,11 +567,38 @@ void GuiTabular::update_borders() } +namespace { + +Length getColumnPWidth(Tabular const & t, size_t cell) +{ + return t.column_info[t.cellColumn(cell)].p_width; +} + + +Length getMColumnPWidth(Tabular const & t, size_t cell) +{ + if (t.isMultiColumn(cell)) + return t.cellInfo(cell).p_width; + return Length(); +} + + +docstring getAlignSpecial(Tabular const & t, size_t cell, int what) +{ + if (what == Tabular::SET_SPECIAL_MULTI) + return t.cellInfo(cell).align_special; + return t.column_info[t.cellColumn(cell)].align_special; +} + +} + + + void GuiTabular::updateContents() { initialiseParams(string()); - Tabular::idx_type const cell = getActiveCell(); + size_t const cell = getActiveCell(); Tabular::row_type const row = tabular_.cellRow(cell); Tabular::col_type const col = tabular_.cellColumn(cell); @@ -594,11 +621,11 @@ void GuiTabular::updateContents() docstring special; if (multicol) { - special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI); - pwidth = tabular_.getMColumnPWidth(cell); + special = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_MULTI); + pwidth = getMColumnPWidth(tabular_, cell); } else { - special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN); - pwidth = tabular_.getColumnPWidth(cell); + special = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_COLUMN); + pwidth = getColumnPWidth(tabular_, cell); } specialAlignmentED->setText(toqstr(special)); @@ -828,13 +855,13 @@ void GuiTabular::closeGUI() // since the changes update the actual tabular_ // // apply the fixed width values - Tabular::idx_type const cell = getActiveCell(); + size_t const cell = getActiveCell(); bool const multicol = tabular_.isMultiColumn(cell); string width = widgetsToLength(widthED, widthUnit); string width2; - Length llen = tabular_.getColumnPWidth(cell); - Length llenMulti = tabular_.getMColumnPWidth(cell); + Length llen = getColumnPWidth(tabular_, cell); + Length llenMulti = getMColumnPWidth(tabular_, cell); if (multicol && !llenMulti.zero()) width2 = llenMulti.asString(); @@ -846,9 +873,9 @@ void GuiTabular::closeGUI() docstring sa2; if (multicol) - sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI); + sa2 = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_MULTI); else - sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN); + sa2 = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_COLUMN); if (sa1 != sa2) { if (multicol) diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 7120372341..86da009bfb 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -290,7 +290,7 @@ class DragTabBar : public QTabBar Q_OBJECT public: /// - DragTabBar(QWidget * parent=0); + DragTabBar(QWidget * parent = 0); #if QT_VERSION < 0x040300 /// diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 96f18d98a9..f9bdd7360d 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1128,28 +1128,6 @@ Length const Tabular::getPWidth(idx_type cell) const } -Length const Tabular::getColumnPWidth(idx_type cell) const -{ - return column_info[cellColumn(cell)].p_width; -} - - -Length const Tabular::getMColumnPWidth(idx_type cell) const -{ - if (isMultiColumn(cell)) - return cellInfo(cell).p_width; - return Length(); -} - - -docstring const Tabular::getAlignSpecial(idx_type cell, int what) const -{ - if (what == SET_SPECIAL_MULTI) - return cellInfo(cell).align_special; - return column_info[cellColumn(cell)].align_special; -} - - int Tabular::cellWidth(idx_type cell) const { return cellInfo(cell).width; diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 3275e8b8bf..149ea80121 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -314,12 +314,6 @@ public: /// Length const getPWidth(idx_type cell) const; /// - Length const getColumnPWidth(idx_type cell) const; - /// - Length const getMColumnPWidth(idx_type cell) const; - /// - docstring const getAlignSpecial(idx_type cell, int what) const; - /// int cellWidth(idx_type cell) const; /// int getBeginningOfTextInCell(idx_type cell) const; -- 2.39.2