+2002-09-06 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * layouts/stdcounters.inc: new file
+
+ * layouts/stdclass.inc: include standard counters
+
2002-09-05 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2bitmap.sh: augment the preliminary blurb, as
Input lyxmacros.inc
Input stdlayouts.inc
Input stdfloats.inc
+Input stdcounters.inc
Input obsolete.inc
--- /dev/null
+# Author : Lars Gullik Bjønnes <larsbj@lyx.org>
+
+# This include file contains all the counters that are defined as standard
+# in most LyX layouts.
+
+
+Counter
+ Name part
+End
+
+Counter
+ Name chapter
+End
+
+Counter
+ Name section
+ Within chapter
+End
+
+Counter
+ Name subsection
+ Within section
+End
+
+Counter
+ Name subsubsection
+ Within subsection
+End
+
+Counter
+ Name paragraph
+ Within subsubsection
+End
+
+Counter
+ Name subparagraph
+ Within paragraph
+End
+
+Counter
+ Name enumi
+End
+
+Counter
+ Name enumii
+ Within enumi
+End
+
+Counter
+ Name enumiii
+ Within enumii
+End
+
+Counter
+ Name enumiv
+ Within enumiii
+End
+
+Counter
+ Name bibitem
+End
+
+Counter
+ Name figure
+End
+
+Counter
+ Name table
+End
+
+Counter
+ Name algorithm
+End
+2002-09-06 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * text2.C (init): update counters after init
+ (insertParagraph): no need to set counter on idividual paragraphs.
+ (setCounter): access the counters object in the textclass object
+ on in the buffer object.
+ (updateCounters): ditto
+
+ * lyxtextclass.C: include counters.h, add variable ctrs_ as
+ shared_ptr<Counters> to avoid loading counters.h in all
+ compilation units.
+ (LyXTextClass): initialize ctrs_
+ (TextClassTags): add TC_COUNTER, and ...
+ (Read): use it here.
+ (CounterTags): new tags
+ (readCounter): new function
+ (counters): new funtion
+ (defaultLayoutName): return a const reference
+
+ * counters.C (Counters): remove contructor
+ (newCounter): remove a couple of unneeded statements.
+ (newCounter): simplify a bit.
+ (numberLabel): some small formatting changes.
+
+ * buffer.[Ch]: remove all traces of counters, move the Counters
+ object to the LyXTextClass.
+
2002-09-06 Alain Castera <castera@in2p3.fr>
- * tabular.C: uses \tabularnewline; uses >{...} construct from array
+ * tabular.C: uses \tabularnewline; uses >{...} construct from array
package to set the horizontal alignment on fixed width columns.
- * lyx_sty.C:
+ * lyx_sty.C:
* lyx_sty.h: added tabularnewline macro def.
- * LaTeXFeatures.C: added NeedTabularnewline macro feature
+ * LaTeXFeatures.C: added NeedTabularnewline macro feature
2002-09-06 John Levon <levon@movementarian.org>
* LyXAction.C: tooltips for sub/superscript
* MenuBackend.C: a bit more verbose
-
+
* lyxfunc.C: tiny clean
- * undo_funcs.C: document undo_frozen
-
+ * undo_funcs.C: document undo_frozen
+
2002-09-05 Lars Gullik Bjønnes <larsbj@gullik.net>
* counters.C (Counters): add missing algorithm counter.
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
- * lyxtextclass.C (TextClassTags): add TC_FLOAT
+ * lyxtextclass.C (TextClassTags): add TC_FLOAT
(Read): add float->TC_FLOAT to textclassTags
(Read): and handle it in the switch
(readFloat): new function
#include "buffer.h"
#include "bufferlist.h"
-#include "counters.h"
#include "LyXAction.h"
#include "lyxrc.h"
#include "lyxlex.h"
Buffer::Buffer(string const & file, bool ronly)
: niceFile(true), lyx_clean(true), bak_clean(true),
unnamed(false), dep_clean(0), read_only(ronly),
- filename_(file), users(0), ctrs(new Counters)
+ filename_(file), users(0)
{
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
filepath_ = OnlyPath(file);
"Use LyX 0.10.x to read this!"));
return false;
} else {
- string command =
+ string command =
LibFileSearch("lyx2lyx", "lyx2lyx");
if (command.empty()) {
Alert::alert(_("ERROR!"),
if (!keys.empty())
return keys;
-
+
// Might be either using bibtex or a child has bibliography
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
}
-Counters & Buffer::counters() const
-{
- return *ctrs.get();
-}
-
-
void Buffer::inset_iterator::setParagraph()
{
while (pit != pend) {
#include "ParagraphList.h"
#include "paragraph.h"
-#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
class BufferView;
-class Counters;
class LyXRC;
class TeXErrors;
class LaTeXFeatures;
/// Used when typesetting to place errorboxes.
TexRow texrow;
- /// Buffer-wide counter array
- Counters & counters() const;
-
private:
/// is save needed
mutable bool lyx_clean;
of the buffers in the list of users to do a #updateLayoutChoice#.
*/
BufferView * users;
-
- /// The pointer is const although its contents may not be
- boost::scoped_ptr<Counters> const ctrs;
-
public:
///
class inset_iterator {
#include "counters.h"
#include "debug.h"
+
#include "support/lstrings.h"
#include "support/LAssert.h"
value_ = 0;
}
+
string Counter::master() const
{
return master_;
}
+
void Counter::setMaster(string const & m)
{
master_ = m;
}
-Counters::Counters()
-{
- // Ehh, should this take a textclass arg?
-
- // Sectioning counters:
- newCounter("part");
- newCounter("chapter");
- newCounter("section", "chapter");
- newCounter("subsection", "section");
- newCounter("subsubsection", "subsection");
- newCounter("paragraph", "subsubsection");
- newCounter("subparagraph", "paragraph");
-
- // Enumeration counters:
- newCounter("enumi");
- newCounter("enumii", "enumi");
- newCounter("enumiii", "enumii");
- newCounter("enumiv", "enumiii");
-
- // Biblio:
- newCounter("bibitem");
-
- // Float counters:
- newCounter("figure");
- newCounter("table");
- newCounter("algorithm");
-}
-
void Counters::newCounter(string const & newc)
{
return;
}
counterList[newc];
- cit = counterList.find(newc);
- cit->second.setMaster("");
}
return;
}
- counterList[newc];
- cit = counterList.find(newc);
- cit->second.setMaster(masterc);
+ counterList[newc].setMaster(masterc);
}
}
} else if (numbertype == "enumeration") {
- ostringstream ei, eii, eiii, eiv;
- //string ei, eiii, eiv;
- //char eii;
+ ostringstream ei;
+ ostringstream eii;
+ ostringstream eiii;
+ ostringstream eiv;
+
if (langtype == "hebrew") {
ei << '.' << value("enumi");
eii << '(' << hebrewCounter(value("enumii")) << ')';
/// Every instantiation is an array of counters of type Counter.
class Counters {
public:
- ///
- Counters();
- ///
- //~Counters();
/// Add a new counter to array.
void newCounter(string const & newc);
/// Add new counter having oldc as its master.
#include "lyxtextclass.h"
#include "debug.h"
#include "lyxlex.h"
+#include "counters.h"
#include "support/lstrings.h"
#include "support/LAssert.h"
LyXTextClass::LyXTextClass(string const & fn, string const & cln,
string const & desc)
- : name_(fn), latexname_(cln), description_(desc)
+ : name_(fn), latexname_(cln), description_(desc), ctrs_(new Counters)
{
outputType_ = LATEX;
columns_ = 1;
TC_PROVIDESURL,
TC_LEFTMARGIN,
TC_RIGHTMARGIN,
- TC_FLOAT
+ TC_FLOAT,
+ TC_COUNTER
};
keyword_item textClassTags[] = {
{ "classoptions", TC_CLASSOPTIONS },
{ "columns", TC_COLUMNS },
+ { "counter", TC_COUNTER },
{ "defaultfont", TC_DEFAULTFONT },
{ "defaultstyle", TC_DEFAULTSTYLE },
{ "float", TC_FLOAT },
<< MakeDisplayPath(filename)
<< endl;
- LyXLex lexrc(textClassTags, TC_FLOAT);
+ LyXLex lexrc(textClassTags, TC_COUNTER);
bool error = false;
lexrc.setFile(filename);
case TC_FLOAT:
readFloat(lexrc);
break;
+ case TC_COUNTER:
+ readCounter(lexrc);
+ break;
}
}
}
+enum CounterTags {
+ CT_NAME = 1,
+ CT_WITHIN,
+ CT_END
+};
+
+void LyXTextClass::readCounter(LyXLex & lexrc)
+{
+ keyword_item counterTags[] = {
+ { "end", CT_END },
+ { "name", CT_NAME },
+ { "within", CT_WITHIN }
+ };
+
+ lexrc.pushTable(counterTags, CT_END);
+
+ string name;
+ string within;
+
+ bool getout = false;
+ while (!getout && lexrc.isOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown ClassOption tag `$$Token'");
+ continue;
+ default: break;
+ }
+ switch (static_cast<CounterTags>(le)) {
+ case CT_NAME:
+ lexrc.next();
+ name = lexrc.getString();
+ break;
+ case CT_WITHIN:
+ lexrc.next();
+ within = lexrc.getString();
+ if (within == "none")
+ within.erase();
+ break;
+ case CT_END:
+ getout = true;
+ break;
+ }
+ }
+
+ // Here if have a full float if getout == true
+ if (getout) {
+ if (within.empty()) {
+ ctrs_->newCounter(name);
+ } else {
+ ctrs_->newCounter(name, within);
+ }
+ }
+
+ lexrc.popTable();
+}
+
+
LyXFont const & LyXTextClass::defaultfont() const
{
return defaultfont_;
}
-string const LyXTextClass::defaultLayoutName() const
+Counters & LyXTextClass::counters() const
+{
+ return *ctrs_.get();
+}
+
+
+string const & LyXTextClass::defaultLayoutName() const
{
// This really should come from the actual layout... (Lgb)
return defaultlayout_;
#include "support/types.h"
+#include <boost/shared_ptr.hpp>
+
#include <vector>
class LyXLex;
+class Counters;
///
class LyXTextClass {
typedef LayoutList::const_iterator const_iterator;
///
explicit
- LyXTextClass (string const & = string(),
- string const & = string(),
- string const & = string());
+ LyXTextClass(string const & = string(),
+ string const & = string(),
+ string const & = string());
///
const_iterator begin() const { return layoutlist_.begin(); }
///
void readFloat(LyXLex &);
///
+ void readCounter(LyXLex &);
+ ///
bool hasLayout(string const & name) const;
///
FloatList & floats();
/// the list of floats defined in the class
FloatList const & floats() const;
-
+ /// The Counters present in this textclass.
+ Counters & counters() const;
///
- string const defaultLayoutName() const;
+ string const & defaultLayoutName() const;
///
LyXLayout_ptr const & defaultLayout() const;
///
///
FloatList floatlist_;
+ ///
+ boost::shared_ptr<Counters> ctrs_;
+
/// Has this layout file been loaded yet?
mutable bool loaded;
};
#include "debug.h"
#include "lyxlex.h"
#include "gettext.h"
-
#include "frontends/Alert.h"
#include "support/lyxfunctional.h"
}
setCursorIntern(bview, firstrow->par(), 0);
selection.cursor = cursor;
+
+ updateCounters(bview);
}
// insert a new row, starting at position 0
insertRow(row, par, 0);
- // set the counters
- setCounter(bview->buffer(), par);
-
// and now append the whole paragraph behind the new row
if (!row) {
firstrow->height(0);
par->params().appendix(par->previous()->params().appendix());
if (!par->params().appendix() && par->params().startOfAppendix()) {
par->params().appendix(true);
- buf->counters().reset();
+ textclass.counters().reset();
}
par->enumdepth = par->previous()->enumdepth;
par->itemdepth = par->previous()->itemdepth;
if (i >= 0 && i <= buf->params.secnumdepth) {
- buf->counters().step(layout->latexname());
+ textclass.counters().step(layout->latexname());
// Is there a label? Useful for Chapter layout
if (!par->params().appendix()) {
langtype = "latin";
}
- s << buf->counters()
+ s << textclass.counters()
.numberLabel(layout->latexname(),
numbertype, langtype, head);
// possible...
// reset enum counters
- buf->counters().reset("enum");
+ textclass.counters().reset("enum");
} else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
- buf->counters().reset("enum");
+ textclass.counters().reset("enum");
} else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
// FIXME
// Yes I know this is a really, really! bad solution
break;
}
- buf->counters().step(enumcounter);
+ textclass.counters().step(enumcounter);
- s << buf->counters()
+ s << textclass.counters()
.numberLabel(enumcounter,
"enumeration", langtype);
par->params().labelString(s.str().c_str());
}
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
- buf->counters().step("bibitem");
- int number = buf->counters().value("bibitem");
+ textclass.counters().step("bibitem");
+ int number = textclass.counters().value("bibitem");
if (!par->bibkey) {
InsetCommandParams p("bibitem");
par->bibkey = new InsetBibKey(p);
Floating const & fl
= textclass.floats().getType(static_cast<InsetFloat*>(in)->type());
- buf->counters().step(fl.type());
+ textclass.counters().step(fl.type());
// Doesn't work... yet.
ostringstream o;
}
par->params().labelString(s);
- // reset the enumeration counter. They are always resetted
+ // reset the enumeration counter. They are always reset
// when there is any other layout between
+ // Just fall-through between the cases so that all
+ // enum counters deeper than enumdepth is also reset.
switch (par->enumdepth) {
case 0:
- buf->counters().reset("enumi");
+ textclass.counters().reset("enumi");
case 1:
- buf->counters().reset("enumii");
+ textclass.counters().reset("enumii");
case 2:
- buf->counters().reset("enumiii");
+ textclass.counters().reset("enumiii");
case 3:
- buf->counters().reset("enumiv");
+ textclass.counters().reset("enumiv");
}
}
}
Row * row = firstrow;
par = row->par();
- bview->buffer()->counters().reset();
+ // CHECK if this is really needed. (Lgb)
+ bview->buffer()->params.getLyXTextClass().counters().reset();
+
while (par) {
while (row->par() != par)
row = row->next();