2003-02-21 09:20:18 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetBibitem.cpp
|
2003-02-21 09:20:18 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-21 09:20:18 +00:00
|
|
|
*/
|
2003-10-21 16:15:14 +00:00
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
#include <config.h>
|
2008-03-17 21:11:17 +00:00
|
|
|
#include <algorithm>
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetBibitem.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2008-03-04 06:41:47 +00:00
|
|
|
#include "BiblioInfo.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
2010-10-31 01:04:03 +00:00
|
|
|
#include "Cursor.h"
|
2008-03-04 06:41:47 +00:00
|
|
|
#include "buffer_funcs.h"
|
2007-08-16 11:12:56 +00:00
|
|
|
#include "BufferParams.h"
|
2006-10-09 14:21:11 +00:00
|
|
|
#include "BufferView.h"
|
2007-08-16 11:12:56 +00:00
|
|
|
#include "Counters.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
2010-02-12 16:08:30 +00:00
|
|
|
#include "Encoding.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2007-08-14 16:50:51 +00:00
|
|
|
#include "InsetIterator.h"
|
2007-10-24 15:32:43 +00:00
|
|
|
#include "InsetList.h"
|
2011-12-03 22:15:11 +00:00
|
|
|
#include "Language.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2009-06-11 20:08:39 +00:00
|
|
|
#include "output_xhtml.h"
|
2010-02-12 16:08:30 +00:00
|
|
|
#include "OutputParams.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Paragraph.h"
|
2006-03-23 20:11:06 +00:00
|
|
|
#include "ParagraphList.h"
|
2009-07-12 20:09:53 +00:00
|
|
|
#include "ParIterator.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2008-03-04 06:41:47 +00:00
|
|
|
#include "frontends/alert.h"
|
|
|
|
|
2008-06-18 18:54:31 +00:00
|
|
|
#include "support/convert.h"
|
2010-02-12 16:08:30 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/docstream.h"
|
2008-03-04 06:41:47 +00:00
|
|
|
#include "support/gettext.h"
|
2008-06-18 18:54:31 +00:00
|
|
|
#include "support/lstrings.h"
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
using namespace std;
|
2007-12-12 19:57:42 +00:00
|
|
|
using namespace lyx::support;
|
2007-12-12 19:28:07 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2013-10-07 22:59:05 +00:00
|
|
|
// FIXME THREAD
|
2003-02-21 09:20:18 +00:00
|
|
|
int InsetBibitem::key_counter = 0;
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const key_prefix = from_ascii("key-");
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
|
2010-10-29 00:46:21 +00:00
|
|
|
: InsetCommand(buf, p)
|
2003-02-21 09:20:18 +00:00
|
|
|
{
|
2010-08-10 14:28:24 +00:00
|
|
|
buffer().invalidateBibinfoCache();
|
2006-10-20 16:12:49 +00:00
|
|
|
if (getParam("key").empty())
|
|
|
|
setParam("key", key_prefix + convert<docstring>(++key_counter));
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
More cache fixing. Similar fix as for InsetBibtex, and I've renamed the key routine.
Unfortunately, we can't do a one-short fix for InsetCommand, requiring that it take
a Buffer & in the constructor, due to problems in mathed, specifically, here:
void InsetMathHull::label(row_type row, docstring const & label)
{
...
label_[row] = new InsetLabel(p);
if (buffer_)
label_[row]->setBuffer(buffer());
}
If InsetLabel has to have a Buffer, then buffer_ has to be set, which means InsetMathHull needs a Buffer. But then truckloads of these are created in Parser, where we don't really seem to have access to a Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25137 a592a061-630c-0410-9148-cb99ea01b6c8
2008-06-05 06:55:34 +00:00
|
|
|
InsetBibitem::~InsetBibitem()
|
|
|
|
{
|
2010-03-08 18:57:42 +00:00
|
|
|
if (isBufferLoaded())
|
2010-08-10 14:28:24 +00:00
|
|
|
buffer().invalidateBibinfoCache();
|
More cache fixing. Similar fix as for InsetBibtex, and I've renamed the key routine.
Unfortunately, we can't do a one-short fix for InsetCommand, requiring that it take
a Buffer & in the constructor, due to problems in mathed, specifically, here:
void InsetMathHull::label(row_type row, docstring const & label)
{
...
label_[row] = new InsetLabel(p);
if (buffer_)
label_[row]->setBuffer(buffer());
}
If InsetLabel has to have a Buffer, then buffer_ has to be set, which means InsetMathHull needs a Buffer. But then truckloads of these are created in Parser, where we don't really seem to have access to a Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25137 a592a061-630c-0410-9148-cb99ea01b6c8
2008-06-05 06:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-04 06:41:47 +00:00
|
|
|
void InsetBibitem::initView()
|
|
|
|
{
|
|
|
|
updateCommand(getParam("key"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetBibitem::updateCommand(docstring const & new_key, bool)
|
|
|
|
{
|
|
|
|
docstring key = new_key;
|
|
|
|
|
2008-04-25 20:03:03 +00:00
|
|
|
vector<docstring> bibkeys = buffer().masterBibInfo().getKeys();
|
2008-03-04 06:41:47 +00:00
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
|
|
if (find(bibkeys.begin(), bibkeys.end(), key) != bibkeys.end()) {
|
|
|
|
// generate unique label
|
|
|
|
key = new_key + '-' + convert<docstring>(i);
|
|
|
|
while (find(bibkeys.begin(), bibkeys.end(), key) != bibkeys.end()) {
|
|
|
|
++i;
|
|
|
|
key = new_key + '-' + convert<docstring>(i);
|
|
|
|
}
|
|
|
|
frontend::Alert::warning(_("Keys must be unique!"),
|
|
|
|
bformat(_("The key %1$s already exists,\n"
|
|
|
|
"it will be changed to %2$s."), new_key, key));
|
|
|
|
}
|
|
|
|
setParam("key", key);
|
2010-08-10 14:28:24 +00:00
|
|
|
buffer().invalidateBibinfoCache();
|
2008-03-04 06:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamInfo const & InsetBibitem::findInfo(string const & /* cmdName */)
|
2007-10-25 04:13:56 +00:00
|
|
|
{
|
2008-02-23 22:01:02 +00:00
|
|
|
static ParamInfo param_info_;
|
|
|
|
if (param_info_.empty()) {
|
2010-02-13 13:08:32 +00:00
|
|
|
param_info_.add("label", ParamInfo::LATEX_OPTIONAL,
|
|
|
|
ParamInfo::HANDLING_LATEXIFY);
|
|
|
|
param_info_.add("key", ParamInfo::LATEX_REQUIRED,
|
|
|
|
ParamInfo::HANDLING_ESCAPE);
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
return param_info_;
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2003-02-26 19:28:38 +00:00
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2003-05-16 07:44:00 +00:00
|
|
|
|
2003-03-07 21:44:48 +00:00
|
|
|
case LFUN_INSET_MODIFY: {
|
2007-10-19 17:22:55 +00:00
|
|
|
InsetCommandParams p(BIBITEM_CODE);
|
2010-10-29 00:25:28 +00:00
|
|
|
InsetCommand::string2params(to_utf8(cmd.argument()), p);
|
2006-10-09 14:21:11 +00:00
|
|
|
if (p.getCmdName().empty()) {
|
2010-07-08 20:04:35 +00:00
|
|
|
cur.noScreenUpdate();
|
2006-10-09 14:21:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-12-08 09:24:04 +00:00
|
|
|
|
|
|
|
cur.recordUndo();
|
|
|
|
|
2008-08-10 20:32:51 +00:00
|
|
|
docstring const & old_key = params()["key"];
|
2010-10-09 16:02:19 +00:00
|
|
|
docstring const & old_label = params()["label"];
|
|
|
|
docstring label = p["label"];
|
|
|
|
|
|
|
|
// definitions for escaping
|
|
|
|
int previous;
|
|
|
|
static docstring const backslash = from_ascii("\\");
|
|
|
|
static docstring const lbrace = from_ascii("{");
|
|
|
|
static docstring const rbrace = from_ascii("}");
|
|
|
|
static char_type const chars_escape[6] = {
|
|
|
|
'&', '_', '$', '%', '#', '^'};
|
|
|
|
static char_type const brackets_escape[2] = {'[', ']'};
|
|
|
|
|
|
|
|
if (!label.empty()) {
|
|
|
|
// The characters in chars_name[] need to be changed to a command when
|
|
|
|
// they are in the name field.
|
|
|
|
for (int k = 0; k < 6; k++)
|
|
|
|
for (size_t i = 0, pos;
|
|
|
|
(pos = label.find(chars_escape[k], i)) != string::npos;
|
|
|
|
i = pos + 2) {
|
|
|
|
if (pos == 0)
|
|
|
|
previous = 0;
|
|
|
|
else
|
|
|
|
previous = pos - 1;
|
|
|
|
// only if not already escaped
|
|
|
|
if (label[previous] != '\\')
|
|
|
|
label.replace(pos, 1, backslash + chars_escape[k] + lbrace + rbrace);
|
|
|
|
}
|
|
|
|
// The characters '[' and ']' need to be put into braces
|
|
|
|
for (int k = 0; k < 2; k++)
|
|
|
|
for (size_t i = 0, pos;
|
|
|
|
(pos = label.find(brackets_escape[k], i)) != string::npos;
|
|
|
|
i = pos + 2) {
|
|
|
|
if (pos == 0)
|
|
|
|
previous = 0;
|
|
|
|
else
|
|
|
|
previous = pos - 1;
|
|
|
|
// only if not already escaped
|
|
|
|
if (label[previous] != '{')
|
|
|
|
label.replace(pos, 1, lbrace + brackets_escape[k] + rbrace);
|
|
|
|
}
|
2011-12-03 22:24:30 +00:00
|
|
|
}
|
2010-10-09 16:02:19 +00:00
|
|
|
|
2011-12-03 22:24:30 +00:00
|
|
|
if (old_label != label) {
|
|
|
|
p["label"] = label;
|
|
|
|
cur.forceBufferUpdate();
|
|
|
|
buffer().invalidateBibinfoCache();
|
2010-10-09 16:02:19 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 06:41:47 +00:00
|
|
|
setParam("label", p["label"]);
|
2008-08-10 20:32:51 +00:00
|
|
|
if (p["key"] != old_key) {
|
2008-07-14 12:49:39 +00:00
|
|
|
updateCommand(p["key"]);
|
2013-04-06 16:34:26 +00:00
|
|
|
cur.bv().buffer().changeRefsIfUnique(old_key, params()["key"]);
|
2010-07-09 14:37:00 +00:00
|
|
|
cur.forceBufferUpdate();
|
2010-08-10 14:28:24 +00:00
|
|
|
buffer().invalidateBibinfoCache();
|
2008-07-14 12:49:39 +00:00
|
|
|
}
|
2008-03-04 07:33:43 +00:00
|
|
|
break;
|
2003-03-07 21:44:48 +00:00
|
|
|
}
|
2003-05-16 07:44:00 +00:00
|
|
|
|
2003-03-07 21:44:48 +00:00
|
|
|
default:
|
2004-11-24 21:58:42 +00:00
|
|
|
InsetCommand::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
break;
|
2003-02-26 19:28:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetBibitem::read(Lexer & lex)
|
2003-02-21 09:20:18 +00:00
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
InsetCommand::read(lex);
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2007-12-12 19:57:42 +00:00
|
|
|
if (prefixIs(getParam("key"), key_prefix)) {
|
2006-10-20 16:12:49 +00:00
|
|
|
int const key = convert<int>(getParam("key").substr(key_prefix.length()));
|
2007-12-12 19:28:07 +00:00
|
|
|
key_counter = max(key_counter, key);
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring InsetBibitem::bibLabel() const
|
2003-02-21 09:20:18 +00:00
|
|
|
{
|
2013-05-14 19:50:13 +00:00
|
|
|
BufferParams const & bp = buffer().masterBuffer()->params();
|
|
|
|
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
|
|
|
return autolabel_;
|
2006-10-20 16:12:49 +00:00
|
|
|
docstring const & label = getParam("label");
|
2007-08-16 11:12:56 +00:00
|
|
|
return label.empty() ? autolabel_ : label;
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring InsetBibitem::screenLabel() const
|
2003-02-21 09:20:18 +00:00
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
return getParam("key") + " [" + bibLabel() + ']';
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetBibitem::plaintext(odocstringstream & os,
|
2013-04-08 13:18:04 +00:00
|
|
|
OutputParams const &, size_t) const
|
2004-08-14 18:41:27 +00:00
|
|
|
{
|
2007-02-17 16:36:45 +00:00
|
|
|
odocstringstream oss;
|
2008-02-27 20:43:16 +00:00
|
|
|
oss << '[' << bibLabel() << "] ";
|
2007-02-17 16:36:45 +00:00
|
|
|
|
|
|
|
docstring const str = oss.str();
|
|
|
|
os << str;
|
|
|
|
|
|
|
|
return str.size();
|
2004-08-14 18:41:27 +00:00
|
|
|
}
|
2003-02-21 09:20:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ale070405
|
2010-02-12 16:08:30 +00:00
|
|
|
docstring bibitemWidest(Buffer const & buffer, OutputParams const & runparams)
|
2003-02-21 09:20:18 +00:00
|
|
|
{
|
2013-05-14 19:51:05 +00:00
|
|
|
BufferParams const & bp = buffer.masterBuffer()->params();
|
|
|
|
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
|
|
|
return from_ascii("99");
|
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
int w = 0;
|
|
|
|
|
2003-05-27 22:41:04 +00:00
|
|
|
InsetBibitem const * bitem = 0;
|
2006-10-14 15:31:50 +00:00
|
|
|
|
2006-10-14 15:22:08 +00:00
|
|
|
// FIXME: this font is used unitialized for now but should be set to
|
2006-10-14 15:31:50 +00:00
|
|
|
// a proportional font. Here is what Georg Baum has to say about it:
|
2006-10-14 15:22:08 +00:00
|
|
|
/*
|
2007-05-28 22:27:45 +00:00
|
|
|
bibitemWidest() is supposed to find the bibitem with the widest label in the
|
|
|
|
output, because that is needed as an argument of the bibliography
|
2009-05-19 21:29:30 +00:00
|
|
|
environment to determine the correct indentation. To be 100% correct we
|
2007-05-28 22:27:45 +00:00
|
|
|
would need the metrics of the font that is used in the output, but usually
|
2006-10-14 15:22:08 +00:00
|
|
|
we don't have access to these.
|
2007-05-28 22:27:45 +00:00
|
|
|
In practice, any proportional font is probably good enough, since we don't
|
|
|
|
need to know the final with, we only need to know the which label is the
|
2006-10-14 15:22:08 +00:00
|
|
|
widest.
|
2007-05-28 22:27:45 +00:00
|
|
|
Unless there is an easy way to get the metrics of the output font I suggest
|
2006-10-14 15:22:08 +00:00
|
|
|
to use a hardcoded font like "Times" or so.
|
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
It is very important that the result of this function is the same both with
|
|
|
|
and without GUI. After thinking about this it is clear that no Font
|
|
|
|
metrics should be used here, since these come from the gui. If we can't
|
2007-10-28 18:51:54 +00:00
|
|
|
easily get the LaTeX font metrics we should make our own poor mans font
|
2007-05-28 22:27:45 +00:00
|
|
|
metrics replacement, e.g. by hardcoding the metrics of the standard TeX
|
2006-10-14 15:22:08 +00:00
|
|
|
font.
|
|
|
|
*/
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2009-05-23 05:59:44 +00:00
|
|
|
docstring lbl;
|
|
|
|
|
2003-09-09 09:47:59 +00:00
|
|
|
ParagraphList::const_iterator it = buffer.paragraphs().begin();
|
|
|
|
ParagraphList::const_iterator end = buffer.paragraphs().end();
|
2003-05-28 06:47:15 +00:00
|
|
|
|
2003-02-21 09:20:18 +00:00
|
|
|
for (; it != end; ++it) {
|
2007-10-24 15:32:43 +00:00
|
|
|
if (it->insetList().empty())
|
|
|
|
continue;
|
|
|
|
Inset * inset = it->insetList().begin()->inset;
|
|
|
|
if (inset->lyxCode() != BIBITEM_CODE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bitem = static_cast<InsetBibitem const *>(inset);
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring const label = bitem->bibLabel();
|
2007-10-24 15:32:43 +00:00
|
|
|
|
|
|
|
// FIXME: we can't be sure using the following that the GUI
|
|
|
|
// version and the command-line version will give the same
|
|
|
|
// result.
|
|
|
|
//
|
|
|
|
//int const wx = use_gui?
|
|
|
|
// theFontMetrics(font).width(label): label.size();
|
|
|
|
//
|
|
|
|
// So for now we just use the label size in order to be sure
|
|
|
|
// that GUI and no-GUI gives the same bibitem (even if that is
|
|
|
|
// potentially the wrong one.
|
|
|
|
int const wx = label.size();
|
|
|
|
|
2009-05-23 05:59:44 +00:00
|
|
|
if (wx > w) {
|
2007-10-24 15:32:43 +00:00
|
|
|
w = wx;
|
2009-05-23 05:59:44 +00:00
|
|
|
lbl = label;
|
|
|
|
}
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 16:08:30 +00:00
|
|
|
if (!lbl.empty()) {
|
2012-06-30 11:30:48 +00:00
|
|
|
pair<docstring, docstring> latex_lbl =
|
|
|
|
runparams.encoding->latexString(lbl, runparams.dryrun);
|
|
|
|
return latex_lbl.first;
|
2010-02-12 16:08:30 +00:00
|
|
|
}
|
2003-02-21 09:20:18 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
return from_ascii("99");
|
2003-02-21 09:20:18 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2010-12-03 20:08:04 +00:00
|
|
|
void InsetBibitem::collectBibKeys(InsetIterator const & it) const
|
2007-08-14 16:50:51 +00:00
|
|
|
{
|
2007-08-20 16:30:02 +00:00
|
|
|
docstring const key = getParam("key");
|
2012-03-01 00:41:30 +00:00
|
|
|
docstring const label = getParam("label");
|
2008-02-14 05:00:54 +00:00
|
|
|
BibTeXInfo keyvalmap(false);
|
2012-03-01 00:41:30 +00:00
|
|
|
keyvalmap.key(key);
|
|
|
|
keyvalmap.label(label);
|
2013-05-14 19:50:13 +00:00
|
|
|
|
|
|
|
BufferParams const & bp = buffer().masterBuffer()->params();
|
|
|
|
Counters & counters = bp.documentClass().counters();
|
|
|
|
docstring const bibitem = from_ascii("bibitem");
|
|
|
|
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) {
|
|
|
|
if (counters.hasCounter(bibitem))
|
|
|
|
counters.step(bibitem, InternalUpdate);
|
|
|
|
string const & lang = it.paragraph().getParLanguage(bp)->code();
|
|
|
|
keyvalmap.setCiteNumber(counters.theCounter(bibitem, lang));
|
|
|
|
}
|
|
|
|
|
2011-12-03 22:15:11 +00:00
|
|
|
DocIterator doc_it(it);
|
2007-08-14 16:50:51 +00:00
|
|
|
doc_it.forwardPos();
|
2011-12-03 22:24:38 +00:00
|
|
|
keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString(
|
|
|
|
AS_STR_INSETS | AS_STR_SKIPDELETE);
|
2010-12-03 20:08:04 +00:00
|
|
|
buffer().addBibTeXInfo(key, keyvalmap);
|
2007-08-14 16:50:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 11:12:56 +00:00
|
|
|
|
2009-06-11 20:08:39 +00:00
|
|
|
// Update the counters of this inset and of its contents
|
2010-03-03 22:13:45 +00:00
|
|
|
void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
|
2007-08-16 11:12:56 +00:00
|
|
|
{
|
2009-07-12 20:09:53 +00:00
|
|
|
BufferParams const & bp = buffer().masterBuffer()->params();
|
|
|
|
Counters & counters = bp.documentClass().counters();
|
2007-08-16 11:12:56 +00:00
|
|
|
docstring const bibitem = from_ascii("bibitem");
|
2013-05-14 19:50:13 +00:00
|
|
|
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) {
|
2010-11-29 19:11:38 +00:00
|
|
|
if (counters.hasCounter(bibitem))
|
|
|
|
counters.step(bibitem, utype);
|
2009-07-12 20:09:53 +00:00
|
|
|
string const & lang = it.paragraph().getParLanguage(bp)->code();
|
|
|
|
autolabel_ = counters.theCounter(bibitem, lang);
|
2008-02-27 20:43:16 +00:00
|
|
|
} else {
|
2007-08-16 11:12:56 +00:00
|
|
|
autolabel_ = from_ascii("??");
|
2008-02-27 20:43:16 +00:00
|
|
|
}
|
2007-08-16 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-30 22:28:54 +00:00
|
|
|
docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const
|
2009-06-11 20:08:39 +00:00
|
|
|
{
|
2009-11-30 22:28:54 +00:00
|
|
|
// FIXME XHTML
|
|
|
|
// XHTML 1.1 doesn't have the "name" attribute for <a>, so we have to use
|
|
|
|
// the "id" atttribute to get the document to validate. Probably, we will
|
|
|
|
// need to use "name" anyway, eventually, because some browsers do not
|
|
|
|
// handle jumping to ids. If we don't do that, though, we can just put the
|
|
|
|
// id into the span tag.
|
2013-02-04 16:51:59 +00:00
|
|
|
string const attrs =
|
2012-05-14 12:29:17 +00:00
|
|
|
"id='LyXCite-" + to_utf8(html::cleanAttr(getParam("key"))) + "'";
|
2010-01-19 22:08:04 +00:00
|
|
|
xs << html::CompTag("a", attrs);
|
|
|
|
xs << html::StartTag("span", "class='bibitemlabel'");
|
2009-11-30 22:28:54 +00:00
|
|
|
xs << bibLabel();
|
2010-01-19 22:08:04 +00:00
|
|
|
xs << html::EndTag("span");
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-11 20:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|