From eead5ba43d0ddf06544ad1b40063981d3788c635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 30 Jul 2003 15:41:39 +0000 Subject: [PATCH] prevent crash when inserting minipage in table cell, small cosmetic stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7454 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/insets/ChangeLog | 7 +++++++ src/insets/insetcollapsable.C | 6 ++---- src/insets/insetfootlike.C | 4 ++-- src/insets/insettabular.C | 25 ++++++++++++------------- src/tabular.C | 4 ++-- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2b5a834442..ff1b01b7b4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ + +2003-07-30 André Pönitz + + * tabular.C: don't use Assert too heavily. This crashes where it + shouldn't + 2003-07-30 Alfredo Braunstein * lyxfunc.C (dispatch): do not mark the buffer dirty if the action diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 072e271c87..8c31b752dc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ + +2003-07-30 André Pönitz + + * insetcollapsable.C: + * insetfootlike.C: + * insettabular.C: parantheses, localize vars etc. + 2003-07-29 Martin Vermeer * insetnote.C: Implement a newenvironment in preamble for diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 2a328f3c46..4a5002bf19 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -113,7 +113,6 @@ void InsetCollapsable::read(Buffer const * buf, LyXLex & lex) void InsetCollapsable::dimension_collapsed(Dimension & dim) const { font_metrics::buttonText(label, labelfont, dim.wid, dim.asc, dim.des); - dim.wid += 2 * TEXT_TO_INSET_OFFSET; } @@ -141,7 +140,7 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const { - pi.pain.buttonText(x + TEXT_TO_INSET_OFFSET, y, label, labelfont); + pi.pain.buttonText(x, y, label, labelfont); } @@ -181,8 +180,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const inset.draw(pi, x, y); } else { draw_collapsed(pi, old_x, bl); - int const yy = bl + dim_collapsed.descent() + inset.ascent(); - inset.draw(pi, x, yy); + inset.draw(pi, x, bl + dim_collapsed.descent() + inset.ascent()); } } diff --git a/src/insets/insetfootlike.C b/src/insets/insetfootlike.C index 0605cfe34a..85e3366316 100644 --- a/src/insets/insetfootlike.C +++ b/src/insets/insetfootlike.C @@ -51,8 +51,8 @@ void InsetFootlike::write(Buffer const * buf, ostream & os) const bool InsetFootlike::insetAllowed(InsetOld::Code code) const { - if ((code == InsetOld::FOOT_CODE) || (code == InsetOld::MARGIN_CODE) - || (code == InsetOld::FLOAT_CODE)) + if (code == InsetOld::FOOT_CODE || code == InsetOld::MARGIN_CODE + || code == InsetOld::FLOAT_CODE) return false; return InsetCollapsable::insetAllowed(code); } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index c001980299..1cbf00c932 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -275,14 +275,12 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const { //lyxerr << "InsetTabular::draw: " << x << " " << y << "\n"; if (nodraw()) { + lyxerr << "InsetTabular::nodraw: " << x << " " << y << "\n"; need_update = FULL; return; } BufferView * bv = pi.base.bv; - int i; - int j; - int nx; #if 0 UpdatableInset::draw(pi, x, y); @@ -296,25 +294,24 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const x += ADD_TO_TABULAR_WIDTH; int cell = 0; - int cx; first_visible_cell = -1; - for (i = 0; i < tabular.rows(); ++i) { - nx = x; + for (int i = 0; i < tabular.rows(); ++i) { + int nx = x; cell = tabular.getCellNumber(i, 0); - if (!((y + tabular.getDescentOfRow(i)) > 0) && - (y - tabular.getAscentOfRow(i)) < pi.pain.paperHeight()) + if (y + tabular.getDescentOfRow(i) <= 0 && + y - tabular.getAscentOfRow(i) < pi.pain.paperHeight()) { - y += tabular.getDescentOfRow(i) + - tabular.getAscentOfRow(i + 1) + - tabular.getAdditionalHeight(i + 1); + y += tabular.getDescentOfRow(i) + + tabular.getAscentOfRow(i + 1) + + tabular.getAdditionalHeight(i + 1); continue; } - for (j = 0; j < tabular.columns(); ++j) { + for (int j = 0; j < tabular.columns(); ++j) { if (nx > bv->workWidth()) break; if (tabular.isPartOfMultiColumn(i, j)) continue; - cx = nx + tabular.getBeginningOfTextInCell(cell); + int cx = nx + tabular.getBeginningOfTextInCell(cell); if (first_visible_cell < 0) first_visible_cell = cell; if (hasSelection()) { @@ -2619,7 +2616,9 @@ bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const // well we didn't obviously find it so maybe our owner knows more if (owner()) return owner()->forceDefaultParagraphs(in); + // if we're here there is really something strange going on!!! + lyxerr << "if we're here there is really something strange going on!\n"; return false; } diff --git a/src/tabular.C b/src/tabular.C index b5067a263c..5ad06be2cc 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2609,8 +2609,8 @@ int LyXTabular::getCellFromInset(InsetOld const * inset, int maybe_cell) const { // is this inset part of the tabular? if (!inset || inset->owner() != owner_) { - lyxerr << "this is not a cell of the tabular!" << endl; - Assert(0); + //lyxerr << "Abort::this is not a cell of the tabular!" << endl; + return -1; } const int save_cur_cell = cur_cell;