]> source.dussan.org Git - poi.git/commitdiff
Support for creating a new Comment2000 record
authorNick Burch <nick@apache.org>
Sun, 12 Mar 2006 19:18:59 +0000 (19:18 +0000)
committerNick Burch <nick@apache.org>
Sun, 12 Mar 2006 19:18:59 +0000 (19:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@385355 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java

index 27ae0aa7a6c1f169a2a15d668f1eeb0a0f543daa..c7858253eba8dacbb69d17fcaac8d591165d2a20 100644 (file)
@@ -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