From 452efd8c3c3bb6a799d6ace72a01f74f2c88049f Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 6 Feb 2006 09:25:48 +0000 Subject: [PATCH] Record level support for PPT 2000/XP comments (but not yet comment summaries or details) git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@375233 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hslf/record/TestComment2000.java | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java new file mode 100644 index 0000000000..401f3db257 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java @@ -0,0 +1,148 @@ + +/* ==================================================================== + Copyright 2002-2004 Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + + + +package org.apache.poi.hslf.record; + + +import junit.framework.TestCase; +import java.io.ByteArrayOutputStream; + +/** + * Tests that Comment2000 works properly. + * TODO: Test Comment200Atom within + * + * @author Nick Burch (nick at torchbox dot com) + */ +public class TestComment2000 extends TestCase { + // From a real file + private byte[] data_a = new byte[] { + 0x0F, 00, 0xE0-256, 0x2E, 0x9C-256, 00, 00, 00, + 00, 00, 0xBA-256, 0x0F, 0x14, 00, 00, 00, + 0x44, 00, 0x75, 00, 0x6D, 00, 0x62, 00, + 0x6C, 00, 0x65, 00, 0x64, 00, 0x6F, 00, + 0x72, 00, 0x65, 00, + 0x10, 00, 0xBA-256, 0x0F, 0x4A, 00, 00, 00, + 0x59, 00, 0x65, 00, 0x73, 00, 0x2C, 00, + 0x20, 00, 0x74, 00, 0x68, 00, 0x65, 00, + 0x79, 00, 0x20, 00, 0x63, 00, 0x65, 00, + 0x72, 00, 0x74, 00, 0x61, 00, 0x69, 00, + 0x6E, 00, 0x6C, 00, 0x79, 00, 0x20, 00, + 0x61, 00, 0x72, 00, 0x65, 00, 0x2C, 00, + 0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00, + 0x6E, 00, 0x27, 00, 0x74, 00, 0x20, 00, + 0x74, 00, 0x68, 00, 0x65, 00, 0x79, 00, 0x21, 00, + 0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00, + 0x44, 00, + 00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00, + 01, 00, 00, 00, 0xD6-256, 07, 01, 00, + 02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00, + 0x0F, 00, 0xCD-256, 00, 0x92-256, 00, + 00, 00, 0x92-256, 00, 00, 00 + }; + private byte[] data_b = new byte[] { + 0x0F, 00, 0xE0-256, 0x2E, 0xAC-256, 00, 00, 00, + 00, 00, 0xBA-256, 0x0F, 0x10, 00, 00, 00, + 0x48, 00, 0x6F, 00, 0x67, 00, 0x77, 00, + 0x61, 00, 0x72, 00, 0x74, 00, 0x73, 00, + 0x10, 00, 0xBA-256, 0x0F, 0x5E, 00, 00, 00, + 0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00, + 0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00, + 0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00, + 0x20, 00, 0x66, 00, 0x75, 00, 0x6E, 00, + 0x20, 00, 0x74, 00, 0x68, 00, 0x69, 00, + 0x6E, 00, 0x67, 00, 0x73, 00, 0x20, 00, + 0x74, 00, 0x6F, 00, 0x20, 00, 0x61, 00, + 0x64, 00, 0x64, 00, 0x20, 00, 0x69, 00, + 0x6E, 00, 0x2C, 00, 0x20, 00, 0x61, 00, + 0x72, 00, 0x65, 00, 0x6E, 00, 0x27, 00, + 0x74, 00, 0x20, 00, 0x74, 00, 0x68, 00, + 0x65, 00, 0x79, 00, 0x3F, 00, + 0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00, + 0x48, 00, + 00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00, + 01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, + 02, 00, 0x18, 00, 0x0A, 00, 0x19, 00, 03, + 00, 0xD5-256, 02, 0x0A, 00, 00, 00, + 0x0A, 00, 00, 00 + }; + + public void testRecordType() throws Exception { + Comment2000 ca = new Comment2000(data_a, 0, data_a.length); + assertEquals(12000l, ca.getRecordType()); + } + public void testAuthor() throws Exception { + Comment2000 ca = new Comment2000(data_a, 0, data_a.length); + assertEquals("Dumbledore", ca.getAuthor()); + assertEquals("D", ca.getAuthorInitials()); + } + public void testText() throws Exception { + Comment2000 ca = new Comment2000(data_a, 0, data_a.length); + assertEquals("Yes, they certainly are, aren't they!", ca.getText()); + } + + public void testWrite() throws Exception { + Comment2000 ca = new Comment2000(data_a, 0, data_a.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ca.writeOut(baos); + byte[] b = baos.toByteArray(); + + assertEquals(data_a.length, b.length); + for(int i=0; i