c.setRootDocumentLayer(c.getRootLayer()); for (Iterator i = _pages.iterator(); i.hasNext(); ) { PageBox pageBox = (PageBox)i.next(); pageBox.layout(c); } } public void addPageSequence(BlockBox start) {
public void layoutPages(LayoutContext c) { c.setRootDocumentLayer(c.getRootLayer()); for (Iterator i = _pages.iterator(); i.hasNext(); ) { PageBox pageBox = (PageBox)i.next(); pageBox.layout(c); } }
public boolean isNeedsKeepWithInline(LayoutContext c) { if (c.isPrint() && getStyle().isKeepWithInline()) { LineBox line = findFirstLineBox(); if (line != null) { PageBox linePage = c.getRootLayer().getFirstPage(c, line); PageBox ourPage = c.getRootLayer().getFirstPage(c, this); return linePage != null && ourPage != null && linePage.getPageNo() == ourPage.getPageNo()+1; } } return false; }
public boolean isNeedsKeepWithInline(LayoutContext c) { if (c.isPrint() && getStyle().isKeepWithInline()) { LineBox line = findFirstLineBox(); if (line != null) { PageBox linePage = c.getRootLayer().getFirstPage(c, line); PageBox ourPage = c.getRootLayer().getFirstPage(c, this); return linePage != null && ourPage != null && linePage.getPageNo() == ourPage.getPageNo()+1; } } return false; }
private boolean isShouldMoveToNextPage(LayoutContext c) { PageBox page = c.getRootLayer().getFirstPage(c, this); if (getAbsY() + getHeight() < page.getBottom()) { return false; } for (Iterator i = getChildIterator(); i.hasNext(); ) { TableCellBox cell = (TableCellBox)i.next(); int baseline = cell.calcBlockBaseline(c); if (baseline != BlockBox.NO_BASELINE && baseline < page.getBottom()) { return false; } } return true; }
private boolean isShouldMoveToNextPage(LayoutContext c) { PageBox page = c.getRootLayer().getFirstPage(c, this); if (getAbsY() + getHeight() < page.getBottom()) { return false; } for (Iterator i = getChildIterator(); i.hasNext(); ) { TableCellBox cell = (TableCellBox)i.next(); int baseline = cell.calcBlockBaseline(c); if (baseline != BlockBox.NO_BASELINE && baseline < page.getBottom()) { return false; } } return true; }
public PageBox getPage(LayoutContext c, int absY) { PageBox page; PageBox last = getLastPage(); if (last != null && absY >= last.getTop() && absY < last.getBottom()) { page = last; } else { page = c.getRootLayer().getPage(c, absY); setLastPage(page); } return page; }
public PageBox getPage(LayoutContext c, int absY) { PageBox page; PageBox last = getLastPage(); if (last != null && absY >= last.getTop() && absY < last.getBottom()) { page = last; } else { page = c.getRootLayer().getPage(c, absY); setLastPage(page); } return page; }
public boolean crossesPageBreak(LayoutContext c) { if (! c.isPageBreaksAllowed()) { return false; } PageBox pageBox = c.getRootLayer().getFirstPage(c, this); if (pageBox == null) { return false; } else { return getAbsY() + getHeight() >= pageBox.getBottom() - c.getExtraSpaceBottom(); } }
public boolean crossesPageBreak(LayoutContext c) { if (! c.isPageBreaksAllowed()) { return false; } PageBox pageBox = c.getRootLayer().getFirstPage(c, this); if (pageBox == null) { return false; } else { return getAbsY() + getHeight() >= pageBox.getBottom() - c.getExtraSpaceBottom(); } }
public BreakAtLineContext calcBreakAtLineContext(LayoutContext c) { if (! c.isPrint() || ! getStyle().isKeepWithInline()) { return null; } LineBox breakLine = findLastNthLineBox((int)getStyle().asFloat(CSSName.WIDOWS)); if (breakLine != null) { PageBox linePage = c.getRootLayer().getLastPage(c, breakLine); PageBox ourPage = c.getRootLayer().getLastPage(c, this); if (linePage != null && ourPage != null && linePage.getPageNo() + 1 == ourPage.getPageNo()) { BlockBox breakBox = (BlockBox)breakLine.getParent(); return new BreakAtLineContext(breakBox, breakBox.findOffset(breakLine)); } } return null; }
public boolean isPageBreaksChange(LayoutContext c, int posDeltaY) { if (! c.isPageBreaksAllowed()) { return false; } PageBox page = c.getRootLayer().getFirstPage(c, this); int bottomEdge = getAbsY() + getChildrenHeight(); return bottomEdge >= page.getBottom() - c.getExtraSpaceBottom() || bottomEdge + posDeltaY >= page.getBottom() - c.getExtraSpaceBottom(); }
public BreakAtLineContext calcBreakAtLineContext(LayoutContext c) { if (! c.isPrint() || ! getStyle().isKeepWithInline()) { return null; } LineBox breakLine = findLastNthLineBox((int)getStyle().asFloat(CSSName.WIDOWS)); if (breakLine != null) { PageBox linePage = c.getRootLayer().getLastPage(c, breakLine); PageBox ourPage = c.getRootLayer().getLastPage(c, this); if (linePage != null && ourPage != null && linePage.getPageNo() + 1 == ourPage.getPageNo()) { BlockBox breakBox = (BlockBox)breakLine.getParent(); return new BreakAtLineContext(breakBox, breakBox.findOffset(breakLine)); } } return null; }
public boolean isPageBreaksChange(LayoutContext c, int posDeltaY) { if (! c.isPageBreaksAllowed()) { return false; } PageBox page = c.getRootLayer().getFirstPage(c, this); int bottomEdge = getAbsY() + getChildrenHeight(); return bottomEdge >= page.getBottom() - c.getExtraSpaceBottom() || bottomEdge + posDeltaY >= page.getBottom() - c.getExtraSpaceBottom(); }
private static boolean isPageBreakBetweenChildBoxes(RelayoutDataList relayoutDataList, int runStart, int runEnd, LayoutContext c, BlockBox block) { for ( int i = runStart; i < runEnd; i++ ) { Box prevChild = block.getChild(i); Box nextChild = block.getChild(i+1); // if nextChild is made of several lines, then only the first line // is relevant for "page-break-before: avoid". Box nextLine = getFirstLine(nextChild) == null ? nextChild : getFirstLine(nextChild); int prevChildEnd = prevChild.getAbsY() + prevChild.getHeight(); int nextLineEnd = nextLine.getAbsY() + nextLine.getHeight(); if ( c.getRootLayer().crossesPageBreak(c, prevChildEnd, nextLineEnd) ) { return true; } } return false; }
private void calcExtraPageClearance(LayoutContext c) { if (c.isPageBreaksAllowed() && c.getExtraSpaceTop() > 0 && (getStyle().isSpecifiedAsBlock() || getStyle().isListItem())) { PageBox first = c.getRootLayer().getFirstPage(c, this); if (first != null && first.getTop() + c.getExtraSpaceTop() > getAbsY()) { int diff = first.getTop() + c.getExtraSpaceTop() - getAbsY(); setY(getY() + diff); c.translate(0, diff); calcCanvasLocation(); } } }
protected void layoutChildren(LayoutContext c, int contentStart) { ensureChildren(c); // If we have a running footer, we need its dimensions right away boolean running = c.isPrint() && getStyle().isPaginateTable(); if (running) { int headerHeight = layoutRunningHeader(c); int footerHeight = layoutRunningFooter(c); int spacingHeight = footerHeight == 0 ? 0 : getStyle().getBorderVSpacing(c); PageBox first = c.getRootLayer().getFirstPage(c, this); if (getAbsY() + getTy() + headerHeight + footerHeight + spacingHeight > first.getBottom()) { // XXX Performance problem here. This forces the table // to move to the next page (which we want), but the initial // table layout run still completes (which we don't) setNeedPageClear(true); } } super.layoutChildren(c, contentStart); }
private void calcExtraPageClearance(LayoutContext c) { if (c.isPageBreaksAllowed() && c.getExtraSpaceTop() > 0 && (getStyle().isSpecifiedAsBlock() || getStyle().isListItem())) { PageBox first = c.getRootLayer().getFirstPage(c, this); if (first != null && first.getTop() + c.getExtraSpaceTop() > getAbsY()) { int diff = first.getTop() + c.getExtraSpaceTop() - getAbsY(); setY(getY() + diff); c.translate(0, diff); calcCanvasLocation(); } } }
public void checkPagePosition(LayoutContext c, boolean alwaysBreak) { if (! c.isPageBreaksAllowed()) { return; } PageBox pageBox = c.getRootLayer().getFirstPage(c, this); if (pageBox != null) { boolean needsPageBreak = alwaysBreak || getAbsY() + getHeight() >= pageBox.getBottom() - c.getExtraSpaceBottom(); if (needsPageBreak) { forcePageBreakBefore(c, IdentValue.ALWAYS, false); calcCanvasLocation(); } else if (pageBox.getTop() + c.getExtraSpaceTop() > getAbsY()) { int diff = pageBox.getTop() + c.getExtraSpaceTop() - getAbsY(); setY(getY() + diff); calcCanvasLocation(); } } }
public void checkPagePosition(LayoutContext c, boolean alwaysBreak) { if (! c.isPageBreaksAllowed()) { return; } PageBox pageBox = c.getRootLayer().getFirstPage(c, this); if (pageBox != null) { boolean needsPageBreak = alwaysBreak || getAbsY() + getHeight() >= pageBox.getBottom() - c.getExtraSpaceBottom(); if (needsPageBreak) { forcePageBreakBefore(c, IdentValue.ALWAYS, false); calcCanvasLocation(); } else if (pageBox.getTop() + c.getExtraSpaceTop() > getAbsY()) { int diff = pageBox.getTop() + c.getExtraSpaceTop() - getAbsY(); setY(getY() + diff); calcCanvasLocation(); } } }