poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1874983 - in /poi/trunk/src: java/org/apache/poi/ss/format/ ooxml/java/org/apache/poi/xwpf/usermodel/ ooxml/testcases/org/apache/poi/xwpf/usermodel/ testcases/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/ss/format/
Date Sun, 08 Mar 2020 20:17:19 GMT
Author: centic
Date: Sun Mar  8 20:17:19 2020
New Revision: 1874983

URL: http://svn.apache.org/viewvc?rev=1874983&view=rev
Log:
Work on bug 64038 and other bugs and add test for 62865

Modified:
    poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
    poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java

Modified: poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java?rev=1874983&r1=1874982&r2=1874983&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/format/CellNumberFormatter.java Sun Mar  8 20:17:19
2020
@@ -766,7 +766,6 @@ public class CellNumberFormatter extends
         }
 
         ListIterator<Special> it = numSpecials.listIterator(numSpecials.size());
-        boolean followWithGroupingSeparator = false;
         Special lastOutputIntegerDigit = null;
         int digit = 0;
         while (it.hasPrevious()) {
@@ -778,7 +777,7 @@ public class CellNumberFormatter extends
                 resultCh = '0';
             }
             Special s = it.previous();
-            followWithGroupingSeparator = showGroupingSeparator && digit > 0 &&
digit % 3 == 0;
+            boolean followWithGroupingSeparator = showGroupingSeparator && digit
> 0 && digit % 3 == 0;
             boolean zeroStrip = false;
             if (resultCh != '0' || s.ch == '0' || s.ch == '?' || pos >= strip) {
                 zeroStrip = s.ch == '?' && pos < strip;
@@ -787,7 +786,6 @@ public class CellNumberFormatter extends
             }
             if (followWithGroupingSeparator) {
                 mods.add(insertMod(s, zeroStrip ? " " : groupingSeparator, CellNumberStringMod.AFTER));
-                followWithGroupingSeparator = false;
             }
             digit++;
             --pos;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1874983&r1=1874982&r2=1874983&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Sun Mar  8 20:17:19
2020
@@ -420,7 +420,7 @@ public class XWPFParagraph implements IB
         }
         return null;
     }
-    
+
     /**
      * Indicates whether this paragraph should be kept on the same page as the next one.
      *
@@ -432,9 +432,9 @@ public class XWPFParagraph implements IB
         }
         return false;
     }
-    
+
     /**
-     * Sets this paragraph to be kept on the same page as the next one or not. 
+     * Sets this paragraph to be kept on the same page as the next one or not.
      *
      * @since POI 4.1.1
      */
@@ -1092,7 +1092,7 @@ public class XWPFParagraph implements IB
             return val[0].doubleValue() + (val[1].doubleValue() / 240L);
         }
         BigInteger[] val = spacing.getLine().divideAndRemainder(BigInteger.valueOf(20L));
-        return val[0].doubleValue() + (val[1].doubleValue() / 20L);        
+        return val[0].doubleValue() + (val[1].doubleValue() / 20L);
     }
 
     /**
@@ -1105,8 +1105,8 @@ public class XWPFParagraph implements IB
      *               font size. If AT_LEAST, then spacing value is in inches, and is the
      *               minimum size of the line. If the line height is taller, then the
      *               line expands to match. If EXACT, then spacing is the exact line
-     *               height. If the text is taller than the line height, then it is 
-     *               clipped at the top. 
+     *               height. If the text is taller than the line height, then it is
+     *               clipped at the top.
      */
     public void setSpacingBetween(double spacing, LineSpacingRule rule) {
         CTSpacing ctSp = getCTSpacing(true);
@@ -1117,7 +1117,7 @@ public class XWPFParagraph implements IB
         }
         ctSp.setLineRule(STLineSpacingRule.Enum.forInt(rule.getValue()));
     }
-    
+
     /**
      * Sets the spacing between lines in a paragraph
      *
@@ -1126,7 +1126,7 @@ public class XWPFParagraph implements IB
     public void setSpacingBetween(double spacing) {
         setSpacingBetween(spacing, LineSpacingRule.AUTO);
     }
-    
+
     /**
      * Specifies the indentation which shall be placed between the left text
      * margin for this paragraph and the left edge of that paragraph's content
@@ -1460,17 +1460,17 @@ public class XWPFParagraph implements IB
      * @since POI 4.1.1
      */
     public XWPFHyperlinkRun createHyperlinkRun(String uri) {
-        // Create a relationship ID for this link. 
+        // Create a relationship ID for this link.
         String rId = getPart().getPackagePart().addExternalRelationship(
                 uri, XWPFRelation.HYPERLINK.getRelation()
         ).getId();
-        
-        // Create the run. 
+
+        // Create the run.
         CTHyperlink ctHyperLink = getCTP().addNewHyperlink();
         ctHyperLink.setId(rId);
         ctHyperLink.addNewR();
-        
-        // Append this run to the paragraph. 
+
+        // Append this run to the paragraph.
         XWPFHyperlinkRun link = new XWPFHyperlinkRun(ctHyperLink, ctHyperLink.getRArray(0),
this);
         runs.add(link);
         iruns.add(link);
@@ -1481,7 +1481,7 @@ public class XWPFParagraph implements IB
      * insert a new Run in RunArray
      *
      * @param pos The position at which the new run should be added.
-     * 
+     *
      * @return the inserted run or null if the given pos is out of bounds.
      */
     public XWPFRun insertNewRun(int pos) {
@@ -1537,7 +1537,7 @@ public class XWPFParagraph implements IB
             startChar = startPos.getChar();
         int beginRunPos = 0, candCharPos = 0;
         boolean newList = false;
-        
+
         CTR[] rArray = paragraph.getRArray();
         for (int runPos = startRun; runPos < rArray.length; runPos++) {
             int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos;
@@ -1555,7 +1555,7 @@ public class XWPFParagraph implements IB
                             } else {
                                 charPos = 0;
                             }
-    
+
                             for (; charPos < candidate.length(); charPos++) {
                                 if ((candidate.charAt(charPos) == searched.charAt(0)) &&
(candCharPos == 0)) {
                                     beginTextPos = textPos;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1874983&r1=1874982&r2=1874983&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Sun
Mar  8 20:17:19 2020
@@ -198,6 +198,8 @@ public final class TestXWPFDocument {
             XWPFHyperlinkRun h = p.createHyperlinkRun("https://poi.apache.org/");
             h.setText("Apache POI");
 
+            assertEquals("rId7", h.getHyperlinkId());
+
             assertEquals("https://poi.apache.org/", h.getHyperlink(doc).getURL());
             assertEquals(p.getRuns().size(), 1);
             assertEquals(p.getRuns().get(0), h);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java?rev=1874983&r1=1874982&r2=1874983&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java Sun Mar  8
20:17:19 2020
@@ -109,7 +109,13 @@ public final class TestUnfixedBugs {
     }
 
     @Test
-    public void testDataFormattingWithQuestionMark() {
+    public void testBug62242() {
+        CellFormat cfUK  = CellFormat.getInstance("_ * #,##0.00_ ;_ * \\-#,##0.00_ ;_ * \"-\"??_
;_ @_");
+        assertEquals("    -   ", cfUK.apply((double) 0).text);
+    }
+
+    @Test
+    public void testDataFormattingWithQuestionMarkBug62242() {
         // The question mark in the format should be replaced by blanks, but
         // this is currently not handled when producing the Java formatting and
         // so we end up with a trailing zero here
@@ -118,13 +124,16 @@ public final class TestUnfixedBugs {
     }
 
     @Test
-    public void testDataFormattingWithQuestionMarkAndPound() {
+    public void testDataFormattingWithQuestionMarkAndPoundBug62242() {
         char pound = '\u00A3';
 
         // The question mark in the format should be replaced by blanks, but
         // this is currently not handled when producing the Java formatting and
         // so we end up with a trailing zero here
         CellFormat cfUK  = CellFormat.getInstance("_-[$£-809]* \"-\"??_-");
-        assertEquals(" "+pound+"   -  ", cfUK.apply((double) 0).text);
+        assertEquals(" "+pound+"   -   ", cfUK.apply((double) 0).text);
+
+        cfUK  = CellFormat.getInstance("_-[$£-809]* \"-\"??_-a");
+        assertEquals(" "+pound+"   -   a", cfUK.apply((double) 0).text);
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java?rev=1874983&r1=1874982&r2=1874983&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java Sun Mar  8 20:17:19
2020
@@ -1007,4 +1007,10 @@ public class TestCellFormat {
         assertNotNull(instance);
         assertEquals("01/01/1970", instance.apply(new Date(12345)).text);
     }
+
+    @Test
+    public void testBug62865() {
+        CellFormat cf = CellFormat.getInstance("\"ca. \"0");
+        assertEquals("ca. 5", cf.apply((double) 5).text);
+    }
 }



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


Mime
View raw message