You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/09/11 21:24:08 UTC
svn commit: r1866808 [5/7] - in /poi: site/src/documentation/content/xdocs/
trunk/src/java/org/apache/poi/common/usermodel/
trunk/src/java/org/apache/poi/common/usermodel/fonts/
trunk/src/java/org/apache/poi/ddf/ trunk/src/java/org/apache/poi/hssf/user...
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java Wed Sep 11 21:24:06 2019
@@ -20,8 +20,15 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherBoolProperty;
@@ -31,11 +38,13 @@ import org.apache.poi.ddf.EscherOptRecor
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherRGBProperty;
import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@@ -52,7 +61,7 @@ import org.apache.poi.util.POILogger;
// For now, pretending to be an atom. Might not always be, but that
// would require a wrapping class
-public final class PPDrawing extends RecordAtom {
+public final class PPDrawing extends RecordAtom implements Iterable<EscherRecord> {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 10_485_760;
@@ -70,8 +79,14 @@ public final class PPDrawing extends Rec
/**
* Get access to the underlying Escher Records
*/
+ @SuppressWarnings("WeakerAccess")
public List<EscherRecord> getEscherRecords() { return childRecords; }
+ @Override
+ public Iterator<EscherRecord> iterator() {
+ return childRecords.iterator();
+ }
+
/**
* Get access to the atoms inside Textboxes
*/
@@ -97,7 +112,7 @@ public final class PPDrawing extends Rec
/**
* Sets everything up, groks the escher etc
*/
- protected PPDrawing(byte[] source, int start, int len) {
+ PPDrawing(byte[] source, int start, int len) {
// Get the header
_header = new byte[8];
System.arraycopy(source,start,_header,0,8);
@@ -115,61 +130,59 @@ public final class PPDrawing extends Rec
EscherContainerRecord dgContainer = getDgContainer();
if (dgContainer != null) {
- textboxWrappers = findInDgContainer(dgContainer);
+ textboxWrappers = Stream.of(dgContainer).
+ flatMap(findEscherContainer(EscherRecordTypes.SPGR_CONTAINER)).
+ flatMap(findEscherContainer(EscherRecordTypes.SP_CONTAINER)).
+ flatMap(PPDrawing::getTextboxHelper).
+ toArray(EscherTextboxWrapper[]::new);
} else {
// Find and EscherTextboxRecord's, and wrap them up
final List<EscherTextboxWrapper> textboxes = new ArrayList<>();
findEscherTextboxRecord(childRecords, textboxes);
- this.textboxWrappers = textboxes.toArray(new EscherTextboxWrapper[textboxes.size()]);
+ this.textboxWrappers = textboxes.toArray(new EscherTextboxWrapper[0]);
}
}
- private EscherTextboxWrapper[] findInDgContainer(final EscherContainerRecord dgContainer) {
- final List<EscherTextboxWrapper> found = new LinkedList<>();
- final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType(RecordTypes.EscherSpgrContainer, dgContainer);
- final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType(RecordTypes.EscherSpContainer, spgrContainer);
- for (EscherContainerRecord spContainer : spContainers) {
- EscherSpRecord sp = (EscherSpRecord)findFirstEscherRecordOfType(RecordTypes.EscherSp, spContainer);
- EscherTextboxRecord clientTextbox = (EscherTextboxRecord)findFirstEscherRecordOfType(RecordTypes.EscherClientTextbox, spContainer);
- if (null == clientTextbox) { continue; }
-
- EscherTextboxWrapper w = new EscherTextboxWrapper(clientTextbox);
- StyleTextProp9Atom nineAtom = findInSpContainer(spContainer);
- w.setStyleTextProp9Atom(nineAtom);
- if (null != sp) {
- w.setShapeId(sp.getShapeId());
- }
- found.add(w);
+
+ private static Stream<EscherTextboxWrapper> getTextboxHelper(EscherContainerRecord spContainer) {
+ Optional<EscherTextboxRecord> oTB = firstEscherRecord(spContainer, EscherRecordTypes.CLIENT_TEXTBOX);
+ if (!oTB.isPresent()) {
+ return Stream.empty();
}
- return found.toArray(new EscherTextboxWrapper[found.size()]);
+
+ EscherTextboxWrapper tbw = new EscherTextboxWrapper(oTB.get());
+ findInSpContainer(spContainer).ifPresent(tbw::setStyleTextProp9Atom);
+
+ Optional<EscherSpRecord> oSP = firstEscherRecord(spContainer, EscherRecordTypes.SP);
+ oSP.map(EscherSpRecord::getShapeId).ifPresent(tbw::setShapeId);
+
+ return Stream.of(tbw);
}
-
- private StyleTextProp9Atom findInSpContainer(final EscherContainerRecord spContainer) {
- HSLFEscherClientDataRecord cldata = spContainer.getChildById(RecordTypes.EscherClientData.typeID);
- if (cldata == null) {
- return null;
- }
- DummyPositionSensitiveRecordWithChildren progTags =
- getChildRecord(cldata.getHSLFChildRecords(), RecordTypes.ProgTags);
- if (progTags == null) {
- return null;
- }
- DummyPositionSensitiveRecordWithChildren progBinaryTag =
- (DummyPositionSensitiveRecordWithChildren)progTags.findFirstOfType(RecordTypes.ProgBinaryTag.typeID);
- if (progBinaryTag == null) {
- return null;
- }
- int size = progBinaryTag.getChildRecords().length;
- if (2 != size) { return null; }
- final Record r0 = progBinaryTag.getChildRecords()[0];
- final Record r1 = progBinaryTag.getChildRecords()[1];
-
- if (!(r0 instanceof CString)) { return null; }
- if (!("___PPT9".equals(((CString) r0).getText()))) { return null; }
- if (!(r1 instanceof BinaryTagDataBlob )) { return null; }
- final BinaryTagDataBlob blob = (BinaryTagDataBlob) r1;
- if (1 != blob.getChildRecords().length) { return null; }
- return (StyleTextProp9Atom) blob.findFirstOfType(RecordTypes.StyleTextProp9Atom.typeID);
+ private static Optional<StyleTextProp9Atom> findInSpContainer(final EscherContainerRecord spContainer) {
+ Optional<HSLFEscherClientDataRecord> oCD = firstEscherRecord(spContainer, EscherRecordTypes.CLIENT_DATA);
+ return oCD.map(HSLFEscherClientDataRecord::getHSLFChildRecords).map(List::stream).orElseGet(Stream::empty).
+ filter(sameHSLF(RecordTypes.ProgTags)).
+ flatMap(r -> Stream.of(r.getChildRecords())).
+ filter(sameHSLF(RecordTypes.ProgBinaryTag)).
+ flatMap(PPDrawing::findInProgBinaryTag).
+ findFirst();
+ }
+
+ private static Stream<StyleTextProp9Atom> findInProgBinaryTag(Record r) {
+ Record[] ch = r.getChildRecords();
+ if (ch != null &&
+ ch.length == 2 &&
+ ch[0] instanceof CString &&
+ ch[1] instanceof BinaryTagDataBlob &&
+ "___PPT9".equals(((CString)ch[0]).getText())
+ ) {
+ BinaryTagDataBlob blob = (BinaryTagDataBlob) ch[1];
+ StyleTextProp9Atom prop9 = (StyleTextProp9Atom) blob.findFirstOfType(RecordTypes.StyleTextProp9Atom.typeID);
+ if (prop9 != null) {
+ return Stream.of(prop9);
+ }
+ }
+ return Stream.empty();
}
/**
@@ -192,7 +205,7 @@ public final class PPDrawing extends Rec
logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
}
- /**
+ /*
* Sanity check. Always advance the cursor by the correct value.
*
* getRecordSize() must return exactly the same number of bytes that was written in fillFields.
@@ -349,15 +362,7 @@ public final class PPDrawing extends Rec
* @since POI 3.14-Beta2
*/
public EscherContainerRecord getDgContainer() {
- if (childRecords.isEmpty()) {
- return null;
- }
- EscherRecord r = childRecords.get(0);
- if (r instanceof EscherContainerRecord && r.getRecordId() == RecordTypes.EscherDgContainer.typeID) {
- return (EscherContainerRecord)r;
- } else {
- return null;
- }
+ return (EscherContainerRecord)firstEscherRecord(this, EscherRecordTypes.DG_CONTAINER).orElse(null);
}
/**
@@ -367,72 +372,45 @@ public final class PPDrawing extends Rec
*/
public EscherDgRecord getEscherDgRecord(){
if (dg == null) {
- EscherContainerRecord dgr = getDgContainer();
- if (dgr != null) {
- for(EscherRecord r : dgr.getChildRecords()){
- if(r instanceof EscherDgRecord){
- dg = (EscherDgRecord)r;
- break;
- }
- }
- }
+ firstEscherRecord(this, EscherRecordTypes.DG_CONTAINER).
+ flatMap(c -> firstEscherRecord((EscherContainerRecord)c, EscherRecordTypes.DG)).
+ ifPresent(c -> dg = (EscherDgRecord)c);
}
return dg;
}
- protected EscherContainerRecord findFirstEscherContainerRecordOfType(RecordTypes type, EscherContainerRecord parent) {
- if (null == parent) { return null; }
- final List<EscherContainerRecord> children = parent.getChildContainers();
- for (EscherContainerRecord child : children) {
- if (type.typeID == child.getRecordId()) {
- return child;
- }
- }
- return null;
- }
- protected EscherRecord findFirstEscherRecordOfType(RecordTypes type, EscherContainerRecord parent) {
- if (null == parent) { return null; }
- final List<EscherRecord> children = parent.getChildRecords();
- for (EscherRecord child : children) {
- if (type.typeID == child.getRecordId()) {
- return child;
- }
- }
- return null;
- }
- protected EscherContainerRecord[] findAllEscherContainerRecordOfType(RecordTypes type, EscherContainerRecord parent) {
- if (null == parent) { return new EscherContainerRecord[0]; }
- final List<EscherContainerRecord> children = parent.getChildContainers();
- final List<EscherContainerRecord> result = new LinkedList<>();
- for (EscherContainerRecord child : children) {
- if (type.typeID == child.getRecordId()) {
- result.add(child);
- }
- }
- return result.toArray(new EscherContainerRecord[result.size()]);
- }
-
public StyleTextProp9Atom[] getNumberedListInfo() {
- final List<StyleTextProp9Atom> result = new LinkedList<>();
- EscherContainerRecord dgContainer = getDgContainer();
- final EscherContainerRecord spgrContainer = findFirstEscherContainerRecordOfType(RecordTypes.EscherSpgrContainer, dgContainer);
- final EscherContainerRecord[] spContainers = findAllEscherContainerRecordOfType(RecordTypes.EscherSpContainer, spgrContainer);
- for (EscherContainerRecord spContainer : spContainers) {
- StyleTextProp9Atom prop9 = findInSpContainer(spContainer);
- if (prop9 != null) {
- result.add(prop9);
- }
- }
- return result.toArray(new StyleTextProp9Atom[result.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private static <T extends Record> T getChildRecord(List<? extends Record> children, RecordTypes type) {
- for (Record r : children) {
- if (r.getRecordType() == type.typeID) {
- return (T)r;
- }
- }
- return null;
+ EscherContainerRecord dgContainer = getDgContainer();
+
+ return (dgContainer == null) ? new StyleTextProp9Atom[0] : Stream.of(dgContainer).
+ flatMap(findEscherContainer(EscherRecordTypes.SPGR_CONTAINER)).
+ flatMap(findEscherContainer(EscherRecordTypes.SP_CONTAINER)).
+ map(PPDrawing::findInSpContainer).
+ filter(Optional::isPresent).
+ map(Optional::get).
+ toArray(StyleTextProp9Atom[]::new);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("escherRecords", this::getEscherRecords);
+ }
+
+ private static Predicate<Record> sameHSLF(RecordTypes type) {
+ return (p) -> p.getRecordType() == type.typeID;
+ }
+
+ private static Predicate<EscherRecord> sameEscher(EscherRecordTypes type) {
+ return (p) -> p.getRecordId() == type.typeID;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T extends EscherRecord> Optional<T> firstEscherRecord(Iterable<EscherRecord> container, EscherRecordTypes type) {
+ return StreamSupport.stream(container.spliterator(), false).filter(sameEscher(type)).map(o -> (T)o).findFirst();
+ }
+
+ private static Function<EscherContainerRecord,Stream<EscherContainerRecord>> findEscherContainer(EscherRecordTypes type) {
+ return (r) -> r.getChildContainers().stream().filter(sameEscher(type));
+ }
+
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java Wed Sep 11 21:24:06 2019
@@ -17,22 +17,25 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.ddf.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.poi.ddf.DefaultEscherRecordFactory;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-
/**
* Container records which always exists inside Document.
* It always acts as a holder for escher DGG container
* which may contain which Escher BStore container information
* about pictures containes in the presentation (if any).
- *
- * @author Yegor Kozlov
*/
public final class PPDrawingGroup extends RecordAtom {
@@ -131,4 +134,11 @@ public final class PPDrawingGroup extend
}
return dgg;
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "dggContainer", this::getDggContainer
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java Wed Sep 11 21:24:06 2019
@@ -25,10 +25,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@@ -41,8 +44,6 @@ import org.apache.poi.util.POILogger;
* moves, then we have update all of these. If we come up with a new version
* of a slide, then we have to add one of these to the end of the chain
* (via CurrentUserAtom and UserEditAtom) pointing to the new slide location
- *
- * @author Nick Burch
*/
public final class PersistPtrHolder extends PositionDependentRecordAtom
@@ -62,8 +63,8 @@ public final class PersistPtrHolder exte
*/
private Map<Integer,Integer> _slideLocations;
- private static final BitField persistIdFld = new BitField(0X000FFFFF);
- private static final BitField cntPersistFld = new BitField(0XFFF00000);
+ private static final BitField persistIdFld = BitFieldFactory.getInstance(0X000FFFFF);
+ private static final BitField cntPersistFld = BitFieldFactory.getInstance(0XFFF00000);
/**
* Return the value we were given at creation, be it 6001 or 6002
@@ -248,4 +249,11 @@ public final class PersistPtrHolder exte
return buf;
}
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "slideLocations", this::getSlideLocationsLookup
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Wed Sep 11 21:24:06 2019
@@ -20,8 +20,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.RecordTypes.RecordConstructor;
@@ -37,7 +39,7 @@ import org.apache.poi.util.POILogger;
* @author Nick Burch
*/
-public abstract class Record
+public abstract class Record implements GenericRecord
{
// For logging
protected static final POILogger logger = POILogFactory.getLogger(Record.class);
@@ -71,6 +73,17 @@ public abstract class Record
*/
public abstract void writeOut(OutputStream o) throws IOException;
+ @Override
+ public Enum getGenericRecordType() {
+ return RecordTypes.forTypeID((int)getRecordType());
+ }
+
+ @Override
+ public List<Record> getGenericChildren() {
+ Record[] recs = getChildRecords();
+ return (recs == null) ? null : Arrays.asList(recs);
+ }
+
/**
* When writing out, write out a signed int (32bit) in Little Endian format
*/
@@ -188,4 +201,6 @@ public abstract class Record
// Return the created record
return toReturn;
}
+
+
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java Wed Sep 11 21:24:06 2019
@@ -21,6 +21,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.util.MutableByteArrayOutputStream;
import org.apache.poi.util.ArrayUtil;
@@ -370,5 +372,8 @@ public abstract class RecordContainer ex
}
}
-
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return null;
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Wed Sep 11 21:24:06 2019
@@ -169,43 +169,7 @@ public enum RecordTypes {
// Records ~12050 seem to be related to Document Encryption
DocumentEncryptionAtom(12052,DocumentEncryptionAtom::new),
-
- // records greater then 0xF000 belong to with Microsoft Office Drawing format also known as Escher
- EscherDggContainer(0xF000,null),
- EscherDgg(0xf006,null),
- EscherCLSID(0xf016,null),
- EscherOPT(0xf00b,null),
- EscherBStoreContainer(0xf001,null),
- EscherBSE(0xf007,null),
- EscherBlip_START(0xf018,null),
- EscherBlip_END(0xf117,null),
- EscherDgContainer(0xf002,null),
- EscherDg(0xf008,null),
- EscherRegroupItems(0xf118,null),
- EscherColorScheme(0xf120,null),
- EscherSpgrContainer(0xf003,null),
- EscherSpContainer(0xf004,null),
- EscherSpgr(0xf009,null),
- EscherSp(0xf00a,null),
- EscherTextbox(0xf00c,null),
- EscherClientTextbox(0xf00d,null),
- EscherAnchor(0xf00e,null),
- EscherChildAnchor(0xf00f,null),
- EscherClientAnchor(0xf010,null),
- EscherClientData(0xf011,null),
- EscherSolverContainer(0xf005,null),
- EscherConnectorRule(0xf012,null),
- EscherAlignRule(0xf013,null),
- EscherArcRule(0xf014,null),
- EscherClientRule(0xf015,null),
- EscherCalloutRule(0xf017,null),
- EscherSelection(0xf119,null),
- EscherColorMRU(0xf11a,null),
- EscherDeletedPspl(0xf11d,null),
- EscherSplitMenuColors(0xf11e,null),
- EscherOleObject(0xf11f,null),
- // same as EscherTertiaryOptRecord.RECORD_ID
- EscherUserDefined(0xf122,null);
+ ;
@FunctionalInterface
public interface RecordConstructor<T extends Record> {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndian;
/**
@@ -102,4 +105,9 @@ public final class RoundTripHFPlaceholde
out.write(_header);
out.write(_placeholderId);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("placeholderId", this::getPlaceholderId );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SSSlideInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SSSlideInfoAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SSSlideInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SSSlideInfoAtom.java Wed Sep 11 21:24:06 2019
@@ -17,9 +17,14 @@
package org.apache.poi.hslf.record;
+import static org.apache.poi.util.GenericRecordUtil.getBitsAsString;
+
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
@@ -108,7 +113,27 @@ public class SSSlideInfoAtom extends Rec
// public static int RESERVED5_BIT = 1 << 9;
// public static int RESERVED6_BIT = 1 << 11;
// public static int RESERVED7_BIT = 1 << 13 | 1 << 14 | 1 << 15;
-
+
+ private static final int[] EFFECT_MASKS = {
+ MANUAL_ADVANCE_BIT,
+ HIDDEN_BIT,
+ SOUND_BIT,
+ LOOP_SOUND_BIT,
+ STOP_SOUND_BIT,
+ AUTO_ADVANCE_BIT,
+ CURSOR_VISIBLE_BIT
+ };
+
+ private static final String[] EFFECT_NAMES = {
+ "MANUAL_ADVANCE",
+ "HIDDEN",
+ "SOUND",
+ "LOOP_SOUND",
+ "STOP_SOUND",
+ "AUTO_ADVANCE",
+ "CURSOR_VISIBLE"
+ };
+
private static final long _type = RecordTypes.SSSlideInfoAtom.typeID;
private byte[] _header;
@@ -286,4 +311,16 @@ public class SSSlideInfoAtom extends Rec
public void setSpeed(short speed) {
this._speed = speed;
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "effectTransitionFlags", getBitsAsString(this::getEffectTransitionFlags, EFFECT_MASKS, EFFECT_NAMES),
+ "slideTime", this::getSlideTime,
+ "soundIdRef", this::getSoundIdRef,
+ "effectDirection", this::getEffectDirection,
+ "effectType", this::getEffectType,
+ "speed", this::getSpeed
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java Wed Sep 11 21:24:06 2019
@@ -19,8 +19,11 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.record.SlideAtomLayout.SlideLayoutType;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -170,4 +173,16 @@ public final class SlideAtom extends Rec
// Reserved data
out.write(reserved);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "masterID", this::getMasterID,
+ "notesID", this::getNotesID,
+ "followMasterObjects", this::getFollowMasterObjects,
+ "followMasterScheme", this::getFollowMasterScheme,
+ "followMasterBackground", this::getFollowMasterBackground,
+ "layoutAtom", this::getSSlideLayoutAtom
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java Wed Sep 11 21:24:06 2019
@@ -19,8 +19,12 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@@ -32,7 +36,7 @@ import org.apache.poi.util.LittleEndian;
* This might eventually merged with the XSLF counterpart
*/
@Internal
-public class SlideAtomLayout {
+public class SlideAtomLayout implements GenericRecord {
// The different kinds of geometry
public enum SlideLayoutType {
/** One title and one subtitle placeholder shapes. */
@@ -130,4 +134,11 @@ public class SlideAtomLayout {
out.write(placeholderIDs);
}
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "geometry", this::getGeometryType,
+ "placeholderIDs", () -> placeholderIDs
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java Wed Sep 11 21:24:06 2019
@@ -47,6 +47,7 @@ import org.apache.poi.util.LittleEndian;
// For now, pretend to be an atom
public final class SlideListWithText extends RecordContainer {
+ private static final long _type = RecordTypes.SlideListWithText.typeID;
/**
* Instance filed of the record header indicates that this SlideListWithText stores
@@ -65,7 +66,6 @@ public final class SlideListWithText ext
public static final int NOTES = 2;
private byte[] _header;
- private static long _type = 4080;
private SlideAtomsSet[] slideAtomsSets;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlidePersistAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlidePersistAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlidePersistAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlidePersistAtom.java Wed Sep 11 21:24:06 2019
@@ -17,45 +17,61 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.LittleEndian;
+import static org.apache.poi.util.GenericRecordUtil.getBitsAsString;
+
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.poi.util.GenericRecordUtil;
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.LittleEndian;
/**
* A SlidePersist Atom (type 1011). Holds information on the text of a
* given slide, which are stored in the same SlideListWithText
- *
- * @author Nick Burch
*/
public final class SlidePersistAtom extends RecordAtom {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 32;
- private byte[] _header;
- private static long _type = 1011l;
+ private static final long _type = 1011l;
+ private static final int HAS_SHAPES_OTHER_THAN_PLACEHOLDERS = 4;
- /**
- * Slide reference ID. Should correspond to the PersistPtr
- * "sheet ID" of the matching slide/notes record
- */
+ private static final int[] FLAGS_MASKS = { HAS_SHAPES_OTHER_THAN_PLACEHOLDERS };
+ private static final String[] FLAGS_NAMES = { "HAS_SHAPES_OTHER_THAN_PLACEHOLDERS" };
+
+
+ private final byte[] _header = new byte[8];
+
+ /** Slide reference ID. Should correspond to the PersistPtr "sheet ID" of the matching slide/notes record */
private int refID;
- private boolean hasShapesOtherThanPlaceholders;
+ private int flags;
+
/** Number of placeholder texts that will follow in the SlideListWithText */
private int numPlaceholderTexts;
- /**
- * The internal identifier (256+), which is used to tie slides
- * and notes together
- */
+ /** The internal identifier (256+), which is used to tie slides and notes together */
private int slideIdentifier;
/** Reserved fields. Who knows what they do */
private byte[] reservedFields;
- public int getRefID() { return refID; }
- public int getSlideIdentifier() { return slideIdentifier; }
- public int getNumPlaceholderTexts() { return numPlaceholderTexts; }
- public boolean getHasShapesOtherThanPlaceholders() { return hasShapesOtherThanPlaceholders; }
+ public int getRefID() {
+ return refID;
+ }
+
+ public int getSlideIdentifier() {
+ return slideIdentifier;
+ }
+
+ public int getNumPlaceholderTexts() {
+ return numPlaceholderTexts;
+ }
+
+ public boolean getHasShapesOtherThanPlaceholders() {
+ return (flags & HAS_SHAPES_OTHER_THAN_PLACEHOLDERS) != 0;
+ }
// Only set these if you know what you're doing!
public void setRefID(int id) {
@@ -75,19 +91,13 @@ public final class SlidePersistAtom exte
if(len < 8) { len = 8; }
// Get the header
- _header = new byte[8];
System.arraycopy(source,start,_header,0,8);
// Grab the reference ID
refID = LittleEndian.getInt(source,start+8);
// Next up is a set of flags, but only bit 3 is used!
- int flags = LittleEndian.getInt(source,start+12);
- if(flags == 4) {
- hasShapesOtherThanPlaceholders = true;
- } else {
- hasShapesOtherThanPlaceholders = false;
- }
+ flags = LittleEndian.getInt(source,start+12);
// Now the number of Placeholder Texts
numPlaceholderTexts = LittleEndian.getInt(source,start+16);
@@ -104,13 +114,12 @@ public final class SlidePersistAtom exte
/**
* Create a new SlidePersistAtom, for use with a new Slide
*/
- public SlidePersistAtom(){
- _header = new byte[8];
+ public SlidePersistAtom() {
LittleEndian.putUShort(_header, 0, 0);
LittleEndian.putUShort(_header, 2, (int)_type);
LittleEndian.putInt(_header, 4, 20);
- hasShapesOtherThanPlaceholders = true;
+ flags = HAS_SHAPES_OTHER_THAN_PLACEHOLDERS;
reservedFields = new byte[4];
}
@@ -127,12 +136,6 @@ public final class SlidePersistAtom exte
// Header - size or type unchanged
out.write(_header);
- // Compute the flags part - only bit 3 is used
- int flags = 0;
- if(hasShapesOtherThanPlaceholders) {
- flags = 4;
- }
-
// Write out our fields
writeLittleEndian(refID,out);
writeLittleEndian(flags,out);
@@ -140,4 +143,14 @@ public final class SlidePersistAtom exte
writeLittleEndian(slideIdentifier,out);
out.write(reservedFields);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "refID", this::getRefID,
+ "flags", getBitsAsString(() -> flags, FLAGS_MASKS, FLAGS_NAMES),
+ "numPlaceholderTexts", this::getNumPlaceholderTexts,
+ "slideIdentifier", this::getSlideIdentifier
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -102,4 +105,9 @@ public final class SoundData extends Rec
out.write(_header);
out.write(_data);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("data", this::getData);
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java Wed Sep 11 21:24:06 2019
@@ -21,8 +21,11 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.model.textproperties.TextPFException9;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -145,4 +148,11 @@ public final class StyleTextProp9Atom ex
// Update the size (header bytes 5-8)
LittleEndian.putInt(header, 4, data.length);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "autoNumberSchemes", this::getAutoNumberTypes
+ );
+ }
}
\ No newline at end of file
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Wed Sep 11 21:24:06 2019
@@ -22,10 +22,13 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -109,11 +112,7 @@ public final class StyleTextPropAtom ext
return getCharactersCovered(charStyles);
}
private int getCharactersCovered(List<TextPropCollection> styles) {
- int length = 0;
- for(TextPropCollection tpc : styles) {
- length += tpc.getCharactersCovered();
- }
- return length;
+ return styles.stream().mapToInt(TextPropCollection::getCharactersCovered).sum();
}
/* *************** record code follows ********************** */
@@ -406,4 +405,12 @@ public final class StyleTextPropAtom ext
return out.toString();
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return !initialised ? null : GenericRecordUtil.getGenericProperties(
+ "paragraphStyles", this::getParagraphStyles,
+ "characterStyles", this::getCharacterStyles
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -116,4 +119,11 @@ public final class TextBytesAtom extends
out.append( HexDump.dump(_text, 0, 0) );
return out.toString();
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "text", this::getText
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -112,4 +115,11 @@ public final class TextCharsAtom extends
out.append( HexDump.dump(_text, 0, 0) );
return out.toString();
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "text", this::getText
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java Wed Sep 11 21:24:06 2019
@@ -19,8 +19,12 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndian;
/**
@@ -34,15 +38,6 @@ public final class TextHeaderAtom extend
private byte[] _header;
private RecordContainer parentRecord;
- public static final int TITLE_TYPE = 0;
- public static final int BODY_TYPE = 1;
- public static final int NOTES_TYPE = 2;
- public static final int OTHER_TYPE = 4;
- public static final int CENTRE_BODY_TYPE = 5;
- public static final int CENTER_TITLE_TYPE = 6;
- public static final int HALF_BODY_TYPE = 7;
- public static final int QUARTER_BODY_TYPE = 8;
-
/** The kind of text it is */
private int textType;
/** position in the owning SlideListWithText */
@@ -50,7 +45,15 @@ public final class TextHeaderAtom extend
public int getTextType() { return textType; }
public void setTextType(int type) { textType = type; }
-
+
+ public TextPlaceholder getTextTypeEnum() {
+ return TextPlaceholder.fromNativeId(textType);
+ }
+
+ public void setTextTypeEnum(TextPlaceholder placeholder) {
+ textType = placeholder.nativeId;
+ }
+
/**
* @return 0-based index of the text run in the SLWT container
*/
@@ -97,7 +100,7 @@ public final class TextHeaderAtom extend
LittleEndian.putUShort(_header, 2, (int)_type);
LittleEndian.putInt(_header, 4, 4);
- textType = OTHER_TYPE;
+ textType = TextPlaceholder.OTHER.nativeId;
}
/**
@@ -118,4 +121,12 @@ public final class TextHeaderAtom extend
// Write out our type
writeLittleEndian(textType,out);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "index", this::getIndex,
+ "textType", this::getTextTypeEnum
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java Wed Sep 11 21:24:06 2019
@@ -25,10 +25,13 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.model.textproperties.HSLFTabStop;
import org.apache.poi.hslf.model.textproperties.HSLFTabStopPropCollection;
import org.apache.poi.util.BitField;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@@ -222,4 +225,15 @@ public final class TextRulerAtom extends
this.indent[0] = (int)indent;
this.indent[1] = (int)indent;
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "defaultTabSize", this::getDefaultTabSize,
+ "numLevels", this::getNumberOfLevels,
+ "tabStops", this::getTabStops,
+ "leftMargins", () -> leftMargin,
+ "indents", () -> indent
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java Wed Sep 11 21:24:06 2019
@@ -22,8 +22,11 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@@ -177,4 +180,11 @@ public final class TextSpecInfoAtom exte
return lst.toArray(new TextSpecInfoRun[lst.size()]);
}
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "charactersCovered", this::getCharactersCovered,
+ "textSpecInfoRuns", this::getTextSpecInfoRuns
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java Wed Sep 11 21:24:06 2019
@@ -17,15 +17,23 @@
package org.apache.poi.hslf.record;
+import static org.apache.poi.util.GenericRecordUtil.getBitsAsString;
+
import java.io.IOException;
import java.io.OutputStream;
+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.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
-public class TextSpecInfoRun {
+public class TextSpecInfoRun implements GenericRecord {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 1_000_000;
@@ -51,34 +59,42 @@ public class TextSpecInfoRun {
}
/** A bit that specifies whether the spellInfo field exists. */
- private static final BitField spellFld = new BitField(0X00000001);
+ private static final BitField spellFld = BitFieldFactory.getInstance(0X00000001);
/** A bit that specifies whether the lid field exists. */
- private static final BitField langFld = new BitField(0X00000002);
+ private static final BitField langFld = BitFieldFactory.getInstance(0X00000002);
/** A bit that specifies whether the altLid field exists. */
- private static final BitField altLangFld = new BitField(0X00000004);
+ private static final BitField altLangFld = BitFieldFactory.getInstance(0X00000004);
// unused1, unused2 - Undefined and MUST be ignored.
/** A bit that specifies whether the pp10runid, reserved3, and grammarError fields exist. */
- private static final BitField pp10extFld = new BitField(0X00000020);
+ private static final BitField pp10extFld = BitFieldFactory.getInstance(0X00000020);
/** A bit that specifies whether the bidi field exists. */
- private static final BitField bidiFld = new BitField(0X00000040);
+ private static final BitField bidiFld = BitFieldFactory.getInstance(0X00000040);
// unused3 - Undefined and MUST be ignored.
// reserved1 - MUST be zero and MUST be ignored.
/** A bit that specifies whether the smartTags field exists. */
- private static final BitField smartTagFld = new BitField(0X00000200);
+ private static final BitField smartTagFld = BitFieldFactory.getInstance(0X00000200);
// reserved2 - MUST be zero and MUST be ignored.
/**
* An optional unsigned integer that specifies an identifier for a character
* run that contains StyleTextProp11 data. It MUST exist if and only if pp10ext is TRUE.
**/
- private static final BitField pp10runidFld = new BitField(0X0000000F);
+ private static final BitField pp10runidFld = BitFieldFactory.getInstance(0X0000000F);
// reserved3 - An optional unsigned integer that MUST be zero, and MUST be ignored. It
// MUST exist if and only if fPp10ext is TRUE.
/**
* An optional bit that specifies a grammar error. It MUST exist if and
* only if fPp10ext is TRUE.
**/
- private static final BitField grammarErrorFld = new BitField(0X80000000);
+ private static final BitField grammarErrorFld = BitFieldFactory.getInstance(0X80000000);
+
+ private static final int[] FLAGS_MASKS = {
+ 0X00000001, 0X00000002, 0X00000004, 0X00000020, 0X00000040, 0X00000200,
+ };
+
+ private static final String[] FLAGS_NAMES = {
+ "SPELL", "LANG", "ALT_LANG", "PP10_EXT", "BIDI", "SMART_TAG"
+ };
//Length of special info run.
private int length;
@@ -357,4 +373,18 @@ public class TextSpecInfoRun {
// if both parameters are invalid, remove the extension mask
mask = pp10extFld.setBoolean(mask, pp10extMask != -1);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String,Supplier<?>> m = new LinkedHashMap<>();
+ m.put("flags", getBitsAsString(() -> mask, FLAGS_MASKS, FLAGS_NAMES));
+ m.put("spellInfo", this::getSpellInfo);
+ m.put("langId", this::getLangId);
+ m.put("altLangId", this::getAltLangId);
+ m.put("bidi", this::getBidi);
+ m.put("pp10RunId", this::getPP10RunId);
+ m.put("grammarError", this::getGrammarError);
+ m.put("smartTags", this::getSmartTagsBytes);
+ return Collections.unmodifiableMap(m);
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java Wed Sep 11 21:24:06 2019
@@ -17,12 +17,15 @@
package org.apache.poi.hslf.record;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
-import java.io.OutputStream;
-import java.io.IOException;
-
/**
* Tne atom that holds starting and ending character positions of a hyperlink
*
@@ -125,4 +128,12 @@ public final class TxInteractiveInfoAtom
out.write(_header);
out.write(_data);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "startIndex", this::getStartIndex,
+ "endIndex", this::getEndIndex
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java Wed Sep 11 21:24:06 2019
@@ -22,10 +22,14 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianOutputStream;
@@ -45,8 +49,6 @@ import org.apache.poi.util.POILogger;
* each pair describes an indent level. The first pair describes
* first-level paragraph with no indentation.
* </p>
- *
- * @author Yegor Kozlov
*/
public final class TxMasterStyleAtom extends RecordAtom {
private static final POILogger LOG = POILogFactory.getLogger(TxMasterStyleAtom.class);
@@ -58,8 +60,9 @@ public final class TxMasterStyleAtom ext
*/
public static final int MAX_INDENT = 5;
+ private static final long _type = RecordTypes.TxMasterStyleAtom.typeID;
+
private byte[] _header;
- private static long _type = 4003;
private byte[] _data;
private List<TextPropCollection> paragraphStyles;
@@ -152,7 +155,7 @@ public final class TxMasterStyleAtom ext
for(short i = 0; i < levels; i++) {
TextPropCollection prprops = new TextPropCollection(0, TextPropType.paragraph);
- if (type >= TextHeaderAtom.CENTRE_BODY_TYPE) {
+ if (type >= TextPlaceholder.CENTER_BODY.nativeId) {
// Fetch the 2 byte value, that is safe to ignore for some types of text
short indentLevel = LittleEndian.getShort(_data, pos);
prprops.setIndentLevel(indentLevel);
@@ -195,7 +198,7 @@ public final class TxMasterStyleAtom ext
for (int i=0; i<levels; i++) {
prdummy.copy(paragraphStyles.get(i));
chdummy.copy(charStyles.get(i));
- if (type >= TextHeaderAtom.CENTRE_BODY_TYPE) {
+ if (type >= TextPlaceholder.CENTER_BODY.nativeId) {
leos.writeShort(prdummy.getIndentLevel());
}
@@ -213,4 +216,12 @@ public final class TxMasterStyleAtom ext
throw new HSLFException("error in updating master style properties", e);
}
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "paragraphStyles", this::getParagraphStyles,
+ "charStyles", this::getCharacterStyles
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
@@ -76,4 +79,9 @@ public final class UnknownRecordPlacehol
public void writeOut(OutputStream out) throws IOException {
out.write(_contents);
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties("contents", () -> _contents);
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java Wed Sep 11 21:24:06 2019
@@ -19,7 +19,10 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.function.Supplier;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.LittleEndian;
@@ -32,8 +35,6 @@ import org.apache.poi.util.LittleEndianC
* ** WARNING ** stores byte offsets from the start of the PPT stream to
* other records! If you change the size of any elements before one of
* these, you'll need to update the offsets!
- *
- * @author Nick Burch
*/
public final class UserEditAtom extends PositionDependentRecordAtom
@@ -44,7 +45,7 @@ public final class UserEditAtom extends
public static final int LAST_VIEW_NOTES = 3;
private byte[] _header;
- private static long _type = 4085l;
+ private static final long _type = RecordTypes.UserEditAtom.typeID;
private short unused;
private int lastViewedSlideID;
@@ -190,4 +191,18 @@ public final class UserEditAtom extends
writeLittleEndian(encryptSessionPersistIdRef,out);
}
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String, Supplier<?>> m = new LinkedHashMap<>();
+ m.put("lastViewedSlideID", this::getLastViewedSlideID);
+ m.put("pptVersion", () -> pptVersion);
+ m.put("lastUserEditAtomOffset", this::getLastUserEditAtomOffset);
+ m.put("persistPointersOffset", this::getPersistPointersOffset);
+ m.put("docPersistRef", this::getDocPersistRef);
+ m.put("maxPersistWritten", this::getMaxPersistWritten);
+ m.put("lastViewType", this::getLastViewType);
+ m.put("encryptSessionPersistIdRef", this::getEncryptSessionPersistIdRef);
+ return Collections.unmodifiableMap(m);
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoAtom.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoAtom.java Wed Sep 11 21:24:06 2019
@@ -17,10 +17,12 @@
package org.apache.poi.hslf.record;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.LittleEndian;
/**
@@ -114,5 +116,12 @@ public final class VBAInfoAtom extends R
this.version = version;
}
-
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "persistIdRef", this::getPersistIdRef,
+ "hasMacros", this::isHasMacros,
+ "version", this::getVersion
+ );
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoContainer.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoContainer.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/VBAInfoContainer.java Wed Sep 11 21:24:06 2019
@@ -27,7 +27,7 @@ import org.apache.poi.util.LittleEndian;
*/
public final class VBAInfoContainer extends RecordContainer {
private byte[] _header;
- private static long _type = RecordTypes.VBAInfo.typeID;
+ private static final long _type = RecordTypes.VBAInfo.typeID;
// Links to our more interesting children
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java Wed Sep 11 21:24:06 2019
@@ -29,9 +29,9 @@ import org.apache.poi.ddf.EscherColorRef
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.hslf.record.Document;
-import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.usermodel.ColorStyle;
import org.apache.poi.sl.usermodel.FillStyle;
@@ -257,7 +257,7 @@ public final class HSLFFill {
private boolean isRotatedWithShape() {
// NOFILLHITTEST can be in the normal escher opt record but also in the tertiary record
// the extended bit fields seem to be in the second
- AbstractEscherOptRecord opt = shape.getEscherChild(RecordTypes.EscherUserDefined);
+ AbstractEscherOptRecord opt = shape.getEscherChild(EscherRecordTypes.USER_DEFINED);
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
int propVal = (p == null) ? 0 : p.getPropertyValue();
return FILL_USE_USE_SHAPE_ANCHOR.isSet(propVal) && FILL_USE_SHAPE_ANCHOR.isSet(propVal);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java Wed Sep 11 21:24:06 2019
@@ -35,13 +35,13 @@ import org.apache.poi.ddf.EscherContaine
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherProperty;
import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.HSLFEscherClientDataRecord;
import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.draw.DrawFactory;
import org.apache.poi.sl.usermodel.FillStyle;
import org.apache.poi.sl.usermodel.PresetColor;
@@ -241,7 +241,7 @@ public abstract class HSLFShape implemen
/**
* @since POI 3.14-Beta2
*/
- public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, RecordTypes recordId){
+ public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, EscherRecordTypes recordId){
return getEscherChild(owner, recordId.typeID);
}
@@ -252,7 +252,7 @@ public abstract class HSLFShape implemen
/**
* @since POI 3.14-Beta2
*/
- public <T extends EscherRecord> T getEscherChild(RecordTypes recordId){
+ public <T extends EscherRecord> T getEscherChild(EscherRecordTypes recordId){
return getEscherChild(recordId.typeID);
}
@@ -577,9 +577,9 @@ public abstract class HSLFShape implemen
}
public AbstractEscherOptRecord getEscherOptRecord() {
- AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherOPT);
+ AbstractEscherOptRecord opt = getEscherChild(EscherRecordTypes.OPT);
if (opt == null) {
- opt = getEscherChild(RecordTypes.EscherUserDefined);
+ opt = getEscherChild(EscherRecordTypes.USER_DEFINED);
}
return opt;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java Wed Sep 11 21:24:06 2019
@@ -27,6 +27,7 @@ import org.apache.poi.ddf.EscherProperti
import org.apache.poi.ddf.EscherProperty;
import org.apache.poi.ddf.EscherPropertyFactory;
import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
@@ -64,7 +65,7 @@ public final class HSLFShapeFactory {
public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
boolean isTable = false;
EscherContainerRecord ecr = (EscherContainerRecord)spContainer.getChild(0);
- EscherRecord opt = HSLFShape.getEscherChild(ecr, RecordTypes.EscherUserDefined);
+ EscherRecord opt = HSLFShape.getEscherChild(ecr, EscherRecordTypes.USER_DEFINED);
if (opt != null) {
EscherPropertyFactory f = new EscherPropertyFactory();
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Wed Sep 11 21:24:06 2019
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.model.HeadersFooters;
@@ -47,6 +48,7 @@ import org.apache.poi.sl.usermodel.Notes
import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.Slide;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
/**
* This class represents a slide in a PowerPoint Document. It allows
@@ -168,12 +170,12 @@ public final class HSLFSlide extends HSL
for (EscherContainerRecord c : dgContainer.getChildContainers()) {
EscherSpRecord spr = null;
- switch(c.getRecordId()){
- case EscherContainerRecord.SPGR_CONTAINER:
+ switch(EscherRecordTypes.forTypeID(c.getRecordId())){
+ case SPGR_CONTAINER:
EscherContainerRecord dc = (EscherContainerRecord)c.getChild(0);
spr = dc.getChildById(EscherSpRecord.RECORD_ID);
break;
- case EscherContainerRecord.SP_CONTAINER:
+ case SP_CONTAINER:
spr = c.getChildById(EscherSpRecord.RECORD_ID);
break;
default:
@@ -197,7 +199,7 @@ public final class HSLFSlide extends HSL
HSLFPlaceholder pl = new HSLFPlaceholder();
pl.setShapeType(ShapeType.RECT);
pl.setPlaceholder(Placeholder.TITLE);
- pl.setRunType(TextHeaderAtom.TITLE_TYPE);
+ pl.setRunType(TextPlaceholder.TITLE.nativeId);
pl.setText("Click to edit title");
pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
addShape(pl);
@@ -222,12 +224,10 @@ public final class HSLFSlide extends HSL
continue;
}
int type = tp.get(0).getRunType();
- switch (type) {
- case TextHeaderAtom.CENTER_TITLE_TYPE:
- case TextHeaderAtom.TITLE_TYPE:
- String str = HSLFTextParagraph.getRawText(tp);
- return HSLFTextParagraph.toExternalString(str, type);
- }
+ if (TextPlaceholder.isTitle(type)) {
+ String str = HSLFTextParagraph.getRawText(tp);
+ return HSLFTextParagraph.toExternalString(str, type);
+ }
}
return null;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java Wed Sep 11 21:24:06 2019
@@ -26,6 +26,7 @@ import org.apache.poi.hslf.model.textpro
import org.apache.poi.hslf.record.MainMaster;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.TxMasterStyleAtom;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
import org.apache.poi.util.Internal;
/**
@@ -106,13 +107,15 @@ public final class HSLFSlideMaster exten
}
}
- switch (txtype) {
- case TextHeaderAtom.CENTRE_BODY_TYPE:
- case TextHeaderAtom.HALF_BODY_TYPE:
- case TextHeaderAtom.QUARTER_BODY_TYPE:
- return getPropCollection(TextHeaderAtom.BODY_TYPE, level, name, isCharacter);
- case TextHeaderAtom.CENTER_TITLE_TYPE:
- return getPropCollection(TextHeaderAtom.TITLE_TYPE, level, name, isCharacter);
+ switch (TextPlaceholder.fromNativeId(txtype)) {
+ case BODY:
+ case CENTER_BODY:
+ case HALF_BODY:
+ case QUARTER_BODY:
+ return getPropCollection(TextPlaceholder.BODY.nativeId, level, name, isCharacter);
+ case TITLE:
+ case CENTER_TITLE:
+ return getPropCollection(TextPlaceholder.TITLE.nativeId, level, name, isCharacter);
default:
return null;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Wed Sep 11 21:24:06 2019
@@ -31,7 +31,9 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.common.usermodel.fonts.FontInfo;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -63,7 +65,7 @@ import org.apache.poi.util.Units;
* TODO: - figure out how to match notes to their correct sheet (will involve
* understanding DocSlideList and DocNotesList) - handle Slide creation cleaner
*/
-public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagraph>, Closeable {
+public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagraph>, Closeable, GenericRecord {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 10_000_000;
@@ -1163,4 +1165,14 @@ public final class HSLFSlideShow impleme
public Object getPersistDocument() {
return getSlideShowImpl();
}
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return null;
+ }
+
+ @Override
+ public List<? extends GenericRecord> getGenericChildren() {
+ return Arrays.asList(_hslfSlideShow.getRecords());
+ }
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java Wed Sep 11 21:24:06 2019
@@ -31,8 +31,8 @@ import org.apache.poi.ddf.EscherArrayPro
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.EscherSimpleProperty;
-import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.TableShape;
import org.apache.poi.util.LittleEndian;
@@ -100,14 +100,14 @@ implements HSLFShapeContainer, TableShap
EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
AbstractEscherOptRecord opt = new EscherOptRecord();
- opt.setRecordId(RecordTypes.EscherUserDefined.typeID);
+ opt.setRecordId(EscherRecordTypes.USER_DEFINED.typeID);
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__TABLEPROPERTIES, 1));
EscherArrayProperty p = new EscherArrayProperty((short)(0x4000 | EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES), false, null);
p.setSizeOfElements(0x0004);
p.setNumberOfElementsInArray(numRows);
p.setNumberOfElementsInMemory(numRows);
opt.addEscherProperty(p);
- spCont.addChildBefore(opt, RecordTypes.EscherClientAnchor.typeID);
+ spCont.addChildBefore(opt, EscherRecordTypes.CLIENT_ANCHOR.typeID);
}
/**
@@ -367,7 +367,7 @@ implements HSLFShapeContainer, TableShap
}
// update row height in the table properties
- AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
+ AbstractEscherOptRecord opt = getEscherChild(EscherRecordTypes.USER_DEFINED);
EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
byte[] masterBytes = p.getElement(row);
double currentHeight = Units.masterToPoints(LittleEndian.getInt(masterBytes, 0));
@@ -460,7 +460,7 @@ implements HSLFShapeContainer, TableShap
}
private void updateRowHeightsProperty() {
- AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
+ AbstractEscherOptRecord opt = getEscherChild(EscherRecordTypes.USER_DEFINED);
EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
byte[] val = new byte[4];
for (int rowIdx = 0; rowIdx < cells.length; rowIdx++) {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Wed Sep 11 21:24:06 2019
@@ -50,6 +50,7 @@ import org.apache.poi.sl.usermodel.Place
import org.apache.poi.sl.usermodel.TabStop;
import org.apache.poi.sl.usermodel.TabStop.TabStopType;
import org.apache.poi.sl.usermodel.TextParagraph;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
@@ -1291,20 +1292,12 @@ public final class HSLFTextParagraph imp
// them to \n
String text = rawText.replace('\r', '\n');
- switch (runType) {
- // 0xB acts like cariage return in page titles and like blank in the
- // others
- case -1:
- case org.apache.poi.hslf.record.TextHeaderAtom.TITLE_TYPE:
- case org.apache.poi.hslf.record.TextHeaderAtom.CENTER_TITLE_TYPE:
- text = text.replace((char) 0x0B, '\n');
- break;
- default:
- text = text.replace((char) 0x0B, ' ');
- break;
- }
+ // 0xB acts like carriage return in page titles and like blank in the others
+ final char repl = (runType == -1 ||
+ runType == TextPlaceholder.TITLE.nativeId ||
+ runType == TextPlaceholder.CENTER_TITLE.nativeId) ? '\n' : ' ';
- return text;
+ return text.replace('\u000b', repl);
}
/**
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java Wed Sep 11 21:24:06 2019
@@ -19,6 +19,8 @@ package org.apache.poi.hslf.usermodel;
import static org.apache.poi.hslf.record.RecordTypes.OEPlaceholderAtom;
import static org.apache.poi.hslf.record.RecordTypes.RoundTripHFPlaceholder12;
+import static org.apache.poi.sl.usermodel.TextShape.TextPlaceholder.CENTER_TITLE;
+import static org.apache.poi.sl.usermodel.TextShape.TextPlaceholder.TITLE;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
@@ -376,7 +378,7 @@ implements TextShape<HSLFShape,HSLFTextP
/* package */ HSLFTextAnchor getAlignment(){
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
- HSLFTextAnchor align = HSLFTextAnchor.TOP;
+ final HSLFTextAnchor align;
if (prop == null){
/**
* If vertical alignment was not found in the shape properties then try to
@@ -386,29 +388,17 @@ implements TextShape<HSLFShape,HSLFTextP
HSLFSheet sh = getSheet();
HSLFMasterSheet master = (sh != null) ? sh.getMasterSheet() : null;
HSLFTextShape masterShape = (master != null) ? master.getPlaceholderByTextType(type) : null;
- if (masterShape != null && type != TextHeaderAtom.OTHER_TYPE) {
+ if (masterShape != null && type != TextPlaceholder.OTHER.nativeId) {
align = masterShape.getAlignment();
} else {
//not found in the master sheet. Use the hardcoded defaults.
- switch (type){
- case TextHeaderAtom.TITLE_TYPE:
- case TextHeaderAtom.CENTER_TITLE_TYPE:
- align = HSLFTextAnchor.MIDDLE;
- break;
- default:
- align = HSLFTextAnchor.TOP;
- break;
- }
+ align = (TextPlaceholder.isTitle(type)) ? HSLFTextAnchor.MIDDLE : HSLFTextAnchor.TOP;
}
} else {
align = HSLFTextAnchor.fromNativeId(prop.getPropertyValue());
}
- if (align == null) {
- align = HSLFTextAnchor.TOP;
- }
-
- return align;
+ return (align == null) ? HSLFTextAnchor.TOP : align;
}
/**
@@ -866,34 +856,34 @@ implements TextShape<HSLFShape,HSLFTextP
switch (placeholder) {
default:
case BODY:
- runType = TextHeaderAtom.BODY_TYPE;
+ runType = TextPlaceholder.BODY.nativeId;
ph = Placeholder.BODY;
break;
case TITLE:
- runType = TextHeaderAtom.TITLE_TYPE;
+ runType = TITLE.nativeId;
ph = Placeholder.TITLE;
break;
case CENTER_BODY:
- runType = TextHeaderAtom.CENTRE_BODY_TYPE;
+ runType = TextPlaceholder.CENTER_BODY.nativeId;
ph = Placeholder.BODY;
break;
case CENTER_TITLE:
- runType = TextHeaderAtom.CENTER_TITLE_TYPE;
+ runType = CENTER_TITLE.nativeId;
ph = Placeholder.TITLE;
break;
case HALF_BODY:
- runType = TextHeaderAtom.HALF_BODY_TYPE;
+ runType = TextPlaceholder.HALF_BODY.nativeId;
ph = Placeholder.BODY;
break;
case QUARTER_BODY:
- runType = TextHeaderAtom.QUARTER_BODY_TYPE;
+ runType = TextPlaceholder.QUARTER_BODY.nativeId;
ph = Placeholder.BODY;
break;
case NOTES:
- runType = TextHeaderAtom.NOTES_TYPE;
+ runType = TextPlaceholder.NOTES.nativeId;
break;
case OTHER:
- runType = TextHeaderAtom.OTHER_TYPE;
+ runType = TextPlaceholder.OTHER.nativeId;
break;
}
setRunType(runType);
@@ -904,17 +894,7 @@ implements TextShape<HSLFShape,HSLFTextP
@Override
public TextPlaceholder getTextPlaceholder() {
- switch (getRunType()) {
- default:
- case TextHeaderAtom.BODY_TYPE: return TextPlaceholder.BODY;
- case TextHeaderAtom.TITLE_TYPE: return TextPlaceholder.TITLE;
- case TextHeaderAtom.NOTES_TYPE: return TextPlaceholder.NOTES;
- case TextHeaderAtom.OTHER_TYPE: return TextPlaceholder.OTHER;
- case TextHeaderAtom.CENTRE_BODY_TYPE: return TextPlaceholder.CENTER_BODY;
- case TextHeaderAtom.CENTER_TITLE_TYPE: return TextPlaceholder.CENTER_TITLE;
- case TextHeaderAtom.HALF_BODY_TYPE: return TextPlaceholder.HALF_BODY;
- case TextHeaderAtom.QUARTER_BODY_TYPE: return TextPlaceholder.QUARTER_BODY;
- }
+ return TextPlaceholder.fromNativeId(getRunType());
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfGraphics.java Wed Sep 11 21:24:06 2019
@@ -31,7 +31,6 @@ import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
-import java.awt.geom.Area;
import java.awt.geom.Dimension2D;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
@@ -45,6 +44,7 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.TreeMap;
+import java.util.function.BiConsumer;
import org.apache.commons.codec.Charsets;
import org.apache.poi.common.usermodel.fonts.FontCharset;
@@ -68,7 +68,24 @@ import org.apache.poi.util.LocaleUtil;
public class HwmfGraphics {
public enum FillDrawStyle {
- NONE, FILL, DRAW, FILL_DRAW
+ NONE(FillDrawStyle::fillNone),
+ FILL(HwmfGraphics::fill),
+ DRAW(HwmfGraphics::draw),
+ FILL_DRAW(FillDrawStyle::fillDraw);
+
+ public final BiConsumer<HwmfGraphics,Shape> handler;
+
+ FillDrawStyle(BiConsumer<HwmfGraphics,Shape> handler) {
+ this.handler = handler;
+ }
+
+ private static void fillNone(HwmfGraphics g, Shape s) {
+ }
+
+ private static void fillDraw(HwmfGraphics g, Shape s) {
+ g.fill(s);
+ g.draw(s);
+ }
}
protected final List<HwmfDrawProperties> propStack = new LinkedList<>();
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfImageRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfImageRenderer.java?rev=1866808&r1=1866807&r2=1866808&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfImageRenderer.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfImageRenderer.java Wed Sep 11 21:24:06 2019
@@ -24,11 +24,11 @@ import java.awt.RenderingHints;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
-import java.awt.image.RescaleOp;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hwmf.usermodel.HwmfPicture;
import org.apache.poi.sl.draw.BitmapImageRenderer;
import org.apache.poi.sl.draw.DrawPictureShape;
@@ -112,4 +112,9 @@ public class HwmfImageRenderer implement
return true;
}
}
+
+ @Override
+ public GenericRecord getGenericRecord() {
+ return image;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org