poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1147082 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwpf/converter/AbstractWordConverter.java testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Date Fri, 15 Jul 2011 10:52:14 GMT
Author: sergey
Date: Fri Jul 15 10:52:11 2011
New Revision: 1147082

URL: http://svn.apache.org/viewvc?rev=1147082&view=rev
Log:
fix fields processing, improve test case

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java?rev=1147082&r1=1147081&r2=1147082&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
Fri Jul 15 10:52:11 2011
@@ -19,11 +19,10 @@ package org.apache.poi.hwpf.converter;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.poi.hwpf.converter.FontReplacer.Triplet;
-
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFDocumentCore;
+import org.apache.poi.hwpf.converter.FontReplacer.Triplet;
 import org.apache.poi.hwpf.model.Field;
 import org.apache.poi.hwpf.model.FieldsTables;
 import org.apache.poi.hwpf.model.ListFormatOverride;
@@ -77,7 +76,7 @@ public abstract class AbstractWordConver
     protected boolean processCharacters( HWPFDocumentCore hwpfDocument,
             int currentTableLevel, Range range, final Element block )
     {
-        if (range == null)
+        if ( range == null )
             return false;
 
         boolean haveAnyText = false;
@@ -118,7 +117,15 @@ public abstract class AbstractWordConver
                     {
                         processField( ( (HWPFDocument) hwpfDocument ), range,
                                 currentTableLevel, aliveField, block );
-                        c = aliveField.getEndOffset();
+
+                        int continueAfter = aliveField.getEndOffset();
+                        while ( range.getCharacterRun( c ).getEndOffset() <= continueAfter
+                                && c < range.numCharacterRuns() )
+                            c++;
+
+                        if ( c < range.numCharacterRuns() )
+                            c--;
+
                         continue;
                     }
                 }
@@ -164,10 +171,11 @@ public abstract class AbstractWordConver
                     {
                         if ( stringBuilder.length() > 0 )
                         {
-                            outputCharacters( block, characterRun, stringBuilder.toString()
);
+                            outputCharacters( block, characterRun,
+                                    stringBuilder.toString() );
                             stringBuilder.setLength( 0 );
                         }
-                        processLineBreak(block, characterRun);
+                        processLineBreak( block, characterRun );
                     }
                     else
                     {
@@ -176,7 +184,8 @@ public abstract class AbstractWordConver
                 }
                 if ( stringBuilder.length() > 0 )
                 {
-                    outputCharacters( block, characterRun, stringBuilder.toString() );
+                    outputCharacters( block, characterRun,
+                            stringBuilder.toString() );
                     stringBuilder.setLength( 0 );
                 }
             }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java?rev=1147082&r1=1147081&r2=1147082&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Fri Jul 15 10:52:11 2011
@@ -134,8 +134,10 @@ public class TestWordToHtmlConverter ext
     {
         String result = getHtmlText( "hyperlink.doc" );
 
-        assertContains( result, "<a href=\"http://testuri.org/\">" );
-        assertContains( result, "Hyperlink text" );
+        assertContains( result, "<span>Before text; </span><a " );
+        assertContains( result,
+                "<a href=\"http://testuri.org/\"><span>Hyperlink text</span></a>"
);
+        assertContains( result, "</a><span>; after text</span>" );
     }
 
     public void testInnerTable() throws Exception



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


Mime
View raw message