From 49436e4c2d1ab7ce1a5f6aafdd743793a11ab843 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 12 Jan 2011 22:53:41 +0000 Subject: [PATCH] Add NoCounter layout tag. When working on output of equation numbers, I noticed that article, for example, still has a counter "chapter". This surprised me. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37193 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/layout2layout.py | 7 +++++-- src/Counters.cpp | 6 ++++++ src/Counters.h | 2 ++ src/TextClass.cpp | 12 +++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 89866d2b7e..e27b1da1d6 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -107,6 +107,9 @@ import os, re, string, sys # Incremented to format 30, 13 August 2010 by rgh # Introduced ResetsFont tag for InsetLayout. +# Incremented to format 31, 12 January 2011 by rgh +# Introducted NoCounter tag. + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -114,7 +117,7 @@ import os, re, string, sys # development/tools/updatelayouts.sh script to update all # layout files to the new format. -currentFormat = 30 +currentFormat = 31 def usage(prog_name): @@ -290,7 +293,7 @@ def convert(lines): continue # Only new features - if format == 29: + if format == 29 or format == 30: i += 1 continue diff --git a/src/Counters.cpp b/src/Counters.cpp index d0bb56faf6..1e865c73d4 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -294,6 +294,12 @@ void Counters::reset(docstring const & match) } +bool Counters::remove(docstring const & cnt) +{ + return counterList_.erase(cnt); +} + + void Counters::copy(Counters & from, Counters & to, docstring const & match) { CounterList::iterator it = counterList_.begin(); diff --git a/src/Counters.h b/src/Counters.h index 59570fba33..41b80e6076 100644 --- a/src/Counters.h +++ b/src/Counters.h @@ -132,6 +132,8 @@ public: void reset(); /// Reset counters matched by match string. void reset(docstring const & match); + /// Remove counter \p cnt. + bool remove(docstring const & cnt); /// Copy counters whose name matches match from the &from to /// the &to array of counters. Empty string matches all. void copy(Counters & from, Counters & to, diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 3506afa15d..a43ad9edf9 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -60,7 +60,7 @@ namespace lyx { // development/updatelayouts.sh script, to update the format of // all of our layout files. // -int const LAYOUT_FORMAT = 30; +int const LAYOUT_FORMAT = 31; namespace { @@ -196,6 +196,7 @@ enum TextClassTags { TC_RIGHTMARGIN, TC_FLOAT, TC_COUNTER, + TC_NOCOUNTER, TC_IFCOUNTER, TC_NOFLOAT, TC_TITLELATEXNAME, @@ -233,6 +234,7 @@ namespace { { "input", TC_INPUT }, { "insetlayout", TC_INSETLAYOUT }, { "leftmargin", TC_LEFTMARGIN }, + { "nocounter", TC_NOCOUNTER }, { "nofloat", TC_NOFLOAT }, { "nostyle", TC_NOSTYLE }, { "outputformat", TC_OUTPUTFORMAT }, @@ -652,6 +654,14 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) readCiteFormat(lexrc); break; + case TC_NOCOUNTER: + if (lexrc.next()) { + docstring const cnt = lexrc.getDocString(); + if (!counters_.remove(cnt)) + LYXERR0("Unable to remove counter: " + to_utf8(cnt)); + } + break; + case TC_IFCOUNTER: ifcounter = true; case TC_COUNTER: