poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1776896 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hslf: record/ usermodel/
Date Mon, 02 Jan 2017 00:55:49 GMT
Author: kiwiwings
Date: Mon Jan  2 00:55:49 2017
New Revision: 1776896

URL: http://svn.apache.org/viewvc?rev=1776896&view=rev
Log:
Sonarqube fixes
- replace RuntimeException with application specific runtime exception
- clean-up sources - add braces to if statements and add override annotations
- fix a few hslf blockers

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java Mon Jan  2 00:55:49 2017
@@ -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 exten
 		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 exten
 	/**
 	 * We are of type 3999
 	 */
-	public long getRecordType() { return _type; }
+	@Override
+    public long getRecordType() { return _type; }
 
 
 	/**
@@ -155,7 +158,7 @@ public final class ColorSchemeAtom exten
 			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 exten
 	 */
 	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 exten
 	 * 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);
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java Mon Jan  2 00:55:49 2017
@@ -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 extend
         LittleEndian.putInt(_header, 4, _recdata.length);
     }
 
+    @Override
     public long getRecordType() {
         return RecordTypes.FontEntityAtom.typeID;
     }
@@ -103,7 +105,7 @@ public final class FontEntityAtom extend
 
 		// 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 extend
     /**
 	 * 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);
 	}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java Mon Jan  2 00:55:49 2017
@@ -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 exte
                 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);
             }
         }
         

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Mon Jan  2 00:55:49 2017
@@ -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

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Mon Jan  2 00:55:49 2017
@@ -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");
 //        }
 //    }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java Mon Jan  2 00:55:49 2017
@@ -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 Rec
 	/**
 	 * 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 Rec
 		 */
 		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

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Mon Jan  2 00:55:49 2017
@@ -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 ext
         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 ext
         try {
             updateRawContents();
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new HSLFException(e);
         }
     }
 
@@ -175,6 +180,7 @@ public final class StyleTextPropAtom ext
     /**
      * We are of type 4001
      */
+    @Override
     public long getRecordType() { return _type; }
 
 
@@ -182,6 +188,7 @@ public final class StyleTextPropAtom ext
      * 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 ext
      *  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 ext
      *
      * @return the string representation of the record data
      */
+    @Override
     public String toString(){
         StringBuffer out = new StringBuffer();
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java Mon Jan  2 00:55:49 2017
@@ -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 extend
      */
 	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 extend
 		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 extend
 	/**
 	 * 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);
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java Mon Jan  2 00:55:49 2017
@@ -112,7 +112,7 @@ public final class TextSpecInfoAtom exte
         try {
             sir.writeOut(bos);
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new HSLFException(e);
         }
         _data = bos.toByteArray();
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java Mon Jan  2 00:55:49 2017
@@ -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
 	/**
 	 * 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<Integer,Integer> oldToNewReferencesLookup) {
+	@Override
+    public void updateOtherRecordReferences(Map<Integer,Integer> oldToNewReferencesLookup) {
 		// Look up the new positions of our preceding UserEditAtomOffset
 		if(lastUserEditAtomOffset != 0) {
 			Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(lastUserEditAtomOffset));
 			if(newLocation == null) {
-				throw new RuntimeException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
+				throw new HSLFException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
 			}
 			lastUserEditAtomOffset = newLocation.intValue();
 		}
@@ -159,7 +162,7 @@ public final class UserEditAtom extends
 		// Ditto for our PersistPtr
 		Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(persistPointersOffset));
 		if(newLocation == null) {
-			throw new RuntimeException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
+			throw new HSLFException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
 		}
 		persistPointersOffset = newLocation.intValue();
 	}
@@ -168,7 +171,8 @@ public final class UserEditAtom extends
 	 * 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);
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java Mon Jan  2 00:55:49 2017
@@ -232,7 +232,9 @@ public final class HSLFFreeformShape ext
 
             it.next();
         }
-        if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);
+        if(!isClosed) {
+            segInfo.add(SEGMENTINFO_LINETO);
+        }
         segInfo.add(new byte[]{0x00, (byte)0x80});
 
         AbstractEscherOptRecord opt = getEscherOptRecord();
@@ -357,9 +359,11 @@ public final class HSLFFreeformShape ext
     }
     
     private void fillPoint(byte xyMaster[], double xyPoints[]) {
-        int masterCnt = (xyMaster == null) ? 0 : xyMaster.length;
-        int pointCnt = (xyPoints == null) ? 0 : xyPoints.length;
-        if ((masterCnt != 4 && masterCnt != 8) || pointCnt != 2) {
+        if (xyMaster == null || xyPoints == null) {
+            LOG.log(POILogger.WARN, "Master bytes or points not set - ignore point");
+            return;
+        }
+        if ((xyMaster.length != 4 && xyMaster.length != 8) || xyPoints.length != 2) {
             LOG.log(POILogger.WARN, "Invalid number of master bytes for a single point - ignore point");
             return;
         }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java Mon Jan  2 00:55:49 2017
@@ -166,7 +166,9 @@ public abstract class HSLFSimpleShape ex
         AbstractEscherOptRecord opt = getEscherOptRecord();
 
         EscherSimpleProperty p = getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
-        if(p != null && (p.getPropertyValue() & 0x8) == 0) return null;
+        if(p != null && (p.getPropertyValue() & 0x8) == 0) {
+            return null;
+        }
 
         Color clr = getColor(EscherProperties.LINESTYLE__COLOR, EscherProperties.LINESTYLE__OPACITY, -1);
         return clr == null ? null : clr;
@@ -179,7 +181,9 @@ public abstract class HSLFSimpleShape ex
         AbstractEscherOptRecord opt = getEscherOptRecord();
 
         EscherSimpleProperty p = getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
-        if(p != null && (p.getPropertyValue() & 0x8) == 0) return null;
+        if(p != null && (p.getPropertyValue() & 0x8) == 0) {
+            return null;
+        }
 
         Color clr = getColor(EscherProperties.LINESTYLE__BACKCOLOR, EscherProperties.LINESTYLE__OPACITY, -1);
         return clr == null ? null : clr;
@@ -319,7 +323,9 @@ public abstract class HSLFSimpleShape ex
         }
 
         name = name.replace("adj", "");
-        if ("".equals(name)) name = "1";
+        if ("".equals(name)) {
+            name = "1";
+        }
 
         short escherProp;
         switch (Integer.parseInt(name)) {
@@ -333,7 +339,7 @@ public abstract class HSLFSimpleShape ex
             case 8: escherProp = EscherProperties.GEOMETRY__ADJUST8VALUE; break;
             case 9: escherProp = EscherProperties.GEOMETRY__ADJUST9VALUE; break;
             case 10: escherProp = EscherProperties.GEOMETRY__ADJUST10VALUE; break;
-            default: throw new RuntimeException();
+            default: throw new HSLFException();
         }
 
         // TODO: the adjust values need to be corrected somehow depending on the shape width/height
@@ -392,9 +398,13 @@ public abstract class HSLFSimpleShape ex
     @Override
     public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
         AbstractEscherOptRecord opt = getEscherOptRecord();
-        if (opt == null) return null;
+        if (opt == null) {
+            return null;
+        }
         EscherProperty shadowType = opt.lookup(EscherProperties.SHADOWSTYLE__TYPE);
-        if (shadowType == null) return null;
+        if (shadowType == null) {
+            return null;
+        }
 
         return new Shadow<HSLFShape,HSLFTextParagraph>(){
             @Override

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Mon Jan  2 00:55:49 2017
@@ -25,6 +25,7 @@ import org.apache.poi.ddf.EscherContaine
 import org.apache.poi.ddf.EscherDgRecord;
 import org.apache.poi.ddf.EscherDggRecord;
 import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.model.Comment;
 import org.apache.poi.hslf.model.HeadersFooters;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
@@ -83,7 +84,7 @@ public final class HSLFSlide extends HSL
 		    // Grab text from SlideListWithTexts entries
 		    _paragraphs.addAll(HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords()));
 	        if (_paragraphs.isEmpty()) {
-	            throw new RuntimeException("No text records found for slide");
+	            throw new HSLFException("No text records found for slide");
 	        }
 		} else {
 			// No text on the slide, must just be pictures
@@ -91,7 +92,9 @@ public final class HSLFSlide extends HSL
 
 		// Grab text from slide's PPDrawing
 		for (List<HSLFTextParagraph> l : HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
-		    if (!_paragraphs.contains(l)) _paragraphs.add(l);
+		    if (!_paragraphs.contains(l)) {
+                _paragraphs.add(l);
+            }
 		}
 	}
 
@@ -153,6 +156,7 @@ public final class HSLFSlide extends HSL
      *  <li> set shapeId for the container descriptor and background
      * </p>
      */
+    @Override
     public void onCreate(){
         //initialize drawing group id
         EscherDggRecord dgg = getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
@@ -176,7 +180,9 @@ public final class HSLFSlide extends HSL
                 default:
                     break;
             }
-            if(spr != null) spr.setShapeId(allocateShapeId());
+            if(spr != null) {
+                spr.setShapeId(allocateShapeId());
+            }
         }
 
         //PPT doen't increment the number of saved shapes for group descriptor and background
@@ -213,7 +219,9 @@ public final class HSLFSlide extends HSL
 	@Override
 	public String getTitle(){
 		for (List<HSLFTextParagraph> tp : getTextParagraphs()) {
-		    if (tp.isEmpty()) continue;
+		    if (tp.isEmpty()) {
+                continue;
+            }
 			int type = tp.get(0).getRunType();
 			switch (type) {
     			case TextHeaderAtom.CENTER_TITLE_TYPE:
@@ -230,7 +238,8 @@ public final class HSLFSlide extends HSL
 	/**
 	 * Returns an array of all the TextRuns found
 	 */
-	public List<List<HSLFTextParagraph>> getTextParagraphs() { return _paragraphs; }
+	@Override
+    public List<List<HSLFTextParagraph>> getTextParagraphs() { return _paragraphs; }
 
 	/**
 	 * Returns the (public facing) page number of this slide
@@ -257,13 +266,18 @@ public final class HSLFSlide extends HSL
      *
      * @return the master sheet associated with this slide.
      */
-     public HSLFMasterSheet getMasterSheet(){
+     @Override
+    public HSLFMasterSheet getMasterSheet(){
         int masterId = getSlideRecord().getSlideAtom().getMasterID();
         for (HSLFSlideMaster sm : getSlideShow().getSlideMasters()) {
-            if (masterId == sm._getSheetNumber()) return sm;
+            if (masterId == sm._getSheetNumber()) {
+                return sm;
+            }
         }
         for (HSLFTitleMaster tm : getSlideShow().getTitleMasters()) {
-            if (masterId == tm._getSheetNumber()) return tm;
+            if (masterId == tm._getSheetNumber()) {
+                return tm;
+            }
         }
         return null;
     }
@@ -283,6 +297,7 @@ public final class HSLFSlide extends HSL
      * @param flag  <code>true</code> if the slide follows master,
      * <code>false</code> otherwise
      */
+    @Override
     public void setFollowMasterBackground(boolean flag){
         SlideAtom sa = getSlideRecord().getSlideAtom();
         sa.setFollowMasterBackground(flag);
@@ -294,6 +309,7 @@ public final class HSLFSlide extends HSL
      * @return <code>true</code> if the slide follows master background,
      * <code>false</code> otherwise
      */
+    @Override
     public boolean getFollowMasterBackground(){
         SlideAtom sa = getSlideRecord().getSlideAtom();
         return sa.getFollowMasterBackground();
@@ -305,6 +321,7 @@ public final class HSLFSlide extends HSL
      * @param flag  <code>true</code> if the slide draws master sheet objects,
      * <code>false</code> otherwise
      */
+    @Override
     public void setFollowMasterObjects(boolean flag){
         SlideAtom sa = getSlideRecord().getSlideAtom();
         sa.setFollowMasterObjects(flag);
@@ -338,6 +355,7 @@ public final class HSLFSlide extends HSL
      * @return <code>true</code> if the slide draws master sheet objects,
      * <code>false</code> otherwise
      */
+    @Override
     public boolean getFollowMasterObjects(){
         SlideAtom sa = getSlideRecord().getSlideAtom();
         return sa.getFollowMasterObjects();
@@ -346,7 +364,8 @@ public final class HSLFSlide extends HSL
     /**
      * Background for this slide.
      */
-     public HSLFBackground getBackground() {
+     @Override
+    public HSLFBackground getBackground() {
         if(getFollowMasterBackground()) {
             return getMasterSheet().getBackground();
         }
@@ -356,6 +375,7 @@ public final class HSLFSlide extends HSL
     /**
      * Color scheme for this slide.
      */
+    @Override
     public ColorSchemeAtom getColorScheme() {
         if(getFollowMasterScheme()){
             return getMasterSheet().getColorScheme();
@@ -425,6 +445,7 @@ public final class HSLFSlide extends HSL
         return new HeadersFooters(this, HeadersFootersContainer.SlideHeadersFootersContainer);
     }
 
+    @Override
     protected void onAddTextShape(HSLFTextShape shape) {
         List<HSLFTextParagraph> newParas = shape.getTextParagraphs();
         _paragraphs.add(newParas);
@@ -467,14 +488,13 @@ public final class HSLFSlide extends HSL
         draw.draw(graphics);
     }
     
+    @Override
     public boolean getFollowMasterColourScheme() {
-        // TODO Auto-generated method stub
         return false;
     }
 
+    @Override
     public void setFollowMasterColourScheme(boolean follow) {
-        // TODO Auto-generated method stub
-
     }
     
     @Override

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java Mon Jan  2 00:55:49 2017
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.NavigableMap;
 import java.util.TreeMap;
 
+import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
 import org.apache.poi.hslf.record.DocumentEncryptionAtom;
@@ -206,14 +207,8 @@ public class HSLFSlideShowEncrypted impl
         } catch (Exception e) {
             throw new EncryptedPowerPointFileException(e);
         } finally {
-            try {
-                if (ccis != null) {
-                    ccis.close();
-                }
-                lei.close();
-            } catch (IOException e) {
-                throw new EncryptedPowerPointFileException(e);
-            }
+            IOUtils.closeQuietly(ccis);
+            IOUtils.closeQuietly(lei);
         }
     }
 
@@ -465,7 +460,9 @@ public class HSLFSlideShowEncrypted impl
             recordMap.put(pdr.getLastOnDiskOffset(), r);
         }
 
-        assert(uea != null && pph != null && uea.getPersistPointersOffset() == pph.getLastOnDiskOffset());
+        if (uea == null || pph == null || uea.getPersistPointersOffset() != pph.getLastOnDiskOffset()) {
+            throw new EncryptedDocumentException("UserEditAtom and PersistPtrHolder must exist and their offset need to match.");
+        }
 
         recordMap.put(pph.getLastOnDiskOffset(), pph);
         recordMap.put(uea.getLastOnDiskOffset(), uea);
@@ -508,7 +505,9 @@ public class HSLFSlideShowEncrypted impl
             recordList.add(r);
         }
 
-        assert(ptr != null);
+        if (ptr == null || uea == null) {
+            throw new EncryptedDocumentException("UserEditAtom or PersistPtrholder not found.");
+        }
         if (deaSlideId == -1 && deaOffset == -1) {
             return records;
         }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java Mon Jan  2 00:55:49 2017
@@ -74,8 +74,12 @@ implements HSLFShapeContainer, TableShap
     protected HSLFTable(int numRows, int numCols, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(parent);
 
-        if(numRows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");
-        if(numCols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");
+        if(numRows < 1) {
+            throw new IllegalArgumentException("The number of rows must be greater than 1");
+        }
+        if(numCols < 1) {
+            throw new IllegalArgumentException("The number of columns must be greater than 1");
+        }
 
         double x=0, y=0, tblWidth=0, tblHeight=0;
         cells = new HSLFTableCell[numRows][numCols];
@@ -310,16 +314,16 @@ implements HSLFShapeContainer, TableShap
                     }
                 }
 
-                if (lfit < threshold) {
+                if (lfit < threshold && lline != null) {
                     tc.borderLeft = lline.l;
                 }
-                if (tfit < threshold) {
+                if (tfit < threshold && tline != null) {
                     tc.borderTop = tline.l;
                 }
-                if (rfit < threshold) {
+                if (rfit < threshold && rline != null) {
                     tc.borderRight = rline.l;
                 }
-                if (bfit < threshold) {
+                if (bfit < threshold && bline != null) {
                     tc.borderBottom = bline.l;
                 }
             }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1776896&r1=1776895&r2=1776896&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Mon Jan  2 00:55:49 2017
@@ -36,28 +36,7 @@ import org.apache.poi.hslf.model.textpro
 import org.apache.poi.hslf.model.textproperties.TextProp;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
-import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.hslf.record.EscherTextboxWrapper;
-import org.apache.poi.hslf.record.FontCollection;
-import org.apache.poi.hslf.record.InteractiveInfo;
-import org.apache.poi.hslf.record.MasterTextPropAtom;
-import org.apache.poi.hslf.record.OEPlaceholderAtom;
-import org.apache.poi.hslf.record.OutlineTextRefAtom;
-import org.apache.poi.hslf.record.PPDrawing;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordContainer;
-import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
-import org.apache.poi.hslf.record.SlideListWithText;
-import org.apache.poi.hslf.record.SlidePersistAtom;
-import org.apache.poi.hslf.record.StyleTextProp9Atom;
-import org.apache.poi.hslf.record.StyleTextPropAtom;
-import org.apache.poi.hslf.record.TextBytesAtom;
-import org.apache.poi.hslf.record.TextCharsAtom;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.record.TextRulerAtom;
-import org.apache.poi.hslf.record.TextSpecInfoAtom;
-import org.apache.poi.hslf.record.TxInteractiveInfoAtom;
+import org.apache.poi.hslf.record.*;
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.AutoNumberingScheme;
 import org.apache.poi.sl.usermodel.PaintStyle;
@@ -195,7 +174,9 @@ public final class HSLFTextParagraph imp
     private void supplySheet(HSLFSheet sheet) {
         this._sheet = sheet;
 
-        if (_runs == null) return;
+        if (_runs == null) {
+            return;
+        }
         for (HSLFTextRun rt : _runs) {
             rt.updateSheet();
         }
@@ -232,7 +213,9 @@ public final class HSLFTextParagraph imp
      * @param index
      */
     protected void setIndex(int index) {
-        if (_headerAtom != null) _headerAtom.setIndex(index);
+        if (_headerAtom != null) {
+            _headerAtom.setIndex(index);
+        }
     }
 
     /**
@@ -245,7 +228,9 @@ public final class HSLFTextParagraph imp
     }
 
     public void setRunType(int runType) {
-        if (_headerAtom != null) _headerAtom.setTextType(runType);
+        if (_headerAtom != null) {
+            _headerAtom.setTextType(runType);
+        }
     }
 
     /**
@@ -265,8 +250,12 @@ public final class HSLFTextParagraph imp
         if (_ruler == null) {
             _ruler = TextRulerAtom.getParagraphInstance();
             Record childAfter = _byteAtom;
-            if (childAfter == null) childAfter = _charAtom;
-            if (childAfter == null) childAfter = _headerAtom;
+            if (childAfter == null) {
+                childAfter = _charAtom;
+            }
+            if (childAfter == null) {
+                childAfter = _headerAtom;
+            }
             _headerAtom.getParentRecord().addChildAfter(_ruler, childAfter);
         }
         return _ruler;
@@ -290,7 +279,9 @@ public final class HSLFTextParagraph imp
 
         for (; startIdx[0] < records.length; startIdx[0]++) {
             Record r = records[startIdx[0]];
-            if (r instanceof TextHeaderAtom && (headerAtom == null || r == headerAtom)) break;
+            if (r instanceof TextHeaderAtom && (headerAtom == null || r == headerAtom)) {
+                break;
+            }
         }
 
         if (startIdx[0] >= records.length) {
@@ -301,7 +292,9 @@ public final class HSLFTextParagraph imp
         int length;
         for (length = 1; startIdx[0] + length < records.length; length++) {
             Record r = records[startIdx[0]+length];
-            if (r instanceof TextHeaderAtom || r instanceof SlidePersistAtom) break;
+            if (r instanceof TextHeaderAtom || r instanceof SlidePersistAtom) {
+                break;
+            }
         }
 
         Record result[] = new Record[length];
@@ -383,15 +376,17 @@ public final class HSLFTextParagraph imp
     @Override
     public void setTextAlign(TextAlign align) {
         Integer alignInt = null;
-        if (align != null) switch (align) {
-            default:
-            case LEFT: alignInt = TextAlignmentProp.LEFT;break;
-            case CENTER: alignInt = TextAlignmentProp.CENTER; break;
-            case RIGHT: alignInt = TextAlignmentProp.RIGHT; break;
-            case DIST: alignInt = TextAlignmentProp.DISTRIBUTED; break;
-            case JUSTIFY: alignInt = TextAlignmentProp.JUSTIFY; break;
-            case JUSTIFY_LOW: alignInt = TextAlignmentProp.JUSTIFYLOW; break;
-            case THAI_DIST: alignInt = TextAlignmentProp.THAIDISTRIBUTED; break;
+        if (align != null) {
+            switch (align) {
+                default:
+                case LEFT: alignInt = TextAlignmentProp.LEFT;break;
+                case CENTER: alignInt = TextAlignmentProp.CENTER; break;
+                case RIGHT: alignInt = TextAlignmentProp.RIGHT; break;
+                case DIST: alignInt = TextAlignmentProp.DISTRIBUTED; break;
+                case JUSTIFY: alignInt = TextAlignmentProp.JUSTIFY; break;
+                case JUSTIFY_LOW: alignInt = TextAlignmentProp.JUSTIFYLOW; break;
+                case THAI_DIST: alignInt = TextAlignmentProp.THAIDISTRIBUTED; break;
+            }
         }
         setParagraphTextPropVal("alignment", alignInt);
     }
@@ -399,7 +394,9 @@ public final class HSLFTextParagraph imp
     @Override
     public TextAlign getTextAlign() {
         TextProp tp = getPropVal(_paragraphStyle, "alignment", this);
-        if (tp == null) return null;
+        if (tp == null) {
+            return null;
+        }
         switch (tp.getValue()) {
             default:
             case TextAlignmentProp.LEFT: return TextAlign.LEFT;
@@ -415,7 +412,9 @@ public final class HSLFTextParagraph imp
     @Override
     public FontAlign getFontAlign() {
         TextProp tp = getPropVal(_paragraphStyle, FontAlignmentProp.NAME, this);
-        if (tp == null) return null;
+        if (tp == null) {
+            return null;
+        }
 
         switch (tp.getValue()) {
             case FontAlignmentProp.BASELINE: return FontAlign.BASELINE;
@@ -427,18 +426,26 @@ public final class HSLFTextParagraph imp
     }
 
     public AutoNumberingScheme getAutoNumberingScheme() {
-        if (styleTextProp9Atom == null) return null;
+        if (styleTextProp9Atom == null) {
+            return null;
+        }
         TextPFException9[] ant = styleTextProp9Atom.getAutoNumberTypes();
         int level = getIndentLevel();
-        if (ant == null || level == -1 || level  >= ant.length) return null;
+        if (ant == null || level == -1 || level  >= ant.length) {
+            return null;
+        }
         return ant[level].getAutoNumberScheme();
     }
 
     public Integer getAutoNumberingStartAt() {
-        if (styleTextProp9Atom == null) return null;
+        if (styleTextProp9Atom == null) {
+            return null;
+        }
         TextPFException9[] ant = styleTextProp9Atom.getAutoNumberTypes();
         int level = getIndentLevel();
-        if (ant == null || level  >= ant.length) return null;
+        if (ant == null || level  >= ant.length) {
+            return null;
+        }
         Short startAt = ant[level].getAutoNumberStartNumber();
         assert(startAt != null);
         return startAt.intValue();
@@ -447,7 +454,9 @@ public final class HSLFTextParagraph imp
 
     @Override
     public BulletStyle getBulletStyle() {
-        if (!isBullet() && getAutoNumberingScheme() == null) return null;
+        if (!isBullet() && getAutoNumberingScheme() == null) {
+            return null;
+        }
 
         return new BulletStyle() {
             @Override
@@ -537,7 +546,9 @@ public final class HSLFTextParagraph imp
 
     @Override
     public void setIndentLevel(int level) {
-       if( _paragraphStyle != null ) _paragraphStyle.setIndentLevel((short)level);
+       if( _paragraphStyle != null ) {
+        _paragraphStyle.setIndentLevel((short)level);
+    }
     }
 
     /**
@@ -638,7 +649,9 @@ public final class HSLFTextParagraph imp
     public String getBulletFont() {
         TextProp tp = getPropVal(_paragraphStyle, "bullet.font", this);
         boolean hasFont = getFlag(ParagraphFlagsTextProp.BULLET_HARDFONT_IDX);
-        if (tp == null || !hasFont) return getDefaultFontFamily();
+        if (tp == null || !hasFont) {
+            return getDefaultFontFamily();
+        }
         PPFont ppFont = getSheet().getSlideShow().getFont(tp.getValue());
         assert(ppFont != null);
         return ppFont.getFontName();
@@ -682,7 +695,9 @@ public final class HSLFTextParagraph imp
 
     private Double getPctOrPoints(String propName) {
         TextProp tp = getPropVal(_paragraphStyle, propName, this);
-        if (tp == null) return null;
+        if (tp == null) {
+            return null;
+        }
         int val = tp.getValue();
         return (val < 0) ? Units.masterToPoints(val) : val;
     }
@@ -739,7 +754,9 @@ public final class HSLFTextParagraph imp
         
         BitMaskTextProp maskProp = (BitMaskTextProp) props.findByName(ParagraphFlagsTextProp.NAME);
         boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0);
-        if (hardAttribute) return null;
+        if (hardAttribute) {
+            return null;
+        }
 
         HSLFSheet sheet = paragraph.getSheet();
         int txtype = paragraph.getRunType();
@@ -753,7 +770,9 @@ public final class HSLFTextParagraph imp
 
         for (String pn : propNames) {
             TextProp prop = master.getStyleAttribute(txtype, paragraph.getIndentLevel(), pn, isChar);
-            if (prop != null) return prop;
+            if (prop != null) {
+                return prop;
+            }
         }
 
         return null;
@@ -791,7 +810,7 @@ public final class HSLFTextParagraph imp
             }
             List<HSLFTextRun> ltr = p.getTextRuns();
             if (ltr.isEmpty()) {
-                throw new RuntimeException("paragraph without textruns found");
+                throw new HSLFException("paragraph without textruns found");
             }
             lastRun = ltr.get(ltr.size() - 1);
             assert (lastRun.getRawText() != null);
@@ -889,9 +908,13 @@ public final class HSLFTextParagraph imp
         int /* headerIdx = -1, */ textIdx = -1, styleIdx = -1;
         for (int i = 0; i < cr.length; i++) {
             Record r = cr[i];
-            if (r == headerAtom) ; // headerIdx = i;
-            else if (r == oldRecord || r == newRecord) textIdx = i;
-            else if (r == styleAtom) styleIdx = i;
+            if (r == headerAtom) {
+                ; // headerIdx = i;
+            } else if (r == oldRecord || r == newRecord) {
+                textIdx = i;
+            } else if (r == styleAtom) {
+                styleIdx = i;
+            }
         }
 
         if (textIdx == -1) {
@@ -957,7 +980,10 @@ public final class HSLFTextParagraph imp
             }
         }
 
-        assert (lastPTPC != null && lastRTPC != null && ptpc != null && rtpc != null);
+        if (lastPTPC == null || lastRTPC == null || ptpc == null || rtpc == null) {
+            throw new HSLFException("Not all TextPropCollection could be determined.");
+        }
+        
         ptpc.updateTextSize(ptpc.getCharactersCovered() + 1);
         rtpc.updateTextSize(rtpc.getCharactersCovered() + 1);
         lastPTPC.updateTextSize(lastPTPC.getCharactersCovered() + 1);
@@ -1025,7 +1051,7 @@ public final class HSLFTextParagraph imp
             try {
                 ((EscherTextboxWrapper) _txtbox).writeOut(null);
             } catch (IOException e) {
-                throw new RuntimeException("failed dummy write", e);
+                throw new HSLFException("failed dummy write", e);
             }
         }
     }
@@ -1183,7 +1209,9 @@ public final class HSLFTextParagraph imp
         List<List<HSLFTextParagraph>> runsV = new ArrayList<List<HSLFTextParagraph>>();
         for (EscherTextboxWrapper wrapper : ppdrawing.getTextboxWrappers()) {
             List<HSLFTextParagraph> p = findTextParagraphs(wrapper, sheet);
-            if (p != null) runsV.add(p);
+            if (p != null) {
+                runsV.add(p);
+            }
         }
         return runsV;
     }
@@ -1205,7 +1233,7 @@ public final class HSLFTextParagraph imp
         if (ota != null) {
             // if we are based on an outline, there are no further records to be parsed from the wrapper
             if (sheet == null) {
-                throw new RuntimeException("Outline atom reference can't be solved without a sheet record");
+                throw new HSLFException("Outline atom reference can't be solved without a sheet record");
             }
 
             List<List<HSLFTextParagraph>> sheetRuns = sheet.getTextParagraphs();
@@ -1213,9 +1241,13 @@ public final class HSLFTextParagraph imp
 
             int idx = ota.getTextIndex();
             for (List<HSLFTextParagraph> r : sheetRuns) {
-                if (r.isEmpty()) continue;
+                if (r.isEmpty()) {
+                    continue;
+                }
                 int ridx = r.get(0).getIndex();
-                if (ridx > idx) break;
+                if (ridx > idx) {
+                    break;
+                }
                 if (ridx == idx) {
                     if (rv == null) {
                         rv = r;
@@ -1251,7 +1283,7 @@ public final class HSLFTextParagraph imp
                 case 0: break; // nothing found
                 case 1: rv = rvl.get(0); break; // normal case
                 default:
-                    throw new RuntimeException("TextBox contains more than one list of paragraphs.");
+                    throw new HSLFException("TextBox contains more than one list of paragraphs.");
                 }
             }
         }
@@ -1302,7 +1334,9 @@ public final class HSLFTextParagraph imp
                 // don't search for RecordTypes.StyleTextPropAtom.typeID here ... see findStyleAtomPresent below
             }
 
-            if (header == null) break;
+            if (header == null) {
+                break;
+            }
 
             if (header.getParentRecord() instanceof SlideListWithText) {
                 // runs found in PPDrawing are not linked with SlideListWithTexts
@@ -1353,7 +1387,9 @@ public final class HSLFTextParagraph imp
         for (HSLFHyperlink h : links) {
             int csIdx = 0;
             for (HSLFTextParagraph p : paragraphs) {
-                if (csIdx > h.getEndIndex()) break;
+                if (csIdx > h.getEndIndex()) {
+                    break;
+                }
                 List<HSLFTextRun> runs = p.getTextRuns();
                 for (int rlen=0,rIdx=0; rIdx < runs.size(); csIdx+=rlen, rIdx++) {
                     HSLFTextRun run = runs.get(rIdx);
@@ -1443,7 +1479,9 @@ public final class HSLFTextParagraph imp
         int paraIdx = 0;
         for (TextPropCollection p : paraStyles) {
             for (int ccPara = 0, ccStyle = p.getCharactersCovered(); ccPara < ccStyle; paraIdx++) {
-                if (paraIdx >= paragraphs.size()) return;
+                if (paraIdx >= paragraphs.size()) {
+                    return;
+                }
                 HSLFTextParagraph htp = paragraphs.get(paraIdx);
                 TextPropCollection pCopy = new TextPropCollection(0, TextPropType.paragraph);
                 pCopy.copy(p);
@@ -1452,7 +1490,9 @@ public final class HSLFTextParagraph imp
                 for (HSLFTextRun trun : htp.getTextRuns()) {
                     len += trun.getLength();
                 }
-                if (paraIdx == paragraphs.size()-1) len++;
+                if (paraIdx == paragraphs.size()-1) {
+                    len++;
+                }
                 pCopy.updateTextSize(len);
                 ccPara += len;
             }
@@ -1463,7 +1503,9 @@ public final class HSLFTextParagraph imp
         int paraIdx = 0;
         for (IndentProp p : paraStyles) {
             for (int ccPara = 0, ccStyle = p.getCharactersCovered(); ccPara < ccStyle; paraIdx++) {
-                if (paraIdx >= paragraphs.size() || ccPara >= ccStyle-1) return;
+                if (paraIdx >= paragraphs.size() || ccPara >= ccStyle-1) {
+                    return;
+                }
                 HSLFTextParagraph para = paragraphs.get(paraIdx);
                 int len = 0;
                 for (HSLFTextRun trun : para.getTextRuns()) {
@@ -1517,7 +1559,9 @@ public final class HSLFTextParagraph imp
         switch (cidx) {
             // Background ... Accent 3 color
             case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
-                if (sheet == null) return null;
+                if (sheet == null) {
+                    return null;
+                }
                 ColorSchemeAtom ca = sheet.getColorScheme();
                 tmp = new Color(ca.getColor(cidx), true);
                 break;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message