From 389f85c038b42c23b1a140c4d6f67f3ca269e02c Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 9 Jan 2010 22:30:56 +0000 Subject: [PATCH] Move the anonymous functions that are left closer to where they are now used. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32924 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCitation.cpp | 134 ++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index ebd73641c4..5921e7f130 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -37,6 +37,29 @@ using namespace lyx::support; namespace lyx { +ParamInfo InsetCitation::param_info_; + + +InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p) + : InsetCommand(buf, p, "citation") +{} + + +ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */) +{ + // standard cite does only take one argument if jurabib is + // not used, but jurabib extends this to two arguments, so + // we have to allow both here. InsetCitation takes care that + // LaTeX output is nevertheless correct. + if (param_info_.empty()) { + param_info_.add("after", ParamInfo::LATEX_OPTIONAL); + param_info_.add("before", ParamInfo::LATEX_OPTIONAL); + param_info_.add("key", ParamInfo::LATEX_REQUIRED); + } + return param_info_; +} + + namespace { vector const init_possible_cite_commands() @@ -65,6 +88,50 @@ vector const & possibleCiteCommands() } +} // anon namespace + + +bool InsetCitation::isCompatibleCommand(string const & cmd) +{ + vector const & possibles = possibleCiteCommands(); + vector::const_iterator const end = possibles.end(); + return find(possibles.begin(), end, cmd) != end; +} + + +docstring InsetCitation::toolTip(BufferView const & bv, int, int) const +{ + Buffer const & buf = bv.buffer(); + // Only after the buffer is loaded from file... + if (!buf.isFullyLoaded()) + return docstring(); + + BiblioInfo const & bi = buf.masterBibInfo(); + if (bi.empty()) + return _("No bibliography defined!"); + + docstring const & key = getParam("key"); + if (key.empty()) + return _("No citations selected!"); + + vector keys = getVectorFromString(key); + vector::const_iterator it = keys.begin(); + vector::const_iterator en = keys.end(); + docstring tip; + for (; it != en; ++it) { + docstring const key_info = bi.getInfo(*it); + if (key_info.empty()) + continue; + if (!tip.empty()) + tip += "\n"; + tip += wrap(key_info, -4); + } + return tip; +} + + +namespace { + // FIXME See the header for the issue. string defaultCiteCommand(CiteEngine engine) { @@ -132,72 +199,7 @@ string asValidLatexCommand(string const & input, CiteEngine const engine) return output; } - -} // anon namespace - - -ParamInfo InsetCitation::param_info_; - - -InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p) - : InsetCommand(buf, p, "citation") -{} - - -ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */) -{ - // standard cite does only take one argument if jurabib is - // not used, but jurabib extends this to two arguments, so - // we have to allow both here. InsetCitation takes care that - // LaTeX output is nevertheless correct. - if (param_info_.empty()) { - param_info_.add("after", ParamInfo::LATEX_OPTIONAL); - param_info_.add("before", ParamInfo::LATEX_OPTIONAL); - param_info_.add("key", ParamInfo::LATEX_REQUIRED); - } - return param_info_; -} - - -bool InsetCitation::isCompatibleCommand(string const & cmd) -{ - vector const & possibles = possibleCiteCommands(); - vector::const_iterator const end = possibles.end(); - return find(possibles.begin(), end, cmd) != end; -} - - -docstring InsetCitation::toolTip(BufferView const & bv, int, int) const -{ - Buffer const & buf = bv.buffer(); - // Only after the buffer is loaded from file... - if (!buf.isFullyLoaded()) - return docstring(); - - BiblioInfo const & bi = buf.masterBibInfo(); - if (bi.empty()) - return _("No bibliography defined!"); - - docstring const & key = getParam("key"); - if (key.empty()) - return _("No citations selected!"); - - vector keys = getVectorFromString(key); - vector::const_iterator it = keys.begin(); - vector::const_iterator en = keys.end(); - docstring tip; - for (; it != en; ++it) { - docstring const key_info = bi.getInfo(*it); - if (key_info.empty()) - continue; - if (!tip.empty()) - tip += "\n"; - tip += wrap(key_info, -4); - } - return tip; -} - - +} // anonymous namespace docstring InsetCitation::generateLabel() const { -- 2.39.2