You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/12/22 21:44:48 UTC

svn commit: r1871911 [14/15] - in /poi/trunk/src: integrationtest/org/apache/poi/ integrationtest/org/apache/poi/hssf/usermodel/ java/org/apache/poi/common/ java/org/apache/poi/ddf/ java/org/apache/poi/hssf/eventusermodel/dummyrecord/ java/org/apache/p...

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPenStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPenStyle.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPenStyle.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfPenStyle.java Sun Dec 22 21:44:45 2019
@@ -23,10 +23,28 @@ public class HemfPenStyle extends HwmfPe
 
     private float[] dashPattern;
 
+    public HemfPenStyle(int flag) {
+        super(flag);
+    }
+
+    public HemfPenStyle(HemfPenStyle other) {
+        super(other);
+        dashPattern = (other.dashPattern == null) ? null : other.dashPattern.clone();
+    }
+
+    public static HemfPenStyle valueOf(
+            HwmfLineCap cap, HwmfLineJoin join, HwmfLineDash dash, boolean isAlternateDash, boolean isGeometric) {
+        int flag = 0;
+        flag = SUBSECTION_DASH.setValue(flag, dash.wmfFlag);
+        flag = SUBSECTION_ENDCAP.setValue(flag, cap.wmfFlag);
+        flag = SUBSECTION_JOIN.setValue(flag, join.wmfFlag);
+        flag = SUBSECTION_ALTERNATE.setBoolean(flag, isAlternateDash);
+        flag = SUBSECTION_GEOMETRIC.setBoolean(flag, isGeometric);
+        return new HemfPenStyle(flag);
+    }
+
     public static HemfPenStyle valueOf(int flag) {
-        HemfPenStyle ps = new HemfPenStyle();
-        ps.flag = flag;
-        return ps;
+        return new HemfPenStyle(flag);
     }
 
     @Override
@@ -39,7 +57,7 @@ public class HemfPenStyle extends HwmfPe
     }
 
     @Override
-    public HemfPenStyle clone() {
-        return (HemfPenStyle)super.clone();
+    public HemfPenStyle copy() {
+        return new HemfPenStyle(this);
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emfplus/HemfPlusPen.java Sun Dec 22 21:44:45 2019
@@ -34,13 +34,16 @@ import java.util.function.Supplier;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.hemf.draw.HemfDrawProperties;
 import org.apache.poi.hemf.draw.HemfGraphics;
+import org.apache.poi.hemf.record.emf.HemfPenStyle;
 import org.apache.poi.hemf.record.emfplus.HemfPlusBrush.EmfPlusBrush;
 import org.apache.poi.hemf.record.emfplus.HemfPlusDraw.EmfPlusUnitType;
 import org.apache.poi.hemf.record.emfplus.HemfPlusHeader.EmfPlusGraphicsVersion;
 import org.apache.poi.hemf.record.emfplus.HemfPlusObject.EmfPlusObjectData;
 import org.apache.poi.hemf.record.emfplus.HemfPlusObject.EmfPlusObjectType;
 import org.apache.poi.hemf.record.emfplus.HemfPlusPath.EmfPlusPath;
-import org.apache.poi.hwmf.record.HwmfPenStyle;
+import org.apache.poi.hwmf.record.HwmfPenStyle.HwmfLineCap;
+import org.apache.poi.hwmf.record.HwmfPenStyle.HwmfLineDash;
+import org.apache.poi.hwmf.record.HwmfPenStyle.HwmfLineJoin;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.Internal;
@@ -506,55 +509,45 @@ public class HemfPlusPen {
 
             brush.applyPen(ctx, continuedObjectData);
             prop.setPenWidth(penWidth);
-            prop.setPenStyle(new HwmfPenStyle(){
-                @Override
-                public HwmfLineCap getLineCap() {
-                    // ignore endCap for now
-                    switch(startCap) {
-                        default:
-                        case FLAT:
-                            return HwmfLineCap.FLAT;
-                        case ROUND:
-                            return HwmfLineCap.ROUND;
-                        case SQUARE:
-                            return HwmfLineCap.SQUARE;
-                    }
-                }
 
-                @Override
-                public HwmfLineJoin getLineJoin() {
-                    switch (join) {
-                        default:
-                        case BEVEL:
-                            return HwmfLineJoin.BEVEL;
-                        case ROUND:
-                            return HwmfLineJoin.ROUND;
-                        case MITER_CLIPPED:
-                        case MITER:
-                            return HwmfLineJoin.MITER;
-                    }
-                }
+            HwmfLineCap cap;
+            // ignore endCap for now
+            switch(startCap) {
+                default:
+                case FLAT:
+                    cap = HwmfLineCap.FLAT;
+                    break;
+                case ROUND:
+                    cap = HwmfLineCap.ROUND;
+                    break;
+                case SQUARE:
+                    cap = HwmfLineCap.SQUARE;
+                    break;
+            }
+
+            HwmfLineJoin lineJoin;
+            switch (join) {
+                default:
+                case BEVEL:
+                    lineJoin = HwmfLineJoin.BEVEL;
+                    break;
+                case ROUND:
+                    lineJoin = HwmfLineJoin.ROUND;
+                    break;
+                case MITER_CLIPPED:
+                case MITER:
+                    lineJoin = HwmfLineJoin.MITER;
+                    break;
+            }
+
+            HwmfLineDash lineDash = (dashedLineData == null) ? HwmfLineDash.SOLID : HwmfLineDash.USERSTYLE;
+
+            boolean isAlternate = (lineDash != HwmfLineDash.SOLID && dashOffset != null && dashOffset == 0);
+            boolean isGeometric = (unitType == EmfPlusUnitType.World || unitType == EmfPlusUnitType.Display);
+            HemfPenStyle penStyle = HemfPenStyle.valueOf(cap, lineJoin, lineDash, isAlternate, isGeometric);
+            penStyle.setLineDashes(dashedLineData);
 
-                @Override
-                public HwmfLineDash getLineDash() {
-                    return dashedLineData == null ? HwmfLineDash.SOLID : HwmfLineDash.USERSTYLE;
-                }
-
-                @Override
-                public float[] getLineDashes() {
-                    return dashedLineData;
-                }
-
-                @Override
-                public boolean isAlternateDash() {
-                    return (getLineDash() != HwmfLineDash.SOLID && dashOffset != null && dashOffset == 0);
-                }
-
-                @Override
-                public boolean isGeometric() {
-                    return (unitType == EmfPlusUnitType.World || unitType == EmfPlusUnitType.Display);
-                }
-            });
+            prop.setPenStyle(penStyle);
         }
 
         @Override

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java Sun Dec 22 21:44:45 2019
@@ -25,17 +25,18 @@ import java.util.function.Supplier;
 import org.apache.poi.util.GenericRecordUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
+import org.apache.poi.util.Removal;
 
-/** 
- * Definition of a special kind of property of some text, or its 
- *  paragraph. For these properties, a flag in the "contains" header 
+/**
+ * Definition of a special kind of property of some text, or its
+ *  paragraph. For these properties, a flag in the "contains" header
  *  field tells you the data property family will exist. The value
  *  of the property is itself a mask, encoding several different
  *  (but related) properties
  */
-public abstract class BitMaskTextProp extends TextProp implements Cloneable {
+public abstract class BitMaskTextProp extends TextProp {
     protected static final POILogger logger = POILogFactory.getLogger(BitMaskTextProp.class);
-    
+
     private String[] subPropNames;
 	private int[] subPropMasks;
 	private boolean[] subPropMatches;
@@ -45,20 +46,33 @@ public abstract class BitMaskTextProp ex
 	/** Fetch the list of if the sub properties match or not */
 	public boolean[] getSubPropMatches() { return subPropMatches; }
 
+
+	protected BitMaskTextProp(BitMaskTextProp other) {
+		super(other);
+		subPropNames = (other.subPropNames == null) ? null : other.subPropNames.clone();
+		subPropMasks = (other.subPropMasks == null) ? null : other.subPropMasks.clone();
+
+		// The old clone implementation didn't carry over matches, but keep everything else as it was
+		// this is failing unit tests
+		// subPropMatches = (other.subPropMatches == null) ? null : new boolean[other.subPropMatches.length];
+		subPropMatches = (other.subPropMatches == null) ? null : other.subPropMatches.clone();
+	}
+
+
 	protected BitMaskTextProp(int sizeOfDataBlock, int maskInHeader, String overallName, String... subPropNames) {
 		super(sizeOfDataBlock,maskInHeader,overallName);
 		this.subPropNames = subPropNames;
 		subPropMasks = new int[subPropNames.length];
 		subPropMatches = new boolean[subPropNames.length];
-		
+
 		int LSB = Integer.lowestOneBit(maskInHeader);
-		
+
 		// Initialise the masks list
 		for(int i=0; i<subPropMasks.length; i++) {
 			subPropMasks[i] = (LSB << i);
 		}
 	}
-	
+
 	/**
 	 * Calculate mask from the subPropMatches.
 	 */
@@ -68,7 +82,7 @@ public abstract class BitMaskTextProp ex
 	     * The dataValue can't be taken as a mask, as sometimes certain properties
 	     * are explicitly set to false, i.e. the mask says the property is defined
 	     * but in the actually nibble the property is set to false
-	     */ 
+	     */
 	    int mask = 0, i = 0;
 	    for (int subMask : subPropMasks) {
 	        if (subPropMatches[i++]) mask |= subMask;
@@ -91,7 +105,7 @@ public abstract class BitMaskTextProp ex
 	/**
 	 * Return the text property value.
 	 * Clears all bits of the value, which are marked as unset.
-	 * 
+	 *
 	 * @return the text property value.
 	 */
 	@Override
@@ -108,14 +122,14 @@ public abstract class BitMaskTextProp ex
         }
         return val;
 	}
-	
+
 	/**
 	 * Set the value of the text property, and recompute the sub
 	 * properties based on it, i.e. all unset subvalues will be cleared.
-	 * Use {@link #setSubValue(boolean, int)} to explicitly set subvalues to {@code false}. 
+	 * Use {@link #setSubValue(boolean, int)} to explicitly set subvalues to {@code false}.
 	 */
 	@Override
-	public void setValue(int val) { 
+	public void setValue(int val) {
 		super.setValue(val);
 
 		// Figure out the values of the sub properties
@@ -149,7 +163,7 @@ public abstract class BitMaskTextProp ex
 	        }
 	    }
 	}
-	
+
 	/**
 	 * Fetch the true/false status of the subproperty with the given index
 	 */
@@ -170,20 +184,24 @@ public abstract class BitMaskTextProp ex
         }
         super.setValue(newVal);
 	}
-	
+
 	@Override
-	public BitMaskTextProp clone(){
-		BitMaskTextProp newObj = (BitMaskTextProp)super.clone();
-		
-		// Don't carry over matches, but keep everything 
-		//  else as it was
-		newObj.subPropMatches = new boolean[subPropMatches.length];
-		
-		return newObj;
-	}
-	
-    public BitMaskTextProp cloneAll(){
-        return (BitMaskTextProp)super.clone();
+	@SuppressWarnings("squid:S2975")
+	@Deprecated
+	@Removal(version = "5.0.0")
+	public BitMaskTextProp clone() {
+		return copy();
+	}
+
+	/**
+	 * @return an identical copy of this, i.e. also the subPropMatches are copied
+	 */
+	public BitMaskTextProp cloneAll(){
+		BitMaskTextProp bmtp = copy();
+		if (subPropMatches != null) {
+			System.arraycopy(subPropMatches, 0, bmtp.subPropMatches, 0, subPropMatches.length);
+		}
+		return bmtp;
     }
 
 	@Override
@@ -193,4 +211,7 @@ public abstract class BitMaskTextProp ex
 			"flags", getBitsAsString(this::getValue, subPropMasks, subPropNames)
 		);
 	}
+
+	@Override
+	public abstract BitMaskTextProp copy();
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/CharFlagsTextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/CharFlagsTextProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/CharFlagsTextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/CharFlagsTextProp.java Sun Dec 22 21:44:45 2019
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hslf.model.textproperties;
 
-/** 
+/**
  * Definition for the common character text property bitset, which
  *  handles bold/italic/underline etc.
  */
@@ -43,7 +43,7 @@ public class CharFlagsTextProp extends B
 			"fehint",               // 0x0020  A bit that specifies whether characters originated from double-byte input.
 			"unused2",              // 0x0040  Undefined and MUST be ignored.
 			"kumi",                 // 0x0080  A bit that specifies whether Kumimoji are used for vertical text.
-			"strikethrough",        // 0x0100  aka "unused3" - sometimes contains the strikethrough flag 
+			"strikethrough",        // 0x0100  aka "unused3" - sometimes contains the strikethrough flag
 			"emboss",               // 0x0200  A bit that specifies whether the characters are embossed.
             "pp9rt_1",              // 0x0400  An unsigned integer that specifies the run grouping of additional text properties in StyleTextProp9Atom record.
             "pp9rt_2",              // 0x0800
@@ -53,4 +53,13 @@ public class CharFlagsTextProp extends B
             "unused4_2"             // 0x8000  Undefined and MUST be ignored.
 		);
 	}
+
+	public CharFlagsTextProp(CharFlagsTextProp other) {
+		super(other);
+	}
+
+	@Override
+	public CharFlagsTextProp copy() {
+		return new CharFlagsTextProp(this);
+	}
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java Sun Dec 22 21:44:45 2019
@@ -27,7 +27,7 @@ import org.apache.poi.util.GenericRecord
  * Definition for the font alignment property.
  */
 public class FontAlignmentProp extends TextProp {
-    public static final String NAME = "fontAlign";
+	public static final String NAME = "fontAlign";
 	public static final int BASELINE = 0;
 	public static final int TOP = 1;
 	public static final int CENTER = 2;
@@ -37,6 +37,10 @@ public class FontAlignmentProp extends T
 		super(2, 0x10000, NAME);
 	}
 
+	public FontAlignmentProp(FontAlignmentProp other) {
+		super(other);
+	}
+
 	public FontAlign getFontAlign() {
 		switch (getValue()) {
 			default:
@@ -59,4 +63,9 @@ public class FontAlignmentProp extends T
 			"fontAlign", this::getFontAlign
 		);
 	}
+
+	@Override
+	public FontAlignmentProp copy() {
+		return new FontAlignmentProp(this);
+	}
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStop.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStop.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStop.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStop.java Sun Dec 22 21:44:45 2019
@@ -20,21 +20,23 @@ package org.apache.poi.hslf.model.textpr
 import java.util.Map;
 import java.util.function.Supplier;
 
+import org.apache.poi.common.Duplicatable;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.sl.usermodel.TabStop;
 import org.apache.poi.util.GenericRecordUtil;
 import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
 import org.apache.poi.util.Units;
 
 @Internal
-public class HSLFTabStop implements TabStop, Cloneable, GenericRecord {
+public class HSLFTabStop implements TabStop, Duplicatable, GenericRecord {
     /**
      * A signed integer that specifies an offset, in master units, of the tab stop.
-     * 
+     *
      * If the TextPFException record that contains this TabStop structure also contains a
      * leftMargin, then the value of position is relative to the left margin of the paragraph;
      * otherwise, the value is relative to the left side of the paragraph.
-     * 
+     *
      * If a TextRuler record contains this TabStop structure, the value is relative to the
      * left side of the text ruler.
      */
@@ -50,14 +52,19 @@ public class HSLFTabStop implements TabS
         this.type = type;
     }
 
+    public HSLFTabStop(HSLFTabStop other) {
+        position = other.position;
+        type = other.type;
+    }
+
     public int getPosition() {
         return position;
     }
-    
+
     public void setPosition(final int position) {
         this.position = position;
     }
-    
+
     @Override
     public double getPositionInPoints() {
         return Units.masterToPoints(getPosition());
@@ -79,14 +86,18 @@ public class HSLFTabStop implements TabS
     }
 
     @Override
+    @SuppressWarnings("squid:S2975")
+    @Deprecated
+    @Removal(version = "5.0.0")
     public HSLFTabStop clone() {
-        try {
-            return (HSLFTabStop)super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new IllegalStateException(e);
-        }
+        return copy();
     }
-    
+
+    @Override
+    public HSLFTabStop copy() {
+        return new HSLFTabStop(this);
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStopPropCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStopPropCollection.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStopPropCollection.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStopPropCollection.java Sun Dec 22 21:44:45 2019
@@ -31,6 +31,7 @@ import org.apache.poi.util.LittleEndianC
 import org.apache.poi.util.LittleEndianInput;
 import org.apache.poi.util.LittleEndianOutput;
 import org.apache.poi.util.LittleEndianOutputStream;
+import org.apache.poi.util.Removal;
 
 /**
  * Container for tabstop lists
@@ -38,20 +39,18 @@ import org.apache.poi.util.LittleEndianO
 @Internal
 public class HSLFTabStopPropCollection extends TextProp {
     public static final String NAME = "tabStops";
-    
+
     private final List<HSLFTabStop> tabStops = new ArrayList<>();
-    
+
     public HSLFTabStopPropCollection() {
         super(0, 0x100000, NAME);
     }
-    
-    public HSLFTabStopPropCollection(final HSLFTabStopPropCollection copy) {
-        super(0, copy.getMask(), copy.getName());
-        for (HSLFTabStop ts : copy.tabStops) {
-            tabStops.add(ts.clone());
-        }
+
+    public HSLFTabStopPropCollection(final HSLFTabStopPropCollection other) {
+        super(other);
+        other.tabStops.stream().map(HSLFTabStop::copy).forEach(tabStops::add);
     }
-    
+
     /**
      * Parses the tabstops from TxMasterStyle record
      *
@@ -61,7 +60,7 @@ public class HSLFTabStopPropCollection e
     public void parseProperty(byte[] data, int offset) {
         tabStops.addAll(readTabStops(new LittleEndianByteArrayInputStream(data, offset)));
     }
-    
+
     public static List<HSLFTabStop> readTabStops(final LittleEndianInput lei) {
         final int count = lei.readUShort();
         final List<HSLFTabStop> tabs = new ArrayList<>(count);
@@ -72,7 +71,7 @@ public class HSLFTabStopPropCollection e
         }
         return tabs;
     }
-    
+
 
     public void writeProperty(OutputStream out) {
         writeTabStops(new LittleEndianOutputStream(out), tabStops);
@@ -85,18 +84,18 @@ public class HSLFTabStopPropCollection e
             leo.writeShort(ts.getPosition());
             leo.writeShort(ts.getType().nativeId);
         }
-        
+
     }
-    
+
     @Override
     public int getValue() { return tabStops.size(); }
 
-    
+
     @Override
     public int getSize() {
         return LittleEndianConsts.SHORT_SIZE + tabStops.size()*LittleEndianConsts.INT_SIZE;
     }
-    
+
     public List<HSLFTabStop> getTabStops() {
         return tabStops;
     }
@@ -104,13 +103,21 @@ public class HSLFTabStopPropCollection e
     public void clearTabs() {
         tabStops.clear();
     }
-    
+
     public void addTabStop(HSLFTabStop ts) {
         tabStops.add(ts);
     }
-    
+
     @Override
+    @SuppressWarnings("squid:S2975")
+    @Deprecated
+    @Removal(version = "5.0.0")
     public HSLFTabStopPropCollection clone() {
+        return copy();
+    }
+
+    @Override
+    public HSLFTabStopPropCollection copy() {
         return new HSLFTabStopPropCollection(this);
     }
 
@@ -134,7 +141,7 @@ public class HSLFTabStopPropCollection e
 
         return tabStops.equals(other.tabStops);
     }
-    
+
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder(super.toString());
@@ -150,7 +157,7 @@ public class HSLFTabStopPropCollection e
             isFirst = false;
         }
         sb.append(" ]");
-        
+
         return sb.toString();
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ParagraphFlagsTextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ParagraphFlagsTextProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ParagraphFlagsTextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ParagraphFlagsTextProp.java Sun Dec 22 21:44:45 2019
@@ -38,4 +38,13 @@ public final class ParagraphFlagsTextPro
             "bullet.hardsize"
 		);
 	}
+
+	public ParagraphFlagsTextProp(ParagraphFlagsTextProp other) {
+		super(other);
+	}
+
+	@Override
+	public ParagraphFlagsTextProp copy() {
+		return new ParagraphFlagsTextProp(this);
+	}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java Sun Dec 22 21:44:45 2019
@@ -32,35 +32,35 @@ public class TextAlignmentProp extends T
 	 * For vertical text, top aligned.
 	 */
     public static final int LEFT = 0;
-    
+
     /**
      * For horizontal text, centered.
      * For vertical text, middle aligned.
      */
 	public static final int CENTER = 1;
-	
+
 	/**
 	 * For horizontal text, right aligned.
 	 * For vertical text, bottom aligned.
 	 */
 	public static final int RIGHT = 2;
-	
+
 	/**
 	 * For horizontal text, flush left and right.
 	 * For vertical text, flush top and bottom.
 	 */
 	public static final int JUSTIFY = 3;
-	
+
 	/**
 	 * Distribute space between characters.
 	 */
 	public static final int DISTRIBUTED = 4;
-	
+
 	/**
 	 * Thai distribution justification.
 	 */
 	public static final int THAIDISTRIBUTED = 5;
-	
+
 	/**
 	 * Kashida justify low.
 	 */
@@ -70,6 +70,11 @@ public class TextAlignmentProp extends T
 		super(2, 0x800, "alignment");
 	}
 
+
+	public TextAlignmentProp(TextAlignmentProp other) {
+		super(other);
+	}
+
 	public TextAlign getTextAlign() {
 		switch (getValue()) {
 			default:
@@ -95,4 +100,9 @@ public class TextAlignmentProp extends T
 			"textAlign", this::getTextAlign
 		);
 	}
+
+	@Override
+	public TextAlignmentProp copy() {
+		return new TextAlignmentProp(this);
+	}
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextProp.java Sun Dec 22 21:44:45 2019
@@ -19,29 +19,32 @@ package org.apache.poi.hslf.model.textpr
 
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 import java.util.function.Supplier;
 
+import org.apache.poi.common.Duplicatable;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.util.GenericRecordUtil;
+import org.apache.poi.util.Removal;
 
-/** 
- * Definition of a property of some text, or its paragraph. Defines 
- * how to find out if it's present (via the mask on the paragraph or 
- * character "contains" header field), how long the value of it is, 
+/**
+ * Definition of a property of some text, or its paragraph. Defines
+ * how to find out if it's present (via the mask on the paragraph or
+ * character "contains" header field), how long the value of it is,
  * and how to get and set the value.
- * 
+ *
  * As the exact form of these (such as mask value, size of data
  *  block etc) is different for StyleTextProps and
  *  TxMasterTextProps, the definitions of the standard
- *  TextProps is stored in the different record classes 
+ *  TextProps is stored in the different record classes
  */
-public class TextProp implements Cloneable, GenericRecord {
+public class TextProp implements Duplicatable, GenericRecord {
 	private int sizeOfDataBlock; // Number of bytes the data part uses
 	private String propName;
 	private int dataValue;
 	private int maskInHeader;
 
-	/** 
+	/**
 	 * Generate the definition of a given type of text property.
 	 */
 	public TextProp(int sizeOfDataBlock, int maskInHeader, String propName) {
@@ -60,7 +63,7 @@ public class TextProp implements Cloneab
 	    this.propName = other.propName;
 	    this.dataValue = other.dataValue;
 	}
-	
+
 	/**
 	 * Name of the text property
 	 */
@@ -78,7 +81,7 @@ public class TextProp implements Cloneab
 	public int getMask() { return maskInHeader; }
 	/**
 	 * Get the mask that's used at write time. Only differs from
-	 *  the result of getMask() for the mask based properties 
+	 *  the result of getMask() for the mask based properties
 	 */
 	public int getWriteMask() { return getMask(); }
 
@@ -93,27 +96,27 @@ public class TextProp implements Cloneab
 	 */
 	public void setValue(int val) { dataValue = val; }
 
+	@Override
+	@SuppressWarnings("squid:S2975")
+	@Deprecated
+	@Removal(version = "5.0.0")
+	public TextProp clone() {
+		return copy();
+	}
+
 	/**
 	 * Clone, eg when you want to actually make use of one of these.
 	 */
 	@Override
-	public TextProp clone(){
-		try {
-			return (TextProp)super.clone();
-		} catch(CloneNotSupportedException e) {
-			throw new IllegalStateException(e);
-		}
+	public TextProp copy(){
+		// subclasses need to override copy()
+		assert(TextProp.class.equals(this.getClass()));
+		return new TextProp(this);
 	}
-	
+
 	@Override
 	public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + dataValue;
-        result = prime * result + maskInHeader;
-        result = prime * result + ((propName == null) ? 0 : propName.hashCode());
-        result = prime * result + sizeOfDataBlock;
-        return result;
+		return Objects.hash(dataValue, maskInHeader, propName, sizeOfDataBlock);
     }
 
 	@Override
@@ -146,7 +149,7 @@ public class TextProp implements Cloneab
         }
         return true;
     }
-    
+
     @Override
     public String toString() {
         int len;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java Sun Dec 22 21:44:45 2019
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.function.Supplier;
 
+import org.apache.poi.common.Duplicatable;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.record.StyleTextPropAtom;
@@ -42,9 +43,9 @@ import org.apache.poi.util.POILogger;
  * Used to hold the number of characters affected, the list of active
  *  properties, and the indent level if required.
  */
-public class TextPropCollection implements GenericRecord {
+public class TextPropCollection implements GenericRecord, Duplicatable {
     private static final POILogger LOG = POILogFactory.getLogger(TextPropCollection.class);
-    
+
     /** All the different kinds of paragraph properties we might handle */
     private static final TextProp[] paragraphTextPropTypes = {
         // TextProp order is according to 2.9.20 TextPFException,
@@ -72,7 +73,7 @@ public class TextPropCollection implemen
         new TextProp(0, 0x2000000, "hasBulletScheme"), // TODO: check size
         // 0xFC000000 MUST be zero and MUST be ignored
     };
-    
+
     /** All the different kinds of character properties we might handle */
     private static final TextProp[] characterTextPropTypes = new TextProp[] {
         new TextProp(0, 0x100000, "pp10ext"),
@@ -92,16 +93,16 @@ public class TextPropCollection implemen
     public enum TextPropType {
         paragraph, character
     }
-    
+
     private int charactersCovered;
-	
+
     // indentLevel is only valid for paragraph collection
     // if it's set to -1, it must be omitted - see 2.9.36 TextMasterStyleLevel
     private short indentLevel;
 	private final Map<String,TextProp> textProps = new HashMap<>();
     private int maskSpecial;
     private final TextPropType textPropType;
-    
+
     /**
      * Create a new collection of text properties (be they paragraph
      *  or character) which will be groked via a subsequent call to
@@ -112,6 +113,14 @@ public class TextPropCollection implemen
         this.textPropType = textPropType;
     }
 
+    public TextPropCollection(TextPropCollection other) {
+        charactersCovered = other.charactersCovered;
+        indentLevel = other.indentLevel;
+        maskSpecial = other.maskSpecial;
+        textPropType = other.textPropType;
+        other.textProps.forEach((k,v) -> textProps.put(k, v.copy()));
+    }
+
     public int getSpecialMask() {
         return maskSpecial;
     }
@@ -132,7 +141,7 @@ public class TextPropCollection implemen
         }
 	    return orderedList;
     }
-	
+
 	/** Fetch the TextProp with this name, or null if it isn't present */
 	@SuppressWarnings("unchecked")
     public final <T extends TextProp> T findByName(String textPropName) {
@@ -143,18 +152,18 @@ public class TextPropCollection implemen
 	public final <T extends TextProp> T removeByName(String name) {
 	    return (T)textProps.remove(name);
 	}
-	
+
 	public final TextPropType getTextPropType() {
 	    return textPropType;
 	}
-	
+
 	private TextProp[] getPotentialProperties() {
 	    return (textPropType == TextPropType.paragraph) ? paragraphTextPropTypes : characterTextPropTypes;
 	}
 
 	/**
 	 * Checks the paragraph or character properties for the given property name.
-	 * Throws a HSLFException, if the name doesn't belong into this set of properties 
+	 * Throws a HSLFException, if the name doesn't belong into this set of properties
 	 *
 	 * @param name the property name
 	 * @return if found, the property template to copy from
@@ -166,21 +175,21 @@ public class TextPropCollection implemen
                 return (T)tp;
             }
         }
-       String errStr = 
+       String errStr =
            "No TextProp with name " + name + " is defined to add from. " +
            "Character and paragraphs have their own properties/names.";
-       throw new HSLFException(errStr);       
+       throw new HSLFException(errStr);
 	}
-	
+
     /** Add the TextProp with this name to the list */
     @SuppressWarnings("unchecked")
     public final <T extends TextProp> T addWithName(final String name) {
         // Find the base TextProp to base on
         T existing = findByName(name);
         if (existing != null) return existing;
-        
+
         // Add a copy of this property
-        T textProp = (T)validatePropName(name).clone();
+        T textProp = (T)validatePropName(name).copy();
         textProps.put(name,textProp);
         return textProp;
     }
@@ -197,12 +206,12 @@ public class TextPropCollection implemen
 
 	    String propName = textProp.getName();
 	    validatePropName(propName);
-	    
+
 	    textProps.put(propName, textProp);
 	}
 
 	/**
-	 * For an existing set of text properties, build the list of 
+	 * For an existing set of text properties, build the list of
 	 *  properties coded for in a given run of properties.
 	 * @return the number of bytes that were used encoding the properties list
 	 */
@@ -224,7 +233,7 @@ public class TextPropCollection implemen
                 }
 
 				// Bingo, data contains this property
-				TextProp prop = tp.clone();
+				TextProp prop = tp.copy();
 				int val = 0;
 				if (prop instanceof HSLFTabStopPropCollection) {
                     ((HSLFTabStopPropCollection)prop).parseProperty(data, dataOffset+bytesPassed);
@@ -237,7 +246,7 @@ public class TextPropCollection implemen
                     maskSpecial |= tp.getMask();
                     continue;
                 }
-				
+
 				if (prop instanceof BitMaskTextProp) {
 				    ((BitMaskTextProp)prop).setValueWithMask(val, containsField);
 				} else if (!(prop instanceof HSLFTabStopPropCollection)) {
@@ -255,26 +264,14 @@ public class TextPropCollection implemen
     /**
      * Clones the given text properties
      */
-	public void copy(TextPropCollection other) {
-	    if (other == null) {
-	        throw new HSLFException("trying to copy null TextPropCollection");
-	    }
-	    if (this == other) return;
-        this.charactersCovered = other.charactersCovered;
-        this.indentLevel = other.indentLevel;
-        this.maskSpecial = other.maskSpecial;
-        this.textProps.clear();
-        for (TextProp tp : other.textProps.values()) {
-            TextProp tpCopy = (tp instanceof BitMaskTextProp)
-                ? ((BitMaskTextProp)tp).cloneAll()
-                : tp.clone();
-            addProp(tpCopy);
-        }
+    @Override
+	public TextPropCollection copy() {
+        return new TextPropCollection(this);
 	}
-	
+
 	/**
 	 * Update the size of the text that this set of properties
-	 *  applies to 
+	 *  applies to
 	 */
 	public void updateTextSize(int textSize) {
 		charactersCovered = textSize;
@@ -286,7 +283,7 @@ public class TextPropCollection implemen
     public void writeOut(OutputStream o) throws IOException {
         writeOut(o, false);
     }
-	
+
 	/**
 	 * Writes out to disk the header, and then all the properties
 	 */
@@ -335,7 +332,7 @@ public class TextPropCollection implemen
         }
         this.indentLevel = indentLevel;
     }
-    
+
     public int hashCode() {
         final int prime = 31;
         int result = 1;
@@ -352,7 +349,7 @@ public class TextPropCollection implemen
         if (this == other) return true;
         if (other == null) return false;
         if (getClass() != other.getClass()) return false;
-        
+
         TextPropCollection o = (TextPropCollection)other;
         if (o.maskSpecial != this.maskSpecial || o.indentLevel != this.indentLevel) {
             return false;
@@ -394,7 +391,7 @@ public class TextPropCollection implemen
         } catch (IOException e ) {
             LOG.log(POILogger.ERROR, "can't dump TextPropCollection", e);
         }
-        
+
         return out.toString();
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/WrapFlagsTextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/WrapFlagsTextProp.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/WrapFlagsTextProp.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/WrapFlagsTextProp.java Sun Dec 22 21:44:45 2019
@@ -21,10 +21,19 @@ public class WrapFlagsTextProp extends B
     public static final int CHAR_WRAP_IDX = 0;
     public static final int WORD_WRAO_IDX = 1;
     public static final int OVERFLOW_IDX = 2;
-    
+
     public static final String NAME = "wrapFlags";
-    
+
     public WrapFlagsTextProp() {
         super(2, 0xE0000, NAME, "charWrap", "wordWrap", "overflow");
     }
+
+    public WrapFlagsTextProp(WrapFlagsTextProp other) {
+        super(other);
+    }
+
+    @Override
+    public WrapFlagsTextProp copy() {
+        return new WrapFlagsTextProp(this);
+    }
 }

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=1871911&r1=1871910&r2=1871911&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 Sun Dec 22 21:44:45 2019
@@ -212,13 +212,13 @@ public final class StyleTextPropAtom ext
         if (initialised) {
             return;
         }
-        
+
         int pos = 0;
         int textHandled = 0;
 
         paragraphStyles.clear();
         charStyles.clear();
-        
+
         // While we have text in need of paragraph stylings, go ahead and
         // grok the contents as paragraph formatting data
         int prsize = size;
@@ -295,10 +295,10 @@ public final class StyleTextPropAtom ext
 
         initialised = true;
     }
-    
+
     private int checkTextLength(int readLength, int handledSoFar, int overallSize) {
         if (readLength + handledSoFar > overallSize + 1) {
-            logger.log(POILogger.WARN, "Style length of " + readLength + " at " + handledSoFar + 
+            logger.log(POILogger.WARN, "Style length of " + readLength + " at " + handledSoFar +
                     " larger than stated size of " + overallSize + ", truncating");
             return overallSize + 1 - handledSoFar;
         }
@@ -315,20 +315,20 @@ public final class StyleTextPropAtom ext
             // changed
 
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    
+
             // First up, we need to serialise the paragraph properties
             for(TextPropCollection tpc : paragraphStyles) {
                 tpc.writeOut(baos);
             }
-    
+
             // Now, we do the character ones
             for(TextPropCollection tpc : charStyles) {
                 tpc.writeOut(baos);
             }
-    
+
             rawContents = baos.toByteArray();
         }
-        
+
         // Now ensure that the header size is correct
         int newSize = rawContents.length + reserved.length;
         LittleEndian.putInt(_header,4,newSize);
@@ -343,7 +343,7 @@ public final class StyleTextPropAtom ext
         reserved = new byte[0];
         initialised = true;
     }
-    
+
     /**
      * Create a new Paragraph TextPropCollection, and add it to the list
      * @param charactersCovered The number of characters this TextPropCollection will cover
@@ -354,6 +354,11 @@ public final class StyleTextPropAtom ext
         paragraphStyles.add(tpc);
         return tpc;
     }
+
+    public void addParagraphTextPropCollection(TextPropCollection tpc) {
+        paragraphStyles.add(tpc);
+    }
+
     /**
      * Create a new Character TextPropCollection, and add it to the list
      * @param charactersCovered The number of characters this TextPropCollection will cover
@@ -365,6 +370,10 @@ public final class StyleTextPropAtom ext
         return tpc;
     }
 
+    public void addCharacterTextPropCollection(TextPropCollection tpc) {
+        charStyles.add(tpc);
+    }
+
     /* ************************************************************************ */
 
 
@@ -389,7 +398,7 @@ public final class StyleTextPropAtom ext
             for(TextPropCollection pr : getCharacterStyles()) {
                 out.append(pr);
             }
-            
+
             out.append("Reserved bytes\n");
             out.append( HexDump.dump(reserved, 0, 0) );
         }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java Sun Dec 22 21:44:45 2019
@@ -54,7 +54,7 @@ public final class TxMasterStyleAtom ext
     private static final POILogger LOG = POILogFactory.getLogger(TxMasterStyleAtom.class);
     //arbitrarily selected; may need to increase
     private static final int MAX_RECORD_LENGTH = 100_000;
-    
+
     /**
      * Maximum number of indentation levels allowed in PowerPoint documents
      */
@@ -166,7 +166,7 @@ public final class TxMasterStyleAtom ext
 
             head = LittleEndian.getInt(_data, pos);
             pos += LittleEndian.INT_SIZE;
-            
+
             pos += prprops.buildTextPropList( head, _data, pos);
             paragraphStyles.add(prprops);
 
@@ -180,37 +180,35 @@ public final class TxMasterStyleAtom ext
 
     /**
      * Updates the rawdata from the modified paragraph/character styles
-     * 
+     *
      * @since POI 3.14-beta1
      */
     public void updateStyles() {
         int type = getTextType();
-        
+
         try {
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             LittleEndianOutputStream leos = new LittleEndianOutputStream(bos);
             int levels = paragraphStyles.size();
             leos.writeShort(levels);
-            
-            TextPropCollection prdummy = new TextPropCollection(0, TextPropType.paragraph);
-            TextPropCollection chdummy = new TextPropCollection(0, TextPropType.character);
-            
+
             for (int i=0; i<levels; i++) {
-                prdummy.copy(paragraphStyles.get(i));
-                chdummy.copy(charStyles.get(i));
+                TextPropCollection prdummy = paragraphStyles.get(i).copy();
+                TextPropCollection chdummy = charStyles.get(i).copy();
+
                 if (type >= TextPlaceholder.CENTER_BODY.nativeId) {
                     leos.writeShort(prdummy.getIndentLevel());
                 }
-                
+
                 // Indent level is not written for master styles
                 prdummy.setIndentLevel((short)-1);
                 prdummy.writeOut(bos, true);
                 chdummy.writeOut(bos, true);
             }
-            
+
             _data = bos.toByteArray();
             leos.close();
-            
+
             LittleEndian.putInt(_header, 4, _data.length);
         } catch (IOException e) {
             throw new HSLFException("error in updating master style properties", e);

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=1871911&r1=1871910&r2=1871911&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 Sun Dec 22 21:44:45 2019
@@ -78,7 +78,7 @@ public final class HSLFTextParagraph imp
     private final TextHeaderAtom _headerAtom;
     private TextBytesAtom _byteAtom;
     private TextCharsAtom _charAtom;
-    private TextPropCollection _paragraphStyle = new TextPropCollection(1, TextPropType.paragraph);
+    private TextPropCollection _paragraphStyle;
 
     protected TextRulerAtom _ruler;
     protected final List<HSLFTextRun> _runs = new ArrayList<>();
@@ -141,6 +141,7 @@ public final class HSLFTextParagraph imp
         _byteAtom = tba;
         _charAtom = tca;
         this.parentList = parentList;
+        _paragraphStyle = new TextPropCollection(1, TextPropType.paragraph);
     }
 
     /* package */HSLFTextParagraph(HSLFTextParagraph other) {
@@ -151,7 +152,7 @@ public final class HSLFTextParagraph imp
         _sheet = other._sheet;
         _ruler = other._ruler;
         shapeId = other.shapeId;
-        _paragraphStyle.copy(other._paragraphStyle);
+        _paragraphStyle = other._paragraphStyle;
         parentList = other.parentList;
     }
 
@@ -169,7 +170,7 @@ public final class HSLFTextParagraph imp
     }
 
     public void setParagraphStyle(TextPropCollection paragraphStyle) {
-        _paragraphStyle.copy(paragraphStyle);
+        _paragraphStyle = paragraphStyle;
     }
 
     /**
@@ -906,8 +907,6 @@ public final class HSLFTextParagraph imp
 
     /**
      * Check and add linebreaks to text runs leading other paragraphs
-     *
-     * @param paragraphs
      */
     protected static void fixLineEndings(List<HSLFTextParagraph> paragraphs) {
         HSLFTextRun lastRun = null;
@@ -990,7 +989,7 @@ public final class HSLFTextParagraph imp
         StyleTextPropAtom styleAtom = findStyleAtomPresent(headerAtom, rawText.length());
 
         // Store in the appropriate record
-        Record oldRecord = null, newRecord = null;
+        Record oldRecord = null, newRecord;
         if (isUnicode) {
             if (byteAtom != null || charAtom == null) {
                 oldRecord = byteAtom;
@@ -1069,15 +1068,17 @@ public final class HSLFTextParagraph imp
             ptpc = para.getParagraphStyle();
             ptpc.updateTextSize(0);
             if (!ptpc.equals(lastPTPC)) {
-                lastPTPC = styleAtom.addParagraphTextPropCollection(0);
-                lastPTPC.copy(ptpc);
+                lastPTPC = ptpc.copy();
+                lastPTPC.updateTextSize(0);
+                styleAtom.addParagraphTextPropCollection(lastPTPC);
             }
             for (HSLFTextRun tr : para.getTextRuns()) {
                 rtpc = tr.getCharacterStyle();
                 rtpc.updateTextSize(0);
                 if (!rtpc.equals(lastRTPC)) {
-                    lastRTPC = styleAtom.addCharacterTextPropCollection(0);
-                    lastRTPC.copy(rtpc);
+                    lastRTPC = rtpc.copy();
+                    lastRTPC.updateTextSize(0);
+                    styleAtom.addCharacterTextPropCollection(lastRTPC);
                 }
                 int len = tr.getLength();
                 ptpc.updateTextSize(ptpc.getCharactersCovered() + len);
@@ -1096,10 +1097,8 @@ public final class HSLFTextParagraph imp
         lastPTPC.updateTextSize(lastPTPC.getCharactersCovered() + 1);
         lastRTPC.updateTextSize(lastRTPC.getCharactersCovered() + 1);
 
-        /**
-         * If TextSpecInfoAtom is present, we must update the text size in it,
-         * otherwise the ppt will be corrupted
-         */
+        // If TextSpecInfoAtom is present, we must update the text size in it,
+        // otherwise the ppt will be corrupted
         for (Record r : paragraphs.get(0).getRecords()) {
             if (r instanceof TextSpecInfoAtom) {
                 ((TextSpecInfoAtom) r).setParentSize(rawText.length() + 1);
@@ -1188,7 +1187,7 @@ public final class HSLFTextParagraph imp
                 TextPropCollection tpc = htp.getParagraphStyle();
                 HSLFTextParagraph prevHtp = htp;
                 htp = new HSLFTextParagraph(htp._headerAtom, htp._byteAtom, htp._charAtom, paragraphs);
-                htp.getParagraphStyle().copy(tpc);
+                htp.setParagraphStyle(tpc.copy());
                 htp.setParentShape(prevHtp.getParentShape());
                 htp.setShapeId(prevHtp.getShapeId());
                 htp.supplySheet(prevHtp.getSheet());
@@ -1199,7 +1198,7 @@ public final class HSLFTextParagraph imp
             if (!lastRunEmpty) {
                 TextPropCollection tpc = htr.getCharacterStyle();
                 htr = new HSLFTextRun(htp);
-                htr.getCharacterStyle().copy(tpc);
+                htr.setCharacterStyle(tpc.copy());
                 htp.addTextRun(htr);
             }
             htr.setText(rawText);
@@ -1581,8 +1580,7 @@ public final class HSLFTextParagraph imp
                     return;
                 }
                 HSLFTextParagraph htp = paragraphs.get(paraIdx);
-                TextPropCollection pCopy = new TextPropCollection(0, TextPropType.paragraph);
-                pCopy.copy(p);
+                TextPropCollection pCopy = p.copy();
                 htp.setParagraphStyle(pCopy);
                 int len = 0;
                 for (HSLFTextRun trun : htp.getTextRuns()) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java Sun Dec 22 21:44:45 2019
@@ -74,7 +74,7 @@ public final class HSLFTextRun implement
 	}
 
 	public void setCharacterStyle(TextPropCollection characterStyle) {
-	    this.characterStyle.copy(characterStyle);
+	    this.characterStyle = characterStyle.copy();
 	    this.characterStyle.updateTextSize(_runText.length());
 	}
 
@@ -150,7 +150,7 @@ public final class HSLFTextRun implement
             logger.log(POILogger.ERROR, "Sheet is not available");
             return null;
         }
-        
+
         final HSLFMasterSheet master = sheet.getMasterSheet();
         if (master == null) {
             logger.log(POILogger.WARN, "MasterSheet is not available");
@@ -161,8 +161,8 @@ public final class HSLFTextRun implement
         final TextPropCollection col = master.getPropCollection(txtype, parentParagraph.getIndentLevel(), name, true);
         return (col == null) ? null : col.findByName(name);
 	}
-	
-	
+
+
 	/**
 	 * Set the value of the given flag in the CharFlagsTextProp, adding
 	 *  it if required.
@@ -315,7 +315,7 @@ public final class HSLFTextRun implement
     @Override
 	public void setFontInfo(FontInfo fontInfo, FontGroup fontGroup) {
         FontGroup fg = safeFontGroup(fontGroup);
-        
+
         HSLFSheet sheet = parentParagraph.getSheet();
         @SuppressWarnings("resource")
         HSLFSlideShow slideShow = (sheet == null) ? null : sheet.getSlideShow();
@@ -520,7 +520,7 @@ public final class HSLFTextRun implement
 
         return null;
     }
-    
+
     private FontGroup safeFontGroup(FontGroup fontGroup) {
         return (fontGroup != null) ? fontGroup : FontGroup.getFontGroupFirst(getRawText());
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfDrawProperties.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfDrawProperties.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/draw/HwmfDrawProperties.java Sun Dec 22 21:44:45 2019
@@ -97,21 +97,21 @@ public class HwmfDrawProperties {
         font = new HwmfFont();
         font.initDefaults();
     }
-    
+
     public HwmfDrawProperties(HwmfDrawProperties other) {
         this.window = (other.window == null) ? null : (Rectangle2D)other.window.clone();
         this.viewport = (other.viewport == null) ? null : (Rectangle2D)other.viewport.clone();
         this.location = (Point2D)other.location.clone();
         this.mapMode = other.mapMode;
-        this.backgroundColor = (other.backgroundColor == null) ? null : other.backgroundColor.clone();
+        this.backgroundColor = (other.backgroundColor == null) ? null : other.backgroundColor.copy();
         this.brushStyle = other.brushStyle;
-        this.brushColor = other.brushColor.clone();
+        this.brushColor = other.brushColor.copy();
         this.brushHatch = other.brushHatch;
         this.brushBitmap = other.brushBitmap;
         this.brushTransform.setTransform(other.brushTransform);
         this.penWidth = other.penWidth;
-        this.penStyle = (other.penStyle == null) ? null : other.penStyle.clone();
-        this.penColor = (other.penColor == null) ? null : other.penColor.clone();
+        this.penStyle = (other.penStyle == null) ? null : other.penStyle.copy();
+        this.penColor = (other.penColor == null) ? null : other.penColor.copy();
         this.penMiterLimit = other.penMiterLimit;
         this.bkMode = other.bkMode;
         this.polyfillMode = other.polyfillMode;
@@ -123,7 +123,7 @@ public class HwmfDrawProperties {
         this.palette = other.palette;
         this.paletteOffset = other.paletteOffset;
         this.font = other.font;
-        this.textColor = (other.textColor == null) ? null : other.textColor.clone();
+        this.textColor = (other.textColor == null) ? null : other.textColor.copy();
         this.textAlignLatin = other.textAlignLatin;
         this.textVAlignLatin = other.textVAlignLatin;
         this.textAlignAsian = other.textAlignAsian;
@@ -132,7 +132,7 @@ public class HwmfDrawProperties {
         this.transform.setTransform(other.transform);
         this.clip = other.clip;
     }
-    
+
     public void setViewportExt(double width, double height) {
         if (viewport == null) {
             viewport = (Rectangle2D)window.clone();
@@ -308,7 +308,7 @@ public class HwmfDrawProperties {
     /**
      * Returns the current palette.
      * Callers may modify the palette.
-     * 
+     *
      * @return the current palette or null, if it hasn't been set
      */
     public List<PaletteEntry> getPalette() {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfColorRef.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfColorRef.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfColorRef.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfColorRef.java Sun Dec 22 21:44:45 2019
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Map;
 import java.util.function.Supplier;
 
+import org.apache.poi.common.Duplicatable;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.util.GenericRecordJsonWriter;
 import org.apache.poi.util.GenericRecordUtil;
@@ -35,15 +36,19 @@ import org.apache.poi.util.LittleEndianI
  * Blue (1 byte):  An 8-bit unsigned integer that defines the relative intensity of blue.
  * Reserved (1 byte):  An 8-bit unsigned integer that MUST be 0x00.
  */
-public class HwmfColorRef implements Cloneable, GenericRecord {
+public class HwmfColorRef implements Duplicatable, GenericRecord {
     private Color colorRef = Color.BLACK;
-    
+
     public HwmfColorRef() {}
-    
+
+    public HwmfColorRef(HwmfColorRef other) {
+        colorRef = other.colorRef;
+    }
+
     public HwmfColorRef(Color colorRef) {
         this.colorRef = colorRef;
     }
-    
+
     public int init(LittleEndianInputStream leis) throws IOException {
         int red = leis.readUByte();
         int green = leis.readUByte();
@@ -62,21 +67,9 @@ public class HwmfColorRef implements Clo
         colorRef = color;
     }
 
-    /**
-     * Creates a new object of the same class and with the
-     * same contents as this object.
-     * @return     a clone of this instance.
-     * @exception  OutOfMemoryError            if there is not enough memory.
-     * @see        java.lang.Cloneable
-     */
     @Override
-    public HwmfColorRef clone() {
-        try {
-            return (HwmfColorRef)super.clone();
-        } catch (CloneNotSupportedException e) {
-            // this shouldn't happen, since we are Cloneable
-            throw new InternalError();
-        }
+    public HwmfColorRef copy() {
+        return new HwmfColorRef(this);
     }
 
     @Override

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfPenStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfPenStyle.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfPenStyle.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfPenStyle.java Sun Dec 22 21:44:45 2019
@@ -21,6 +21,7 @@ import java.awt.BasicStroke;
 import java.util.Map;
 import java.util.function.Supplier;
 
+import org.apache.poi.common.Duplicatable;
 import org.apache.poi.common.usermodel.GenericRecord;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
@@ -30,21 +31,21 @@ import org.apache.poi.util.GenericRecord
 /**
  * The 16-bit PenStyle Enumeration is used to specify different types of pens
  * that can be used in graphics operations.
- * 
+ *
  * Various styles can be combined by using a logical OR statement, one from
  * each subsection of Style, EndCap, Join, and Type (Cosmetic).
- * 
+ *
  * The defaults in case the other values of the subsection aren't set are
  * solid, round end caps, round joins and cosmetic type.
  */
-public class HwmfPenStyle implements Cloneable, GenericRecord {
+public class HwmfPenStyle implements Duplicatable, GenericRecord {
     public enum HwmfLineCap {
         /** Rounded ends */
         ROUND(0, BasicStroke.CAP_ROUND),
         /** Square protrudes by half line width */
         SQUARE(1, BasicStroke.CAP_SQUARE),
         /** Line ends at end point*/
-        FLAT(2, BasicStroke.CAP_BUTT);        
+        FLAT(2, BasicStroke.CAP_BUTT);
 
         public final int wmfFlag;
         public final int awtFlag;
@@ -58,9 +59,9 @@ public class HwmfPenStyle implements Clo
                 if (hs.wmfFlag == wmfFlag) return hs;
             }
             return null;
-        }    
+        }
     }
-    
+
     public enum HwmfLineJoin {
         /**Line joins are round. */
         ROUND(0, BasicStroke.JOIN_ROUND),
@@ -84,16 +85,16 @@ public class HwmfPenStyle implements Clo
                 if (hs.wmfFlag == wmfFlag) return hs;
             }
             return null;
-        }    
+        }
     }
-    
+
     public enum HwmfLineDash {
         /**
          * The pen is solid.
          */
         SOLID(0x0000, null),
         /**
-         * The pen is dashed. (-----) 
+         * The pen is dashed. (-----)
          */
         DASH(0x0001, 10, 8),
         /**
@@ -124,7 +125,7 @@ public class HwmfPenStyle implements Clo
          * styling is supposed to come from ...)
          */
         USERSTYLE(0x0007, null);
-        
+
 
         public final int wmfFlag;
         public final float[] dashes;
@@ -138,23 +139,29 @@ public class HwmfPenStyle implements Clo
                 if (hs.wmfFlag == wmfFlag) return hs;
             }
             return null;
-        }    
+        }
     }
-    
-    private static final BitField SUBSECTION_DASH      = BitFieldFactory.getInstance(0x00007);
-    private static final BitField SUBSECTION_ALTERNATE = BitFieldFactory.getInstance(0x00008);
-    private static final BitField SUBSECTION_ENDCAP    = BitFieldFactory.getInstance(0x00300);
-    private static final BitField SUBSECTION_JOIN      = BitFieldFactory.getInstance(0x03000);
-    private static final BitField SUBSECTION_GEOMETRIC = BitFieldFactory.getInstance(0x10000);
+
+    protected static final BitField SUBSECTION_DASH      = BitFieldFactory.getInstance(0x00007);
+    protected static final BitField SUBSECTION_ALTERNATE = BitFieldFactory.getInstance(0x00008);
+    protected static final BitField SUBSECTION_ENDCAP    = BitFieldFactory.getInstance(0x00300);
+    protected static final BitField SUBSECTION_JOIN      = BitFieldFactory.getInstance(0x03000);
+    protected static final BitField SUBSECTION_GEOMETRIC = BitFieldFactory.getInstance(0x10000);
 
     protected int flag;
-    
+
+    public HwmfPenStyle(int flag) {
+        this.flag = flag;
+    }
+
+    public HwmfPenStyle(HwmfPenStyle other) {
+        flag = other.flag;
+    }
+
     public static HwmfPenStyle valueOf(int flag) {
-        HwmfPenStyle ps = new HwmfPenStyle();
-        ps.flag = flag;
-        return ps;
+        return new HwmfPenStyle(flag);
     }
-    
+
     public HwmfLineCap getLineCap() {
         return HwmfLineCap.valueOf(SUBSECTION_ENDCAP.getValue(flag));
     }
@@ -162,7 +169,7 @@ public class HwmfPenStyle implements Clo
     public HwmfLineJoin getLineJoin() {
         return HwmfLineJoin.valueOf(SUBSECTION_JOIN.getValue(flag));
     }
-    
+
     public HwmfLineDash getLineDash() {
         return HwmfLineDash.valueOf(SUBSECTION_DASH.getValue(flag));
     }
@@ -193,21 +200,9 @@ public class HwmfPenStyle implements Clo
     }
 
 
-    /**
-     * Creates a new object of the same class and with the
-     * same contents as this object.
-     * @return     a clone of this instance.
-     * @exception  OutOfMemoryError            if there is not enough memory.
-     * @see        java.lang.Cloneable
-     */
     @Override
-    public HwmfPenStyle clone() {
-        try {
-            return (HwmfPenStyle)super.clone();
-        } catch (CloneNotSupportedException e) {
-            // this shouldn't happen, since we are Cloneable
-            throw new InternalError();
-        }
+    public HwmfPenStyle copy() {
+        return new HwmfPenStyle(this);
     }
 
     @Override

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java Sun Dec 22 21:44:45 2019
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record;
 
 import static org.junit.Assert.assertArrayEquals;
+
 import junit.framework.TestCase;
 
 /**
@@ -57,7 +58,7 @@ public final class TestAutoFilterInfoRec
         record.setNumEntries((short)3);
         byte[] src = record.serialize();
 
-        AutoFilterInfoRecord cloned = record.clone();
+        AutoFilterInfoRecord cloned = record.copy();
         assertEquals(3, record.getNumEntries());
         byte[] cln = cloned.serialize();
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Sun Dec 22 21:44:45 2019
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTru
 
 import java.io.IOException;
 
+import junit.framework.AssertionFailedError;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.record.CFRuleBase.ComparisonOperator;
 import org.apache.poi.hssf.record.cf.BorderFormatting;
@@ -42,8 +43,6 @@ import org.apache.poi.ss.usermodel.IconM
 import org.apache.poi.util.LittleEndian;
 import org.junit.Test;
 
-import junit.framework.AssertionFailedError;
-
 /**
  * Tests the serialization and deserialization of the TestCFRuleRecord
  * class works correctly.
@@ -141,8 +140,8 @@ public final class TestCFRuleRecord {
         record.getMultiStateFormatting().getThresholds()[1].setValue(10d);
         record.getMultiStateFormatting().getThresholds()[2].setType(RangeType.NUMBER.id);
         record.getMultiStateFormatting().getThresholds()[2].setValue(-4d);
-        
-        // Check it 
+
+        // Check it
         testCFRule12Record(record);
         assertEquals(IconSet.GREY_5_ARROWS, record.getMultiStateFormatting().getIconSet());
         assertEquals(5, record.getMultiStateFormatting().getThresholds().length);
@@ -156,7 +155,7 @@ public final class TestCFRuleRecord {
 
         // Deserialize
         record = new CFRule12Record(TestcaseRecordInputStream.create(CFRule12Record.sid, recordData));
-        
+
         // Check it has the icon, and the right number of thresholds
         assertEquals(IconSet.GREY_5_ARROWS, record.getMultiStateFormatting().getIconSet());
         assertEquals(5, record.getMultiStateFormatting().getThresholds().length);
@@ -172,10 +171,10 @@ public final class TestCFRuleRecord {
         }
         workbook.close();
     }
-    
+
     private void testCFRuleRecord(CFRuleRecord record) {
         testCFRuleBase(record);
-        
+
         assertFalse(record.isLeftBorderModified());
         record.setLeftBorderModified(true);
         assertTrue(record.isLeftBorderModified());
@@ -445,22 +444,22 @@ public final class TestCFRuleRecord {
         byte[] data = rr.serialize();
         TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
     }
-    
+
     @Test
     public void testBug53691() throws IOException {
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFSheet sheet = workbook.createSheet();
 
         CFRuleRecord record = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5");
-        
-        CFRuleRecord clone = record.clone();
-        
+
+        CFRuleRecord clone = record.copy();
+
         byte [] serializedRecord = record.serialize();
         byte [] serializedClone = clone.serialize();
         assertArrayEquals(serializedRecord, serializedClone);
         workbook.close();
     }
-    
+
     @Test
     public void testBug57231_rewrite() throws IOException {
         HSSFWorkbook wb1 = HSSFITestDataProvider.instance.openSampleWorkbook("57231_MixedGasReport.xls");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java Sun Dec 22 21:44:45 2019
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.record;
 
 
 import static org.junit.Assert.assertArrayEquals;
+
 import junit.framework.TestCase;
 
 /**
@@ -56,7 +57,7 @@ public final class TestFtCblsSubRecord e
         FtCblsSubRecord record = new FtCblsSubRecord();
         byte[] src = record.serialize();
 
-        FtCblsSubRecord cloned = record.clone();
+        FtCblsSubRecord cloned = record.copy();
         byte[] cln = cloned.serialize();
 
         assertEquals(record.getDataSize(), cloned.getDataSize());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java Sun Dec 22 21:44:45 2019
@@ -34,40 +34,40 @@ import org.junit.Test;
 public final class TestHyperlinkRecord {
 
     //link to http://www.lakings.com/
-    private static final byte[] data1 = { 
+    private static final byte[] data1 = {
         0x02, 0x00,    //First row of the hyperlink
         0x02, 0x00,    //Last row of the hyperlink
         0x00, 0x00,    //First column of the hyperlink
         0x00, 0x00,    //Last column of the hyperlink
-        
+
         //16-byte GUID. Seems to be always the same. Does not depend on the hyperlink type
         (byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         0x02, 0x00, 0x00, 0x00, //integer, always 2
-        
+
         // flags. Define the type of the hyperlink:
         // HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_ABS | HyperlinkRecord.HLINK_LABEL
         0x17, 0x00, 0x00, 0x00,
-        
+
         0x08, 0x00, 0x00, 0x00, //length of the label including the trailing '\0'
-        
+
         //label:
         0x4D, 0x00, 0x79, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x6B, 0x00, 0x00, 0x00,
-        
+
         //16-byte link moniker: HyperlinkRecord.URL_MONIKER
         (byte)0xE0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE,  0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         //count of bytes in the address including the tail
         0x48, 0x00, 0x00, 0x00, //integer
-        
+
         //the actual link, terminated by '\u0000'
         0x68, 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, 0x2F, 0x00,
         0x2F, 0x00, 0x77, 0x00, 0x77, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x6C, 0x00,
         0x61, 0x00, 0x6B, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x73, 0x00,
         0x2E, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x2F, 0x00, 0x00, 0x00,
-        
+
         //standard 24-byte tail of a URL link. Seems to always be the same for all URL HLINKs
         0x79, 0x58, (byte)0x81, (byte)0xF4, 0x3B, 0x1D, 0x7F, 0x48, (byte)0xAF, 0x2C,
         (byte)0x82, 0x5D, (byte)0xC4, (byte)0x85, 0x27, 0x63, 0x00, 0x00, 0x00,
@@ -83,29 +83,29 @@ public final class TestHyperlinkRecord {
         //16-bit GUID. Seems to be always the same. Does not depend on the hyperlink type
         (byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         0x02, 0x00, 0x00, 0x00,    //integer, always 2
-        
+
         0x15, 0x00, 0x00, 0x00,    //options: HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_LABEL
-        
+
         0x05, 0x00, 0x00, 0x00,    //length of the label
         //label
         0x66, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x00, 0x00,
-        
+
         //16-byte link moniker: HyperlinkRecord.FILE_MONIKER
         0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
-        
+
         0x00, 0x00,    //level
         0x0A, 0x00, 0x00, 0x00,    //length of the path )
-        
+
         //path to the file (plain ISO-8859 bytes, NOT UTF-16LE!)
         0x6C, 0x69, 0x6E, 0x6B, 0x31, 0x2E, 0x78, 0x6C, 0x73, 0x00,
-        
+
         //standard 24-byte tail of a file link
         (byte)0xFF, (byte)0xFF, (byte)0xAD, (byte)0xDE, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00,
-        
+
         0x00, 0x00, 0x00, 0x00, // length of address link field
     };
 
@@ -115,25 +115,25 @@ public final class TestHyperlinkRecord {
         0x01, 0x00,
         0x00, 0x00,
         0x00, 0x00,
-        
+
         //16-bit GUID. Seems to be always the same. Does not depend on the hyperlink type
         (byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         0x02, 0x00, 0x00, 0x00, //integer, always 2
-        
+
         0x17, 0x00, 0x00, 0x00,  //options: HyperlinkRecord.HLINK_URL | HyperlinkRecord.HLINK_ABS | HyperlinkRecord.HLINK_LABEL
-        
+
         0x06, 0x00, 0x00, 0x00,     //length of the label
         0x65, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x00, 0x00, //label
-        
+
         //16-byte link moniker: HyperlinkRecord.URL_MONIKER
         (byte)0xE0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         //length of the address including the tail.
         0x76, 0x00, 0x00, 0x00,
-        
+
         //the address is terminated by '\u0000'
         0x6D, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x74, 0x00, 0x6F, 0x00,
         0x3A, 0x00, 0x65, 0x00, 0x62, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6E, 0x00,
@@ -143,7 +143,7 @@ public final class TestHyperlinkRecord {
         0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x2C, 0x00,
         0x25, 0x00, 0x32, 0x00, 0x30, 0x00, 0x45, 0x00, 0x62, 0x00, 0x67, 0x00,
         0x61, 0x00, 0x6E, 0x00, 0x73, 0x00, 0x21, 0x00, 0x00, 0x00,
-        
+
         //standard 24-byte tail of a URL link
         0x79, 0x58, (byte)0x81, (byte)0xF4, 0x3B, 0x1D, 0x7F, 0x48, (byte)0xAF, (byte)0x2C,
         (byte)0x82, 0x5D, (byte)0xC4, (byte)0x85, 0x27, 0x63, 0x00, 0x00, 0x00,
@@ -156,21 +156,21 @@ public final class TestHyperlinkRecord {
         0x03, 0x00,
         0x00, 0x00,
         0x00, 0x00,
-        
+
         //16-bit GUID. Seems to be always the same. Does not depend on the hyperlink type
         (byte)0xD0, (byte)0xC9, (byte)0xEA, 0x79, (byte)0xF9, (byte)0xBA, (byte)0xCE, 0x11,
         (byte)0x8C, (byte)0x82, 0x00, (byte)0xAA, 0x00, 0x4B, (byte)0xA9, 0x0B,
-        
+
         0x02, 0x00, 0x00, 0x00, //integer, always 2
-        
+
         0x1C, 0x00, 0x00, 0x00, //flags: HyperlinkRecord.HLINK_LABEL | HyperlinkRecord.HLINK_PLACE
-        
+
         0x06, 0x00, 0x00, 0x00, //length of the label
-        
+
         0x70, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x00, 0x00, //label
-        
+
         0x0A, 0x00, 0x00, 0x00, //length of the document link including trailing zero
-        
+
         //link: Sheet1!A1
         0x53, 0x00, 0x68, 0x00, 0x65, 0x00, 0x65, 0x00, 0x74, 0x00, 0x31, 0x00, 0x21,
         0x00, 0x41, 0x00, 0x31, 0x00, 0x00, 0x00
@@ -246,7 +246,7 @@ public final class TestHyperlinkRecord {
     	"61 00 72 00 65 00 5C 00 6D 00 79 00 44 00 69 00 " +
     	"72 00 5C 00 50 00 52 00 4F 00 44 00 4E 00 41 00 " +
     	"4D 00 45 00 2E 00 78 00 6C 00 73 00 00 00 " +
-    
+
     	"0C 00 00 00 " + // textMark: PRODNAME!C2
     	"50 00 52 00 4F 00 44 00 4E 00 41 00 4D 00 45 00 21 00 " +
     	"43 00 32 00 00 00"
@@ -274,7 +274,7 @@ public final class TestHyperlinkRecord {
     private void confirmGUID(GUID expectedGuid, GUID actualGuid) {
 		assertEquals(expectedGuid, actualGuid);
 	}
-    
+
     @Test
     public void testReadURLLink(){
         RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data1);
@@ -442,7 +442,7 @@ public final class TestHyperlinkRecord {
         for (final byte[] d : data) {
             RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, d);
             HyperlinkRecord link = new HyperlinkRecord(is);
-            HyperlinkRecord clone = link.clone();
+            HyperlinkRecord clone = link.copy();
             assertArrayEquals(link.serialize(), clone.serialize());
         }
 
@@ -480,7 +480,7 @@ public final class TestHyperlinkRecord {
 		    fail("Identified bug with option URL and UNC set at same time");
 		}
 	}
-	
+
     @Test
 	public void testGUID() {
 		GUID g;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java Sun Dec 22 21:44:45 2019
@@ -22,7 +22,6 @@ import java.util.List;
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
-
 import org.apache.poi.hssf.model.RecordStream;
 import org.apache.poi.hssf.record.aggregates.MergedCellsTable;
 import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
@@ -35,14 +34,14 @@ import org.apache.poi.ss.util.CellRangeA
  *
  */
 public final class TestMergeCellsRecord extends TestCase {
-   
+
 	/**
 	 * Make sure when a clone is called, we actually clone it.
 	 */
 	public void testCloneReferences() {
 		CellRangeAddress[] cras = { new CellRangeAddress(0, 1, 0, 2), };
 		MergeCellsRecord merge = new MergeCellsRecord(cras, 0, cras.length);
-		MergeCellsRecord clone = merge.clone();
+		MergeCellsRecord clone = merge.copy();
 
 		assertNotSame("Merged and cloned objects are the same", merge, clone);
 
@@ -56,7 +55,7 @@ public final class TestMergeCellsRecord
 
         assertNotSame(merge.getAreaAt(0), clone.getAreaAt(0));
 	}
-   
+
 	private static final RecordVisitor dummyRecordVisitor = new RecordVisitor() {
 		@Override
         public void visitRecord(Record r) {
@@ -67,7 +66,7 @@ public final class TestMergeCellsRecord
 		MergedCellsTable mct = new MergedCellsTable();
 		List<Record> recList = new ArrayList<>();
 		CellRangeAddress[] cras = new CellRangeAddress[] {
-				new CellRangeAddress(0, 0, 0, 3), 
+				new CellRangeAddress(0, 0, 0, 3),
 		};
 		recList.add(new MergeCellsRecord(cras, 0, 1));
 		RecordStream rs = new RecordStream(recList, 0);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java Sun Dec 22 21:44:45 2019
@@ -18,9 +18,9 @@
 package org.apache.poi.hssf.record;
 
 import static org.junit.Assert.assertArrayEquals;
+
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
-
 import org.apache.poi.util.HexRead;
 
 /**
@@ -53,7 +53,7 @@ public final class TestNoteRecord extend
     public void testWrite() {
         NoteRecord record = new NoteRecord();
         assertEquals(NoteRecord.sid, record.getSid());
-        
+
         record.setRow((short)6);
         record.setColumn((short)1);
         record.setFlags(NoteRecord.NOTE_VISIBLE);
@@ -73,7 +73,7 @@ public final class TestNoteRecord extend
         record.setShapeId((short)1026);
         record.setAuthor("Apache Software Foundation");
 
-        NoteRecord cloned = record.clone();
+        NoteRecord cloned = record.copy();
         assertEquals(record.getRow(), cloned.getRow());
         assertEquals(record.getColumn(), cloned.getColumn());
         assertEquals(record.getFlags(), cloned.getFlags());
@@ -85,14 +85,14 @@ public final class TestNoteRecord extend
         byte[] cln = cloned.serialize();
         assertArrayEquals(src, cln);
     }
-    
+
     public void testUnicodeAuthor() {
-        // This sample data was created by setting the 'user name' field in the 'Personalize' 
-        // section of Excel's options to \u30A2\u30D1\u30C3\u30C1\u65CF, and then 
+        // This sample data was created by setting the 'user name' field in the 'Personalize'
+        // section of Excel's options to \u30A2\u30D1\u30C3\u30C1\u65CF, and then
         // creating a cell comment.
         byte[] data = HexRead.readFromString("01 00 01 00 00 00 03 00 " +
                 "05 00 01 " + // len=5, 16bit
-                "A2 30 D1 30 C3 30 C1 30 CF 65 " + // character data 
+                "A2 30 D1 30 C3 30 C1 30 CF 65 " + // character data
                 "00 " // padding byte
                 );
         RecordInputStream in = TestcaseRecordInputStream.create(NoteRecord.sid, data);
@@ -102,7 +102,7 @@ public final class TestNoteRecord extend
         }
         assertEquals("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.getAuthor());
         assertTrue(nr.authorIsMultibyte());
-        
+
         byte[] ser = nr.serialize();
         TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, data, ser);
 
@@ -111,23 +111,23 @@ public final class TestNoteRecord extend
         nr = new NoteRecord(in);
         assertEquals("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.getAuthor());
         assertTrue(nr.authorIsMultibyte());
-        
-        
+
+
         // Change to a non unicode author, will stop being unicode
         nr.setAuthor("Simple");
         ser = nr.serialize();
         in = TestcaseRecordInputStream.create(ser);
         nr = new NoteRecord(in);
-        
+
         assertEquals("Simple", nr.getAuthor());
         assertFalse(nr.authorIsMultibyte());
-        
+
         // Now set it back again
         nr.setAuthor("Unicode\u1234");
         ser = nr.serialize();
         in = TestcaseRecordInputStream.create(ser);
         nr = new NoteRecord(in);
-        
+
         assertEquals("Unicode\u1234", nr.getAuthor());
         assertTrue(nr.authorIsMultibyte());
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java Sun Dec 22 21:44:45 2019
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.record;
 
 
 import static org.junit.Assert.assertArrayEquals;
+
 import junit.framework.TestCase;
 
 /**
@@ -58,7 +59,7 @@ public final class TestNoteStructureSubR
         NoteStructureSubRecord record = new NoteStructureSubRecord();
         byte[] src = record.serialize();
 
-        NoteStructureSubRecord cloned = record.clone();
+        NoteStructureSubRecord cloned = record.copy();
         byte[] cln = cloned.serialize();
 
         assertEquals(record.getDataSize(), cloned.getDataSize());



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