change default page margins to 0.4 inches and allow to changes them

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1170227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-09-13 16:15:47 +00:00
parent f3ce711196
commit 95d61faec0

View File

@ -130,6 +130,8 @@ public class ExcelToFoConverter extends AbstractExcelConverter
private final FoDocumentFacade foDocumentFacade; private final FoDocumentFacade foDocumentFacade;
private float pageMarginInches = 0.4f;
public ExcelToFoConverter( Document document ) public ExcelToFoConverter( Document document )
{ {
this.foDocumentFacade = new FoDocumentFacade( document ); this.foDocumentFacade = new FoDocumentFacade( document );
@ -140,7 +142,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
final float paperHeightIn; final float paperHeightIn;
final float paperWidthIn; final float paperWidthIn;
{ {
float requiredWidthIn = tableWidthIn + 2; float requiredWidthIn = tableWidthIn + 2 * getPageMarginInches();
if ( requiredWidthIn < PAPER_A4_WIDTH_INCHES ) if ( requiredWidthIn < PAPER_A4_WIDTH_INCHES )
{ {
@ -157,10 +159,10 @@ public class ExcelToFoConverter extends AbstractExcelConverter
} }
} }
final float leftMargin = 1; final float leftMargin = getPageMarginInches();
final float rightMargin = 1; final float rightMargin = getPageMarginInches();
final float topMargin = 1; final float topMargin = getPageMarginInches();
final float bottomMargin = 1; final float bottomMargin = getPageMarginInches();
Element pageMaster = foDocumentFacade Element pageMaster = foDocumentFacade
.addSimplePageMaster( pageMasterName ); .addSimplePageMaster( pageMasterName );
@ -180,6 +182,11 @@ public class ExcelToFoConverter extends AbstractExcelConverter
return foDocumentFacade.getDocument(); return foDocumentFacade.getDocument();
} }
public float getPageMarginInches()
{
return pageMarginInches;
}
/** /**
* Returns <tt>false</tt> if cell style by itself (without text, i.e. * Returns <tt>false</tt> if cell style by itself (without text, i.e.
* borders, fill, etc.) worth a mention, <tt>true</tt> otherwise * 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" ); block.setAttribute( "keep-together.within-line", "always" );
} }
processCellStyle( workbook, cell.getCellStyle(), processCellStyle( workbook, cell.getCellStyle(), tableCellElement,
tableCellElement, block ); block );
block.appendChild( text ); block.appendChild( text );
tableCellElement.appendChild( block ); tableCellElement.appendChild( block );
@ -812,4 +819,9 @@ public class ExcelToFoConverter extends AbstractExcelConverter
textBlock.setAttribute( "font-family", triplet.fontName ); textBlock.setAttribute( "font-family", triplet.fontName );
} }
public void setPageMarginInches( float pageMarginInches )
{
this.pageMarginInches = pageMarginInches;
}
} }