From 637078aca359b07b8cd6d81e038aa0b24923223c Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 12 Mar 2006 19:18:59 +0000 Subject: [PATCH] Support for creating a new Comment2000 record git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@385355 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hslf/record/Comment2000.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java b/src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java index 27ae0aa7a..c7858253e 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java @@ -3,6 +3,8 @@ package org.apache.poi.hslf.record; import java.io.IOException; import java.io.OutputStream; +import org.apache.poi.util.LittleEndian; + /** * This class represents a comment on a slide, in the format used by * PPT 2000/XP/etc. (PPT 97 uses plain Escher Text Boxes for comments) @@ -72,7 +74,15 @@ public class Comment2000 extends RecordContainer { // 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 author if(_children[0] instanceof CString) { authorRecord = (CString)_children[0]; @@ -98,6 +108,31 @@ public class Comment2000 extends RecordContainer { throw new IllegalStateException("Fourth child record wasn't a Comment2000Atom, was of type " + _children[3].getRecordType()); } } + + /** + * Create a new Comment2000, with blank fields + */ + public Comment2000() { + _header = new byte[8]; + _children = new 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.setCount(0x00); + csb.setCount(0x10); + csc.setCount(0x20); + _children[0] = csa; + _children[1] = csb; + _children[2] = csc; + _children[3] = new Comment2000Atom(); + findInterestingChildren(); + } /** * We are of type 1200