Browse Source

add line breaks (0xb) support

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145609 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_8_BETA4
Sergey Vladimirov 13 years ago
parent
commit
4951c48fb1

+ 28
- 1
src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java 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 );

+ 5
- 0
src/scratchpad/src/org/apache/poi/hwpf/converter/HtmlDocumentFacade.java 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" );

+ 6
- 0
src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java 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 )

+ 6
- 0
src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java 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

Loading…
Cancel
Save