tag r1868490 as 4.1.1

git-svn-id: https://svn.apache.org/repos/asf/poi/tags/REL_4_1_1@1868491 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sonar/examples/pom.xml b/sonar/examples/pom.xml
index 0c16a89..f67fc81 100644
--- a/sonar/examples/pom.xml
+++ b/sonar/examples/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
     </parent>
     <artifactId>poi-examples</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/excelant/pom.xml b/sonar/excelant/pom.xml
index 6008b44..3993a12 100644
--- a/sonar/excelant/pom.xml
+++ b/sonar/excelant/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
     </parent>
     <artifactId>poi-excelant</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/main/pom.xml b/sonar/main/pom.xml
index 464149b..23c9b96 100644
--- a/sonar/main/pom.xml
+++ b/sonar/main/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
     </parent>
     <artifactId>poi-main</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/ooxml-schema-encryption/pom.xml b/sonar/ooxml-schema-encryption/pom.xml
index f18ec33..3db0f22 100644
--- a/sonar/ooxml-schema-encryption/pom.xml
+++ b/sonar/ooxml-schema-encryption/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-encryption</artifactId>
diff --git a/sonar/ooxml-schema-security/pom.xml b/sonar/ooxml-schema-security/pom.xml
index 8735be7..58e355a 100644
--- a/sonar/ooxml-schema-security/pom.xml
+++ b/sonar/ooxml-schema-security/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema-security</artifactId>
diff --git a/sonar/ooxml-schema/pom.xml b/sonar/ooxml-schema/pom.xml
index eaabe65..2963e13 100644
--- a/sonar/ooxml-schema/pom.xml
+++ b/sonar/ooxml-schema/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <artifactId>poi-ooxml-schema</artifactId>
diff --git a/sonar/ooxml/pom.xml b/sonar/ooxml/pom.xml
index c778f43..332c6e4 100644
--- a/sonar/ooxml/pom.xml
+++ b/sonar/ooxml/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
     </parent>
     <artifactId>poi-ooxml</artifactId>
     <packaging>jar</packaging>
diff --git a/sonar/pom.xml b/sonar/pom.xml
index ed6dbd9..91e5062 100644
--- a/sonar/pom.xml
+++ b/sonar/pom.xml
@@ -4,7 +4,7 @@
     <groupId>org.apache.poi</groupId>
     <artifactId>poi-parent</artifactId>
     <packaging>pom</packaging>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
     <name>Apache POI - the Java API for Microsoft Documents</name>
     <description>Maven build of Apache POI for Sonar checks</description>
     <url>http://poi.apache.org/</url>
diff --git a/sonar/scratchpad/pom.xml b/sonar/scratchpad/pom.xml
index 6cd27ab..dc94d9e 100644
--- a/sonar/scratchpad/pom.xml
+++ b/sonar/scratchpad/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-parent</artifactId>
-        <version>4.1.1-SNAPSHOT</version>
+        <version>4.1.2-SNAPSHOT</version>
     </parent>
     <artifactId>poi-scratchpad</artifactId>
     <packaging>jar</packaging>
diff --git a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
index d90d500..3d95698 100644
--- a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
+++ b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
@@ -16,6 +16,8 @@
  */
 
 package org.apache.poi.ss.usermodel;
+
+import java.math.BigDecimal;
 import java.text.FieldPosition;
 import java.text.Format;
 import java.text.ParsePosition;
@@ -99,14 +101,15 @@
 
     public String format(Number num) {
 
-        final double doubleValue = num.doubleValue();
+        final BigDecimal doubleValue = new BigDecimal(num.doubleValue());
         
-        final boolean isNeg = (doubleValue < 0.0f) ? true : false;
-        final double absDoubleValue = Math.abs(doubleValue);
-        
-        final double wholePart = Math.floor(absDoubleValue);
-        final double decPart = absDoubleValue - wholePart;
-        if (wholePart + decPart == 0) {
+        final boolean isNeg = doubleValue.compareTo(BigDecimal.ZERO) < 0;
+
+        final BigDecimal absValue = doubleValue.abs();
+        final BigDecimal wholePart = new BigDecimal(absValue.toBigInteger());
+        final BigDecimal decPart = absValue.remainder(BigDecimal.ONE);
+
+        if (wholePart.add(decPart).compareTo(BigDecimal.ZERO) == 0) {
             return "0";
         }
         
@@ -119,13 +122,13 @@
         // }
         
         //this is necessary to prevent overflow in the maxDenom calculation
-        if (Double.compare(decPart, 0) == 0){
+        if (decPart.compareTo(BigDecimal.ZERO) == 0){
             
             StringBuilder sb = new StringBuilder();
             if (isNeg){
                 sb.append("-");
             }
-            sb.append((int)wholePart);
+            sb.append(wholePart);
             return sb.toString();
         }
         
@@ -133,13 +136,13 @@
         try{
             //this should be the case because of the constructor
             if (exactDenom > 0){
-                fract = SimpleFraction.buildFractionExactDenominator(decPart, exactDenom);
+                fract = SimpleFraction.buildFractionExactDenominator(decPart.doubleValue(), exactDenom);
             } else {
-                fract = SimpleFraction.buildFractionMaxDenominator(decPart, maxDenom);
+                fract = SimpleFraction.buildFractionMaxDenominator(decPart.doubleValue(), maxDenom);
             }
         } catch (RuntimeException e){
             LOGGER.log(POILogger.WARN, "Can't format fraction", e);
-            return Double.toString(doubleValue);
+            return Double.toString(doubleValue.doubleValue());
         }
 
         StringBuilder sb = new StringBuilder();
@@ -151,23 +154,25 @@
         
         //if whole part has to go into the numerator
         if (wholePartFormatString == null || wholePartFormatString.isEmpty()){
-            int trueNum = (fract.getDenominator()*(int)wholePart)+fract.getNumerator();
-            sb.append(trueNum).append("/").append(fract.getDenominator());
+            final int fden = fract.getDenominator();
+            final int fnum = fract.getNumerator();
+            BigDecimal trueNum = wholePart.multiply(new BigDecimal(fden)).add(new BigDecimal(fnum));
+            sb.append(trueNum.toBigInteger()).append("/").append(fden);
             return sb.toString();
         }
         
         
         //short circuit if fraction is 0 or 1
         if (fract.getNumerator() == 0){
-            sb.append(Integer.toString((int)wholePart));
+            sb.append(wholePart);
             return sb.toString();
         } else if (fract.getNumerator() == fract.getDenominator()){
-            sb.append(Integer.toString((int)wholePart+1));
+            sb.append(wholePart.add(BigDecimal.ONE));
             return sb.toString();
         }
        //as mentioned above, this ignores the exact space formatting in Excel
-        if (wholePart > 0){
-            sb.append(Integer.toString((int)wholePart)).append(" ");
+        if (wholePart.compareTo(BigDecimal.ZERO) > 0){
+            sb.append(wholePart).append(" ");
         }
         sb.append(fract.getNumerator()).append("/").append(fract.getDenominator());
         return sb.toString();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
index 824122b..dd7afa4 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
@@ -337,7 +337,7 @@
         }
 
 
-        EscherPropertyTypes escherProp = ADJUST_VALUES[adjInt];
+        EscherPropertyTypes escherProp = ADJUST_VALUES[adjInt-1];
 
         int adjval = getEscherProperty(escherProp, -1);
 
diff --git a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
index aebe0fd..19f54bb 100644
--- a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
+++ b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
@@ -33,102 +33,102 @@
 import org.junit.Test;
 
 public final class TestHPSFPropertiesExtractor {
-	private static final POIDataSamples _samples = POIDataSamples.getHPSFInstance();
+    private static final POIDataSamples _samples = POIDataSamples.getHPSFInstance();
 
-	@Test
-	public void testNormalProperties() throws Exception {
-		try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
-			POIFSFileSystem fs = new POIFSFileSystem(is);
-			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
-			// Check each bit in turn
-			String summary = ext.getSummaryInformationText();
-			String docSummary = ext.getDocumentSummaryInformationText();
+    @Test
+    public void testNormalProperties() throws Exception {
+        try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
+             POIFSFileSystem fs = new POIFSFileSystem(is);
+             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+            // Check each bit in turn
+            String summary = ext.getSummaryInformationText();
+            String docSummary = ext.getDocumentSummaryInformationText();
 
-			assertContains(summary, "TEMPLATE = Normal");
-			assertContains(summary, "SUBJECT = sample subject");
-			assertContains(docSummary, "MANAGER = sample manager");
-			assertContains(docSummary, "COMPANY = sample company");
+            assertContains(summary, "TEMPLATE = Normal");
+            assertContains(summary, "SUBJECT = sample subject");
+            assertContains(docSummary, "MANAGER = sample manager");
+            assertContains(docSummary, "COMPANY = sample company");
 
-			// Now overall
-			String text = ext.getText();
-			assertContains(text, "TEMPLATE = Normal");
-			assertContains(text, "SUBJECT = sample subject");
-			assertContains(text, "MANAGER = sample manager");
-			assertContains(text, "COMPANY = sample company");
-		}
-	}
+            // Now overall
+            String text = ext.getText();
+            assertContains(text, "TEMPLATE = Normal");
+            assertContains(text, "SUBJECT = sample subject");
+            assertContains(text, "MANAGER = sample manager");
+            assertContains(text, "COMPANY = sample company");
+        }
+    }
 
-	@Test
-	public void testNormalUnicodeProperties() throws Exception {
+    @Test
+    public void testNormalUnicodeProperties() throws Exception {
 
-		try (InputStream is = _samples.openResourceAsStream("TestUnicode.xls");
-		 	POIFSFileSystem fs = new POIFSFileSystem(is);
-			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
-			// Check each bit in turn
-			String summary = ext.getSummaryInformationText();
-			String docSummary = ext.getDocumentSummaryInformationText();
+        try (InputStream is = _samples.openResourceAsStream("TestUnicode.xls");
+             POIFSFileSystem fs = new POIFSFileSystem(is);
+             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+            // Check each bit in turn
+            String summary = ext.getSummaryInformationText();
+            String docSummary = ext.getDocumentSummaryInformationText();
 
-			assertContains(summary, "AUTHOR = marshall");
-			assertContains(summary, "TITLE = Titel: \u00c4h");
-			assertContains(docSummary, "COMPANY = Schreiner");
-			assertContains(docSummary, "SCALE = false");
+            assertContains(summary, "AUTHOR = marshall");
+            assertContains(summary, "TITLE = Titel: \u00c4h");
+            assertContains(docSummary, "COMPANY = Schreiner");
+            assertContains(docSummary, "SCALE = false");
 
-			// Now overall
-			String text = ext.getText();
-			assertContains(text, "AUTHOR = marshall");
-			assertContains(text, "TITLE = Titel: \u00c4h");
-			assertContains(text, "COMPANY = Schreiner");
-			assertContains(text, "SCALE = false");
-		}
-	}
+            // Now overall
+            String text = ext.getText();
+            assertContains(text, "AUTHOR = marshall");
+            assertContains(text, "TITLE = Titel: \u00c4h");
+            assertContains(text, "COMPANY = Schreiner");
+            assertContains(text, "SCALE = false");
+        }
+    }
 
-	@Test
-	public void testCustomProperties() throws Exception {
-		try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
-			 POIFSFileSystem fs = new POIFSFileSystem(is);
-			 HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+    @Test
+    public void testCustomProperties() throws Exception {
+        try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
+             POIFSFileSystem fs = new POIFSFileSystem(is);
+             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
 
-			// Custom properties are part of the document info stream
-			String dinfText = ext.getDocumentSummaryInformationText();
-			assertContains(dinfText, "Client = sample client");
-			assertContains(dinfText, "Division = sample division");
+            // Custom properties are part of the document info stream
+            String dinfText = ext.getDocumentSummaryInformationText();
+            assertContains(dinfText, "Client = sample client");
+            assertContains(dinfText, "Division = sample division");
 
-			String text = ext.getText();
-			assertContains(text, "Client = sample client");
-			assertContains(text, "Division = sample division");
-		}
-	}
+            String text = ext.getText();
+            assertContains(text, "Client = sample client");
+            assertContains(text, "Division = sample division");
+        }
+    }
 
-	@Test
-	public void testConstructors() throws IOException {
-		POIFSFileSystem fs;
-		HSSFWorkbook wb;
-		try {
-			fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
-			wb = new HSSFWorkbook(fs);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		ExcelExtractor excelExt = new ExcelExtractor(wb);
+    @Test
+    public void testConstructors() throws IOException {
+        POIFSFileSystem fs;
+        HSSFWorkbook wb;
+        try {
+            fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
+            wb = new HSSFWorkbook(fs);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        ExcelExtractor excelExt = new ExcelExtractor(wb);
 
-		final String fsText;
-		HPSFPropertiesExtractor fsExt = new HPSFPropertiesExtractor(fs);
-		fsExt.setFilesystem(null); // Don't close re-used test resources!
-		try {
-		    fsText = fsExt.getText();
-		} finally {
-		    fsExt.close();
-		}
-        
-        final String hwText; 
-		HPSFPropertiesExtractor hwExt = new HPSFPropertiesExtractor(wb);
-		hwExt.setFilesystem(null); // Don't close re-used test resources!
-		try {
-		    hwText = hwExt.getText();
-		} finally {
-		    hwExt.close();
-		}
-		
+        final String fsText;
+        HPSFPropertiesExtractor fsExt = new HPSFPropertiesExtractor(fs);
+        fsExt.setFilesystem(null); // Don't close re-used test resources!
+        try {
+            fsText = fsExt.getText();
+        } finally {
+            fsExt.close();
+        }
+
+        final String hwText;
+        HPSFPropertiesExtractor hwExt = new HPSFPropertiesExtractor(wb);
+        hwExt.setFilesystem(null); // Don't close re-used test resources!
+        try {
+            hwText = hwExt.getText();
+        } finally {
+            hwExt.close();
+        }
+
         final String eeText;
         HPSFPropertiesExtractor eeExt = new HPSFPropertiesExtractor(excelExt);
         eeExt.setFilesystem(null); // Don't close re-used test resources!
@@ -139,26 +139,26 @@
             wb.close();
         }
 
-		assertEquals(fsText, hwText);
-		assertEquals(fsText, eeText);
+        assertEquals(fsText, hwText);
+        assertEquals(fsText, eeText);
 
-		assertContains(fsText, "AUTHOR = marshall");
-		assertContains(fsText, "TITLE = Titel: \u00c4h");
-	}
+        assertContains(fsText, "AUTHOR = marshall");
+        assertContains(fsText, "TITLE = Titel: \u00c4h");
+    }
 
-	@Test
-	public void test42726() throws IOException {
-		try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("42726.xls");
-				HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(wb)) {
-			String txt = ext.getText();
-			assertContains(txt, "PID_AUTHOR");
-			assertContains(txt, "PID_EDITTIME");
-			assertContains(txt, "PID_REVNUMBER");
-			assertContains(txt, "PID_THUMBNAIL");
-		}
-	}
+    @Test
+    public void test42726() throws IOException {
+        try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("42726.xls");
+             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(wb)) {
+            String txt = ext.getText();
+            assertContains(txt, "PID_AUTHOR");
+            assertContains(txt, "PID_EDITTIME");
+            assertContains(txt, "PID_REVNUMBER");
+            assertContains(txt, "PID_THUMBNAIL");
+        }
+    }
 
-	@Test
+    @Test
     public void testThumbnail() throws Exception {
         POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestThumbnail.xls"));
         HSSFWorkbook wb = new HSSFWorkbook(fs);
@@ -169,25 +169,25 @@
         wb.close();
     }
 
-	@Test
+    @Test
     public void test52258() throws Exception {
-		try (InputStream is = _samples.openResourceAsStream("TestVisioWithCodepage.vsd");
-			 POIFSFileSystem fs = new POIFSFileSystem(is);
-			 HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
-			assertNotNull(ext.getDocSummaryInformation());
-			assertNotNull(ext.getDocumentSummaryInformationText());
-			assertNotNull(ext.getSummaryInformation());
-			assertNotNull(ext.getSummaryInformationText());
-			assertNotNull(ext.getText());
-		}
+        try (InputStream is = _samples.openResourceAsStream("TestVisioWithCodepage.vsd");
+             POIFSFileSystem fs = new POIFSFileSystem(is);
+             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+            assertNotNull(ext.getDocSummaryInformation());
+            assertNotNull(ext.getDocumentSummaryInformationText());
+            assertNotNull(ext.getSummaryInformation());
+            assertNotNull(ext.getSummaryInformationText());
+            assertNotNull(ext.getText());
+        }
     }
 
-	@Test
-	public void test61300Extractor() throws IOException {
-		try (POIFSFileSystem poifs = new POIFSFileSystem(
-				POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
-			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(poifs);
-			assertContains(ext.getText(), "PID_CODEPAGE = 1252");
-		}
-	}
+    @Test
+    public void test61300Extractor() throws IOException {
+        try (POIFSFileSystem poifs = new POIFSFileSystem(
+                POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
+            HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(poifs);
+            assertContains(ext.getText(), "PID_CODEPAGE = 1252");
+        }
+    }
 }
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java b/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
index e99c3fe..dd08f6d 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
@@ -41,6 +41,22 @@
         String ret = f.format(val);
         assertEquals("26027/81", ret);
     }
+    
+    @Test
+    public void testWithBigWholePart() throws Exception {
+        FractionFormat f = new FractionFormat("#", "???/???");
+        
+        assertEquals("10100136259702", f.format(10100136259702d));
+        assertEquals("-10100136259702", f.format(-10100136259702d));
+        
+        // Excel displays fraction: 51/512
+        assertEquals("10100136259702 10/100", f.format(10100136259702.1d));
+        assertEquals("-10100136259702 10/100", f.format(-10100136259702.1d));
+        
+        // Excel displays fraction: 461/512
+        assertEquals("10100136259702 90/100", f.format(10100136259702.9d));
+        assertEquals("-10100136259702 90/100", f.format(-10100136259702.9d));
+    }
      
     @Test
     public void testTruthFile() throws Exception {