]> source.dussan.org Git - poi.git/commitdiff
change default page margins to 0.4 inches and allow to changes them
authorSergey Vladimirov <sergey@apache.org>
Tue, 13 Sep 2011 16:15:47 +0000 (16:15 +0000)
committerSergey Vladimirov <sergey@apache.org>
Tue, 13 Sep 2011 16:15:47 +0000 (16:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1170227 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java

index 0d031396c05206cfaa1c02a889370169ad9cb318..baea9052f3f04d99efb9a4d39d94247618e3cf29 100644 (file)
@@ -130,6 +130,8 @@ public class ExcelToFoConverter extends AbstractExcelConverter
 
     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 AbstractExcelConverter
         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 AbstractExcelConverter
             }
         }
 
-        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 AbstractExcelConverter
         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 AbstractExcelConverter
             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 AbstractExcelConverter
             textBlock.setAttribute( "font-family", triplet.fontName );
     }
 
+    public void setPageMarginInches( float pageMarginInches )
+    {
+        this.pageMarginInches = pageMarginInches;
+    }
+
 }