]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
prepare Qt 5.6 builds
[lyx.git] / src / insets / InsetCitation.cpp
index b7aac592c4d9428a293a2936b3a13de0d33ade0c..4bf6333f2791bd4dd56d2b7a1d0efd8a9e64440d 100644 (file)
@@ -183,7 +183,7 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
 namespace {
 
 
-CitationStyle asValidLatexCommand(string const & input, vector<CitationStyle> const valid_styles)
+CitationStyle asValidLatexCommand(string const & input, vector<CitationStyle> const valid_styles)
 {
        CitationStyle cs = valid_styles[0];
        cs.forceUpperCase = false;
@@ -313,33 +313,27 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
 {
        if (!cache.recalculate && buffer().citeLabelsValid())
                return;
-
        // The label may have changed, so we have to re-create it.
        docstring const glabel = generateLabel();
-
-       unsigned int const maxLabelChars = 45;
-
-       docstring label = glabel;
-       if (label.size() > maxLabelChars) {
-               label.erase(maxLabelChars - 3);
-               label += "...";
-       }
-
        cache.recalculate = false;
        cache.generated_label = glabel;
-       cache.screen_label = label;
+       unsigned int const maxLabelChars = 45;
+       cache.screen_label = glabel.substr(0, maxLabelChars + 1);
+       support::truncateWithEllipsis(cache.screen_label, maxLabelChars);
 }
 
 
-void InsetCitation::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
+                                                        UpdateType) const
 {
        // NOTE
-       // XHTML output uses the TOC to collect the citations
-       // from the document. So if this gets changed, then we
-       // will need to change how the citations are collected.
+       // BiblioInfo::collectCitedEntries() uses the TOC to collect the citations 
+       // from the document. It is used indirectly, via BiblioInfo::makeCitationLables,
+       // by both XHTML and plaintext output. So, if we change what goes into the TOC,
+       // then we will also need to change that routine.
        docstring const tocitem = getParam("key");
-       Toc & toc = buffer().tocBackend().toc("citation");
-       toc.push_back(TocItem(cpit, 0, tocitem, output_active));
+       shared_ptr<Toc> toc = buffer().tocBackend().toc("citation");
+       toc->push_back(TocItem(cpit, 0, tocitem, output_active));
 }
 
 
@@ -404,7 +398,7 @@ void InsetCitation::toString(odocstream & os) const
 }
 
 
-void InsetCitation::forOutliner(docstring & os, size_t) const
+void InsetCitation::forOutliner(docstring & os, size_t const, bool const) const
 {
        os += screenLabel();
 }