diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
index 9d14b7bff5..c720a555ce 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
@@ -17,10 +17,12 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.LittleEndian;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.ByteArrayOutputStream;
+
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.LittleEndian;
/**
* A ColorSchemeAtom (type 2032). Holds the 8 RGB values for the different
@@ -97,7 +99,7 @@ public final class ColorSchemeAtom extends RecordAtom {
if(len < 40) {
len = 40;
if(source.length - start < 40) {
- throw new RuntimeException("Not enough data to form a ColorSchemeAtom (always 40 bytes long) - found " + (source.length - start));
+ throw new HSLFException("Not enough data to form a ColorSchemeAtom (always 40 bytes long) - found " + (source.length - start));
}
}
@@ -140,7 +142,8 @@ public final class ColorSchemeAtom extends RecordAtom {
/**
* We are of type 3999
*/
- public long getRecordType() { return _type; }
+ @Override
+ public long getRecordType() { return _type; }
/**
@@ -155,7 +158,7 @@ public final class ColorSchemeAtom extends RecordAtom {
writeLittleEndian(rgb,baos);
} catch(IOException ie) {
// Should never happen
- throw new RuntimeException(ie);
+ throw new HSLFException(ie);
}
byte[] b = baos.toByteArray();
System.arraycopy(b,0,ret,0,3);
@@ -174,7 +177,7 @@ public final class ColorSchemeAtom extends RecordAtom {
*/
public static int joinRGB(byte[] rgb) {
if(rgb.length != 3) {
- throw new RuntimeException("joinRGB accepts a byte array of 3 values, but got one of " + rgb.length + " values!");
+ throw new HSLFException("joinRGB accepts a byte array of 3 values, but got one of " + rgb.length + " values!");
}
byte[] with_zero = new byte[4];
System.arraycopy(rgb,0,with_zero,0,3);
@@ -188,7 +191,8 @@ public final class ColorSchemeAtom extends RecordAtom {
* Write the contents of the record back, so it can be written
* to disk
*/
- public void writeOut(OutputStream out) throws IOException {
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
// Header - size or type unchanged
out.write(_header);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
index 23a7fe1e40..80126fdb9f 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
@@ -20,6 +20,7 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
@@ -67,6 +68,7 @@ public final class FontEntityAtom extends RecordAtom {
LittleEndian.putInt(_header, 4, _recdata.length);
}
+ @Override
public long getRecordType() {
return RecordTypes.FontEntityAtom.typeID;
}
@@ -103,7 +105,7 @@ public final class FontEntityAtom extends RecordAtom {
// Ensure it's not now too long
if(name.length() > 32) {
- throw new RuntimeException("The length of the font name, including null termination, must not exceed 32 characters");
+ throw new HSLFException("The length of the font name, including null termination, must not exceed 32 characters");
}
// Everything's happy, so save the name
@@ -207,7 +209,8 @@ public final class FontEntityAtom extends RecordAtom {
/**
* Write the contents of the record back, so it can be written to disk
*/
- public void writeOut(OutputStream out) throws IOException {
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
out.write(_header);
out.write(_recdata);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
index 85f0eb9273..8a1c482696 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
@@ -27,6 +27,7 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
+import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
@@ -215,7 +216,7 @@ public final class PersistPtrHolder extends PositionDependentRecordAtom
lastSlideId = nextSlideId;
} catch (IOException e) {
// ByteArrayOutputStream is very unlikely throwing a IO exception (maybe because of OOM ...)
- throw new RuntimeException(e);
+ throw new HSLFException(e);
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
index e2987b3d62..73017b798d 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
+import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -180,13 +181,13 @@ public abstract class Record
// Instantiate
toReturn = con.newInstance(new Object[] { b, start, len });
} catch(InstantiationException ie) {
- throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
+ throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
} catch(java.lang.reflect.InvocationTargetException ite) {
- throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ite + "\nCause was : " + ite.getCause(), ite);
+ throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ite + "\nCause was : " + ite.getCause(), ite);
} catch(IllegalAccessException iae) {
- throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + iae, iae);
+ throw new HSLFException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + iae, iae);
} catch(NoSuchMethodException nsme) {
- throw new RuntimeException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + nsme, nsme);
+ throw new HSLFException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + nsme, nsme);
}
// Handling for special kinds of records follow
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java b/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
index 6e3932606a..c0c57255f3 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
@@ -279,7 +279,7 @@ public enum RecordTypes {
// }
// }
// } catch (IllegalAccessException e){
-// throw new RuntimeException("Failed to initialize records types");
+// throw new HSLFException("Failed to initialize records types");
// }
// }
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
index 68f75c09b1..16be0c6a80 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
@@ -20,6 +20,7 @@ package org.apache.poi.hslf.record;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.LittleEndian;
/**
@@ -138,13 +139,15 @@ public final class SlideAtom extends RecordAtom
/**
* We are of type 1007
*/
- public long getRecordType() { return _type; }
+ @Override
+ public long getRecordType() { return _type; }
/**
* Write the contents of the record back, so it can be written
* to disk
*/
- public void writeOut(OutputStream out) throws IOException {
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
// Header
out.write(_header);
@@ -211,7 +214,7 @@ public final class SlideAtom extends RecordAtom
*/
public SSlideLayoutAtom(byte[] data) {
if(data.length != 12) {
- throw new RuntimeException("SSlideLayoutAtom created with byte array not 12 bytes long - was " + data.length + " bytes in size");
+ throw new HSLFException("SSlideLayoutAtom created with byte array not 12 bytes long - was " + data.length + " bytes in size");
}
// Grab out our data
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
index bfb9d741ab..238385b684 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
@@ -17,13 +17,18 @@
package org.apache.poi.hslf.record;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
-import org.apache.poi.hslf.model.textproperties.*;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
-import org.apache.poi.util.*;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogger;
/**
* A StyleTextPropAtom (type 4001). Holds basic character properties
@@ -121,7 +126,7 @@ public final class StyleTextPropAtom extends RecordAtom
if(len < 18) {
len = 18;
if(source.length - start < 18) {
- throw new RuntimeException("Not enough data to form a StyleTextPropAtom (min size 18 bytes long) - found " + (source.length - start));
+ throw new HSLFException("Not enough data to form a StyleTextPropAtom (min size 18 bytes long) - found " + (source.length - start));
}
}
@@ -167,7 +172,7 @@ public final class StyleTextPropAtom extends RecordAtom
try {
updateRawContents();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new HSLFException(e);
}
}
@@ -175,6 +180,7 @@ public final class StyleTextPropAtom extends RecordAtom
/**
* We are of type 4001
*/
+ @Override
public long getRecordType() { return _type; }
@@ -182,6 +188,7 @@ public final class StyleTextPropAtom extends RecordAtom
* Write the contents of the record back, so it can be written
* to disk
*/
+ @Override
public void writeOut(OutputStream out) throws IOException {
// First thing to do is update the raw bytes of the contents, based
// on the properties
@@ -203,7 +210,9 @@ public final class StyleTextPropAtom extends RecordAtom
* contains, so we can go ahead and initialise ourselves.
*/
public void setParentTextSize(int size) {
- if (initialised) return;
+ if (initialised) {
+ return;
+ }
int pos = 0;
int textHandled = 0;
@@ -365,6 +374,7 @@ public final class StyleTextPropAtom extends RecordAtom
*
* @return the string representation of the record data
*/
+ @Override
public String toString(){
StringBuffer out = new StringBuffer();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
index 3fab236a1c..2d4f41bddc 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
@@ -17,10 +17,12 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.LittleEndian;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.LittleEndian;
+
/**
* A TextHeaderAtom (type 3999). Holds information on what kind of
* text is contained in the TextBytesAtom / TextCharsAtom that follows
@@ -62,8 +64,10 @@ public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecor
*/
public void setIndex(int index) { this.index = index; }
- public RecordContainer getParentRecord() { return parentRecord; }
- public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
+ @Override
+ public RecordContainer getParentRecord() { return parentRecord; }
+ @Override
+ public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
/* *************** record code follows ********************** */
@@ -75,7 +79,7 @@ public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecor
if(len < 12) {
len = 12;
if(source.length - start < 12) {
- throw new RuntimeException("Not enough data to form a TextHeaderAtom (always 12 bytes long) - found " + (source.length - start));
+ throw new HSLFException("Not enough data to form a TextHeaderAtom (always 12 bytes long) - found " + (source.length - start));
}
}
@@ -102,13 +106,15 @@ public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecor
/**
* We are of type 3999
*/
- public long getRecordType() { return _type; }
+ @Override
+ public long getRecordType() { return _type; }
/**
* Write the contents of the record back, so it can be written
* to disk
*/
- public void writeOut(OutputStream out) throws IOException {
+ @Override
+ public void writeOut(OutputStream out) throws IOException {
// Header - size or type unchanged
out.write(_header);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
index d18054ee61..7f87086bfa 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
@@ -112,7 +112,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
try {
sir.writeOut(bos);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new HSLFException(e);
}
_data = bos.toByteArray();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
index b1bd6bba3e..54a0e5033a 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
@@ -17,13 +17,14 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.LittleEndianConsts;
-
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LittleEndianConsts;
+
/**
* A UserEdit Atom (type 4085). Holds information which bits of the file
* were last used by powerpoint, the version of powerpoint last used etc.
@@ -140,18 +141,20 @@ public final class UserEditAtom extends PositionDependentRecordAtom
/**
* We are of type 4085
*/
- public long getRecordType() { return _type; }
+ @Override
+ public long getRecordType() { return _type; }
/**
* At write-out time, update the references to PersistPtrs and
* other UserEditAtoms to point to their new positions
*/
- public void updateOtherRecordReferences(Map
false otherwise
*/
+ @Override
public void setFollowMasterBackground(boolean flag){
SlideAtom sa = getSlideRecord().getSlideAtom();
sa.setFollowMasterBackground(flag);
@@ -294,6 +309,7 @@ public final class HSLFSlide extends HSLFSheet implements Slidefalse otherwise
*/
+ @Override
public boolean getFollowMasterBackground(){
SlideAtom sa = getSlideRecord().getSlideAtom();
return sa.getFollowMasterBackground();
@@ -305,6 +321,7 @@ public final class HSLFSlide extends HSLFSheet implements Slidefalse otherwise
*/
+ @Override
public void setFollowMasterObjects(boolean flag){
SlideAtom sa = getSlideRecord().getSlideAtom();
sa.setFollowMasterObjects(flag);
@@ -338,6 +355,7 @@ public final class HSLFSlide extends HSLFSheet implements Slidefalse otherwise
*/
+ @Override
public boolean getFollowMasterObjects(){
SlideAtom sa = getSlideRecord().getSlideAtom();
return sa.getFollowMasterObjects();
@@ -346,7 +364,8 @@ public final class HSLFSlide extends HSLFSheet implements Slide