aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi/hdgf
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2007-06-27 18:34:17 +0000
committerNick Burch <nick@apache.org>2007-06-27 18:34:17 +0000
commit97fb171369ed0ee344790448071e276de874cee4 (patch)
tree06f7d8f7f93b8192038795bf30624f510c39f194 /src/scratchpad/testcases/org/apache/poi/hdgf
parent296705e0b6148b983c14adb412c1f70df7b6f902 (diff)
downloadpoi-97fb171369ed0ee344790448071e276de874cee4.tar.gz
poi-97fb171369ed0ee344790448071e276de874cee4.zip
Lots more HDGF support for chunks, and add support for basic text extraction
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@551258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi/hdgf')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
index c2d03f0c89..5ea21d1a1c 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
@@ -18,6 +18,7 @@ package org.apache.poi.hdgf.streams;
import java.io.FileInputStream;
+import org.apache.poi.hdgf.chunks.Chunk;
import org.apache.poi.hdgf.chunks.ChunkFactory;
import org.apache.poi.hdgf.pointers.Pointer;
import org.apache.poi.hdgf.pointers.PointerFactory;
@@ -202,4 +203,63 @@ public class TestStreamComplex extends StreamTest {
assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
}
+
+ public void testChunkWithText() throws Exception {
+ // Parent ChunkStream is at 0x7194
+ // This is one of the last children of the trailer
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+
+ ts.findChildren(contents);
+
+ assertNotNull(ts.getChildPointers());
+ assertNotNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(20, ts.getPointedToStreams().length);
+
+ assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
+ assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
+
+ PointerContainingStream ps7194 = (PointerContainingStream)
+ ts.getPointedToStreams()[13];
+
+ // First child is at 0x64b3
+ assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
+ assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
+
+ ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
+
+ // Should be 26bc bytes un-compressed
+ assertEquals(0x26bc, cs.getStore().getContents().length);
+ // And should have lots of children
+ assertEquals(131, cs.getChunks().length);
+
+ // One of which is Text
+ boolean hasText = false;
+ for(int i=0; i<cs.getChunks().length; i++) {
+ if(cs.getChunks()[i].getName().equals("Text")) {
+ hasText = true;
+ }
+ }
+ assertTrue(hasText);
+ // Which is the 72nd command
+ assertEquals("Text", cs.getChunks()[72].getName());
+
+ Chunk text = cs.getChunks()[72];
+ assertEquals("Text", text.getName());
+
+ // Which contains our text
+ assertEquals(1, text.getCommands().length);
+ assertEquals("Test View\n", text.getCommands()[0].getValue());
+
+
+ // Almost at the end is some more text
+ assertEquals("Text", cs.getChunks()[128].getName());
+ text = cs.getChunks()[128];
+ assertEquals("Text", text.getName());
+
+ assertEquals(1, text.getCommands().length);
+ assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
+ }
}