{
final double clipWidth = normalizedImageWidth.getValue() - imageAreaWidthVal.getValue();
final double clipHeight = normalizedImageHeight.getValue() - imageAreaHeightVal.getValue();
if (clipWidth > 0 && clipHeight > 0)
{
final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
final StringBuffer buffer = new StringBuffer();
buffer.append("rect(");
buffer.append(clipHeight / 2);
buffer.append(imageAreaHeightVal.getType().getType());
buffer.append(' ');
buffer.append(clipWidth / 2);
buffer.append(imageAreaWidthVal.getType().getType());
buffer.append(' ');
buffer.append(clipHeight / 2);
buffer.append(imageAreaHeightVal.getType().getType());
buffer.append(' ');
buffer.append(clipWidth / 2);
buffer.append(imageAreaWidthVal.getType().getType());
buffer.append(')');
graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());
styleName = imageStyle.getStyleName();
getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
}
else if (clipWidth > 0)
{
final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
final StringBuffer buffer = new StringBuffer();
buffer.append("rect(0cm ");
buffer.append(clipWidth / 2);
buffer.append(imageAreaWidthVal.getType().getType());
buffer.append(" 0cm ");
buffer.append(clipWidth / 2);
buffer.append(imageAreaWidthVal.getType().getType());
buffer.append(')');
graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());
styleName = imageStyle.getStyleName();
getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
imageAreaHeightVal = normalizedImageHeight;
}
else if (clipHeight > 0)
{
final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
final StringBuffer buffer = new StringBuffer();
buffer.append("rect(");
buffer.append(clipHeight / 2);
buffer.append(imageAreaHeightVal.getType().getType());
buffer.append(" 0cm ");
buffer.append(clipHeight / 2);
buffer.append(imageAreaHeightVal.getType().getType());
buffer.append(" 0cm)");
graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());
styleName = imageStyle.getStyleName();
getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
imageAreaWidthVal = normalizedImageWidth;
}
else
{