]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
Fix a couple unused variable warnings.
[lyx.git] / src / insets / InsetCitation.cpp
index 8a427c66efb2852af6401abae965bc7576ac829f..6f9035c5b9f4606d07f8323428d7beb0587cbef7 100644 (file)
@@ -19,6 +19,8 @@
 #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"
@@ -99,6 +101,14 @@ bool InsetCitation::isCompatibleCommand(string const & cmd)
 }
 
 
+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();
@@ -459,11 +469,10 @@ docstring InsetCitation::screenLabel() const
 
 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;
@@ -474,8 +483,7 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
                label += "...";
        }
 
-       cache.engine  = engine;
-       cache.params = params();
+       cache.recalculate = false;
        cache.generated_label = glabel;
        cache.screen_label = label;
 }
@@ -556,7 +564,7 @@ void InsetCitation::forToc(docstring & os, size_t) const
 // 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(otexstream & 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();
@@ -584,8 +592,6 @@ int InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
 
        if (runparams.inulemcmd)
                os << "}";
-
-       return 0;
 }