From 0003b5e76c80487518968e4640bea546b99aada9 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 7 Apr 2003 20:32:29 +0000 Subject: [PATCH] bugs 1013, 1017 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6728 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 10 ++++++++++ src/paragraph.C | 2 -- src/text.C | 43 +------------------------------------------ src/text2.C | 10 ++++++++++ 4 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fbc26e38a7..4fa2a97ac9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2003-04-07 John Levon + + * paragraph.C: remove dead comment + + * text.C: remove troublesome depth-fiddling code + in leftMargin() and rightMargin() (bug 1017) + + * text2.C (updateCounters): fix up depth values + (bug 1013) + 2003-04-07 John Levon * BufferView_pimpl.C: clear message when doc finishes resizing, diff --git a/src/paragraph.C b/src/paragraph.C index b83a8a77a5..25bf6ea63f 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -433,8 +433,6 @@ LyXFont const Paragraph::getFirstFontSettings() const // The difference is that this one is used for generating the LaTeX file, // and thus cosmetic "improvements" are disallowed: This has to deliver // the true picture of the buffer. (Asger) -// If position is -1, we get the layout font of the paragraph. -// If position is -2, we get the font of the manual label of the paragraph. LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos) const { diff --git a/src/text.C b/src/text.C index 7f8b79f552..9f55453e36 100644 --- a/src/text.C +++ b/src/text.C @@ -543,7 +543,7 @@ int LyXText::leftMargin(Row const & row) const Paragraph * newpar = row.par()->outerHook(); - // make a corresponding row. Needed to call LeftMargin() + // make a corresponding row. Needed to call leftMargin() // check wether it is a sufficent paragraph if (newpar && newpar->layout()->isEnvironment()) { @@ -551,12 +551,6 @@ int LyXText::leftMargin(Row const & row) const dummyrow.par(newpar); dummyrow.pos(newpar->size()); x = leftMargin(dummyrow); - } else { - // this is no longer an error, because this function - // is used to clear impossible depths after changing - // a layout. Since there is always a redo, - // LeftMargin() is always called - row.par()->params().depth(0); } if (newpar && row.par()->layout() == tclass.defaultLayout()) { @@ -717,38 +711,6 @@ int LyXText::rightMargin(Buffer const & buf, Row const & row) const + font_metrics::signedWidth(tclass.rightmargin(), tclass.defaultfont()); - // this is the way, LyX handles the LaTeX-Environments. - // I have had this idea very late, so it seems to be a - // later added hack and this is true - if (row.par()->getDepth()) { - // find the next level paragraph - - ParagraphList::iterator newpit = row.par(); - - do { - --newpit; - } while (newpit != ownerParagraphs().begin() - && newpit->getDepth() >= row.par()->getDepth()); - - // make a corresponding row. Needed to call LeftMargin() - - // check wether it is a sufficent paragraph - if (newpit != ownerParagraphs().begin() && - newpit->layout()->isEnvironment()) { - Row dummyrow; - dummyrow.par(newpit); - dummyrow.pos(0); - x = rightMargin(buf, dummyrow); - } else { - // this is no longer an error, because this function - // is used to clear impossible depths after changing - // a layout. Since there is always a redo, - // LeftMargin() is always called - row.par()->params().depth(0); - } - } - - //lyxerr << "rightmargin: " << layout->rightmargin << endl; x += font_metrics::signedWidth(layout->rightmargin, tclass.defaultfont()) * 4 / (row.par()->getDepth() + 4); @@ -841,9 +803,6 @@ LyXText::rowBreakPoint(Row const & row) const getLabelFont(bv()->buffer(), &*pit)); if (pit->isLineSeparator(i - 1)) thiswidth -= singleWidth(&*pit, i - 1); - int left_margin = labelEnd(row); - if (thiswidth < left_margin) - thiswidth = left_margin; } x += thiswidth; diff --git a/src/text2.C b/src/text2.C index 4b634fda5e..e42eaf733d 100644 --- a/src/text2.C +++ b/src/text2.C @@ -519,7 +519,10 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only) setCursor(selection.end.par(), selection.end.pos()); } + // this handles the counter labels, and also fixes up + // depth values for follow-on (child) paragraphs updateCounters(); + setSelection(); setCursor(tmpcursor.par(), tmpcursor.pos()); @@ -1237,6 +1240,13 @@ void LyXText::updateCounters() string const oldLabel = pit->params().labelString(); + int maxdepth = 0; + if (pit != ownerParagraphs().begin()) + maxdepth = boost::prior(pit)->getMaxDepthAfter(); + + if (pit->params().depth() > maxdepth) + pit->params().depth(maxdepth); + // setCounter can potentially change the labelString. setCounter(bv()->buffer(), &*pit); -- 2.39.2