* @param spm SimplePageMaster containing the dimensions for this
* page-reference-area
*/
public Page(SimplePageMaster spm) {
// Width and Height of the page view port
FODimension pageViewPortDims = new FODimension(spm.getPageWidth().getValue()
, spm.getPageHeight().getValue());
// Get absolute margin properties (top, left, bottom, right)
CommonMarginBlock mProps = spm.getCommonMarginBlock();
/*
* Create the page reference area rectangle (0,0 is at top left
* of the "page media" and y increases
* when moving towards the bottom of the page.
* The media rectangle itself is (0,0,pageWidth,pageHeight).
*/
/* Special rules apply to resolving margins in the page context.
* Contrary to normal margins in this case top and bottom margin
* are resolved relative to the height. In the property subsystem
* all margin properties are configured to using BLOCK_WIDTH.
* That's why we 'cheat' here and setup a context for the height but
* use the LengthBase.BLOCK_WIDTH.
*/
SimplePercentBaseContext pageWidthContext
= new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
, pageViewPortDims.ipd);
SimplePercentBaseContext pageHeightContext
= new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH
, pageViewPortDims.bpd);
Rectangle pageRefRect
= new Rectangle(mProps.marginLeft.getValue(pageWidthContext)
, mProps.marginTop.getValue(pageHeightContext)
, pageViewPortDims.ipd
- mProps.marginLeft.getValue(pageWidthContext)
- mProps.marginRight.getValue(pageWidthContext)
, pageViewPortDims.bpd
- mProps.marginTop.getValue(pageHeightContext)
- mProps.marginBottom.getValue(pageHeightContext));
// Set up the CTM on the page reference area based on writing-mode
// and reference-orientation
FODimension reldims = new FODimension(0, 0);
CTM pageCTM = CTM.getCTMandRelDims(spm.getReferenceOrientation(),
spm.getWritingMode(), pageRefRect, reldims);
// Create a RegionViewport/ reference area pair for each page region
RegionReference rr = null;