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)
|
|
|
|
: InsetCommand(p)
|
2000-07-15 23:51:46 +00:00
|
|
|
{}
|
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
string InsetCitation::getScreenLabel() const
|
|
|
|
{
|
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;
|
|
|
|
if( contains( keys, "," ) ) {
|
|
|
|
// Final comma allows while loop to cover all keys
|
|
|
|
keys = frontStrip( split( keys, label, ',' ) ) + ",";
|
2000-06-07 08:53:40 +00:00
|
|
|
|
2000-07-19 08:37:26 +00:00
|
|
|
const int maxSize( 40 );
|
|
|
|
while( contains( keys, "," ) ) {
|
|
|
|
string key;
|
|
|
|
keys = frontStrip( split( keys, key, ',' ) );
|
|
|
|
|
|
|
|
int size = label.size() + 2 + key.size();
|
|
|
|
if( size >= maxSize ) {
|
|
|
|
label += ", ...";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
label += ", " + key;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
label = keys;
|
2000-06-07 08:53:40 +00:00
|
|
|
}
|
|
|
|
|
2000-07-19 08:37:26 +00:00
|
|
|
if( !getOptions().empty() )
|
|
|
|
label += ", " + getOptions();
|
|
|
|
|
|
|
|
return '[' + label + ']';
|
2000-06-07 08:53:40 +00:00
|
|
|
}
|
2000-07-14 07:52:03 +00:00
|
|
|
|
|
|
|
void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
|
|
|
|
{
|
2000-07-19 08:37:26 +00:00
|
|
|
bv->owner()->getDialogs()->showCitation( this );
|
2000-07-14 07:52:03 +00:00
|
|
|
}
|
|
|
|
|