2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 #include "function.hxx"
21 #include "sci_malloc.h"
22 #include "loadOnUseClassPath.h"
23 #include "CallHelpBrowser.h"
25 #include "localization.h"
26 #include "charEncoding.h"
29 using namespace types;
31 static BOOL loadedDep = FALSE;
33 Function::ReturnValue sci_helpbrowser(typed_list &in, int _iRetCount, typed_list& out)
36 char **helpAdr = NULL;
37 char **languageAdr = NULL;
41 Scierror(78, _("%s: Wrong number of output argument(s): %d to %d expected."), "helpbrowser", 0, 1);
42 return Function::Error;
47 if ( !(in[3]->isBool() == true && in[3]->getAs<Bool>()->isScalar() == true))
49 Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected."), "helpbrowser", 4);
50 return Function::Error;
52 if ( !(in[2]->isString() == true && in[2]->getAs<String>()->isScalar() == true))
54 Scierror(999, _("%s: Wrong type for input argument #%d: A string expected."), "helpbrowser", 3);
55 return Function::Error;
58 // Second argument must be String or at least [].
59 if ( !(in[1]->isString() == true && in[1]->getAs<String>()->isScalar() == true))
61 Scierror(999, _("%s: Wrong type for input argument #%d: A string expected."), "helpbrowser", 2);
62 return Function::Error;
64 // Matrix of String or [] allowed.
65 if ( !( (in[0]->isString() == true)
66 || (in[0]->isDouble() == true && in[0]->getAs<Double>()->isEmpty() == true)) )
68 Scierror(999, _("%s: Wrong type for input argument #%d: A string expected."), "helpbrowser", 1);
69 return Function::Error;
73 Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected."), "helpbrowser", 2, 4);
74 return Function::Error;
77 /* We load SciNotes when calling javahelp because we have no way to know
78 * to load it when using Javahelp because it can call SciNotes directly */
81 loadOnUseClassPath("SciNotes");
85 if (in[0]->isString() == true)
87 String *pInHelpAdr = in[0]->getAs<String>();
88 helpAdr = new char*[pInHelpAdr->getSize()];
89 iHelpAdrSize = pInHelpAdr->getSize();
91 for (int i = 0 ; i < pInHelpAdr->getSize() ; ++i)
93 helpAdr[i] = wide_string_to_UTF8(pInHelpAdr->get(i));
101 pstLang = wide_string_to_UTF8(in[1]->getAs<String>()->get(0));
102 launchHelpBrowser(helpAdr, iHelpAdrSize, pstLang);
107 pstLang = wide_string_to_UTF8(in[2]->getAs<String>()->get(0));
108 pstKey = wide_string_to_UTF8(in[1]->getAs<String>()->get(0));
109 int iFullText = in[3]->getAs<Bool>()->get(0);
110 searchKeyword(helpAdr, iHelpAdrSize, pstKey, pstLang, (BOOL) iFullText);
123 if (helpAdr != NULL) /* No toolboxes loaded */
125 for (int i = 0 ; i < iHelpAdrSize ; i++)