1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
#include <fstream>
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
#include "insetbib.h"
|
|
|
|
#include "buffer.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyx_gui_misc.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "bibforms.h"
|
|
|
|
#include "lyxtext.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
2000-05-17 13:40:40 +00:00
|
|
|
#include "support/path.h"
|
2000-10-03 18:38:10 +00:00
|
|
|
#include "lyxrc.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
2000-05-05 07:54:27 +00:00
|
|
|
using std::ifstream;
|
|
|
|
using std::getline;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
2000-06-07 08:53:40 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::pair;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
FD_bibitem_form * bibitem_form = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
FD_bibitem_form * create_form_bibitem_form(void);
|
|
|
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
extern "C"
|
|
|
|
void bibitem_cb(FL_OBJECT *, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-07-07 07:46:37 +00:00
|
|
|
InsetBibKey::Holder * holder =
|
|
|
|
static_cast<InsetBibKey::Holder*>
|
|
|
|
(bibitem_form->bibitem_form->u_vdata);
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
holder->inset->callback( bibitem_form, data );
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
FD_bibitem_form * create_form_bibitem_form(void)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-07 00:44:53 +00:00
|
|
|
FL_OBJECT * obj;
|
1999-12-16 06:43:25 +00:00
|
|
|
FD_bibitem_form * fdui = (FD_bibitem_form *) fl_calloc(1, sizeof(FD_bibitem_form));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fdui->bibitem_form = fl_bgn_form(FL_NO_BOX, 220, 130);
|
1999-11-15 10:58:38 +00:00
|
|
|
obj = fl_add_box(FL_UP_BOX, 0, 0, 220, 130, "");
|
|
|
|
fdui->key = obj = fl_add_input(FL_NORMAL_INPUT, 80, 10, 130, 30, idex(_("Key:|#K")));
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_set_input_shortcut(obj, scex(_("Key:|#K")), 1);
|
|
|
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
1999-11-15 10:58:38 +00:00
|
|
|
obj = fl_add_button(FL_RETURN_BUTTON, 20, 90, 90, 30, _("OK"));
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
2000-06-07 08:53:40 +00:00
|
|
|
fl_set_object_callback(obj, bibitem_cb, 1);
|
1999-11-15 10:58:38 +00:00
|
|
|
obj = fl_add_button(FL_NORMAL_BUTTON, 120, 90, 90, 30, idex(_("Cancel|^[")));
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
|
|
|
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
2000-06-07 08:53:40 +00:00
|
|
|
fl_set_object_callback(obj, bibitem_cb, 0);
|
1999-11-15 10:58:38 +00:00
|
|
|
fdui->label = obj = fl_add_input(FL_NORMAL_INPUT, 80, 50, 130, 30, idex(_("Label:|#L")));
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_set_input_shortcut(obj, scex(_("Label:|#L")), 1);
|
|
|
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_end_form();
|
|
|
|
|
|
|
|
//fdui->bibitem_form->fdui = fdui;
|
|
|
|
|
|
|
|
return fdui;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetBibKey::InsetBibKey(InsetCommandParams const & p)
|
|
|
|
: InsetCommand(p)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
counter = 1;
|
|
|
|
}
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetBibKey::~InsetBibKey()
|
|
|
|
{
|
|
|
|
if(bibitem_form && bibitem_form->bibitem_form
|
2000-03-20 14:49:54 +00:00
|
|
|
&& bibitem_form->bibitem_form->visible
|
|
|
|
&& bibitem_form->bibitem_form->u_vdata == &holder)
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_hide_form(bibitem_form->bibitem_form);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
|
2000-10-10 11:50:43 +00:00
|
|
|
Inset * InsetBibKey::Clone(Buffer const &) const
|
2000-08-04 13:12:30 +00:00
|
|
|
{
|
|
|
|
InsetBibKey * b = new InsetBibKey(params());
|
|
|
|
b->setCounter(counter);
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
void InsetBibKey::callback( FD_bibitem_form * form, long data )
|
|
|
|
{
|
2000-07-15 23:51:46 +00:00
|
|
|
switch (data) {
|
2000-07-07 07:46:37 +00:00
|
|
|
case 1:
|
2000-07-15 23:51:46 +00:00
|
|
|
if(!holder.view->buffer()->isReadonly()) {
|
2000-07-07 07:46:37 +00:00
|
|
|
setContents(fl_get_input(form->key));
|
|
|
|
setOptions(fl_get_input(form->label));
|
|
|
|
// shouldn't mark the buffer dirty unless
|
|
|
|
// something was actually altered
|
|
|
|
holder.view->updateInset( this, true );
|
|
|
|
} // fall through to Cancel
|
|
|
|
case 0:
|
|
|
|
fl_hide_form(form->bibitem_form);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void InsetBibKey::setCounter(int c)
|
|
|
|
{
|
|
|
|
counter = c;
|
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
if (getCmdName().empty())
|
|
|
|
setCmdName( tostr(counter) );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// I'm sorry but this is still necessary because \bibitem is used also
|
|
|
|
// as a LyX 2.x command, and lyxlex is not enough smart to understand
|
|
|
|
// real LaTeX commands. Yes, that could be fixed, but would be a waste
|
|
|
|
// of time cause LyX3 won't use lyxlex anyway. (ale)
|
2000-06-12 11:27:15 +00:00
|
|
|
void InsetBibKey::Write(Buffer const *, ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-06 02:42:40 +00:00
|
|
|
os << "\\bibitem ";
|
2000-06-07 08:53:40 +00:00
|
|
|
if (! getOptions().empty()) {
|
2000-03-06 02:42:40 +00:00
|
|
|
os << '['
|
2000-06-07 08:53:40 +00:00
|
|
|
<< getOptions() << ']';
|
2000-03-06 02:42:40 +00:00
|
|
|
}
|
|
|
|
os << '{'
|
2000-06-07 08:53:40 +00:00
|
|
|
<< getContents() << "}\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-13 09:38:34 +00:00
|
|
|
// This is necessary here because this is written without begin_inset
|
|
|
|
// This should be changed!!! (Jug)
|
|
|
|
void InsetBibKey::Read(Buffer const *, LyXLex & lex)
|
|
|
|
{
|
|
|
|
string token;
|
|
|
|
|
|
|
|
if (lex.EatLine()) {
|
|
|
|
token = lex.GetString();
|
|
|
|
scanCommand(token);
|
|
|
|
} else
|
|
|
|
lex.printError("InsetCommand: Parse error: `$$Token'");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetBibKey::getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-06-07 08:53:40 +00:00
|
|
|
if (! getOptions().empty())
|
|
|
|
return getOptions();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
return tostr(counter);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
/**
|
1999-09-27 18:44:28 +00:00
|
|
|
The value in "Key:" isn't allways set right after a few bibkey insets have
|
1999-11-22 16:19:48 +00:00
|
|
|
been added/removed. Perhaps the wrong object is deleted/used somewhere
|
|
|
|
upwards?
|
1999-09-27 18:44:28 +00:00
|
|
|
(Joacim 1998-03-04)
|
|
|
|
*/
|
2000-02-25 12:06:15 +00:00
|
|
|
void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-22 00:36:17 +00:00
|
|
|
if(bv->buffer()->isReadonly())
|
|
|
|
WarnReadonly(bv->buffer()->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!bibitem_form) {
|
|
|
|
bibitem_form = create_form_bibitem_form();
|
|
|
|
fl_set_form_atclose(bibitem_form->bibitem_form,
|
1999-10-02 16:21:10 +00:00
|
|
|
CancelCloseBoxCB, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
|
|
holder.inset = this;
|
|
|
|
holder.view = bv;
|
|
|
|
|
|
|
|
bibitem_form->bibitem_form->u_vdata = &holder;
|
1999-09-27 18:44:28 +00:00
|
|
|
// InsetBibtex uses the same form, with different labels
|
|
|
|
fl_set_object_label(bibitem_form->key, idex(_("Key:|#K")));
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_set_button_shortcut(bibitem_form->key, scex(_("Key:|#K")), 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_object_label(bibitem_form->label, idex(_("Label:|#L")));
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_set_button_shortcut(bibitem_form->label, scex(_("Label:|#L")), 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_input(bibitem_form->key, getContents().c_str());
|
|
|
|
fl_set_input(bibitem_form->label, getOptions().c_str());
|
|
|
|
if (bibitem_form->bibitem_form->visible) {
|
|
|
|
fl_raise_form(bibitem_form->bibitem_form);
|
|
|
|
} else {
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_show_form(bibitem_form->bibitem_form, FL_PLACE_MOUSE,
|
1999-09-27 18:44:28 +00:00
|
|
|
FL_FULLBORDER,
|
|
|
|
_("Bibliography item"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
InsetBibtex::InsetBibtex(InsetCommandParams const & p)
|
|
|
|
: InsetCommand(p)
|
2000-07-15 23:51:46 +00:00
|
|
|
{}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-20 14:49:54 +00:00
|
|
|
InsetBibtex::~InsetBibtex()
|
|
|
|
{
|
|
|
|
if(bibitem_form && bibitem_form->bibitem_form
|
|
|
|
&& bibitem_form->bibitem_form->visible
|
|
|
|
&& bibitem_form->bibitem_form->u_vdata == &holder)
|
|
|
|
fl_hide_form(bibitem_form->bibitem_form);
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetBibtex::getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return _("BibTeX Generated References");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-03 09:13:34 +00:00
|
|
|
int InsetBibtex::Latex(Buffer const * buffer, ostream & os,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool /*fragile*/, bool/*fs*/) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-02 02:19:43 +00:00
|
|
|
// If we generate in a temp dir, we might need to give an
|
|
|
|
// absolute path there. This is a bit complicated since we can
|
|
|
|
// have a comma-separated list of bibliographies
|
|
|
|
string adb, db_out;
|
|
|
|
string db_in = getContents();
|
|
|
|
db_in = split(db_in, adb, ',');
|
|
|
|
while(!adb.empty()) {
|
2000-10-03 09:13:34 +00:00
|
|
|
if (!buffer->niceFile &&
|
|
|
|
IsFileReadable(MakeAbsPath(adb, buffer->filepath)+".bib"))
|
|
|
|
adb = MakeAbsPath(adb, buffer->filepath);
|
2000-05-17 13:40:40 +00:00
|
|
|
|
2000-03-02 02:19:43 +00:00
|
|
|
db_out += adb;
|
|
|
|
db_out += ',';
|
|
|
|
db_in= split(db_in, adb,',');
|
|
|
|
}
|
|
|
|
db_out = strip(db_out, ',');
|
|
|
|
// Idem, but simpler
|
|
|
|
string style;
|
2000-10-03 09:13:34 +00:00
|
|
|
if (!buffer->niceFile
|
|
|
|
&& IsFileReadable(MakeAbsPath(getOptions(), buffer->filepath)
|
2000-03-02 02:19:43 +00:00
|
|
|
+ ".bst"))
|
2000-10-03 09:13:34 +00:00
|
|
|
style = MakeAbsPath(getOptions(), buffer->filepath);
|
2000-03-02 02:19:43 +00:00
|
|
|
else
|
|
|
|
style = getOptions();
|
|
|
|
|
|
|
|
os << "\\bibliographystyle{" << style << "}\n"
|
|
|
|
<< "\\bibliography{" << db_out << "}\n";
|
|
|
|
return 2;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This method returns a comma separated list of Bibtex entries
|
2000-10-03 09:13:34 +00:00
|
|
|
vector<pair<string, string> > const InsetBibtex::getKeys(Buffer const * buffer) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-10-03 09:13:34 +00:00
|
|
|
Path p(buffer->filepath);
|
2000-05-17 13:40:40 +00:00
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
vector<pair<string,string> > keys;
|
|
|
|
string tmp;
|
1999-11-24 22:14:46 +00:00
|
|
|
string bibfiles = getContents();
|
|
|
|
bibfiles = split(bibfiles, tmp, ',');
|
1999-09-27 18:44:28 +00:00
|
|
|
while(!tmp.empty()) {
|
2000-05-11 16:12:46 +00:00
|
|
|
string fil = findtexfile(ChangeExtension(tmp, "bib"),
|
1999-11-24 22:14:46 +00:00
|
|
|
"bib");
|
1999-12-22 14:35:05 +00:00
|
|
|
lyxerr[Debug::LATEX] << "Bibfile: " << fil << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
// If we didn't find a matching file name just fail silently
|
1999-11-24 22:14:46 +00:00
|
|
|
if (!fil.empty()) {
|
|
|
|
// This is a _very_ simple parser for Bibtex database
|
|
|
|
// files. All it does is to look for lines starting
|
|
|
|
// in @ and not being @preamble and @string entries.
|
1999-09-27 18:44:28 +00:00
|
|
|
// It does NOT do any syntax checking!
|
1999-11-24 22:14:46 +00:00
|
|
|
ifstream ifs(fil.c_str());
|
2000-06-07 08:53:40 +00:00
|
|
|
string linebuf0;
|
|
|
|
while (getline(ifs, linebuf0)) {
|
|
|
|
string linebuf = frontStrip(strip(linebuf0));
|
|
|
|
if( linebuf.empty() ) continue;
|
1999-11-24 22:14:46 +00:00
|
|
|
if (prefixIs(linebuf, "@")) {
|
|
|
|
linebuf = subst(linebuf, '{', '(');
|
|
|
|
linebuf = split(linebuf, tmp, '(');
|
|
|
|
tmp = lowercase(tmp);
|
|
|
|
if (!prefixIs(tmp, "@string")
|
|
|
|
&& !prefixIs(tmp, "@preamble")) {
|
2000-06-07 08:53:40 +00:00
|
|
|
linebuf = split(linebuf, tmp, ',');
|
|
|
|
tmp = frontStrip(tmp);
|
1999-11-24 22:14:46 +00:00
|
|
|
if (!tmp.empty()) {
|
2000-06-07 08:53:40 +00:00
|
|
|
keys.push_back(pair<string,string>(tmp,string()));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
2000-06-07 08:53:40 +00:00
|
|
|
} else if( !keys.empty() ) {
|
|
|
|
keys.back().second += linebuf + "\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Get next file name
|
1999-11-24 22:14:46 +00:00
|
|
|
bibfiles = split(bibfiles, tmp, ',');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
return keys;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// BibTeX should have its own dialog. This is provisional.
|
2000-03-20 14:49:54 +00:00
|
|
|
void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!bibitem_form) {
|
|
|
|
bibitem_form = create_form_bibitem_form();
|
|
|
|
fl_set_form_atclose(bibitem_form->bibitem_form,
|
1999-10-02 16:21:10 +00:00
|
|
|
CancelCloseBoxCB, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-03-20 14:49:54 +00:00
|
|
|
holder.inset = this;
|
|
|
|
holder.view = bv;
|
|
|
|
bibitem_form->bibitem_form->u_vdata = &holder;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_object_label(bibitem_form->key, _("Database:"));
|
|
|
|
fl_set_object_label(bibitem_form->label, _("Style: "));
|
|
|
|
fl_set_input(bibitem_form->key, getContents().c_str());
|
|
|
|
fl_set_input(bibitem_form->label, getOptions().c_str());
|
|
|
|
if (bibitem_form->bibitem_form->visible) {
|
|
|
|
fl_raise_form(bibitem_form->bibitem_form);
|
|
|
|
} else {
|
1999-11-04 01:40:20 +00:00
|
|
|
fl_show_form(bibitem_form->bibitem_form,
|
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("BibTeX"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
bool InsetBibtex::addDatabase(string const & db)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-07-27 08:55:59 +00:00
|
|
|
string contents(getContents());
|
2000-09-26 13:54:57 +00:00
|
|
|
if (!contains(contents, db)) {
|
2000-07-27 08:55:59 +00:00
|
|
|
if (!contents.empty())
|
|
|
|
contents += ",";
|
|
|
|
setContents(contents + db);
|
1999-09-27 18:44:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
bool InsetBibtex::delDatabase(string const & db)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-09-26 13:54:57 +00:00
|
|
|
if (contains(getContents(), db)) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string bd = db;
|
2000-06-07 08:53:40 +00:00
|
|
|
int n = tokenPos(getContents(), ',', bd);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (n > 0) {
|
1999-10-26 23:33:30 +00:00
|
|
|
// Weird code, would someone care to explain this?(Lgb)
|
1999-11-15 10:58:38 +00:00
|
|
|
string tmp(", ");
|
1999-09-27 18:44:28 +00:00
|
|
|
tmp += bd;
|
2000-09-26 13:54:57 +00:00
|
|
|
setContents(subst(getContents(), tmp, ", "));
|
1999-11-15 10:58:38 +00:00
|
|
|
} else if (n == 0)
|
2000-06-07 08:53:40 +00:00
|
|
|
setContents(split(getContents(), bd, ','));
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
|
2000-07-05 14:57:48 +00:00
|
|
|
int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
|
|
|
int w = 0;
|
|
|
|
// Does look like a hack? It is! (but will change at 0.13)
|
2000-10-03 09:13:34 +00:00
|
|
|
LyXParagraph * par = bv->buffer()->paragraph;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
while (par) {
|
|
|
|
if (par->bibkey) {
|
2000-07-05 14:57:48 +00:00
|
|
|
int wx = par->bibkey->width(bv, font);
|
2000-02-10 17:53:36 +00:00
|
|
|
if (wx > w) w = wx;
|
|
|
|
}
|
|
|
|
par = par->next;
|
|
|
|
}
|
|
|
|
return w;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
// ale070405
|
2000-10-03 18:38:10 +00:00
|
|
|
string const bibitemWidest(Buffer const * buffer)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
|
|
|
int w = 0;
|
|
|
|
// Does look like a hack? It is! (but will change at 0.13)
|
2000-10-03 18:38:10 +00:00
|
|
|
LyXParagraph * par = buffer->paragraph;
|
|
|
|
BufferView * bv = buffer->getUser();
|
2000-02-10 17:53:36 +00:00
|
|
|
InsetBibKey * bkey = 0;
|
|
|
|
LyXFont font;
|
|
|
|
|
|
|
|
while (par) {
|
|
|
|
if (par->bibkey) {
|
2000-07-05 14:57:48 +00:00
|
|
|
int wx = par->bibkey->width(bv, font);
|
2000-02-10 17:53:36 +00:00
|
|
|
if (wx > w) {
|
|
|
|
w = wx;
|
|
|
|
bkey = par->bibkey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
par = par->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bkey && !bkey->getScreenLabel().empty())
|
|
|
|
return bkey->getScreenLabel();
|
|
|
|
|
|
|
|
return "99";
|
|
|
|
}
|