The following patch (which could easily be broken in parts) does the
following:
- fix numbering of sections on display. In particular, secnumdepth is
respected.
- add proper numbering for Paragraph and SubParagraph.
- fix the problem with extra spacing above unnumbered Chapter.
- makes sure Koma-script's captionabove and captionbelow get into the
table of floats.
- hopefully fix correctly numbering of Theorems with several
paragraphs (I was sure there was a bug for that, but I cannot find
it anymore).
- update screen and counters after a class switch.
- update screen and counters after a secnumdepth change.
Testing is very welcome. More works remains to be done on counters:
- make numbering of captions work
- use this proper numbering in List of Floats.
- The table of contents is not able to display items with a toclevel
<=0. This is related to the removal of LyXTextClass::maxcounter in
HEAD. Basically, we have to know what is the index of the topmost
toc level (which is different between book and article, for
example).
- other bug reports?
If no problems are uncovered in this patch, I would like to commit it.
If some parts are controversial, I can commit the rest.
JMarc
Index: lib/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v
retrieving revision 1.684
diff -u -p -r1.684 ChangeLog
--- lib/ChangeLog 9 Apr 2005 10:52:52 -0000 1.684
+++ lib/ChangeLog 14 Apr 2005 14:42:34 -0000
@@ -1,3 +1,14 @@
+2005-04-14 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * layouts/scrclass.inc: do not assign a toclevel to addchap or
+ addsec.
+
+ * layouts/numreport.inc: use data from numarticle.inc, so that
+ changes from article are obvious.
+
+ * layouts/numarticle.inc: add numbering stuff for Paragraph and
+ SubParagraph; set Part TocLevel to 0.
+
2005-04-09 Angus Leeming <[EMAIL PROTECTED]>
* Makefile.am (dist_scripts_DATA): add scripts/fig_copy.sh and
Index: lib/layouts/numarticle.inc
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/layouts/numarticle.inc,v
retrieving revision 1.3
diff -u -p -r1.3 numarticle.inc
--- lib/layouts/numarticle.inc 13 Oct 2003 09:50:10 -0000 1.3
+++ lib/layouts/numarticle.inc 14 Apr 2005 14:42:34 -0000
@@ -1,10 +1,11 @@
# Author : Andr� P�nitz
-# This include files contains label definitions for a article-like numbering.
+# This include file contains label definitions for an article-like numbering.
Style Part
LabelType Counter
LabelCounter part
LabelString "Part \Roman{part}"
+ TocLevel 0
End
@@ -36,10 +37,18 @@ End
Style Paragraph
+ LabelType Counter
+ LabelCounter paragraph
+ LabelString "@[EMAIL PROTECTED]"
+ LabelStringAppendix "@[EMAIL PROTECTED]"
TocLevel 4
End
Style Subparagraph
+ LabelType Counter
+ LabelCounter subparagraph
+ LabelString "@[EMAIL PROTECTED]"
+ LabelStringAppendix "@[EMAIL PROTECTED]"
TocLevel 5
End
Index: lib/layouts/numreport.inc
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/layouts/numreport.inc,v
retrieving revision 1.3
diff -u -p -r1.3 numreport.inc
--- lib/layouts/numreport.inc 13 Oct 2003 09:50:10 -0000 1.3
+++ lib/layouts/numreport.inc 14 Apr 2005 14:42:34 -0000
@@ -1,10 +1,10 @@
# Author : Andr� P�nitz
-# This include files contains a label definitions for a report-like numbering.
+# This include file contains label definitions for a report-like numbering.
+
+Input numarticle.inc
Style Part
- LabelType Counter
- LabelCounter part
- LabelString "Part \Roman{part}"
+ TocLevel -1
End
@@ -13,42 +13,12 @@ Style Chapter
LabelCounter chapter
LabelString "Chapter \arabic{chapter}"
LabelStringAppendix "Appendix \Alph{chapter}"
- TocLevel 1
+ TocLevel 0
End
Style Section
- LabelType Counter
- LabelCounter section
LabelString "\arabic{chapter}.\arabic{section}"
LabelStringAppendix "\Alph{chapter}.\arabic{section}"
- TocLevel 2
-End
-
-
-Style Subsection
- LabelType Counter
- LabelCounter subsection
- LabelString "@[EMAIL PROTECTED]"
- LabelStringAppendix "@[EMAIL PROTECTED]"
- TocLevel 3
-End
-
-
-Style Subsubsection
- LabelType Counter
- LabelCounter subsubsection
- LabelString "@[EMAIL PROTECTED]"
- LabelStringAppendix "@[EMAIL PROTECTED]"
- TocLevel 4
-End
-
-
-Style Paragraph
- TocLevel 5
End
-
-Style Subparagraph
- TocLevel 6
-End
Index: lib/layouts/scrclass.inc
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/layouts/scrclass.inc,v
retrieving revision 1.11
diff -u -p -r1.11 scrclass.inc
--- lib/layouts/scrclass.inc 13 Oct 2003 09:50:10 -0000 1.11
+++ lib/layouts/scrclass.inc 14 Apr 2005 14:42:34 -0000
@@ -109,14 +109,12 @@ End
Style Addchap
CopyStyle Chapter*
LatexName addchap
- TocLevel 1
End
Style Addsec
CopyStyle Section*
LatexName addsec
- TocLevel 2
End
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2155
diff -u -p -r1.2155 ChangeLog
--- src/ChangeLog 14 Apr 2005 10:19:37 -0000 1.2155
+++ src/ChangeLog 14 Apr 2005 14:42:35 -0000
@@ -1,3 +1,20 @@
+2005-04-14 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * lyxfunc.C (actOnUpdatedPrefs): avoid warning
+ (dispatch): update counters and screen after LFUN_TEXTCLASS_APPLY.
+
+ * rowpainter.C (paintFirst): simplify the code a little bit. In
+ particular, remove the test for secnumdepth.
+ * text.C (setHeightOfRow): only allocate space for chapter number
+ when updateCounters provided an actual label, instead of looking
+ at secnumdepth directly.
+
+ * lyxlayout.C (LyXLayout): set toclevel to -2 by default.
+
+ * buffer_funcs.C (setCounter): only number LABEL_COUNTER
+ paragraphs when secnumdepth is large enough or, for environments,
+ when they are not the first in a sequence.
+
2005-04-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
* text3.C (dispatch): change the layout to "Caption" after inserting
Index: src/buffer_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.C,v
retrieving revision 1.24
diff -u -p -r1.24 buffer_funcs.C
--- src/buffer_funcs.C 25 Feb 2005 11:55:31 -0000 1.24
+++ src/buffer_funcs.C 14 Apr 2005 14:42:35 -0000
@@ -26,6 +26,7 @@
#include "LaTeX.h"
#include "lyxtextclass.h"
#include "paragraph.h"
+#include "paragraph_funcs.h"
#include "ParagraphList_fwd.h"
#include "ParagraphParameters.h"
#include "pariterator.h"
@@ -377,9 +378,14 @@ void setCounter(Buffer const & buf, ParI
// is it a layout that has an automatic label?
if (layout->labeltype == LABEL_COUNTER) {
- counters.step(layout->counter);
- string label = expandLabel(textclass, layout, par.params().appendix());
- par.params().labelString(label);
+ if (layout->toclevel <= buf.params().secnumdepth
+ && (!layout->isEnvironment()
+ || isFirstInSequence(it.pit(), it.plist()))) {
+ counters.step(layout->counter);
+ string label = expandLabel(textclass, layout,
+ par.params().appendix());
+ par.params().labelString(label);
+ }
} else if (layout->labeltype == LABEL_ITEMIZE) {
// At some point of time we should do something more
// clever here, like:
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.651
diff -u -p -r1.651 lyxfunc.C
--- src/lyxfunc.C 13 Apr 2005 09:43:56 -0000 1.651
+++ src/lyxfunc.C 14 Apr 2005 14:42:35 -0000
@@ -1474,6 +1474,8 @@ void LyXFunc::dispatch(FuncRequest const
bufferErrors(*buffer, el);
view()->showErrorList(_("Class switch"));
+ updateCounters(*buffer);
+ update = true;
break;
}
@@ -1971,6 +1973,7 @@ void actOnUpdatedPrefs(LyXRC const & lyx
case LyXRC::RC_SPELL_COMMAND:
case LyXRC::RC_TEMPDIRPATH:
case LyXRC::RC_TEMPLATEPATH:
+ case LyXRC::RC_TEX_ALLOWS_SPACES:
case LyXRC::RC_UIFILE:
case LyXRC::RC_USER_EMAIL:
case LyXRC::RC_USER_NAME:
Index: src/lyxlayout.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlayout.C,v
retrieving revision 1.25
diff -u -p -r1.25 lyxlayout.C
--- src/lyxlayout.C 6 Jan 2005 13:48:07 -0000 1.25
+++ src/lyxlayout.C 14 Apr 2005 14:42:35 -0000
@@ -121,7 +121,7 @@ LyXLayout::LyXLayout ()
free_spacing = false;
pass_thru = false;
is_environment = false;
- toclevel = 0;
+ toclevel = -2;
commanddepth = 0;
}
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.146
diff -u -p -r1.146 rowpainter.C
--- src/rowpainter.C 12 Apr 2005 18:42:27 -0000 1.146
+++ src/rowpainter.C 14 Apr 2005 14:42:35 -0000
@@ -501,37 +501,35 @@ void RowPainter::paintFirst()
|| layout->latextype != LATEX_ENVIRONMENT
|| is_seq)) {
- LyXFont font = getLabelFont();
- if (!par_.getLabelstring().empty()) {
+ LyXFont const font = getLabelFont();
+ string const str = par_.getLabelstring();
+ if (!str.empty()) {
double x = x_;
- string const str = par_.getLabelstring();
// this is special code for the chapter layout. This is
// printed in an extra row and has a pagebreak at
// the top.
if (layout->counter == "chapter") {
- if (buffer.params().secnumdepth >= 0) {
- double spacing_val = 1.0;
- if (!parparams.spacing().isDefault()) {
- spacing_val = parparams.spacing().getValue();
- } else {
- spacing_val = buffer.params().spacing().getValue();
- }
+ double spacing_val = 1.0;
+ if (!parparams.spacing().isDefault()) {
+ spacing_val = parparams.spacing().getValue();
+ } else {
+ spacing_val = buffer.params().spacing().getValue();
+ }
#ifdef WITH_WARNINGS
#warning Look is this correct?
#endif
- int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
-
- int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
- + int(layout->parsep) * defaultRowHeight();
+ int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
- if (is_rtl) {
- x = width_ - leftMargin() -
- font_metrics::width(str, font);
- }
+ int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
+ + int(layout->parsep) * defaultRowHeight();
- pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
+ if (is_rtl) {
+ x = width_ - leftMargin() -
+ font_metrics::width(str, font);
}
+
+ pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
} else {
if (is_rtl) {
x = width_ - leftMargin()
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.597
diff -u -p -r1.597 text.C
--- src/text.C 12 Apr 2005 18:42:25 -0000 1.597
+++ src/text.C 14 Apr 2005 14:42:35 -0000
@@ -911,12 +911,13 @@ void LyXText::setHeightOfRow(pit_type co
maxasc += bufparams.getDefSkip().inPixels(*bv());
}
- if (pars_[pit].params().startOfAppendix())
+ if (par.params().startOfAppendix())
maxasc += int(3 * dh);
// This is special code for the chapter, since the label of this
// layout is printed in an extra row
- if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) {
+ if (layout->counter == "chapter"
+ && !par.params().labelString().empty()) {
labeladdon = int(font_metrics::maxHeight(labelfont)
* layout->spacing.getValue()
* spacing(par));
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.472
diff -u -p -r1.472 ChangeLog
--- src/frontends/controllers/ChangeLog 13 Apr 2005 09:43:57 -0000 1.472
+++ src/frontends/controllers/ChangeLog 14 Apr 2005 14:42:35 -0000
@@ -1,8 +1,13 @@
+2005-04-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * ControlDocument.C (dispatchParams): update the counters if
+ necessary.
+
2005-04-13 Georg Baum <[EMAIL PROTECTED]>
* Dialog.[Ch] (checkStatus): new
-2005-03-27 MArtin Vermeer <[EMAIL PROTECTED]>
+2005-03-27 Martin Vermeer <[EMAIL PROTECTED]>
* ControlDocument.C (dispatch_bufferparams): fix bug 1843
Index: src/frontends/controllers/ControlDocument.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlDocument.C,v
retrieving revision 1.54
diff -u -p -r1.54 ControlDocument.C
--- src/frontends/controllers/ControlDocument.C 27 Mar 2005 07:14:12 -0000 1.54
+++ src/frontends/controllers/ControlDocument.C 14 Apr 2005 14:42:35 -0000
@@ -16,6 +16,8 @@
#include "BranchList.h"
#include "buffer.h"
#include "bufferparams.h"
+#include "BufferView.h"
+#include "buffer_funcs.h"
#include "funcrequest.h"
#include "language.h"
#include "LColor.h"
@@ -89,14 +91,22 @@ void ControlDocument::dispatchParams()
textclass_type const old_class =
kernel().buffer().params().textclass;
textclass_type const new_class = bp_->textclass;
-
if (new_class != old_class) {
string const name = textclasslist[new_class].name();
kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
}
+ int const old_secnumdepth = kernel().buffer().params().secnumdepth;
+ int const new_secnumdepth = bp_->secnumdepth;
+
// Apply the BufferParams.
dispatch_bufferparams(kernel(), params(), LFUN_BUFFERPARAMS_APPLY);
+
+ // redo the numbering if necessary
+ if (new_secnumdepth != old_secnumdepth) {
+ updateCounters(kernel().buffer());
+ kernel().bufferview()->update();
+ }
// Generate the colours requested by each new branch.
BranchList & branchlist = params().branchlist();
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1128
diff -u -p -r1.1128 ChangeLog
--- src/insets/ChangeLog 14 Apr 2005 10:19:38 -0000 1.1128
+++ src/insets/ChangeLog 14 Apr 2005 14:42:36 -0000
@@ -1,3 +1,10 @@
+2005-04-14 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
+
+ * insetwrap.C (addToToc): copy the code from InsetFloat::addToToc.
+
+ * insetfloat.C (addToToc): do not use the harcoded "Caption" name,
+ but the SENSITIVE label type.
+
2005-04-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
* insetfloat.C (InsetFloat):
Index: src/insets/insetfloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloat.C,v
retrieving revision 1.136
diff -u -p -r1.136 insetfloat.C
--- src/insets/insetfloat.C 14 Apr 2005 10:19:39 -0000 1.136
+++ src/insets/insetfloat.C 14 Apr 2005 14:42:36 -0000
@@ -114,10 +114,6 @@ using std::ostringstream;
namespace {
-// this should not be hardcoded, but be part of the definition
-// of the float (JMarc)
-string const caplayout("Caption");
-
string floatname(string const & type, BufferParams const & bp)
{
FloatList const & floats = bp.getLyXTextClass().floats();
@@ -421,7 +417,7 @@ void InsetFloat::addToToc(lyx::toc::TocL
// Find a caption layout in one of the (child inset's) pars
for (; pit != end; ++pit) {
- if (pit->layout()->name() == caplayout) {
+ if (pit->layout()->labeltype == LABEL_SENSITIVE) {
string const name = floatname(params_.type, buf.params());
string const str =
convert<string>(toclist[name].size() + 1)
Index: src/insets/insetwrap.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetwrap.C,v
retrieving revision 1.73
diff -u -p -r1.73 insetwrap.C
--- src/insets/insetwrap.C 14 Apr 2005 10:19:39 -0000 1.73
+++ src/insets/insetwrap.C 14 Apr 2005 14:42:36 -0000
@@ -27,6 +27,7 @@
#include "lyxlex.h"
#include "outputparams.h"
#include "paragraph.h"
+#include "pariterator.h"
#include "support/convert.h"
@@ -42,10 +43,6 @@ using std::ostringstream;
namespace {
-// this should not be hardcoded, but be part of the definition
-// of the float (JMarc)
-string const caplayout("Caption");
-
string floatname(string const & type, BufferParams const & bp)
{
FloatList const & floats = bp.getLyXTextClass().floats();
@@ -224,17 +221,17 @@ bool InsetWrap::showInsetDialog(BufferVi
void InsetWrap::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
{
- // Now find the caption in the float...
- ParagraphList::const_iterator tmp = paragraphs().begin();
- ParagraphList::const_iterator end = paragraphs().end();
+ ParConstIterator pit = par_const_iterator_begin(*this);
+ ParConstIterator end = par_const_iterator_end(*this);
- for (; tmp != end; ++tmp) {
- if (tmp->layout()->name() == caplayout) {
+ // Find a caption layout in one of the (child inset's) pars
+ for (; pit != end; ++pit) {
+ if (pit->layout()->labeltype == LABEL_SENSITIVE) {
string const name = floatname(params_.type, buf.params());
string const str =
convert<string>(toclist[name].size() + 1)
- + ". " + tmp->asString(buf, false);
- lyx::toc::TocItem const item(tmp->id(), 0 , str);
+ + ". " + pit->asString(buf, false);
+ lyx::toc::TocItem const item(pit->id(), 0 , str);
toclist[name].push_back(item);
}
}