use of org.xwiki.formula.FormulaRenderer.FontSize in project xwiki-platform by xwiki.
the class FormulaMacro method execute.
@Override
public List<Block> execute(FormulaMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException {
if (StringUtils.isEmpty(content)) {
throw new MacroExecutionException(CONTENT_MISSING_ERROR);
}
String rendererHint = this.configuration.getRenderer();
FontSize size = parameters.getFontSize();
Type type = parameters.getImageType();
Block result;
try {
result = render(content, context.isInline(), size, type, rendererHint);
} catch (MacroExecutionException ex) {
this.logger.debug("Failed to render content with the [{}] renderer. Falling back to the safe renderer.", rendererHint, ex);
try {
result = render(content, context.isInline(), size, type, this.configuration.getSafeRenderer());
} catch (IllegalArgumentException ex2) {
throw new MacroExecutionException(WRONG_CONTENT_ERROR);
}
} catch (IllegalArgumentException ex) {
throw new MacroExecutionException(WRONG_CONTENT_ERROR);
}
// If no image was generated, just return the original text
if (result == null) {
result = new WordBlock(content);
}
// Block level formulae should be wrapped in a paragraph element
if (!context.isInline()) {
result = new ParagraphBlock(Collections.<Block>singletonList(result));
}
return Collections.singletonList(result);
}
Aggregations