public void addContent(final LayoutContext context,
final ContentToken content)
throws NormalizationException
{
final RenderableTextFactory textFactory = getCurrentTextFactory();
if (content instanceof GenericType)
{
final GenericType generic = (GenericType) content;
ResourceKey source = null;
if (content instanceof ResourceType)
{
final ResourceType resourceType = (ResourceType) content;
source = resourceType.getContent().getSource();
}
final Object raw = generic.getRaw();
if (raw instanceof Image)
{
final RenderableReplacedContent replacedContent =
createImage((Image) raw, source, context);
if (replacedContent != null)
{
replacedContent.appyStyle(context, layoutProcess.getOutputMetaData());
getInsertationPoint().addChilds(textFactory.finishText());
getInsertationPoint().addChild(replacedContent);
tryValidateOutput(null);
return;
}
}
else if (raw instanceof DrawableWrapper)
{
final RenderableReplacedContent replacedContent =
createDrawable((DrawableWrapper) raw, source, context);
if (replacedContent != null)
{
replacedContent.appyStyle(context, layoutProcess.getOutputMetaData());
getInsertationPoint().addChilds(textFactory.finishText());
getInsertationPoint().addChild(replacedContent);
tryValidateOutput(null);
return;
}
}
}
if (content instanceof ResolvedCounterToken)
{
final ResolvedCounterToken resolvedToken = (ResolvedCounterToken) content;
if (isProcessingNormalFlow() == false)
{
getInsertationPoint().addChilds(textFactory.finishText());
try
{
final RenderableTextBox token = new RenderableTextBox
(textFactory.saveState(), resolvedToken, context);
token.appyStyle(context, getLayoutProcess().getOutputMetaData());
getInsertationPoint().addChild(token);
token.close();
tryValidateOutput(null);
return;
}
catch (StateException se)
{
// Should not happen ..
throw new NormalizationException("State failed.", se);
}
}
}
if (context instanceof ResolvedStringToken)
{
final ResolvedStringToken resolvedToken = (ResolvedStringToken) context;
final ComputedToken parent = resolvedToken.getParent();
// todo: The test should be: isProcessingPageFlow()
if (parent instanceof VariableToken && isProcessingNormalFlow() == false)
{
getInsertationPoint().addChilds(textFactory.finishText());
try
{
final RenderableTextBox token = new RenderableTextBox
(textFactory.saveState(), resolvedToken, context);
token.appyStyle(context, getLayoutProcess().getOutputMetaData());
getInsertationPoint().addChild(token);
token.close();
tryValidateOutput(null);
return;