コード例 #1
0
 public String getSignature() {
   final int count = functionDescription.getParameterCount();
   final StringBuffer signature = new StringBuffer(getName());
   signature.append('(');
   for (int i = 0; i < count; i++) {
     signature.append(functionDescription.getParameterDisplayName(i, defaultLocale));
     if (i != (count - 1)) {
       signature.append(';');
     }
   }
   signature.append(')');
   return signature.toString();
 }
コード例 #2
0
  public StarFunctionDescription(
      final DefaultFormulaContext defaultContext,
      final XComponentContext context,
      final XFunctionCategory category,
      final FunctionDescription functionDescription) {
    m_xContext = context;
    this.category = category;
    Locale locale;
    try {
      functionDescription.getDisplayName(defaultContext.getLocalizationContext().getLocale());
      locale = defaultContext.getLocalizationContext().getLocale();
    } catch (MissingResourceException e) {
      locale = Locale.ENGLISH;
    }
    this.defaultLocale = locale;

    this.functionDescription = functionDescription;
    // use the last parameter of the PropertySetMixin constructor
    // for your optional attributes if necessary. See the documentation
    // of the PropertySetMixin helper for further information.
    // Ensure that your attributes are initialized correctly!
    m_prophlp =
        new PropertySetMixin(
            m_xContext, this, new Type(com.sun.star.report.meta.XFunctionDescription.class), null);
  }
コード例 #3
0
 public com.sun.star.sheet.FunctionArgument[] getArguments() {
   int count = functionDescription.getParameterCount();
   final boolean infinite = functionDescription.isInfiniteParameterCount();
   if (infinite) {
     count = 30;
   }
   final FunctionArgument[] args = new FunctionArgument[count];
   for (int i = 0; i < args.length; i++) {
     final int pos = infinite ? 0 : i;
     args[i] = new FunctionArgument();
     args[i].Description = functionDescription.getParameterDescription(pos, defaultLocale);
     args[i].Name = functionDescription.getParameterDisplayName(pos, defaultLocale);
     args[i].IsOptional = !functionDescription.isParameterMandatory(pos);
   }
   return args;
 }
コード例 #4
0
 public String getDescription() {
   try {
     return functionDescription.getDescription(defaultLocale);
   } catch (Exception ex) {
   }
   return "Missing function description for " + this.getClass().getName();
 }
コード例 #5
0
  public String createFormula(String[] arguments)
      throws com.sun.star.lang.DisposedException, com.sun.star.lang.IllegalArgumentException,
          com.sun.star.uno.Exception {
    final boolean infinite = functionDescription.isInfiniteParameterCount();
    final int count = functionDescription.getParameterCount();
    if (!infinite && arguments.length > count) {
      throw new com.sun.star.lang.IllegalArgumentException();
    }

    final StringBuffer formula = new StringBuffer(getName());
    formula.append('(');
    for (int i = 0; i < arguments.length; ++i) {
      if (arguments[i].length() == 0) {
        break;
      }
      formula.append(arguments[i]);
      if (i < (arguments.length - 1) && arguments[i + 1].length() != 0) {
        formula.append(';');
      }
    }
    formula.append(')');
    return formula.toString();
  }