/** if id can be resolved then simply return a word, otherwise return a resolvable area */ private InlineArea getPageNumberCitationLastInlineArea(LayoutManager parentLM) { TextArea text = null; int level = getBidiLevel(); if (!getPSLM().associateLayoutManagerID(fobj.getRefId())) { text = new UnresolvedPageNumber(fobj.getRefId(), font, UnresolvedPageNumber.LAST); getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) text); String str = "MMM"; // reserve three spaces for page number int width = getStringWidth(str); text.setBidiLevel(level); text.setIPD(width); resolved = false; } else { PageViewport page = getPSLM().getLastPVWithID(fobj.getRefId()); String str = page.getPageNumberString(); // get page string from parent, build area text = new TextArea(); int width = getStringWidth(str); text.setBidiLevel(level); text.addWord(str, 0, level); text.setIPD(width); resolved = true; } updateTextAreaTraits(text); return text; }
/** {@inheritDoc} */ protected Page createPage(int pageNumber, boolean isBlank) { String pageNumberString = pageSeq.makeFormattedPageNumber(pageNumber); Dimension imageSize = this.imageLayout.getViewportSize(); // Set up the CTM on the page reference area based on writing-mode // and reference-orientation Rectangle referenceRect; if (pageSeq.getReferenceOrientation() % 180 == 0) { referenceRect = new Rectangle(0, 0, imageSize.width, imageSize.height); } else { referenceRect = new Rectangle(0, 0, imageSize.height, imageSize.width); } FODimension reldims = new FODimension(0, 0); CTM pageCTM = CTM.getCTMandRelDims( pageSeq.getReferenceOrientation(), Constants.EN_LR_TB, referenceRect, reldims); Page page = new Page(referenceRect, pageNumber, pageNumberString, isBlank); PageViewport pv = page.getPageViewport(); org.apache.fop.area.Page pageArea = new org.apache.fop.area.Page(); pv.setPage(pageArea); RegionViewport rv = new RegionViewport(referenceRect); rv.setIPD(referenceRect.width); rv.setBPD(referenceRect.height); rv.setClip(true); BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY, "fop-image-region", rv, 1, 0); body.setIPD(imageSize.width); body.setBPD(imageSize.height); body.setCTM(pageCTM); rv.setRegionReference(body); pageArea.setRegionViewport(Constants.FO_REGION_BODY, rv); // Set unique key obtained from the AreaTreeHandler pv.setKey(areaTreeHandler.generatePageViewportKey()); // Also creates first normal flow region pv.createSpan(false); return page; }
/** if id can be resolved then simply return a word, otherwise return a resolvable area */ private InlineArea getPageNumberCitationInlineArea() { final PageViewport page = getPSLM().getFirstPVWithID(this.fobj.getRefId()); TextArea text = null; if (page != null) { final String str = page.getPageNumberString(); // get page string from parent, build area text = new TextArea(); final int width = getStringWidth(str); text.addWord(str, 0); text.setIPD(width); this.resolved = true; } else { this.resolved = false; text = new UnresolvedPageNumber(this.fobj.getRefId(), this.font); final String str = "MMM"; // reserve three spaces for page number final int width = getStringWidth(str); text.setIPD(width); } updateTextAreaTraits(text); return text; }