You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/01/29 17:03:53 UTC

svn commit: r738908 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java

Author: yegor
Date: Thu Jan 29 16:03:52 2009
New Revision: 738908

URL: http://svn.apache.org/viewvc?rev=738908&view=rev
Log:
fixed bugs 40520 and 46553: HSSFFont.applyFont() formats wrong parts of HSSFRichTextString

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=738908&r1=738907&r2=738908&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Thu Jan 29 16:03:52 2009
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta5" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
            <action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
            <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
            <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=738908&r1=738907&r2=738908&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Jan 29 16:03:52 2009
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta5" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
            <action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
            <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
            <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java?rev=738908&r1=738907&r2=738908&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java Thu Jan 29 16:03:52 2009
@@ -109,7 +109,7 @@
         //the range is completed
         short currentFont = NO_FONT;
         if (endIndex != length()) {
-          currentFont = this.getFontAtIndex(startIndex);
+          currentFont = this.getFontAtIndex(endIndex);
         }
 
         //Need to clear the current formatting between the startIndex and endIndex

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java?rev=738908&r1=738907&r2=738908&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java Thu Jan 29 16:03:52 2009
@@ -74,4 +74,59 @@
       r.clearFormatting();
       assertEquals(0, r.numFormattingRuns());
     }
+
+
+    /**
+     * Test case proposed in Bug 40520:  formated twice => will format whole String
+     */
+    public void test40520_1(){
+
+        short font = 3;
+
+        HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+        r.applyFont(0,7,font);
+        r.applyFont(5,9,font);
+
+        for(int i=0; i < 7; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=5; i < 9; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=9; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+    }
+
+    /**
+     * Test case proposed in Bug 40520:  overlapped range => will format whole String
+     */
+    public void test40520_2(){
+
+        short font = 3;
+        HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+        r.applyFont(0,2,font);
+        for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=2; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+
+        r.applyFont(0,2,font);
+        for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=2; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+    }
+
+    /**
+     * Test case proposed in Bug 40520:  formated twice => will format whole String
+     */
+    public void test40520_3(){
+
+        short font = 3;
+        HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+        // wrong order => will format 0-6
+        r.applyFont(0,2,font);
+        r.applyFont(5,7,font);
+        r.applyFont(0,2,font);
+
+        r.applyFont(0,2,font);
+        for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=2; i < 5; i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+        for(int i=5; i < 7; i++) assertEquals(font, r.getFontAtIndex(i));
+        for(int i=7; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+    }
 }



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