aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java37
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java2
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java16
-rw-r--r--test-data/document/lists-margins.docbin0 -> 10752 bytes
4 files changed, 52 insertions, 3 deletions
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 3b4f4c5525..cffcea5699 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
@@ -553,8 +553,41 @@ public class WordToHtmlConverter extends AbstractWordConverter
{
if ( WordToHtmlUtils.isNotEmpty( bulletText ) )
{
- Text textNode = htmlDocumentFacade.createText( bulletText );
- pElement.appendChild( textNode );
+ 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,
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java
index 5b51af101b..484d367788 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java
@@ -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,
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
index 9a4d1d8b8d..a3efb666a1 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
@@ -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" );
diff --git a/test-data/document/lists-margins.doc b/test-data/document/lists-margins.doc
new file mode 100644
index 0000000000..348a926f06
--- /dev/null
+++ b/test-data/document/lists-margins.doc
Binary files differ