From 0b1b6dfa4ed99f2b7c2a36cb56dcbb9d5553ac33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 17 Jul 2000 18:27:53 +0000 Subject: [PATCH] more changes...read the Changelog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@891 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 50 ++++++++++++ src/Makefile.am | 4 + src/Sectioning.C | 52 +++++++++++++ src/Sectioning.h | 58 ++++++++++++++ src/counters.C | 140 ++++++++++++++++++++++++++++++++++ src/counters.h | 66 ++++++++++++++++ src/insets/Makefile.am | 4 + src/insets/inset.C | 4 +- src/insets/insetcaption.C | 17 +++++ src/insets/insetcaption.h | 30 ++++++++ src/insets/insetcollapsable.C | 26 +++---- src/insets/insetfloat.C | 18 +++-- src/insets/insetfootlike.C | 2 +- src/insets/insetinfo.C | 51 +++++++------ src/insets/insetinfo.h | 2 + src/insets/insetquotes.C | 2 +- src/insets/insetquotes.h | 3 +- src/insets/insetsection.C | 17 +++++ src/insets/insetsection.h | 33 ++++++++ src/insets/lyxinset.h | 2 +- src/layout.h | 4 +- src/lyxparagraph.h | 1 + src/lyxtext.h | 8 +- src/mathed/formula.C | 3 + src/mathed/formula.h | 3 +- src/paragraph.C | 20 +++++ src/text2.C | 15 ++-- 27 files changed, 571 insertions(+), 64 deletions(-) create mode 100644 src/Sectioning.C create mode 100644 src/Sectioning.h create mode 100644 src/counters.C create mode 100644 src/counters.h create mode 100644 src/insets/insetcaption.C create mode 100644 src/insets/insetcaption.h create mode 100644 src/insets/insetsection.C create mode 100644 src/insets/insetsection.h diff --git a/ChangeLog b/ChangeLog index 17cb7d9423..491d8990d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2000-07-17 Lars Gullik Bjønnes + + * src/mathed/formula.h (ConvertFont): constify + + * src/mathed/formula.C (Read): add warning if \end_inset is not + found on expected place. + + * src/insets/lyxinset.h (ConvertFont): consify + + * src/insets/insetquotes.C (ConvertFont): constify + * src/insets/insetquotes.h: ditto + + * src/insets/insetinfo.h: add labelfont + + * src/insets/insetinfo.C (InsetInfo): set the labelfont + (ascent): use labelfont + (descent): likewise + (width): likewise + (draw): likewise + (Write): make .lyx file a bit nicer + + * src/insets/insetfloat.C (Write): simplify somewhat... + (Read): add warning if arg is not found + + * src/insets/insetcollapsable.C: add using std::max + (Read): move string token and add warning in arg is not found + (draw): use std::max to get the right ty + (getMaxWidth): simplify by using std::max + + * src/insets/insetsection.h: new file + * src/insets/insetsection.C: new file + * src/insets/insetcaption.h: new file + * src/insets/insetcaption.C: new file + + * src/insets/inset.C (ConvertFont): constify signature + + * src/insets/Makefile.am (libinsets_la_SOURCES): add + insetcaption.[Ch] and insetsection.[Ch] + + * src/layout.h: remove LABEL_FIRST_COUNTER from enum, change all + uses to use LABEL_COUNTER_CHAPTER instead. + * src/text2.C (SetCounter): here + + * src/counters.h: new file + * src/counters.C: new file + * src/Sectioning.h: new file + * src/Sectioning.C: new file + + * src/Makefile.am (lyx_SOURCES): add Sectioning.[hC] and counters.[Ch] + 2000-07-17 Jean-Marc Lasgouttes * lib/Makefile.am (listerrors): build-listerrors is in ${srcdir}, diff --git a/src/Makefile.am b/src/Makefile.am index 59b6fef0b2..6324609fb3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,6 +63,8 @@ lyx_SOURCES = \ PaperLayout.C \ ParagraphExtra.C \ PrinterParams.h \ + Sectioning.h \ + Sectioning.C \ Spacing.C \ Spacing.h \ TableLayout.C \ @@ -97,6 +99,8 @@ lyx_SOURCES = \ combox.h \ commandtags.h \ config.h.in \ + counters.C \ + counters.h \ credits.C \ credits.h \ credits_form.C \ diff --git a/src/Sectioning.C b/src/Sectioning.C new file mode 100644 index 0000000000..f14bb3b236 --- /dev/null +++ b/src/Sectioning.C @@ -0,0 +1,52 @@ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Sectioning.h" + +string const & Section::name() const +{ + return name_; +} + + +int Section::level() const +{ + return level_; +} + + +string const & Section::indent() const +{ + return indent_; +} + + +string const & Section::beforeskip() const +{ + return beforeskip_; +} + + +string const & Section::afterskip() const +{ + return afterskip_; +} + + +LyXFont const & Section::style() const +{ + return style_; +} + + +bool Section::display() const +{ + // If afterskip is negative it is a display section. + if (!afterskip_.empty() && afterskip_[0] == '-') + return false; + return true; +} diff --git a/src/Sectioning.h b/src/Sectioning.h new file mode 100644 index 0000000000..ca1dd134b0 --- /dev/null +++ b/src/Sectioning.h @@ -0,0 +1,58 @@ +// -*- C++ -*- + +#ifndef SECTIONING_H +#define SECTIONING_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include + +#include "LString.h" +#include "lyxfont.h" + +/// +class Section { +public: + /// + string const & name() const; + /// + int level() const; + /// + string const & indent() const; + /// + string const & beforeskip() const; + /// + string const & afterskip() const; + /// + LyXFont const & style() const; + /// + bool display() const; +private: + /// + string name_; + /// + int level_; + /// + string indent_; + /// + string beforeskip_; + /// + string afterskip_; + /// + LyXFont style_; +}; + + +/// +class SectioningList { +public: +private: + /// + typedef std::map List_; + /// + List_ list_; +}; + +#endif diff --git a/src/counters.C b/src/counters.C new file mode 100644 index 0000000000..2a72bf99f4 --- /dev/null +++ b/src/counters.C @@ -0,0 +1,140 @@ +#include + +#include "counters.h" +#include "debug.h" + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Connection; +using SigC::slot; +#endif + +using std::endl; + + +Counter::Counter() +{ + reset(); +} + + +void Counter::set(int v) +{ + value_ = v; +} + + +void Counter::addto(int v) +{ + value_ += v; +} + + +int Counter::value() const +{ + return value_; +} + + +void Counter::step() +{ + ++value_; + onstep.emit(); +} + + +void Counter::reset() +{ + value_ = 0; +} + + +Counters::~Counters() +{ + // We need this since we store the Counter's as pointers in + // the counterList. + for (CounterList::iterator it = counterList.begin(); + it != counterList.end(); + ++it) + delete (*it).second; +} + + +void Counters::newCounter(string const & newc) +{ + // First check if newc already exist + CounterList::const_iterator cit = counterList.find(newc); + // if alrady exist give warning and return + if (cit != counterList.end()) { + lyxerr << "The new counter already exist." << endl; + return; + } + counterList[newc] = new Counter; +} + + +void Counters::newCounter(string const & newc, string const & oldc) +{ + // First check if newc already exist + CounterList::const_iterator cit = counterList.find(newc); + // if already existant give warning and return + if (cit != counterList.end()) { + lyxerr << "The new counter already exist." << endl; + return; + } + // then check if oldc exist + CounterList::iterator it = counterList.find(oldc); + // if not give warning and return + if (it == counterList.end()) { + lyxerr << "The old counter does not exist." << endl; + return; + } + + Counter * tmp = new Counter; + (*it).second->onstep.connect(slot(tmp, + &Counter::reset)); + counterList[newc] = tmp; +} + + +void Counters::set(string const & ctr, int val) +{ + CounterList::iterator it = counterList.find(ctr); + if (it == counterList.end()) { + lyxerr << "Counter does not exist." << endl; + return; + } + (*it).second->set(val); +} + + +void Counters::addto(string const & ctr, int val) +{ + CounterList::iterator it = counterList.find(ctr); + if (it == counterList.end()) { + lyxerr << "Counter does not exist." << endl; + return; + } + (*it).second->addto(val); +} + + +int Counters::value(string const & ctr) const +{ + CounterList::const_iterator cit = counterList.find(ctr); + if (cit == counterList.end()) { + lyxerr << "Counter does not exist." << endl; + return 0; + } + return (*cit).second->value(); +} + + +void Counters::step(string const & ctr) +{ + CounterList::iterator it = counterList.find(ctr); + if (it == counterList.end()) { + lyxerr << "Counter does not exist." << endl; + return; + } + (*it).second->step(); +} diff --git a/src/counters.h b/src/counters.h new file mode 100644 index 0000000000..19014cc6fc --- /dev/null +++ b/src/counters.h @@ -0,0 +1,66 @@ +// -*- C++ -*- + +#ifndef COUNTERS_H +#define COUTNERS_H + +#include +#include +#include "LString.h" + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Object; +using SigC::Signal0; +#endif + + +/// +class Counter : public Object { +public: + /// + Counter(); + /// + void set(int v); + /// + void addto(int v); + /// + int value() const; + /// + void step(); + /// + void reset(); + /// + Signal0 onstep; +private: + /// + int value_; +}; + + +/** This is a class of (La)TeX type counters. The counters is in a text + Style and can be reset by signals emitted from a single counter. +*/ +class Counters { +public: + /// + ~Counters(); + /// + void newCounter(string const & newc); + /// + void newCounter(string const & newc, string const & oldc); + /// + void set(string const & ctr, int val); + /// + void addto(string const & ctr, int val); + /// + int value(string const & ctr) const; + /// + void step(string const & ctr); + // string refstep(string const & cou); +private: + /// + typedef std::map CounterList; + /// + CounterList counterList; +}; + +#endif diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index dcfca79d1c..0449bcb4d7 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -21,6 +21,8 @@ libinsets_la_SOURCES = \ insetbib.h \ insetbutton.C \ insetbutton.h \ + insetcaption.C \ + insetcaption.h \ insetcite.C \ insetcite.h \ insetcollapsable.C \ @@ -69,6 +71,8 @@ libinsets_la_SOURCES = \ insetquotes.h \ insetref.C \ insetref.h \ + insetsection.h \ + insetsection.C \ insetspecialchar.C \ insetspecialchar.h \ insettabular.C \ diff --git a/src/insets/inset.C b/src/insets/inset.C index 37abd2a4dd..333c1a6b2c 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -58,9 +58,9 @@ void Inset::Edit(BufferView *, int, int, unsigned int) } -LyXFont Inset::ConvertFont(LyXFont font) +LyXFont Inset::ConvertFont(LyXFont const & font) const { - return font; + return LyXFont(font); } diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C new file mode 100644 index 0000000000..8d89efaad5 --- /dev/null +++ b/src/insets/insetcaption.C @@ -0,0 +1,17 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "insetcaption.h" diff --git a/src/insets/insetcaption.h b/src/insets/insetcaption.h new file mode 100644 index 0000000000..328c7aa6c1 --- /dev/null +++ b/src/insets/insetcaption.h @@ -0,0 +1,30 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + *====================================================== + */ + + +#ifndef INSETCAPTION_H +#define INSETCAPTION_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "insettext.h" + +/** A caption inset +*/ +class InsetCaption : public InsetText { +public: +protected: +private: +}; + +#endif diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 8e3b78f304..1f6f9a0a5e 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -29,6 +29,7 @@ class LyXText; using std::ostream; using std::endl; +using std::max; InsetCollapsable::InsetCollapsable() : UpdatableInset() @@ -81,14 +82,15 @@ void InsetCollapsable::Write(Buffer const * buf, ostream & os) const void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex) { - string token; - if (lex.IsOK()) { lex.next(); - token = lex.GetString(); + string token = lex.GetString(); if (token == "collapsed") { lex.next(); collapsed = lex.GetBool(); + } else { + lyxerr << "InsetCollapsable::Read: Missing collapsed!" + << endl; } } inset->Read(buf, lex); @@ -176,18 +178,16 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, if (!cleared && ((inset->need_update == InsetText::FULL) || (inset->need_update == InsetText::INIT) || (top_x!=int(x)) || (top_baseline!=baseline))) { - int w = owner()? width(bv, f) : pain.paperWidth(); - int h = ascent(bv,f) + descent(bv, f); - int tx = (needFullRow() && !owner())? 0:int(x); - int ty = baseline - ascent(bv,f); + int w = owner() ? width(bv, f) : pain.paperWidth(); + int h = ascent(bv, f) + descent(bv, f); + int tx = (needFullRow() && !owner()) ? 0 : int(x); + int ty = max(0, baseline - ascent(bv, f)); - if (ty < 0) - ty = 0; if ((ty + h) > pain.paperHeight()) h = pain.paperHeight(); if ((top_x + w) > pain.paperWidth()) w = pain.paperWidth(); - pain.fillRectangle(tx, ty-1, w, h+2); + pain.fillRectangle(tx, ty - 1, w, h + 2); cleared = true; } @@ -293,13 +293,11 @@ int InsetCollapsable::getMaxWidth(Painter & pain, int w = UpdatableInset::getMaxWidth(pain,inset); if (w < 0) { + // What does a negative max width signify? (Lgb) return w; } - w -= widthCollapsed; // should be at least 30 pixels !!! - if (w < 30) - w = 30; - return w; // - top_x - widthCollapsed; + return max(30, w - widthCollapsed); } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index e0809a3b37..55eccaa7bc 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -99,12 +99,15 @@ InsetFloat::InsetFloat(string const & type) void InsetFloat::Write(Buffer const * buf, ostream & os) const { os << getInsetName() - << " " << floatType - << "\nplacement "; - if (floatPlacement.empty()) - os << floatList.getType(floatType).placement << "\n"; - else - os << floatPlacement << "\n"; + << " " << floatType << '\n'; + + if (floatPlacement.empty()) { + os << "placement " + << floatList.getType(floatType).placement << "\n"; + } else { + os << "placement " << floatPlacement << "\n"; + } + InsetCollapsable::Write(buf, os); } @@ -117,6 +120,9 @@ void InsetFloat::Read(Buffer const * buf, LyXLex & lex) if (token == "placement") { lex.next(); floatPlacement = lex.GetString(); + } else { + lyxerr << "InsetFloat::Read: Missing placement!" + << endl; } } InsetCollapsable::Read(buf, lex); diff --git a/src/insets/insetfootlike.C b/src/insets/insetfootlike.C index 527dc644c6..20b28ad568 100644 --- a/src/insets/insetfootlike.C +++ b/src/insets/insetfootlike.C @@ -3,7 +3,7 @@ * * LyX, The Document Processor * - * Copyright 1998 The LyX Team. + * Copyright 2000 The LyX Team. * * ====================================================== */ diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 1f4e68e7b4..445bb65c0f 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -35,13 +35,19 @@ extern BufferView * current_view; InsetInfo::InsetInfo() - : form(0) -{} + : form(0), labelfont(LyXFont::ALL_SANE) +{ + labelfont.decSize().decSize() + .setColor(LColor::note).setLatex(LyXFont::OFF); +} InsetInfo::InsetInfo(string const & str) - : contents(str), form(0) -{} + : contents(str), form(0), labelfont(LyXFont::ALL_SANE) +{ + labelfont.decSize().decSize() + .setColor(LColor::note).setLatex(LyXFont::OFF); +} InsetInfo::~InsetInfo() @@ -54,52 +60,53 @@ InsetInfo::~InsetInfo() } -int InsetInfo::ascent(BufferView *, LyXFont const & font) const +int InsetInfo::ascent(BufferView *, LyXFont const &) const { - return lyxfont::maxAscent(font) + 1; + return lyxfont::maxAscent(labelfont) + 1; } -int InsetInfo::descent(BufferView *, LyXFont const & font) const +int InsetInfo::descent(BufferView *, LyXFont const &) const { - return lyxfont::maxDescent(font) + 1; + return lyxfont::maxDescent(labelfont) + 1; } -int InsetInfo::width(BufferView *, LyXFont const & font) const +int InsetInfo::width(BufferView *, LyXFont const &) const { - return 6 + lyxfont::width(_("Note"), font); + return 6 + lyxfont::width(_("Note"), labelfont); } -void InsetInfo::draw(BufferView * bv, LyXFont const & f, +void InsetInfo::draw(BufferView * bv, LyXFont const &, int baseline, float & x, bool) const { Painter & pain = bv->painter(); +#if 0 LyXFont font(f); - /* Info-insets are never LaTeX, so just correct the font */ + // Info-insets are never LaTeX, so just correct the font font.setLatex(LyXFont::OFF).setColor(LColor::note); - +#endif // Draw as "Note" in a yellow box x += 1; - pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1, - width(bv, font) - 2, - ascent(bv, font) + descent(bv, font) - 2, + pain.fillRectangle(int(x), baseline - ascent(bv, labelfont), + width(bv, labelfont) - 2, + ascent(bv, labelfont) + descent(bv, labelfont) - 2, LColor::notebg); - pain.rectangle(int(x), baseline - ascent(bv, font) + 1, - width(bv, font) - 2, - ascent(bv, font) + descent(bv, font) - 2, + pain.rectangle(int(x), baseline - ascent(bv, labelfont), + width(bv, labelfont) - 2, + ascent(bv, labelfont) + descent(bv, labelfont) - 2, LColor::noteframe); - pain.text(int(x + 2), baseline, _("Note"), font); - x += width(bv, font) - 1; + pain.text(int(x + 2), baseline, _("Note"), labelfont); + x += width(bv, labelfont) - 1; } void InsetInfo::Write(Buffer const *, ostream & os) const { - os << "Info " << contents; + os << "Info\n" << contents; } diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index 8b01e35455..01894676d6 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -77,5 +77,7 @@ private: FL_FORM * form; /// FL_OBJECT * strobj; + /// + LyXFont labelfont; }; #endif diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index e8e5bde31a..8c9bd55521 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -190,7 +190,7 @@ int InsetQuotes::width(BufferView *, LyXFont const & font) const //LyXFont InsetQuotes::ConvertFont(LyXFont font) // I really belive this should be -LyXFont InsetQuotes::ConvertFont(LyXFont const & f) +LyXFont InsetQuotes::ConvertFont(LyXFont const & f) const { LyXFont font(f); // quotes-insets cannot be latex of any kind diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index de07412d66..f19a7b7792 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -80,7 +80,7 @@ public: /// void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// - LyXFont ConvertFont(LyXFont const & font); + LyXFont ConvertFont(LyXFont const & font) const; //LyXFont ConvertFont(LyXFont font); /// void Write(Buffer const *, std::ostream &) const; @@ -119,3 +119,4 @@ private: string DispString() const; }; #endif + diff --git a/src/insets/insetsection.C b/src/insets/insetsection.C new file mode 100644 index 0000000000..27ba035e7c --- /dev/null +++ b/src/insets/insetsection.C @@ -0,0 +1,17 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "insetsection.h" diff --git a/src/insets/insetsection.h b/src/insets/insetsection.h new file mode 100644 index 0000000000..2c97a328d4 --- /dev/null +++ b/src/insets/insetsection.h @@ -0,0 +1,33 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + *====================================================== + */ + + +#ifndef INSETSECTION_H +#define INSETSECTION_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "LString.h" + +#include "insettext.h" + +/** A colapsable text inset +*/ +class InsetSection : public InsetText { +public: +protected: +private: + string type_; +}; + +#endif diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index ba66d0f74b..792756a862 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -130,7 +130,7 @@ public: virtual void update(BufferView *, LyXFont const &, bool = false) {} /// - virtual LyXFont ConvertFont(LyXFont font); + virtual LyXFont ConvertFont(LyXFont const & font) const; /// what appears in the minibuffer when opening virtual const char * EditMessage() const; /// diff --git a/src/layout.h b/src/layout.h index 5aa994442e..779cfa1624 100644 --- a/src/layout.h +++ b/src/layout.h @@ -140,9 +140,7 @@ enum LYX_LABEL_TYPES { /// LABEL_COUNTER_ENUMIII, /// - LABEL_COUNTER_ENUMIV, - /// - LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER + LABEL_COUNTER_ENUMIV }; enum LYX_END_LABEL_TYPES { diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 4d509179f3..69793b8516 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -271,6 +271,7 @@ public: bool noindent; private: + /// block counter_; public: /// diff --git a/src/lyxtext.h b/src/lyxtext.h index 0988122595..7d14d14a6c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -70,9 +70,6 @@ public: /// InsetText * inset_owner; - /// - // void owner(BufferView *); - /// LyXFont GetFont(Buffer const *, LyXParagraph * par, LyXParagraph::size_type pos) const; @@ -270,7 +267,8 @@ public: /// void SetCursorFromCoordinates(BufferView *, int x, long y) const; - void SetCursorFromCoordinates(BufferView *, LyXCursor &, int x, long y) const; + void SetCursorFromCoordinates(BufferView *, LyXCursor &, + int x, long y) const; /// void CursorUp(BufferView *) const; /// @@ -501,8 +499,6 @@ public: /// int workWidth(BufferView *) const; /// - // Buffer * buffer() const; - /// void ComputeBidiTables(Buffer const *, Row * row) const; /// Maps positions in the visual string to positions in logical string. diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 267a00452c..b00ea87361 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -370,11 +370,14 @@ void InsetFormula::Read(Buffer const *, LyXLex & lex) label = mathed_label; mathed_label = 0; } + // reading of end_inset in the inset!!! while (lex.IsOK()) { lex.nextToken(); if (lex.GetString() == "\\end_inset") break; + lyxerr << "InsetFormula::Read: Garbage before \\end_inset," + " or missing \\end_inset!" << endl; } #ifdef DEBUG diff --git a/src/mathed/formula.h b/src/mathed/formula.h index fa9412e33f..d8ac350492 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -68,8 +68,9 @@ public: /// Inset::Code LyxCode() const { return Inset::MATH_CODE; } /// - LyXFont ConvertFont(LyXFont font) { + LyXFont ConvertFont(LyXFont const & f) const { // We have already discussed what was here + LyXFont font(f); font.setLatex(LyXFont::OFF); return font; } diff --git a/src/paragraph.C b/src/paragraph.C index b6c10aca02..bb5634e54e 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -88,6 +88,16 @@ LyXParagraph::LyXParagraph() id_ = paragraph_id++; bibkey = 0; // ale970302 Clear(); +#if 0 + // Insert the main counters + // Should later (asap) be moved to layout files + counters.newCounter("part"); + counters.newCounter("section"); + counters.newCounter("subsection", "section"); + counters.newCounter("subsubsection", "subsection"); + counters.newCounter("paragraph", "subsubsection"); + counters.newCounter("subparagraph", "paragraph"); +#endif } @@ -123,6 +133,16 @@ LyXParagraph::LyXParagraph(LyXParagraph * par) bibkey = 0; // ale970302 Clear(); +#if 0 + // Insert the main counters + // Should later (asap) be moved to layout files + counters.newCounter("part"); + counters.newCounter("section"); + counters.newCounter("subsection", "section"); + counters.newCounter("subsubsection", "subsection"); + counters.newCounter("paragraph", "subsubsection"); + counters.newCounter("subparagraph", "paragraph"); +#endif } diff --git a/src/text2.C b/src/text2.C index 8fb50ea6e8..45172be79a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1698,9 +1698,9 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const } /* is it a layout that has an automatic label ? */ - if (layout.labeltype >= LABEL_FIRST_COUNTER) { + if (layout.labeltype >= LABEL_COUNTER_CHAPTER) { - int i = layout.labeltype - LABEL_FIRST_COUNTER; + int i = layout.labeltype - LABEL_COUNTER_CHAPTER; if (i >= 0 && i<= buf->params.secnumdepth) { par->incCounter(i); // increment the counter @@ -1723,7 +1723,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const ostrstream s; #endif if (!par->appendix) { - switch (2 * LABEL_FIRST_COUNTER - + switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) { case LABEL_COUNTER_CHAPTER: s << par->getCounter(i); @@ -1761,11 +1761,14 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const break; default: + // Can this ever be reached? And in the + // case it is, how can this be correct? + // (Lgb) s << par->getCounter(i) << '.'; break; } } else { // appendix - switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) { + switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) { case LABEL_COUNTER_CHAPTER: if (par->isRightToLeftPar(buf->params)) s << hebrewCounter(par->getCounter(i)); @@ -1836,7 +1839,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const // Can this ever be reached? And in the // case it is, how can this be correct? // (Lgb) - s << static_cast(par->getCounter(i)) << '.'; + s << par->getCounter(i) << '.'; break; } @@ -1917,7 +1920,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const } } else if (layout.labeltype == LABEL_BIBLIO) {// ale970302 - int i = LABEL_COUNTER_ENUMI - LABEL_FIRST_COUNTER + par->enumdepth; + int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth; par->incCounter(i); int number = par->getCounter(i); if (!par->bibkey) -- 2.39.2