]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
Cocoa based Qt-4.6 needs to paint every character separately to match metrics computa...
[lyx.git] / src / insets / InsetCitation.cpp
index 5d8d8c9a203c90aacfb9b18ba6a217314b8f198d..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,14 +483,13 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
                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
@@ -540,17 +548,23 @@ docstring InsetCitation::xhtml(XHTMLStream & xs, OutputParams const &) const
 }
 
 
-void InsetCitation::tocString(odocstream & os) const
+void InsetCitation::toString(odocstream & os) const
 {
        plaintext(os, OutputParams(0));
 }
 
 
+void InsetCitation::forToc(docstring & os, size_t) const
+{
+       os += screenLabel();
+}
+
+
 // Have to overwrite the default InsetCommand method in order to check that
 // 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();
@@ -578,8 +592,6 @@ int InsetCitation::latex(odocstream & os, OutputParams const & runparams) const
 
        if (runparams.inulemcmd)
                os << "}";
-
-       return 0;
 }