handle lists margins
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1173161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a99be3269
commit
f779c3f462
@ -553,9 +553,42 @@ public class WordToHtmlConverter extends AbstractWordConverter
|
||||
{
|
||||
if ( WordToHtmlUtils.isNotEmpty( bulletText ) )
|
||||
{
|
||||
Text textNode = htmlDocumentFacade.createText( bulletText );
|
||||
if ( bulletText.endsWith( "\t" ) )
|
||||
{
|
||||
/*
|
||||
* We don't know how to handle all cases in HTML, but at
|
||||
* least simplest case shall be handled
|
||||
*/
|
||||
final float defaultTab = TWIPS_PER_INCH / 2;
|
||||
float firstLinePosition = paragraph.getIndentFromLeft()
|
||||
+ paragraph.getFirstLineIndent() + 20; // char have
|
||||
// some space
|
||||
|
||||
float nextStop = (float) ( Math.ceil( firstLinePosition
|
||||
/ defaultTab ) * defaultTab );
|
||||
|
||||
final float spanMinWidth = nextStop - firstLinePosition;
|
||||
|
||||
Element span = htmlDocumentFacade.getDocument()
|
||||
.createElement( "span" );
|
||||
htmlDocumentFacade
|
||||
.addStyleClass( span, "s",
|
||||
"display: inline-block; text-indent: 0; min-width: "
|
||||
+ ( spanMinWidth / TWIPS_PER_INCH )
|
||||
+ "in;" );
|
||||
pElement.appendChild( span );
|
||||
|
||||
Text textNode = htmlDocumentFacade.createText( bulletText
|
||||
.substring( 0, bulletText.length() - 1 ) );
|
||||
span.appendChild( textNode );
|
||||
}
|
||||
else
|
||||
{
|
||||
Text textNode = htmlDocumentFacade.createText( bulletText
|
||||
.substring( 0, bulletText.length() - 1 ) );
|
||||
pElement.appendChild( textNode );
|
||||
}
|
||||
}
|
||||
|
||||
processCharacters( hwpfDocument, currentTableLevel, paragraph,
|
||||
pElement );
|
||||
|
@ -143,7 +143,7 @@ public class WordToHtmlUtils extends AbstractWordUtils
|
||||
if ( twipsValue == 0 )
|
||||
return;
|
||||
|
||||
style.append( cssName + ":" + ( twipsValue / TWIPS_PER_PT ) + "pt;" );
|
||||
style.append( cssName + ":" + ( twipsValue / TWIPS_PER_INCH ) + "in;" );
|
||||
}
|
||||
|
||||
public static void addJustification( Paragraph paragraph,
|
||||
|
@ -191,6 +191,22 @@ public class TestWordToHtmlConverter extends TestCase
|
||||
getHtmlText( "innertable.doc" );
|
||||
}
|
||||
|
||||
public void testListsMargins() throws Exception
|
||||
{
|
||||
String result = getHtmlText( "lists-margins.doc" );
|
||||
|
||||
assertContains( result,
|
||||
".s1{display: inline-block; text-indent: 0; min-width: 0.4861111in;}" );
|
||||
assertContains( result,
|
||||
".s2{display: inline-block; text-indent: 0; min-width: 0.23055555in;}" );
|
||||
assertContains( result,
|
||||
".s3{display: inline-block; text-indent: 0; min-width: 0.28541666in;}" );
|
||||
assertContains( result,
|
||||
".s4{display: inline-block; text-indent: 0; min-width: 0.28333333in;}" );
|
||||
assertContains( result,
|
||||
".p4{text-indent:-0.59652776in;margin-left:-0.70069444in;" );
|
||||
}
|
||||
|
||||
public void testO_kurs_doc() throws Exception
|
||||
{
|
||||
getHtmlText( "o_kurs.doc" );
|
||||
|
BIN
test-data/document/lists-margins.doc
Normal file
BIN
test-data/document/lists-margins.doc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user