You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2011/09/13 18:15:47 UTC

svn commit: r1170227 - /poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java

Author: sergey
Date: Tue Sep 13 16:15:47 2011
New Revision: 1170227

URL: http://svn.apache.org/viewvc?rev=1170227&view=rev
Log:
change default page margins to 0.4 inches and allow to changes them

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java?rev=1170227&r1=1170226&r2=1170227&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Tue Sep 13 16:15:47 2011
@@ -130,6 +130,8 @@ public class ExcelToFoConverter extends 
 
     private final FoDocumentFacade foDocumentFacade;
 
+    private float pageMarginInches = 0.4f;
+
     public ExcelToFoConverter( Document document )
     {
         this.foDocumentFacade = new FoDocumentFacade( document );
@@ -140,7 +142,7 @@ public class ExcelToFoConverter extends 
         final float paperHeightIn;
         final float paperWidthIn;
         {
-            float requiredWidthIn = tableWidthIn + 2;
+            float requiredWidthIn = tableWidthIn + 2 * getPageMarginInches();
 
             if ( requiredWidthIn < PAPER_A4_WIDTH_INCHES )
             {
@@ -157,10 +159,10 @@ public class ExcelToFoConverter extends 
             }
         }
 
-        final float leftMargin = 1;
-        final float rightMargin = 1;
-        final float topMargin = 1;
-        final float bottomMargin = 1;
+        final float leftMargin = getPageMarginInches();
+        final float rightMargin = getPageMarginInches();
+        final float topMargin = getPageMarginInches();
+        final float bottomMargin = getPageMarginInches();
 
         Element pageMaster = foDocumentFacade
                 .addSimplePageMaster( pageMasterName );
@@ -180,6 +182,11 @@ public class ExcelToFoConverter extends 
         return foDocumentFacade.getDocument();
     }
 
+    public float getPageMarginInches()
+    {
+        return pageMarginInches;
+    }
+
     /**
      * Returns <tt>false</tt> if cell style by itself (without text, i.e.
      * borders, fill, etc.) worth a mention, <tt>true</tt> otherwise
@@ -323,8 +330,8 @@ public class ExcelToFoConverter extends 
             block.setAttribute( "keep-together.within-line", "always" );
         }
 
-        processCellStyle( workbook, cell.getCellStyle(),
-                tableCellElement, block );
+        processCellStyle( workbook, cell.getCellStyle(), tableCellElement,
+                block );
 
         block.appendChild( text );
         tableCellElement.appendChild( block );
@@ -812,4 +819,9 @@ public class ExcelToFoConverter extends 
             textBlock.setAttribute( "font-family", triplet.fontName );
     }
 
+    public void setPageMarginInches( float pageMarginInches )
+    {
+        this.pageMarginInches = pageMarginInches;
+    }
+
 }



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