2000-07-07 07:46:37 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
2000-06-07 08:53:40 +00:00
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
#include <config.h>
|
2000-06-07 08:53:40 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetcite.h"
|
2000-07-14 07:52:03 +00:00
|
|
|
#include "BufferView.h"
|
2000-08-01 17:33:32 +00:00
|
|
|
#include "LyXView.h"
|
2000-07-14 07:52:03 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
2000-07-19 08:37:26 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCitation::InsetCitation(InsetCommandParams const & p)
|
2000-08-03 12:56:25 +00:00
|
|
|
: InsetCommand(p)
|
2000-07-15 23:51:46 +00:00
|
|
|
{}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetCitation::getScreenLabel() const
|
2000-06-07 08:53:40 +00:00
|
|
|
{
|
2000-07-19 08:37:26 +00:00
|
|
|
string keys(getContents());
|
|
|
|
|
|
|
|
// If keys is "too long" then only print out the first few tokens
|
|
|
|
string label;
|
2000-09-27 18:13:30 +00:00
|
|
|
if (contains(keys, ",")) {
|
2000-07-19 08:37:26 +00:00
|
|
|
// Final comma allows while loop to cover all keys
|
2000-09-27 18:13:30 +00:00
|
|
|
keys = frontStrip(split(keys, label, ',')) + ",";
|
2000-06-07 08:53:40 +00:00
|
|
|
|
2000-10-17 09:14:34 +00:00
|
|
|
string::size_type const maxSize = 40;
|
2000-09-27 18:13:30 +00:00
|
|
|
while (contains( keys, "," )) {
|
2000-07-19 08:37:26 +00:00
|
|
|
string key;
|
2000-09-27 18:13:30 +00:00
|
|
|
keys = frontStrip(split(keys, key, ','));
|
2000-07-19 08:37:26 +00:00
|
|
|
|
2000-10-17 09:14:34 +00:00
|
|
|
string::size_type size = label.size() + 2 + key.size();
|
2000-11-04 10:00:12 +00:00
|
|
|
if (size >= maxSize) {
|
2000-07-19 08:37:26 +00:00
|
|
|
label += ", ...";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
label += ", " + key;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
label = keys;
|
2000-06-07 08:53:40 +00:00
|
|
|
}
|
|
|
|
|
2000-09-27 18:13:30 +00:00
|
|
|
if (!getOptions().empty())
|
2000-07-19 08:37:26 +00:00
|
|
|
label += ", " + getOptions();
|
|
|
|
|
2000-10-03 18:38:10 +00:00
|
|
|
return "[" + label + "]";
|
2000-06-07 08:53:40 +00:00
|
|
|
}
|
2000-07-14 07:52:03 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2000-07-14 07:52:03 +00:00
|
|
|
void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
|
|
|
|
{
|
2000-09-27 18:13:30 +00:00
|
|
|
bv->owner()->getDialogs()->showCitation(this);
|
2000-07-14 07:52:03 +00:00
|
|
|
}
|
|
|
|
|
2001-05-27 17:51:16 +00:00
|
|
|
|
2001-05-29 12:40:26 +00:00
|
|
|
int InsetCitation::Ascii(Buffer const *, std::ostream & os, int) const
|
2001-05-27 17:51:16 +00:00
|
|
|
{
|
|
|
|
os << "[" << getContents() << "]";
|
|
|
|
return 0;
|
|
|
|
}
|