if (image != null)
{
final ImageElementContext imageContext = (ImageElementContext) attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "image-context");
// When scaling, we have to create an image-style.
final CSSNumericValue width = image.getWidth(); // always in 100th of a mm
final CSSNumericValue height = image.getHeight(); // always in 100th of a mm
LOGGER.debug("Image " + imageData + " Width: " + width + ", Height: " + height);
if (width == null || height == null)
{
return;
}
CSSNumericValue imageAreaWidthVal;
CSSNumericValue imageAreaHeightVal;
String styleName = null;
if (imageContext != null)
{
imageAreaWidthVal = computeImageWidth(imageContext);
imageAreaHeightVal = computeImageHeight(imageContext);
if (imageAreaWidthVal == null || imageAreaHeightVal == null)
{
LOGGER.debug("Image data returned from context is invalid. Maybe this is not an image?");
return;
}
else
{
// compute the clip-area ..
final CSSNumericValue normalizedImageWidth =
CSSValueResolverUtility.convertLength(width, imageAreaWidthVal.getType());
final CSSNumericValue normalizedImageHeight =
CSSValueResolverUtility.convertLength(height, imageAreaHeightVal.getType());
final boolean scale = OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE));
if (!scale && normalizedImageWidth.getValue() > 0 && normalizedImageHeight.getValue() > 0)
{
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();