fix fields processing, improve test case
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1147082 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3f4627ec37
commit
3568e18a60
@ -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 AbstractWordConverter
|
||||
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 AbstractWordConverter
|
||||
{
|
||||
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 AbstractWordConverter
|
||||
{
|
||||
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 AbstractWordConverter
|
||||
}
|
||||
if ( stringBuilder.length() > 0 )
|
||||
{
|
||||
outputCharacters( block, characterRun, stringBuilder.toString() );
|
||||
outputCharacters( block, characterRun,
|
||||
stringBuilder.toString() );
|
||||
stringBuilder.setLength( 0 );
|
||||
}
|
||||
}
|
||||
|
@ -134,8 +134,10 @@ public class TestWordToHtmlConverter extends TestCase
|
||||
{
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user