From bb0175e906808256e68a670a8ae5e83e00bf3603 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 17 Jul 2003 09:25:06 +0000 Subject: [PATCH] simplify InsetTabular::calculate_dimensions_of_cells a bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7302 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/insettabular.C | 30 ++++++++++++++---------------- src/insets/insettabular.h | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 6067326101..a0c0ef3862 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -257,7 +257,7 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex) void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const { if (mi.base.bv) { - calculate_dimensions_of_cells(mi.base.bv, true); + calculate_dimensions_of_cells(mi.base.bv); //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl; for (int i = 0; i < tabular.getNumberOfCells(); ++i) { tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv; @@ -437,7 +437,7 @@ void InsetTabular::insetUnlock(BufferView * bv) void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const { if (what == INIT) { - calculate_dimensions_of_cells(bv, true); + calculate_dimensions_of_cells(bv); } if (!locked && what == CELL) what = FULL; @@ -1228,22 +1228,18 @@ void InsetTabular::validate(LaTeXFeatures & features) const } -bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) const +void InsetTabular::calculate_dimensions_of_cells(BufferView * bv) const { - int cell = -1; - int maxAsc = 0; - int maxDesc = 0; - InsetText * inset; - bool changed = false; - // FIXME: since InsetText ignores this anyway, it doesn't // matter what we pass it. Ugly LyXFont font; // if we have a locking_inset we should have to check only this cell for // change so I'll try this to have a boost, but who knows ;) - if ((need_update != INIT) && - (the_locking_inset == tabular.getCellInset(actcell))) { + if (need_update != INIT && + the_locking_inset == tabular.getCellInset(actcell)) { + int maxAsc = 0; + int maxDesc = 0; for(int i = 0; i < tabular.columns(); ++i) { Dimension dim; MetricsInfo mi(bv, font); @@ -1251,11 +1247,14 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c maxAsc = max(dim.asc, maxAsc); maxDesc = max(dim.des, maxDesc); } - changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); - changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed; - changed = tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed; - return changed; + tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); + tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT); + tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT); + return; } + + int cell = -1; + bool changed = false; for (int i = 0; i < tabular.rows(); ++i) { maxAsc = 0; maxDesc = 0; @@ -1275,7 +1274,6 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c } if (changed) tabular.reinit(); - return changed; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 816f833c77..9b2347a3d1 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -240,7 +240,7 @@ private: /// void lfunMouseMotion(FuncRequest const &); /// - bool calculate_dimensions_of_cells(BufferView *, bool = false) const; + void calculate_dimensions_of_cells(BufferView *) const; /// void drawCellLines(Painter &, int x, int baseline, int row, int cell) const; -- 2.39.2