]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
move the validation code from InsetFlex to InsetCollapsable
[lyx.git] / src / insets / InsetCitation.cpp
index 33298c827b4ce738404a019a129216b2452af6b0..859ceba81f4e050b65cb2c9f4c3b78dd3888c0c4 100644 (file)
@@ -84,7 +84,7 @@ string defaultCiteCommand(CiteEngine engine)
        return str;
 }
 
-               
+       
 string asValidLatexCommand(string const & input, CiteEngine const engine)
 {
        string const default_str = defaultCiteCommand(engine);
@@ -94,13 +94,16 @@ string asValidLatexCommand(string const & input, CiteEngine const engine)
        string output;
        switch (engine) {
                case ENGINE_BASIC:
-                       output = input;
+                       if (input == "nocite")
+                               output = input;
+                       else
+                               output = default_str;
                        break;
 
                case ENGINE_NATBIB_AUTHORYEAR:
                case ENGINE_NATBIB_NUMERICAL:
-                       if (input == "cite" || input == "citefield" ||
-                                                       input == "citetitle" || input == "cite*")
+                       if (input == "cite" || input == "citefield"
+                           || input == "citetitle" || input == "cite*")
                                output = default_str;
                        else if (prefixIs(input, "foot"))
                                output = input.substr(4);
@@ -137,37 +140,7 @@ docstring complexLabel(Buffer const & buffer,
        if (!buffer.isFullyLoaded())
                return docstring();
 
-       // Cache the labels
-       typedef map<Buffer const *, BiblioInfo> CachedMap;
-       static CachedMap cached_keys;
-
-       // and cache the timestamp of the bibliography files.
-       static map<FileName, time_t> bibfileStatus;
-
-       BiblioInfo biblist;
-
-       support::FileNameList const & bibfilesCache = buffer.getBibfilesCache();
-       // compare the cached timestamps with the actual ones.
-       bool changed = false;
-       support::FileNameList::const_iterator ei = bibfilesCache.begin();
-       support::FileNameList::const_iterator en = bibfilesCache.end();
-       for (; ei != en; ++ ei) {
-               time_t lastw = ei->lastModified();
-               if (lastw != bibfileStatus[*ei]) {
-                       changed = true;
-                       bibfileStatus[*ei] = lastw;
-               }
-       }
-
-       // build the list only if the bibfiles have been changed
-       if (cached_keys[&buffer].empty() || bibfileStatus.empty() || changed) {
-               biblist.fillWithBibKeys(&buffer);
-               cached_keys[&buffer] = biblist;
-       } else {
-               // use the cached keys
-               biblist = cached_keys[&buffer];
-       }
-
+       BiblioInfo const & biblist = buffer.masterBibInfo();
        if (biblist.empty())
                return docstring();
 
@@ -457,7 +430,7 @@ void InsetCitation::updateLabels(ParIterator const &)
 }
 
 
-void InsetCitation::addToToc(ParConstIterator const & cpit) const
+void InsetCitation::addToToc(DocIterator const & cpit)
 {
        Toc & toc = buffer().tocBackend().toc("citation");
        toc.push_back(TocItem(cpit, 0, cache.screen_label));
@@ -546,4 +519,10 @@ void InsetCitation::validate(LaTeXFeatures & features) const
 }
 
 
+docstring InsetCitation::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-citation");
+}
+
+
 } // namespace lyx