#include "BufferParams.h"
#include "BufferView.h"
#include "DispatchResult.h"
+#include "FuncCode.h"
+#include "FuncRequest.h"
#include "LaTeXFeatures.h"
#include "output_xhtml.h"
#include "ParIterator.h"
}
+void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ if (cmd.action() == LFUN_INSET_MODIFY)
+ cache.recalculate = true;
+ InsetCommand::doDispatch(cur, cmd);
+}
+
+
docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
{
Buffer const & buf = bv.buffer();
namespace {
-
+
// FIXME See the header for the issue.
string defaultCiteCommand(CiteEngine engine)
{
return str;
}
-
+
string asValidLatexCommand(string const & input, CiteEngine const engine)
{
string const default_str = defaultCiteCommand(engine);
}
-inline docstring wrapCitation(docstring const & key,
+inline docstring wrapCitation(docstring const & key,
docstring const & content, bool for_xhtml)
{
if (!for_xhtml)
else
label += wrapCitation(*it, author, for_xhtml) + sep_str;
}
- }
+ }
// nocite
else if (cite_type == "nocite") {
label += *it + sep_str;
- }
+ }
// (authors1 (<before> year); ... ;
// authors_last (<before> year, <after>)
else if (cite_type == "citet") {
case ENGINE_BASIC:
break;
}
- }
- // author, year; author, year; ...
+ }
+ // author, year; author, year; ...
else if (cite_type == "citep" ||
cite_type == "citealp") {
if (engine == ENGINE_NATBIB_NUMERICAL) {
label += wrapCitation(*it, author + ", " + year, for_xhtml) + sep_str;
}
- }
+ }
// (authors1 <before> year;
// authors_last <before> year, <after>)
else if (cite_type == "citealt") {
wrapCitation(*it, citenum, for_xhtml) + sep_str;
break;
case ENGINE_JURABIB:
- label += before_str +
+ label += before_str +
wrapCitation(*it, author + ' ' + year, for_xhtml) + sep_str;
break;
case ENGINE_BASIC:
break;
}
-
- }
+
+ }
// author; author; ...
else if (cite_type == "citeauthor") {
label += wrapCitation(*it, author, for_xhtml) + sep_str;
label = before_str + label;
}
- if (cite_type == "citep" || cite_type == "citeyearpar" ||
+ if (cite_type == "citep" || cite_type == "citeyearpar" ||
(cite_type == "cite" && engine == ENGINE_BASIC) )
label = op + label + cp;
void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
{
- CiteEngine const engine = buffer().params().citeEngine();
- if (cache.params == params() && cache.engine == engine)
+ if (!cache.recalculate && buffer().citeLabelsValid())
return;
- // The label has changed, so we have to re-create it.
+ // The label may have changed, so we have to re-create it.
docstring const glabel = generateLabel();
unsigned int const maxLabelChars = 45;
label += "...";
}
- cache.engine = engine;
- cache.params = params();
+ cache.recalculate = false;
cache.generated_label = glabel;
cache.screen_label = label;
}
-void InsetCitation::addToToc(DocIterator const & cpit)
+void InsetCitation::addToToc(DocIterator const & cpit) const
{
// NOTE
// XHTML output uses the TOC to collect the citations
// the \cite command is valid. Eg, the user has natbib enabled, inputs some
// citations and then changes his mind, turning natbib support off. The output
// should revert to \cite[]{}
-int InsetCitation::latex(odocstream & os, OutputParams const & runparams) const
+void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
{
CiteEngine cite_engine = buffer().params().citeEngine();
BiblioInfo const & bi = buffer().masterBibInfo();
if (runparams.inulemcmd)
os << "}";
-
- return 0;
}
}
-docstring InsetCitation::contextMenuName() const
+string InsetCitation::contextMenuName() const
{
- return from_ascii("context-citation");
+ return "context-citation";
}