poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1173161 - in /poi/trunk: src/scratchpad/src/org/apache/poi/hwpf/converter/ src/scratchpad/testcases/org/apache/poi/hwpf/converter/ test-data/document/
Date Tue, 20 Sep 2011 14:14:18 GMT
Author: sergey
Date: Tue Sep 20 14:14:17 2011
New Revision: 1173161

URL: http://svn.apache.org/viewvc?rev=1173161&view=rev
Log:
handle lists margins

Added:
    poi/trunk/test-data/document/lists-margins.doc   (with props)
Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java?rev=1173161&r1=1173160&r2=1173161&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java Tue
Sep 20 14:14:17 2011
@@ -553,8 +553,41 @@ public class WordToHtmlConverter extends
         {
             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,

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java?rev=1173161&r1=1173160&r2=1173161&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlUtils.java Tue Sep
20 14:14:17 2011
@@ -143,7 +143,7 @@ public class WordToHtmlUtils extends Abs
         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,

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java?rev=1173161&r1=1173160&r2=1173161&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java
Tue Sep 20 14:14:17 2011
@@ -191,6 +191,22 @@ public class TestWordToHtmlConverter ext
         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" );

Added: poi/trunk/test-data/document/lists-margins.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/lists-margins.doc?rev=1173161&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/lists-margins.doc
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message