// reload the bibkey list
std::map<Buffer const *, bool> loading_buffer;
-string const getNatbibLabel(Buffer const * buffer,
+string const getNatbibLabel(Buffer const & buffer,
string const & citeType, string const & keyList,
string const & before, string const & after,
bool numerical)
// Only load the bibkeys once if we're loading up the buffer,
// else load them afresh each time.
- map<Buffer const *, bool>::iterator lit = loading_buffer.find(buffer);
+ map<Buffer const *, bool>::iterator lit = loading_buffer.find(&buffer);
if (lit == loading_buffer.end())
- loading_buffer[buffer] = true;
+ loading_buffer[&buffer] = true;
- bool loadkeys = !loading_buffer[buffer];
+ bool loadkeys = !loading_buffer[&buffer];
if (!loadkeys) {
- CachedMap::iterator kit = cached_keys.find(buffer);
+ CachedMap::iterator kit = cached_keys.find(&buffer);
loadkeys = kit == cached_keys.end();
}
// build the keylist
typedef vector<std::pair<string, string> > InfoType;
InfoType bibkeys;
- buffer->fillWithBibKeys(bibkeys);
+ buffer.fillWithBibKeys(bibkeys);
InfoType::const_iterator bit = bibkeys.begin();
InfoType::const_iterator bend = bibkeys.end();
if (infomap.empty())
return string();
- cached_keys[buffer] = infomap;
+ cached_keys[&buffer] = infomap;
}
- biblio::InfoMap infomap = cached_keys[buffer];
+ biblio::InfoMap infomap = cached_keys[&buffer];
// the natbib citation-styles
// CITET: author (year)
}
-string const InsetCitation::generateLabel(Buffer const * buffer) const
+string const InsetCitation::generateLabel(Buffer const & buffer) const
{
string const before = string();
string const after = getOptions();
string label;
- if (buffer->params.use_natbib) {
+ if (buffer.params.use_natbib) {
string cmd = getCmdName();
if (cmd == "cite") {
// We may be "upgrading" from an older LyX version.
// author/year info is not present in the biblio
// database, then getNatbibLabel will exit gracefully
// and we'll call getBasicLabel.
- if (buffer->params.use_numerical_citations)
+ if (buffer.params.use_numerical_citations)
cmd = "citep";
else
cmd = "citet";
}
label = getNatbibLabel(buffer, cmd, getContents(),
before, after,
- buffer->params.use_numerical_citations);
+ buffer.params.use_numerical_citations);
}
// Fallback to fail-safe
}
-InsetCitation::Cache::Style InsetCitation::getStyle(Buffer const * buffer) const
+InsetCitation::Cache::Style InsetCitation::getStyle(Buffer const & buffer) const
{
Cache::Style style = Cache::BASIC;
- if (buffer->params.use_natbib) {
- if (buffer->params.use_numerical_citations) {
+ if (buffer.params.use_natbib) {
+ if (buffer.params.use_numerical_citations) {
style = Cache::NATBIB_NUM;
} else {
style = Cache::NATBIB_AY;
}
-string const InsetCitation::getScreenLabel(Buffer const * buffer) const
+string const InsetCitation::getScreenLabel(Buffer const & buffer) const
{
Cache::Style const style = getStyle(buffer);
if (cache.params == params() && cache.style == style)
}
-void InsetCitation::setLoadingBuffer(Buffer const * buffer, bool state) const
+void InsetCitation::setLoadingBuffer(Buffer const & buffer, bool state) const
{
// Doesn't matter if there is no bv->buffer() entry in the map.
- loading_buffer[buffer] = state;
+ loading_buffer[&buffer] = state;
}
case LFUN_INSET_EDIT:
// A call to edit indicates that we're no longer loading the
// buffer but doing some real work.
- setLoadingBuffer(cmd.view()->buffer(), false);
+ setLoadingBuffer(*cmd.view()->buffer(), false);
InsetCommandMailer("citation", *this).showDialog(cmd.view());
return DISPATCHED;
}
-int InsetCitation::ascii(Buffer const * buffer, ostream & os, int) const
+int InsetCitation::ascii(Buffer const & buffer, ostream & os, int) const
{
if (cache.params == params() && cache.style == getStyle(buffer))
os << cache.generated_label;
// 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(Buffer const * buffer, ostream & os,
+int InsetCitation::latex(Buffer const & buffer, ostream & os,
LatexRunParams const &) const
{
os << "\\";
- if (buffer->params.use_natbib)
+ if (buffer.params.use_natbib)
os << getCmdName();
else
os << "cite";
string const before = string();
string const after = getOptions();
- if (!before.empty() && buffer->params.use_natbib)
+ if (!before.empty() && buffer.params.use_natbib)
os << '[' << before << "][" << after << ']';
else if (!after.empty())
os << '[' << after << ']';