From cd694827a934423effc364d82408709d02adb02b Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 4 Aug 2000 13:12:30 +0000 Subject: [PATCH] Another clean-up patch from Angus git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@953 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 53 ++++++++++++++++++ INSTALL | 3 +- src/LyXAction.C | 2 +- src/buffer.C | 63 +++++++++++---------- src/commandtags.h | 2 +- src/frontends/xforms/FormCitation.C | 14 +---- src/frontends/xforms/FormCitation.h | 24 +++++--- src/frontends/xforms/FormIndex.C | 24 +++----- src/frontends/xforms/FormToc.C | 17 +----- src/frontends/xforms/FormToc.h | 3 + src/frontends/xforms/FormUrl.C | 26 +++------ src/insets/insetbib.C | 26 ++++----- src/insets/insetbib.h | 35 +++--------- src/insets/insetcite.h | 3 +- src/insets/insetcommand.C | 82 +++++++++++++-------------- src/insets/insetcommand.h | 48 ++++++++-------- src/insets/insetinclude.C | 8 +-- src/insets/insetinclude.h | 9 +-- src/insets/insetindex.h | 5 +- src/insets/insetlabel.C | 13 +---- src/insets/insetlabel.h | 17 ++---- src/insets/insetparent.C | 9 +-- src/insets/insetparent.h | 27 ++++----- src/insets/insetref.C | 30 ++++------ src/insets/insetref.h | 29 ++-------- src/insets/insettoc.h | 3 +- src/insets/inseturl.h | 3 +- src/lyx_cb.C | 25 ++++----- src/lyxfunc.C | 87 +++++++++++++++++------------ src/menus.C | 12 ++-- src/paragraph.C | 6 +- src/support/strerror.c | 4 +- src/texrow.C | 4 +- src/text2.C | 6 +- 34 files changed, 347 insertions(+), 375 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70ee015ac4..2b9624a4ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,56 @@ +2000-08-04 Jean-Marc Lasgouttes + + * src/support/strerror.c: remove C++ comment. + +2000-08-04 Angus Leeming + + * src/commandtags.h: LFUN_INDEX_CREATE_LAST reverts to + LFUN_INDEX_INSERT_LAST + + * src/texrow.C (getIdFromRow): changed from const_iterator to + iterator, allowing code to compile with DEC cxx + + * src/frontends/xforms/FormCitation.[Ch]: made vector + stores part of the class, as suggested by Allan. Will allow + multiple LyXViews. + (apply): test to apply uses InsetCommandParams operator!= + + * src/frontends/xforms/FormIndex.C: moved set_minsize into build + (apply): test to apply uses InsetCommandParams operator!= + + * src/frontends/xforms/FormToc.[Ch]: made vector + stores part of the class. + (update): removed limits on min/max size. + + * src/frontends/xforms/FormUrl.C: moved set_minsize into build + (apply): test to apply uses InsetCommandParams operator!= + + * src/insets/insetcommand.[Ch] InsetCommand made noncopyable + (Read, Write, scanCommand, getCommand): moved functionality + into InsetCommandParams. + (Clone): removed + (getScreenLabel): made pure virtual + new InsetCommandParams operators== and != + + * src/insets/insetbib.[Ch] (InsetBibKey, InsetBibtex): new + c-tors based on InsetCommandParams. Removed others. + * src/insets/insetinclude.[Ch]: ditto + * src/insets/insetlabel.[Ch]: ditto + * src/insets/insetparent.[Ch]: ditto + * src/insets/insetref.[Ch]: ditto. Also moved gotoLabel into .C + + * src/buffer.C (parseSingleLyXformat2Token, readInset): all + insets derived from InsetCommand created using similar c-tors + based on InsetCommandParams + * src/lyx_cb.C (MenuInsertLabel, RefSelectCB): ditto + * src/menus.C (ShowRefsMenu): ditto + * src/paragraph.C (Clone): ditto + * src/text2.C (SetCounter): ditto + * src/lyxfunc.C (Dispatch) ditto + Also recreated old InsetIndex behaviour exactly. Can now + index-insert at the start of a paragraph and index-insert-last + without launching the pop-up. + 2000-08-03 Lars Gullik Bjønnes * lib/lyxrc.example: mark te pdf options as non functional. diff --git a/INSTALL b/INSTALL index 302f09a807..d506060d49 100644 --- a/INSTALL +++ b/INSTALL @@ -275,7 +275,8 @@ Preparing a binary distribution for the use of others in some private place and running it. In particular, check the output of `ldd lyx' to know which libraries are really needed. - o Upload your binary file to ftp.lyx.org:/pub/lyx/uploads. + o Upload your binary file to ftp.devel.lyx.org:/pub/incoming, and + notify larsbj@lyx.org. Problems diff --git a/src/LyXAction.C b/src/LyXAction.C index 6c52cc6923..0a80b37246 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -249,7 +249,7 @@ void LyXAction::init() N_("Insert hyphenation point"), Noop }, { LFUN_INDEX_CREATE, "index-insert", N_("Insert index item"), Noop }, - { LFUN_INDEX_CREATE_LAST, "index-insert-last", + { LFUN_INDEX_INSERT_LAST, "index-insert-last", N_("Insert last index item"), Noop }, { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"), Noop }, diff --git a/src/buffer.C b/src/buffer.C index 9284be47bd..3efdd06779 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -489,7 +489,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, if (pp.first) { params.textclass = pp.second; } else { - lex.printError("Unknown textclass `$$Token'"); + lex.printError("Unknown textclass `$$Token'"); params.textclass = 0; } if (!textclasslist.Load(params.textclass)) { @@ -889,7 +889,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertInset(pos, inset, font); ++pos; } else if (tmptok == "Include") { - Inset * inset = new InsetInclude(string(), this); + InsetCommandParams p( "Include" ); + Inset * inset = new InsetInclude(p, this); inset->Read(this, lex); par->InsertInset(pos, inset, font); ++pos; @@ -951,25 +952,25 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertInset(pos, inset, font); ++pos; } else if (tmptok == "LatexCommand") { - InsetCommand inscmd; - inscmd.Read(this, lex); + InsetCommandParams inscmd; + inscmd.Read(lex); Inset * inset = 0; if (inscmd.getCmdName() == "cite") { - inset = new InsetCitation(inscmd.params()); + inset = new InsetCitation(inscmd); } else if (inscmd.getCmdName() == "bibitem") { lex.printError("Wrong place for bibitem"); - inset = inscmd.Clone(); + inset = new InsetBibKey(inscmd); } else if (inscmd.getCmdName() == "BibTeX") { - inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this); + inset = new InsetBibtex(inscmd, this); } else if (inscmd.getCmdName() == "index") { - inset = new InsetIndex(inscmd.params()); + inset = new InsetIndex(inscmd); } else if (inscmd.getCmdName() == "include") { - inset = new InsetInclude(inscmd.getContents(), this); + inset = new InsetInclude(inscmd, this); } else if (inscmd.getCmdName() == "label") { - inset = new InsetLabel(inscmd.getCommand()); + inset = new InsetLabel(inscmd); } else if (inscmd.getCmdName() == "url" || inscmd.getCmdName() == "htmlurl") { - inset = new InsetUrl(inscmd.params()); + inset = new InsetUrl(inscmd); } else if (inscmd.getCmdName() == "ref" || inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "vref" @@ -982,11 +983,11 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, || inscmd.getCmdName() == "listofalgorithms" || inscmd.getCmdName() == "listoffigures" || inscmd.getCmdName() == "listoftables") { - inset = new InsetTOC(inscmd.params()); + inset = new InsetTOC(inscmd); } else if (inscmd.getCmdName() == "printindex") { - inset = new InsetPrintIndex(inscmd.params()); + inset = new InsetPrintIndex(inscmd); } else if (inscmd.getCmdName() == "lyxparent") { - inset = new InsetParent(inscmd.getContents(), this); + inset = new InsetParent(inscmd, this); } if (inset) { @@ -1054,8 +1055,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } ++pos; } else if (token == "\\bibitem") { // ale970302 - if (!par->bibkey) - par->bibkey = new InsetBibKey; + if (!par->bibkey) { + InsetCommandParams p( "bibitem" ); + par->bibkey = new InsetBibKey(p); + } par->bibkey->Read(this, lex); }else if (token == "\\backslash") { par->InsertChar(pos, '\\', font); @@ -1120,7 +1123,8 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, par->InsertInset(pos, inset, font); ++pos; } else if (tmptok == "Include") { - Inset * inset = new InsetInclude(string(), this); + InsetCommandParams p( "Include" ); + Inset * inset = new InsetInclude(p, this); inset->Read(this, lex); par->InsertInset(pos, inset, font); ++pos; @@ -1181,26 +1185,25 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, //inset->Read(this, lex); par->InsertInset(pos, inset, font); } else if (tmptok == "LatexCommand") { - InsetCommand inscmd; - inscmd.Read(this, lex); + InsetCommandParams inscmd; + inscmd.Read(lex); Inset * inset = 0; if (inscmd.getCmdName() == "cite") { - inset = new InsetCitation(inscmd.params()); + inset = new InsetCitation(inscmd); } else if (inscmd.getCmdName() == "bibitem") { lex.printError("Wrong place for bibitem"); - inset = inscmd.Clone(); + inset = new InsetBibKey(inscmd); } else if (inscmd.getCmdName() == "BibTeX") { - inset = new InsetBibtex(inscmd.getContents(), - inscmd.getOptions(), this); + inset = new InsetBibtex(inscmd, this); } else if (inscmd.getCmdName() == "index") { - inset = new InsetIndex(inscmd.params()); + inset = new InsetIndex(inscmd); } else if (inscmd.getCmdName() == "include") { - inset = new InsetInclude(inscmd.getContents(), this); + inset = new InsetInclude(inscmd, this); } else if (inscmd.getCmdName() == "label") { - inset = new InsetLabel(inscmd.getCommand()); + inset = new InsetLabel(inscmd); } else if (inscmd.getCmdName() == "url" || inscmd.getCmdName() == "htmlurl") { - inset = new InsetUrl(inscmd.params()); + inset = new InsetUrl(inscmd); } else if (inscmd.getCmdName() == "ref" || inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "vref" @@ -1214,11 +1217,11 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, || inscmd.getCmdName() == "listofalgorithms" || inscmd.getCmdName() == "listoffigures" || inscmd.getCmdName() == "listoftables") { - inset = new InsetTOC(inscmd.params()); + inset = new InsetTOC(inscmd); } else if (inscmd.getCmdName() == "printindex") { - inset = new InsetPrintIndex(inscmd.params()); + inset = new InsetPrintIndex(inscmd); } else if (inscmd.getCmdName() == "lyxparent") { - inset = new InsetParent(inscmd.getContents(), this); + inset = new InsetParent(inscmd, this); } if (inset) { diff --git a/src/commandtags.h b/src/commandtags.h index 902f2ab7f9..1789a476c7 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -199,7 +199,7 @@ enum kb_action { LFUN_CITATION_INSERT, // AAS 97-02-23 LFUN_INSERT_BIBTEX, // AAS 97-02-23 LFUN_INDEX_CREATE, // Lgb 97-02-27 - LFUN_INDEX_CREATE_LAST, // 180 // Reh 98-09-17 + LFUN_INDEX_INSERT_LAST, // 180 // Reh 98-09-17 LFUN_INDEX_PRINT, // Lgb 97-02-27 LFUN_APROPOS, // Asger 1997-02-27 LFUN_LATEX_LOG, // Lgb 97-04-05 diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index df45cd020c..731e14e17e 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -35,10 +35,6 @@ using std::max; using std::min; using std::find; -static vector citekeys; -static vector bibkeys; -static vector bibkeysInfo; - FormCitation::FormCitation(LyXView * lv, Dialogs * d) : FormCommand(lv, d, _("Citation")), dialog_(0) { @@ -73,7 +69,7 @@ void FormCitation::build() FL_FORM * const FormCitation::form() const { - if( dialog_ && dialog_->form_citation ) + if( dialog_ ) // no need to test for dialog_->citation return dialog_->form_citation; else return 0; @@ -102,8 +98,6 @@ void FormCitation::update() keys = frontStrip( split(keys, tmp, ',') ); } - fl_freeze_form( dialog_->form_citation ); - updateBrowser( dialog_->bibBrsr, bibkeys ); updateBrowser( dialog_->citeBrsr, citekeys ); fl_clear_browser( dialog_->infoBrsr ); @@ -123,8 +117,6 @@ void FormCitation::update() setSize( size, bibPresent ); fl_set_input( dialog_->textAftr, params.getOptions().c_str() ); - - fl_unfreeze_form( dialog_->form_citation ); } @@ -417,9 +409,7 @@ void FormCitation::apply() if( inset_ != 0 ) { // Only update if contents have changed - if( params.getCmdName() != inset_->getCmdName() || - params.getContents() != inset_->getContents() || - params.getOptions() != inset_->getOptions() ) { + if( params != inset_->params() ) { inset_->setParams( params ); lv_->view()->updateInset( inset_, true ); } diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index cf542c1703..f6e222d8e8 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -23,6 +23,15 @@ struct FD_form_citation; */ class FormCitation : public FormCommand { public: + /**@name Constructors and Destructors */ + //@{ + /// + FormCitation(LyXView *, Dialogs *); + /// + ~FormCitation(); + //@} + +private: /// enum State { DOWN, @@ -34,15 +43,6 @@ public: ON, OFF }; - /**@name Constructors and Destructors */ - //@{ - /// #FormCitation x(LyXFunc ..., Dialogs ...);# - FormCitation(LyXView *, Dialogs *); - /// - ~FormCitation(); - //@} - -private: /// Build the dialog virtual void build(); /// Filter the inputs @@ -69,6 +69,12 @@ private: /// Real GUI implementation. FD_form_citation * dialog_; + /// + std::vector citekeys; + /// + std::vector bibkeys; + /// + std::vector bibkeysInfo; }; #endif diff --git a/src/frontends/xforms/FormIndex.C b/src/frontends/xforms/FormIndex.C index 528c3e7338..8a38f7eeb6 100644 --- a/src/frontends/xforms/FormIndex.C +++ b/src/frontends/xforms/FormIndex.C @@ -47,12 +47,18 @@ FormIndex::~FormIndex() void FormIndex::build() { dialog_ = build_index(); + + int w = form()->w; + int h = form()->h; + + fl_set_form_minsize(form(), w, h); + fl_set_form_maxsize(form(), 2*w, h); } FL_FORM * const FormIndex::form() const { - if( dialog_ && dialog_->form_index ) + if( dialog_ ) // no need to test for dialog_->form_index return dialog_->form_index; else return 0; @@ -61,18 +67,6 @@ FL_FORM * const FormIndex::form() const void FormIndex::update() { - static int ow = -1, oh; - - if (ow < 0) { - ow = dialog_->form_index->w; - oh = dialog_->form_index->h; - - fl_set_form_minsize(dialog_->form_index, ow, oh); - fl_set_form_maxsize(dialog_->form_index, 2*ow, oh); - } - - fl_freeze_form( dialog_->form_index ); - fl_set_input(dialog_->key, params.getContents().c_str()); if( lv_->buffer()->isReadonly() ) { @@ -84,8 +78,6 @@ void FormIndex::update() fl_activate_object( dialog_->ok ); fl_set_object_lcol( dialog_->ok, FL_BLACK ); } - - fl_unfreeze_form( dialog_->form_index ); } @@ -98,7 +90,7 @@ void FormIndex::apply() if( inset_ != 0 ) { // Only update if contents have changed - if( params.getContents() != inset_->getContents() ) { + if( params != inset_->params() ) { inset_->setParams( params ); lv_->view()->updateInset( inset_, true ); } diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index 9a24d2b7ce..07befefa14 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -23,12 +23,9 @@ #include "Dialogs.h" #include "FormToc.h" #include "LyXView.h" -#include "buffer.h" #include "form_toc.h" #include "lyxtext.h" -static vector toclist; - FormToc::FormToc(LyXView * lv, Dialogs * d) : FormCommand(lv, d, _("Table of Contents")), dialog_(0) { @@ -58,12 +55,14 @@ void FormToc::build() dialog_ = build_toc(); fl_addto_choice(dialog_->type, _(" TOC | LOF | LOT | LOA ")); + + // Don't need to limit size of this dialog } FL_FORM * const FormToc::form() const { - if( dialog_ && dialog_->form_toc ) + if( dialog_ ) // no need to test for dialog_->form_toc return dialog_->form_toc; else return 0; @@ -72,16 +71,6 @@ FL_FORM * const FormToc::form() const void FormToc::update() { - static int ow = -1, oh; - - if (ow < 0) { - ow = form()->w; - oh = form()->h; - - fl_set_form_minsize(form(), ow, oh); - fl_set_form_maxsize(form(), 2*ow, oh); - } - Buffer::TocType type; if( params.getCmdName() == "tableofcontents" ) diff --git a/src/frontends/xforms/FormToc.h b/src/frontends/xforms/FormToc.h index 6825b212c9..7872ce813a 100644 --- a/src/frontends/xforms/FormToc.h +++ b/src/frontends/xforms/FormToc.h @@ -17,6 +17,7 @@ #endif #include "FormCommand.h" +#include "buffer.h" struct FD_form_toc; /** This class provides an XForms implementation of the FormToc Dialog. @@ -50,6 +51,8 @@ private: /// Real GUI implementation. FD_form_toc * dialog_; + /// + std::vector toclist; }; #endif diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index d5a99291ff..8edfe11e16 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -47,12 +47,18 @@ FormUrl::~FormUrl() void FormUrl::build() { dialog_ = build_url(); + + int w = form()->w; + int h = form()->h; + + fl_set_form_minsize(form(), w, h); + fl_set_form_maxsize(form(), 2*w, h); } FL_FORM * const FormUrl::form() const { - if( dialog_ && dialog_->form_url ) + if( dialog_ ) // no need to test for dialog_->form_url return dialog_->form_url; else return 0; @@ -61,18 +67,6 @@ FL_FORM * const FormUrl::form() const void FormUrl::update() { - static int ow = -1, oh; - - if (ow < 0) { - ow = dialog_->form_url->w; - oh = dialog_->form_url->h; - - fl_set_form_minsize(dialog_->form_url, ow, oh); - fl_set_form_maxsize(dialog_->form_url, 2*ow, oh); - } - - fl_freeze_form( dialog_->form_url ); - fl_set_input(dialog_->url, params.getContents().c_str()); fl_set_input(dialog_->name, params.getOptions().c_str()); @@ -94,8 +88,6 @@ void FormUrl::update() fl_activate_object( dialog_->ok ); fl_set_object_lcol( dialog_->ok, FL_BLACK ); } - - fl_unfreeze_form( dialog_->form_url ); } @@ -114,9 +106,7 @@ void FormUrl::apply() if( inset_ != 0 ) { // Only update if contents have changed - if( params.getCmdName() != inset_->getCmdName() || - params.getContents() != inset_->getContents() || - params.getOptions() != inset_->getOptions() ) { + if( params != inset_->params() ) { inset_->setParams( params ); lv_->view()->updateInset( inset_, true ); } diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index a2647612a2..1f1dcfbf9a 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -72,19 +72,10 @@ FD_bibitem_form * create_form_bibitem_form(void) } -InsetBibKey::InsetBibKey(string const & key, string const & label) - : InsetCommand("bibitem", key, label) +InsetBibKey::InsetBibKey(InsetCommandParams const & p) + : InsetCommand(p) { counter = 1; - if (key.empty()) - setCmdName(" "); -} - - -InsetBibKey::InsetBibKey(InsetBibKey const * b) - : InsetCommand("bibitem", b->getContents(), b->getOptions()) -{ - counter = b->counter; } @@ -97,6 +88,14 @@ InsetBibKey::~InsetBibKey() } +Inset * InsetBibKey::Clone() const +{ + InsetBibKey * b = new InsetBibKey(params()); + b->setCounter(counter); + return b; +} + + void InsetBibKey::callback( FD_bibitem_form * form, long data ) { switch (data) { @@ -201,9 +200,8 @@ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int) } -InsetBibtex::InsetBibtex(string const & dbase, string const & style, - Buffer * o) - : InsetCommand("BibTeX", dbase, style), owner(o) +InsetBibtex::InsetBibtex(InsetCommandParams const & p, Buffer * o) + : InsetCommand(p), owner(o) {} diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index c886bbe6c6..58266516ab 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -16,8 +16,8 @@ #pragma interface #endif -#include "insetcommand.h" #include +#include "insetcommand.h" class Buffer; struct FD_bibitem_form; @@ -30,17 +30,11 @@ struct FD_bibitem_form; class InsetBibKey : public InsetCommand { public: /// - InsetBibKey() : InsetCommand("bibitem") { counter = 1; } - /// - explicit - InsetBibKey(string const & key, string const & label = string()); - /// - explicit - InsetBibKey(InsetBibKey const *); + InsetBibKey(InsetCommandParams const &); /// ~InsetBibKey(); /// - Inset * Clone() const { return new InsetBibKey(this); } + Inset * Clone() const; /** Currently \bibitem is used as a LyX2.x command, so we need this method. */ @@ -83,36 +77,25 @@ private: */ class InsetBibtex : public InsetCommand { public: - /// - InsetBibtex() : InsetCommand("BibTeX") { owner = 0; } /// - InsetBibtex(string const & dbase, string const & style, - Buffer *); + InsetBibtex(InsetCommandParams const &, Buffer *); /// ~InsetBibtex(); - - /// - Inset * Clone() const { - return new InsetBibtex(getContents(), getOptions(), owner); - } /// - Inset::Code LyxCode() const - { - return Inset::BIBTEX_CODE; - } + Inset * Clone() const { return new InsetBibtex(params(), owner); } /// string getScreenLabel() const; /// + EDITABLE Editable() const { return IS_EDITABLE; } + /// + Inset::Code LyxCode() const { return Inset::BIBTEX_CODE; } + /// void Edit(BufferView *, int x, int y, unsigned int button); /// int Latex(Buffer const *, std::ostream &, bool fragile, bool freespace) const; /// std::vector > getKeys() const; - /// - EDITABLE Editable() const { - return IS_EDITABLE; - } /// bool addDatabase(string const &); /// diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 7a766f577d..fc2487c41c 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -16,11 +16,10 @@ #endif #include "insetcommand.h" -#include "support/utility.hpp" /** Used to insert citations */ -class InsetCitation : public InsetCommand, public noncopyable { +class InsetCitation : public InsetCommand { public: /// InsetCitation(InsetCommandParams const &); diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 4beaec279c..6260da9615 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -59,38 +59,25 @@ void InsetCommandParams::setFromString( string const & b ) } -InsetCommand::InsetCommand() -{} - - -InsetCommand::InsetCommand( string const & n, - string const & c, - string const & o ) - : p_(n, c, o) -{} - - -InsetCommand::InsetCommand( InsetCommandParams const & p ) - : p_( p.getCmdName(), p.getContents(), p.getOptions() ) -{} - - -void InsetCommand::setParams(InsetCommandParams const & p ) +bool InsetCommandParams::operator==(InsetCommandParams const & o) const { - p_.setCmdName( p.getCmdName() ); - p_.setContents( p.getContents() ); - p_.setOptions( p.getOptions() ); + if( cmdname != o.cmdname ) return false; + if( contents != o.contents ) return false; + if( options != o.options ) return false; + return true; } -// In lyxf3 this will be just LaTeX -void InsetCommand::Write(Buffer const *, ostream & os) const +bool InsetCommandParams::operator!=(InsetCommandParams const & o) const { - os << "LatexCommand " << getCommand() << "\n"; + if( cmdname != o.cmdname ) return true; + if( contents != o.contents ) return true; + if( options != o.options ) return true; + return false; } -void InsetCommand::scanCommand(string const & cmd) +void InsetCommandParams::scanCommand(string const & cmd) { string tcmdname, toptions, tcontents; @@ -153,7 +140,7 @@ void InsetCommand::scanCommand(string const & cmd) // This function will not be necessary when lyx3 -void InsetCommand::Read(Buffer const *, LyXLex & lex) +void InsetCommandParams::Read(LyXLex & lex) { string token; @@ -175,6 +162,35 @@ void InsetCommand::Read(Buffer const *, LyXLex & lex) } +void InsetCommandParams::Write(ostream & os) const +{ + os << "LatexCommand " << getCommand() << "\n"; +} + + +string InsetCommandParams::getCommand() const +{ + string s; + if (!getCmdName().empty()) s += "\\"+getCmdName(); + if (!getOptions().empty()) s += "["+getOptions()+']'; + s += "{"+getContents()+'}'; + return s; +} + + +InsetCommand::InsetCommand( InsetCommandParams const & p ) + : p_( p.getCmdName(), p.getContents(), p.getOptions() ) +{} + + +void InsetCommand::setParams(InsetCommandParams const & p ) +{ + p_.setCmdName( p.getCmdName() ); + p_.setContents( p.getContents() ); + p_.setOptions( p.getOptions() ); +} + + int InsetCommand::Latex(Buffer const *, ostream & os, bool /*fragile*/, bool/*fs*/) const { @@ -199,19 +215,3 @@ int InsetCommand::DocBook(Buffer const *, ostream &) const { return 0; } - - -Inset * InsetCommand::Clone() const -{ - return new InsetCommand(getCmdName(), getContents(), getOptions()); -} - - -string InsetCommand::getCommand() const -{ - string s; - if (!getCmdName().empty()) s += "\\"+getCmdName(); - if (!getOptions().empty()) s += "["+getOptions()+']'; - s += "{"+getContents()+'}'; - return s; -} diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 81f58781c5..4fb9df7d97 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -18,6 +18,7 @@ #include "insetbutton.h" #include +#include "support/utility.hpp" #ifdef SIGC_CXX_NAMESPACES using SigC::Signal0; @@ -39,6 +40,18 @@ public: string const & c = string(), string const & o = string()); /// + bool operator==(InsetCommandParams const &) const; + /// + bool operator!=(InsetCommandParams const &) const; + /// + void Read(LyXLex &); + /// Parse the command + void scanCommand(string const &); + /// + void Write(std::ostream &) const; + /// Build the complete LaTeX command + string getCommand() const; + /// string const & getCmdName() const { return cmdname; } /// string const & getOptions() const { return options; } @@ -54,7 +67,6 @@ public: string getAsString() const; /// void setFromString( string const & ); - private: /// string cmdname; @@ -65,27 +77,20 @@ private: }; -class InsetCommand : public InsetButton { +class InsetCommand : public InsetButton, public noncopyable { public: - /// - InsetCommand(); - /// - explicit - InsetCommand(string const & n, - string const & c = string(), - string const & o = string()); - /// explicit InsetCommand(InsetCommandParams const &); /// virtual ~InsetCommand() { hide(); }; /// - void Write(Buffer const *, std::ostream &) const; - - /// Parse the command. - void scanCommand(string const & cmd); + void Write(Buffer const *, std::ostream & os) const + { p_.Write( os ); } /// - virtual void Read(Buffer const *, LyXLex & lex); + virtual void Read(Buffer const *, LyXLex & lex) + { p_.Read( lex ); } + /// Can remove one InsetBibKey is modified + void scanCommand(string const & c) { p_.scanCommand( c ); }; /// virtual int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; @@ -96,12 +101,7 @@ public: /// virtual int DocBook(Buffer const *, std::ostream &) const; /// - Inset * Clone() const; - /// - Inset::Code LyxCode() const - { - return Inset::NO_CODE; - } + Inset::Code LyxCode() const { return Inset::NO_CODE; } /** Get the label that appears at screen. @@ -109,9 +109,9 @@ public: confusion with lyxinset::getLabel(int), but I've seen that it wasn't. I hope you never confuse again both methods. (ale) */ - virtual string getScreenLabel() const { return getCommand(); } - /// Build the complete LaTeX command - string getCommand() const; + virtual string getScreenLabel() const = 0; + /// + string getCommand() const { return p_.getCommand(); } /// string const & getCmdName() const { return p_.getCmdName(); } /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 1bd6113480..bb2c28c854 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -210,11 +210,9 @@ static string unique_id() { } -InsetInclude::InsetInclude(string const & fname, Buffer * bf) - : InsetCommand("include") +InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer * bf) + : InsetCommand(p), master(bf) { - master = bf; - setContents(fname); flag = InsetInclude::INCLUDE; noload = false; include_label = unique_id(); @@ -240,7 +238,7 @@ InsetInclude::~InsetInclude() Inset * InsetInclude::Clone() const { - InsetInclude * ii = new InsetInclude (getContents(), master); + InsetInclude * ii = new InsetInclude (params(), master); ii->setNoLoad(isNoLoad()); // By default, the newly created inset is of `include' type, // so we do not test this case. diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 041e923cfe..ff6477c069 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -26,15 +26,8 @@ struct LaTeXFeatures; */ class InsetInclude: public InsetCommand { public: -#if 0 /// - InsetInclude(): InsetCommand("include") - { - flag = InsetInclude::INCLUDE; - } -#endif - /// - InsetInclude(string const &, Buffer *); + InsetInclude(InsetCommandParams const &, Buffer *); /// ~InsetInclude(); /// diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index b92853804f..92b6f57542 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -17,13 +17,12 @@ #endif #include "insetcommand.h" -#include "support/utility.hpp" struct LaTeXFeatures; /** Used to insert index labels */ -class InsetIndex : public InsetCommand, public noncopyable { +class InsetIndex : public InsetCommand { public: /// InsetIndex(InsetCommandParams const &); @@ -38,7 +37,7 @@ public: }; -class InsetPrintIndex : public InsetCommand, public noncopyable { +class InsetPrintIndex : public InsetCommand { public: /// InsetPrintIndex(InsetCommandParams const &); diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 0a8ca63951..2aa37e0efd 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -28,16 +28,9 @@ using std::pair; /* Label. Used to insert a label automatically */ -InsetLabel::InsetLabel(string const & cmd) -{ - scanCommand(cmd); -} - - -Inset * InsetLabel::Clone() const -{ - return new InsetLabel(getCommand()); -} +InsetLabel::InsetLabel(InsetCommandParams const & p) + : InsetCommand(p) +{} vector InsetLabel::getLabelList() const diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index 750a3508ad..39cc24e8e0 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -17,29 +17,24 @@ #endif #include "insetcommand.h" -#include "LString.h" -/// class InsetLabel : public InsetCommand { public: /// - explicit - InsetLabel(string const & cmd); + InsetLabel(InsetCommandParams const &); /// - InsetLabel() : InsetCommand("label") {} - /// - Inset * Clone() const; - /// - Inset::Code LyxCode() const { return Inset::LABEL_CODE; } - /// - std::vector getLabelList() const; + Inset * Clone() const { return new InsetLabel(params()); } /// string getScreenLabel() const { return getContents(); } /// EDITABLE Editable() const { return IS_EDITABLE; } /// + Inset::Code LyxCode() const { return Inset::LABEL_CODE; } + /// void Edit(BufferView *, int, int, unsigned int); /// + std::vector getLabelList() const; + /// int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; /// diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index fb65bdcb22..3672116110 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -28,11 +28,12 @@ using std::ostream; -InsetParent::InsetParent(string const & fn, Buffer * owner) - : InsetCommand("lyxparent") +InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf) + : InsetCommand(p) { - if (owner) - setContents(MakeAbsPath(fn, OnlyPath(owner->fileName()))); + string fn = p.getContents(); + if (bf) + setContents(MakeAbsPath(fn, OnlyPath(bf->fileName()))); else setContents(fn); } diff --git a/src/insets/insetparent.h b/src/insets/insetparent.h index 861ac9d2a6..0a1e982702 100644 --- a/src/insets/insetparent.h +++ b/src/insets/insetparent.h @@ -26,27 +26,22 @@ class Buffer; */ class InsetParent : public InsetCommand { public: - /// Non-standard LyX macro - InsetParent() : InsetCommand("lyxparent") {} /// - explicit - InsetParent(string const & fn, Buffer * owner = 0); + InsetParent(InsetCommandParams const &, Buffer * owner = 0); + /// + Inset * Clone() const { return new InsetParent(params()); } + /// + string getScreenLabel() const; + /// + EDITABLE Editable() const { return IS_EDITABLE; } + /// + Inset::Code LyxCode() const { return Inset::PARENT_CODE; } + /// + void Edit(BufferView *, int, int, unsigned int); /// int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; /// - Inset * Clone() const { return new InsetParent(getContents()); } - /// - string getScreenLabel() const; - /// - void Edit(BufferView *, int, int, unsigned int); - /// - EDITABLE Editable() const { - return IS_EDITABLE; - } - /// - Inset::Code LyxCode() const { return Inset::PARENT_CODE; } - /// void setParent(string fn) { setContents(fn); } }; #endif diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 6d1b80d781..72be4d27f0 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -23,24 +23,12 @@ using std::endl; extern BufferView * current_view; -InsetRef::InsetRef(string const & cmd, Buffer * bf) - : master(bf) +InsetRef::InsetRef(InsetCommandParams const & p, Buffer * bf) + : InsetCommand(p), master(bf) { - scanCommand(cmd); GenerateFlag(); } - -InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf) - : master(bf) -{ - setCmdName(inscmd.getCmdName()); - setContents(inscmd.getContents()); - setOptions(inscmd.getOptions()); - GenerateFlag(); -} - - void InsetRef::GenerateFlag() { if (getCmdName() == "ref") @@ -101,10 +89,8 @@ int InsetRef::Latex(Buffer const *, ostream & os, if(getOptions().empty()) os << escape(getCommand()); else { - string ns; - InsetCommand clone(getCmdName(), - getContents(), ns); - os << escape(clone.getCommand()); + InsetCommandParams p( getCmdName(), getContents(), "" ); + os << escape(p.getCommand()); } return 0; } @@ -168,3 +154,11 @@ void InsetRef::Validate(LaTeXFeatures & features) const break; } } + + +void InsetRef::gotoLabel() +{ + if (master) { + master->getUser()->gotoLabel(getContents()); + } +} diff --git a/src/insets/insetref.h b/src/insets/insetref.h index f000853828..994d3ad914 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -16,8 +16,8 @@ #endif #include "insetcommand.h" -#include "buffer.h" +class Buffer; struct LaTeXFeatures; /** The reference inset @@ -43,28 +43,20 @@ public: }; /// - InsetRef() : InsetCommand("ref") { flag = InsetRef::REF; } + InsetRef(InsetCommandParams const &, Buffer *); /// - InsetRef(string const &, Buffer *); + Inset * Clone() const { return new InsetRef(params(), master); } /// - InsetRef(InsetCommand const &, Buffer *); - /// - Inset * Clone() const { - return new InsetRef (getCommand(), master); - } + string getScreenLabel() const; + /// + EDITABLE Editable() const { return IS_EDITABLE; } /// Inset::Code LyxCode() const { return Inset::REF_CODE; } /// void Edit(BufferView *, int, int, unsigned int); - /// - EDITABLE Editable() const { - return IS_EDITABLE; - } /// bool display() const { return false; } /// - string getScreenLabel() const; - /// void Toggle(); /// void gotoLabel(); @@ -89,13 +81,4 @@ private: /// Buffer * master; }; - - -inline -void InsetRef::gotoLabel() -{ - if (master) { - master->getUser()->gotoLabel(getContents()); - } -} #endif diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index 4c6848c447..cf0de54519 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -17,11 +17,10 @@ #endif #include "insetcommand.h" -#include "support/utility.hpp" /** Used to insert table of contents */ -class InsetTOC : public InsetCommand, public noncopyable { +class InsetTOC : public InsetCommand { public: /// InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {} diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 6170b545df..30a7b2c49b 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -16,13 +16,12 @@ #endif #include "insetcommand.h" -#include "support/utility.hpp" struct LaTeXFeatures; /** The url inset */ -class InsetUrl : public InsetCommand, public noncopyable { +class InsetUrl : public InsetCommand { public: /// explicit diff --git a/src/lyx_cb.C b/src/lyx_cb.C index ed3430bea4..45d9c08fa8 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -1145,9 +1145,9 @@ void MenuInsertLabel(char const * arg) } } if (!label.empty()) { - InsetLabel * new_inset = new InsetLabel; - new_inset->setContents(label); - current_view->insertInset(new_inset); + InsetCommandParams p( "label", label ); + InsetLabel * inset = new InsetLabel( p ); + current_view->insertInset( inset ); } AllowInput(current_view); } @@ -2928,19 +2928,16 @@ extern "C" void RefSelectCB(FL_OBJECT *, long data) return; } - static string const commands[5] - = { "\\ref", "\\pageref", "\\vref", "\\vpageref", - "\\prettyref"}; - string t = commands[data]; - + static string const cmdname[5] + = { "ref", "pageref", "vref", "vpageref", "prettyref"}; + InsetCommandParams p( cmdname[data] ); + p.setContents( s ); + if (current_view->buffer()->isSGML()) - t += "[" + u + "]" + "{" + s + "}"; - else - t += "{" + s + "}"; + p.setOptions( u ); - Inset * new_inset = - new InsetRef(t, current_view->buffer()); - current_view->insertInset(new_inset); + Inset * inset = new InsetRef( p, current_view->buffer() ); + current_view->insertInset( inset ); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d01236b739..519414281f 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2572,20 +2572,19 @@ string LyXFunc::Dispatch(int ac, // ale970405+lasgoutt970425 // The argument can be up to two tokens separated // by a space. The first one is the bibstyle. - string lsarg(argument); - string bibstyle = token(lsarg, ' ', 1); + string db = token(argument, ' ', 0); + string bibstyle = token(argument, ' ', 1); if (bibstyle.empty()) bibstyle = "plain"; - InsetBibtex * new_inset - = new InsetBibtex(token(lsarg, ' ', 0), - bibstyle, - owner->buffer()); + + InsetCommandParams p( "BibTeX", db, bibstyle ); + InsetBibtex * inset = new InsetBibtex(p, owner->buffer()); - if (owner->view()->insertInset(new_inset)) { - if (lsarg.empty()) - new_inset->Edit(owner->view(), 0, 0, 0); + if (owner->view()->insertInset(inset)) { + if (argument.empty()) + inset->Edit(owner->view(), 0, 0, 0); } else - delete new_inset; + delete inset; } break; @@ -2621,28 +2620,22 @@ string LyXFunc::Dispatch(int ac, break; case LFUN_INDEX_CREATE: - case LFUN_INDEX_CREATE_LAST: { - // Can't do that at the beginning of a paragraph. - if (owner->view()->text->cursor.pos() - 1 < 0) - break; - InsetCommandParams p( "index" ); - if (!argument.empty()) { - p.setContents( argument ); - } else { - //get the current word for an argument - LyXParagraph::size_type lastpos = + if( argument.empty() ) { + // Get the word immediately preceding the cursor + LyXParagraph::size_type curpos = owner->view()->text->cursor.pos() - 1; - // Get the current word. note that this must be done - // before inserting the inset, or the inset will - // break the word - string curstring(owner->view() - ->text->cursor.par()->GetWord(lastpos)); - //make the new inset and write the current word into it + string curstring; + if( curpos >= 0 ) + curstring = owner->view()->text + ->cursor.par()->GetWord(curpos); + p.setContents( curstring ); + } else { + p.setContents( argument ); } owner->getDialogs()->createIndex( p.getAsString() ); @@ -2653,8 +2646,29 @@ string LyXFunc::Dispatch(int ac, { InsetCommandParams p; p.setFromString( argument ); - InsetIndex * inset = new InsetIndex( p ); + + if (!owner->view()->insertInset(inset)) + delete inset; + else + owner->view()->updateInset( inset, true ); + } + break; + + case LFUN_INDEX_INSERT_LAST: + { + // Get word immediately preceding the cursor + LyXParagraph::size_type curpos = + owner->view()->text->cursor.pos() - 1; + // Can't do that at the beginning of a paragraph + if( curpos < 0 ) break; + + string curstring( owner->view()->text + ->cursor.par()->GetWord(curpos) ); + + InsetCommandParams p( "index", curstring ); + InsetIndex * inset = new InsetIndex( p ); + if (!owner->view()->insertInset(inset)) delete inset; else @@ -2664,7 +2678,7 @@ string LyXFunc::Dispatch(int ac, case LFUN_INDEX_PRINT: { - InsetCommandParams p("printindex"); + InsetCommandParams p( "printindex" ); Inset * inset = new InsetPrintIndex(p); if (!owner->view()->insertInset(inset, "Standard", true)) delete inset; @@ -2674,20 +2688,21 @@ string LyXFunc::Dispatch(int ac, case LFUN_PARENTINSERT: { lyxerr << "arg " << argument << endl; - Inset * new_inset = new InsetParent(argument, owner->buffer()); - if (!owner->view()->insertInset(new_inset, "Standard", true)) - delete new_inset; + InsetCommandParams p( "lyxparent", argument ); + Inset * inset = new InsetParent(p, owner->buffer()); + if (!owner->view()->insertInset(inset, "Standard", true)) + delete inset; } break; case LFUN_CHILDINSERT: { - Inset * new_inset = new InsetInclude(argument, - owner->buffer()); - if (owner->view()->insertInset(new_inset, "Standard", true)) - new_inset->Edit(owner->view(), 0, 0, 0); + InsetCommandParams p( "Include", argument ); + Inset * inset = new InsetInclude(p, owner->buffer()); + if (owner->view()->insertInset(inset, "Standard", true)) + inset->Edit(owner->view(), 0, 0, 0); else - delete new_inset; + delete inset; } break; diff --git a/src/menus.C b/src/menus.C index aacb3f007c..2816cd216a 100644 --- a/src/menus.C +++ b/src/menus.C @@ -1563,11 +1563,11 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long) men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO, label_list[num].c_str()); else { - static string const commands[5] - = { "\\ref", "\\pageref", "\\vref", "\\vpageref", - "\\prettyref"}; - string t = commands[type] + "{" + label_list[num] + "}"; - men->currentView()->insertInset(new InsetRef(t, buffer)); + static string const cmdname[5] + = { "ref", "pageref", "vref", "vpageref", "prettyref"}; + InsetCommandParams p( cmdname[type] ); + p.setContents( label_list[num] ); + men->currentView()->insertInset(new InsetRef(p, buffer)); } } @@ -1901,7 +1901,7 @@ void Menus::ShowInsertMenu(FL_OBJECT * ob, long) case 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break; case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break; case 16: tmpfunc->Dispatch(LFUN_INDEX_CREATE); break; - case 17: tmpfunc->Dispatch(LFUN_INDEX_CREATE_LAST); break; + case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break; case 18: tmpfunc->Dispatch(LFUN_URL); break; } } diff --git a/src/paragraph.C b/src/paragraph.C index fddf45ae30..8e4f7bad46 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1651,8 +1651,10 @@ LyXParagraph * LyXParagraph::Clone() const result->inset_owner = inset_owner; // ale970302 - result->bibkey = (bibkey) ? new InsetBibKey(bibkey): 0; - + if (bibkey) + result->bibkey = static_cast(bibkey->Clone()); + else + result->bibkey = 0; // copy everything behind the break-position to the new paragraph diff --git a/src/support/strerror.c b/src/support/strerror.c index b0754b7476..adf217865f 100644 --- a/src/support/strerror.c +++ b/src/support/strerror.c @@ -5,10 +5,10 @@ #include -// $Id: strerror.c,v 1.2 1999/10/02 16:21:10 larsbj Exp $ +/* $Id: strerror.c,v 1.3 2000/08/04 13:12:30 lasgouttes Exp $ */ #if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: strerror.c,v 1.2 1999/10/02 16:21:10 larsbj Exp $"; +static char vcid[] = "$Id: strerror.c,v 1.3 2000/08/04 13:12:30 lasgouttes Exp $"; #endif /* lint */ extern int sys_nerr ; diff --git a/src/texrow.C b/src/texrow.C index 6403c0a311..3d9dc4d00d 100644 --- a/src/texrow.C +++ b/src/texrow.C @@ -53,8 +53,8 @@ void TexRow::newline() void TexRow::getIdFromRow(int row, int & id, int & pos) const { - RowList::const_iterator cit = rowlist.begin(); - RowList::const_iterator end = rowlist.end(); + RowList::iterator cit = rowlist.begin(); + RowList::iterator end = rowlist.end(); for (; cit != end; ++cit) { if ((*cit).rownumber() == row) break; } diff --git a/src/text2.C b/src/text2.C index bbd6061d37..9542fc6a3b 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2027,8 +2027,10 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth; par->incCounter(i); int number = par->getCounter(i); - if (!par->bibkey) - par->bibkey = new InsetBibKey(); + if (!par->bibkey) { + InsetCommandParams p( "bibitem" ); + par->bibkey = new InsetBibKey(p); + } par->bibkey->setCounter(number); par->labelstring = layout.labelstring();