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 [4/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/ColorSchemeAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ColorSchemeAtom.java Sat May 22 21:37:08 2021
@@ -36,200 +36,200 @@ import org.apache.poi.util.LittleEndian;
* defines the colours to be used
*/
public final class ColorSchemeAtom extends RecordAtom {
- private static final long _type = 2032L;
+ private static final long _type = 2032L;
- private final byte[] _header;
- private int backgroundColourRGB;
- private int textAndLinesColourRGB;
- private int shadowsColourRGB;
- private int titleTextColourRGB;
- private int fillsColourRGB;
- private int accentColourRGB;
- private int accentAndHyperlinkColourRGB;
- private int accentAndFollowingHyperlinkColourRGB;
-
- /** Fetch the RGB value for Background Colour */
- public int getBackgroundColourRGB() { return backgroundColourRGB; }
- /** Set the RGB value for Background Colour */
- public void setBackgroundColourRGB(int rgb) { backgroundColourRGB = rgb; }
-
- /** Fetch the RGB value for Text And Lines Colour */
- public int getTextAndLinesColourRGB() { return textAndLinesColourRGB; }
- /** Set the RGB value for Text And Lines Colour */
- public void setTextAndLinesColourRGB(int rgb) { textAndLinesColourRGB = rgb; }
-
- /** Fetch the RGB value for Shadows Colour */
- public int getShadowsColourRGB() { return shadowsColourRGB; }
- /** Set the RGB value for Shadows Colour */
- public void setShadowsColourRGB(int rgb) { shadowsColourRGB = rgb; }
-
- /** Fetch the RGB value for Title Text Colour */
- public int getTitleTextColourRGB() { return titleTextColourRGB; }
- /** Set the RGB value for Title Text Colour */
- public void setTitleTextColourRGB(int rgb) { titleTextColourRGB = rgb; }
-
- /** Fetch the RGB value for Fills Colour */
- public int getFillsColourRGB() { return fillsColourRGB; }
- /** Set the RGB value for Fills Colour */
- public void setFillsColourRGB(int rgb) { fillsColourRGB = rgb; }
-
- /** Fetch the RGB value for Accent Colour */
- public int getAccentColourRGB() { return accentColourRGB; }
- /** Set the RGB value for Accent Colour */
- public void setAccentColourRGB(int rgb) { accentColourRGB = rgb; }
-
- /** Fetch the RGB value for Accent And Hyperlink Colour */
- public int getAccentAndHyperlinkColourRGB()
- { return accentAndHyperlinkColourRGB; }
- /** Set the RGB value for Accent And Hyperlink Colour */
- public void setAccentAndHyperlinkColourRGB(int rgb)
- { accentAndHyperlinkColourRGB = rgb; }
-
- /** Fetch the RGB value for Accent And Following Hyperlink Colour */
- public int getAccentAndFollowingHyperlinkColourRGB()
- { return accentAndFollowingHyperlinkColourRGB; }
- /** Set the RGB value for Accent And Following Hyperlink Colour */
- public void setAccentAndFollowingHyperlinkColourRGB(int rgb)
- { accentAndFollowingHyperlinkColourRGB = rgb; }
-
- /* *************** record code follows ********************** */
-
- /**
- * For the Colour Scheme (ColorSchem) Atom
- */
- protected ColorSchemeAtom(byte[] source, int start, int len) {
- // Sanity Checking - we're always 40 bytes long
- if (len < 40) {
- if(source.length - start < 40) {
- throw new HSLFException("Not enough data to form a ColorSchemeAtom (always 40 bytes long) - found " + (source.length - start));
- }
- }
-
- // Get the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Grab the rgb values
- backgroundColourRGB = LittleEndian.getInt(source, start+8);
- textAndLinesColourRGB = LittleEndian.getInt(source,start+8+4);
- shadowsColourRGB = LittleEndian.getInt(source,start+8+8);
- titleTextColourRGB = LittleEndian.getInt(source,start+8+12);
- fillsColourRGB = LittleEndian.getInt(source,start+8+16);
- accentColourRGB = LittleEndian.getInt(source,start+8+20);
- accentAndHyperlinkColourRGB = LittleEndian.getInt(source,start+8+24);
- accentAndFollowingHyperlinkColourRGB = LittleEndian.getInt(source,start+8+28);
- }
-
- /**
- * Create a new ColorSchemeAtom, to go with a new Slide
- */
- public ColorSchemeAtom(){
- _header = new byte[8];
- LittleEndian.putUShort(_header, 0, 16);
- LittleEndian.putUShort(_header, 2, (int)_type);
- LittleEndian.putInt(_header, 4, 32);
-
- // Setup the default rgb values
- backgroundColourRGB = 16777215;
- textAndLinesColourRGB = 0;
- shadowsColourRGB = 8421504;
- titleTextColourRGB = 0;
- fillsColourRGB = 10079232;
- accentColourRGB = 13382451;
- accentAndHyperlinkColourRGB = 16764108;
- accentAndFollowingHyperlinkColourRGB = 11711154;
- }
-
-
- /**
- * We are of type 3999
- */
- @Override
+ private final byte[] _header;
+ private int backgroundColourRGB;
+ private int textAndLinesColourRGB;
+ private int shadowsColourRGB;
+ private int titleTextColourRGB;
+ private int fillsColourRGB;
+ private int accentColourRGB;
+ private int accentAndHyperlinkColourRGB;
+ private int accentAndFollowingHyperlinkColourRGB;
+
+ /** Fetch the RGB value for Background Colour */
+ public int getBackgroundColourRGB() { return backgroundColourRGB; }
+ /** Set the RGB value for Background Colour */
+ public void setBackgroundColourRGB(int rgb) { backgroundColourRGB = rgb; }
+
+ /** Fetch the RGB value for Text And Lines Colour */
+ public int getTextAndLinesColourRGB() { return textAndLinesColourRGB; }
+ /** Set the RGB value for Text And Lines Colour */
+ public void setTextAndLinesColourRGB(int rgb) { textAndLinesColourRGB = rgb; }
+
+ /** Fetch the RGB value for Shadows Colour */
+ public int getShadowsColourRGB() { return shadowsColourRGB; }
+ /** Set the RGB value for Shadows Colour */
+ public void setShadowsColourRGB(int rgb) { shadowsColourRGB = rgb; }
+
+ /** Fetch the RGB value for Title Text Colour */
+ public int getTitleTextColourRGB() { return titleTextColourRGB; }
+ /** Set the RGB value for Title Text Colour */
+ public void setTitleTextColourRGB(int rgb) { titleTextColourRGB = rgb; }
+
+ /** Fetch the RGB value for Fills Colour */
+ public int getFillsColourRGB() { return fillsColourRGB; }
+ /** Set the RGB value for Fills Colour */
+ public void setFillsColourRGB(int rgb) { fillsColourRGB = rgb; }
+
+ /** Fetch the RGB value for Accent Colour */
+ public int getAccentColourRGB() { return accentColourRGB; }
+ /** Set the RGB value for Accent Colour */
+ public void setAccentColourRGB(int rgb) { accentColourRGB = rgb; }
+
+ /** Fetch the RGB value for Accent And Hyperlink Colour */
+ public int getAccentAndHyperlinkColourRGB()
+ { return accentAndHyperlinkColourRGB; }
+ /** Set the RGB value for Accent And Hyperlink Colour */
+ public void setAccentAndHyperlinkColourRGB(int rgb)
+ { accentAndHyperlinkColourRGB = rgb; }
+
+ /** Fetch the RGB value for Accent And Following Hyperlink Colour */
+ public int getAccentAndFollowingHyperlinkColourRGB()
+ { return accentAndFollowingHyperlinkColourRGB; }
+ /** Set the RGB value for Accent And Following Hyperlink Colour */
+ public void setAccentAndFollowingHyperlinkColourRGB(int rgb)
+ { accentAndFollowingHyperlinkColourRGB = rgb; }
+
+ /* *************** record code follows ********************** */
+
+ /**
+ * For the Colour Scheme (ColorSchem) Atom
+ */
+ protected ColorSchemeAtom(byte[] source, int start, int len) {
+ // Sanity Checking - we're always 40 bytes long
+ if (len < 40) {
+ if(source.length - start < 40) {
+ throw new HSLFException("Not enough data to form a ColorSchemeAtom (always 40 bytes long) - found " + (source.length - start));
+ }
+ }
+
+ // Get the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Grab the rgb values
+ backgroundColourRGB = LittleEndian.getInt(source, start+8);
+ textAndLinesColourRGB = LittleEndian.getInt(source,start+8+4);
+ shadowsColourRGB = LittleEndian.getInt(source,start+8+8);
+ titleTextColourRGB = LittleEndian.getInt(source,start+8+12);
+ fillsColourRGB = LittleEndian.getInt(source,start+8+16);
+ accentColourRGB = LittleEndian.getInt(source,start+8+20);
+ accentAndHyperlinkColourRGB = LittleEndian.getInt(source,start+8+24);
+ accentAndFollowingHyperlinkColourRGB = LittleEndian.getInt(source,start+8+28);
+ }
+
+ /**
+ * Create a new ColorSchemeAtom, to go with a new Slide
+ */
+ public ColorSchemeAtom(){
+ _header = new byte[8];
+ LittleEndian.putUShort(_header, 0, 16);
+ LittleEndian.putUShort(_header, 2, (int)_type);
+ LittleEndian.putInt(_header, 4, 32);
+
+ // Setup the default rgb values
+ backgroundColourRGB = 16777215;
+ textAndLinesColourRGB = 0;
+ shadowsColourRGB = 8421504;
+ titleTextColourRGB = 0;
+ fillsColourRGB = 10079232;
+ accentColourRGB = 13382451;
+ accentAndHyperlinkColourRGB = 16764108;
+ accentAndFollowingHyperlinkColourRGB = 11711154;
+ }
+
+
+ /**
+ * We are of type 3999
+ */
+ @Override
public long getRecordType() { return _type; }
- /**
- * Convert from an integer RGB value to individual R, G, B 0-255 values
- */
- public static byte[] splitRGB(int rgb) {
- byte[] ret = new byte[3];
-
- // Serialise to bytes, then grab the right ones out
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- try {
- writeLittleEndian(rgb,baos);
- } catch(IOException ie) {
- // Should never happen
- throw new HSLFException(ie);
- }
- byte[] b = baos.toByteArray();
- System.arraycopy(b,0,ret,0,3);
-
- return ret;
- }
-
- /**
- * Convert from split R, G, B values to an integer RGB value
- */
- public static int joinRGB(byte r, byte g, byte b) {
- return joinRGB(new byte[] { r,g,b });
- }
- /**
- * Convert from split R, G, B values to an integer RGB value
- */
- public static int joinRGB(byte[] rgb) {
- if(rgb.length != 3) {
- throw new HSLFException("joinRGB accepts a byte array of 3 values, but got one of " + rgb.length + " values!");
- }
- byte[] with_zero = new byte[4];
- System.arraycopy(rgb,0,with_zero,0,3);
- with_zero[3] = 0;
+ /**
+ * Convert from an integer RGB value to individual R, G, B 0-255 values
+ */
+ public static byte[] splitRGB(int rgb) {
+ byte[] ret = new byte[3];
+
+ // Serialise to bytes, then grab the right ones out
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ try {
+ writeLittleEndian(rgb,baos);
+ } catch(IOException ie) {
+ // Should never happen
+ throw new HSLFException(ie);
+ }
+ byte[] b = baos.toByteArray();
+ System.arraycopy(b,0,ret,0,3);
+
+ return ret;
+ }
+
+ /**
+ * Convert from split R, G, B values to an integer RGB value
+ */
+ public static int joinRGB(byte r, byte g, byte b) {
+ return joinRGB(new byte[] { r,g,b });
+ }
+ /**
+ * Convert from split R, G, B values to an integer RGB value
+ */
+ public static int joinRGB(byte[] rgb) {
+ if(rgb.length != 3) {
+ throw new HSLFException("joinRGB accepts a byte array of 3 values, but got one of " + rgb.length + " values!");
+ }
+ byte[] with_zero = new byte[4];
+ System.arraycopy(rgb,0,with_zero,0,3);
+ with_zero[3] = 0;
return LittleEndian.getInt(with_zero,0);
- }
+ }
- /**
- * 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 {
- // Header - size or type unchanged
- out.write(_header);
+ // Header - size or type unchanged
+ out.write(_header);
- // Write out the rgb values
- writeLittleEndian(backgroundColourRGB,out);
- writeLittleEndian(textAndLinesColourRGB,out);
- writeLittleEndian(shadowsColourRGB,out);
- writeLittleEndian(titleTextColourRGB,out);
- writeLittleEndian(fillsColourRGB,out);
- writeLittleEndian(accentColourRGB,out);
- writeLittleEndian(accentAndHyperlinkColourRGB,out);
- writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out);
- }
-
- /**
- * Returns color by its index
- *
- * @param idx 0-based color index
- * @return color by its index
- */
- public int getColor(int idx){
- int[] clr = {backgroundColourRGB, textAndLinesColourRGB, shadowsColourRGB, titleTextColourRGB,
- fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB};
- return clr[idx];
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- final Map<String, Supplier<?>> m = new LinkedHashMap<>();
- m.put("backgroundColourRGB", this::getBackgroundColourRGB);
- m.put("textAndLinesColourRGB", this::getTextAndLinesColourRGB);
- m.put("shadowsColourRGB", this::getShadowsColourRGB);
- m.put("titleTextColourRGB", this::getTitleTextColourRGB);
- m.put("fillsColourRGB", this::getFillsColourRGB);
- m.put("accentColourRGB", this::getAccentColourRGB);
- m.put("accentAndHyperlinkColourRGB", this::getAccentAndHyperlinkColourRGB);
- m.put("accentAndFollowingHyperlinkColourRGB", this::getAccentAndFollowingHyperlinkColourRGB);
- return Collections.unmodifiableMap(m);
- }
+ // Write out the rgb values
+ writeLittleEndian(backgroundColourRGB,out);
+ writeLittleEndian(textAndLinesColourRGB,out);
+ writeLittleEndian(shadowsColourRGB,out);
+ writeLittleEndian(titleTextColourRGB,out);
+ writeLittleEndian(fillsColourRGB,out);
+ writeLittleEndian(accentColourRGB,out);
+ writeLittleEndian(accentAndHyperlinkColourRGB,out);
+ writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out);
+ }
+
+ /**
+ * Returns color by its index
+ *
+ * @param idx 0-based color index
+ * @return color by its index
+ */
+ public int getColor(int idx){
+ int[] clr = {backgroundColourRGB, textAndLinesColourRGB, shadowsColourRGB, titleTextColourRGB,
+ fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB};
+ return clr[idx];
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String, Supplier<?>> m = new LinkedHashMap<>();
+ m.put("backgroundColourRGB", this::getBackgroundColourRGB);
+ m.put("textAndLinesColourRGB", this::getTextAndLinesColourRGB);
+ m.put("shadowsColourRGB", this::getShadowsColourRGB);
+ m.put("titleTextColourRGB", this::getTitleTextColourRGB);
+ m.put("fillsColourRGB", this::getFillsColourRGB);
+ m.put("accentColourRGB", this::getAccentColourRGB);
+ m.put("accentAndHyperlinkColourRGB", this::getAccentAndHyperlinkColourRGB);
+ m.put("accentAndFollowingHyperlinkColourRGB", this::getAccentAndFollowingHyperlinkColourRGB);
+ return Collections.unmodifiableMap(m);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000.java Sat May 22 21:37:08 2021
@@ -30,10 +30,10 @@ import static org.apache.logging.log4j.u
* PPT 2000/XP/etc. (PPT 97 uses plain Escher Text Boxes for comments)
*/
public final class Comment2000 extends RecordContainer {
- private byte[] _header;
- private static final long _type = RecordTypes.Comment2000.typeID;
+ private byte[] _header;
+ private static final long _type = RecordTypes.Comment2000.typeID;
- // Links to our more interesting children
+ // Links to our more interesting children
/**
* An optional string that specifies the name of the author of the presentation comment.
@@ -53,68 +53,68 @@ public final class Comment2000 extends R
*/
private Comment2000Atom commentAtom;
- /**
- * Returns the Comment2000Atom of this Comment
- */
- public Comment2000Atom getComment2000Atom() { return commentAtom; }
-
- /**
- * Get the Author of this comment
- */
- public String getAuthor() {
- return authorRecord == null ? null : authorRecord.getText();
- }
- /**
- * Set the Author of this comment
- */
- public void setAuthor(String author) {
- authorRecord.setText(author);
- }
-
- /**
- * Get the Author's Initials of this comment
- */
- public String getAuthorInitials() {
- return authorInitialsRecord == null ? null : authorInitialsRecord.getText();
- }
- /**
- * Set the Author's Initials of this comment
- */
- public void setAuthorInitials(String initials) {
- authorInitialsRecord.setText(initials);
- }
-
- /**
- * Get the text of this comment
- */
- public String getText() {
- return commentRecord == null ? null : commentRecord.getText();
- }
- /**
- * Set the text of this comment
- */
- public void setText(String text) {
- commentRecord.setText(text);
- }
-
- /**
- * Set things up, and find our more interesting children
- */
- protected Comment2000(byte[] source, int start, int len) {
- // Grab the header
- _header = Arrays.copyOfRange(source, start, start+8);
-
- // Find our children
- _children = org.apache.poi.hslf.record.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() {
+ /**
+ * Returns the Comment2000Atom of this Comment
+ */
+ public Comment2000Atom getComment2000Atom() { return commentAtom; }
+
+ /**
+ * Get the Author of this comment
+ */
+ public String getAuthor() {
+ return authorRecord == null ? null : authorRecord.getText();
+ }
+ /**
+ * Set the Author of this comment
+ */
+ public void setAuthor(String author) {
+ authorRecord.setText(author);
+ }
+
+ /**
+ * Get the Author's Initials of this comment
+ */
+ public String getAuthorInitials() {
+ return authorInitialsRecord == null ? null : authorInitialsRecord.getText();
+ }
+ /**
+ * Set the Author's Initials of this comment
+ */
+ public void setAuthorInitials(String initials) {
+ authorInitialsRecord.setText(initials);
+ }
+
+ /**
+ * Get the text of this comment
+ */
+ public String getText() {
+ return commentRecord == null ? null : commentRecord.getText();
+ }
+ /**
+ * Set the text of this comment
+ */
+ public void setText(String text) {
+ commentRecord.setText(text);
+ }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected Comment2000(byte[] source, int start, int len) {
+ // Grab the header
+ _header = Arrays.copyOfRange(source, start, start+8);
+
+ // Find our children
+ _children = org.apache.poi.hslf.record.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() {
for(org.apache.poi.hslf.record.Record r : _children){
if (r instanceof CString){
@@ -129,47 +129,47 @@ public final class Comment2000 extends R
} else if (r instanceof Comment2000Atom){
commentAtom = (Comment2000Atom)r;
} else {
- LOG.atWarn().log("Unexpected record with type={} in Comment2000: {}", box(r.getRecordType()),r.getClass().getName());
+ LOG.atWarn().log("Unexpected record with type={} in Comment2000: {}", box(r.getRecordType()),r.getClass().getName());
}
}
- }
+ }
- /**
- * Create a new Comment2000, with blank fields
- */
- public Comment2000() {
- _header = new byte[8];
- _children = new org.apache.poi.hslf.record.Record[4];
-
- // 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();
- CString csc = new CString();
- csa.setOptions(0x00);
- csb.setOptions(0x10);
- csc.setOptions(0x20);
- _children[0] = csa;
- _children[1] = csb;
- _children[2] = csc;
- _children[3] = new Comment2000Atom();
- findInterestingChildren();
- }
-
- /**
- * We are of type 1200
- */
- 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 Comment2000, with blank fields
+ */
+ public Comment2000() {
+ _header = new byte[8];
+ _children = new org.apache.poi.hslf.record.Record[4];
+
+ // 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();
+ CString csc = new CString();
+ csa.setOptions(0x00);
+ csb.setOptions(0x10);
+ csc.setOptions(0x20);
+ _children[0] = csa;
+ _children[1] = csb;
+ _children[2] = csc;
+ _children[3] = new Comment2000Atom();
+ findInterestingChildren();
+ }
+
+ /**
+ * We are of type 1200
+ */
+ 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/Comment2000Atom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000Atom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000Atom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Comment2000Atom.java Sat May 22 21:37:08 2021
@@ -98,7 +98,7 @@ public final class Comment2000Atom exten
* @return the comment date.
*/
public Date getDate() {
- return SystemTimeUtils.getDate(_data,4);
+ return SystemTimeUtils.getDate(_data,4);
}
/**
@@ -106,7 +106,7 @@ public final class Comment2000Atom exten
* @param date the comment date.
*/
public void setDate(Date date) {
- SystemTimeUtils.storeDate(date, _data, 4);
+ SystemTimeUtils.storeDate(date, _data, 4);
}
/**
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java Sat May 22 21:37:08 2021
@@ -46,232 +46,232 @@ import org.apache.poi.util.StringUtil;
*/
public class CurrentUserAtom
{
- private static final Logger LOG = LogManager.getLogger(CurrentUserAtom.class);
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
-
- /** Standard Atom header */
- private static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
- /** The PowerPoint magic number for a non-encrypted file */
- private static final byte[] headerToken = new byte[] { 95, -64, -111, -29 };
- /** The PowerPoint magic number for an encrypted file */
- private static final byte[] encHeaderToken = new byte[] { -33, -60, -47, -13 };
- // The Powerpoint 97 version, major and minor numbers
- // byte[] ppt97FileVer = new byte[] { 8, 00, -13, 03, 03, 00 };
-
- /** The version, major and minor numbers */
- private int docFinalVersion;
- private byte docMajorNo;
- private byte docMinorNo;
+ private static final Logger LOG = LogManager.getLogger(CurrentUserAtom.class);
+ //arbitrarily selected; may need to increase
+ private static final int MAX_RECORD_LENGTH = 1_000_000;
+
+ /** Standard Atom header */
+ private static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
+ /** The PowerPoint magic number for a non-encrypted file */
+ private static final byte[] headerToken = new byte[] { 95, -64, -111, -29 };
+ /** The PowerPoint magic number for an encrypted file */
+ private static final byte[] encHeaderToken = new byte[] { -33, -60, -47, -13 };
+ // The Powerpoint 97 version, major and minor numbers
+ // byte[] ppt97FileVer = new byte[] { 8, 00, -13, 03, 03, 00 };
+
+ /** The version, major and minor numbers */
+ private int docFinalVersion;
+ private byte docMajorNo;
+ private byte docMinorNo;
- /** The Offset into the file for the current edit */
+ /** The Offset into the file for the current edit */
private long currentEditOffset;
- /** The Username of the last person to edit the file */
- private String lastEditUser;
- /** The document release version. Almost always 8 */
- private long releaseVersion;
-
- /** Only correct after reading in or writing out */
- private byte[] _contents;
-
- /** Flag for encryption state of the whole file */
- private boolean isEncrypted;
-
-
- /* ********************* getter/setter follows *********************** */
-
- public int getDocFinalVersion() { return docFinalVersion; }
- public byte getDocMajorNo() { return docMajorNo; }
- public byte getDocMinorNo() { return docMinorNo; }
-
- public long getReleaseVersion() { return releaseVersion; }
- public void setReleaseVersion(long rv) { releaseVersion = rv; }
-
- /** Points to the UserEditAtom */
- public long getCurrentEditOffset() { return currentEditOffset; }
- public void setCurrentEditOffset(long id ) { currentEditOffset = id; }
-
- public String getLastEditUsername() { return lastEditUser; }
- public void setLastEditUsername(String u) { lastEditUser = u; }
-
- public boolean isEncrypted() { return isEncrypted; }
- public void setEncrypted(boolean isEncrypted) { this.isEncrypted = isEncrypted; }
-
-
- /* ********************* real code follows *************************** */
-
- /**
- * Create a new Current User Atom
- */
- public CurrentUserAtom() {
- _contents = new byte[0];
-
- // Initialise to empty
- docFinalVersion = 0x03f4;
- docMajorNo = 3;
- docMinorNo = 0;
- releaseVersion = 8;
- currentEditOffset = 0;
- lastEditUser = "Apache POI";
- isEncrypted = false;
- }
-
-
- /**
- * Find the Current User in the filesystem, and create from that
- */
- public CurrentUserAtom(DirectoryNode dir) throws IOException {
- // Decide how big it is
- DocumentEntry docProps =
- (DocumentEntry)dir.getEntry("Current User");
-
- // If it's clearly junk, bail out
- if(docProps.getSize() > 131072) {
- throw new CorruptPowerPointFileException("The Current User stream is implausably long. It's normally 28-200 bytes long, but was " + docProps.getSize() + " bytes");
- }
-
- // Grab the contents
- try (InputStream in = dir.createDocumentInputStream("Current User")) {
- _contents = IOUtils.toByteArray(in, docProps.getSize(), MAX_RECORD_LENGTH);
- }
-
- // See how long it is. If it's under 28 bytes long, we can't
- // read it
- if(_contents.length < 28) {
- boolean isPP95 = dir.hasEntry(PP95_DOCUMENT);
- // PPT95 has 4 byte size, then data
- if (!isPP95 && _contents.length >= 4) {
- int size = LittleEndian.getInt(_contents);
- isPP95 = (size + 4 == _contents.length);
- }
-
- if (isPP95) {
- throw new OldPowerPointFormatException("Based on the Current User stream, you seem to have supplied a PowerPoint95 file, which isn't supported");
- } else {
- throw new CorruptPowerPointFileException("The Current User stream must be at least 28 bytes long, but was only " + _contents.length);
- }
- }
-
- // Set everything up
- init();
- }
-
- /**
- * Actually do the creation from a block of bytes
- */
- private void init() {
- // First up is the size, in 4 bytes, which is fixed
- // Then is the header
-
- isEncrypted = (LittleEndian.getInt(encHeaderToken) == LittleEndian.getInt(_contents,12));
-
- // Grab the edit offset
- currentEditOffset = LittleEndian.getUInt(_contents,16);
-
- // Grab the versions
- docFinalVersion = LittleEndian.getUShort(_contents,22);
- docMajorNo = _contents[24];
- docMinorNo = _contents[25];
-
- // Get the username length
- long usernameLen = LittleEndian.getUShort(_contents,20);
- if(usernameLen > 512) {
- // Handle the case of it being garbage
- LOG.atWarn().log("Invalid username length {} found, treating as if there was no username set", box(usernameLen));
- usernameLen = 0;
- }
-
- // Now we know the length of the username,
- // use this to grab the revision
- if(_contents.length >= 28+(int)usernameLen + 4) {
- releaseVersion = LittleEndian.getUInt(_contents,28+(int)usernameLen);
- } else {
- // No revision given, as not enough data. Odd
- releaseVersion = 0;
- }
-
- // Grab the unicode username, if stored
- int start = 28+(int)usernameLen+4;
-
- if(_contents.length >= start+2*usernameLen) {
- lastEditUser = StringUtil.getFromUnicodeLE(_contents, start, (int)usernameLen);
- } else {
- // Fake from the 8 bit version
- lastEditUser = StringUtil.getFromCompressedUnicode(_contents, 28, (int)usernameLen);
- }
- }
-
-
- /**
- * Writes ourselves back out
- */
- public void writeOut(OutputStream out) throws IOException {
- // Decide on the size
- // 8 = atom header
- // 20 = up to name
- // 4 = revision
- // 3 * len = ascii + unicode
- int size = 8 + 20 + 4 + (3 * lastEditUser.length());
- _contents = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
-
- // First we have a 8 byte atom header
- System.arraycopy(atomHeader,0,_contents,0,4);
- // Size is 20+user len + revision len(4)
- int atomSize = 20+4+lastEditUser.length();
- LittleEndian.putInt(_contents,4,atomSize);
-
- // Now we have the size of the details, which is 20
- LittleEndian.putInt(_contents,8,20);
-
- // Now the ppt un-encrypted header token (4 bytes)
- System.arraycopy((isEncrypted ? encHeaderToken : headerToken),0,_contents,12,4);
-
- // Now the current edit offset
- LittleEndian.putInt(_contents,16,(int)currentEditOffset);
-
- // The username gets stored twice, once as US
- // ascii, and again as unicode laster on
- byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), MAX_RECORD_LENGTH);
- StringUtil.putCompressedUnicode(lastEditUser,asciiUN,0);
-
- // Now we're able to do the length of the last edited user
- LittleEndian.putShort(_contents,20,(short)asciiUN.length);
-
- // Now the file versions, 2+1+1
- LittleEndian.putShort(_contents,22,(short)docFinalVersion);
- _contents[24] = docMajorNo;
- _contents[25] = docMinorNo;
-
- // 2 bytes blank
- _contents[26] = 0;
- _contents[27] = 0;
-
- // At this point we have the username as us ascii
- System.arraycopy(asciiUN,0,_contents,28,asciiUN.length);
-
- // 4 byte release version
- LittleEndian.putInt(_contents,28+asciiUN.length,(int)releaseVersion);
-
- // username in unicode
- byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, MAX_RECORD_LENGTH);
- StringUtil.putUnicodeLE(lastEditUser,ucUN,0);
- System.arraycopy(ucUN,0,_contents,28+asciiUN.length+4,ucUN.length);
-
- // Write out
- out.write(_contents);
- }
-
- /**
- * Writes ourselves back out to a filesystem
- */
- public void writeToFS(POIFSFileSystem fs) throws IOException {
- // Grab contents
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
- writeOut(baos);
- try (InputStream is = baos.toInputStream()) {
- // Write out
- fs.createOrUpdateDocument(is, "Current User");
- }
- }
- }
+ /** The Username of the last person to edit the file */
+ private String lastEditUser;
+ /** The document release version. Almost always 8 */
+ private long releaseVersion;
+
+ /** Only correct after reading in or writing out */
+ private byte[] _contents;
+
+ /** Flag for encryption state of the whole file */
+ private boolean isEncrypted;
+
+
+ /* ********************* getter/setter follows *********************** */
+
+ public int getDocFinalVersion() { return docFinalVersion; }
+ public byte getDocMajorNo() { return docMajorNo; }
+ public byte getDocMinorNo() { return docMinorNo; }
+
+ public long getReleaseVersion() { return releaseVersion; }
+ public void setReleaseVersion(long rv) { releaseVersion = rv; }
+
+ /** Points to the UserEditAtom */
+ public long getCurrentEditOffset() { return currentEditOffset; }
+ public void setCurrentEditOffset(long id ) { currentEditOffset = id; }
+
+ public String getLastEditUsername() { return lastEditUser; }
+ public void setLastEditUsername(String u) { lastEditUser = u; }
+
+ public boolean isEncrypted() { return isEncrypted; }
+ public void setEncrypted(boolean isEncrypted) { this.isEncrypted = isEncrypted; }
+
+
+ /* ********************* real code follows *************************** */
+
+ /**
+ * Create a new Current User Atom
+ */
+ public CurrentUserAtom() {
+ _contents = new byte[0];
+
+ // Initialise to empty
+ docFinalVersion = 0x03f4;
+ docMajorNo = 3;
+ docMinorNo = 0;
+ releaseVersion = 8;
+ currentEditOffset = 0;
+ lastEditUser = "Apache POI";
+ isEncrypted = false;
+ }
+
+
+ /**
+ * Find the Current User in the filesystem, and create from that
+ */
+ public CurrentUserAtom(DirectoryNode dir) throws IOException {
+ // Decide how big it is
+ DocumentEntry docProps =
+ (DocumentEntry)dir.getEntry("Current User");
+
+ // If it's clearly junk, bail out
+ if(docProps.getSize() > 131072) {
+ throw new CorruptPowerPointFileException("The Current User stream is implausably long. It's normally 28-200 bytes long, but was " + docProps.getSize() + " bytes");
+ }
+
+ // Grab the contents
+ try (InputStream in = dir.createDocumentInputStream("Current User")) {
+ _contents = IOUtils.toByteArray(in, docProps.getSize(), MAX_RECORD_LENGTH);
+ }
+
+ // See how long it is. If it's under 28 bytes long, we can't
+ // read it
+ if(_contents.length < 28) {
+ boolean isPP95 = dir.hasEntry(PP95_DOCUMENT);
+ // PPT95 has 4 byte size, then data
+ if (!isPP95 && _contents.length >= 4) {
+ int size = LittleEndian.getInt(_contents);
+ isPP95 = (size + 4 == _contents.length);
+ }
+
+ if (isPP95) {
+ throw new OldPowerPointFormatException("Based on the Current User stream, you seem to have supplied a PowerPoint95 file, which isn't supported");
+ } else {
+ throw new CorruptPowerPointFileException("The Current User stream must be at least 28 bytes long, but was only " + _contents.length);
+ }
+ }
+
+ // Set everything up
+ init();
+ }
+
+ /**
+ * Actually do the creation from a block of bytes
+ */
+ private void init() {
+ // First up is the size, in 4 bytes, which is fixed
+ // Then is the header
+
+ isEncrypted = (LittleEndian.getInt(encHeaderToken) == LittleEndian.getInt(_contents,12));
+
+ // Grab the edit offset
+ currentEditOffset = LittleEndian.getUInt(_contents,16);
+
+ // Grab the versions
+ docFinalVersion = LittleEndian.getUShort(_contents,22);
+ docMajorNo = _contents[24];
+ docMinorNo = _contents[25];
+
+ // Get the username length
+ long usernameLen = LittleEndian.getUShort(_contents,20);
+ if(usernameLen > 512) {
+ // Handle the case of it being garbage
+ LOG.atWarn().log("Invalid username length {} found, treating as if there was no username set", box(usernameLen));
+ usernameLen = 0;
+ }
+
+ // Now we know the length of the username,
+ // use this to grab the revision
+ if(_contents.length >= 28+(int)usernameLen + 4) {
+ releaseVersion = LittleEndian.getUInt(_contents,28+(int)usernameLen);
+ } else {
+ // No revision given, as not enough data. Odd
+ releaseVersion = 0;
+ }
+
+ // Grab the unicode username, if stored
+ int start = 28+(int)usernameLen+4;
+
+ if(_contents.length >= start+2*usernameLen) {
+ lastEditUser = StringUtil.getFromUnicodeLE(_contents, start, (int)usernameLen);
+ } else {
+ // Fake from the 8 bit version
+ lastEditUser = StringUtil.getFromCompressedUnicode(_contents, 28, (int)usernameLen);
+ }
+ }
+
+
+ /**
+ * Writes ourselves back out
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ // Decide on the size
+ // 8 = atom header
+ // 20 = up to name
+ // 4 = revision
+ // 3 * len = ascii + unicode
+ int size = 8 + 20 + 4 + (3 * lastEditUser.length());
+ _contents = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
+
+ // First we have a 8 byte atom header
+ System.arraycopy(atomHeader,0,_contents,0,4);
+ // Size is 20+user len + revision len(4)
+ int atomSize = 20+4+lastEditUser.length();
+ LittleEndian.putInt(_contents,4,atomSize);
+
+ // Now we have the size of the details, which is 20
+ LittleEndian.putInt(_contents,8,20);
+
+ // Now the ppt un-encrypted header token (4 bytes)
+ System.arraycopy((isEncrypted ? encHeaderToken : headerToken),0,_contents,12,4);
+
+ // Now the current edit offset
+ LittleEndian.putInt(_contents,16,(int)currentEditOffset);
+
+ // The username gets stored twice, once as US
+ // ascii, and again as unicode laster on
+ byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), MAX_RECORD_LENGTH);
+ StringUtil.putCompressedUnicode(lastEditUser,asciiUN,0);
+
+ // Now we're able to do the length of the last edited user
+ LittleEndian.putShort(_contents,20,(short)asciiUN.length);
+
+ // Now the file versions, 2+1+1
+ LittleEndian.putShort(_contents,22,(short)docFinalVersion);
+ _contents[24] = docMajorNo;
+ _contents[25] = docMinorNo;
+
+ // 2 bytes blank
+ _contents[26] = 0;
+ _contents[27] = 0;
+
+ // At this point we have the username as us ascii
+ System.arraycopy(asciiUN,0,_contents,28,asciiUN.length);
+
+ // 4 byte release version
+ LittleEndian.putInt(_contents,28+asciiUN.length,(int)releaseVersion);
+
+ // username in unicode
+ byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, MAX_RECORD_LENGTH);
+ StringUtil.putUnicodeLE(lastEditUser,ucUN,0);
+ System.arraycopy(ucUN,0,_contents,28+asciiUN.length+4,ucUN.length);
+
+ // Write out
+ out.write(_contents);
+ }
+
+ /**
+ * Writes ourselves back out to a filesystem
+ */
+ public void writeToFS(POIFSFileSystem fs) throws IOException {
+ // Grab contents
+ try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ writeOut(baos);
+ try (InputStream is = baos.toInputStream()) {
+ // Write out
+ fs.createOrUpdateDocument(is, "Current User");
+ }
+ }
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocInfoListContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocInfoListContainer.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocInfoListContainer.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocInfoListContainer.java Sat May 22 21:37:08 2021
@@ -29,62 +29,62 @@ import org.apache.poi.util.LittleEndian;
* A container record that specifies information about the document and document display settings.
*/
public final class DocInfoListContainer extends RecordContainer {
- private byte[] _header;
- private static final long _type = RecordTypes.List.typeID;
+ private byte[] _header;
+ private static final long _type = RecordTypes.List.typeID;
- // Links to our more interesting children
+ // Links to our more interesting children
- /**
- * Set things up, and find our more interesting children
- */
- protected DocInfoListContainer(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() {
-
- }
-
- /**
- * Create a new DocInfoListContainer, with blank fields - not yet supported
- */
- private DocInfoListContainer() {
- _header = new byte[8];
- _children = new org.apache.poi.hslf.record.Record[0];
-
- // Setup our header block
- _header[0] = 0x0f; // We are a container record
- LittleEndian.putShort(_header, 2, (short)_type);
-
- // Setup our child records
- findInterestingChildren();
- }
-
- /**
- * We are of type 0x7D0
- */
- 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);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return null;
- }
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected DocInfoListContainer(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() {
+
+ }
+
+ /**
+ * Create a new DocInfoListContainer, with blank fields - not yet supported
+ */
+ private DocInfoListContainer() {
+ _header = new byte[8];
+ _children = new org.apache.poi.hslf.record.Record[0];
+
+ // Setup our header block
+ _header[0] = 0x0f; // We are a container record
+ LittleEndian.putShort(_header, 2, (short)_type);
+
+ // Setup our child records
+ findInterestingChildren();
+ }
+
+ /**
+ * We are of type 0x7D0
+ */
+ 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);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return null;
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Document.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Document.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Document.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Document.java Sat May 22 21:37:08 2021
@@ -31,177 +31,177 @@ import static org.apache.logging.log4j.u
public final class Document extends PositionDependentRecordContainer
{
- private byte[] _header;
- private static long _type = 1000;
+ private byte[] _header;
+ private static long _type = 1000;
- // Links to our more interesting children
- private DocumentAtom documentAtom;
- private Environment environment;
- private PPDrawingGroup ppDrawing;
- private SlideListWithText[] slwts;
- private ExObjList exObjList; // Can be null
-
- /**
- * Returns the DocumentAtom of this Document
- */
- public DocumentAtom getDocumentAtom() { return documentAtom; }
-
- /**
- * Returns the Environment of this Notes, which lots of
- * settings for the document in it
- */
- public Environment getEnvironment() { return environment; }
-
- /**
- * Returns the PPDrawingGroup, which holds an Escher Structure
- * that contains information on pictures in the slides.
- */
- public PPDrawingGroup getPPDrawingGroup() { return ppDrawing; }
-
- /**
- * Returns the ExObjList, which holds the references to
- * external objects used in the slides. This may be null, if
- * there are no external references.
- *
- * @param create if true, create an ExObjList if it doesn't exist
- */
- public ExObjList getExObjList(boolean create) {
- if (exObjList == null && create) {
- exObjList = new ExObjList();
- addChildAfter(exObjList, getDocumentAtom());
- }
- return exObjList;
- }
-
- /**
- * Returns all the SlideListWithTexts that are defined for
- * this Document. They hold the text, and some of the text
- * properties, which are referred to by the slides.
- * This will normally return an array of size 2 or 3
- */
- public SlideListWithText[] getSlideListWithTexts() { return slwts; }
-
- /**
- * Returns the SlideListWithText that deals with the
- * Master Slides
- */
- public SlideListWithText getMasterSlideListWithText() {
- for (SlideListWithText slwt : slwts) {
- if (slwt.getInstance() == SlideListWithText.MASTER) {
- return slwt;
- }
- }
+ // Links to our more interesting children
+ private DocumentAtom documentAtom;
+ private Environment environment;
+ private PPDrawingGroup ppDrawing;
+ private SlideListWithText[] slwts;
+ private ExObjList exObjList; // Can be null
+
+ /**
+ * Returns the DocumentAtom of this Document
+ */
+ public DocumentAtom getDocumentAtom() { return documentAtom; }
+
+ /**
+ * Returns the Environment of this Notes, which lots of
+ * settings for the document in it
+ */
+ public Environment getEnvironment() { return environment; }
+
+ /**
+ * Returns the PPDrawingGroup, which holds an Escher Structure
+ * that contains information on pictures in the slides.
+ */
+ public PPDrawingGroup getPPDrawingGroup() { return ppDrawing; }
+
+ /**
+ * Returns the ExObjList, which holds the references to
+ * external objects used in the slides. This may be null, if
+ * there are no external references.
+ *
+ * @param create if true, create an ExObjList if it doesn't exist
+ */
+ public ExObjList getExObjList(boolean create) {
+ if (exObjList == null && create) {
+ exObjList = new ExObjList();
+ addChildAfter(exObjList, getDocumentAtom());
+ }
+ return exObjList;
+ }
+
+ /**
+ * Returns all the SlideListWithTexts that are defined for
+ * this Document. They hold the text, and some of the text
+ * properties, which are referred to by the slides.
+ * This will normally return an array of size 2 or 3
+ */
+ public SlideListWithText[] getSlideListWithTexts() { return slwts; }
+
+ /**
+ * Returns the SlideListWithText that deals with the
+ * Master Slides
+ */
+ public SlideListWithText getMasterSlideListWithText() {
+ for (SlideListWithText slwt : slwts) {
+ if (slwt.getInstance() == SlideListWithText.MASTER) {
+ return slwt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the SlideListWithText that deals with the
+ * Slides, or null if there isn't one
+ */
+ public SlideListWithText getSlideSlideListWithText() {
+ for (SlideListWithText slwt : slwts) {
+ if (slwt.getInstance() == SlideListWithText.SLIDES) {
+ return slwt;
+ }
+ }
+ return null;
+ }
+ /**
+ * Returns the SlideListWithText that deals with the
+ * notes, or null if there isn't one
+ */
+ public SlideListWithText getNotesSlideListWithText() {
+ for (SlideListWithText slwt : slwts) {
+ if (slwt.getInstance() == SlideListWithText.NOTES) {
+ return slwt;
+ }
+ }
return null;
}
- /**
- * Returns the SlideListWithText that deals with the
- * Slides, or null if there isn't one
- */
- public SlideListWithText getSlideSlideListWithText() {
- for (SlideListWithText slwt : slwts) {
- if (slwt.getInstance() == SlideListWithText.SLIDES) {
- return slwt;
- }
- }
- return null;
- }
- /**
- * Returns the SlideListWithText that deals with the
- * notes, or null if there isn't one
- */
- public SlideListWithText getNotesSlideListWithText() {
- for (SlideListWithText slwt : slwts) {
- if (slwt.getInstance() == SlideListWithText.NOTES) {
- return slwt;
- }
- }
- return null;
- }
-
-
- /**
- * Set things up, and find our more interesting children
- */
- /* package */ Document(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);
-
- // Our first one should be a document atom
- if(! (_children[0] instanceof DocumentAtom)) {
- throw new IllegalStateException("The first child of a Document must be a DocumentAtom");
- }
- documentAtom = (DocumentAtom)_children[0];
-
- // Find how many SlideListWithTexts we have
- // Also, grab the Environment and PPDrawing records
- // on our way past
- int slwtcount = 0;
- for(int i=1; i<_children.length; i++) {
- if(_children[i] instanceof SlideListWithText) {
- slwtcount++;
- }
- if(_children[i] instanceof Environment) {
- environment = (Environment)_children[i];
- }
- if(_children[i] instanceof PPDrawingGroup) {
- ppDrawing = (PPDrawingGroup)_children[i];
- }
- if(_children[i] instanceof ExObjList) {
- exObjList = (ExObjList)_children[i];
- }
- }
-
- // You should only every have 1, 2 or 3 SLWTs
- // (normally it's 2, or 3 if you have notes)
- // Complain if it's not
- if(slwtcount == 0) {
- LOG.atWarn().log("No SlideListWithText's found - there should normally be at least one!");
- }
- if(slwtcount > 3) {
- LOG.atWarn().log("Found {} SlideListWithTexts - normally there should only be three!", box(slwtcount));
- }
-
- // Now grab all the SLWTs
- slwts = new SlideListWithText[slwtcount];
- slwtcount = 0;
- for(int i=1; i<_children.length; i++) {
- if(_children[i] instanceof SlideListWithText) {
- slwts[slwtcount] = (SlideListWithText)_children[i];
- slwtcount++;
- }
- }
- }
-
- /**
- * Adds a new SlideListWithText record, at the appropriate
- * point in the child records.
- */
- public void addSlideListWithText(SlideListWithText slwt) {
- // The new SlideListWithText should go in
- // just before the EndDocumentRecord
- Record endDoc = _children[_children.length - 1];
- if(endDoc.getRecordType() == RecordTypes.RoundTripCustomTableStyles12.typeID) {
- // last record can optionally be a RoundTripCustomTableStyles12Atom
- endDoc = _children[_children.length - 2];
- }
- if(endDoc.getRecordType() != RecordTypes.EndDocument.typeID) {
- throw new IllegalStateException("The last child record of a Document should be EndDocument, but it was " + endDoc);
- }
-
- // Add in the record
- addChildBefore(slwt, endDoc);
-
- // Updated our cached list of SlideListWithText records
- int newSize = slwts.length + 1;
- SlideListWithText[] nl = new SlideListWithText[newSize];
- System.arraycopy(slwts, 0, nl, 0, slwts.length);
- nl[nl.length-1] = slwt;
- slwts = nl;
- }
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ /* package */ Document(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);
+
+ // Our first one should be a document atom
+ if(! (_children[0] instanceof DocumentAtom)) {
+ throw new IllegalStateException("The first child of a Document must be a DocumentAtom");
+ }
+ documentAtom = (DocumentAtom)_children[0];
+
+ // Find how many SlideListWithTexts we have
+ // Also, grab the Environment and PPDrawing records
+ // on our way past
+ int slwtcount = 0;
+ for(int i=1; i<_children.length; i++) {
+ if(_children[i] instanceof SlideListWithText) {
+ slwtcount++;
+ }
+ if(_children[i] instanceof Environment) {
+ environment = (Environment)_children[i];
+ }
+ if(_children[i] instanceof PPDrawingGroup) {
+ ppDrawing = (PPDrawingGroup)_children[i];
+ }
+ if(_children[i] instanceof ExObjList) {
+ exObjList = (ExObjList)_children[i];
+ }
+ }
+
+ // You should only every have 1, 2 or 3 SLWTs
+ // (normally it's 2, or 3 if you have notes)
+ // Complain if it's not
+ if(slwtcount == 0) {
+ LOG.atWarn().log("No SlideListWithText's found - there should normally be at least one!");
+ }
+ if(slwtcount > 3) {
+ LOG.atWarn().log("Found {} SlideListWithTexts - normally there should only be three!", box(slwtcount));
+ }
+
+ // Now grab all the SLWTs
+ slwts = new SlideListWithText[slwtcount];
+ slwtcount = 0;
+ for(int i=1; i<_children.length; i++) {
+ if(_children[i] instanceof SlideListWithText) {
+ slwts[slwtcount] = (SlideListWithText)_children[i];
+ slwtcount++;
+ }
+ }
+ }
+
+ /**
+ * Adds a new SlideListWithText record, at the appropriate
+ * point in the child records.
+ */
+ public void addSlideListWithText(SlideListWithText slwt) {
+ // The new SlideListWithText should go in
+ // just before the EndDocumentRecord
+ Record endDoc = _children[_children.length - 1];
+ if(endDoc.getRecordType() == RecordTypes.RoundTripCustomTableStyles12.typeID) {
+ // last record can optionally be a RoundTripCustomTableStyles12Atom
+ endDoc = _children[_children.length - 2];
+ }
+ if(endDoc.getRecordType() != RecordTypes.EndDocument.typeID) {
+ throw new IllegalStateException("The last child record of a Document should be EndDocument, but it was " + endDoc);
+ }
+
+ // Add in the record
+ addChildBefore(slwt, endDoc);
+
+ // Updated our cached list of SlideListWithText records
+ int newSize = slwts.length + 1;
+ SlideListWithText[] nl = new SlideListWithText[newSize];
+ System.arraycopy(slwts, 0, nl, 0, slwts.length);
+ nl[nl.length-1] = slwt;
+ slwts = nl;
+ }
public void removeSlideListWithText(SlideListWithText slwt) {
ArrayList<SlideListWithText> lst = new ArrayList<>();
@@ -214,16 +214,16 @@ public final class Document extends Posi
slwts = lst.toArray(new SlideListWithText[0]);
}
- /**
- * We are of type 1000
- */
- 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);
- }
+ /**
+ * We are of type 1000
+ */
+ 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/DocumentAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentAtom.java Sat May 22 21:37:08 2021
@@ -36,224 +36,224 @@ import org.apache.poi.util.Removal;
@SuppressWarnings({"WeakerAccess", "unused"})
public final class DocumentAtom extends RecordAtom {
- /**
- * Holds the different Slide Size values
- */
- public enum SlideSize {
- /** Slide size ratio is consistent with a computer screen. */
- ON_SCREEN,
- /** Slide size ratio is consistent with letter paper. */
- LETTER_SIZED_PAPER,
- /** Slide size ratio is consistent with A4 paper. */
- A4_SIZED_PAPER,
- /** Slide size ratio is consistent with 35mm photo slides. */
- ON_35MM,
- /** Slide size ratio is consistent with overhead projector slides. */
- OVERHEAD,
- /** Slide size ratio is consistent with a banner. */
- BANNER,
- /**
- * Slide size ratio that is not consistent with any of the other specified slide sizes in
- * this enumeration.
- */
- CUSTOM
- }
-
-
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
-
-
-
- private final byte[] _header = new byte[8];
- private static final long _type = RecordTypes.DocumentAtom.typeID;
-
- private long slideSizeX; // PointAtom, assume 1st 4 bytes = X
- private long slideSizeY; // PointAtom, assume 2nd 4 bytes = Y
- private long notesSizeX; // PointAtom, assume 1st 4 bytes = X
- private long notesSizeY; // PointAtom, assume 2nd 4 bytes = Y
- private long serverZoomFrom; // RatioAtom, assume 1st 4 bytes = from
- private long serverZoomTo; // RatioAtom, assume 2nd 4 bytes = to
-
- private final long notesMasterPersist; // ref to NotesMaster, 0 if none
- private final long handoutMasterPersist; // ref to HandoutMaster, 0 if none
-
- private final int firstSlideNum;
- private int slideSizeType; // see DocumentAtom.SlideSize
-
- private byte saveWithFonts;
- private final byte omitTitlePlace;
- private final byte rightToLeft;
- private final byte showComments;
-
- private final byte[] reserved;
-
-
- public long getSlideSizeX() { return slideSizeX; }
- public long getSlideSizeY() { return slideSizeY; }
- public long getNotesSizeX() { return notesSizeX; }
- public long getNotesSizeY() { return notesSizeY; }
- public void setSlideSizeX(long x) { slideSizeX = x; }
- public void setSlideSizeY(long y) { slideSizeY = y; }
- public void setNotesSizeX(long x) { notesSizeX = x; }
- public void setNotesSizeY(long y) { notesSizeY = y; }
-
- public long getServerZoomFrom() { return serverZoomFrom; }
- public long getServerZoomTo() { return serverZoomTo; }
- public void setServerZoomFrom(long zoom) { serverZoomFrom = zoom; }
- public void setServerZoomTo(long zoom) { serverZoomTo = zoom; }
-
- /** Returns a reference to the NotesMaster, or 0 if none */
- public long getNotesMasterPersist() { return notesMasterPersist; }
- /** Returns a reference to the HandoutMaster, or 0 if none */
- public long getHandoutMasterPersist() { return handoutMasterPersist; }
-
- public int getFirstSlideNum() { return firstSlideNum; }
-
- /**
- * The Size of the Document's slides, @see DocumentAtom.SlideSize for values
- * @deprecated to be replaced by enum
- */
- @Deprecated
- @Removal(version = "5.0.0")
- public int getSlideSizeType() { return slideSizeType; }
-
- public SlideSize getSlideSizeTypeEnum() {
- return SlideSize.values()[slideSizeType];
- }
-
- public void setSlideSize(SlideSize size) {
- slideSizeType = size.ordinal();
- }
-
- /** Was the document saved with True Type fonts embeded? */
- public boolean getSaveWithFonts() {
- return saveWithFonts != 0;
- }
-
- /** Set the font embedding state */
- public void setSaveWithFonts(boolean saveWithFonts) {
- this.saveWithFonts = (byte)(saveWithFonts ? 1 : 0);
- }
-
- /** Have the placeholders on the title slide been omitted? */
- public boolean getOmitTitlePlace() {
- return omitTitlePlace != 0;
- }
-
- /** Is this a Bi-Directional PPT Doc? */
- public boolean getRightToLeft() {
- return rightToLeft != 0;
- }
-
- /** Are comment shapes visible? */
- public boolean getShowComments() {
- return showComments != 0;
- }
-
-
- /* *************** record code follows ********************** */
-
- /**
- * For the Document Atom
- */
- /* package */ DocumentAtom(byte[] source, int start, int len) {
- final int maxLen = Math.max(len, 48);
- LittleEndianByteArrayInputStream leis =
- new LittleEndianByteArrayInputStream(source, start, maxLen);
-
- // Get the header
- leis.readFully(_header);
-
- // Get the sizes and zoom ratios
- slideSizeX = leis.readInt();
- slideSizeY = leis.readInt();
- notesSizeX = leis.readInt();
- notesSizeY = leis.readInt();
- serverZoomFrom = leis.readInt();
- serverZoomTo = leis.readInt();
-
- // Get the master persists
- notesMasterPersist = leis.readInt();
- handoutMasterPersist = leis.readInt();
-
- // Get the ID of the first slide
- firstSlideNum = leis.readShort();
-
- // Get the slide size type
- slideSizeType = leis.readShort();
-
- // Get the booleans as bytes
- saveWithFonts = leis.readByte();
- omitTitlePlace = leis.readByte();
- rightToLeft = leis.readByte();
- showComments = leis.readByte();
-
- // If there's any other bits of data, keep them about
- reserved = IOUtils.safelyAllocate(maxLen-48L, MAX_RECORD_LENGTH);
- leis.readFully(reserved);
- }
-
- /**
- * We are of type 1001
- */
- @Override
- public long getRecordType() { return _type; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- */
- @Override
- public void writeOut(OutputStream out) throws IOException {
- // Header
- out.write(_header);
-
- // The sizes and zoom ratios
- writeLittleEndian((int)slideSizeX,out);
- writeLittleEndian((int)slideSizeY,out);
- writeLittleEndian((int)notesSizeX,out);
- writeLittleEndian((int)notesSizeY,out);
- writeLittleEndian((int)serverZoomFrom,out);
- writeLittleEndian((int)serverZoomTo,out);
-
- // The master persists
- writeLittleEndian((int)notesMasterPersist,out);
- writeLittleEndian((int)handoutMasterPersist,out);
-
- // The ID of the first slide
- writeLittleEndian((short)firstSlideNum,out);
-
- // The slide size type
- writeLittleEndian((short)slideSizeType,out);
-
- // The booleans as bytes
- out.write(saveWithFonts);
- out.write(omitTitlePlace);
- out.write(rightToLeft);
- out.write(showComments);
-
- // Reserved data
- out.write(reserved);
- }
-
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- final Map<String, Supplier<?>> m = new LinkedHashMap<>();
- m.put("slideSizeX", this::getSlideSizeX);
- m.put("slideSizeY", this::getSlideSizeY);
- m.put("notesSizeX", this::getNotesSizeX);
- m.put("notesSizeY", this::getNotesSizeY);
- m.put("serverZoomFrom", this::getServerZoomFrom);
- m.put("serverZoomTo", this::getServerZoomTo);
- m.put("notesMasterPersist", this::getNotesMasterPersist);
- m.put("handoutMasterPersist", this::getHandoutMasterPersist);
- m.put("firstSlideNum", this::getFirstSlideNum);
- m.put("slideSize", this::getSlideSizeTypeEnum);
- m.put("saveWithFonts", this::getSaveWithFonts);
- m.put("omitTitlePlace", this::getOmitTitlePlace);
- m.put("rightToLeft", this::getRightToLeft);
- m.put("showComments", this::getShowComments);
- return Collections.unmodifiableMap(m);
- }
+ /**
+ * Holds the different Slide Size values
+ */
+ public enum SlideSize {
+ /** Slide size ratio is consistent with a computer screen. */
+ ON_SCREEN,
+ /** Slide size ratio is consistent with letter paper. */
+ LETTER_SIZED_PAPER,
+ /** Slide size ratio is consistent with A4 paper. */
+ A4_SIZED_PAPER,
+ /** Slide size ratio is consistent with 35mm photo slides. */
+ ON_35MM,
+ /** Slide size ratio is consistent with overhead projector slides. */
+ OVERHEAD,
+ /** Slide size ratio is consistent with a banner. */
+ BANNER,
+ /**
+ * Slide size ratio that is not consistent with any of the other specified slide sizes in
+ * this enumeration.
+ */
+ CUSTOM
+ }
+
+
+ //arbitrarily selected; may need to increase
+ private static final int MAX_RECORD_LENGTH = 1_000_000;
+
+
+
+ private final byte[] _header = new byte[8];
+ private static final long _type = RecordTypes.DocumentAtom.typeID;
+
+ private long slideSizeX; // PointAtom, assume 1st 4 bytes = X
+ private long slideSizeY; // PointAtom, assume 2nd 4 bytes = Y
+ private long notesSizeX; // PointAtom, assume 1st 4 bytes = X
+ private long notesSizeY; // PointAtom, assume 2nd 4 bytes = Y
+ private long serverZoomFrom; // RatioAtom, assume 1st 4 bytes = from
+ private long serverZoomTo; // RatioAtom, assume 2nd 4 bytes = to
+
+ private final long notesMasterPersist; // ref to NotesMaster, 0 if none
+ private final long handoutMasterPersist; // ref to HandoutMaster, 0 if none
+
+ private final int firstSlideNum;
+ private int slideSizeType; // see DocumentAtom.SlideSize
+
+ private byte saveWithFonts;
+ private final byte omitTitlePlace;
+ private final byte rightToLeft;
+ private final byte showComments;
+
+ private final byte[] reserved;
+
+
+ public long getSlideSizeX() { return slideSizeX; }
+ public long getSlideSizeY() { return slideSizeY; }
+ public long getNotesSizeX() { return notesSizeX; }
+ public long getNotesSizeY() { return notesSizeY; }
+ public void setSlideSizeX(long x) { slideSizeX = x; }
+ public void setSlideSizeY(long y) { slideSizeY = y; }
+ public void setNotesSizeX(long x) { notesSizeX = x; }
+ public void setNotesSizeY(long y) { notesSizeY = y; }
+
+ public long getServerZoomFrom() { return serverZoomFrom; }
+ public long getServerZoomTo() { return serverZoomTo; }
+ public void setServerZoomFrom(long zoom) { serverZoomFrom = zoom; }
+ public void setServerZoomTo(long zoom) { serverZoomTo = zoom; }
+
+ /** Returns a reference to the NotesMaster, or 0 if none */
+ public long getNotesMasterPersist() { return notesMasterPersist; }
+ /** Returns a reference to the HandoutMaster, or 0 if none */
+ public long getHandoutMasterPersist() { return handoutMasterPersist; }
+
+ public int getFirstSlideNum() { return firstSlideNum; }
+
+ /**
+ * The Size of the Document's slides, @see DocumentAtom.SlideSize for values
+ * @deprecated to be replaced by enum
+ */
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public int getSlideSizeType() { return slideSizeType; }
+
+ public SlideSize getSlideSizeTypeEnum() {
+ return SlideSize.values()[slideSizeType];
+ }
+
+ public void setSlideSize(SlideSize size) {
+ slideSizeType = size.ordinal();
+ }
+
+ /** Was the document saved with True Type fonts embeded? */
+ public boolean getSaveWithFonts() {
+ return saveWithFonts != 0;
+ }
+
+ /** Set the font embedding state */
+ public void setSaveWithFonts(boolean saveWithFonts) {
+ this.saveWithFonts = (byte)(saveWithFonts ? 1 : 0);
+ }
+
+ /** Have the placeholders on the title slide been omitted? */
+ public boolean getOmitTitlePlace() {
+ return omitTitlePlace != 0;
+ }
+
+ /** Is this a Bi-Directional PPT Doc? */
+ public boolean getRightToLeft() {
+ return rightToLeft != 0;
+ }
+
+ /** Are comment shapes visible? */
+ public boolean getShowComments() {
+ return showComments != 0;
+ }
+
+
+ /* *************** record code follows ********************** */
+
+ /**
+ * For the Document Atom
+ */
+ /* package */ DocumentAtom(byte[] source, int start, int len) {
+ final int maxLen = Math.max(len, 48);
+ LittleEndianByteArrayInputStream leis =
+ new LittleEndianByteArrayInputStream(source, start, maxLen);
+
+ // Get the header
+ leis.readFully(_header);
+
+ // Get the sizes and zoom ratios
+ slideSizeX = leis.readInt();
+ slideSizeY = leis.readInt();
+ notesSizeX = leis.readInt();
+ notesSizeY = leis.readInt();
+ serverZoomFrom = leis.readInt();
+ serverZoomTo = leis.readInt();
+
+ // Get the master persists
+ notesMasterPersist = leis.readInt();
+ handoutMasterPersist = leis.readInt();
+
+ // Get the ID of the first slide
+ firstSlideNum = leis.readShort();
+
+ // Get the slide size type
+ slideSizeType = leis.readShort();
+
+ // Get the booleans as bytes
+ saveWithFonts = leis.readByte();
+ omitTitlePlace = leis.readByte();
+ rightToLeft = leis.readByte();
+ showComments = leis.readByte();
+
+ // If there's any other bits of data, keep them about
+ reserved = IOUtils.safelyAllocate(maxLen-48L, MAX_RECORD_LENGTH);
+ leis.readFully(reserved);
+ }
+
+ /**
+ * We are of type 1001
+ */
+ @Override
+ public long getRecordType() { return _type; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ */
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
+ // Header
+ out.write(_header);
+
+ // The sizes and zoom ratios
+ writeLittleEndian((int)slideSizeX,out);
+ writeLittleEndian((int)slideSizeY,out);
+ writeLittleEndian((int)notesSizeX,out);
+ writeLittleEndian((int)notesSizeY,out);
+ writeLittleEndian((int)serverZoomFrom,out);
+ writeLittleEndian((int)serverZoomTo,out);
+
+ // The master persists
+ writeLittleEndian((int)notesMasterPersist,out);
+ writeLittleEndian((int)handoutMasterPersist,out);
+
+ // The ID of the first slide
+ writeLittleEndian((short)firstSlideNum,out);
+
+ // The slide size type
+ writeLittleEndian((short)slideSizeType,out);
+
+ // The booleans as bytes
+ out.write(saveWithFonts);
+ out.write(omitTitlePlace);
+ out.write(rightToLeft);
+ out.write(showComments);
+
+ // Reserved data
+ out.write(reserved);
+ }
+
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ final Map<String, Supplier<?>> m = new LinkedHashMap<>();
+ m.put("slideSizeX", this::getSlideSizeX);
+ m.put("slideSizeY", this::getSlideSizeY);
+ m.put("notesSizeX", this::getNotesSizeX);
+ m.put("notesSizeY", this::getNotesSizeY);
+ m.put("serverZoomFrom", this::getServerZoomFrom);
+ m.put("serverZoomTo", this::getServerZoomTo);
+ m.put("notesMasterPersist", this::getNotesMasterPersist);
+ m.put("handoutMasterPersist", this::getHandoutMasterPersist);
+ m.put("firstSlideNum", this::getFirstSlideNum);
+ m.put("slideSize", this::getSlideSizeTypeEnum);
+ m.put("saveWithFonts", this::getSaveWithFonts);
+ m.put("omitTitlePlace", this::getOmitTitlePlace);
+ m.put("rightToLeft", this::getRightToLeft);
+ m.put("showComments", this::getShowComments);
+ return Collections.unmodifiableMap(m);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentEncryptionAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentEncryptionAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentEncryptionAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DocumentEncryptionAtom.java Sat May 22 21:37:08 2021
@@ -42,101 +42,101 @@ import org.apache.poi.util.LittleEndianI
*/
public final class DocumentEncryptionAtom extends PositionDependentRecordAtom {
private static final long _type = RecordTypes.DocumentEncryptionAtom.typeID;
- private final byte[] _header;
- private EncryptionInfo ei;
+ private final byte[] _header;
+ private EncryptionInfo ei;
- /**
- * For the Document Encryption Atom
- */
- protected DocumentEncryptionAtom(byte[] source, int start, int len) {
- // Get the header
- _header = Arrays.copyOfRange(source,start,start+8);
-
- ByteArrayInputStream bis = new ByteArrayInputStream(source, start+8, len-8);
- try (LittleEndianInputStream leis = new LittleEndianInputStream(bis)) {
- ei = new EncryptionInfo(leis, EncryptionMode.cryptoAPI);
- } catch (IOException e) {
- throw new EncryptedDocumentException(e);
- }
- }
-
- public DocumentEncryptionAtom() {
- _header = new byte[8];
- LittleEndian.putShort(_header, 0, (short)0x000F);
- LittleEndian.putShort(_header, 2, (short)_type);
- // record length not yet known ...
-
- ei = new EncryptionInfo(EncryptionMode.cryptoAPI);
- }
-
- /**
- * Initializes the encryption settings
- *
- * @param keyBits see {@link CipherAlgorithm#rc4} for allowed values, use -1 for default size
- */
- public void initializeEncryptionInfo(int keyBits) {
- ei = new EncryptionInfo(EncryptionMode.cryptoAPI, CipherAlgorithm.rc4, HashAlgorithm.sha1, keyBits, -1, null);
- }
-
- /**
- * Return the length of the encryption key, in bits
- */
- public int getKeyLength() {
- return ei.getHeader().getKeySize();
- }
-
- /**
- * Return the name of the encryption provider used
- */
- public String getEncryptionProviderName() {
- return ei.getHeader().getCspName();
- }
-
- /**
- * @return the {@link EncryptionInfo} object for details about encryption settings
- */
- public EncryptionInfo getEncryptionInfo() {
- return ei;
- }
-
-
- /**
- * We are of type 12052
- */
- 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 {
+ /**
+ * For the Document Encryption Atom
+ */
+ protected DocumentEncryptionAtom(byte[] source, int start, int len) {
+ // Get the header
+ _header = Arrays.copyOfRange(source,start,start+8);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(source, start+8, len-8);
+ try (LittleEndianInputStream leis = new LittleEndianInputStream(bis)) {
+ ei = new EncryptionInfo(leis, EncryptionMode.cryptoAPI);
+ } catch (IOException e) {
+ throw new EncryptedDocumentException(e);
+ }
+ }
+
+ public DocumentEncryptionAtom() {
+ _header = new byte[8];
+ LittleEndian.putShort(_header, 0, (short)0x000F);
+ LittleEndian.putShort(_header, 2, (short)_type);
+ // record length not yet known ...
- // Data
+ ei = new EncryptionInfo(EncryptionMode.cryptoAPI);
+ }
+
+ /**
+ * Initializes the encryption settings
+ *
+ * @param keyBits see {@link CipherAlgorithm#rc4} for allowed values, use -1 for default size
+ */
+ public void initializeEncryptionInfo(int keyBits) {
+ ei = new EncryptionInfo(EncryptionMode.cryptoAPI, CipherAlgorithm.rc4, HashAlgorithm.sha1, keyBits, -1, null);
+ }
+
+ /**
+ * Return the length of the encryption key, in bits
+ */
+ public int getKeyLength() {
+ return ei.getHeader().getKeySize();
+ }
+
+ /**
+ * Return the name of the encryption provider used
+ */
+ public String getEncryptionProviderName() {
+ return ei.getHeader().getCspName();
+ }
+
+ /**
+ * @return the {@link EncryptionInfo} object for details about encryption settings
+ */
+ public EncryptionInfo getEncryptionInfo() {
+ return ei;
+ }
+
+
+ /**
+ * We are of type 12052
+ */
+ 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 {
+
+ // Data
byte[] data = new byte[1024];
- LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(data, 0);
- bos.writeShort(ei.getVersionMajor());
- bos.writeShort(ei.getVersionMinor());
- bos.writeInt(ei.getEncryptionFlags());
+ LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(data, 0);
+ bos.writeShort(ei.getVersionMajor());
+ bos.writeShort(ei.getVersionMinor());
+ bos.writeInt(ei.getEncryptionFlags());
- ((CryptoAPIEncryptionHeader)ei.getHeader()).write(bos);
- ((CryptoAPIEncryptionVerifier)ei.getVerifier()).write(bos);
+ ((CryptoAPIEncryptionHeader)ei.getHeader()).write(bos);
+ ((CryptoAPIEncryptionVerifier)ei.getVerifier()).write(bos);
// Header
- LittleEndian.putInt(_header, 4, bos.getWriteIndex());
+ LittleEndian.putInt(_header, 4, bos.getWriteIndex());
out.write(_header);
- out.write(data, 0, bos.getWriteIndex());
- bos.close();
- }
+ out.write(data, 0, bos.getWriteIndex());
+ bos.close();
+ }
@Override
public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
// nothing to update
}
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "encryptionInfo", this::getEncryptionInfo
- );
- }
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "encryptionInfo", this::getEncryptionInfo
+ );
+ }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyPositionSensitiveRecordWithChildren.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyPositionSensitiveRecordWithChildren.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyPositionSensitiveRecordWithChildren.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyPositionSensitiveRecordWithChildren.java Sat May 22 21:37:08 2021
@@ -35,32 +35,32 @@ import org.apache.poi.util.LittleEndian;
public final class DummyPositionSensitiveRecordWithChildren extends PositionDependentRecordContainer
{
- private byte[] _header;
- private long _type;
+ private byte[] _header;
+ private long _type;
- /**
- * Create a new holder for a boring record with children, but with
- * position dependent characteristics
- */
- protected DummyPositionSensitiveRecordWithChildren(byte[] source, int start, int len) {
- // Just grab the header, not the whole contents
- _header = Arrays.copyOfRange(source,start,start+8);
- _type = LittleEndian.getUShort(_header,2);
+ /**
+ * Create a new holder for a boring record with children, but with
+ * position dependent characteristics
+ */
+ protected DummyPositionSensitiveRecordWithChildren(byte[] source, int start, int len) {
+ // Just grab the header, not the whole contents
+ _header = Arrays.copyOfRange(source,start,start+8);
+ _type = LittleEndian.getUShort(_header,2);
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- }
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ }
- /**
- * Return the value we were given at creation
- */
- public long getRecordType() { return _type; }
+ /**
+ * Return the value we were given at creation
+ */
+ 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);
- }
+ /**
+ * 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/DummyRecordWithChildren.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyRecordWithChildren.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyRecordWithChildren.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/DummyRecordWithChildren.java Sat May 22 21:37:08 2021
@@ -31,31 +31,31 @@ import org.apache.poi.util.LittleEndian;
public final class DummyRecordWithChildren extends RecordContainer
{
- private byte[] _header;
- private long _type;
+ private byte[] _header;
+ private long _type;
- /**
- * Create a new holder for a boring record with children
- */
- protected DummyRecordWithChildren(byte[] source, int start, int len) {
- // Just grab the header, not the whole contents
- _header = Arrays.copyOfRange(source, start, start+8);
- _type = LittleEndian.getUShort(_header,2);
+ /**
+ * Create a new holder for a boring record with children
+ */
+ protected DummyRecordWithChildren(byte[] source, int start, int len) {
+ // Just grab the header, not the whole contents
+ _header = Arrays.copyOfRange(source, start, start+8);
+ _type = LittleEndian.getUShort(_header,2);
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- }
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ }
- /**
- * Return the value we were given at creation
- */
- public long getRecordType() { return _type; }
+ /**
+ * Return the value we were given at creation
+ */
+ 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);
- }
+ /**
+ * 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/Environment.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java Sat May 22 21:37:08 2021
@@ -27,58 +27,58 @@ import java.util.Arrays;
public final class Environment extends PositionDependentRecordContainer
{
- private byte[] _header;
- private static long _type = 1010;
+ private byte[] _header;
+ private static long _type = 1010;
- // Links to our more interesting children
- private FontCollection fontCollection;
+ // Links to our more interesting children
+ private FontCollection fontCollection;
//master style for text with type=TextHeaderAtom.OTHER_TYPE
private TxMasterStyleAtom txmaster;
- /**
- * Returns the FontCollection of this Environment
- */
- public FontCollection getFontCollection() { return fontCollection; }
-
-
- /**
- * Set things up, and find our more interesting children
- */
- protected Environment(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 our FontCollection record
- for(int i=0; i<_children.length; i++) {
- if(_children[i] instanceof FontCollection) {
- fontCollection = (FontCollection)_children[i];
- } else if (_children[i] instanceof TxMasterStyleAtom){
+ /**
+ * Returns the FontCollection of this Environment
+ */
+ public FontCollection getFontCollection() { return fontCollection; }
+
+
+ /**
+ * Set things up, and find our more interesting children
+ */
+ protected Environment(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 our FontCollection record
+ for(int i=0; i<_children.length; i++) {
+ if(_children[i] instanceof FontCollection) {
+ fontCollection = (FontCollection)_children[i];
+ } else if (_children[i] instanceof TxMasterStyleAtom){
txmaster = (TxMasterStyleAtom)_children[i];
}
- }
+ }
- if(fontCollection == null) {
- throw new IllegalStateException("Environment didn't contain a FontCollection record!");
- }
- }
+ if(fontCollection == null) {
+ throw new IllegalStateException("Environment didn't contain a FontCollection record!");
+ }
+ }
public TxMasterStyleAtom getTxMasterStyleAtom(){
return txmaster;
}
- /**
- * We are of type 1010
- */
- 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);
- }
+ /**
+ * We are of type 1010
+ */
+ 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);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org