aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
commit34601b5377387e293868937bfa8f7e4cb4d45573 (patch)
tree0808a35acf7ae70b156ae104fce3608f6fa90901 /poi-scratchpad
parente694cf4d534bb09d2a706f390db49e6e779dfa2b (diff)
downloadpoi-34601b5377387e293868937bfa8f7e4cb4d45573.tar.gz
poi-34601b5377387e293868937bfa8f7e4cb4d45573.zip
some lgtm issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904048 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java25
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java2
2 files changed, 19 insertions, 8 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
index 69668f3deb..09c17d054b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.java
@@ -27,6 +27,7 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
+import java.io.InputStream;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collections;
@@ -387,17 +388,27 @@ public class HemfPlusBrush {
return brushBytes;
}
+ /**
+ * @param continuedObjectData list of object data
+ * @return {@link EmfPlusBrushData}
+ * @throws IllegalStateException if the data cannot be processed
+ */
public EmfPlusBrushData getBrushData(List<? extends EmfPlusObjectData> continuedObjectData) {
EmfPlusBrushData brushData = brushType.constructor.get();
byte[] buf = getRawData(continuedObjectData);
- try {
- brushData.init(new LittleEndianInputStream(new UnsynchronizedByteArrayInputStream(buf)), buf.length);
+ try (UnsynchronizedByteArrayInputStream bis = new UnsynchronizedByteArrayInputStream(buf)){
+ brushData.init(new LittleEndianInputStream(bis), buf.length);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
return brushData;
}
+ /**
+ * @param continuedObjectData list of object data
+ * @return byte array
+ * @throws IllegalStateException if the data cannot be processed
+ */
public byte[] getRawData(List<? extends EmfPlusObjectData> continuedObjectData) {
try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
bos.write(getBrushBytes());
@@ -408,7 +419,7 @@ public class HemfPlusBrush {
}
return bos.toByteArray();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
@@ -560,7 +571,7 @@ public class HemfPlusBrush {
}
if (isPreset() && (isBlendH() || isBlendV())) {
- throw new RuntimeException("invalid combination of preset colors and blend factors v/h");
+ throw new IOException("invalid combination of preset colors and blend factors v/h");
}
size += (isPreset()) ? readColors(leis, d -> positions = d, c -> blendColors = c) : 0;
@@ -764,7 +775,7 @@ public class HemfPlusBrush {
final boolean isPreset = PRESET_COLORS.isSet(dataFlags);
final boolean blendH = BLEND_FACTORS_H.isSet(dataFlags);
if (isPreset && blendH) {
- throw new RuntimeException("invalid combination of preset colors and blend factors h");
+ throw new IOException("invalid combination of preset colors and blend factors h");
}
size += (isPreset) ? readColors(leis, d -> positions = d, c -> blendColors = c) : 0;
@@ -777,7 +788,7 @@ public class HemfPlusBrush {
// A 32-bit unsigned integer that specifies the number of focus scales. This value MUST be 2.
int focusScaleCount = leis.readInt();
if (focusScaleCount != 2) {
- throw new RuntimeException("invalid focus scale count");
+ throw new IOException("invalid focus scale count");
}
// A floating-point value that defines the horizontal/vertical focus scale.
// The focus scale MUST be a value between 0.0 and 1.0, exclusive.
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java
index d4d6094743..d457ee63b7 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java
@@ -252,7 +252,7 @@ public final class SlideShowDumper {
// Check for corrupt / lying ones
if (recordLen != 8 && (recordLen != (atomLen + 8))) {
- out.printf(Locale.ROOT, ind + "** Atom length of $2d ($3d) doesn't match record length of %4d%n", "", atomLen, atomLen + 8, recordLen);
+ out.printf(Locale.ROOT, ind + "** Atom length of %2d (%3d) doesn't match record length of %4d%n", atomLen, atomLen + 8, recordLen);
}
// Print the record's details