add line breaks (0xb) support

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-12 14:40:06 +00:00
parent 5ee8f707be
commit 92381ae7d8
4 changed files with 45 additions and 1 deletions

View File

@ -155,7 +155,31 @@ public abstract class AbstractWordConverter
|| ( text.charAt( text.length() - 1 ) == BEL_MARK && currentTableLevel != 0 ) )
text = text.substring( 0, text.length() - 1 );
outputCharacters( block, characterRun, text );
{
// line breaks
StringBuilder stringBuilder = new StringBuilder();
for ( char charChar : text.toCharArray() )
{
if ( charChar == 11 )
{
if ( stringBuilder.length() > 0 )
{
outputCharacters( block, characterRun, stringBuilder.toString() );
stringBuilder.setLength( 0 );
}
processLineBreak(block, characterRun);
}
else
{
stringBuilder.append( charChar );
}
}
if ( stringBuilder.length() > 0 )
{
outputCharacters( block, characterRun, stringBuilder.toString() );
stringBuilder.setLength( 0 );
}
}
haveAnyText |= text.trim().length() != 0;
}
@ -293,6 +317,9 @@ public abstract class AbstractWordConverter
protected abstract void processImage( Element currentBlock,
boolean inlined, Picture picture );
protected abstract void processLineBreak( Element block,
CharacterRun characterRun );
protected abstract void processPageref( HWPFDocumentCore wordDocument,
Element currentBlock, Range textRange, int currentTableLevel,
String pageref );

View File

@ -82,6 +82,11 @@ public class HtmlDocumentFacade
return basicLink;
}
public Element createLineBreak()
{
return document.createElement( "br" );
}
public Element createListItem()
{
return document.createElement( "li" );

View File

@ -294,6 +294,12 @@ public class WordToFoConverter extends AbstractWordConverter
+ "' can be here" ) );
}
@Override
protected void processLineBreak( Element block, CharacterRun characterRun )
{
block.appendChild( foDocumentFacade.createBlock() );
}
protected void processPageref( HWPFDocumentCore hwpfDocument,
Element currentBlock, Range textRange, int currentTableLevel,
String pageref )

View File

@ -251,6 +251,12 @@ public class WordToHtmlConverter extends AbstractWordConverter
basicLink );
}
@Override
protected void processLineBreak( Element block, CharacterRun characterRun )
{
block.appendChild( htmlDocumentFacade.createLineBreak() );
}
/**
* This method shall store image bytes in external file and convert it if
* necessary. Images shall be stored using PNG format. Other formats may be