Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
parser = new FormulaParser();
try
{
final XFormulaOpCodeMapper mapper = (XFormulaOpCodeMapper) UnoRuntime.queryInterface(XFormulaOpCodeMapper.class, m_xContext.getServiceManager().createInstanceWithContext("simple.formula.FormulaOpCodeMapperObj", m_xContext));
FormulaOpCodeMapEntry[] opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.FUNCTIONS);
final DefaultFormulaContext defaultContext = new DefaultFormulaContext();
final FunctionRegistry functionRegistry = defaultContext.getFunctionRegistry();
String[] names = functionRegistry.getFunctionNames();
addOpCodes(names, opCodes, FUNCTIONS);
names = getOperators(defaultContext, OPERATORS);
opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.UNARY_OPERATORS);
addOpCodes(names, opCodes, UNARY_OPERATORS);
opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.BINARY_OPERATORS);
addOpCodes(names, opCodes, BINARY_OPERATORS);
names = GeneratedFormulaParserConstants.tokenImage.clone();
for (int i = 0; i < names.length; i++)
{
final String token = names[i];
if ( token != null && token.length() > 0 && token.charAt(0) == '"' )
{
names[i] = token.substring(1, token.length() - 1);
}
}
opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.SEPARATORS);
addOpCodes(names, opCodes, SEPARATORS, false);
opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.ARRAY_SEPARATORS);
addOpCodes(names, opCodes, ARRAY_SEPARATORS, false);
opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.SPECIAL);
for (int i = 0; i < opCodes.length; i++)
{
final FormulaOpCodeMapEntry opCode = opCodes[i];
parserAllOpCodes.put(opCode.Token.OpCode, opCode);