aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2019-10-25 20:00:06 +0000
committerAndreas Beeker <kiwiwings@apache.org>2019-10-25 20:00:06 +0000
commit6e32d853bea059a5ec795d779a0a3c29fc079b0d (patch)
tree4412ba59be3cec56042a410e0b70604a7a6f5799 /src/scratchpad
parent468346fca8ce777ecfdefd8d5125b71638315ea9 (diff)
downloadpoi-6e32d853bea059a5ec795d779a0a3c29fc079b0d.tar.gz
poi-6e32d853bea059a5ec795d779a0a3c29fc079b0d.zip
#63745 - Make GenericRecordJsonWriter Json-conformant
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1868952 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java20
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java34
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java6
3 files changed, 51 insertions, 9 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
index b1cb5a4324..c07323dad6 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
@@ -20,11 +20,13 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.record.ExOleObjStg;
-import org.apache.poi.poifs.filesystem.DirectoryEntry;
-import org.apache.poi.poifs.filesystem.FileMagic;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.sl.usermodel.ObjectData;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -32,7 +34,7 @@ import org.apache.poi.util.POILogger;
/**
* A class that represents object data embedded in a slide show.
*/
-public class HSLFObjectData implements ObjectData {
+public class HSLFObjectData implements ObjectData, GenericRecord {
private static final POILogger LOG = POILogFactory.getLogger(HSLFObjectData.class);
/**
@@ -91,4 +93,14 @@ public class HSLFObjectData implements ObjectData {
public String getFileName() {
return null;
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return null;
+ }
+
+ @Override
+ public List<? extends GenericRecord> getGenericChildren() {
+ return Collections.singletonList(getExOleObjStg());
+ }
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
index 1a8061d3c9..df3de7229a 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
@@ -21,17 +21,28 @@ import java.awt.Dimension;
import java.io.IOException;
import java.io.OutputStream;
import java.security.MessageDigest;
-
-import org.apache.poi.hslf.blip.*;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.poi.common.usermodel.GenericRecord;
+import org.apache.poi.hslf.blip.DIB;
+import org.apache.poi.hslf.blip.EMF;
+import org.apache.poi.hslf.blip.JPEG;
+import org.apache.poi.hslf.blip.PICT;
+import org.apache.poi.hslf.blip.PNG;
+import org.apache.poi.hslf.blip.WMF;
import org.apache.poi.poifs.crypt.CryptoFunctions;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.sl.usermodel.PictureData;
-import org.apache.poi.util.*;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.Units;
/**
* A class that represents image data contained in a slide show.
*/
-public abstract class HSLFPictureData implements PictureData {
+public abstract class HSLFPictureData implements PictureData, GenericRecord {
/**
* Size of the image checksum calculated using MD5 algorithm.
@@ -226,4 +237,19 @@ public abstract class HSLFPictureData implements PictureData {
Units.pointsToPixel(dim.getHeight())
);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String,Supplier<?>> m = new LinkedHashMap<>();
+ m.put("type", this::getType);
+ m.put("imageDimension", this::getImageDimension);
+ m.put("signature", this::getSignature);
+ m.put("uidInstanceCount", this::getUIDInstanceCount);
+ m.put("offset", this::getOffset);
+ m.put("uid", this::getUID);
+ m.put("checksum", this::getChecksum);
+ m.put("index", this::getIndex);
+ m.put("rawData", this::getRawData);
+ return Collections.unmodifiableMap(m);
+ }
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
index 490a590d30..5f182d5886 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
@@ -53,6 +53,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
@@ -1168,7 +1169,10 @@ public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagrap
@Override
public Map<String, Supplier<?>> getGenericProperties() {
- return null;
+ return GenericRecordUtil.getGenericProperties(
+ "pictures", this::getPictureData,
+ "embeddedObjects", this::getEmbeddedObjects
+ );
}
@Override