StyleFormatReference styleFormatReference =
(StyleFormatReference) container;
FormatReference reference = styleFormatReference.getReference();
// Try and find the format instance.
Format format = pageContext.getFormat(reference.getStem(),
FormatNamespace.CONTAINER);
if (format != null) {
instance = (ContainerInstance) pageContext.getFormatInstance(
format, reference.getIndex());
}
} else if (containerName != null) {
final ContainerInstance currentContainer =
pageContext.getCurrentContainerInstance();
if (specifiedLayout == null && currentContainer != null &&
containerName.equals(currentContainer.getFormat().getName())) {
// if no new layout is specified and the container name is the
// same as the name of the current container then we can use the
// current container
specifiedCurrentContainer = true;
} else {
DeviceLayoutContext layoutContext = specifiedLayout;
if (layoutContext == null) {
// If none was specified, then try and find the format in
// the current layout.
layoutContext = pageContext.getDeviceLayoutContext();
}
Format format = layoutContext.getFormat(containerName,
FormatNamespace.CONTAINER);
if (format != null) {
int dimensions = format.getDimensions();
NDimensionalIndex index;
if (dimensions > 0) {
int[] indeces = new int[dimensions];
index = new NDimensionalIndex(indeces);
} else {