You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 21:37:10 UTC
svn commit: r1890122 [5/16] - in /poi/trunk/poi-scratchpad/src:
main/java/org/apache/poi/hdgf/ main/java/org/apache/poi/hdgf/chunks/
main/java/org/apache/poi/hdgf/dev/ main/java/org/apache/poi/hdgf/exceptions/
main/java/org/apache/poi/hdgf/extractor/ m...
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherTextboxWrapper.java Sat May 22 21:37:08 2021
@@ -34,99 +34,99 @@ import org.apache.poi.util.GenericRecord
* parent PPDrawing) will do the actual write out
*/
public final class EscherTextboxWrapper extends RecordContainer {
- private final EscherTextboxRecord _escherRecord;
- private long _type;
- private int shapeId;
- private StyleTextPropAtom styleTextPropAtom;
- private StyleTextProp9Atom styleTextProp9Atom;
-
- /**
- * Returns the underlying DDF Escher Record
- */
- public EscherTextboxRecord getEscherRecord() { return _escherRecord; }
-
- /**
- * Creates the wrapper for the given DDF Escher Record and children
- */
- public EscherTextboxWrapper(EscherTextboxRecord textbox) {
- _escherRecord = textbox;
- _type = _escherRecord.getRecordId();
-
- // Find the child records in the escher data
- byte[] data = _escherRecord.getData();
- _children = Record.findChildRecords(data,0,data.length);
- for (org.apache.poi.hslf.record.Record r : this._children) {
- if (r instanceof StyleTextPropAtom) { this.styleTextPropAtom = (StyleTextPropAtom) r; }
- }
- }
-
- /**
- * Creates a new, empty wrapper for DDF Escher Records and their children
- */
- public EscherTextboxWrapper() {
- _escherRecord = new EscherTextboxRecord();
- _escherRecord.setRecordId(EscherTextboxRecord.RECORD_ID);
- _escherRecord.setOptions((short)15);
-
- _children = new org.apache.poi.hslf.record.Record[0];
- }
-
-
- /**
- * Return the type of the escher record (normally in the 0xFnnn range)
- */
- @Override
- public long getRecordType() { return _type; }
-
- /**
- * Stores the data for the child records back into the Escher layer.
- * Doesn't actually do the writing out, that's left to the Escher
- * layer to do. Must be called before writeOut/serialize is called
- * on the underlying Escher object!
- */
- @Override
- public void writeOut(OutputStream out) throws IOException {
- // Write out our children, and stuff them into the Escher layer
-
- // Grab the children's data
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- for (org.apache.poi.hslf.record.Record r : _children) r.writeOut(baos);
- byte[] data = baos.toByteArray();
-
- // Save in the escher layer
- _escherRecord.setData(data);
- }
-
- /**
- * @return Shape ID
- */
- public int getShapeId(){
- return shapeId;
- }
-
- /**
- * @param id Shape ID
- */
- public void setShapeId(int id){
- shapeId = id;
- }
-
- public StyleTextPropAtom getStyleTextPropAtom() {
- return styleTextPropAtom;
- }
-
- public void setStyleTextProp9Atom(final StyleTextProp9Atom nineAtom) {
- this.styleTextProp9Atom = nineAtom;
- }
- public StyleTextProp9Atom getStyleTextProp9Atom() {
- return this.styleTextProp9Atom;
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "shapeId", this::getShapeId,
- "escherRecord", this::getEscherRecord
- );
- }
+ private final EscherTextboxRecord _escherRecord;
+ private long _type;
+ private int shapeId;
+ private StyleTextPropAtom styleTextPropAtom;
+ private StyleTextProp9Atom styleTextProp9Atom;
+
+ /**
+ * Returns the underlying DDF Escher Record
+ */
+ public EscherTextboxRecord getEscherRecord() { return _escherRecord; }
+
+ /**
+ * Creates the wrapper for the given DDF Escher Record and children
+ */
+ public EscherTextboxWrapper(EscherTextboxRecord textbox) {
+ _escherRecord = textbox;
+ _type = _escherRecord.getRecordId();
+
+ // Find the child records in the escher data
+ byte[] data = _escherRecord.getData();
+ _children = Record.findChildRecords(data,0,data.length);
+ for (org.apache.poi.hslf.record.Record r : this._children) {
+ if (r instanceof StyleTextPropAtom) { this.styleTextPropAtom = (StyleTextPropAtom) r; }
+ }
+ }
+
+ /**
+ * Creates a new, empty wrapper for DDF Escher Records and their children
+ */
+ public EscherTextboxWrapper() {
+ _escherRecord = new EscherTextboxRecord();
+ _escherRecord.setRecordId(EscherTextboxRecord.RECORD_ID);
+ _escherRecord.setOptions((short)15);
+
+ _children = new org.apache.poi.hslf.record.Record[0];
+ }
+
+
+ /**
+ * Return the type of the escher record (normally in the 0xFnnn range)
+ */
+ @Override
+ public long getRecordType() { return _type; }
+
+ /**
+ * Stores the data for the child records back into the Escher layer.
+ * Doesn't actually do the writing out, that's left to the Escher
+ * layer to do. Must be called before writeOut/serialize is called
+ * on the underlying Escher object!
+ */
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
+ // Write out our children, and stuff them into the Escher layer
+
+ // Grab the children's data
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ for (org.apache.poi.hslf.record.Record r : _children) r.writeOut(baos);
+ byte[] data = baos.toByteArray();
+
+ // Save in the escher layer
+ _escherRecord.setData(data);
+ }
+
+ /**
+ * @return Shape ID
+ */
+ public int getShapeId(){
+ return shapeId;
+ }
+
+ /**
+ * @param id Shape ID
+ */
+ public void setShapeId(int id){
+ shapeId = id;
+ }
+
+ public StyleTextPropAtom getStyleTextPropAtom() {
+ return styleTextPropAtom;
+ }
+
+ public void setStyleTextProp9Atom(final StyleTextProp9Atom nineAtom) {
+ this.styleTextProp9Atom = nineAtom;
+ }
+ public StyleTextProp9Atom getStyleTextProp9Atom() {
+ return this.styleTextProp9Atom;
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "shapeId", this::getShapeId,
+ "escherRecord", this::getEscherRecord
+ );
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExEmbedAtom.java Sat May 22 21:37:08 2021
@@ -100,7 +100,7 @@ public class ExEmbedAtom extends RecordA
// Must be at least 8 bytes long
if(_data.length < 8) {
- throw new IllegalArgumentException("The length of the data for a ExEmbedAtom must be at least 4 bytes, but was only " + _data.length);
+ throw new IllegalArgumentException("The length of the data for a ExEmbedAtom must be at least 4 bytes, but was only " + _data.length);
}
}
@@ -125,7 +125,7 @@ public class ExEmbedAtom extends RecordA
}
public void setCantLockServerB(boolean cantBeLocked) {
- _data[4] = (byte)(cantBeLocked ? 1 : 0);
+ _data[4] = (byte)(cantBeLocked ? 1 : 0);
}
/**
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlink.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlink.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlink.java Sat May 22 21:37:08 2021
@@ -28,28 +28,28 @@ import static org.apache.logging.log4j.u
* This class represents the data of a link in the document.
*/
public class ExHyperlink extends RecordContainer {
- private static final long _type = RecordTypes.ExHyperlink.typeID;
+ private static final long _type = RecordTypes.ExHyperlink.typeID;
- private byte[] _header;
+ private byte[] _header;
- // Links to our more interesting children
- private ExHyperlinkAtom linkAtom;
- private CString linkDetailsA;
- private CString linkDetailsB;
-
- /**
- * Returns the ExHyperlinkAtom of this link
- */
- public ExHyperlinkAtom getExHyperlinkAtom() { return linkAtom; }
+ // Links to our more interesting children
+ private ExHyperlinkAtom linkAtom;
+ private CString linkDetailsA;
+ private CString linkDetailsB;
- /**
- * Returns the URL of the link.
+ /**
+ * Returns the ExHyperlinkAtom of this link
+ */
+ public ExHyperlinkAtom getExHyperlinkAtom() { return linkAtom; }
+
+ /**
+ * Returns the URL of the link.
*
* @return the URL of the link
- */
- public String getLinkURL() {
- return linkDetailsB == null ? null : linkDetailsB.getText();
- }
+ */
+ public String getLinkURL() {
+ return linkDetailsB == null ? null : linkDetailsB.getText();
+ }
/**
* Returns the hyperlink's user-readable name
@@ -60,15 +60,15 @@ public class ExHyperlink extends RecordC
return linkDetailsA == null ? null : linkDetailsA.getText();
}
- /**
- * Sets the URL of the link
- * TODO: Figure out if we should always set both
- */
- public void setLinkURL(String url) {
- if(linkDetailsB != null) {
- linkDetailsB.setText(url);
- }
- }
+ /**
+ * Sets the URL of the link
+ * TODO: Figure out if we should always set both
+ */
+ public void setLinkURL(String url) {
+ if(linkDetailsB != null) {
+ linkDetailsB.setText(url);
+ }
+ }
public void setLinkOptions(int options) {
if(linkDetailsB != null) {
@@ -82,49 +82,49 @@ public class ExHyperlink extends RecordC
}
}
- /**
- * Get the link details (field A)
- */
- public String _getDetailsA() {
- return linkDetailsA == null ? null : linkDetailsA.getText();
- }
- /**
- * Get the link details (field B)
- */
- public String _getDetailsB() {
- return linkDetailsB == null ? null : linkDetailsB.getText();
- }
-
- /**
- * Set things up, and find our more interesting children
- */
- protected ExHyperlink(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- findInterestingChildren();
- }
-
- /**
- * Go through our child records, picking out the ones that are
- * interesting, and saving those for use by the easy helper
- * methods.
- */
- private void findInterestingChildren() {
-
- // First child should be the ExHyperlinkAtom
- Record child = _children[0];
- if(child instanceof ExHyperlinkAtom) {
- linkAtom = (ExHyperlinkAtom) child;
- } else {
- LOG.atError().log("First child record wasn't a ExHyperlinkAtom, was of type {}", box(child.getRecordType()));
- }
+ /**
+ * Get the link details (field A)
+ */
+ public String _getDetailsA() {
+ return linkDetailsA == null ? null : linkDetailsA.getText();
+ }
+ /**
+ * Get the link details (field B)
+ */
+ public String _getDetailsB() {
+ return linkDetailsB == null ? null : linkDetailsB.getText();
+ }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected ExHyperlink(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ findInterestingChildren();
+ }
+
+ /**
+ * Go through our child records, picking out the ones that are
+ * interesting, and saving those for use by the easy helper
+ * methods.
+ */
+ private void findInterestingChildren() {
+
+ // First child should be the ExHyperlinkAtom
+ Record child = _children[0];
+ if(child instanceof ExHyperlinkAtom) {
+ linkAtom = (ExHyperlinkAtom) child;
+ } else {
+ LOG.atError().log("First child record wasn't a ExHyperlinkAtom, was of type {}", box(child.getRecordType()));
+ }
for (int i = 1; i < _children.length; i++) {
- child = _children[i];
- if (child instanceof CString){
+ child = _children[i];
+ if (child instanceof CString){
if ( linkDetailsA == null) linkDetailsA = (CString) child;
else linkDetailsB = (CString) child;
} else {
@@ -132,40 +132,40 @@ public class ExHyperlink extends RecordC
}
}
- }
+ }
- /**
- * Create a new ExHyperlink, with blank fields
- */
- public ExHyperlink() {
- _header = new byte[8];
- _children = new org.apache.poi.hslf.record.Record[3];
-
- // Setup our header block
- _header[0] = 0x0f; // We are a container record
- LittleEndian.putShort(_header, 2, (short)_type);
-
- // Setup our child records
- CString csa = new CString();
- CString csb = new CString();
- csa.setOptions(0x00);
- csb.setOptions(0x10);
- _children[0] = new ExHyperlinkAtom();
- _children[1] = csa;
- _children[2] = csb;
- findInterestingChildren();
- }
-
- /**
- * We are of type 4055
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],_type,_children,out);
- }
+ /**
+ * Create a new ExHyperlink, with blank fields
+ */
+ public ExHyperlink() {
+ _header = new byte[8];
+ _children = new org.apache.poi.hslf.record.Record[3];
+
+ // Setup our header block
+ _header[0] = 0x0f; // We are a container record
+ LittleEndian.putShort(_header, 2, (short)_type);
+
+ // Setup our child records
+ CString csa = new CString();
+ CString csb = new CString();
+ csa.setOptions(0x00);
+ csb.setOptions(0x10);
+ _children[0] = new ExHyperlinkAtom();
+ _children[1] = csa;
+ _children[2] = csb;
+ findInterestingChildren();
+ }
+
+ /**
+ * We are of type 4055
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],_type,_children,out);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlinkAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlinkAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlinkAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExHyperlinkAtom.java Sat May 22 21:37:08 2021
@@ -76,7 +76,7 @@ public final class ExHyperlinkAtom exten
// Must be at least 4 bytes long
if(_data.length < 4) {
- throw new IllegalArgumentException("The length of the data for a ExHyperlinkAtom must be at least 4 bytes, but was only " + _data.length);
+ throw new IllegalArgumentException("The length of the data for a ExHyperlinkAtom must be at least 4 bytes, but was only " + _data.length);
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java Sat May 22 21:37:08 2021
@@ -27,85 +27,85 @@ import org.apache.poi.util.LittleEndian;
* This class holds the links to exernal objects referenced from the document.
*/
public class ExObjList extends RecordContainer {
- private byte[] _header;
- private static final long _type = RecordTypes.ExObjList.typeID;
+ private byte[] _header;
+ private static final long _type = RecordTypes.ExObjList.typeID;
- // Links to our more interesting children
- private ExObjListAtom exObjListAtom;
+ // Links to our more interesting children
+ private ExObjListAtom exObjListAtom;
- /**
- * Returns the ExObjListAtom of this list
- */
- public ExObjListAtom getExObjListAtom() { return exObjListAtom; }
-
- /**
- * Returns all the ExHyperlinks
- */
- public ExHyperlink[] getExHyperlinks() {
- ArrayList<ExHyperlink> links = new ArrayList<>();
- for(int i=0; i<_children.length; i++) {
- if(_children[i] instanceof ExHyperlink) {
- links.add( (ExHyperlink)_children[i] );
- }
- }
-
- return links.toArray(new ExHyperlink[0]);
- }
-
- /**
- * Set things up, and find our more interesting children
- */
- protected ExObjList(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- findInterestingChildren();
- }
-
- /**
- * Go through our child records, picking out the ones that are
- * interesting, and saving those for use by the easy helper
- * methods.
- */
- private void findInterestingChildren() {
- // First child should be the atom
- if(_children[0] instanceof ExObjListAtom) {
- exObjListAtom = (ExObjListAtom)_children[0];
- } else {
- throw new IllegalStateException("First child record wasn't a ExObjListAtom, was of type " + _children[0].getRecordType());
- }
- }
-
- /**
- * Create a new ExObjList, with blank fields
- */
- public ExObjList() {
- _header = new byte[8];
- _children = new org.apache.poi.hslf.record.Record[1];
-
- // Setup our header block
- _header[0] = 0x0f; // We are a container record
- LittleEndian.putShort(_header, 2, (short)_type);
-
- // Setup our child records
- _children[0] = new ExObjListAtom();
- findInterestingChildren();
- }
-
- /**
- * We are of type 1033
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],_type,_children,out);
- }
+ /**
+ * Returns the ExObjListAtom of this list
+ */
+ public ExObjListAtom getExObjListAtom() { return exObjListAtom; }
+
+ /**
+ * Returns all the ExHyperlinks
+ */
+ public ExHyperlink[] getExHyperlinks() {
+ ArrayList<ExHyperlink> links = new ArrayList<>();
+ for(int i=0; i<_children.length; i++) {
+ if(_children[i] instanceof ExHyperlink) {
+ links.add( (ExHyperlink)_children[i] );
+ }
+ }
+
+ return links.toArray(new ExHyperlink[0]);
+ }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected ExObjList(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ findInterestingChildren();
+ }
+
+ /**
+ * Go through our child records, picking out the ones that are
+ * interesting, and saving those for use by the easy helper
+ * methods.
+ */
+ private void findInterestingChildren() {
+ // First child should be the atom
+ if(_children[0] instanceof ExObjListAtom) {
+ exObjListAtom = (ExObjListAtom)_children[0];
+ } else {
+ throw new IllegalStateException("First child record wasn't a ExObjListAtom, was of type " + _children[0].getRecordType());
+ }
+ }
+
+ /**
+ * Create a new ExObjList, with blank fields
+ */
+ public ExObjList() {
+ _header = new byte[8];
+ _children = new org.apache.poi.hslf.record.Record[1];
+
+ // Setup our header block
+ _header[0] = 0x0f; // We are a container record
+ LittleEndian.putShort(_header, 2, (short)_type);
+
+ // Setup our child records
+ _children[0] = new ExObjListAtom();
+ findInterestingChildren();
+ }
+
+ /**
+ * We are of type 1033
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],_type,_children,out);
+ }
/**
* Lookup a hyperlink by its unique id
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java Sat May 22 21:37:08 2021
@@ -78,7 +78,7 @@ public class ExObjListAtom extends Recor
// Must be at least 4 bytes long
if(_data.length < 4) {
- throw new IllegalArgumentException("The length of the data for a ExObjListAtom must be at least 4 bytes, but was only " + _data.length);
+ throw new IllegalArgumentException("The length of the data for a ExObjListAtom must be at least 4 bytes, but was only " + _data.length);
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjRefAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjRefAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjRefAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjRefAtom.java Sat May 22 21:37:08 2021
@@ -34,14 +34,14 @@ import org.apache.poi.util.LittleEndian;
*/
public final class ExObjRefAtom extends RecordAtom {
- private byte[] _header;
+ private byte[] _header;
- /**
- * A 4-byte unsigned integer that specifies a reference to an external object.
- * It MUST be equal to the value of the exObjId field of an ExMediaAtom record
- * or the value of the exObjId field of an ExOleObjAtom record.
- */
- private int exObjIdRef;
+ /**
+ * A 4-byte unsigned integer that specifies a reference to an external object.
+ * It MUST be equal to the value of the exObjId field of an ExMediaAtom record
+ * or the value of the exObjId field of an ExOleObjAtom record.
+ */
+ private int exObjIdRef;
/**
* Create a new instance of <code>ExObjRefAtom</code>
@@ -61,16 +61,16 @@ public final class ExObjRefAtom extends
* @param start the start offset into the byte array.
* @param len the length of the slice in the byte array.
*/
- protected ExObjRefAtom(byte[] source, int start, int len) {
+ protected ExObjRefAtom(byte[] source, int start, int len) {
_header = Arrays.copyOfRange(source, start, start+8);
exObjIdRef = (int)LittleEndian.getUInt(source, start+8);
- }
+ }
/**
* @return type of this record {@link RecordTypes#ExObjRefAtom}.
*/
- public long getRecordType() {
- return RecordTypes.ExObjRefAtom.typeID;
+ public long getRecordType() {
+ return RecordTypes.ExObjRefAtom.typeID;
}
public int getExObjIdRef(){
@@ -82,17 +82,17 @@ public final class ExObjRefAtom extends
}
/**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
byte[] recdata = new byte[4];
LittleEndian.putUInt(recdata, 0, exObjIdRef);
out.write(recdata);
- }
+ }
@Override
public Map<String, Supplier<?>> getGenericProperties() {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExOleObjAtom.java Sat May 22 21:37:08 2021
@@ -195,7 +195,7 @@ public class ExOleObjAtom extends Record
// Must be at least 24 bytes long
if(_data.length < 24) {
- throw new IllegalArgumentException("The length of the data for a ExOleObjAtom must be at least 24 bytes, but was only " + _data.length);
+ throw new IllegalArgumentException("The length of the data for a ExOleObjAtom must be at least 24 bytes, but was only " + _data.length);
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExVideoContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExVideoContainer.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExVideoContainer.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExVideoContainer.java Sat May 22 21:37:08 2021
@@ -29,73 +29,73 @@ import static org.apache.logging.log4j.u
* A container record that specifies information about external video data.
*/
public final class ExVideoContainer extends RecordContainer {
- private byte[] _header;
+ private byte[] _header;
- // Links to our more interesting children
- private ExMediaAtom mediaAtom;
+ // Links to our more interesting children
+ private ExMediaAtom mediaAtom;
//the UNC or local path to a video file.
private CString pathAtom;
- /**
- * Set things up, and find our more interesting children
- */
- protected ExVideoContainer(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- findInterestingChildren();
- }
-
- /**
- * Go through our child records, picking out the ones that are
- * interesting, and saving those for use by the easy helper
- * methods.
- */
- private void findInterestingChildren() {
-
- // First child should be the ExMediaAtom
- Record child = _children[0];
- if(child instanceof ExMediaAtom) {
- mediaAtom = (ExMediaAtom) child;
- } else {
- LOG.atError().log("First child record wasn't a ExMediaAtom, was of type {}", box(child.getRecordType()));
- }
- child = _children[1];
- if(child instanceof CString) {
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected ExVideoContainer(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ findInterestingChildren();
+ }
+
+ /**
+ * Go through our child records, picking out the ones that are
+ * interesting, and saving those for use by the easy helper
+ * methods.
+ */
+ private void findInterestingChildren() {
+
+ // First child should be the ExMediaAtom
+ Record child = _children[0];
+ if(child instanceof ExMediaAtom) {
+ mediaAtom = (ExMediaAtom) child;
+ } else {
+ LOG.atError().log("First child record wasn't a ExMediaAtom, was of type {}", box(child.getRecordType()));
+ }
+ child = _children[1];
+ if(child instanceof CString) {
pathAtom = (CString) child;
} else {
LOG.atError().log("Second child record wasn't a CString, was of type {}", box(child.getRecordType()));
}
- }
+ }
- /**
- * Create a new ExVideoContainer, with blank fields
- */
- public ExVideoContainer() {
+ /**
+ * Create a new ExVideoContainer, with blank fields
+ */
+ public ExVideoContainer() {
// Setup our header block
- _header = new byte[8];
- _header[0] = 0x0f; // We are a container record
- LittleEndian.putShort(_header, 2, (short)getRecordType());
+ _header = new byte[8];
+ _header[0] = 0x0f; // We are a container record
+ LittleEndian.putShort(_header, 2, (short)getRecordType());
_children = new org.apache.poi.hslf.record.Record[2];
- _children[0] = mediaAtom = new ExMediaAtom();
- _children[1] = pathAtom = new CString();
- }
-
- /**
- * We are of type 4103
- */
- public long getRecordType() { return RecordTypes.ExVideoContainer.typeID; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],getRecordType(),_children,out);
- }
+ _children[0] = mediaAtom = new ExMediaAtom();
+ _children[1] = pathAtom = new CString();
+ }
+
+ /**
+ * We are of type 4103
+ */
+ public long getRecordType() { return RecordTypes.ExVideoContainer.typeID; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],getRecordType(),_children,out);
+ }
/**
* Returns the ExMediaAtom of this link
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontCollection.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontCollection.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontCollection.java Sat May 22 21:37:08 2021
@@ -46,42 +46,42 @@ public final class FontCollection extend
private final Map<Integer,HSLFFontInfo> fonts = new LinkedHashMap<>();
private byte[] _header;
- /* package */ FontCollection(byte[] source, int start, int len) {
+ /* package */ FontCollection(byte[] source, int start, int len) {
_header = Arrays.copyOfRange(source, start, start+8);
- _children = Record.findChildRecords(source,start+8,len-8);
+ _children = Record.findChildRecords(source,start+8,len-8);
- for (org.apache.poi.hslf.record.Record r : _children){
- if(r instanceof FontEntityAtom) {
+ for (org.apache.poi.hslf.record.Record r : _children){
+ if(r instanceof FontEntityAtom) {
HSLFFontInfo fi = new HSLFFontInfo((FontEntityAtom) r);
fonts.put(fi.getIndex(), fi);
} else if (r instanceof FontEmbeddedData) {
FontEmbeddedData fed = (FontEmbeddedData)r;
- FontHeader fontHeader = fed.getFontHeader();
- HSLFFontInfo fi = addFont(fontHeader);
- fi.addFacet(fed);
- } else {
- LOG.atWarn().log("FontCollection child wasn't a FontEntityAtom, was {}", r.getClass().getSimpleName());
- }
- }
- }
-
- /**
- * Return the type, which is 2005
- */
- @Override
+ FontHeader fontHeader = fed.getFontHeader();
+ HSLFFontInfo fi = addFont(fontHeader);
+ fi.addFacet(fed);
+ } else {
+ LOG.atWarn().log("FontCollection child wasn't a FontEntityAtom, was {}", r.getClass().getSimpleName());
+ }
+ }
+ }
+
+ /**
+ * Return the type, which is 2005
+ */
+ @Override
public long getRecordType() {
return RecordTypes.FontCollection.typeID;
}
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- @Override
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ @Override
public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],getRecordType(),_children,out);
- }
+ writeOut(_header[0],_header[1],getRecordType(),_children,out);
+ }
/**
* Add font with the given FontInfo configuration to the font collection.
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEntityAtom.java Sat May 22 21:37:08 2021
@@ -62,21 +62,21 @@ public final class FontEntityAtom extend
*/
private final byte[] _header;
- /**
+ /**
* record data
*/
- private byte[] _recdata;
+ private byte[] _recdata;
/**
* Build an instance of <code>FontEntityAtom</code> from on-disk data
*/
- /* package */ FontEntityAtom(byte[] source, int start, int len) {
- // Get the header
+ /* package */ FontEntityAtom(byte[] source, int start, int len) {
+ // Get the header
_header = Arrays.copyOfRange(source, start, start+8);
- // Grab the record data
- _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
- }
+ // Grab the record data
+ _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ }
/**
* Create a new instance of <code>FontEntityAtom</code>
@@ -97,19 +97,19 @@ public final class FontEntityAtom extend
/**
* A null-terminated string that specifies the typeface name of the font.
* The length of this string must not exceed 32 characters
- * including the null terminator.
+ * including the null terminator.
* @return font name
*/
public String getFontName(){
- final int maxLen = Math.min(_recdata.length,64)/2;
- return StringUtil.getFromUnicodeLE0Terminated(_recdata, 0, maxLen);
+ final int maxLen = Math.min(_recdata.length,64)/2;
+ return StringUtil.getFromUnicodeLE0Terminated(_recdata, 0, maxLen);
}
/**
* Set the name of the font.
* The length of this string must not exceed 32 characters
- * including the null terminator.
- * Will be converted to null-terminated if not already
+ * including the null terminator.
+ * Will be converted to null-terminated if not already
* @param name of the font
*/
public void setFontName(String name) {
@@ -220,13 +220,13 @@ public final class FontEntityAtom extend
}
/**
- * Write the contents of the record back, so it can be written to disk
- */
- @Override
+ * Write the contents of the record back, so it can be written to disk
+ */
+ @Override
public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_recdata);
- }
+ out.write(_header);
+ out.write(_recdata);
+ }
@Override
public Map<String, Supplier<?>> getGenericProperties() {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HeadersFootersAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HeadersFootersAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HeadersFootersAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/HeadersFootersAtom.java Sat May 22 21:37:08 2021
@@ -131,21 +131,21 @@ public final class HeadersFootersAtom ex
*/
private final byte[] _header;
- /**
+ /**
* record data
*/
- private final byte[] _recdata;
+ private final byte[] _recdata;
/**
* Build an instance of {@code HeadersFootersAtom} from on-disk data
*/
- protected HeadersFootersAtom(byte[] source, int start, int len) {
- // Get the header
+ protected HeadersFootersAtom(byte[] source, int start, int len) {
+ // Get the header
_header = Arrays.copyOfRange(source, start, start+8);
- // Grab the record data
- _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
- }
+ // Grab the record data
+ _recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
+ }
/**
* Create a new instance of {@code HeadersFootersAtom}
@@ -164,13 +164,13 @@ public final class HeadersFootersAtom ex
}
/**
- * Write the contents of the record back, so it can be written to disk
- */
- @Override
+ * Write the contents of the record back, so it can be written to disk
+ */
+ @Override
public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_recdata);
- }
+ out.write(_header);
+ out.write(_recdata);
+ }
/**
* A signed integer that specifies the format ID to be used to style the datetime.
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfo.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfo.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfo.java Sat May 22 21:37:08 2021
@@ -28,70 +28,70 @@ import org.apache.poi.util.LittleEndian;
* in it.
*/
public class InteractiveInfo extends RecordContainer {
- private byte[] _header;
- private static final long _type = RecordTypes.InteractiveInfo.typeID;
+ private byte[] _header;
+ private static final long _type = RecordTypes.InteractiveInfo.typeID;
- // Links to our more interesting children
- private InteractiveInfoAtom infoAtom;
+ // Links to our more interesting children
+ private InteractiveInfoAtom infoAtom;
- /**
- * Returns the InteractiveInfoAtom of this InteractiveInfo
- */
- public InteractiveInfoAtom getInteractiveInfoAtom() { return infoAtom; }
-
- /**
- * Set things up, and find our more interesting children
- */
- protected InteractiveInfo(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- findInterestingChildren();
- }
-
- /**
- * Go through our child records, picking out the ones that are
- * interesting, and saving those for use by the easy helper
- * methods.
- */
- private void findInterestingChildren() {
- // First child should be the InteractiveInfoAtom
- if (_children == null || _children.length == 0 || !(_children[0] instanceof InteractiveInfoAtom)) {
- LOG.atWarn().log("First child record wasn't a InteractiveInfoAtom - leaving this atom in an invalid state...");
- return;
- }
-
- infoAtom = (InteractiveInfoAtom)_children[0];
- }
-
- /**
- * Create a new InteractiveInfo, with blank fields
- */
- public InteractiveInfo() {
- _header = new byte[8];
- _children = new org.apache.poi.hslf.record.Record[1];
-
- // Setup our header block
- _header[0] = 0x0f; // We are a container record
- LittleEndian.putShort(_header, 2, (short)_type);
-
- // Setup our child records
- infoAtom = new InteractiveInfoAtom();
- _children[0] = infoAtom;
- }
-
- /**
- * We are of type 4802
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],_type,_children,out);
- }
+ /**
+ * Returns the InteractiveInfoAtom of this InteractiveInfo
+ */
+ public InteractiveInfoAtom getInteractiveInfoAtom() { return infoAtom; }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected InteractiveInfo(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ findInterestingChildren();
+ }
+
+ /**
+ * Go through our child records, picking out the ones that are
+ * interesting, and saving those for use by the easy helper
+ * methods.
+ */
+ private void findInterestingChildren() {
+ // First child should be the InteractiveInfoAtom
+ if (_children == null || _children.length == 0 || !(_children[0] instanceof InteractiveInfoAtom)) {
+ LOG.atWarn().log("First child record wasn't a InteractiveInfoAtom - leaving this atom in an invalid state...");
+ return;
+ }
+
+ infoAtom = (InteractiveInfoAtom)_children[0];
+ }
+
+ /**
+ * Create a new InteractiveInfo, with blank fields
+ */
+ public InteractiveInfo() {
+ _header = new byte[8];
+ _children = new org.apache.poi.hslf.record.Record[1];
+
+ // Setup our header block
+ _header[0] = 0x0f; // We are a container record
+ LittleEndian.putShort(_header, 2, (short)_type);
+
+ // Setup our child records
+ infoAtom = new InteractiveInfoAtom();
+ _children[0] = infoAtom;
+ }
+
+ /**
+ * We are of type 4802
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],_type,_children,out);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfoAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfoAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/InteractiveInfoAtom.java Sat May 22 21:37:08 2021
@@ -158,7 +158,7 @@ public class InteractiveInfoAtom extends
// Must be at least 16 bytes long
if(_data.length < 16) {
- throw new IllegalArgumentException("The length of the data for a InteractiveInfoAtom must be at least 16 bytes, but was only " + _data.length);
+ throw new IllegalArgumentException("The length of the data for a InteractiveInfoAtom must be at least 16 bytes, but was only " + _data.length);
}
// First 4 bytes - no idea, normally 0
@@ -197,7 +197,7 @@ public class InteractiveInfoAtom extends
* @param val a reference to a sound in the sound collection
*/
public void setSoundRef(int val) {
- LittleEndian.putInt(_data, 0, val);
+ LittleEndian.putInt(_data, 0, val);
}
/**
@@ -221,7 +221,7 @@ public class InteractiveInfoAtom extends
* @param val hyperlink action.
*/
public void setAction(byte val) {
- _data[8] = val;
+ _data[8] = val;
}
/**
@@ -235,7 +235,7 @@ public class InteractiveInfoAtom extends
* Only valid when action == OLEAction. OLE verb to use, 0 = first verb, 1 = second verb, etc.
*/
public void setOleVerb(byte val) {
- _data[9] = val;
+ _data[9] = val;
}
/**
@@ -259,7 +259,7 @@ public class InteractiveInfoAtom extends
* @param val jump
*/
public void setJump(byte val) {
- _data[10] = val;
+ _data[10] = val;
}
/**
@@ -285,7 +285,7 @@ public class InteractiveInfoAtom extends
* </ul>
*/
public void setFlags(byte val) {
- _data[11] = val;
+ _data[11] = val;
}
/**
@@ -303,7 +303,7 @@ public class InteractiveInfoAtom extends
* @param val hyperlink type
*/
public void setHyperlinkType(byte val) {
- _data[12] = val;
+ _data[12] = val;
}
/**
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MainMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MainMaster.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MainMaster.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MainMaster.java Sat May 22 21:37:08 2021
@@ -26,78 +26,78 @@ import java.util.Arrays;
* Master slide
*/
public final class MainMaster extends SheetContainer {
- private byte[] _header;
- private static long _type = 1016;
+ private byte[] _header;
+ private static long _type = 1016;
- // Links to our more interesting children
- private SlideAtom slideAtom;
- private PPDrawing ppDrawing;
- private TxMasterStyleAtom[] txmasters;
- private ColorSchemeAtom[] clrscheme;
- private ColorSchemeAtom _colorScheme;
-
- /**
- * Returns the SlideAtom of this Slide
- */
- public SlideAtom getSlideAtom() { return slideAtom; }
-
- /**
- * Returns the PPDrawing of this Slide, which has all the
- * interesting data in it
- */
- public PPDrawing getPPDrawing() { return ppDrawing; }
-
- public TxMasterStyleAtom[] getTxMasterStyleAtoms() { return txmasters; }
-
- public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
-
- /**
- * Set things up, and find our more interesting children
- */
- protected MainMaster(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
-
- ArrayList<TxMasterStyleAtom> tx = new ArrayList<>();
- ArrayList<ColorSchemeAtom> clr = new ArrayList<>();
- // Find the interesting ones in there
- for (Record child : _children) {
- if (child instanceof SlideAtom) {
- slideAtom = (SlideAtom) child;
- } else if (child instanceof PPDrawing) {
- ppDrawing = (PPDrawing) child;
- } else if (child instanceof TxMasterStyleAtom) {
- tx.add((TxMasterStyleAtom) child);
- } else if (child instanceof ColorSchemeAtom) {
- clr.add((ColorSchemeAtom) child);
- }
-
- if (ppDrawing != null && child instanceof ColorSchemeAtom) {
- _colorScheme = (ColorSchemeAtom) child;
- }
-
- }
- txmasters = tx.toArray(new TxMasterStyleAtom[0]);
- clrscheme = clr.toArray(new ColorSchemeAtom[0]);
- }
-
- /**
- * We are of type 1016
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],_type,_children,out);
- }
-
- public ColorSchemeAtom getColorScheme(){
- return _colorScheme;
- }
+ // Links to our more interesting children
+ private SlideAtom slideAtom;
+ private PPDrawing ppDrawing;
+ private TxMasterStyleAtom[] txmasters;
+ private ColorSchemeAtom[] clrscheme;
+ private ColorSchemeAtom _colorScheme;
+
+ /**
+ * Returns the SlideAtom of this Slide
+ */
+ public SlideAtom getSlideAtom() { return slideAtom; }
+
+ /**
+ * Returns the PPDrawing of this Slide, which has all the
+ * interesting data in it
+ */
+ public PPDrawing getPPDrawing() { return ppDrawing; }
+
+ public TxMasterStyleAtom[] getTxMasterStyleAtoms() { return txmasters; }
+
+ public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected MainMaster(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+
+ ArrayList<TxMasterStyleAtom> tx = new ArrayList<>();
+ ArrayList<ColorSchemeAtom> clr = new ArrayList<>();
+ // Find the interesting ones in there
+ for (Record child : _children) {
+ if (child instanceof SlideAtom) {
+ slideAtom = (SlideAtom) child;
+ } else if (child instanceof PPDrawing) {
+ ppDrawing = (PPDrawing) child;
+ } else if (child instanceof TxMasterStyleAtom) {
+ tx.add((TxMasterStyleAtom) child);
+ } else if (child instanceof ColorSchemeAtom) {
+ clr.add((ColorSchemeAtom) child);
+ }
+
+ if (ppDrawing != null && child instanceof ColorSchemeAtom) {
+ _colorScheme = (ColorSchemeAtom) child;
+ }
+
+ }
+ txmasters = tx.toArray(new TxMasterStyleAtom[0]);
+ clrscheme = clr.toArray(new ColorSchemeAtom[0]);
+ }
+
+ /**
+ * We are of type 1016
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],_type,_children,out);
+ }
+
+ public ColorSchemeAtom getColorScheme(){
+ return _colorScheme;
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java Sat May 22 21:37:08 2021
@@ -28,62 +28,62 @@ import java.util.Arrays;
public final class Notes extends SheetContainer
{
- private byte[] _header;
- private static long _type = 1008l;
+ private byte[] _header;
+ private static long _type = 1008l;
- // Links to our more interesting children
- private NotesAtom notesAtom;
- private PPDrawing ppDrawing;
+ // Links to our more interesting children
+ private NotesAtom notesAtom;
+ private PPDrawing ppDrawing;
private ColorSchemeAtom _colorScheme;
- /**
- * Returns the NotesAtom of this Notes
- */
- public NotesAtom getNotesAtom() { return notesAtom; }
- /**
- * Returns the PPDrawing of this Notes, which has all the
- * interesting data in it
- */
- public PPDrawing getPPDrawing() { return ppDrawing; }
-
-
- /**
- * Set things up, and find our more interesting children
- */
- protected Notes(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
-
- // Find the interesting ones in there
- for (Record child : _children) {
- if (child instanceof NotesAtom) {
- notesAtom = (NotesAtom) child;
- }
- if (child instanceof PPDrawing) {
- ppDrawing = (PPDrawing) child;
- }
- if (ppDrawing != null && child instanceof ColorSchemeAtom) {
- _colorScheme = (ColorSchemeAtom) child;
- }
- }
- }
-
-
- /**
- * We are of type 1008
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],_type,_children,out);
- }
+ /**
+ * Returns the NotesAtom of this Notes
+ */
+ public NotesAtom getNotesAtom() { return notesAtom; }
+ /**
+ * Returns the PPDrawing of this Notes, which has all the
+ * interesting data in it
+ */
+ public PPDrawing getPPDrawing() { return ppDrawing; }
+
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected Notes(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+
+ // Find the interesting ones in there
+ for (Record child : _children) {
+ if (child instanceof NotesAtom) {
+ notesAtom = (NotesAtom) child;
+ }
+ if (child instanceof PPDrawing) {
+ ppDrawing = (PPDrawing) child;
+ }
+ if (ppDrawing != null && child instanceof ColorSchemeAtom) {
+ _colorScheme = (ColorSchemeAtom) child;
+ }
+ }
+ }
+
+
+ /**
+ * We are of type 1008
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],_type,_children,out);
+ }
public ColorSchemeAtom getColorScheme(){
return _colorScheme;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java Sat May 22 21:37:08 2021
@@ -35,89 +35,89 @@ import org.apache.poi.util.LittleEndian;
public final class NotesAtom extends RecordAtom
{
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ //arbitrarily selected; may need to increase
+ private static final int MAX_RECORD_LENGTH = 1_000_000;
- private byte[] _header;
- private static long _type = 1009l;
+ private byte[] _header;
+ private static long _type = 1009l;
- private int slideID;
- private boolean followMasterObjects;
- private boolean followMasterScheme;
- private boolean followMasterBackground;
- private byte[] reserved;
-
-
- public int getSlideID() { return slideID; }
- public void setSlideID(int id) { slideID = id; }
-
- public boolean getFollowMasterObjects() { return followMasterObjects; }
- public boolean getFollowMasterScheme() { return followMasterScheme; }
- public boolean getFollowMasterBackground() { return followMasterBackground; }
- public void setFollowMasterObjects(boolean flag) { followMasterObjects = flag; }
- public void setFollowMasterScheme(boolean flag) { followMasterScheme = flag; }
- public void setFollowMasterBackground(boolean flag) { followMasterBackground = flag; }
-
-
- /* *************** record code follows ********************** */
-
- /**
- * For the Notes Atom
- */
- protected NotesAtom(byte[] source, int start, int len) {
- // Sanity Checking
- if(len < 8) { len = 8; }
-
- // Get the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Get the slide ID
- slideID = LittleEndian.getInt(source,start+8);
-
- // Grok the flags, stored as bits
- int flags = LittleEndian.getUShort(source,start+12);
- followMasterBackground = (flags & 4) == 4;
- followMasterScheme = (flags & 2) == 2;
- followMasterObjects = (flags & 1) == 1;
-
- // There might be 2 more bytes, which are a reserved field
- reserved = IOUtils.safelyClone(source, start+14, len-14, MAX_RECORD_LENGTH);
- }
-
- /**
- * We are of type 1009
- */
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- public void writeOut(OutputStream out) throws IOException {
- // Header
- out.write(_header);
-
- // Slide ID
- writeLittleEndian(slideID,out);
-
- // Flags
- short flags = 0;
- if(followMasterObjects) { flags += 1; }
- if(followMasterScheme) { flags += 2; }
- if(followMasterBackground) { flags += 4; }
- writeLittleEndian(flags,out);
-
- // Reserved fields
- out.write(reserved);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "slideId", this::getSlideID,
- "followMasterObjects", this::getFollowMasterObjects,
- "followMasterScheme", this::getFollowMasterScheme,
- "followMasterBackground", this::getFollowMasterBackground
- );
- }
+ private int slideID;
+ private boolean followMasterObjects;
+ private boolean followMasterScheme;
+ private boolean followMasterBackground;
+ private byte[] reserved;
+
+
+ public int getSlideID() { return slideID; }
+ public void setSlideID(int id) { slideID = id; }
+
+ public boolean getFollowMasterObjects() { return followMasterObjects; }
+ public boolean getFollowMasterScheme() { return followMasterScheme; }
+ public boolean getFollowMasterBackground() { return followMasterBackground; }
+ public void setFollowMasterObjects(boolean flag) { followMasterObjects = flag; }
+ public void setFollowMasterScheme(boolean flag) { followMasterScheme = flag; }
+ public void setFollowMasterBackground(boolean flag) { followMasterBackground = flag; }
+
+
+ /* *************** record code follows ********************** */
+
+ /**
+ * For the Notes Atom
+ */
+ protected NotesAtom(byte[] source, int start, int len) {
+ // Sanity Checking
+ if(len < 8) { len = 8; }
+
+ // Get the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Get the slide ID
+ slideID = LittleEndian.getInt(source,start+8);
+
+ // Grok the flags, stored as bits
+ int flags = LittleEndian.getUShort(source,start+12);
+ followMasterBackground = (flags & 4) == 4;
+ followMasterScheme = (flags & 2) == 2;
+ followMasterObjects = (flags & 1) == 1;
+
+ // There might be 2 more bytes, which are a reserved field
+ reserved = IOUtils.safelyClone(source, start+14, len-14, MAX_RECORD_LENGTH);
+ }
+
+ /**
+ * We are of type 1009
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ // Header
+ out.write(_header);
+
+ // Slide ID
+ writeLittleEndian(slideID,out);
+
+ // Flags
+ short flags = 0;
+ if(followMasterObjects) { flags += 1; }
+ if(followMasterScheme) { flags += 2; }
+ if(followMasterBackground) { flags += 4; }
+ writeLittleEndian(flags,out);
+
+ // Reserved fields
+ out.write(reserved);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "slideId", this::getSlideID,
+ "followMasterObjects", this::getFollowMasterObjects,
+ "followMasterScheme", this::getFollowMasterScheme,
+ "followMasterBackground", this::getFollowMasterBackground
+ );
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/OEPlaceholderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/OEPlaceholderAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/OEPlaceholderAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/OEPlaceholderAtom.java Sat May 22 21:37:08 2021
@@ -52,7 +52,7 @@ public final class OEPlaceholderAtom ext
*/
public static final int PLACEHOLDER_QUARTSIZE = 2;
- private byte[] _header;
+ private byte[] _header;
private int placementId;
private int placeholderId;
@@ -77,7 +77,7 @@ public final class OEPlaceholderAtom ext
/**
* Build an instance of {@code OEPlaceholderAtom} from on-disk data
*/
- protected OEPlaceholderAtom(byte[] source, int start, int len) {
+ protected OEPlaceholderAtom(byte[] source, int start, int len) {
_header = Arrays.copyOfRange(source, start, start+8);
int offset = start+8;
@@ -85,12 +85,12 @@ public final class OEPlaceholderAtom ext
placeholderId = LittleEndian.getUByte(source, offset); offset++;
placeholderSize = LittleEndian.getUByte(source, offset); offset++;
unusedShort = LittleEndian.getShort(source, offset);
- }
+ }
/**
* @return type of this record {@link RecordTypes#OEPlaceholderAtom}.
*/
- @Override
+ @Override
public long getRecordType() { return RecordTypes.OEPlaceholderAtom.typeID; }
/**
@@ -163,12 +163,12 @@ public final class OEPlaceholderAtom ext
placeholderSize = size;
}
- /**
- * Write the contents of the record back, so it can be written to disk
- */
- @Override
+ /**
+ * Write the contents of the record back, so it can be written to disk
+ */
+ @Override
public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
+ out.write(_header);
byte[] recdata = new byte[8];
LittleEndian.putInt(recdata, 0, placementId);
@@ -177,7 +177,7 @@ public final class OEPlaceholderAtom ext
LittleEndian.putShort(recdata, 6, unusedShort);
out.write(recdata);
- }
+ }
@Override
public Map<String, Supplier<?>> getGenericProperties() {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawing.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/PPDrawing.java Sat May 22 21:37:08 2021
@@ -64,34 +64,34 @@ import org.apache.poi.util.LittleEndian;
// would require a wrapping class
public final class PPDrawing extends RecordAtom implements Iterable<EscherRecord> {
- private final byte[] _header;
- private long _type;
+ private final byte[] _header;
+ private long _type;
- private EscherTextboxWrapper[] textboxWrappers;
+ private EscherTextboxWrapper[] textboxWrappers;
- private final EscherContainerRecord dgContainer = new EscherContainerRecord();
+ private final EscherContainerRecord dgContainer = new EscherContainerRecord();
- //cached EscherDgRecord
- private EscherDgRecord dg;
+ //cached EscherDgRecord
+ private EscherDgRecord dg;
- /**
- * Get access to the underlying Escher Records
- */
- @SuppressWarnings("WeakerAccess")
- public List<EscherRecord> getEscherRecords() { return Collections.singletonList(dgContainer); }
+ /**
+ * Get access to the underlying Escher Records
+ */
+ @SuppressWarnings("WeakerAccess")
+ public List<EscherRecord> getEscherRecords() { return Collections.singletonList(dgContainer); }
- @Override
- public Iterator<EscherRecord> iterator() {
- return getEscherRecords().iterator();
- }
+ @Override
+ public Iterator<EscherRecord> iterator() {
+ return getEscherRecords().iterator();
+ }
- /**
- * Get access to the atoms inside Textboxes
- */
- public EscherTextboxWrapper[] getTextboxWrappers() { return textboxWrappers; }
+ /**
+ * Get access to the atoms inside Textboxes
+ */
+ public EscherTextboxWrapper[] getTextboxWrappers() { return textboxWrappers; }
- /* ******************** record stuff follows ********************** */
+ /* ******************** record stuff follows ********************** */
/**
* Creates a new, empty, PPDrawing (typically for use with a new Slide
@@ -107,223 +107,223 @@ public final class PPDrawing extends Rec
create();
}
- /**
- * Sets everything up, groks the escher etc
- */
- PPDrawing(byte[] source, int start, int len) {
- // Get the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Get the type
- _type = LittleEndian.getUShort(_header,2);
-
- // Build up a tree of Escher records contained within
- final DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
- dgContainer.fillFields(source, start + 8, erf);
- assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
- dg = dgContainer.getChildById(EscherRecordTypes.DG.typeID);
-
- textboxWrappers = Stream.of(dgContainer).
- flatMap(findEscherContainer(EscherRecordTypes.SPGR_CONTAINER)).
- flatMap(findEscherContainer(EscherRecordTypes.SP_CONTAINER)).
- flatMap(PPDrawing::getTextboxHelper).
- toArray(EscherTextboxWrapper[]::new);
- }
-
- private static Stream<EscherTextboxWrapper> getTextboxHelper(EscherContainerRecord spContainer) {
- Optional<EscherTextboxRecord> oTB = firstEscherRecord(spContainer, EscherRecordTypes.CLIENT_TEXTBOX);
- if (!oTB.isPresent()) {
- return Stream.empty();
- }
-
- 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 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(org.apache.poi.hslf.record.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();
- }
-
- /**
- * We are type 1036
- */
- public long getRecordType() { return _type; }
-
- /**
- * We're pretending to be an atom, so return null
- */
- public org.apache.poi.hslf.record.Record[] getChildRecords() { return null; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- * Walks the escher layer to get the contents
- */
- public void writeOut(OutputStream out) throws IOException {
- // Ensure the escher layer reflects the text changes
- for (EscherTextboxWrapper w : textboxWrappers) {
- w.writeOut(null);
- }
-
- // Find the new size of the escher children;
- int newSize = 0;
- newSize += dgContainer.getRecordSize();
-
- // Update the size (header bytes 5-8)
- LittleEndian.putInt(_header,4,newSize);
-
- // Write out our header
- out.write(_header);
-
- // Now grab the children's data
- byte[] b = new byte[newSize];
- int done = 0;
- dgContainer.serialize(done, b);
-
- // Finally, write out the children
- out.write(b);
- }
-
- /**
- * Create the Escher records associated with a new PPDrawing
- */
- private void create(){
- dgContainer.setRecordId( EscherContainerRecord.DG_CONTAINER );
- dgContainer.setOptions((short)15);
-
- dg = new EscherDgRecord();
- dg.setOptions((short)16);
- dg.setNumShapes(1);
- dgContainer.addChildRecord(dg);
-
- EscherContainerRecord spgrContainer = new EscherContainerRecord();
- spgrContainer.setOptions((short)15);
- spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
-
- EscherContainerRecord spContainer = new EscherContainerRecord();
- spContainer.setOptions((short)15);
- spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
-
- EscherSpgrRecord spgr = new EscherSpgrRecord();
- spgr.setOptions((short)1);
- spContainer.addChildRecord(spgr);
-
- EscherSpRecord sp = new EscherSpRecord();
- sp.setOptions((short)((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2));
- sp.setFlags(EscherSpRecord.FLAG_PATRIARCH | EscherSpRecord.FLAG_GROUP);
- spContainer.addChildRecord(sp);
- spgrContainer.addChildRecord(spContainer);
- dgContainer.addChildRecord(spgrContainer);
-
- spContainer = new EscherContainerRecord();
- spContainer.setOptions((short)15);
- spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
- sp = new EscherSpRecord();
- sp.setOptions((short)((ShapeType.RECT.nativeId << 4) + 2));
- sp.setFlags(EscherSpRecord.FLAG_BACKGROUND | EscherSpRecord.FLAG_HASSHAPETYPE);
- spContainer.addChildRecord(sp);
-
- EscherOptRecord opt = new EscherOptRecord();
- opt.setRecordId(EscherOptRecord.RECORD_ID);
- opt.addEscherProperty(new EscherRGBProperty(EscherPropertyTypes.FILL__FILLCOLOR, 134217728));
- opt.addEscherProperty(new EscherRGBProperty(EscherPropertyTypes.FILL__FILLBACKCOLOR, 134217733));
- opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.FILL__RECTRIGHT, 10064750));
- opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.FILL__RECTBOTTOM, 7778750));
- opt.addEscherProperty(new EscherBoolProperty(EscherPropertyTypes.FILL__NOFILLHITTEST, 1179666));
- opt.addEscherProperty(new EscherBoolProperty(EscherPropertyTypes.LINESTYLE__NOLINEDRAWDASH, 524288));
- opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.SHAPE__BLACKANDWHITESETTINGS, 9));
- opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.SHAPE__BACKGROUNDSHAPE, 65537));
- spContainer.addChildRecord(opt);
-
- dgContainer.addChildRecord(spContainer);
- }
-
- /**
- * Add a new EscherTextboxWrapper to this <code>PPDrawing</code>.
- */
- public void addTextboxWrapper(EscherTextboxWrapper txtbox){
- EscherTextboxWrapper[] tw = new EscherTextboxWrapper[textboxWrappers.length + 1];
- System.arraycopy(textboxWrappers, 0, tw, 0, textboxWrappers.length);
-
- tw[textboxWrappers.length] = txtbox;
- textboxWrappers = tw;
- }
-
- /**
- * @return the container record for drawings
- * @since POI 3.14-Beta2
- */
- public EscherContainerRecord getDgContainer() {
- return dgContainer;
- }
-
- /**
- * Return EscherDgRecord which keeps track of the number of shapes and shapeId in this drawing group
- *
- * @return EscherDgRecord
- */
- public EscherDgRecord getEscherDgRecord(){
- return dg;
- }
+ /**
+ * Sets everything up, groks the escher etc
+ */
+ PPDrawing(byte[] source, int start, int len) {
+ // Get the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Get the type
+ _type = LittleEndian.getUShort(_header,2);
+
+ // Build up a tree of Escher records contained within
+ final DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
+ dgContainer.fillFields(source, start + 8, erf);
+ assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
+ dg = dgContainer.getChildById(EscherRecordTypes.DG.typeID);
+
+ textboxWrappers = Stream.of(dgContainer).
+ flatMap(findEscherContainer(EscherRecordTypes.SPGR_CONTAINER)).
+ flatMap(findEscherContainer(EscherRecordTypes.SP_CONTAINER)).
+ flatMap(PPDrawing::getTextboxHelper).
+ toArray(EscherTextboxWrapper[]::new);
+ }
+
+ private static Stream<EscherTextboxWrapper> getTextboxHelper(EscherContainerRecord spContainer) {
+ Optional<EscherTextboxRecord> oTB = firstEscherRecord(spContainer, EscherRecordTypes.CLIENT_TEXTBOX);
+ if (!oTB.isPresent()) {
+ return Stream.empty();
+ }
+
+ 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 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(org.apache.poi.hslf.record.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();
+ }
+
+ /**
+ * We are type 1036
+ */
+ public long getRecordType() { return _type; }
+
+ /**
+ * We're pretending to be an atom, so return null
+ */
+ public org.apache.poi.hslf.record.Record[] getChildRecords() { return null; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ * Walks the escher layer to get the contents
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ // Ensure the escher layer reflects the text changes
+ for (EscherTextboxWrapper w : textboxWrappers) {
+ w.writeOut(null);
+ }
+
+ // Find the new size of the escher children;
+ int newSize = 0;
+ newSize += dgContainer.getRecordSize();
+
+ // Update the size (header bytes 5-8)
+ LittleEndian.putInt(_header,4,newSize);
+
+ // Write out our header
+ out.write(_header);
+
+ // Now grab the children's data
+ byte[] b = new byte[newSize];
+ int done = 0;
+ dgContainer.serialize(done, b);
+
+ // Finally, write out the children
+ out.write(b);
+ }
+
+ /**
+ * Create the Escher records associated with a new PPDrawing
+ */
+ private void create(){
+ dgContainer.setRecordId( EscherContainerRecord.DG_CONTAINER );
+ dgContainer.setOptions((short)15);
+
+ dg = new EscherDgRecord();
+ dg.setOptions((short)16);
+ dg.setNumShapes(1);
+ dgContainer.addChildRecord(dg);
+
+ EscherContainerRecord spgrContainer = new EscherContainerRecord();
+ spgrContainer.setOptions((short)15);
+ spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
+
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ spContainer.setOptions((short)15);
+ spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
+
+ EscherSpgrRecord spgr = new EscherSpgrRecord();
+ spgr.setOptions((short)1);
+ spContainer.addChildRecord(spgr);
+
+ EscherSpRecord sp = new EscherSpRecord();
+ sp.setOptions((short)((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2));
+ sp.setFlags(EscherSpRecord.FLAG_PATRIARCH | EscherSpRecord.FLAG_GROUP);
+ spContainer.addChildRecord(sp);
+ spgrContainer.addChildRecord(spContainer);
+ dgContainer.addChildRecord(spgrContainer);
+
+ spContainer = new EscherContainerRecord();
+ spContainer.setOptions((short)15);
+ spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
+ sp = new EscherSpRecord();
+ sp.setOptions((short)((ShapeType.RECT.nativeId << 4) + 2));
+ sp.setFlags(EscherSpRecord.FLAG_BACKGROUND | EscherSpRecord.FLAG_HASSHAPETYPE);
+ spContainer.addChildRecord(sp);
+
+ EscherOptRecord opt = new EscherOptRecord();
+ opt.setRecordId(EscherOptRecord.RECORD_ID);
+ opt.addEscherProperty(new EscherRGBProperty(EscherPropertyTypes.FILL__FILLCOLOR, 134217728));
+ opt.addEscherProperty(new EscherRGBProperty(EscherPropertyTypes.FILL__FILLBACKCOLOR, 134217733));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.FILL__RECTRIGHT, 10064750));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.FILL__RECTBOTTOM, 7778750));
+ opt.addEscherProperty(new EscherBoolProperty(EscherPropertyTypes.FILL__NOFILLHITTEST, 1179666));
+ opt.addEscherProperty(new EscherBoolProperty(EscherPropertyTypes.LINESTYLE__NOLINEDRAWDASH, 524288));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.SHAPE__BLACKANDWHITESETTINGS, 9));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherPropertyTypes.SHAPE__BACKGROUNDSHAPE, 65537));
+ spContainer.addChildRecord(opt);
+
+ dgContainer.addChildRecord(spContainer);
+ }
+
+ /**
+ * Add a new EscherTextboxWrapper to this <code>PPDrawing</code>.
+ */
+ public void addTextboxWrapper(EscherTextboxWrapper txtbox){
+ EscherTextboxWrapper[] tw = new EscherTextboxWrapper[textboxWrappers.length + 1];
+ System.arraycopy(textboxWrappers, 0, tw, 0, textboxWrappers.length);
+
+ tw[textboxWrappers.length] = txtbox;
+ textboxWrappers = tw;
+ }
+
+ /**
+ * @return the container record for drawings
+ * @since POI 3.14-Beta2
+ */
+ public EscherContainerRecord getDgContainer() {
+ return dgContainer;
+ }
+
+ /**
+ * Return EscherDgRecord which keeps track of the number of shapes and shapeId in this drawing group
+ *
+ * @return EscherDgRecord
+ */
+ public EscherDgRecord getEscherDgRecord(){
+ return dg;
+ }
public StyleTextProp9Atom[] getNumberedListInfo() {
- return 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<org.apache.poi.hslf.record.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));
- }
+ return 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<org.apache.poi.hslf.record.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/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ParentAwareRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ParentAwareRecord.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ParentAwareRecord.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ParentAwareRecord.java Sat May 22 21:37:08 2021
@@ -22,6 +22,6 @@ package org.apache.poi.hslf.record;
* parent is, and how it wants to be told which record is its parent.
*/
public interface ParentAwareRecord {
- public org.apache.poi.hslf.record.RecordContainer getParentRecord();
- public void setParentRecord(RecordContainer parentRecord);
+ public org.apache.poi.hslf.record.RecordContainer getParentRecord();
+ public void setParentRecord(RecordContainer parentRecord);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org