diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java index 2f740f5131..64494a9c8c 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java @@ -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 ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/HtmlDocumentFacade.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/HtmlDocumentFacade.java index 186f037a5a..d43fd44945 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/converter/HtmlDocumentFacade.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/HtmlDocumentFacade.java @@ -82,6 +82,11 @@ public class HtmlDocumentFacade return basicLink; } + public Element createLineBreak() + { + return document.createElement( "br" ); + } + public Element createListItem() { return document.createElement( "li" ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java index e1f47d7385..7d118dbca5 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java @@ -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 ) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java index 4c8e03f291..5daf0375b8 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java @@ -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