poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1848906 [3/3] - in /poi/branches/hemf: ./ src/examples/src/org/apache/poi/xslf/usermodel/ src/examples/src/org/apache/poi/xwpf/usermodel/examples/ src/integrationtest/org/apache/poi/ src/integrationtest/org/apache/poi/stress/ src/java/org/...
Date Fri, 14 Dec 2018 00:44:41 GMT
Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
(original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
Fri Dec 14 00:44:40 2018
@@ -23,20 +23,16 @@ import java.awt.geom.PathIterator;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherArrayProperty;
 import org.apache.poi.ddf.EscherContainerRecord;
 import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.ddf.EscherProperty;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.sl.usermodel.FreeformShape;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -53,79 +49,6 @@ import org.apache.poi.util.Units;
 public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph>
{
     private static final POILogger LOG = POILogFactory.getLogger(HSLFFreeformShape.class);
 
-    private static final byte[] SEGMENTINFO_MOVETO   = new byte[]{0x00, 0x40};
-    private static final byte[] SEGMENTINFO_LINETO   = new byte[]{0x00, (byte)0xAC};
-    private static final byte[] SEGMENTINFO_ESCAPE   = new byte[]{0x01, 0x00};
-    private static final byte[] SEGMENTINFO_ESCAPE2  = new byte[]{0x01, 0x20};
-    private static final byte[] SEGMENTINFO_CUBICTO  = new byte[]{0x00, (byte)0xAD};
-    // OpenOffice inserts 0xB3 instead of 0xAD.
-    // private static final byte[] SEGMENTINFO_CUBICTO2 = new byte[]{0x00, (byte)0xB3};
-    private static final byte[] SEGMENTINFO_CLOSE    = new byte[]{0x01, (byte)0x60};
-    private static final byte[] SEGMENTINFO_END      = new byte[]{0x00, (byte)0x80};
-
-    private static final BitField PATH_INFO = BitFieldFactory.getInstance(0xE000);
-    // private static final BitField ESCAPE_INFO = BitFieldFactory.getInstance(0x1F00);
-
-    enum PathInfo {
-        lineTo(0),curveTo(1),moveTo(2),close(3),end(4),escape(5),clientEscape(6);
-        private final int flag;
-        PathInfo(int flag) {
-            this.flag = flag;
-        }
-        public int getFlag() {
-            return flag;
-        }
-        static PathInfo valueOf(int flag) {
-            for (PathInfo v : values()) {
-                if (v.flag == flag) {
-                    return v;
-                }
-            }
-            return null;
-        }
-    }
-
-    enum EscapeInfo {
-        EXTENSION(0x0000),
-        ANGLE_ELLIPSE_TO(0x0001),
-        ANGLE_ELLIPSE(0x0002),
-        ARC_TO(0x0003),
-        ARC(0x0004),
-        CLOCKWISE_ARC_TO(0x0005),
-        CLOCKWISE_ARC(0x0006),
-        ELLIPTICAL_QUADRANT_X(0x0007),
-        ELLIPTICAL_QUADRANT_Y(0x0008),
-        QUADRATIC_BEZIER(0x0009),
-        NO_FILL(0X000A),
-        NO_LINE(0X000B),
-        AUTO_LINE(0X000C),
-        AUTO_CURVE(0X000D),
-        CORNER_LINE(0X000E),
-        CORNER_CURVE(0X000F),
-        SMOOTH_LINE(0X0010),
-        SMOOTH_CURVE(0X0011),
-        SYMMETRIC_LINE(0X0012),
-        SYMMETRIC_CURVE(0X0013),
-        FREEFORM(0X0014),
-        FILL_COLOR(0X0015),
-        LINE_COLOR(0X0016);
-
-        private final int flag;
-        EscapeInfo(int flag) {
-            this.flag = flag;
-        }
-        public int getFlag() {
-            return flag;
-        }
-        static EscapeInfo valueOf(int flag) {
-            for (EscapeInfo v : values()) {
-                if (v.flag == flag) {
-                    return v;
-                }
-            }
-            return null;
-        }
-    }
 
     enum ShapePath {
         LINES(0),
@@ -182,9 +105,9 @@ public final class HSLFFreeformShape ext
     }
 
     @Override
-    public int setPath(Path2D.Double path) {
+    public int setPath(Path2D path) {
         Rectangle2D bounds = path.getBounds2D();
-        PathIterator it = path.getPathIterator(new AffineTransform());
+        PathIterator it = path.getPathIterator(null);
 
         List<byte[]> segInfo = new ArrayList<>();
         List<Point2D.Double> pntInfo = new ArrayList<>();
@@ -275,187 +198,24 @@ public final class HSLFFreeformShape ext
     }
 
     @Override
-    public Path2D.Double getPath(){
-        AbstractEscherOptRecord opt = getEscherOptRecord();
-
-        EscherArrayProperty verticesProp = getShapeProp(opt, EscherProperties.GEOMETRY__VERTICES);
-        EscherArrayProperty segmentsProp = getShapeProp(opt, EscherProperties.GEOMETRY__SEGMENTINFO);
-
-        // return empty path if either GEOMETRY__VERTICES or GEOMETRY__SEGMENTINFO is missing,
see Bugzilla 54188
-        Path2D.Double path = new Path2D.Double();
+    public Path2D getPath(){
+        Path2D path2D = new Path2D.Double();
+        getGeometry(path2D);
 
-        //sanity check
-        if(verticesProp == null) {
-            LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
-            return path;
-        }
-        if(segmentsProp == null) {
-            LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
-            return path;
-        }
-
-        Iterator<byte[]> vertIter = verticesProp.iterator();
-        Iterator<byte[]> segIter = segmentsProp.iterator();
-        double xyPoints[] = new double[2];
-        
-        while (vertIter.hasNext() && segIter.hasNext()) {
-            byte[] segElem = segIter.next();
-            PathInfo pi = getPathInfo(segElem);
-            if (pi != null) {
-                switch (pi) {
-                    case escape: {
-                        // handleEscapeInfo(path, segElem, vertIter);
-                        break;
-                    }
-                    case moveTo: {
-                        fillPoint(vertIter.next(), xyPoints);
-                        double x = xyPoints[0];
-                        double y = xyPoints[1];
-                        path.moveTo(x, y);
-                        break;
-                    }
-                    case curveTo: {
-                        fillPoint(vertIter.next(), xyPoints);
-                        double x1 = xyPoints[0];
-                        double y1 = xyPoints[1];
-                        fillPoint(vertIter.next(), xyPoints);
-                        double x2 = xyPoints[0];
-                        double y2 = xyPoints[1];
-                        fillPoint(vertIter.next(), xyPoints);
-                        double x3 = xyPoints[0];
-                        double y3 = xyPoints[1];
-                        path.curveTo(x1, y1, x2, y2, x3, y3);
-                        break;
-                    }
-                    case lineTo:
-                        if (vertIter.hasNext()) {
-                            fillPoint(vertIter.next(), xyPoints);
-                            double x = xyPoints[0];
-                            double y = xyPoints[1];
-                            path.lineTo(x, y);
-                        }
-                        break;
-                    case close:
-                        path.closePath();
-                        break;
-                    default:
-                        break;
-                }
-            }
-        }
-
-        EscherSimpleProperty shapePath = getShapeProp(opt, EscherProperties.GEOMETRY__SHAPEPATH);
-        ShapePath sp = ShapePath.valueOf(shapePath == null ? 1 : shapePath.getPropertyValue());
-        if (sp == ShapePath.LINES_CLOSED || sp == ShapePath.CURVES_CLOSED) {
-            path.closePath();
-        }
-        
+        Rectangle2D bounds = path2D.getBounds2D();
         Rectangle2D anchor = getAnchor();
-        Rectangle2D bounds = path.getBounds2D();
         AffineTransform at = new AffineTransform();
         at.translate(anchor.getX(), anchor.getY());
         at.scale(
                 anchor.getWidth()/bounds.getWidth(),
                 anchor.getHeight()/bounds.getHeight()
         );
-        return new Path2D.Double(at.createTransformedShape(path));
-    }
-    
-    private void fillPoint(byte xyMaster[], double xyPoints[]) {
-        if (xyMaster == null || xyPoints == null) {
-            LOG.log(POILogger.WARN, "Master bytes or points not set - ignore point");
-            return;
-        }
-        if ((xyMaster.length != 4 && xyMaster.length != 8) || xyPoints.length !=
2) {
-            LOG.log(POILogger.WARN, "Invalid number of master bytes for a single point -
ignore point");
-            return;
-        }
-        
-        int x, y;
-        if (xyMaster.length == 4) {
-            x = LittleEndian.getShort(xyMaster, 0);
-            y = LittleEndian.getShort(xyMaster, 2);
-        } else {
-            x = LittleEndian.getInt(xyMaster, 0);
-            y = LittleEndian.getInt(xyMaster, 4);
-        }
-        
-        xyPoints[0] = Units.masterToPoints(x);
-        xyPoints[1] = Units.masterToPoints(y);
-    }
-    
-    private static <T extends EscherProperty> T getShapeProp(AbstractEscherOptRecord
opt, int propId) {
-        T prop = getEscherProperty(opt, (short)(propId + 0x4000));
-        if (prop == null) {
-            prop = getEscherProperty(opt, propId);
-        }
-        return prop;
-    }
-    
-//    private void handleEscapeInfo(Path2D path, byte segElem[], Iterator<byte[]> vertIter)
{
-//        EscapeInfo ei = getEscapeInfo(segElem);
-//        switch (ei) {
-//            case EXTENSION:
-//                break;
-//            case ANGLE_ELLIPSE_TO:
-//                break;
-//            case ANGLE_ELLIPSE:
-//                break;
-//            case ARC_TO:
-//                break;
-//            case ARC:
-//                break;
-//            case CLOCKWISE_ARC_TO:
-//                break;
-//            case CLOCKWISE_ARC:
-//                break;
-//            case ELLIPTICAL_QUADRANT_X:
-//                break;
-//            case ELLIPTICAL_QUADRANT_Y:
-//                break;
-//            case QUADRATIC_BEZIER:
-//                break;
-//            case NO_FILL:
-//                break;
-//            case NO_LINE:
-//                break;
-//            case AUTO_LINE:
-//                break;
-//            case AUTO_CURVE:
-//                break;
-//            case CORNER_LINE:
-//                break;
-//            case CORNER_CURVE:
-//                break;
-//            case SMOOTH_LINE:
-//                break;
-//            case SMOOTH_CURVE:
-//                break;
-//            case SYMMETRIC_LINE:
-//                break;
-//            case SYMMETRIC_CURVE:
-//                break;
-//            case FREEFORM:
-//                break;
-//            case FILL_COLOR:
-//                break;
-//            case LINE_COLOR:
-//                break;
-//            default:
-//                break;
-//        }
-//    }
-    
 
-    private static PathInfo getPathInfo(byte elem[]) {
-        int elemUS = LittleEndian.getUShort(elem, 0);
-        int pathInfo = PATH_INFO.getValue(elemUS);
-        return PathInfo.valueOf(pathInfo);
+        path2D.transform(at);
+
+
+        return path2D;
     }
-    
-//    private static EscapeInfo getEscapeInfo(byte elem[]) {
-//        int elemUS = LittleEndian.getUShort(elem, 0);
-//        int escInfo = ESCAPE_INFO.getValue(elemUS);
-//        return EscapeInfo.valueOf(escInfo);
-//    }
+
+
 }

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java (original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java Fri
Dec 14 00:44:40 2018
@@ -358,17 +358,18 @@ public abstract class HSLFShape implemen
         _sheet = sheet;
     }
 
-    Color getColor(short colorProperty, short opacityProperty, int defaultColor){
-        AbstractEscherOptRecord opt = getEscherOptRecord();
-        EscherSimpleProperty p = getEscherProperty(opt, colorProperty);
-        if(p == null && defaultColor == -1) return null;
-
-        int val = (p == null) ? defaultColor : p.getPropertyValue();
-
-        EscherColorRef ecr = new EscherColorRef(val);
-        Color col = getColor(ecr);
-        if (col == null) {
-            return null;
+    Color getColor(short colorProperty, short opacityProperty){
+        final AbstractEscherOptRecord opt = getEscherOptRecord();
+        final EscherSimpleProperty colProp = getEscherProperty(opt, colorProperty);
+        final Color col;
+        if (colProp == null) {
+            col = Color.WHITE;
+        } else {
+            EscherColorRef ecr = new EscherColorRef(colProp.getPropertyValue());
+            col = getColor(ecr);
+            if (col == null) {
+                return null;
+            }
         }
 
         double alpha = getAlpha(opacityProperty);

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
(original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
Fri Dec 14 00:44:40 2018
@@ -164,7 +164,7 @@ public abstract class HSLFSimpleShape ex
             return null;
         }
 
-        Color clr = getColor(EscherProperties.LINESTYLE__COLOR, EscherProperties.LINESTYLE__OPACITY,
-1);
+        Color clr = getColor(EscherProperties.LINESTYLE__COLOR, EscherProperties.LINESTYLE__OPACITY);
         return clr == null ? null : clr;
     }
 
@@ -179,7 +179,7 @@ public abstract class HSLFSimpleShape ex
             return null;
         }
 
-        Color clr = getColor(EscherProperties.LINESTYLE__BACKCOLOR, EscherProperties.LINESTYLE__OPACITY,
-1);
+        Color clr = getColor(EscherProperties.LINESTYLE__BACKCOLOR, EscherProperties.LINESTYLE__OPACITY);
         return clr == null ? null : clr;
     }
 
@@ -385,7 +385,7 @@ public abstract class HSLFSimpleShape ex
      * @return color of the line. If color is not set returns <code>java.awt.Color.black</code>
      */
     public Color getShadowColor(){
-        Color clr = getColor(EscherProperties.SHADOWSTYLE__COLOR, EscherProperties.SHADOWSTYLE__OPACITY,
-1);
+        Color clr = getColor(EscherProperties.SHADOWSTYLE__COLOR, EscherProperties.SHADOWSTYLE__OPACITY);
         return clr == null ? Color.black : clr;
     }
 

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
(original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
Fri Dec 14 00:44:40 2018
@@ -71,6 +71,7 @@ public final class HSLFSlideShow impleme
 
 	/** Powerpoint document entry/stream name */
     public static final String POWERPOINT_DOCUMENT = "PowerPoint Document";
+	public static final String PP95_DOCUMENT = "PP40";
 
     enum LoadSavePhase {
         INIT, LOADED

Modified: poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
(original)
+++ poi/branches/hemf/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
Fri Dec 14 00:44:40 2018
@@ -17,6 +17,9 @@
 
 package org.apache.poi.hslf.usermodel;
 
+import static org.apache.poi.hslf.usermodel.HSLFSlideShow.POWERPOINT_DOCUMENT;
+import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
@@ -35,6 +38,7 @@ import java.util.TreeMap;
 import org.apache.poi.POIDocument;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
 import org.apache.poi.hslf.record.CurrentUserAtom;
 import org.apache.poi.hslf.record.DocumentEncryptionAtom;
 import org.apache.poi.hslf.record.ExOleObjStg;
@@ -183,13 +187,18 @@ public final class HSLFSlideShowImpl ext
      * @throws IOException when the powerpoint can't be read
      */
     private void readPowerPointStream() throws IOException {
+        final DirectoryNode dir = getDirectory();
+
+        if (!dir.hasEntry(POWERPOINT_DOCUMENT) && dir.hasEntry(PP95_DOCUMENT)) {
+            throw new OldPowerPointFormatException("You seem to have supplied a PowerPoint95
file, which isn't supported");
+        }
+
         // Get the main document stream
-        DocumentEntry docProps =
-                (DocumentEntry) getDirectory().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+        DocumentEntry docProps = (DocumentEntry)dir.getEntry(POWERPOINT_DOCUMENT);
 
         // Grab the document stream
         int len = docProps.getSize();
-        try (InputStream is = getDirectory().createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT))
{
+        try (InputStream is = dir.createDocumentInputStream(docProps)) {
             _docstream = IOUtils.toByteArray(is, len);
         }
     }
@@ -665,8 +674,8 @@ public final class HSLFSlideShowImpl ext
 
         // Write the PPT stream into the POIFS layer
         ByteArrayInputStream bais = new ByteArrayInputStream(_docstream);
-        outFS.createOrUpdateDocument(bais, HSLFSlideShow.POWERPOINT_DOCUMENT);
-        writtenEntries.add(HSLFSlideShow.POWERPOINT_DOCUMENT);
+        outFS.createOrUpdateDocument(bais, POWERPOINT_DOCUMENT);
+        writtenEntries.add(POWERPOINT_DOCUMENT);
 
         currentUser.setEncrypted(encryptedSS.getDocumentEncryptionAtom() != null);
         currentUser.writeToFS(outFS);

Modified: poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java
(original)
+++ poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java
Fri Dec 14 00:44:40 2018
@@ -25,7 +25,6 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    TestBackground.class,
     TestFreeform.class,
     TestHeadersFooters.class,
     TestHyperlink.class,

Modified: poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
(original)
+++ poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
Fri Dec 14 00:44:40 2018
@@ -87,7 +87,7 @@ public final class TestFreeform {
     public void test54188() {
 
         HSLFFreeformShape p = new HSLFFreeformShape();
-        Path2D.Double path = p.getPath();
+        Path2D path = p.getPath();
         Path2D.Double emptyPath = new Path2D.Double();
         assertEquals(emptyPath.getBounds2D(), path.getBounds2D());
     }

Modified: poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java
(original)
+++ poi/branches/hemf/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java
Fri Dec 14 00:44:40 2018
@@ -26,6 +26,7 @@ import org.junit.runners.Suite;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
     TestAddingSlides.class,
+    TestBackground.class,
     TestBugs.class,
     TestCounts.class,
     TestMostRecentRecords.class,

Modified: poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
(original)
+++ poi/branches/hemf/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
Fri Dec 14 00:44:40 2018
@@ -17,6 +17,7 @@
 
 package org.apache.poi.poifs.filesystem;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -278,4 +279,18 @@ public final class TestPOIFSFileSystem {
 	private static InputStream openSampleStream(String sampleFileName) {
 		return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
 	}
+
+	@Test
+	public void fileMagics() {
+		for (FileMagic fm : FileMagic.values()) {
+			if (fm == FileMagic.UNKNOWN) {
+				continue;
+			}
+			for (byte[] b : fm.magic) {
+				assertEquals(fm, FileMagic.valueOf(b));
+			}
+		}
+
+		assertEquals(FileMagic.UNKNOWN, FileMagic.valueOf("foobaa".getBytes(UTF_8)));
+	}
 }

Modified: poi/branches/hemf/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java?rev=1848906&r1=1848905&r2=1848906&view=diff
==============================================================================
--- poi/branches/hemf/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
(original)
+++ poi/branches/hemf/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
Fri Dec 14 00:44:40 2018
@@ -91,9 +91,9 @@ public class TestExcelStyleDateFormatter
      */
     private int localeIndex(Locale locale) {
         final String provider = System.getProperty("java.locale.providers");
-        return jreVersion < 12 ||
+        return jreVersion < 9 ||
             !locale.equals (Locale.CHINESE) ||
-            (provider != null && provider.startsWith("JRE"))
+            (provider != null && (provider.startsWith("JRE") || provider.startsWith("COMPAT")))
             ? 0 : 1;
     }
 



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


Mime
View raw message