]> git.lyx.org Git - features.git/commitdiff
Another clean-up patch from Angus
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 4 Aug 2000 13:12:30 +0000 (13:12 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 4 Aug 2000 13:12:30 +0000 (13:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@953 a592a061-630c-0410-9148-cb99ea01b6c8

34 files changed:
ChangeLog
INSTALL
src/LyXAction.C
src/buffer.C
src/commandtags.h
src/frontends/xforms/FormCitation.C
src/frontends/xforms/FormCitation.h
src/frontends/xforms/FormIndex.C
src/frontends/xforms/FormToc.C
src/frontends/xforms/FormToc.h
src/frontends/xforms/FormUrl.C
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetcite.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insettoc.h
src/insets/inseturl.h
src/lyx_cb.C
src/lyxfunc.C
src/menus.C
src/paragraph.C
src/support/strerror.c
src/texrow.C
src/text2.C

index 70ee015ac4b00256e03bae2ce398a37c9675f44e..2b9624a4acf05f2b32dc9ade9eba112d6a4d0eb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,56 @@
+2000-08-04  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/support/strerror.c: remove C++ comment.
+
+2000-08-04  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * 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<string>
+       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<string>
+       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  <larsbj@lyx.org>
 
        * lib/lyxrc.example: mark te pdf options as non functional.
diff --git a/INSTALL b/INSTALL
index 302f09a8075bc0df683ad40d485b2afac20ec31b..d506060d495c8d4c706f5b84ee7fb36996032fe7 100644 (file)
--- 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
index 6c52cc69233de38621c76f4a465c472b085e064c..0a80b37246fc1aab07841e90be9f9181fd93a0b4 100644 (file)
@@ -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 },
index 9284be47bdd80f5b0517cf2734eef1cd96e93345..3efdd0677958cb97586344273ed263046a77b1b9 100644 (file)
@@ -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) {
index 902f2ab7f9dbefafb65125fe2e0b93d34ef023c3..1789a476c7515bc00d1e5601ee03574df7f9f263 100644 (file)
@@ -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
index df45cd020cd8acaec9a841cf3fb0ef17bbd2f726..731e14e17edb45fb9d77fd0d5a20d51afc48fca8 100644 (file)
@@ -35,10 +35,6 @@ using std::max;
 using std::min;
 using std::find;
 
-static vector<string> citekeys;
-static vector<string> bibkeys;
-static vector<string> 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 );
                }
index cf542c1703feef7fe2fae34080fac9c9b9ea1f3f..f6e222d8e81daa9e6a3168f83f3a47ff811ce2f5 100644 (file)
@@ -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<string> citekeys;
+       ///
+       std::vector<string> bibkeys;
+       ///
+       std::vector<string> bibkeysInfo;
 };
 
 #endif
index 528c3e7338c7b830a82569c19145b9e3577dd387..8a38f7eeb646e1869fc8055ff422e8bfa8ad06f4 100644 (file)
@@ -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 );
                }
index 9a24d2b7ce5ca1198e037913a26291c0d8571b34..07befefa14de3eb01f4ea4dc2a2d55ef779ccb27 100644 (file)
 #include "Dialogs.h"
 #include "FormToc.h"
 #include "LyXView.h"
-#include "buffer.h"
 #include "form_toc.h"
 #include "lyxtext.h"
 
-static vector<Buffer::TocItem> 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" )
index 6825b212c9c18880a6e04e36a0d09409ddec2c0c..7872ce813afa6139e358222db87bede327386b8a 100644 (file)
@@ -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<Buffer::TocItem> toclist;
 };
 
 #endif
index d5a99291ff1721b5e839821af0b11a0bc8f5f843..8edfe11e16393a29c99b9f17771ddcf84169da35 100644 (file)
@@ -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 );
                }
index a2647612a27ff18bc74af909162b5487fe15e5d2..1f1dcfbf9a3141a55fe0003bd7d51edb37a47557 100644 (file)
@@ -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)
 {}
 
 
index c886bbe6c64e7e0552de342cb17c0b439f6e1295..58266516ab109aa586f678bee68c561fc4fc01e5 100644 (file)
@@ -16,8 +16,8 @@
 #pragma interface
 #endif
 
-#include "insetcommand.h"
 #include <vector>
+#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<std::pair<string,string> > getKeys() const;
-       ///
-       EDITABLE Editable() const {
-               return IS_EDITABLE;
-       }
         ///
         bool addDatabase(string const &);
         ///
index 7a766f577d4ec33b4d09fec0a15a4aac215fddee..fc2487c41ccea920da49703559add13f5a5204b6 100644 (file)
 #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 &);
index 4beaec279c5a8948413e279660cdd4a374b1748f..6260da9615442c334bced468d273a1c8794940b0 100644 (file)
@@ -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;
-}
index 81f58781c57d70720cd4724aba66387786f9e99d..4fb9df7d97976414054f37331e1c64e5ba033a18 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "insetbutton.h"
 #include <sigc++/signal_system.h>
+#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(); }
        ///
index 1bd61134803d0a5331fa1b92e3c8972d57f8c2bd..bb2c28c85472e3334a438e1d331df8efeed7d2fc 100644 (file)
@@ -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.
index 041e923cfef466c342a2df047f2068073d5748d5..ff6477c0692b20527c5c3a11f5220483cdd4ad09 100644 (file)
@@ -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();
         ///
index b92853804f179ecd8d5c94b0e4dd65d2c2f406df..92b6f57542445cf85b6a44b6104301eeb3ac9000 100644 (file)
 #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 &);
index 0a8ca63951da5846a75aaf37bc27d0576d98b65e..2aa37e0efd93af30483e363bef8fd790a429d5cf 100644 (file)
@@ -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<string> InsetLabel::getLabelList() const
index 750a3508ad7ce47640d7195325397470c1befaf1..39cc24e8e0e55840981446076b0a845a59195160 100644 (file)
 #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<string> 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<string> getLabelList() const;
+       ///
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
index fb65bdcb225da3b1fad39e7c5de3fbad90450fbd..36721161105f8f7bd15eafa4a99eff937136a679 100644 (file)
 
 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);
 }
index 861ac9d2a683e85380c291eab464c471e3266c77..0a1e9827023cf19f5ee41dec0a6a73ebabfc1b75 100644 (file)
@@ -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);
-       /// 
-       int Latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
-        ///
-        Inset * Clone() const { return new InsetParent(getContents()); }
+       InsetParent(InsetCommandParams const &, Buffer * owner = 0);
+       ///
+       Inset * Clone() const { return new InsetParent(params()); }
        ///
        string getScreenLabel() const;
         ///
-       void Edit(BufferView *, int, int, unsigned int);
-        ///
-       EDITABLE Editable() const {
-               return IS_EDITABLE;
-       }
+       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;
+        ///
         void setParent(string fn) { setContents(fn); }
 };
 #endif
index 6d1b80d781b78d5d0695af7a87d3c2a95d3a742e..72be4d27f0c069cdd8b83ee9667b267a9e5703a2 100644 (file)
@@ -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());
+    }
+}
index f000853828bfa8a299afe73d9c14b646a6b85e8f..994d3ad914786a9f3fd023ab33561529ff2cd0ce 100644 (file)
@@ -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
index 4c6848c447b6fc73868851f2ca7549062db96e87..cf0de54519bb71dc09fe13124324d3edfd981a29 100644 (file)
 #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) {}
index 6170b545df86cb3ea154a205ea9b24f408713d83..30a7b2c49bbd5342569f9b47817fb4b0672a7aec 100644 (file)
 #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
index ed3430bea4aa5815fe6ba3dd989540fa509ef483..45d9c08fa8d8cfbe4094a5d63168c4c16ff41e19 100644 (file)
@@ -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 );
 }
 
 
index d01236b739da9216911a1ff169d21ce891e73903..519414281f5698a0d0b4c96c70a246b91c5c3a9e 100644 (file)
@@ -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;
 
index aacb3f007c323cc6359a068169fca8e53c22413a..2816cd216a4b78d323092b96c58e36e5be399fc6 100644 (file)
@@ -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;
                }
        }
index fddf45ae30db5bd074c72871c864a175a32b6a2b..8e4f7bad4669d7e8b4cf230f63d89ddb25bd9ad9 100644 (file)
@@ -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<InsetBibKey *>(bibkey->Clone());
+       else
+               result->bibkey = 0;
     
        // copy everything behind the break-position to the new paragraph
 
index b0754b74765be5fcadaa99ac74e99470b5309f07..adf217865f0ebc34c4803a39b3006147fa028fd2 100644 (file)
@@ -5,10 +5,10 @@
 
 #include <config.h>
 
-//     $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 ;
index 6403c0a31127750e960986f3d118f2758018823a..3d9dc4d00d85b4f7bdd4792243aebeddde45859b 100644 (file)
@@ -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;
        }
index bbd6061d3732657d817e0875b1617a28d1854da9..9542fc6a3b0226a404d5f86436615dab249f601a 100644 (file)
@@ -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();