From bdfcd5f16aee500eb2661d170aeca47a21a9c014 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Sun, 3 Aug 2008 22:14:04 +0000 Subject: [PATCH] InsetInfo: implement InsetInfo::validate git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26042 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetInfo.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index ac1d05bd20..581a24a25a 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -147,10 +147,34 @@ void InsetInfo::write(ostream & os) const } -bool InsetInfo::validate(docstring const & /* argument */) const +bool InsetInfo::validate(docstring const & arg) const { - // FIXME! - return true; + string type; + string name; + + name = trim(split(to_utf8(arg), type, ' ')); + switch (nameTranslator().find(type)) { + case UNKNOWN_INFO: + return false; + case SHORTCUT_INFO: + case SHORTCUTS_INFO: + case MENU_INFO: + case ICON_INFO: { + FuncRequest func = lyxaction.lookupFunc(name); + return func.action != LFUN_UNKNOWN_ACTION; + } + case LYXRC_INFO: { + ostringstream oss; + lyxrc.write(oss, true, name); + return !oss.str().empty(); + } + case PACKAGE_INFO: + case TEXTCLASS_INFO: + return true; + case BUFFER_INFO: + return name_ == "name" || name_ == "path" || name_ == "class"; + } + return false; } -- 2.39.2