protected void processInlineLevelNode(final RenderNode node) { if (lineBreakState.isInsideParagraph() == false) { throw new InvalidReportStateException( "A inline-level box outside of a paragraph box is not allowed."); } final int nodeType = node.getNodeType(); if (nodeType == LayoutNodeTypes.TYPE_NODE_FINISHEDNODE) { final FinishedRenderNode finNode = (FinishedRenderNode) node; node.setCachedWidth(finNode.getLayoutedWidth()); return; } if (nodeType == LayoutNodeTypes.TYPE_NODE_TEXT) { lineBreakState.add(TextSequenceElement.INSTANCE, node); } else if (nodeType == LayoutNodeTypes.TYPE_NODE_SPACER) { final StyleSheet styleSheet = node.getStyleSheet(); if (WhitespaceCollapse.PRESERVE.equals( styleSheet.getStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE)) && styleSheet.getBooleanStyleProperty(TextStyleKeys.TRIM_TEXT_CONTENT) == false) { // bug-alert: This condition could indicate a workaround for a logic-flaw in the // text-processor lineBreakState.add(SpacerSequenceElement.INSTANCE, node); } else if (lineBreakState.isContainsContent()) { lineBreakState.add(SpacerSequenceElement.INSTANCE, node); } } else { lineBreakState.add(InlineNodeSequenceElement.INSTANCE, node); } }
public void addProgressMarkerBox() { final RenderBox parent = this.context.getRenderBox(); final RenderNode child = parent.getLastChild(); if (isCollapseProgressMarker() && child != null && child.getNodeType() == LayoutNodeTypes.TYPE_BOX_PROGRESS_MARKER) { final ProgressMarkerRenderBox markerRenderBox = (ProgressMarkerRenderBox) child; markerRenderBox.setStateKey(stateKey); } else { final ProgressMarkerRenderBox markerBox = new ProgressMarkerRenderBox(); markerBox.setStateKey(stateKey); this.context.addChild(markerBox); markerBox.close(); } this.context.setEmpty(false); }
protected void processParagraphChilds(final ParagraphRenderBox box) { paragraphLayoutWatch.start(); try { final MinorAxisNodeContext nodeContext = getNodeContext(); final MinorAxisParagraphBreakState breakState = getLineBreakState(); if (box.isComplexParagraph()) { final RenderBox lineboxContainer = box.getLineboxContainer(); RenderNode node = lineboxContainer.getFirstChild(); while (node != null) { // all childs of the linebox container must be inline boxes. They // represent the lines in the paragraph. Any other element here is // a error that must be reported if (node.getNodeType() != LayoutNodeTypes.TYPE_BOX_LINEBOX) { throw new IllegalStateException("Expected ParagraphPoolBox elements."); } final ParagraphPoolBox inlineRenderBox = (ParagraphPoolBox) node; if (startLine(inlineRenderBox)) { processBoxChilds(inlineRenderBox); finishLine(inlineRenderBox, nodeContext, breakState); } node = node.getNext(); } } else { final ParagraphPoolBox node = box.getPool(); if (node.getFirstChild() == null) { return; } // all childs of the linebox container must be inline boxes. They // represent the lines in the paragraph. Any other element here is // a error that must be reported if (startLine(node)) { processBoxChilds(node); finishLine(node, nodeContext, breakState); } } } finally { paragraphLayoutWatch.stop(true); } }
protected void processOtherNode(final RenderNode node) { try { final int nodeType = node.getNodeType(); if (nodeType == LayoutNodeTypes.TYPE_NODE_TEXT || nodeType == LayoutNodeTypes.TYPE_NODE_COMPLEX_TEXT) { super.processOtherNode(node); return; } if (node.isVirtualNode()) { return; } if (nodeType == LayoutNodeTypes.TYPE_NODE_SPACER) { final SpacerRenderNode spacer = (SpacerRenderNode) node; final int count = Math.max(1, spacer.getSpaceCount()); for (int i = 0; i < count; i++) { xmlWriter.writeText(" "); } } } catch (final IOException e) { throw new RuntimeException("Failed", e); } }