X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCitation.cpp;h=13fddd7802217c2f6015ee5c87bf2625a5bdfeb9;hb=3d7ede605978461a6bd67b250925fcc8bf8404c3;hp=c0e61798a8fecda40ed999b9d0091ff0020f4841;hpb=4df02801a6e01356a3af033466864197d8e18f11;p=lyx.git diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index c0e61798a8..13fddd7802 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -24,6 +24,7 @@ #include "LaTeXFeatures.h" #include "output_xhtml.h" #include "ParIterator.h" +#include "texstream.h" #include "TocBackend.h" #include "support/debug.h" @@ -33,6 +34,7 @@ #include "support/lstrings.h" #include +#include using namespace std; using namespace lyx::support; @@ -164,17 +166,18 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const return _("No citations selected!"); vector keys = getVectorFromString(key); - vector::const_iterator it = keys.begin(); - vector::const_iterator en = keys.end(); + if (keys.size() == 1) + return bi.getInfo(keys[0], buffer(), true); + docstring tip; - for (; it != en; ++it) { - docstring const key_info = bi.getInfo(*it, buffer()); + tip += "
    "; + for (docstring const & key : keys) { + docstring const key_info = bi.getInfo(key, buffer(), true); if (key_info.empty()) continue; - if (!tip.empty()) - tip += "\n"; - tip += wrap(key_info, -4); + tip += "
  1. " + key_info + "
  2. "; } + tip += "
"; return tip; } @@ -182,7 +185,7 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const namespace { -CitationStyle asValidLatexCommand(string const & input, vector const valid_styles) +CitationStyle asValidLatexCommand(string const & input, vector const & valid_styles) { CitationStyle cs = valid_styles[0]; cs.forceUpperCase = false; @@ -273,8 +276,8 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const buffer().params().documentClass().addCiteMacro("!textafter", to_utf8(after)); */ docstring label; - vector const keys = getVectorFromString(key); - label = biblist.getLabel(keys, buffer(), cite_type, for_xhtml, before, after); + vector keys = getVectorFromString(key); + label = biblist.getLabel(keys, buffer(), cite_type, for_xhtml, UINT_MAX, before, after); return label; } @@ -312,33 +315,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 = buffer().tocBackend().toc("citation"); + toc->push_back(TocItem(cpit, 0, tocitem, output_active)); } @@ -403,7 +400,7 @@ void InsetCitation::toString(odocstream & os) const } -void InsetCitation::forToc(docstring & os, size_t) const +void InsetCitation::forOutliner(docstring & os, size_t const, bool const) const { os += screenLabel(); } @@ -422,7 +419,7 @@ void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const // FIXME UNICODE docstring const cite_str = from_utf8(citationStyleToString(cs)); - if (runparams.inulemcmd) + if (runparams.inulemcmd > 0) os << "\\mbox{"; os << "\\" << cite_str;