InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p)
: InsetCommand(buf, p)
-{}
+{
+ buffer().removeBiblioTempFiles();
+}
+
+
+InsetCitation::~InsetCitation()
+{
+ if (isBufferLoaded())
+ buffer().removeBiblioTempFiles();
+}
ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */)
void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
{
- if (cmd.action() == LFUN_INSET_MODIFY)
+ if (cmd.action() == LFUN_INSET_MODIFY) {
+ buffer().removeBiblioTempFiles();
cache.recalculate = true;
+ }
InsetCommand::doDispatch(cur, cmd);
}
+bool InsetCitation::addKey(string const & key)
+{
+ docstring const ukey = from_utf8(key);
+ docstring const & curkeys = getParam("key");
+ if (curkeys.empty()) {
+ setParam("key", ukey);
+ cache.recalculate = true;
+ return true;
+ }
+
+ vector<docstring> keys = getVectorFromString(curkeys);
+ vector<docstring>::const_iterator it = keys.begin();
+ vector<docstring>::const_iterator en = keys.end();
+ for (; it != en; ++it) {
+ if (*it == ukey) {
+ LYXERR0("Key " << key << " already present.");
+ return false;
+ }
+ }
+ keys.push_back(ukey);
+ setParam("key", getStringFromVector(keys));
+ cache.recalculate = true;
+ return true;
+}
+
+
docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
{
Buffer const & buf = bv.buffer();
return content;
// we have to do the escaping here, because we will ultimately
// write this as a raw string, so as not to escape the tags.
- return "<a href='#" + key + "'>" +
+ return "<a href='#LyXCite-" + key + "'>" +
html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>";
}