diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakClear.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakClear.java index ec107931bc..8ad98905e0 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakClear.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakClear.java @@ -86,26 +86,25 @@ public enum BreakClear { private final int value; private BreakClear(int val) { - value = val; + value = val; } public int getValue() { - return value; + return value; } private static Map imap = new HashMap(); static { - for (BreakClear p : values()) { - imap.put(p.getValue(), p); - } + for (BreakClear p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static BreakClear valueOf(int type) { - BreakClear bType = imap.get(type); - if (bType == null) - throw new IllegalArgumentException("Unknown break clear type: " - + type); - return bType; + BreakClear bType = imap.get(new Integer(type)); + if (bType == null) + throw new IllegalArgumentException("Unknown break clear type: " + + type); + return bType; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakType.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakType.java index 97e9ad27de..60b35225b7 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakType.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/BreakType.java @@ -59,26 +59,25 @@ public enum BreakType { private final int value; private BreakType(int val) { - value = val; + value = val; } public int getValue() { - return value; + return value; } private static Map imap = new HashMap(); static { - for (BreakType p : values()) { - imap.put(p.getValue(), p); - } + for (BreakType p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static BreakType valueOf(int type) { - BreakType bType = imap.get(type); - if (bType == null) - throw new IllegalArgumentException("Unknown break type: " - + type); - return bType; + BreakType bType = imap.get(new Integer(type)); + if (bType == null) + throw new IllegalArgumentException("Unknown break type: " + + type); + return bType; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java index be77ff70de..166d8e7012 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java @@ -52,25 +52,24 @@ public enum LineSpacingRule { private final int value; private LineSpacingRule(int val) { - value = val; + value = val; } public int getValue() { - return value; + return value; } private static Map imap = new HashMap(); static { - for (LineSpacingRule p : values()) { - imap.put(p.getValue(), p); - } + for (LineSpacingRule p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static LineSpacingRule valueOf(int type) { - LineSpacingRule lineType = imap.get(type); - if (lineType == null) - throw new IllegalArgumentException("Unknown line type: " + type); - return lineType; + LineSpacingRule lineType = imap.get(new Integer(type)); + if (lineType == null) + throw new IllegalArgumentException("Unknown line type: " + type); + return lineType; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java index 2fd6acade0..0585ecb4c4 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java @@ -53,12 +53,12 @@ public enum ParagraphAlignment { private static Map imap = new HashMap(); static{ for (ParagraphAlignment p : values()) { - imap.put(p.getValue(), p); + imap.put(new Integer(p.getValue()), p); } } public static ParagraphAlignment valueOf(int type){ - ParagraphAlignment err = imap.get(type); + ParagraphAlignment err = imap.get(new Integer(type)); if(err == null) throw new IllegalArgumentException("Unknown paragraph alignment: " + type); return err; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java index 4bf1f86d12..b2a8c13c78 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java @@ -59,20 +59,19 @@ public enum TextAlignment { } public int getValue(){ - return value; + return value; } private static Map imap = new HashMap(); static{ - for (TextAlignment p : values()) { - imap.put(p.getValue(), p); - } + for (TextAlignment p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static TextAlignment valueOf(int type){ - TextAlignment align = imap.get(type); - if(align == null) throw new IllegalArgumentException("Unknown text alignment: " + type); - return align; + TextAlignment align = imap.get(new Integer(type)); + if(align == null) throw new IllegalArgumentException("Unknown text alignment: " + type); + return align; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java index a2d3682a4a..578dec3325 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java @@ -138,26 +138,25 @@ public enum UnderlinePatterns { private final int value; private UnderlinePatterns(int val) { - value = val; + value = val; } public int getValue() { - return value; + return value; } private static Map imap = new HashMap(); static { - for (UnderlinePatterns p : values()) { - imap.put(p.getValue(), p); - } + for (UnderlinePatterns p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static UnderlinePatterns valueOf(int type) { - UnderlinePatterns align = imap.get(type); - if (align == null) - throw new IllegalArgumentException("Unknown underline pattern: " - + type); - return align; + UnderlinePatterns align = imap.get(new Integer(type)); + if (align == null) + throw new IllegalArgumentException("Unknown underline pattern: " + + type); + return align; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java index 691d856c10..84ff628587 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java @@ -50,26 +50,25 @@ public enum VerticalAlign { private final int value; private VerticalAlign(int val) { - value = val; + value = val; } public int getValue() { - return value; + return value; } private static Map imap = new HashMap(); static { - for (VerticalAlign p : values()) { - imap.put(p.getValue(), p); - } + for (VerticalAlign p : values()) { + imap.put(new Integer(p.getValue()), p); + } } public static VerticalAlign valueOf(int type) { - VerticalAlign align = imap.get(type); - if (align == null) - throw new IllegalArgumentException("Unknown vertical alignment: " - + type); - return align; + VerticalAlign align = imap.get(new Integer(type)); + if (align == null) + throw new IllegalArgumentException("Unknown vertical alignment: " + + type); + return align; } - } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 7a34c7e5ba..a1f23cef8f 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -583,35 +583,39 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { return false; } + + private int getPosOfBodyElement(IBodyElement needle) { + BodyElementType type = needle.getElementType(); + IBodyElement current; + for(int i=0; i