Inconsistent whitespace

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1766493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2016-10-25 09:35:28 +00:00
parent 41d7cf537e
commit a4988318ec
5 changed files with 141 additions and 141 deletions

View File

@ -22,35 +22,35 @@ package org.apache.poi.hdgf.pointers;
* blocks elsewhere in the file * blocks elsewhere in the file
*/ */
public abstract class Pointer { public abstract class Pointer {
protected int type; protected int type;
protected int address; protected int address;
protected int offset; protected int offset;
protected int length; protected int length;
protected short format; protected short format;
public int getAddress() { public int getAddress() {
return address; return address;
} }
public short getFormat() { public short getFormat() {
return format; return format;
} }
public int getLength() { public int getLength() {
return length; return length;
} }
public int getOffset() { public int getOffset() {
return offset; return offset;
} }
public int getType() { public int getType() {
return type; return type;
} }
public abstract int getSizeInBytes(); public abstract int getSizeInBytes();
public abstract int getNumPointersOffset(byte[] data); public abstract int getNumPointersOffset(byte[] data);
public abstract int getNumPointers(int offset, byte[] data); public abstract int getNumPointers(int offset, byte[] data);
public abstract int getPostNumPointersSkip(); public abstract int getPostNumPointersSkip();
public abstract boolean destinationHasStrings(); public abstract boolean destinationHasStrings();
public abstract boolean destinationHasPointers(); public abstract boolean destinationHasPointers();
public abstract boolean destinationHasChunks(); public abstract boolean destinationHasChunks();
public abstract boolean destinationCompressed(); public abstract boolean destinationCompressed();
} }

View File

@ -25,27 +25,27 @@ import org.apache.poi.util.LittleEndian;
* of the file * of the file
*/ */
public final class PointerFactory { public final class PointerFactory {
private int version; private int version;
public PointerFactory(int version) { public PointerFactory(int version) {
this.version = version; this.version = version;
} }
public int getVersion() { return version; } public int getVersion() { return version; }
/** /**
* Creates a single Pointer from the data at the given offset * Creates a single Pointer from the data at the given offset
*/ */
public Pointer createPointer(byte[] data, int offset) { public Pointer createPointer(byte[] data, int offset) {
Pointer p; Pointer p;
if(version >= 6) { if(version >= 6) {
p = new PointerV6(); p = new PointerV6();
p.type = LittleEndian.getInt(data, offset+0); p.type = LittleEndian.getInt(data, offset+0);
p.address = (int)LittleEndian.getUInt(data, offset+4); p.address = (int)LittleEndian.getUInt(data, offset+4);
p.offset = (int)LittleEndian.getUInt(data, offset+8); p.offset = (int)LittleEndian.getUInt(data, offset+8);
p.length = (int)LittleEndian.getUInt(data, offset+12); p.length = (int)LittleEndian.getUInt(data, offset+12);
p.format = LittleEndian.getShort(data, offset+16); p.format = LittleEndian.getShort(data, offset+16);
return p; return p;
} else if(version == 5) { } else if(version == 5) {
p = new PointerV5(); p = new PointerV5();
p.type = LittleEndian.getShort(data, offset+0); p.type = LittleEndian.getShort(data, offset+0);
p.format = LittleEndian.getShort(data, offset+2); p.format = LittleEndian.getShort(data, offset+2);
@ -54,31 +54,31 @@ public final class PointerFactory {
p.length = (int)LittleEndian.getUInt(data, offset+12); p.length = (int)LittleEndian.getUInt(data, offset+12);
return p; return p;
} else { } else {
throw new IllegalArgumentException("Visio files with versions below 5 are not supported, yours was " + version); throw new IllegalArgumentException("Visio files with versions below 5 are not supported, yours was " + version);
} }
} }
/** /**
* Parsers the {@link PointerContainingStream} contents and * Parsers the {@link PointerContainingStream} contents and
* creates all the child Pointers for it * creates all the child Pointers for it
*/ */
public Pointer[] createContainerPointers(Pointer parent, byte[] data) { public Pointer[] createContainerPointers(Pointer parent, byte[] data) {
// Where in the stream does the "number of pointers" offset live? // Where in the stream does the "number of pointers" offset live?
int numPointersOffset = parent.getNumPointersOffset(data); int numPointersOffset = parent.getNumPointersOffset(data);
// How many do we have? // How many do we have?
int numPointers = parent.getNumPointers(numPointersOffset, data); int numPointers = parent.getNumPointers(numPointersOffset, data);
// How much to skip for the num pointers + any extra data? // How much to skip for the num pointers + any extra data?
int skip = parent.getPostNumPointersSkip(); int skip = parent.getPostNumPointersSkip();
// Create // Create
int pos = numPointersOffset + skip; int pos = numPointersOffset + skip;
Pointer[] childPointers = new Pointer[numPointers]; Pointer[] childPointers = new Pointer[numPointers];
for(int i=0; i<numPointers; i++) { for(int i=0; i<numPointers; i++) {
childPointers[i] = this.createPointer(data, pos); childPointers[i] = this.createPointer(data, pos);
pos += childPointers[i].getSizeInBytes(); pos += childPointers[i].getSizeInBytes();
} }
return childPointers; return childPointers;
} }
} }

View File

@ -24,42 +24,42 @@ import org.apache.poi.util.LittleEndian;
*/ */
public final class PointerV5 extends Pointer { public final class PointerV5 extends Pointer {
// TODO Are these getters correct? // TODO Are these getters correct?
public boolean destinationHasStrings() { public boolean destinationHasStrings() {
return (0x40 <= format && format < 0x50); return (0x40 <= format && format < 0x50);
} }
public boolean destinationHasPointers() { public boolean destinationHasPointers() {
if(type == 20) return true; if(type == 20) return true;
if(format == 0x1d || format == 0x1e) return true; if(format == 0x1d || format == 0x1e) return true;
return (0x50 <= format && format < 0x60); return (0x50 <= format && format < 0x60);
} }
public boolean destinationHasChunks() { public boolean destinationHasChunks() {
return (0xd0 <= format && format < 0xdf); return (0xd0 <= format && format < 0xdf);
} }
public boolean destinationCompressed() { public boolean destinationCompressed() {
// Apparently, it's the second least significant bit // Apparently, it's the second least significant bit
return (format & 2) > 0; return (format & 2) > 0;
} }
/** /**
* With v6 pointers, the on-disk size is 16 bytes * With v6 pointers, the on-disk size is 16 bytes
*/ */
public int getSizeInBytes() { return 16; } public int getSizeInBytes() { return 16; }
/** /**
* Depends on the type only, not stored * Depends on the type only, not stored
*/ */
public int getNumPointersOffset(byte[] data) { public int getNumPointersOffset(byte[] data) {
switch (type) { switch (type) {
case 0x1d: case 0x1d:
case 0x4e: case 0x4e:
return 0x24-6; return 30;
case 0x1e: case 0x1e:
return 0x3c-6; return 54;
case 0x14: case 0x14:
return 0x88-6; return 130;
} }
return 10; return 10;
} }
/** /**
* 16 bit int at the given offset * 16 bit int at the given offset

View File

@ -23,31 +23,31 @@ import org.apache.poi.util.LittleEndian;
* A Pointer from v6+ * A Pointer from v6+
*/ */
public final class PointerV6 extends Pointer { public final class PointerV6 extends Pointer {
public boolean destinationHasStrings() { public boolean destinationHasStrings() {
return (0x40 <= format && format < 0x50); return (0x40 <= format && format < 0x50);
} }
public boolean destinationHasPointers() { public boolean destinationHasPointers() {
if(type == 20) return true; if(type == 20) return true;
if(format == 0x1d || format == 0x1e) return true; if(format == 0x1d || format == 0x1e) return true;
return (0x50 <= format && format < 0x60); return (0x50 <= format && format < 0x60);
} }
public boolean destinationHasChunks() { public boolean destinationHasChunks() {
return (0xd0 <= format && format < 0xdf); return (0xd0 <= format && format < 0xdf);
} }
public boolean destinationCompressed() { public boolean destinationCompressed() {
// Apparently, it's the second least significant bit // Apparently, it's the second least significant bit
return (format & 2) > 0; return (format & 2) > 0;
} }
/** /**
* With v6 pointers, the on-disk size is 18 bytes * With v6 pointers, the on-disk size is 18 bytes
*/ */
public int getSizeInBytes() { return 18; } public int getSizeInBytes() { return 18; }
/** /**
* Stored within the data * Stored within the data
*/ */
public int getNumPointersOffset(byte[] data) { public int getNumPointersOffset(byte[] data) {
return getNumPointersOffsetV6(data); return getNumPointersOffsetV6(data);
} }

View File

@ -23,32 +23,32 @@ import static org.apache.poi.hdgf.pointers.PointerV6.*;
import junit.framework.TestCase; import junit.framework.TestCase;
public abstract class StreamTest extends TestCase { public abstract class StreamTest extends TestCase {
public static class TestPointer extends Pointer { public static class TestPointer extends Pointer {
private final boolean compressed; private final boolean compressed;
protected boolean hasPointers = false; protected boolean hasPointers = false;
public TestPointer(boolean compressed, int offset, int length, int type, short format) { public TestPointer(boolean compressed, int offset, int length, int type, short format) {
this.compressed = compressed; this.compressed = compressed;
this.offset = offset; this.offset = offset;
this.length = length; this.length = length;
this.type = type; this.type = type;
this.format = format; this.format = format;
} }
@Override @Override
public boolean destinationCompressed() { return compressed; } public boolean destinationCompressed() { return compressed; }
@Override @Override
public boolean destinationHasChunks() { return false; } public boolean destinationHasChunks() { return false; }
@Override @Override
public boolean destinationHasPointers() { return hasPointers; } public boolean destinationHasPointers() { return hasPointers; }
@Override @Override
public boolean destinationHasStrings() { return false; } public boolean destinationHasStrings() { return false; }
@Override @Override
public int getSizeInBytes() { return -1; } public int getSizeInBytes() { return -1; }
@Override @Override
public int getNumPointersOffset(byte[] data) { public int getNumPointersOffset(byte[] data) {
return getNumPointersOffsetV6(data); return getNumPointersOffsetV6(data);
} }
@Override @Override
public int getNumPointers(int offset, byte[] data) { public int getNumPointers(int offset, byte[] data) {
return getNumPointersV6(offset, data); return getNumPointersV6(offset, data);
@ -57,5 +57,5 @@ public abstract class StreamTest extends TestCase {
public int getPostNumPointersSkip() { public int getPostNumPointersSkip() {
return getPostNumPointersSkipV6(); return getPostNumPointersSkipV6();
} }
} }
} }