#include "Buffer.h"
#include "BufferParams.h"
-#include "debug.h"
#include "DispatchResult.h"
+#include "support/gettext.h"
+#include "EmbeddedFiles.h"
#include "FuncRequest.h"
#include "LaTeXFeatures.h"
+#include "support/debug.h"
+#include "support/docstream.h"
#include "support/lstrings.h"
#include <algorithm>
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::FileName;
-using support::getStringFromVector;
-using support::getVectorFromString;
-using support::ltrim;
-using support::prefixIs;
-using support::rtrim;
-using support::split;
-using support::tokenPos;
-
-using std::endl;
-using std::string;
-using std::vector;
-
namespace {
vector<string> const init_possible_cite_commands()
{
char const * const possible[] = {
- "cite", "citet", "citep", "citealt", "citealp",
+ "cite", "nocite", "citet", "citep", "citealt", "citealp",
"citeauthor", "citeyear", "citeyearpar",
"citet*", "citep*", "citealt*", "citealp*", "citeauthor*",
"Citet", "Citep", "Citealt", "Citealp", "Citeauthor",
string output;
switch (engine) {
case biblio::ENGINE_BASIC:
- output = default_str;
+ output = input;
break;
case biblio::ENGINE_NATBIB_AUTHORYEAR:
}
-docstring const getNatbibLabel(Buffer const & buffer,
+docstring const getComplexLabel(Buffer const & buffer,
string const & citeType, docstring const & keyList,
docstring const & before, docstring const & after,
biblio::CiteEngine engine)
return docstring();
// Cache the labels
- typedef std::map<Buffer const *, BiblioInfo> CachedMap;
+ typedef map<Buffer const *, BiblioInfo> CachedMap;
static CachedMap cached_keys;
// and cache the timestamp of the bibliography files.
- static std::map<FileName, time_t> bibfileStatus;
+ static map<FileName, time_t> bibfileStatus;
BiblioInfo biblist;
- vector<FileName> const & bibfilesCache = buffer.getBibfilesCache();
+ EmbeddedFileList const & bibfilesCache = buffer.getBibfilesCache();
// compare the cached timestamps with the actual ones.
bool changed = false;
- for (vector<FileName>::const_iterator it = bibfilesCache.begin();
+ for (EmbeddedFileList::const_iterator it = bibfilesCache.begin();
it != bibfilesCache.end(); ++ it) {
FileName const f = *it;
- std::time_t lastw = f.lastModified();
+ time_t lastw = f.lastModified();
if (lastw != bibfileStatus[f]) {
changed = true;
bibfileStatus[f] = lastw;
}
docstring after_str;
- if (!after.empty()) {
- // The "after" key is appended only to the end of the whole.
+ // The "after" key is appended only to the end of the whole.
+ if (cite_type == "nocite")
+ after_str = " (" + _("not cited") + ')';
+ else if (!after.empty()) {
after_str = ", " + after;
}
// One day, these might be tunable (as they are in BibTeX).
- char const op = '('; // opening parenthesis.
- char const cp = ')'; // closing parenthesis.
- // puctuation mark separating citation entries.
- char const * const sep = ";";
+ char op, cp; // opening and closing parenthesis.
+ char * sep; // punctuation mark separating citation entries.
+ if (engine == biblio::ENGINE_BASIC) {
+ op = '[';
+ cp = ']';
+ sep = ",";
+ } else {
+ op = '(';
+ cp = ')';
+ sep = ";";
+ }
docstring const op_str = ' ' + docstring(1, op);
docstring const cp_str = docstring(1, cp) + ' ';
// authors1/<before>; ... ;
// authors_last, <after>
- if (cite_type == "cite" && engine == biblio::ENGINE_JURABIB) {
- if (it == keys.begin())
- label += author + before_str + sep_str;
- else
- label += author + sep_str;
+ if (cite_type == "cite") {
+ if (engine == biblio::ENGINE_BASIC) {
+ label += *it + sep_str;
+ } else if (engine == biblio::ENGINE_JURABIB) {
+ if (it == keys.begin())
+ label += author + before_str + sep_str;
+ else
+ label += author + sep_str;
+ }
+
+ // nocite
+ } else if (cite_type == "nocite") {
+ label += *it + sep_str;
// (authors1 (<before> year); ... ;
// authors_last (<before> year, <after>)
label = before_str + label;
}
- if (cite_type == "citep" || cite_type == "citeyearpar")
+ if (cite_type == "citep" || cite_type == "citeyearpar" ||
+ (cite_type == "cite" && engine == biblio::ENGINE_BASIC) )
label = op + label + cp;
return label;
docstring const getBasicLabel(docstring const & keyList, docstring const & after)
{
- using support::contains;
-
docstring keys = keyList;
docstring label;
{}
-CommandInfo const * InsetCitation::findInfo(std::string const & /* cmdName */)
+CommandInfo const * InsetCitation::findInfo(string const & /* cmdName */)
{
// standard cite does only take one argument if jurabib is
// not used, but jurabib extends this to two arguments, so
}
-bool InsetCitation::isCompatibleCommand(std::string const & cmd)
+bool InsetCitation::isCompatibleCommand(string const & cmd)
{
vector<string> const & possibles = possible_cite_commands();
vector<string>::const_iterator const end = possibles.end();
- return std::find(possibles.begin(), end, cmd) != end;
+ return find(possibles.begin(), end, cmd) != end;
}
docstring label;
biblio::CiteEngine const engine = buffer.params().getEngine();
- if (engine != biblio::ENGINE_BASIC) {
- label = getNatbibLabel(buffer, getCmdName(), getParam("key"),
- before, after, engine);
- }
+ label = getComplexLabel(buffer, getCmdName(), getParam("key"),
+ before, after, engine);
// Fallback to fail-safe
if (label.empty())
int InsetCitation::docbook(Buffer const &, odocstream & os,
OutputParams const &) const
{
- os << "<citation>"
+ os << from_ascii("<citation>")
<< cleanupWhitespace(getParam("key"))
- << "</citation>";
+ << from_ascii("</citation>");
return 0;
}
-int InsetCitation::textString(Buffer const & buf, odocstream & os,
- OutputParams const & op) const
+void InsetCitation::textString(Buffer const & buf, odocstream & os) const
{
- return plaintext(buf, os, op);
+ plaintext(buf, os, OutputParams(0));
}