#64716 - wmf display error

- close polygons
- reset current path location on emf modifyworldtransform
- mirror text if the affinetransform is negative scaled

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1883460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-11-15 21:49:24 +00:00
parent b8cb440ce4
commit c6b408b232
7 changed files with 41 additions and 2 deletions

View File

@ -298,7 +298,7 @@ public final class PPTX2PNG {
// default rendering options
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setRenderingHint(Drawable.DEFAULT_CHARSET, getDefaultCharset());

View File

@ -205,6 +205,11 @@ public final class HemfDraw {
return bounds;
}
@Override
protected boolean addClose() {
return false;
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
return GenericRecordUtil.getGenericProperties(
@ -352,6 +357,11 @@ public final class HemfDraw {
// The line segments SHOULD be drawn using the current pen.
return FillDrawStyle.DRAW;
}
@Override
protected boolean addClose() {
return false;
}
}
/**
@ -952,6 +962,11 @@ public final class HemfDraw {
return bounds;
}
@Override
protected boolean addClose() {
return false;
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
return GenericRecordUtil.getGenericProperties(

View File

@ -831,6 +831,7 @@ public class HemfMisc {
break;
}
ctx.updateWindowMapMode();
ctx.getProperties().setLocation(0,0);
}
@Override

View File

@ -95,7 +95,7 @@ public class HemfText {
// A WMF PointL object that specifies the coordinates of the reference point used to position the string.
// The reference point is defined by the last EMR_SETTEXTALIGN record.
// If no such record has been set, the default alignment is TA_LEFT,TA_TOP.
// If no such record has been set, the defaulint alignment is TA_LEFT,TA_TOP.
size += readPointL(leis, reference);
// A 32-bit unsigned integer that specifies the number of characters in the string.
stringLength = (int)leis.readUInt();

View File

@ -495,6 +495,7 @@ public class HwmfGraphics implements HwmfCharsetAware {
if (scale != null) {
graphicsCtx.scale(scale.getWidth() < 0 ? -1 : 1, scale.getHeight() < 0 ? -1 : 1);
}
graphicsCtx.scale(at.getScaleX() < 0 ? -1 : 1, at.getScaleY() < 0 ? -1 : 1);
graphicsCtx.translate(dst.getX(), dst.getY());
graphicsCtx.setColor(prop.getTextColor().getColor());
graphicsCtx.drawString(as.getIterator(), 0, 0);

View File

@ -158,6 +158,11 @@ public final class HwmfDraw {
}
}
if (addClose()) {
// polygons are closed / polylines not
poly.closePath();
}
return LittleEndianConsts.SHORT_SIZE+numberofPoints*LittleEndianConsts.INT_SIZE;
}
@ -185,6 +190,13 @@ public final class HwmfDraw {
return poly;
}
/**
* @return {@code true} if the path needs to be closed
*/
protected boolean addClose() {
return true;
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
return GenericRecordUtil.getGenericProperties("poly", this::getPoly);
@ -206,6 +218,11 @@ public final class HwmfDraw {
protected FillDrawStyle getFillDrawStyle() {
return FillDrawStyle.DRAW;
}
@Override
protected boolean addClose() {
return false;
}
}
/**

View File

@ -469,6 +469,10 @@ public class HwmfText {
return bounds;
}
public WmfExtTextOutOptions getOptions() {
return options;
}
protected boolean isUnicode() {
return false;
}
@ -491,6 +495,7 @@ public class HwmfText {
return GenericRecordUtil.getGenericProperties(
"reference", this::getReference,
"bounds", this::getBounds,
"options", this::getOptions,
"text", this::getGenericText,
"dx", () -> dx
);