aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-02-21 21:14:31 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-02-21 21:14:31 +0000
commit159ad62a47a9642d96782bf6fdf8d634d78bcfdb (patch)
treed364dced93b5c9893072255141291d171e780128 /src/scratchpad
parentfd4410d50bffb31c3883206ee2f4da3076b58fd4 (diff)
downloadpoi-159ad62a47a9642d96782bf6fdf8d634d78bcfdb.tar.gz
poi-159ad62a47a9642d96782bf6fdf8d634d78bcfdb.zip
fix IntelliJ warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874338 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java53
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java37
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java25
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfHeader.java4
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java29
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java10
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecord.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfWindowing.java18
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java11
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java10
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java1
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java4
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPath.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java194
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRecord.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRegion.java1
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emfplus/UnimplementedHemfPlusRecord.java19
22 files changed, 212 insertions, 231 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java
index d476c21bcc..2e603fe261 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java
@@ -96,10 +96,10 @@ public class HemfComment {
*
* @param ctx the graphics context to modify
*/
- default void draw(HemfGraphics ctx) {};
+ default void draw(HemfGraphics ctx) {}
@Override
- default Enum getGenericRecordType() {
+ default HemfCommentRecordType getGenericRecordType() {
return getCommentRecordType();
}
}
@@ -137,6 +137,14 @@ public class HemfComment {
public Map<String, Supplier<?>> getGenericProperties() {
return GenericRecordUtil.getGenericProperties("data", this::getCommentData);
}
+
+ static void validateCommentType(final LittleEndianInputStream leis, HemfCommentRecordType commentType) {
+ int commentIdentifier = (int)leis.readUInt();
+ if (commentIdentifier == HemfCommentRecordType.emfPublic.id) {
+ commentIdentifier = (int)leis.readUInt();
+ }
+ assert(commentIdentifier == commentType.id);
+ }
}
public static class EmfCommentDataIterator implements Iterator<EmfCommentData> {
@@ -172,20 +180,19 @@ public class HemfComment {
}
private EmfCommentData _next() {
- long type, recordSize;
+ long recordSize;
if (currentRecord == null && emfParent) {
- type = HemfRecordType.comment.id;
recordSize = limit;
} else {
// A 32-bit unsigned integer from the RecordType enumeration that identifies this record
// as a comment record. This value MUST be 0x00000046.
try {
- type = leis.readUInt();
+ long type = leis.readUInt();
+ assert(type == HemfRecordType.comment.id);
} catch (RuntimeException e) {
// EOF
return null;
}
- assert(type == HemfRecordType.comment.id);
// A 32-bit unsigned integer that specifies the size in bytes of this record in the
// metafile. This value MUST be a multiple of 4 bytes.
recordSize = leis.readUInt();
@@ -288,9 +295,8 @@ public class HemfComment {
@Override
public long init(final LittleEndianInputStream leis, final long dataSize)
throws IOException {
- long startIdx = leis.getReadIndex();
- int commentIdentifier = leis.readInt();
- assert (commentIdentifier == HemfCommentRecordType.emfPlus.id);
+ final int startIdx = leis.getReadIndex();
+ EmfComment.validateCommentType(leis, HemfCommentRecordType.emfPlus);
new HemfPlusRecordIterator(leis, (int)dataSize-LittleEndianConsts.INT_SIZE).forEachRemaining(records::add);
return leis.getReadIndex()-startIdx;
}
@@ -328,13 +334,9 @@ public class HemfComment {
}
@Override
- public long init(final LittleEndianInputStream leis, final long dataSize)
- throws IOException {
+ public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
final int startIdx = leis.getReadIndex();
- final int commentIdentifier = (int)leis.readUInt();
- assert(commentIdentifier == HemfCommentRecordType.emfPublic.id);
- final int publicCommentIdentifier = (int)leis.readUInt();
- assert(publicCommentIdentifier == HemfCommentRecordType.emfBeginGroup.id);
+ EmfComment.validateCommentType(leis, HemfCommentRecordType.emfBeginGroup);
HemfDraw.readRectL(leis, bounds);
// The number of Unicode characters in the optional description string that follows.
@@ -347,6 +349,7 @@ public class HemfComment {
return leis.getReadIndex()-startIdx;
}
+
public Rectangle2D getBounds() {
return bounds;
}
@@ -374,10 +377,7 @@ public class HemfComment {
public long init(final LittleEndianInputStream leis, final long dataSize)
throws IOException {
final int startIdx = leis.getReadIndex();
- final int commentIdentifier = (int)leis.readUInt();
- assert(commentIdentifier == HemfCommentRecordType.emfPublic.id);
- final int publicCommentIdentifier = (int)leis.readUInt();
- assert(publicCommentIdentifier == HemfCommentRecordType.emfEndGroup.id);
+ EmfComment.validateCommentType(leis, HemfCommentRecordType.emfEndGroup);
return leis.getReadIndex()-startIdx;
}
@@ -397,13 +397,9 @@ public class HemfComment {
}
@Override
- public long init(final LittleEndianInputStream leis, final long dataSize)
- throws IOException {
+ public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
final int startIdx = leis.getReadIndex();
- final int commentIdentifier = (int)leis.readUInt();
- assert(commentIdentifier == HemfCommentRecordType.emfPublic.id);
- final int publicCommentIdentifier = (int)leis.readUInt();
- assert(publicCommentIdentifier == HemfCommentRecordType.emfMultiFormats.id);
+ EmfComment.validateCommentType(leis, HemfCommentRecordType.emfMultiFormats);
HemfDraw.readRectL(leis, bounds);
// A 32-bit unsigned integer that specifies the number of graphics formats contained in this record.
@@ -487,6 +483,7 @@ public class HemfComment {
private int offData;
private byte[] rawData;
+ @SuppressWarnings("unused")
public long init(final LittleEndianInputStream leis, final long dataSize, long startIdx) throws IOException {
// A 32-bit unsigned integer that specifies the format of the image data.
signature = EmfFormatSignature.getById(leis.readInt());
@@ -539,13 +536,11 @@ public class HemfComment {
return HemfCommentRecordType.emfWMF;
}
+ @SuppressWarnings("unused")
@Override
public long init(final LittleEndianInputStream leis, final long dataSize) throws IOException {
final int startIdx = leis.getReadIndex();
- final int commentIdentifier = (int)leis.readUInt();
- assert(commentIdentifier == HemfCommentRecordType.emfPublic.id);
- final int publicCommentIdentifier = (int)leis.readUInt();
- assert(publicCommentIdentifier == HemfCommentRecordType.emfWMF.id);
+ EmfComment.validateCommentType(leis, HemfCommentRecordType.emfWMF);
// A 16-bit unsigned integer that specifies the WMF metafile version in terms
//of support for device-independent bitmaps (DIBs)
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
index 71a2dad577..caabb04a4c 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfDraw.java
@@ -42,7 +42,9 @@ import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
-public class HemfDraw {
+public final class HemfDraw {
+ private HemfDraw() {}
+
/**
* The EMR_SELECTOBJECT record adds a graphics object to the current metafile playback device
* context. The object is specified either by its index in the EMF Object Table or by its
@@ -102,7 +104,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -212,7 +214,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -313,7 +315,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -456,6 +458,7 @@ public class HemfDraw {
return readPointL(leis, point);
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
long size = readRectL(leis, bounds);
@@ -521,7 +524,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -593,7 +596,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -618,7 +621,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -647,7 +650,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -677,7 +680,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -706,7 +709,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -733,7 +736,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -759,7 +762,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -792,7 +795,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -818,7 +821,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -848,7 +851,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -958,7 +961,7 @@ public class HemfDraw {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -1215,8 +1218,6 @@ public class HemfDraw {
* path by using the current pen, and fills its interior by using the current brush.
*/
public static class EmfStrokeAndFillPath extends EmfStrokePath {
- protected final Rectangle2D bounds = new Rectangle2D.Double();
-
@Override
public HemfRecordType getEmfRecordType() {
return HemfRecordType.strokeAndFillPath;
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
index d6b8228ea6..195182a509 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFill.java
@@ -53,8 +53,8 @@ import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
-public class HemfFill {
- private static final int MAX_RECORD_LENGTH = 10_000_000;
+public final class HemfFill {
+ private HemfFill() {}
/**
* The EMR_SETPOLYFILLMODE record defines polygon fill mode.
@@ -75,7 +75,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -98,7 +98,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -224,7 +224,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -309,7 +309,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -341,6 +341,7 @@ public class HemfFill {
return HemfRecordType.frameRgn;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
long size = readRectL(leis, bounds);
@@ -386,7 +387,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -401,6 +402,7 @@ public class HemfFill {
return HemfRecordType.invertRgn;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
long size = readRectL(leis, bounds);
@@ -453,6 +455,7 @@ public class HemfFill {
return HemfRecordType.fillRgn;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
long size = readRectL(leis, bounds);
@@ -486,7 +489,7 @@ public class HemfFill {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -500,6 +503,7 @@ public class HemfFill {
return HemfRecordType.extSelectClipRgn;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
// A 32-bit unsigned integer that specifies the size of region data in bytes
@@ -522,7 +526,6 @@ public class HemfFill {
@Override
public void draw(HemfGraphics ctx) {
- HemfDrawProperties prop = ctx.getProperties();
ctx.setClip(getShape(), regionMode, true);
}
@@ -692,6 +695,7 @@ public class HemfFill {
return HemfRecordType.setDiBitsToDevice;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
int startIdx = leis.getReadIndex();
@@ -804,6 +808,7 @@ public class HemfFill {
}
+ @SuppressWarnings("unused")
static long readRgnData(final LittleEndianInputStream leis, final List<Rectangle2D> rgnRects) {
// *** RegionDataHeader ***
// A 32-bit unsigned integer that specifies the size of this object in bytes. This MUST be 0x00000020.
@@ -873,7 +878,7 @@ public class HemfFill {
return 6 * LittleEndian.INT_SIZE;
}
- protected static Shape getRgnShape(List<Rectangle2D> rgnRects) {
+ static Shape getRgnShape(List<Rectangle2D> rgnRects) {
if (rgnRects.size() == 1) {
return rgnRects.get(0);
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
index 66229fb536..b95f83c3cf 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
@@ -237,6 +237,7 @@ public class HemfFont extends HwmfFont {
protected LogFontDetails details;
+ @SuppressWarnings("unused")
@Override
public int init(LittleEndianInputStream leis, long recordSize) throws IOException {
// A 32-bit signed integer that specifies the height, in logical units, of the font's
@@ -517,7 +518,7 @@ public class HemfFont extends HwmfFont {
}
@Override
- protected int readString(LittleEndianInputStream leis, StringBuilder sb, int limit) throws IOException {
+ protected int readString(LittleEndianInputStream leis, StringBuilder sb, int limit) {
sb.setLength(0);
byte[] buf = new byte[limit * 2];
leis.readFully(buf);
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfHeader.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfHeader.java
index 52a4055029..d8d3d34c7c 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfHeader.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfHeader.java
@@ -43,9 +43,6 @@ import org.apache.poi.util.LittleEndianInputStream;
@Internal
public class HemfHeader implements HemfRecord {
- private static final int MAX_RECORD_LENGTH = 1_000_000;
-
-
private final Rectangle2D boundsRectangle = new Rectangle2D.Double();
private final Rectangle2D frameRectangle = new Rectangle2D.Double();
private long bytes;
@@ -131,6 +128,7 @@ public class HemfHeader implements HemfRecord {
return HemfRecordType.header;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
if (recordId != HemfRecordType.header.id) {
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java
index e9056f682c..4552f858a2 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfMisc.java
@@ -100,6 +100,7 @@ public class HemfMisc {
return HemfRecordType.eof;
}
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long recordSize, long recordId) throws IOException {
final int startIdx = leis.getReadIndex();
@@ -112,7 +113,7 @@ public class HemfMisc {
int size = 2 * LittleEndianConsts.INT_SIZE;
if (nPalEntries > 0 && offPalEntries > 0) {
- int undefinedSpace1 = (int) (offPalEntries - (size + HEADER_SIZE));
+ int undefinedSpace1 = offPalEntries - (size + HEADER_SIZE);
assert (undefinedSpace1 >= 0);
leis.skipFully(undefinedSpace1);
size += undefinedSpace1;
@@ -165,7 +166,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -191,7 +192,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -213,7 +214,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -240,7 +241,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -260,7 +261,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -283,7 +284,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -306,7 +307,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -331,7 +332,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -385,7 +386,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -454,7 +455,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -477,7 +478,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -538,7 +539,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -668,7 +669,7 @@ public class HemfMisc {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
index 5c5f9283ac..0bfbebad38 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPalette.java
@@ -48,7 +48,7 @@ public class HemfPalette {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -96,7 +96,7 @@ public class HemfPalette {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -144,7 +144,7 @@ public class HemfPalette {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -191,7 +191,7 @@ public class HemfPalette {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -212,7 +212,7 @@ public class HemfPalette {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecord.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecord.java
index cd33b10ca0..0ab50e819d 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecord.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecord.java
@@ -63,7 +63,7 @@ public interface HemfRecord extends GenericRecord {
default void setHeader(HemfHeader header) {}
@Override
- default Enum getGenericRecordType() {
+ default HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
index 3c8e906e10..344cc62a9b 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfText.java
@@ -225,7 +225,7 @@ public class HemfText {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -266,7 +266,7 @@ public class HemfText {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -286,7 +286,7 @@ public class HemfText {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -338,7 +338,7 @@ public class HemfText {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfWindowing.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfWindowing.java
index d95b9d94a0..6167cd6028 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfWindowing.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfWindowing.java
@@ -53,7 +53,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -73,7 +73,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -93,7 +93,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -113,7 +113,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -134,7 +134,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -155,7 +155,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -176,7 +176,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -197,7 +197,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
@@ -218,7 +218,7 @@ public class HemfWindowing {
}
@Override
- public Enum getGenericRecordType() {
+ public HemfRecordType getGenericRecordType() {
return getEmfRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
index 4aeaf43e94..e297bd45d1 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
@@ -251,6 +251,7 @@ public class HemfPlusBrush {
}
+ @SuppressWarnings("unused")
public interface EmfPlusBrushData extends GenericRecord {
/**
* This flag is meaningful in EmfPlusPathGradientBrushData objects.
@@ -458,7 +459,7 @@ public class HemfPlusBrush {
}
@Override
- public Enum getGenericRecordType() {
+ public EmfPlusBrushType getGenericRecordType() {
return EmfPlusBrushType.SOLID_COLOR;
}
@@ -500,7 +501,7 @@ public class HemfPlusBrush {
}
@Override
- public Enum getGenericRecordType() {
+ public EmfPlusBrushType getGenericRecordType() {
return EmfPlusBrushType.HATCH_FILL;
}
@@ -600,7 +601,7 @@ public class HemfPlusBrush {
}
@Override
- public Enum getGenericRecordType() {
+ public EmfPlusBrushType getGenericRecordType() {
return EmfPlusBrushType.LINEAR_GRADIENT;
}
@@ -810,7 +811,7 @@ public class HemfPlusBrush {
@Override
- public Enum getGenericRecordType() {
+ public EmfPlusBrushType getGenericRecordType() {
return EmfPlusBrushType.PATH_GRADIENT;
}
@@ -884,7 +885,7 @@ public class HemfPlusBrush {
}
@Override
- public Enum getGenericRecordType() {
+ public EmfPlusBrushType getGenericRecordType() {
return EmfPlusBrushType.TEXTURE_FILL;
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
index 09b51fd1d2..92e58f58f1 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusDraw.java
@@ -62,9 +62,11 @@ import org.apache.poi.util.LittleEndianInputStream;
import org.apache.poi.util.StringUtil;
@SuppressWarnings("WeakerAccess")
-public class HemfPlusDraw {
+public final class HemfPlusDraw {
private static final int MAX_OBJECT_SIZE = 1_000_000;
+ private HemfPlusDraw() {}
+
public enum EmfPlusUnitType {
/** Specifies a unit of logical distance within the world space. */
World(0x00),
@@ -126,9 +128,9 @@ public class HemfPlusDraw {
* If set, each element in PointData specifies a location in the coordinate space that is relative to the
* location specified by the previous element in the array. In the case of the first element in PointData,
* a previous location at coordinates (0,0) is assumed.
- * If clear, PointData specifies absolute locations according to the {@link #isCompressed()} flag.
+ * If clear, PointData specifies absolute locations according to the {@link EmfPlusCompressed#isCompressed()} flag.
*
- * Note If this flag is set, the {@link #isCompressed()} flag (above) is undefined and MUST be ignored.
+ * Note If this flag is set, the {@link EmfPlusCompressed#isCompressed()} flag (above) is undefined and MUST be ignored.
*/
BitField POSITION = BitFieldFactory.getInstance(0x0800);
@@ -330,6 +332,7 @@ public class HemfPlusDraw {
}
/** The EmfPlusDrawImagePoints record specifies drawing a scaled image inside a parallelogram. */
+ @SuppressWarnings("unused")
public static class EmfPlusDrawImagePoints implements HemfPlusRecord, EmfPlusObjectId, EmfPlusCompressed, EmfPlusRelativePosition {
/**
* This bit indicates that the rendering of the image includes applying an effect.
@@ -625,6 +628,7 @@ public class HemfPlusDraw {
}
/** The EmfPlusDrawDriverString record specifies text output with character positions. */
+ @SuppressWarnings("unused")
public static class EmfPlusDrawDriverString implements HemfPlusRecord, EmfPlusObjectId, EmfPlusSolidColor {
/**
* If set, the positions of character glyphs SHOULD be specified in a character map lookup table.
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
index 251dd41200..2d8f3b0e45 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
@@ -32,6 +32,7 @@ import java.io.InputStream;
import org.apache.poi.sl.draw.BitmapImageRenderer;
import org.apache.poi.util.IOUtils;
+@SuppressWarnings("unused")
public class HemfPlusGDIImageRenderer extends BitmapImageRenderer {
private int width;
private int height;
@@ -81,7 +82,7 @@ public class HemfPlusGDIImageRenderer extends BitmapImageRenderer {
}
@Override
- public void loadImage(byte[] data, String contentType) throws IOException {
+ public void loadImage(byte[] data, String contentType) {
img = readGDIImage(data);
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
index 256c72ea49..e61dae8d2f 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusHeader.java
@@ -110,6 +110,7 @@ public class HemfPlusHeader implements HemfPlusRecord {
*
* @return {@code true} if dual-mode is enabled
*/
+ @SuppressWarnings("unused")
public boolean isEmfPlusDualMode() {
return (flags & 1) == 1;
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
index d8ad091f2f..840b752f37 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusImage.java
@@ -52,9 +52,6 @@ import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
public class HemfPlusImage {
- /** Maximum image dimension for converting embedded metafiles */
- private static final int MAX_IMAGE_SIZE = 1500;
-
/** The ImageDataType enumeration defines types of image data formats. */
public enum EmfPlusImageDataType {
/** The type of image is not known. */
@@ -80,6 +77,7 @@ public class HemfPlusImage {
}
}
+ @SuppressWarnings("unused")
public enum EmfPlusPixelFormat {
UNDEFINED(0X00000000),
INDEXED_1BPP(0X00030101),
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
index 2a8866be48..40b3d729eb 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusMisc.java
@@ -243,8 +243,6 @@ public class HemfPlusMisc {
@Override
public void draw(HemfGraphics ctx) {
- HemfDrawProperties prop = ctx.getProperties();
-
AffineTransform tx = ctx.getInitTransform();
tx.concatenate(getMatrixData());
ctx.setTransform(tx);
@@ -318,6 +316,7 @@ public class HemfPlusMisc {
}
/** The EmfPlusSetClipRect record combines the current clipping region with a rectangle. */
+ @SuppressWarnings("unused")
public static class EmfPlusSetClipRect implements HemfPlusRecord {
private static final BitField COMBINE_MODE = BitFieldFactory.getInstance(0x0F00);
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java
index 06335f0ad0..908a1d1151 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java
@@ -117,6 +117,7 @@ public class HemfPlusObject {
* The EmfPlusObject record specifies an object for use in graphics operations. The object definition
* can span multiple records), which is indicated by the value of the Flags field.
*/
+ @SuppressWarnings("unused")
public static class EmfPlusObject implements HemfPlusRecord, EmfPlusObjectId, HwmfObjectTableEntry {
/**
* Indicates that the object definition continues on in the next EmfPlusObject
@@ -136,6 +137,7 @@ public class HemfPlusObject {
private int flags;
// for debugging
+ @SuppressWarnings("FieldCanBeLocal")
private int objectId;
private EmfPlusObjectData objectData;
private List<EmfPlusObjectData> continuedObjectData;
@@ -155,6 +157,7 @@ public class HemfPlusObject {
return EmfPlusObjectType.valueOf(OBJECT_TYPE.getValue(flags));
}
+ @SuppressWarnings("unchecked")
public <T extends EmfPlusObjectData> T getObjectData() {
return (T)objectData;
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPath.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPath.java
index ef29a9d63d..a69f4954e1 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPath.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPath.java
@@ -55,9 +55,10 @@ public class HemfPlusPath {
// not defined
UNUSED,
/** Specifies that the point is an endpoint or control point of a cubic Bezier curve */
- BEZIER;
+ BEZIER
}
+ @SuppressWarnings("unused")
public static class EmfPlusPath implements EmfPlusObjectData, EmfPlusCompressed, EmfPlusRelativePosition {
/**
* If set, the point types in the PathPointTypes array are specified by EmfPlusPathPointTypeRLE objects,
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
index a52841bb56..b2213df707 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
@@ -46,6 +46,7 @@ import org.apache.poi.hwmf.record.HwmfPenStyle.HwmfLineDash;
import org.apache.poi.hwmf.record.HwmfPenStyle.HwmfLineJoin;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
@@ -233,14 +234,64 @@ public class HemfPlusPen {
@Internal
- public interface EmfPlusCustomLineCap extends GenericRecord {
- long init(LittleEndianInputStream leis) throws IOException;
- }
+ public static abstract class EmfPlusCustomLineCap implements GenericRecord {
+ private EmfPlusLineCapType startCap;
+ private EmfPlusLineCapType endCap;
+ private EmfPlusLineJoin join;
+ private double miterLimit;
+ private double widthScale;
+ private final Point2D fillHotSpot = new Point2D.Double();
+ private final Point2D lineHotSpot = new Point2D.Double();
+ protected long init(LittleEndianInputStream leis) throws IOException {
+ // A 32-bit unsigned integer that specifies the value in the LineCap enumeration that indicates the line
+ // cap used at the start/end of the line to be drawn.
+ startCap = EmfPlusLineCapType.valueOf(leis.readInt());
+ endCap = EmfPlusLineCapType.valueOf(leis.readInt());
- public static class EmfPlusPen implements EmfPlusObjectData {
+ // A 32-bit unsigned integer that specifies the value in the LineJoin enumeration, which specifies how
+ // to join two lines that are drawn by the same pen and whose ends meet. At the intersection of the two
+ // line ends, a line join makes the connection look more continuous.
+ join = EmfPlusLineJoin.valueOf(leis.readInt());
+
+ // A 32-bit floating-point value that contains the limit of the thickness of the join on a mitered corner
+ // by setting the maximum allowed ratio of miter length to line width.
+ miterLimit = leis.readFloat();
+
+ // A 32-bit floating-point value that specifies the amount by which to scale the custom line cap with
+ // respect to the width of the EmfPlusPen object that is used to draw the lines.
+ widthScale = leis.readFloat();
+
+ long size = 5*LittleEndianConsts.INT_SIZE;
+
+ // An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
+ size += readPointF(leis, fillHotSpot);
+ size += readPointF(leis, lineHotSpot);
+
+ return size;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String,Supplier<?>> m = new LinkedHashMap<>();
+ m.put("startCap", () -> startCap);
+ m.put("endCap", () -> endCap);
+ m.put("join", () -> join);
+ m.put("miterLimit", () -> miterLimit);
+ m.put("widthScale", () -> widthScale);
+ m.put("fillHotSpot", () -> fillHotSpot);
+ m.put("lineHotSpot", () -> lineHotSpot);
+ return m;
+ }
+
+ @Override
+ public final EmfPlusObjectType getGenericRecordType() {
+ return EmfPlusObjectType.CUSTOM_LINE_CAP;
+ }
+ }
+ public static class EmfPlusPen implements EmfPlusObjectData {
/**
* If set, a 2x3 transform matrix MUST be specified in the OptionalData field of an EmfPlusPenData object.
*/
@@ -581,7 +632,7 @@ public class HemfPlusPen {
}
}
- public static class EmfPlusPathArrowCap implements EmfPlusCustomLineCap {
+ public static class EmfPlusPathArrowCap extends EmfPlusCustomLineCap {
/**
* If set, an EmfPlusFillPath object MUST be specified in the OptionalData field of the
* EmfPlusCustomLineCapData object for filling the custom line cap.
@@ -600,13 +651,6 @@ public class HemfPlusPen {
private int dataFlags;
private EmfPlusLineCapType baseCap;
private double baseInset;
- private EmfPlusLineCapType startCap;
- private EmfPlusLineCapType endCap;
- private EmfPlusLineJoin join;
- private double miterLimit;
- private double widthScale;
- private final Point2D fillHotSpot = new Point2D.Double();
- private final Point2D lineHotSpot = new Point2D.Double();
private EmfPlusPath fillPath;
private EmfPlusPath outlinePath;
@@ -624,78 +668,44 @@ public class HemfPlusPen {
// beginning of the line cap and the end of the line.
baseInset = leis.readFloat();
- // A 32-bit unsigned integer that specifies the value in the LineCap enumeration that indicates the line
- // cap used at the start/end of the line to be drawn.
- startCap = EmfPlusLineCapType.valueOf(leis.readInt());
- endCap = EmfPlusLineCapType.valueOf(leis.readInt());
+ long size = 3*LittleEndianConsts.INT_SIZE;
- // A 32-bit unsigned integer that specifies the value in the LineJoin enumeration, which specifies how
- // to join two lines that are drawn by the same pen and whose ends meet. At the intersection of the two
- // line ends, a line join makes the connection look more continuous.
- join = EmfPlusLineJoin.valueOf(leis.readInt());
-
- // A 32-bit floating-point value that contains the limit of the thickness of the join on a mitered corner
- // by setting the maximum allowed ratio of miter length to line width.
- miterLimit = leis.readFloat();
-
- // A 32-bit floating-point value that specifies the amount by which to scale the custom line cap with
- // respect to the width of the EmfPlusPen object that is used to draw the lines.
- widthScale = leis.readFloat();
-
- int size = 8* LittleEndianConsts.INT_SIZE;
+ size += super.init(leis);
- // An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
- size += readPointF(leis, fillHotSpot);
- size += readPointF(leis, lineHotSpot);
+ size += initPath(leis, FILL_PATH, p -> fillPath = p);
+ size += initPath(leis, LINE_PATH, p -> outlinePath = p);
- if (FILL_PATH.isSet(dataFlags)) {
- int fillSize = leis.readInt();
- size += LittleEndianConsts.INT_SIZE;
- fillPath = new EmfPlusPath();
- size += fillPath.init(leis, fillSize, EmfPlusObjectType.PATH, -1);
- }
+ return size;
+ }
- if (LINE_PATH.isSet(dataFlags)) {
- int pathSize = leis.readInt();
- size += LittleEndianConsts.INT_SIZE;
- outlinePath = new EmfPlusPath();
- size += outlinePath.init(leis, pathSize, EmfPlusObjectType.PATH, -1);
+ private long initPath(LittleEndianInputStream leis, BitField bitField, Consumer<EmfPlusPath> setter) throws IOException {
+ if (!bitField.isSet(dataFlags)) {
+ return 0;
}
-
- return size;
+ int pathSize = leis.readInt();
+ EmfPlusPath path = new EmfPlusPath();
+ setter.accept(path);
+ return LittleEndianConsts.INT_SIZE + path.init(leis, pathSize, EmfPlusObjectType.PATH, -1);
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
- final Map<String,Supplier<?>> m = new LinkedHashMap<>();
- m.put("flags", getBitsAsString(() -> dataFlags, FLAGS_MASKS, FLAGS_NAMES));
- m.put("baseCap", () -> baseCap);
- m.put("baseInset", () -> baseInset);
- m.put("startCap", () -> startCap);
- m.put("endCap", () -> endCap);
- m.put("join", () -> join);
- m.put("miterLimit", () -> miterLimit);
- m.put("widthScale", () -> widthScale);
- m.put("fillHotSpot", () -> fillHotSpot);
- m.put("lineHotSpot", () -> lineHotSpot);
- m.put("fillPath", () -> fillPath);
- m.put("outlinePath", () -> outlinePath);
- return Collections.unmodifiableMap(m);
+ return GenericRecordUtil.getGenericProperties(
+ "flags", getBitsAsString(() -> dataFlags, FLAGS_MASKS, FLAGS_NAMES),
+ "baseCap", () -> baseCap,
+ "baseInset", () -> baseInset,
+ "base", super::getGenericProperties,
+ "fillPath", () -> fillPath,
+ "outlinePath", () -> outlinePath
+ );
}
}
- public static class EmfPlusAdjustableArrowCap implements EmfPlusCustomLineCap {
+ public static class EmfPlusAdjustableArrowCap extends EmfPlusCustomLineCap {
private double width;
private double height;
private double middleInset;
private boolean isFilled;
- private EmfPlusLineCapType startCap;
- private EmfPlusLineCapType endCap;
- private EmfPlusLineJoin join;
- private double miterLimit;
- private double widthScale;
- private final Point2D fillHotSpot = new Point2D.Double();
- private final Point2D lineHotSpot = new Point2D.Double();
@Override
public long init(LittleEndianInputStream leis) throws IOException {
@@ -719,51 +729,19 @@ public class HemfPlusPen {
// If the arrow cap is not filled, only the outline is drawn.
isFilled = (leis.readInt() != 0);
- // A 32-bit unsigned integer that specifies the value in the LineCap enumeration that indicates
- // the line cap to be used at the start/end of the line to be drawn.
- startCap = EmfPlusLineCapType.valueOf(leis.readInt());
- endCap = EmfPlusLineCapType.valueOf(leis.readInt());
-
- // 32-bit unsigned integer that specifies the value in the LineJoin enumeration that specifies how to
- // join two lines that are drawn by the same pen and whose ends meet. At the intersection of the two
- // line ends, a line join makes the connection look more continuous.
- join = EmfPlusLineJoin.valueOf(leis.readInt());
-
- // A 32-bit floating-point value that specifies the limit of the thickness of the join on a mitered
- // corner by setting the maximum allowed ratio of miter length to line width.
- miterLimit = leis.readFloat();
-
- // A 32-bit floating-point value that specifies the amount by which to scale an EmfPlusCustomLineCap
- // object with respect to the width of the graphics pen that is used to draw the lines.
- widthScale = leis.readFloat();
-
- int size = 9 * LittleEndianConsts.INT_SIZE;
-
- // An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
- size += readPointF(leis, fillHotSpot);
-
- // An EmfPlusPointF object that is not currently used. It MUST be set to {0.0, 0.0}.
- size += readPointF(leis, lineHotSpot);
-
- return size;
+ return 4*LittleEndianConsts.INT_SIZE + super.init(leis);
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
- final Map<String,Supplier<?>> m = new LinkedHashMap<>();
- m.put("width", () -> width);
- m.put("height", () -> height);
- m.put("middleInset", () -> middleInset);
- m.put("isFilled", () -> isFilled);
- m.put("startCap", () -> startCap);
- m.put("endCap", () -> endCap);
- m.put("join", () -> join);
- m.put("miterLimit", () -> miterLimit);
- m.put("widthScale", () -> widthScale);
- m.put("fillHotSpot", () -> fillHotSpot);
- m.put("lineHotSpot", () -> lineHotSpot);
- return Collections.unmodifiableMap(m);
+ return GenericRecordUtil.getGenericProperties(
+ "width", () -> width,
+ "height", () -> height,
+ "middleInset", () -> middleInset,
+ "isFilled", () -> isFilled,
+ "base", super::getGenericProperties
+ );
}
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRecord.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRecord.java
index af1cf0935f..3ac27f0dec 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRecord.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRecord.java
@@ -56,7 +56,7 @@ public interface HemfPlusRecord extends GenericRecord {
}
@Override
- default Enum getGenericRecordType() {
+ default HemfPlusRecordType getGenericRecordType() {
return getEmfPlusRecordType();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRegion.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRegion.java
index 8862e856b9..9ccfb5ff6a 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRegion.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusRegion.java
@@ -108,6 +108,7 @@ public class HemfPlusRegion {
private final EmfPlusGraphicsVersion graphicsVersion = new EmfPlusGraphicsVersion();
private EmfPlusRegionNodeData regionNode;
+ @SuppressWarnings("unused")
@Override
public long init(LittleEndianInputStream leis, long dataSize, EmfPlusObjectType objectType, int flags) throws IOException {
long size = graphicsVersion.init(leis);
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/UnimplementedHemfPlusRecord.java b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/UnimplementedHemfPlusRecord.java
index 9ca1b375eb..74c8e6c458 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/UnimplementedHemfPlusRecord.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/UnimplementedHemfPlusRecord.java
@@ -30,11 +30,8 @@ import org.apache.poi.util.LittleEndianInputStream;
@Internal
public class UnimplementedHemfPlusRecord implements HemfPlusRecord {
- private static final int MAX_RECORD_LENGTH = 1_000_000;
-
private HemfPlusRecordType recordType;
private int flags;
- private byte[] recordBytes;
@Override
public HemfPlusRecordType getEmfPlusRecordType() {
@@ -50,21 +47,17 @@ public class UnimplementedHemfPlusRecord implements HemfPlusRecord {
public long init(LittleEndianInputStream leis, long dataSize, long recordId, int flags) throws IOException {
recordType = HemfPlusRecordType.getById(recordId);
this.flags = flags;
- recordBytes = IOUtils.safelyAllocate(dataSize, MAX_RECORD_LENGTH);
- leis.readFully(recordBytes);
- return recordBytes.length;
- }
-
- public byte[] getRecordBytes() {
- //should probably defensively return a copy.
- return recordBytes;
+ long skipped = IOUtils.skipFully(leis, dataSize);
+ if (skipped < dataSize) {
+ throw new IOException("End of stream reached before record read");
+ }
+ return skipped;
}
@Override
public Map<String, Supplier<?>> getGenericProperties() {
return GenericRecordUtil.getGenericProperties(
- "flags", this::getFlags,
- "recordBytes", () -> recordBytes
+ "flags", this::getFlags
);
}
} \ No newline at end of file