You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 20:15:01 UTC
svn commit: r777204 [4/21] - in /poi/trunk/src/scratchpad:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/
src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/
src/org/apach...
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/PointerContainingStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/PointerContainingStream.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/PointerContainingStream.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/PointerContainingStream.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -25,35 +26,35 @@
* A stream that holds pointers, possibly in addition to some
* other data too.
*/
-public class PointerContainingStream extends Stream {
+public class PointerContainingStream extends Stream { // TODO - instantiable superclass
private Pointer[] childPointers;
private Stream[] childStreams;
-
+
private ChunkFactory chunkFactory;
private PointerFactory pointerFactory;
private int numPointersLocalOffset;
-
+
protected PointerContainingStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory) {
super(pointer, store);
this.chunkFactory = chunkFactory;
this.pointerFactory = pointerFactory;
-
+
// Find the offset to the number of child pointers we have
// This ought to be the first thing stored in us
numPointersLocalOffset = (int)LittleEndian.getUInt(
store.getContents(), 0
);
-
+
// Generate the objects for the pointers we contain
int numPointers = (int)LittleEndian.getUInt(
store.getContents(), numPointersLocalOffset
);
childPointers = new Pointer[numPointers];
-
+
// After the number of pointers is another (unknown)
// 4 byte value
int pos = numPointersLocalOffset + 4 + 4;
-
+
// Now create the pointer objects
for(int i=0; i<numPointers; i++) {
childPointers[i] = pointerFactory.createPointer(
@@ -62,7 +63,7 @@
pos += childPointers[i].getSizeInBytes();
}
}
-
+
/**
* Returns all the pointers that we contain
*/
@@ -72,8 +73,8 @@
* These are all the streams pointed to by the pointers
* that we contain.
*/
- public Stream[] getPointedToStreams() { return childStreams; }
-
+ public Stream[] getPointedToStreams() { return childStreams; }
+
/**
* Performs a recursive search, identifying the pointers we contain,
* creating the Streams for where they point to, then searching
@@ -85,16 +86,16 @@
for(int i=0; i<childPointers.length; i++) {
Pointer ptr = childPointers[i];
childStreams[i] = Stream.createStream(ptr, documentData, chunkFactory, pointerFactory);
-
+
// Process chunk streams into their chunks
if(childStreams[i] instanceof ChunkStream) {
ChunkStream child = (ChunkStream)childStreams[i];
child.findChunks();
}
-
+
// Recurse into pointer containing streams
if(childStreams[i] instanceof PointerContainingStream) {
- PointerContainingStream child =
+ PointerContainingStream child =
(PointerContainingStream)childStreams[i];
child.findChildren(documentData);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import java.io.IOException;
@@ -33,21 +34,21 @@
public abstract class Stream {
private Pointer pointer;
private StreamStore store;
-
+
public Pointer getPointer() { return pointer; }
protected StreamStore getStore() { return store; }
public StreamStore _getStore() { return store; }
public int _getContentsLength() { return store.getContents().length; }
-
+
/**
* Creates a new Stream, having already used the pointer
- * to build a store
+ * to build a store
*/
protected Stream(Pointer pointer, StreamStore store) {
this.pointer = pointer;
this.store = store;
}
-
+
/**
* Uses the pointer to locate a Stream within the document
* data, and creates it.
@@ -71,7 +72,7 @@
documentData, pointer.getOffset(), pointer.getLength()
);
}
-
+
// Figure out what sort of Stream to create, create and return it
if(pointer.getType() == 20) {
return new TrailerStream(pointer, store, chunkFactory, pointerFactory);
@@ -80,12 +81,12 @@
return new PointerContainingStream(pointer, store, chunkFactory, pointerFactory);
}
else if(pointer.destinationHasChunks()) {
- return new ChunkStream(pointer, store, chunkFactory);
+ return new ChunkStream(pointer, store, chunkFactory);
}
else if(pointer.destinationHasStrings()) {
return new StringsStream(pointer, store, chunkFactory);
}
-
+
// Give up and return a generic one
return new UnknownStream(pointer, store);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
/**
@@ -21,9 +22,9 @@
* handles de-compressing it as required.
* In future, may also handle writing it back out again
*/
-public class StreamStore {
+public class StreamStore { // TODO - instantiable superclass
private byte[] contents;
-
+
/**
* Creates a new, non compressed Stream Store
*/
@@ -31,7 +32,7 @@
contents = new byte[length];
System.arraycopy(data, offset, contents, 0, length);
}
-
+
protected void prependContentsWith(byte[] b) {
byte[] newContents = new byte[contents.length + b.length];
System.arraycopy(b, 0, newContents, 0, b.length);
@@ -39,7 +40,7 @@
contents = newContents;
}
protected void copyBlockHeaderToContents() {}
-
+
protected byte[] getContents() { return contents; }
public byte[] _getContents() { return contents; }
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StringsStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StringsStream.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StringsStream.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/StringsStream.java Thu May 21 18:12:22 2009
@@ -1,19 +1,20 @@
/* ====================================================================
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+ 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.
+ 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.hdgf.streams;
import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -23,7 +24,7 @@
* A Stream which holds Strings. This is just another kind
* of ChunkStream, it seems
*/
-public class StringsStream extends Stream {
+public final class StringsStream extends Stream {
protected StringsStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory) {
super(pointer, store);
// super(pointer, store, chunkFactory);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/TrailerStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/TrailerStream.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/TrailerStream.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/TrailerStream.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -26,7 +27,7 @@
* These is one of these in each document, and it's pointed to by
* a special series of byte near the start of the file.
*/
-public class TrailerStream extends PointerContainingStream {
+public class TrailerStream extends PointerContainingStream { // TODO - instantiable superclass
protected TrailerStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory) {
super(pointer, store, chunkFactory, pointerFactory);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/UnknownStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/UnknownStream.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/UnknownStream.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/streams/UnknownStream.java Thu May 21 18:12:22 2009
@@ -14,15 +14,16 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import org.apache.poi.hdgf.pointers.Pointer;
/**
- * A placeholder for a stream where we don't known anything
+ * A placeholder for a stream where we don't known anything
* about how to process / handle it
*/
-public class UnknownStream extends Stream {
+public final class UnknownStream extends Stream {
protected UnknownStream(Pointer pointer, StreamStore store) {
super(pointer, store);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java Thu May 21 18:12:22 2009
@@ -30,16 +30,16 @@
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/**
- * This class provides the basic functionality
+ * This class provides the basic functionality
* for HPBF, our implementation of the publisher
- * file format.
+ * file format.
*/
public final class HPBFDocument extends POIDocument {
private MainContents mainContents;
private QuillContents quillContents;
private EscherStm escherStm;
private EscherDelayStm escherDelayStm;
-
+
/**
* Opens a new publisher document
*/
@@ -49,19 +49,19 @@
public HPBFDocument(InputStream inp) throws IOException {
this(new POIFSFileSystem(inp));
}
-
+
/**
* Opens an embeded publisher document,
* at the given directory.
*/
public HPBFDocument(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
super(dir, fs);
-
+
// Go looking for our interesting child
// streams
mainContents = new MainContents(dir);
quillContents = new QuillContents(dir);
-
+
// Now the Escher bits
escherStm = new EscherStm(dir);
escherDelayStm = new EscherDelayStm(dir);
@@ -79,7 +79,7 @@
public EscherDelayStm getEscherDelayStm() {
return escherDelayStm;
}
-
+
public void write(OutputStream out) throws IOException {
throw new IllegalStateException("Writing is not yet implemented, see http://poi.apache.org/hpbf/");
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.dev;
import java.io.FileInputStream;
@@ -33,7 +34,7 @@
* files, while we try to figure out how they're
* constructed.
*/
-public class HPBFDumper {
+public final class HPBFDumper {
private POIFSFileSystem fs;
public HPBFDumper(POIFSFileSystem fs) {
this.fs = fs;
@@ -41,7 +42,7 @@
public HPBFDumper(InputStream inp) throws IOException {
this(new POIFSFileSystem(inp));
}
-
+
private static byte[] getData(DirectoryNode dir, String name) throws IOException {
DocumentEntry docProps =
(DocumentEntry)dir.getEntry(name);
@@ -49,11 +50,11 @@
// Grab the document stream
byte[] d = new byte[docProps.getSize()];
dir.createDocumentInputStream(name).read(d);
-
+
// All done
return d;
}
-
+
/**
* Dumps out the given number of bytes as hex,
* two chars
@@ -64,7 +65,7 @@
int j = i + offset;
int b = data[j];
if(b < 0) { b += 256; }
-
+
String bs = Integer.toHexString(b);
if(bs.length() == 1)
ret.append('0');
@@ -73,7 +74,7 @@
}
return ret.toString();
}
-
+
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Use:");
@@ -83,41 +84,41 @@
HPBFDumper dump = new HPBFDumper(
new FileInputStream(args[0])
);
-
+
System.out.println("Dumping " + args[0]);
dump.dumpContents();
dump.dumpEnvelope();
dump.dumpEscher();
dump.dump001CompObj(dump.fs.getRoot());
dump.dumpQuill();
-
+
// Still to go:
// (0x03)Internal
// Objects
}
-
+
/**
* Dump out the escher parts of the file.
* Escher -> EscherStm and EscherDelayStm
*/
public void dumpEscher() throws IOException {
- DirectoryNode escherDir = (DirectoryNode)
+ DirectoryNode escherDir = (DirectoryNode)
fs.getRoot().getEntry("Escher");
-
+
dumpEscherStm(escherDir);
dumpEscherDelayStm(escherDir);
}
private void dumpEscherStream(byte[] data) {
- DefaultEscherRecordFactory erf =
+ DefaultEscherRecordFactory erf =
new DefaultEscherRecordFactory();
-
+
// Dump
int left = data.length;
while(left > 0) {
EscherRecord er = erf.createRecord(data, 0);
er.fillFields(data, 0, erf);
left -= er.getRecordSize();
-
+
System.out.println(er.toString());
}
}
@@ -135,52 +136,52 @@
if(data.length > 0)
dumpEscherStream(data);
}
-
+
public void dumpEnvelope() throws IOException {
byte[] data = getData(fs.getRoot(), "Envelope");
-
+
System.out.println("");
System.out.println("Envelope - " + data.length + " bytes long:");
}
-
+
public void dumpContents() throws IOException {
byte[] data = getData(fs.getRoot(), "Contents");
-
+
System.out.println("");
System.out.println("Contents - " + data.length + " bytes long:");
-
+
// 8 bytes, always seems to be
- // E8 AC 2C 00 E8 03 05 01
- // E8 AC 2C 00 E8 03 05 01
-
+ // E8 AC 2C 00 E8 03 05 01
+ // E8 AC 2C 00 E8 03 05 01
+
// 4 bytes - size of contents
// 13/15 00 00 01
-
+
// ....
-
+
// E8 03 08 08 0C 20 03 00 00 00 00 88 16 00 00 00 ..... ..........
-
+
// 01 18 27 00 03 20 00 00 E8 03 08 08 0C 20 03 00 ..'.. ....... ..
-
- // 01 18 30 00 03 20 00 00
+
+ // 01 18 30 00 03 20 00 00
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
// 00 00 00 88 1E 00 00 00
-
+
// 01 18 31 00 03 20 00 00
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
// 00 00 00 88 1E 00 00 00
-
+
// 01 18 32 00 03 20 00 00
// E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
// 00 00 00 88 1E 00 00 00
}
-
+
public void dumpCONTENTSraw(DirectoryNode dir) throws IOException {
byte[] data = getData(dir, "CONTENTS");
-
+
System.out.println("");
System.out.println("CONTENTS - " + data.length + " bytes long:");
-
+
// Between the start and 0x200 we have
// CHNKINK(space) + 24 bytes
// 0x1800
@@ -194,7 +195,7 @@
// STSH + 8 bytes
// but towards 0x200 the pattern may
// break down a little bit
-
+
// After the second of a given type,
// it seems to be 4 bytes giving the start,
// then 4 bytes giving the length, then
@@ -203,7 +204,7 @@
new String(data, 0, 8) +
dumpBytes(data, 8, 0x20-8)
);
-
+
int pos = 0x20;
boolean sixNotEight = true;
while(pos < 0x200) {
@@ -220,11 +221,11 @@
System.out.println(
text + " " + dumpBytes(data, pos+4, blen)
);
-
+
pos += 4 + blen;
sixNotEight = ! sixNotEight;
}
-
+
// Text from 0x200 onwards until we get
// to \r(00)\n(00)(00)(00)
int textStop = -1;
@@ -240,18 +241,18 @@
StringUtil.getFromUnicodeLE(data, 0x200, len)
);
}
-
+
// The font list comes slightly later
-
+
// The hyperlinks may come before the fonts,
// or slightly in front
}
public void dumpCONTENTSguessed(DirectoryNode dir) throws IOException {
byte[] data = getData(dir, "CONTENTS");
-
+
System.out.println("");
System.out.println("CONTENTS - " + data.length + " bytes long:");
-
+
String[] startType = new String[20];
String[] endType = new String[20];
int[] optA = new int[20];
@@ -259,7 +260,7 @@
int[] optC = new int[20];
int[] from = new int[20];
int[] len = new int[20];
-
+
for(int i=0; i<20; i++) {
int offset = 0x20 + i*24;
if(data[offset] == 0x18 && data[offset+1] == 0x00) {
@@ -275,11 +276,11 @@
// Doesn't have data
}
}
-
+
String text = StringUtil.getFromUnicodeLE(
data, from[0], len[0]/2
);
-
+
// Dump
for(int i=0; i<20; i++) {
String num = Integer.toString(i);
@@ -287,14 +288,14 @@
num = "0" + i;
}
System.out.print(num + " ");
-
+
if(startType[i] == null) {
System.out.println("(not present)");
} else {
System.out.println(
"\t" +
- startType[i] + " " +
- optA[i] + " " +
+ startType[i] + " " +
+ optA[i] + " " +
optB[i] + " " +
optC[i]
);
@@ -303,30 +304,30 @@
endType[i] + " " +
"from: " +
Integer.toHexString(from[i]) +
- " (" + from[i] + ")" +
+ " (" + from[i] + ")" +
", len: " +
Integer.toHexString(len[i]) +
" (" + len[i] + ")"
);
}
}
-
+
// Text
System.out.println("");
System.out.println("TEXT:");
System.out.println(text);
System.out.println("");
-
+
// All the others
for(int i=0; i<20; i++) {
if(startType[i] == null) {
continue;
}
int start = from[i];
-
+
System.out.println(
startType[i] + " -> " + endType[i] +
- " @ " + Integer.toHexString(start) +
+ " @ " + Integer.toHexString(start) +
" (" + start + ")"
);
System.out.println("\t" + dumpBytes(data, start, 4));
@@ -335,15 +336,15 @@
System.out.println("\t(etc)");
}
}
-
+
protected void dump001CompObj(DirectoryNode dir) {
// TODO
}
-
+
public void dumpQuill() throws IOException {
- DirectoryNode quillDir = (DirectoryNode)
+ DirectoryNode quillDir = (DirectoryNode)
fs.getRoot().getEntry("Quill");
- DirectoryNode quillSubDir = (DirectoryNode)
+ DirectoryNode quillSubDir = (DirectoryNode)
quillDir.getEntry("QuillSub");
dump001CompObj(quillSubDir);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/PLCDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/PLCDumper.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/PLCDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/PLCDumper.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.dev;
import java.io.FileInputStream;
@@ -31,10 +32,10 @@
* HPBF (Publisher) file, while we try to figure out
* what the format of them is.
*/
-public class PLCDumper {
+public final class PLCDumper {
private HPBFDocument doc;
private QuillContents qc;
-
+
public PLCDumper(HPBFDocument hpbfDoc) {
doc = hpbfDoc;
qc = doc.getQuillContents();
@@ -45,7 +46,7 @@
public PLCDumper(InputStream inp) throws IOException {
this(new POIFSFileSystem(inp));
}
-
+
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Use:");
@@ -55,14 +56,14 @@
PLCDumper dump = new PLCDumper(
new FileInputStream(args[0])
);
-
+
System.out.println("Dumping " + args[0]);
dump.dumpPLC();
}
-
- private void dumpPLC() {
+
+ private void dumpPLC() {
QCBit[] bits = qc.getBits();
-
+
for(int i=0; i<bits.length; i++) {
if(bits[i] == null) continue;
if(bits[i].getBitType().equals("PLC ")) {
@@ -70,14 +71,14 @@
}
}
}
-
+
private void dumpBit(QCBit bit, int index) {
System.out.println("");
System.out.println("Dumping " + bit.getBitType() + " bit at " + index);
System.out.println(" Is a " + bit.getThingType() + ", number is " + bit.getOptA());
System.out.println(" Starts at " + bit.getDataOffset() + " (0x" + Integer.toHexString(bit.getDataOffset()) + ")");
System.out.println(" Runs for " + bit.getLength() + " (0x" + Integer.toHexString(bit.getLength()) + ")");
-
+
System.out.println(HexDump.dump(bit.getData(), 0, 0));
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/extractor/PublisherTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/extractor/PublisherTextExtractor.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/extractor/PublisherTextExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/extractor/PublisherTextExtractor.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.extractor;
import java.io.FileInputStream;
@@ -28,12 +29,12 @@
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/**
- * Extract text from HPBF Publisher files
+ * Extract text from HPBF Publisher files
*/
-public class PublisherTextExtractor extends POIOLE2TextExtractor {
+public final class PublisherTextExtractor extends POIOLE2TextExtractor {
private HPBFDocument doc;
private boolean hyperlinksByDefault = false;
-
+
public PublisherTextExtractor(HPBFDocument doc) {
super(doc);
this.doc = doc;
@@ -44,7 +45,7 @@
public PublisherTextExtractor(InputStream is) throws IOException {
this(new POIFSFileSystem(is));
}
-
+
/**
* Should a call to getText() return hyperlinks inline
* with the text?
@@ -54,10 +55,10 @@
this.hyperlinksByDefault = hyperlinksByDefault;
}
-
+
public String getText() {
StringBuffer text = new StringBuffer();
-
+
// Get the text from the Quill Contents
QCBit[] bits = doc.getQuillContents().getBits();
for(int i=0; i<bits.length; i++) {
@@ -66,7 +67,7 @@
text.append( t.getText().replace('\r', '\n') );
}
}
-
+
// If requested, add in the hyperlinks
// Ideally, we'd do these inline, but the hyperlink
// positions are relative to the text area the
@@ -84,20 +85,20 @@
}
}
}
-
+
// Get more text
// TODO
-
+
return text.toString();
}
-
-
+
+
public static void main(String[] args) throws Exception {
if(args.length == 0) {
System.err.println("Use:");
System.err.println(" PublisherTextExtractor <file.pub>");
}
-
+
for(int i=0; i<args.length; i++) {
PublisherTextExtractor te = new PublisherTextExtractor(
new FileInputStream(args[i])
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java Thu May 21 18:12:22 2009
@@ -20,7 +20,9 @@
import java.io.IOException;
import org.apache.poi.poifs.filesystem.DirectoryNode;
-
+/**
+ *
+ */
public final class EscherDelayStm extends EscherPart {
private static final String[] PATH = { "Escher", "EscherDelayStm", };
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java Thu May 21 18:12:22 2009
@@ -29,36 +29,36 @@
*/
public abstract class EscherPart extends HPBFPart {
private EscherRecord[] records;
-
+
/**
* Creates the Escher Part, and finds our child
* escher records
*/
public EscherPart(DirectoryNode baseDir, String[] parts) throws IOException {
super(baseDir, parts);
-
+
// Now create our Escher children
- DefaultEscherRecordFactory erf =
+ DefaultEscherRecordFactory erf =
new DefaultEscherRecordFactory();
-
+
ArrayList ec = new ArrayList();
int left = data.length;
while(left > 0) {
EscherRecord er = erf.createRecord(data, 0);
er.fillFields(data, 0, erf);
left -= er.getRecordSize();
-
+
ec.add(er);
}
-
+
records = (EscherRecord[])
ec.toArray(new EscherRecord[ec.size()]);
}
-
+
public EscherRecord[] getEscherRecords() {
return records;
}
-
+
/**
* Serialises our Escher children back
* into bytes.
@@ -66,13 +66,13 @@
protected void generateData() {
int size = 0;
for(int i=0; i<records.length; i++) {
- size += records[i].getRecordSize();
+ size += records[i].getRecordSize();
}
-
+
data = new byte[size];
size = 0;
for(int i=0; i<records.length; i++) {
- int thisSize =
+ int thisSize =
records[i].serialize(size, data);
size += thisSize;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java Thu May 21 18:12:22 2009
@@ -20,7 +20,9 @@
import java.io.IOException;
import org.apache.poi.poifs.filesystem.DirectoryNode;
-
+/**
+ *
+ */
public final class EscherStm extends EscherPart {
private static final String[] PATH = { "Escher", "EscherStm", };
public EscherStm(DirectoryNode baseDir) throws IOException {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model;
import java.io.ByteArrayInputStream;
@@ -34,15 +35,15 @@
* @param path the path to the part, eg Contents or Quill, QuillSub, CONTENTS
*/
public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
-
+
DirectoryNode dir = getDir(path, baseDir);
String name = path[path.length-1];
-
+
DocumentEntry docProps;
try {
docProps = (DocumentEntry)dir.getEntry(name);
} catch (FileNotFoundException e) {
- throw new IllegalArgumentException("File invalid - failed to find document entry '"
+ throw new IllegalArgumentException("File invalid - failed to find document entry '"
+ name + "'");
}
@@ -56,16 +57,16 @@
try {
dir = (DirectoryNode)dir.getEntry(path[i]);
} catch (FileNotFoundException e) {
- throw new IllegalArgumentException("File invalid - failed to find directory entry '"
+ throw new IllegalArgumentException("File invalid - failed to find directory entry '"
+ path[i] + "'");
}
}
return dir;
}
-
+
public void writeOut(DirectoryNode baseDir) throws IOException {
String[] path = getPath();
-
+
// Ensure that all parent directories exist
DirectoryNode dir = baseDir;
for(int i=0; i<path.length-1; i++) {
@@ -75,22 +76,22 @@
dir.createDirectory(path[i]);
}
}
-
+
// Update the byte array with the latest data
generateData();
-
+
// Write out
ByteArrayInputStream bais = new ByteArrayInputStream(data);
dir.createDocument(path[path.length-1], bais);
}
-
+
/**
* Called just before writing out, to trigger
* the data byte array to be updated with the
* latest contents.
*/
protected abstract void generateData();
-
+
/**
* Returns the raw data that makes up
* this document part.
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java Thu May 21 18:12:22 2009
@@ -26,7 +26,7 @@
*/
public final class MainContents extends HPBFPart {
private static final String[] PATH = { "Contents", };
-
+
public MainContents(DirectoryNode baseDir) throws IOException {
super(baseDir, PATH);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model;
import java.io.IOException;
@@ -31,20 +32,20 @@
public final class QuillContents extends HPBFPart {
private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
private QCBit[] bits;
-
+
public QuillContents(DirectoryNode baseDir) throws IOException {
super(baseDir, PATH);
-
+
// Now parse the first 512 bytes, and produce
// all our bits
-
+
// Check first 8 bytes
String f8 = new String(data, 0, 8);
if(! f8.equals("CHNKINK ")) {
throw new IllegalArgumentException("Expecting 'CHNKINK ' but was '"+f8+"'");
}
// Ignore the next 24, for now at least
-
+
// Now, parse all our QC Bits
bits = new QCBit[20];
for(int i=0; i<20; i++) {
@@ -58,10 +59,10 @@
String bitType = new String(data, offset+12, 4);
int from = (int)LittleEndian.getUInt(data, offset+16);
int len = (int)LittleEndian.getUInt(data, offset+20);
-
+
byte[] bitData = new byte[len];
System.arraycopy(data, from, bitData, 0, len);
-
+
// Create
if(bitType.equals("TEXT")) {
bits[i] = new QCTextBit(thingType, bitType, bitData);
@@ -83,7 +84,7 @@
public QCBit[] getBits() {
return bits;
}
-
+
protected void generateData() {
// TODO
throw new IllegalStateException("Not done yet!");
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCBit.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCBit.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCBit.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCBit.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model.qcbits;
/**
@@ -23,19 +24,19 @@
protected String thingType;
protected String bitType;
protected byte[] data;
-
+
protected int optA;
protected int optB;
protected int optC;
-
+
protected int dataOffset;
-
+
public QCBit(String thingType, String bitType, byte[] data) {
this.thingType = thingType;
this.bitType = bitType;
this.data = data;
}
-
+
/**
* Returns the type of the thing, eg TEXT, FONT
* or TOKN
@@ -75,7 +76,7 @@
public void setDataOffset(int offset) {
this.dataOffset = offset;
}
-
+
public int getLength() {
return data.length;
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model.qcbits;
import org.apache.poi.util.LittleEndian;
@@ -24,12 +25,12 @@
* A "PLC " (PLC) based bit of Quill Contents. The exact
* format is determined by the type of the PLCs.
*/
-public class QCPLCBit extends QCBit {
+public abstract class QCPLCBit extends QCBit {
protected int numberOfPLCs;
protected int typeOfPLCS;
- /**
+ /**
* The data which goes before the main PLC entries.
- * This is apparently always made up of 2 byte
+ * This is apparently always made up of 2 byte
* un-signed ints..
*/
protected int[] preData;
@@ -37,24 +38,24 @@
protected long[] plcValA;
/** The second value of each PLC, normally 4 bytes */
protected long[] plcValB;
-
-
+
+
private QCPLCBit(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
-
+
// First four bytes are the number
numberOfPLCs = (int)LittleEndian.getUInt(data, 0);
-
+
// Next four bytes are the type
typeOfPLCS = (int)LittleEndian.getUInt(data, 4);
-
+
// Init the arrays that we can
plcValA = new long[numberOfPLCs];
plcValB = new long[numberOfPLCs];
}
-
-
-
+
+
+
public int getNumberOfPLCs() {
return numberOfPLCs;
}
@@ -92,7 +93,7 @@
}
}
-
+
/**
* Type 0 seem to be somewhat rare. They have 8 bytes of pre-data,
* then 2x 2 byte values.
@@ -100,14 +101,14 @@
public static class Type0 extends QCPLCBit {
private Type0(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
-
+
// Grab our 4x pre-data
preData = new int[4];
preData[0] = LittleEndian.getUShort(data, 8+0);
preData[1] = LittleEndian.getUShort(data, 8+2);
preData[2] = LittleEndian.getUShort(data, 8+4);
preData[3] = LittleEndian.getUShort(data, 8+6);
-
+
// And grab the 2 byte values
for(int i=0; i<numberOfPLCs; i++) {
plcValA[i] = LittleEndian.getUShort(data, 16+(4*i));
@@ -115,7 +116,7 @@
}
}
}
-
+
/**
* Type 4 is quite common. They have 8 bytes of pre-data,
* then 2x 4 byte values.
@@ -123,14 +124,14 @@
public static class Type4 extends QCPLCBit {
private Type4(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
-
+
// Grab our 4x pre-data
preData = new int[4];
preData[0] = LittleEndian.getUShort(data, 8+0);
preData[1] = LittleEndian.getUShort(data, 8+2);
preData[2] = LittleEndian.getUShort(data, 8+4);
preData[3] = LittleEndian.getUShort(data, 8+6);
-
+
// And grab the 4 byte values
for(int i=0; i<numberOfPLCs; i++) {
plcValA[i] = LittleEndian.getUInt(data, 16+(8*i));
@@ -138,7 +139,7 @@
}
}
}
-
+
/**
* Type 8 is quite common. They have 14 bytes of pre-data,
* then 2x 4 byte values.
@@ -146,7 +147,7 @@
public static class Type8 extends QCPLCBit {
private Type8(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
-
+
// Grab our 7x pre-data
preData = new int[7];
preData[0] = LittleEndian.getUShort(data, 8+0);
@@ -156,7 +157,7 @@
preData[4] = LittleEndian.getUShort(data, 8+8);
preData[5] = LittleEndian.getUShort(data, 8+10);
preData[6] = LittleEndian.getUShort(data, 8+12);
-
+
// And grab the 4 byte values
for(int i=0; i<numberOfPLCs; i++) {
plcValA[i] = LittleEndian.getUInt(data, 22+(8*i));
@@ -164,7 +165,7 @@
}
}
}
-
+
/**
* Type 12 holds hyperlinks, and is very complex.
* There is normally one of these for each text
@@ -174,14 +175,14 @@
*/
public static class Type12 extends QCPLCBit {
private String[] hyperlinks;
-
+
private static final int oneStartsAt = 0x4c;
private static final int twoStartsAt = 0x68;
private static final int threePlusIncrement = 22;
-
+
private Type12(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
-
+
// How many hyperlinks do we really have?
// (zero hyperlinks gets numberOfPLCs=1)
if(data.length == 0x34) {
@@ -189,14 +190,14 @@
} else {
hyperlinks = new String[numberOfPLCs];
}
-
+
// We have 4 bytes, then the start point of each
// hyperlink, then the end point of the text.
preData = new int[1+numberOfPLCs+1];
for(int i=0; i<preData.length; i++) {
preData[i] = (int)LittleEndian.getUInt(data, 8+(i*4));
}
-
+
// Then we have a whole bunch of stuff, which grows
// with the number of hyperlinks
// For now, we think these are shorts
@@ -207,13 +208,13 @@
} else if(numberOfPLCs >= 2) {
until = twoStartsAt + (numberOfPLCs-2)*threePlusIncrement;
}
-
+
plcValA = new long[(until-at)/2];
plcValB = new long[0];
for(int i=0; i<plcValA.length; i++) {
plcValA[i] = LittleEndian.getUShort(data, at+(i*2));
}
-
+
// Finally, we have a series of lengths + hyperlinks
at = until;
for(int i=0; i<hyperlinks.length; i++) {
@@ -232,9 +233,9 @@
}
}
}
-
+
/**
- * Returns the number of hyperlinks, which should
+ * Returns the number of hyperlinks, which should
* either be zero, or the number of PLC bits
*/
public int getNumberOfHyperlinks() {
@@ -251,7 +252,7 @@
}
/**
* Returns where in the text (in characters) the
- * hyperlink at the given index starts
+ * hyperlink at the given index starts
* applying to.
* This position is relative to the text area that this
* PLCBit applies to.
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model.qcbits;
import org.apache.poi.util.StringUtil;
@@ -21,7 +22,7 @@
/**
* A Text based bit of Quill Contents
*/
-public class QCTextBit extends QCBit {
+public final class QCTextBit extends QCBit {
public QCTextBit(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
}
@@ -35,7 +36,7 @@
data, 0, data.length/2
);
}
-
+
public void setText(String text) {
data = new byte[text.length()*2];
StringUtil.putUnicodeLE(text, data, 0);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/UnknownQCBit.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/UnknownQCBit.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/UnknownQCBit.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/UnknownQCBit.java Thu May 21 18:12:22 2009
@@ -14,13 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hpbf.model.qcbits;
/**
* Any Quill Contents bits we don't know
* how to handle explicitly
*/
-public class UnknownQCBit extends QCBit {
+public final class UnknownQCBit extends QCBit {
public UnknownQCBit(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf;
@@ -35,15 +32,15 @@
/**
* This class provides helper functions for determining if a
- * PowerPoint document is Encrypted.
+ * PowerPoint document is Encrypted.
* In future, it may also provide Encryption and Decryption
- * functions, but first we'd need to figure out how
+ * functions, but first we'd need to figure out how
* PowerPoint encryption is really done!
*
* @author Nick Burch
*/
-public class EncryptedSlideShow
+public final class EncryptedSlideShow
{
/**
* Check to see if a HSLFSlideShow represents an encrypted
@@ -61,11 +58,11 @@
} catch(FileNotFoundException fnfe) {
// Doesn't have encrypted properties
}
-
+
// If they encrypted the document but not the properties,
// it's harder.
// We need to see what the last record pointed to by the
- // first PersistPrtHolder is - if it's a
+ // first PersistPrtHolder is - if it's a
// DocumentEncryptionAtom, then the file's Encrypted
DocumentEncryptionAtom dea = fetchDocumentEncryptionAtom(hss);
if(dea != null) {
@@ -73,23 +70,23 @@
}
return false;
}
-
+
/**
* Return the DocumentEncryptionAtom for a HSLFSlideShow, or
* null if there isn't one.
* @return a DocumentEncryptionAtom, or null if there isn't one
*/
public static DocumentEncryptionAtom fetchDocumentEncryptionAtom(HSLFSlideShow hss) {
- // Will be the last Record pointed to by the
+ // Will be the last Record pointed to by the
// first PersistPrtHolder, if there is one
-
+
CurrentUserAtom cua = hss.getCurrentUserAtom();
if(cua.getCurrentEditOffset() != 0) {
// Check it's not past the end of the file
if(cua.getCurrentEditOffset() > hss.getUnderlyingBytes().length) {
throw new CorruptPowerPointFileException("The CurrentUserAtom claims that the offset of last edit details are past the end of the file");
}
-
+
// Grab the details of the UserEditAtom there
// If the record's messed up, we could AIOOB
Record r = null;
@@ -102,7 +99,7 @@
if(r == null) { return null; }
if(! (r instanceof UserEditAtom)) { return null; }
UserEditAtom uea = (UserEditAtom)r;
-
+
// Now get the PersistPtrHolder
Record r2 = Record.buildRecordAtOffset(
hss.getUnderlyingBytes(),
@@ -110,7 +107,7 @@
);
if(! (r2 instanceof PersistPtrHolder)) { return null; }
PersistPtrHolder pph = (PersistPtrHolder)r2;
-
+
// Now get the last record
int[] slideIds = pph.getKnownSlideIDs();
int maxSlideId = -1;
@@ -118,7 +115,7 @@
if(slideIds[i] > maxSlideId) { maxSlideId = slideIds[i]; }
}
if(maxSlideId == -1) { return null; }
-
+
int offset = (
(Integer)pph.getSlideLocationsLookup().get(
new Integer(maxSlideId)
@@ -127,13 +124,13 @@
hss.getUnderlyingBytes(),
offset
);
-
+
// If we have a DocumentEncryptionAtom, it'll be this one
if(r3 instanceof DocumentEncryptionAtom) {
return (DocumentEncryptionAtom)r3;
}
}
-
+
return null;
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java Thu May 21 18:12:22 2009
@@ -47,7 +47,7 @@
import org.apache.poi.util.POILogger;
/**
- * This class contains the main functionality for the Powerpoint file
+ * This class contains the main functionality for the Powerpoint file
* "reader". It is only a very basic class for now
*
* @author Nick Burch
@@ -80,7 +80,7 @@
}
/**
- * Constructs a Powerpoint document from fileName. Parses the document
+ * Constructs a Powerpoint document from fileName. Parses the document
* and places all the important stuff into data structures.
*
* @param fileName The name of the file to read.
@@ -90,9 +90,9 @@
{
this(new FileInputStream(fileName));
}
-
+
/**
- * Constructs a Powerpoint document from an input stream. Parses the
+ * Constructs a Powerpoint document from an input stream. Parses the
* document and places all the important stuff into data structures.
*
* @param inputStream the source of the data
@@ -104,7 +104,7 @@
}
/**
- * Constructs a Powerpoint document from a POIFS Filesystem. Parses the
+ * Constructs a Powerpoint document from a POIFS Filesystem. Parses the
* document and places all the important stuff into data structures.
*
* @param filesystem the POIFS FileSystem to read from
@@ -114,9 +114,9 @@
{
this(filesystem.getRoot(), filesystem);
}
-
+
/**
- * Constructs a Powerpoint document from a specific point in a
+ * Constructs a Powerpoint document from a specific point in a
* POIFS Filesystem. Parses the document and places all the
* important stuff into data structures.
*
@@ -127,15 +127,15 @@
public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
{
super(dir, filesystem);
-
+
// First up, grab the "Current User" stream
// We need this before we can detect Encrypted Documents
readCurrentUserStream();
-
- // Next up, grab the data that makes up the
+
+ // Next up, grab the data that makes up the
// PowerPoint stream
readPowerPointStream();
-
+
// Check to see if we have an encrypted document,
// bailing out if we do
boolean encrypted = EncryptedSlideShow.checkIfEncrypted(this);
@@ -148,7 +148,7 @@
// Look for Property Streams:
readProperties();
-
+
// Look for any other streams
readOtherStreams();
@@ -171,8 +171,8 @@
}
/**
- * Extracts the main PowerPoint document stream from the
- * POI file, ready to be passed
+ * Extracts the main PowerPoint document stream from the
+ * POI file, ready to be passed
*
* @throws IOException
*/
@@ -186,9 +186,9 @@
_docstream = new byte[docProps.getSize()];
directory.createDocumentInputStream("PowerPoint Document").read(_docstream);
}
-
+
/**
- * Builds the list of records, based on the contents
+ * Builds the list of records, based on the contents
* of the PowerPoint stream
*/
private void buildRecords()
@@ -206,7 +206,7 @@
// <xx xx yy yy zz zz zz zz dd dd dd dd dd dd dd>
// All lengths given exclude the 8 byte record header
// (Data records are known as Atoms)
-
+
// Document should start with:
// 0F 00 E8 03 ## ## ## ##
// (type 1000 = document, info 00 0f is normal, rest is document length)
@@ -216,9 +216,9 @@
// 05 00 00 00 0A 00 00 00 xx xx xx
// (the contents of the document atom, not sure what it means yet)
// (records then follow)
-
+
// When parsing a document, look to see if you know about that type
- // of the current record. If you know it's a type that has children,
+ // of the current record. If you know it's a type that has children,
// process the record's data area looking for more records
// If you know about the type and it doesn't have children, either do
// something with the data (eg TextRun) or skip over it
@@ -231,7 +231,7 @@
private Record[] read(byte[] docstream, int usrOffset){
ArrayList lst = new ArrayList();
- HashMap offset2id = new HashMap();
+ HashMap offset2id = new HashMap();
while (usrOffset != 0){
UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
lst.add(new Integer(usrOffset));
@@ -269,7 +269,7 @@
}
/**
- * Find the "Current User" stream, and load it
+ * Find the "Current User" stream, and load it
*/
private void readCurrentUserStream() {
try {
@@ -279,9 +279,9 @@
currentUser = new CurrentUserAtom();
}
}
-
+
/**
- * Find any other streams from the filesystem, and load them
+ * Find any other streams from the filesystem, and load them
*/
private void readOtherStreams() {
// Currently, there aren't any
@@ -301,7 +301,7 @@
DocumentInputStream is = directory.createDocumentInputStream("Pictures");
is.read(pictstream);
} catch (FileNotFoundException e){
- // Silently catch exceptions if the presentation doesn't
+ // Silently catch exceptions if the presentation doesn't
// contain pictures - will use a null set instead
return;
}
@@ -348,7 +348,7 @@
logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
}
}
-
+
pos += imgsize;
}
}
@@ -383,7 +383,7 @@
// The list of entries we've written out
List writtenEntries = new ArrayList(1);
-
+
// Write out the Property Streams
writeProperties(outFS, writtenEntries);
@@ -449,7 +449,7 @@
currentUser.writeToFS(outFS);
writtenEntries.add("Current User");
-
+
// Write any pictures, into another stream
if (_pictures.size() > 0) {
ByteArrayOutputStream pict = new ByteArrayOutputStream();
@@ -461,7 +461,7 @@
);
writtenEntries.add("Pictures");
}
-
+
// If requested, write out any other streams we spot
if(preserveNodes) {
copyNodes(filesystem, outFS, writtenEntries);
@@ -498,7 +498,7 @@
_records = r;
return addedAt;
}
-
+
/**
* Add a new picture to this presentation.
*
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.usermodel.PictureData;
@@ -24,7 +25,7 @@
/**
* Represents a bitmap picture data: JPEG or PNG.
* The data is not compressed and the exact file content is written in the stream.
- *
+ *
* @author Yegor Kozlov
*/
public abstract class Bitmap extends PictureData {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java Thu May 21 18:12:22 2009
@@ -1,51 +1,68 @@
-package org.apache.poi.hslf.blip;
-
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
-==================================================================== */
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-
-/**
- * Creates BufferedImage using javax.imageio.ImageIO and draws it in the specified graphics.
- *
- * @author Yegor Kozlov.
- */
-public class BitmapPainter implements ImagePainter {
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
-
- public void paint(Graphics2D graphics, PictureData pict, Picture parent) {
- BufferedImage img;
- try {
- img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
- }
- catch (Exception e){
- logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + pict.getType());
- return;
- }
- Rectangle anchor = parent.getAnchor();
- Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
- graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.blip;
+
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
+
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+==================================================================== */
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Creates BufferedImage using javax.imageio.ImageIO and draws it in the specified graphics.
+ *
+ * @author Yegor Kozlov.
+ */
+public final class BitmapPainter implements ImagePainter {
+ protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
+ public void paint(Graphics2D graphics, PictureData pict, Picture parent) {
+ BufferedImage img;
+ try {
+ img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
+ }
+ catch (Exception e){
+ logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + pict.getType());
+ return;
+ }
+ Rectangle anchor = parent.getAnchor();
+ Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
+ graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
+ }
+
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
@@ -23,10 +24,10 @@
/**
* Represents a DIB picture data in a PPT file
- *
+ *
* @author Yegor Kozlov
*/
-public class DIB extends Bitmap {
+public final class DIB extends Bitmap {
/**
* Size of the BITMAPFILEHEADER structure preceding the actual DIB bytes
*/
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
@@ -29,10 +30,10 @@
/**
* Represents EMF (Windows Enhanced Metafile) picture data.
- *
+ *
* @author Yegor Kozlov
*/
-public class EMF extends Metafile {
+public final class EMF extends Metafile {
/**
* Extract compressed EMF data from a ppt
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java Thu May 21 18:12:22 2009
@@ -1,71 +1,72 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.blip;
-
-import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.usermodel.PictureData;
-
-import java.awt.*;
-
-/**
- * A common interface for objects that can render ppt picture data.
- * <p>
- * Subclasses can redefine it and use third-party libraries for actual rendering,
- * for example, Bitmaps can be rendered using javax.imageio.* , WMF can be rendered using Apache Batik,
- * PICT can be rendered using Apple QuickTime API for Java, etc.
- * </p>
- *
- * A typical usage is as follows:
- * <code>
- * public WMFPaiter implements ImagePainter{
- * public void paint(Graphics2D graphics, PictureData pict, Picture parent){
- * DataInputStream is = new DataInputStream(new ByteArrayInputStream(pict.getData()));
- * org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
- * new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
- * try {
- * wmfStore.read(is);
- * } catch (IOException e){
- * return;
- * }
- *
- * Rectangle anchor = parent.getAnchor();
- * float scale = (float)anchor.width/wmfStore.getWidthPixels();
- *
- * org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
- * new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
- * graphics.translate(anchor.x, anchor.y);
- * painter.paint(graphics);
- * }
- * }
- * PictureData.setImagePainter(Picture.WMF, new WMFPaiter());
- * ...
- * </code>
- * Subsequent calls of Slide.draw(Graphics gr) will use WMFPaiter for WMF images.
- *
- * @author Yegor Kozlov.
- */
-public interface ImagePainter {
-
- /**
- * Paints the specified picture data
- *
- * @param graphics the graphics to paintb into
- * @param pict the data to paint
- * @param parent the shapes that owns the picture data
- */
- public void paint(Graphics2D graphics, PictureData pict, Picture parent);
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.blip;
+
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.hslf.usermodel.PictureData;
+
+import java.awt.*;
+
+/**
+ * A common interface for objects that can render ppt picture data.
+ * <p>
+ * Subclasses can redefine it and use third-party libraries for actual rendering,
+ * for example, Bitmaps can be rendered using javax.imageio.* , WMF can be rendered using Apache Batik,
+ * PICT can be rendered using Apple QuickTime API for Java, etc.
+ * </p>
+ *
+ * A typical usage is as follows:
+ * <code>
+ * public WMFPaiter implements ImagePainter{
+ * public void paint(Graphics2D graphics, PictureData pict, Picture parent){
+ * DataInputStream is = new DataInputStream(new ByteArrayInputStream(pict.getData()));
+ * org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
+ * new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
+ * try {
+ * wmfStore.read(is);
+ * } catch (IOException e){
+ * return;
+ * }
+ *
+ * Rectangle anchor = parent.getAnchor();
+ * float scale = (float)anchor.width/wmfStore.getWidthPixels();
+ *
+ * org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
+ * new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
+ * graphics.translate(anchor.x, anchor.y);
+ * painter.paint(graphics);
+ * }
+ * }
+ * PictureData.setImagePainter(Picture.WMF, new WMFPaiter());
+ * ...
+ * </code>
+ * Subsequent calls of Slide.draw(Graphics gr) will use WMFPaiter for WMF images.
+ *
+ * @author Yegor Kozlov.
+ */
+public interface ImagePainter {
+
+ /**
+ * Paints the specified picture data
+ *
+ * @param graphics the graphics to paintb into
+ * @param pict the data to paint
+ * @param parent the shapes that owns the picture data
+ */
+ public void paint(Graphics2D graphics, PictureData pict, Picture parent);
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java Thu May 21 18:12:22 2009
@@ -14,16 +14,17 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
/**
* Represents a JPEG picture data in a PPT file
- *
+ *
* @author Yegor Kozlov
*/
-public class JPEG extends Bitmap {
+public final class JPEG extends Bitmap {
/**
* @return type of this picture
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.util.LittleEndian;
@@ -27,7 +28,7 @@
/**
* Represents a metafile picture which can be one of the following types: EMF, WMF, or PICT.
* A metafile is stored compressed using the ZIP deflate/inflate algorithm.
- *
+ *
* @author Yegor Kozlov
*/
public abstract class Metafile extends PictureData {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
@@ -27,10 +28,10 @@
/**
* Represents Macintosh PICT picture data.
- *
+ *
* @author Yegor Kozlov
*/
-public class PICT extends Metafile {
+public final class PICT extends Metafile {
public PICT(){
super();
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
@@ -26,10 +27,10 @@
/**
* Represents a PNG picture data in a PPT file
- *
+ *
* @author Yegor Kozlov
*/
-public class PNG extends Bitmap {
+public final class PNG extends Bitmap {
/**
* @return PNG data
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.blip;
import org.apache.poi.util.LittleEndian;
@@ -28,10 +29,10 @@
/**
* Represents a WMF (Windows Metafile) picture data.
- *
+ *
* @author Yegor Kozlov
*/
-public class WMF extends Metafile {
+public final class WMF extends Metafile {
/**
* Extract compressed WMF data from a ppt
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,8 +15,6 @@
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
import org.apache.poi.hslf.*;
@@ -29,7 +26,7 @@
* Having found them, it sees if they have DDF Textbox records, and if so,
* searches those for text. Prints out any text it finds
*/
-public class PPDrawingTextListing {
+public final class PPDrawingTextListing {
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Need to give a filename");
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java Thu May 21 18:12:22 2009
@@ -28,7 +28,7 @@
* @author Yegor Kozlov
*/
-public class PPTXMLDump {
+public final class PPTXMLDump {
public static final int HEADER_SIZE = 8; //size of the record header
public static final int PICT_HEADER_SIZE = 25; //size of the picture header
public final static String PPDOC_ENTRY = "PowerPoint Document";
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,8 +15,6 @@
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
import org.apache.poi.hslf.HSLFSlideShow;
@@ -31,7 +28,7 @@
* Having found them, it sees if they have any SlideListWithTexts,
* and reports how many, and what sorts of things they contain
*/
-public class SLWTListing {
+public final class SLWTListing {
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Need to give a filename");
@@ -46,7 +43,7 @@
if(records[i] instanceof Document) {
Document doc = (Document)records[i];
SlideListWithText[] slwts = doc.getSlideListWithTexts();
-
+
System.out.println("Document at " + i + " had " + slwts.length + " SlideListWithTexts");
if(slwts.length == 0) {
System.err.println("** Warning: Should have had at least 1! **");
@@ -54,14 +51,14 @@
if(slwts.length > 3) {
System.err.println("** Warning: Shouldn't have more than 3!");
}
-
+
// Check the SLWTs contain what we'd expect
for(int j=0; j<slwts.length; j++) {
SlideListWithText slwt = slwts[j];
Record[] children = slwt.getChildRecords();
-
+
System.out.println(" - SLWT at " + j + " had " + children.length + " children:");
-
+
// Should only have SlideAtomSets if the second one
int numSAS = slwt.getSlideAtomsSets().length;
if(j == 1) {
@@ -75,7 +72,7 @@
System.err.println(" ** SLWT " + j + " had " + numSAS + " SlideAtomSets! (expected 0)");
}
}
-
+
// Report the first 5 children, to give a flavour
int upTo = 5;
if(children.length < 5) { upTo = children.length; }
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,8 +15,6 @@
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
import org.apache.poi.hslf.*;
@@ -28,7 +25,7 @@
* Having found them, it sees if they have any text, and prints out
* what it finds.
*/
-public class SLWTTextListing {
+public final class SLWTTextListing {
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Need to give a filename");
@@ -48,7 +45,7 @@
System.out.println("Found SLWT at pos " + j + " in the Document at " + i);
System.out.println(" Has " + docChildren[j].getChildRecords().length + " children");
- // Grab the SlideAtomSet's, which contain
+ // Grab the SlideAtomSet's, which contain
// a SlidePersistAtom and then a bunch of text
// + related records
SlideListWithText slwt = (SlideListWithText)docChildren[j];
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,8 +15,6 @@
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
import org.apache.poi.hslf.*;
@@ -30,7 +27,7 @@
* what they are all about. Useful for checking the matching between
* Slides, Master Slides and Notes
*/
-public class SlideAndNotesAtomListing {
+public final class SlideAndNotesAtomListing {
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Need to give a filename");
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,8 +15,6 @@
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
import org.apache.poi.hslf.*;
@@ -34,7 +31,7 @@
* in them, and displays them, so you can try to guess what they
* all mean
*/
-public class SlideIdListing {
+public final class SlideIdListing {
private static byte[] fileContents;
public static void main(String[] args) throws Exception {
@@ -47,12 +44,12 @@
// Create the slideshow object, for normal working with
HSLFSlideShow hss = new HSLFSlideShow(args[0]);
SlideShow ss = new SlideShow(hss);
-
+
// Grab the base contents
fileContents = hss.getUnderlyingBytes();
Record[] records = hss.getRecords();
Record[] latestRecords = ss.getMostRecentCoreRecords();
-
+
// Grab any records that interest us
Document document = null;
for(int i=0; i<latestRecords.length; i++) {
@@ -60,10 +57,10 @@
document = (Document)latestRecords[i];
}
}
-
+
System.out.println("");
-
-
+
+
// Look for SlidePersistAtoms, and report what they have to
// say about possible slide IDs
SlideListWithText[] slwts = document.getSlideListWithTexts();
@@ -78,9 +75,9 @@
}
}
}
-
+
System.out.println("");
-
+
// Look for latest core records that are slides or notes
for(int i=0; i<latestRecords.length; i++) {
if(latestRecords[i] instanceof Slide) {
@@ -108,7 +105,7 @@
}
System.out.println("");
-
+
// Find any persist ones first
int pos = 0;
for(int i=0; i<records.length; i++) {
@@ -159,7 +156,7 @@
long rlen = LittleEndian.getUInt(fileContents, pos+4);
Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
-
+
return r;
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.dev;
@@ -40,14 +37,14 @@
* To figure out what things are, and if they are atoms or not, used the
* list in hslf.record.RecordTypes
*
- * To peek inside PPDrawings, which hold Escher drawings, we use the
+ * To peek inside PPDrawings, which hold Escher drawings, we use the
* DDF package from POI (but we can fake it by using the Escher listings
* from hslf.record.RecordTypes also)
- *
+ *
* @author Nick Burch
*/
-public class SlideShowDumper
+public final class SlideShowDumper
{
private InputStream istream;
private POIFSFileSystem filesystem;
@@ -91,7 +88,7 @@
/**
- * Constructs a Powerpoint dump from fileName. Parses the document
+ * Constructs a Powerpoint dump from fileName. Parses the document
* and dumps out the contents
*
* @param fileName The name of the file to read.
@@ -101,9 +98,9 @@
{
this(new FileInputStream(fileName));
}
-
+
/**
- * Constructs a Powerpoint dump from an input stream. Parses the
+ * Constructs a Powerpoint dump from an input stream. Parses the
* document and dumps out the contents
*
* @param inputStream the source of the data
@@ -117,7 +114,7 @@
}
/**
- * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the
+ * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the
* document and dumps out the contents
*
* @param filesystem the POIFS FileSystem to read from
@@ -189,7 +186,7 @@
// (type 1001 = document atom, info 00 01 normal, 28 bytes long)
// When parsing a document, look to see if you know about that type
- // of the current record. If you know it's a type that has children,
+ // of the current record. If you know it's a type that has children,
// process the record's data area looking for more records
// If you know about the type and it doesn't have children, either do
// something with the data (eg TextRun) or skip over it
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org