Another clean-up patch from Angus

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@953 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-08-04 13:12:30 +00:00
parent f4b8943ebb
commit cd694827a9
34 changed files with 347 additions and 375 deletions

View File

@ -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> 2000-08-03 Lars Gullik Bjønnes <larsbj@lyx.org>
* lib/lyxrc.example: mark te pdf options as non functional. * lib/lyxrc.example: mark te pdf options as non functional.

View File

@ -275,7 +275,8 @@ Preparing a binary distribution for the use of others
in some private place and running it. In particular, check the in some private place and running it. In particular, check the
output of `ldd lyx' to know which libraries are really needed. 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 Problems

View File

@ -249,7 +249,7 @@ void LyXAction::init()
N_("Insert hyphenation point"), Noop }, N_("Insert hyphenation point"), Noop },
{ LFUN_INDEX_CREATE, "index-insert", { LFUN_INDEX_CREATE, "index-insert",
N_("Insert index item"), Noop }, 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 }, N_("Insert last index item"), Noop },
{ LFUN_INDEX_PRINT, "index-print", N_("Insert index list"), { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"),
Noop }, Noop },

View File

@ -489,7 +489,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
if (pp.first) { if (pp.first) {
params.textclass = pp.second; params.textclass = pp.second;
} else { } else {
lex.printError("Unknown textclass `$$Token'"); lex.printError("Unknown textclass `$$Token'");
params.textclass = 0; params.textclass = 0;
} }
if (!textclasslist.Load(params.textclass)) { if (!textclasslist.Load(params.textclass)) {
@ -889,7 +889,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
++pos; ++pos;
} else if (tmptok == "Include") { } else if (tmptok == "Include") {
Inset * inset = new InsetInclude(string(), this); InsetCommandParams p( "Include" );
Inset * inset = new InsetInclude(p, this);
inset->Read(this, lex); inset->Read(this, lex);
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
++pos; ++pos;
@ -951,25 +952,25 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
++pos; ++pos;
} else if (tmptok == "LatexCommand") { } else if (tmptok == "LatexCommand") {
InsetCommand inscmd; InsetCommandParams inscmd;
inscmd.Read(this, lex); inscmd.Read(lex);
Inset * inset = 0; Inset * inset = 0;
if (inscmd.getCmdName() == "cite") { if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.params()); inset = new InsetCitation(inscmd);
} else if (inscmd.getCmdName() == "bibitem") { } else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem"); lex.printError("Wrong place for bibitem");
inset = inscmd.Clone(); inset = new InsetBibKey(inscmd);
} else if (inscmd.getCmdName() == "BibTeX") { } else if (inscmd.getCmdName() == "BibTeX") {
inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this); inset = new InsetBibtex(inscmd, this);
} else if (inscmd.getCmdName() == "index") { } else if (inscmd.getCmdName() == "index") {
inset = new InsetIndex(inscmd.params()); inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") { } else if (inscmd.getCmdName() == "include") {
inset = new InsetInclude(inscmd.getContents(), this); inset = new InsetInclude(inscmd, this);
} else if (inscmd.getCmdName() == "label") { } else if (inscmd.getCmdName() == "label") {
inset = new InsetLabel(inscmd.getCommand()); inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url" } else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") { || inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.params()); inset = new InsetUrl(inscmd);
} else if (inscmd.getCmdName() == "ref" } else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref" || inscmd.getCmdName() == "vref"
@ -982,11 +983,11 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|| inscmd.getCmdName() == "listofalgorithms" || inscmd.getCmdName() == "listofalgorithms"
|| inscmd.getCmdName() == "listoffigures" || inscmd.getCmdName() == "listoffigures"
|| inscmd.getCmdName() == "listoftables") { || inscmd.getCmdName() == "listoftables") {
inset = new InsetTOC(inscmd.params()); inset = new InsetTOC(inscmd);
} else if (inscmd.getCmdName() == "printindex") { } else if (inscmd.getCmdName() == "printindex") {
inset = new InsetPrintIndex(inscmd.params()); inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") { } else if (inscmd.getCmdName() == "lyxparent") {
inset = new InsetParent(inscmd.getContents(), this); inset = new InsetParent(inscmd, this);
} }
if (inset) { if (inset) {
@ -1054,8 +1055,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
} }
++pos; ++pos;
} else if (token == "\\bibitem") { // ale970302 } else if (token == "\\bibitem") { // ale970302
if (!par->bibkey) if (!par->bibkey) {
par->bibkey = new InsetBibKey; InsetCommandParams p( "bibitem" );
par->bibkey = new InsetBibKey(p);
}
par->bibkey->Read(this, lex); par->bibkey->Read(this, lex);
}else if (token == "\\backslash") { }else if (token == "\\backslash") {
par->InsertChar(pos, '\\', font); par->InsertChar(pos, '\\', font);
@ -1120,7 +1123,8 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
++pos; ++pos;
} else if (tmptok == "Include") { } else if (tmptok == "Include") {
Inset * inset = new InsetInclude(string(), this); InsetCommandParams p( "Include" );
Inset * inset = new InsetInclude(p, this);
inset->Read(this, lex); inset->Read(this, lex);
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
++pos; ++pos;
@ -1181,26 +1185,25 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
//inset->Read(this, lex); //inset->Read(this, lex);
par->InsertInset(pos, inset, font); par->InsertInset(pos, inset, font);
} else if (tmptok == "LatexCommand") { } else if (tmptok == "LatexCommand") {
InsetCommand inscmd; InsetCommandParams inscmd;
inscmd.Read(this, lex); inscmd.Read(lex);
Inset * inset = 0; Inset * inset = 0;
if (inscmd.getCmdName() == "cite") { if (inscmd.getCmdName() == "cite") {
inset = new InsetCitation(inscmd.params()); inset = new InsetCitation(inscmd);
} else if (inscmd.getCmdName() == "bibitem") { } else if (inscmd.getCmdName() == "bibitem") {
lex.printError("Wrong place for bibitem"); lex.printError("Wrong place for bibitem");
inset = inscmd.Clone(); inset = new InsetBibKey(inscmd);
} else if (inscmd.getCmdName() == "BibTeX") { } else if (inscmd.getCmdName() == "BibTeX") {
inset = new InsetBibtex(inscmd.getContents(), inset = new InsetBibtex(inscmd, this);
inscmd.getOptions(), this);
} else if (inscmd.getCmdName() == "index") { } else if (inscmd.getCmdName() == "index") {
inset = new InsetIndex(inscmd.params()); inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") { } else if (inscmd.getCmdName() == "include") {
inset = new InsetInclude(inscmd.getContents(), this); inset = new InsetInclude(inscmd, this);
} else if (inscmd.getCmdName() == "label") { } else if (inscmd.getCmdName() == "label") {
inset = new InsetLabel(inscmd.getCommand()); inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url" } else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "htmlurl") { || inscmd.getCmdName() == "htmlurl") {
inset = new InsetUrl(inscmd.params()); inset = new InsetUrl(inscmd);
} else if (inscmd.getCmdName() == "ref" } else if (inscmd.getCmdName() == "ref"
|| inscmd.getCmdName() == "pageref" || inscmd.getCmdName() == "pageref"
|| inscmd.getCmdName() == "vref" || inscmd.getCmdName() == "vref"
@ -1214,11 +1217,11 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
|| inscmd.getCmdName() == "listofalgorithms" || inscmd.getCmdName() == "listofalgorithms"
|| inscmd.getCmdName() == "listoffigures" || inscmd.getCmdName() == "listoffigures"
|| inscmd.getCmdName() == "listoftables") { || inscmd.getCmdName() == "listoftables") {
inset = new InsetTOC(inscmd.params()); inset = new InsetTOC(inscmd);
} else if (inscmd.getCmdName() == "printindex") { } else if (inscmd.getCmdName() == "printindex") {
inset = new InsetPrintIndex(inscmd.params()); inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") { } else if (inscmd.getCmdName() == "lyxparent") {
inset = new InsetParent(inscmd.getContents(), this); inset = new InsetParent(inscmd, this);
} }
if (inset) { if (inset) {

View File

@ -199,7 +199,7 @@ enum kb_action {
LFUN_CITATION_INSERT, // AAS 97-02-23 LFUN_CITATION_INSERT, // AAS 97-02-23
LFUN_INSERT_BIBTEX, // AAS 97-02-23 LFUN_INSERT_BIBTEX, // AAS 97-02-23
LFUN_INDEX_CREATE, // Lgb 97-02-27 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_INDEX_PRINT, // Lgb 97-02-27
LFUN_APROPOS, // Asger 1997-02-27 LFUN_APROPOS, // Asger 1997-02-27
LFUN_LATEX_LOG, // Lgb 97-04-05 LFUN_LATEX_LOG, // Lgb 97-04-05

View File

@ -35,10 +35,6 @@ using std::max;
using std::min; using std::min;
using std::find; using std::find;
static vector<string> citekeys;
static vector<string> bibkeys;
static vector<string> bibkeysInfo;
FormCitation::FormCitation(LyXView * lv, Dialogs * d) FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Citation")), dialog_(0) : FormCommand(lv, d, _("Citation")), dialog_(0)
{ {
@ -73,7 +69,7 @@ void FormCitation::build()
FL_FORM * const FormCitation::form() const FL_FORM * const FormCitation::form() const
{ {
if( dialog_ && dialog_->form_citation ) if( dialog_ ) // no need to test for dialog_->citation
return dialog_->form_citation; return dialog_->form_citation;
else else
return 0; return 0;
@ -102,8 +98,6 @@ void FormCitation::update()
keys = frontStrip( split(keys, tmp, ',') ); keys = frontStrip( split(keys, tmp, ',') );
} }
fl_freeze_form( dialog_->form_citation );
updateBrowser( dialog_->bibBrsr, bibkeys ); updateBrowser( dialog_->bibBrsr, bibkeys );
updateBrowser( dialog_->citeBrsr, citekeys ); updateBrowser( dialog_->citeBrsr, citekeys );
fl_clear_browser( dialog_->infoBrsr ); fl_clear_browser( dialog_->infoBrsr );
@ -123,8 +117,6 @@ void FormCitation::update()
setSize( size, bibPresent ); setSize( size, bibPresent );
fl_set_input( dialog_->textAftr, params.getOptions().c_str() ); 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 ) if( inset_ != 0 )
{ {
// Only update if contents have changed // Only update if contents have changed
if( params.getCmdName() != inset_->getCmdName() || if( params != inset_->params() ) {
params.getContents() != inset_->getContents() ||
params.getOptions() != inset_->getOptions() ) {
inset_->setParams( params ); inset_->setParams( params );
lv_->view()->updateInset( inset_, true ); lv_->view()->updateInset( inset_, true );
} }

View File

@ -23,6 +23,15 @@ struct FD_form_citation;
*/ */
class FormCitation : public FormCommand { class FormCitation : public FormCommand {
public: public:
/**@name Constructors and Destructors */
//@{
///
FormCitation(LyXView *, Dialogs *);
///
~FormCitation();
//@}
private:
/// ///
enum State { enum State {
DOWN, DOWN,
@ -34,15 +43,6 @@ public:
ON, ON,
OFF OFF
}; };
/**@name Constructors and Destructors */
//@{
/// #FormCitation x(LyXFunc ..., Dialogs ...);#
FormCitation(LyXView *, Dialogs *);
///
~FormCitation();
//@}
private:
/// Build the dialog /// Build the dialog
virtual void build(); virtual void build();
/// Filter the inputs /// Filter the inputs
@ -69,6 +69,12 @@ private:
/// Real GUI implementation. /// Real GUI implementation.
FD_form_citation * dialog_; FD_form_citation * dialog_;
///
std::vector<string> citekeys;
///
std::vector<string> bibkeys;
///
std::vector<string> bibkeysInfo;
}; };
#endif #endif

View File

@ -47,12 +47,18 @@ FormIndex::~FormIndex()
void FormIndex::build() void FormIndex::build()
{ {
dialog_ = build_index(); 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 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; return dialog_->form_index;
else else
return 0; return 0;
@ -61,18 +67,6 @@ FL_FORM * const FormIndex::form() const
void FormIndex::update() 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()); fl_set_input(dialog_->key, params.getContents().c_str());
if( lv_->buffer()->isReadonly() ) { if( lv_->buffer()->isReadonly() ) {
@ -84,8 +78,6 @@ void FormIndex::update()
fl_activate_object( dialog_->ok ); fl_activate_object( dialog_->ok );
fl_set_object_lcol( dialog_->ok, FL_BLACK ); fl_set_object_lcol( dialog_->ok, FL_BLACK );
} }
fl_unfreeze_form( dialog_->form_index );
} }
@ -98,7 +90,7 @@ void FormIndex::apply()
if( inset_ != 0 ) if( inset_ != 0 )
{ {
// Only update if contents have changed // Only update if contents have changed
if( params.getContents() != inset_->getContents() ) { if( params != inset_->params() ) {
inset_->setParams( params ); inset_->setParams( params );
lv_->view()->updateInset( inset_, true ); lv_->view()->updateInset( inset_, true );
} }

View File

@ -23,12 +23,9 @@
#include "Dialogs.h" #include "Dialogs.h"
#include "FormToc.h" #include "FormToc.h"
#include "LyXView.h" #include "LyXView.h"
#include "buffer.h"
#include "form_toc.h" #include "form_toc.h"
#include "lyxtext.h" #include "lyxtext.h"
static vector<Buffer::TocItem> toclist;
FormToc::FormToc(LyXView * lv, Dialogs * d) FormToc::FormToc(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Table of Contents")), dialog_(0) : FormCommand(lv, d, _("Table of Contents")), dialog_(0)
{ {
@ -58,12 +55,14 @@ void FormToc::build()
dialog_ = build_toc(); dialog_ = build_toc();
fl_addto_choice(dialog_->type, fl_addto_choice(dialog_->type,
_(" TOC | LOF | LOT | LOA ")); _(" TOC | LOF | LOT | LOA "));
// Don't need to limit size of this dialog
} }
FL_FORM * const FormToc::form() const 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; return dialog_->form_toc;
else else
return 0; return 0;
@ -72,16 +71,6 @@ FL_FORM * const FormToc::form() const
void FormToc::update() 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; Buffer::TocType type;
if( params.getCmdName() == "tableofcontents" ) if( params.getCmdName() == "tableofcontents" )

View File

@ -17,6 +17,7 @@
#endif #endif
#include "FormCommand.h" #include "FormCommand.h"
#include "buffer.h"
struct FD_form_toc; struct FD_form_toc;
/** This class provides an XForms implementation of the FormToc Dialog. /** This class provides an XForms implementation of the FormToc Dialog.
@ -50,6 +51,8 @@ private:
/// Real GUI implementation. /// Real GUI implementation.
FD_form_toc * dialog_; FD_form_toc * dialog_;
///
std::vector<Buffer::TocItem> toclist;
}; };
#endif #endif

View File

@ -47,12 +47,18 @@ FormUrl::~FormUrl()
void FormUrl::build() void FormUrl::build()
{ {
dialog_ = build_url(); 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 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; return dialog_->form_url;
else else
return 0; return 0;
@ -61,18 +67,6 @@ FL_FORM * const FormUrl::form() const
void FormUrl::update() 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_->url, params.getContents().c_str());
fl_set_input(dialog_->name, params.getOptions().c_str()); fl_set_input(dialog_->name, params.getOptions().c_str());
@ -94,8 +88,6 @@ void FormUrl::update()
fl_activate_object( dialog_->ok ); fl_activate_object( dialog_->ok );
fl_set_object_lcol( dialog_->ok, FL_BLACK ); fl_set_object_lcol( dialog_->ok, FL_BLACK );
} }
fl_unfreeze_form( dialog_->form_url );
} }
@ -114,9 +106,7 @@ void FormUrl::apply()
if( inset_ != 0 ) if( inset_ != 0 )
{ {
// Only update if contents have changed // Only update if contents have changed
if( params.getCmdName() != inset_->getCmdName() || if( params != inset_->params() ) {
params.getContents() != inset_->getContents() ||
params.getOptions() != inset_->getOptions() ) {
inset_->setParams( params ); inset_->setParams( params );
lv_->view()->updateInset( inset_, true ); lv_->view()->updateInset( inset_, true );
} }

View File

@ -72,19 +72,10 @@ FD_bibitem_form * create_form_bibitem_form(void)
} }
InsetBibKey::InsetBibKey(string const & key, string const & label) InsetBibKey::InsetBibKey(InsetCommandParams const & p)
: InsetCommand("bibitem", key, label) : InsetCommand(p)
{ {
counter = 1; 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 ) void InsetBibKey::callback( FD_bibitem_form * form, long data )
{ {
switch (data) { switch (data) {
@ -201,9 +200,8 @@ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
} }
InsetBibtex::InsetBibtex(string const & dbase, string const & style, InsetBibtex::InsetBibtex(InsetCommandParams const & p, Buffer * o)
Buffer * o) : InsetCommand(p), owner(o)
: InsetCommand("BibTeX", dbase, style), owner(o)
{} {}

View File

@ -16,8 +16,8 @@
#pragma interface #pragma interface
#endif #endif
#include "insetcommand.h"
#include <vector> #include <vector>
#include "insetcommand.h"
class Buffer; class Buffer;
struct FD_bibitem_form; struct FD_bibitem_form;
@ -30,17 +30,11 @@ struct FD_bibitem_form;
class InsetBibKey : public InsetCommand { class InsetBibKey : public InsetCommand {
public: public:
/// ///
InsetBibKey() : InsetCommand("bibitem") { counter = 1; } InsetBibKey(InsetCommandParams const &);
///
explicit
InsetBibKey(string const & key, string const & label = string());
///
explicit
InsetBibKey(InsetBibKey const *);
/// ///
~InsetBibKey(); ~InsetBibKey();
/// ///
Inset * Clone() const { return new InsetBibKey(this); } Inset * Clone() const;
/** Currently \bibitem is used as a LyX2.x command, /** Currently \bibitem is used as a LyX2.x command,
so we need this method. so we need this method.
*/ */
@ -83,36 +77,25 @@ private:
*/ */
class InsetBibtex : public InsetCommand { class InsetBibtex : public InsetCommand {
public: public:
///
InsetBibtex() : InsetCommand("BibTeX") { owner = 0; }
/// ///
InsetBibtex(string const & dbase, string const & style, InsetBibtex(InsetCommandParams const &, Buffer *);
Buffer *);
/// ///
~InsetBibtex(); ~InsetBibtex();
///
Inset * Clone() const {
return new InsetBibtex(getContents(), getOptions(), owner);
}
/// ///
Inset::Code LyxCode() const Inset * Clone() const { return new InsetBibtex(params(), owner); }
{
return Inset::BIBTEX_CODE;
}
/// ///
string getScreenLabel() const; 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); void Edit(BufferView *, int x, int y, unsigned int button);
/// ///
int Latex(Buffer const *, std::ostream &, int Latex(Buffer const *, std::ostream &,
bool fragile, bool freespace) const; bool fragile, bool freespace) const;
/// ///
std::vector<std::pair<string,string> > getKeys() const; std::vector<std::pair<string,string> > getKeys() const;
///
EDITABLE Editable() const {
return IS_EDITABLE;
}
/// ///
bool addDatabase(string const &); bool addDatabase(string const &);
/// ///

View File

@ -16,11 +16,10 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "support/utility.hpp"
/** Used to insert citations /** Used to insert citations
*/ */
class InsetCitation : public InsetCommand, public noncopyable { class InsetCitation : public InsetCommand {
public: public:
/// ///
InsetCitation(InsetCommandParams const &); InsetCitation(InsetCommandParams const &);

View File

@ -59,38 +59,25 @@ void InsetCommandParams::setFromString( string const & b )
} }
InsetCommand::InsetCommand() bool InsetCommandParams::operator==(InsetCommandParams const & o) const
{}
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 )
{ {
p_.setCmdName( p.getCmdName() ); if( cmdname != o.cmdname ) return false;
p_.setContents( p.getContents() ); if( contents != o.contents ) return false;
p_.setOptions( p.getOptions() ); if( options != o.options ) return false;
return true;
} }
// In lyxf3 this will be just LaTeX bool InsetCommandParams::operator!=(InsetCommandParams const & o) const
void InsetCommand::Write(Buffer const *, ostream & os) 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; string tcmdname, toptions, tcontents;
@ -153,7 +140,7 @@ void InsetCommand::scanCommand(string const & cmd)
// This function will not be necessary when lyx3 // This function will not be necessary when lyx3
void InsetCommand::Read(Buffer const *, LyXLex & lex) void InsetCommandParams::Read(LyXLex & lex)
{ {
string token; 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, int InsetCommand::Latex(Buffer const *, ostream & os,
bool /*fragile*/, bool/*fs*/) const bool /*fragile*/, bool/*fs*/) const
{ {
@ -199,19 +215,3 @@ int InsetCommand::DocBook(Buffer const *, ostream &) const
{ {
return 0; 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;
}

View File

@ -18,6 +18,7 @@
#include "insetbutton.h" #include "insetbutton.h"
#include <sigc++/signal_system.h> #include <sigc++/signal_system.h>
#include "support/utility.hpp"
#ifdef SIGC_CXX_NAMESPACES #ifdef SIGC_CXX_NAMESPACES
using SigC::Signal0; using SigC::Signal0;
@ -39,6 +40,18 @@ public:
string const & c = string(), string const & c = string(),
string const & o = 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 & getCmdName() const { return cmdname; }
/// ///
string const & getOptions() const { return options; } string const & getOptions() const { return options; }
@ -54,7 +67,6 @@ public:
string getAsString() const; string getAsString() const;
/// ///
void setFromString( string const & ); void setFromString( string const & );
private: private:
/// ///
string cmdname; string cmdname;
@ -65,27 +77,20 @@ private:
}; };
class InsetCommand : public InsetButton { class InsetCommand : public InsetButton, public noncopyable {
public: public:
///
InsetCommand();
///
explicit
InsetCommand(string const & n,
string const & c = string(),
string const & o = string());
///
explicit explicit
InsetCommand(InsetCommandParams const &); InsetCommand(InsetCommandParams const &);
/// ///
virtual ~InsetCommand() { hide(); }; virtual ~InsetCommand() { hide(); };
/// ///
void Write(Buffer const *, std::ostream &) const; void Write(Buffer const *, std::ostream & os) const
{ p_.Write( os ); }
/// Parse the command.
void scanCommand(string const & cmd);
/// ///
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 &, virtual int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; bool fragile, bool free_spc) const;
@ -96,12 +101,7 @@ public:
/// ///
virtual int DocBook(Buffer const *, std::ostream &) const; 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. /** Get the label that appears at screen.
@ -109,9 +109,9 @@ public:
confusion with lyxinset::getLabel(int), but I've seen that confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale) it wasn't. I hope you never confuse again both methods. (ale)
*/ */
virtual string getScreenLabel() const { return getCommand(); } virtual string getScreenLabel() const = 0;
/// Build the complete LaTeX command ///
string getCommand() const; string getCommand() const { return p_.getCommand(); }
/// ///
string const & getCmdName() const { return p_.getCmdName(); } string const & getCmdName() const { return p_.getCmdName(); }
/// ///

View File

@ -210,11 +210,9 @@ static string unique_id() {
} }
InsetInclude::InsetInclude(string const & fname, Buffer * bf) InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer * bf)
: InsetCommand("include") : InsetCommand(p), master(bf)
{ {
master = bf;
setContents(fname);
flag = InsetInclude::INCLUDE; flag = InsetInclude::INCLUDE;
noload = false; noload = false;
include_label = unique_id(); include_label = unique_id();
@ -240,7 +238,7 @@ InsetInclude::~InsetInclude()
Inset * InsetInclude::Clone() const Inset * InsetInclude::Clone() const
{ {
InsetInclude * ii = new InsetInclude (getContents(), master); InsetInclude * ii = new InsetInclude (params(), master);
ii->setNoLoad(isNoLoad()); ii->setNoLoad(isNoLoad());
// By default, the newly created inset is of `include' type, // By default, the newly created inset is of `include' type,
// so we do not test this case. // so we do not test this case.

View File

@ -26,15 +26,8 @@ struct LaTeXFeatures;
*/ */
class InsetInclude: public InsetCommand { class InsetInclude: public InsetCommand {
public: public:
#if 0
/// ///
InsetInclude(): InsetCommand("include") InsetInclude(InsetCommandParams const &, Buffer *);
{
flag = InsetInclude::INCLUDE;
}
#endif
///
InsetInclude(string const &, Buffer *);
/// ///
~InsetInclude(); ~InsetInclude();
/// ///

View File

@ -17,13 +17,12 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "support/utility.hpp"
struct LaTeXFeatures; struct LaTeXFeatures;
/** Used to insert index labels /** Used to insert index labels
*/ */
class InsetIndex : public InsetCommand, public noncopyable { class InsetIndex : public InsetCommand {
public: public:
/// ///
InsetIndex(InsetCommandParams const &); InsetIndex(InsetCommandParams const &);
@ -38,7 +37,7 @@ public:
}; };
class InsetPrintIndex : public InsetCommand, public noncopyable { class InsetPrintIndex : public InsetCommand {
public: public:
/// ///
InsetPrintIndex(InsetCommandParams const &); InsetPrintIndex(InsetCommandParams const &);

View File

@ -28,16 +28,9 @@ using std::pair;
/* Label. Used to insert a label automatically */ /* Label. Used to insert a label automatically */
InsetLabel::InsetLabel(string const & cmd) InsetLabel::InsetLabel(InsetCommandParams const & p)
{ : InsetCommand(p)
scanCommand(cmd); {}
}
Inset * InsetLabel::Clone() const
{
return new InsetLabel(getCommand());
}
vector<string> InsetLabel::getLabelList() const vector<string> InsetLabel::getLabelList() const

View File

@ -17,29 +17,24 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "LString.h"
///
class InsetLabel : public InsetCommand { class InsetLabel : public InsetCommand {
public: public:
/// ///
explicit InsetLabel(InsetCommandParams const &);
InsetLabel(string const & cmd);
/// ///
InsetLabel() : InsetCommand("label") {} Inset * Clone() const { return new InsetLabel(params()); }
///
Inset * Clone() const;
///
Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
///
std::vector<string> getLabelList() const;
/// ///
string getScreenLabel() const { return getContents(); } string getScreenLabel() const { return getContents(); }
/// ///
EDITABLE Editable() const { return IS_EDITABLE; } EDITABLE Editable() const { return IS_EDITABLE; }
/// ///
Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
///
void Edit(BufferView *, int, int, unsigned int); void Edit(BufferView *, int, int, unsigned int);
/// ///
std::vector<string> getLabelList() const;
///
int Latex(Buffer const *, std::ostream &, int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; bool fragile, bool free_spc) const;
/// ///

View File

@ -28,11 +28,12 @@
using std::ostream; using std::ostream;
InsetParent::InsetParent(string const & fn, Buffer * owner) InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf)
: InsetCommand("lyxparent") : InsetCommand(p)
{ {
if (owner) string fn = p.getContents();
setContents(MakeAbsPath(fn, OnlyPath(owner->fileName()))); if (bf)
setContents(MakeAbsPath(fn, OnlyPath(bf->fileName())));
else else
setContents(fn); setContents(fn);
} }

View File

@ -26,27 +26,22 @@ class Buffer;
*/ */
class InsetParent : public InsetCommand { class InsetParent : public InsetCommand {
public: public:
/// Non-standard LyX macro
InsetParent() : InsetCommand("lyxparent") {}
/// ///
explicit InsetParent(InsetCommandParams const &, Buffer * owner = 0);
InsetParent(string const & fn, 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 &, int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; 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); } void setParent(string fn) { setContents(fn); }
}; };
#endif #endif

View File

@ -23,24 +23,12 @@ using std::endl;
extern BufferView * current_view; extern BufferView * current_view;
InsetRef::InsetRef(string const & cmd, Buffer * bf) InsetRef::InsetRef(InsetCommandParams const & p, Buffer * bf)
: master(bf) : InsetCommand(p), master(bf)
{ {
scanCommand(cmd);
GenerateFlag(); GenerateFlag();
} }
InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf)
: master(bf)
{
setCmdName(inscmd.getCmdName());
setContents(inscmd.getContents());
setOptions(inscmd.getOptions());
GenerateFlag();
}
void InsetRef::GenerateFlag() void InsetRef::GenerateFlag()
{ {
if (getCmdName() == "ref") if (getCmdName() == "ref")
@ -101,10 +89,8 @@ int InsetRef::Latex(Buffer const *, ostream & os,
if(getOptions().empty()) if(getOptions().empty())
os << escape(getCommand()); os << escape(getCommand());
else { else {
string ns; InsetCommandParams p( getCmdName(), getContents(), "" );
InsetCommand clone(getCmdName(), os << escape(p.getCommand());
getContents(), ns);
os << escape(clone.getCommand());
} }
return 0; return 0;
} }
@ -168,3 +154,11 @@ void InsetRef::Validate(LaTeXFeatures & features) const
break; break;
} }
} }
void InsetRef::gotoLabel()
{
if (master) {
master->getUser()->gotoLabel(getContents());
}
}

View File

@ -16,8 +16,8 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "buffer.h"
class Buffer;
struct LaTeXFeatures; struct LaTeXFeatures;
/** The reference inset /** 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 *); string getScreenLabel() const;
/// ///
Inset * Clone() const { EDITABLE Editable() const { return IS_EDITABLE; }
return new InsetRef (getCommand(), master);
}
/// ///
Inset::Code LyxCode() const { return Inset::REF_CODE; } Inset::Code LyxCode() const { return Inset::REF_CODE; }
/// ///
void Edit(BufferView *, int, int, unsigned int); void Edit(BufferView *, int, int, unsigned int);
///
EDITABLE Editable() const {
return IS_EDITABLE;
}
/// ///
bool display() const { return false; } bool display() const { return false; }
/// ///
string getScreenLabel() const;
///
void Toggle(); void Toggle();
/// ///
void gotoLabel(); void gotoLabel();
@ -89,13 +81,4 @@ private:
/// ///
Buffer * master; Buffer * master;
}; };
inline
void InsetRef::gotoLabel()
{
if (master) {
master->getUser()->gotoLabel(getContents());
}
}
#endif #endif

View File

@ -17,11 +17,10 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "support/utility.hpp"
/** Used to insert table of contents /** Used to insert table of contents
*/ */
class InsetTOC : public InsetCommand, public noncopyable { class InsetTOC : public InsetCommand {
public: public:
/// ///
InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {} InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {}

View File

@ -16,13 +16,12 @@
#endif #endif
#include "insetcommand.h" #include "insetcommand.h"
#include "support/utility.hpp"
struct LaTeXFeatures; struct LaTeXFeatures;
/** The url inset /** The url inset
*/ */
class InsetUrl : public InsetCommand, public noncopyable { class InsetUrl : public InsetCommand {
public: public:
/// ///
explicit explicit

View File

@ -1145,9 +1145,9 @@ void MenuInsertLabel(char const * arg)
} }
} }
if (!label.empty()) { if (!label.empty()) {
InsetLabel * new_inset = new InsetLabel; InsetCommandParams p( "label", label );
new_inset->setContents(label); InsetLabel * inset = new InsetLabel( p );
current_view->insertInset(new_inset); current_view->insertInset( inset );
} }
AllowInput(current_view); AllowInput(current_view);
} }
@ -2928,19 +2928,16 @@ extern "C" void RefSelectCB(FL_OBJECT *, long data)
return; return;
} }
static string const commands[5] static string const cmdname[5]
= { "\\ref", "\\pageref", "\\vref", "\\vpageref", = { "ref", "pageref", "vref", "vpageref", "prettyref"};
"\\prettyref"}; InsetCommandParams p( cmdname[data] );
string t = commands[data]; p.setContents( s );
if (current_view->buffer()->isSGML()) if (current_view->buffer()->isSGML())
t += "[" + u + "]" + "{" + s + "}"; p.setOptions( u );
else
t += "{" + s + "}";
Inset * new_inset = Inset * inset = new InsetRef( p, current_view->buffer() );
new InsetRef(t, current_view->buffer()); current_view->insertInset( inset );
current_view->insertInset(new_inset);
} }

View File

@ -2572,20 +2572,19 @@ string LyXFunc::Dispatch(int ac,
// ale970405+lasgoutt970425 // ale970405+lasgoutt970425
// The argument can be up to two tokens separated // The argument can be up to two tokens separated
// by a space. The first one is the bibstyle. // by a space. The first one is the bibstyle.
string lsarg(argument); string db = token(argument, ' ', 0);
string bibstyle = token(lsarg, ' ', 1); string bibstyle = token(argument, ' ', 1);
if (bibstyle.empty()) if (bibstyle.empty())
bibstyle = "plain"; bibstyle = "plain";
InsetBibtex * new_inset
= new InsetBibtex(token(lsarg, ' ', 0), InsetCommandParams p( "BibTeX", db, bibstyle );
bibstyle, InsetBibtex * inset = new InsetBibtex(p, owner->buffer());
owner->buffer());
if (owner->view()->insertInset(new_inset)) { if (owner->view()->insertInset(inset)) {
if (lsarg.empty()) if (argument.empty())
new_inset->Edit(owner->view(), 0, 0, 0); inset->Edit(owner->view(), 0, 0, 0);
} else } else
delete new_inset; delete inset;
} }
break; break;
@ -2621,28 +2620,22 @@ string LyXFunc::Dispatch(int ac,
break; break;
case LFUN_INDEX_CREATE: 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" ); InsetCommandParams p( "index" );
if (!argument.empty()) { if( argument.empty() ) {
p.setContents( argument ); // Get the word immediately preceding the cursor
} else { LyXParagraph::size_type curpos =
//get the current word for an argument
LyXParagraph::size_type lastpos =
owner->view()->text->cursor.pos() - 1; 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 ); p.setContents( curstring );
} else {
p.setContents( argument );
} }
owner->getDialogs()->createIndex( p.getAsString() ); owner->getDialogs()->createIndex( p.getAsString() );
@ -2653,8 +2646,29 @@ string LyXFunc::Dispatch(int ac,
{ {
InsetCommandParams p; InsetCommandParams p;
p.setFromString( argument ); p.setFromString( argument );
InsetIndex * inset = new InsetIndex( p ); 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)) if (!owner->view()->insertInset(inset))
delete inset; delete inset;
else else
@ -2664,7 +2678,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_INDEX_PRINT: case LFUN_INDEX_PRINT:
{ {
InsetCommandParams p("printindex"); InsetCommandParams p( "printindex" );
Inset * inset = new InsetPrintIndex(p); Inset * inset = new InsetPrintIndex(p);
if (!owner->view()->insertInset(inset, "Standard", true)) if (!owner->view()->insertInset(inset, "Standard", true))
delete inset; delete inset;
@ -2674,20 +2688,21 @@ string LyXFunc::Dispatch(int ac,
case LFUN_PARENTINSERT: case LFUN_PARENTINSERT:
{ {
lyxerr << "arg " << argument << endl; lyxerr << "arg " << argument << endl;
Inset * new_inset = new InsetParent(argument, owner->buffer()); InsetCommandParams p( "lyxparent", argument );
if (!owner->view()->insertInset(new_inset, "Standard", true)) Inset * inset = new InsetParent(p, owner->buffer());
delete new_inset; if (!owner->view()->insertInset(inset, "Standard", true))
delete inset;
} }
break; break;
case LFUN_CHILDINSERT: case LFUN_CHILDINSERT:
{ {
Inset * new_inset = new InsetInclude(argument, InsetCommandParams p( "Include", argument );
owner->buffer()); Inset * inset = new InsetInclude(p, owner->buffer());
if (owner->view()->insertInset(new_inset, "Standard", true)) if (owner->view()->insertInset(inset, "Standard", true))
new_inset->Edit(owner->view(), 0, 0, 0); inset->Edit(owner->view(), 0, 0, 0);
else else
delete new_inset; delete inset;
} }
break; break;

View File

@ -1563,11 +1563,11 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO, men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO,
label_list[num].c_str()); label_list[num].c_str());
else { else {
static string const commands[5] static string const cmdname[5]
= { "\\ref", "\\pageref", "\\vref", "\\vpageref", = { "ref", "pageref", "vref", "vpageref", "prettyref"};
"\\prettyref"}; InsetCommandParams p( cmdname[type] );
string t = commands[type] + "{" + label_list[num] + "}"; p.setContents( label_list[num] );
men->currentView()->insertInset(new InsetRef(t, buffer)); 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 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break; case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break;
case 16: tmpfunc->Dispatch(LFUN_INDEX_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; case 18: tmpfunc->Dispatch(LFUN_URL); break;
} }
} }

View File

@ -1651,8 +1651,10 @@ LyXParagraph * LyXParagraph::Clone() const
result->inset_owner = inset_owner; result->inset_owner = inset_owner;
// ale970302 // 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 // copy everything behind the break-position to the new paragraph

View File

@ -5,10 +5,10 @@
#include <config.h> #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) #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 */ #endif /* lint */
extern int sys_nerr ; extern int sys_nerr ;

View File

@ -53,8 +53,8 @@ void TexRow::newline()
void TexRow::getIdFromRow(int row, int & id, int & pos) const void TexRow::getIdFromRow(int row, int & id, int & pos) const
{ {
RowList::const_iterator cit = rowlist.begin(); RowList::iterator cit = rowlist.begin();
RowList::const_iterator end = rowlist.end(); RowList::iterator end = rowlist.end();
for (; cit != end; ++cit) { for (; cit != end; ++cit) {
if ((*cit).rownumber() == row) break; if ((*cit).rownumber() == row) break;
} }

View File

@ -2027,8 +2027,10 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const
int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth; int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i); par->incCounter(i);
int number = par->getCounter(i); int number = par->getCounter(i);
if (!par->bibkey) if (!par->bibkey) {
par->bibkey = new InsetBibKey(); InsetCommandParams p( "bibitem" );
par->bibkey = new InsetBibKey(p);
}
par->bibkey->setCounter(number); par->bibkey->setCounter(number);
par->labelstring = layout.labelstring(); par->labelstring = layout.labelstring();