@Override public JRPrintElement fill() { try { printText = (JRPrintText)textField.fill(); } catch (JRException e) { throw new JRRuntimeException(e); } printElement.setY(fillContext.getElementPrintY()); printElement.setHeight(printText.getHeight()); copy(printElement); return printElement; }
public void exportElement( JRXmlExporterContext exporterContext, JRGenericPrintElement element ) { JRXml4SwfExporter exporter = (JRXml4SwfExporter)exporterContext.getExporterRef(); JRPrintText text = getTextElementReplacement(exporterContext, element); try { exporter.exportText(text); } catch (IOException e) { throw new JRRuntimeException(e); } }
public void exportElement( JROdsExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout ) { JROdsExporter exporter = (JROdsExporter)exporterContext.getExporterRef(); JRExporterGridCell newGridCell = getGridCellReplacement(exporterContext, element, gridCell); try { exporter.exportText((JRPrintText)newGridCell.getElement(), newGridCell, colIndex, rowIndex); } catch (JRException e) { throw new JRRuntimeException(e); } }
@Override public String getTextValue(JRCsvExporterContext exporterContext, JRGenericPrintElement element) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText == null) { return null; } String text = null; JRStyledText styledText = ((JRCsvExporter)exporterContext.getExporterRef()).getStyledText(labelPrintText); if (styledText == null) { text = ""; } else { text = styledText.getText(); } return text; }
public void exportElement( JRXlsExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout ) { JRXlsExporter exporter = (JRXlsExporter)exporterContext.getExporterRef(); JRExporterGridCell newGridCell = getGridCellReplacement(exporterContext, element, gridCell); try { exporter.exportText((JRPrintText)newGridCell.getElement(), newGridCell, colIndex, rowIndex); } catch (JRException e) { throw new JRRuntimeException(e); } }
public JRPrintText getTextElementReplacement( JRExporterContext exporterContext, JRGenericPrintElement element ) { JRBasePrintText text = new JRBasePrintText(exporterContext.getExportedReport().getDefaultStyleProvider()); text.setX(element.getX()); text.setY(element.getY()); text.setWidth(element.getWidth()); text.setHeight(element.getHeight()); text.setText("[Open Flash Chart Component]"); text.setMode(ModeEnum.OPAQUE); text.setBackcolor(Color.lightGray); text.setHorizontalTextAlign(HorizontalTextAlignEnum.CENTER); text.setVerticalTextAlign(VerticalTextAlignEnum.MIDDLE); text.getLineBox().getPen().setLineWidth(1f); text.getLineBox().getPen().setLineColor(Color.black); text.getLineBox().getPen().setLineStyle(LineStyleEnum.DASHED); JRTextMeasurerUtil.getInstance(exporterContext.getJasperReportsContext()).measureTextElement(text); return text; }
@Override public void exportElement( JRXlsxExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex ) throws JRException { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText != null) { try { JRXlsxExporter exporter = (JRXlsxExporter)exporterContext.getExporterRef(); exporter.exportText(labelPrintText, gridCell, colIndex, rowIndex); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * */ public String getFrameStyle(JRPrintText text) throws IOException //FIXMEODT is this used? { FrameStyle frameStyle = new FrameStyle(styleWriter, text); frameStyle.setBox(text.getLineBox()); String frameStyleId = frameStyle.getId(); String frameStyleName = frameStyles.get(frameStyleId); if (frameStyleName == null) { frameStyleName = "F" + frameStylesCounter++; frameStyles.put(frameStyleId, frameStyleName); frameStyle.write(frameStyleName); } return frameStyleName; }
/** * */ public String getParagraphStyle(JRPrintText text, boolean isIgnoreTextFormatting) { ParagraphStyle paragraphStyle = new ParagraphStyle(styleWriter, text, isIgnoreTextFormatting); String paragraphStyleId = paragraphStyle.getId(); String paragraphStyleName = paragraphStyles.get(paragraphStyleId); if (paragraphStyleName == null) { paragraphStyleName = "P" + paragraphStylesCounter++; paragraphStyles.put(paragraphStyleId, paragraphStyleName); paragraphStyle.write(paragraphStyleName); } return paragraphStyleName; }
@Override public void exportText( JRPrintText text, JRExporterGridCell gridCell, int colIndex, int rowIndex ) throws JRException { tableBuilder.exportText(text, gridCell, isShrinkToFit(text), isWrapText(text), isIgnoreTextFormatting(text)); XlsReportConfiguration configuration = getCurrentItemConfiguration(); if (!configuration.isIgnoreAnchors() && text.getAnchorName() != null) { String cellAddress = "$'" + tableBuilder.getTableName() + "'." + getCellAddress(rowIndex, colIndex); int lastCol = Math.max(0, colIndex + gridCell.getColSpan() -1); String cellRangeAddress = getCellAddress(rowIndex + gridCell.getRowSpan() - 1, lastCol); namedExpressions.append("<table:named-range table:name=\""+ JRStringUtil.xmlEncode(text.getAnchorName()) +"\" table:base-cell-address=\"" + cellAddress +"\" table:cell-range-address=\"" + cellAddress +":" +cellRangeAddress +"\"/>\n"); } }
protected AbstractPdfTextRenderer getTextRenderer(JRPrintText text, JRStyledText styledText) { AbstractPdfTextRenderer textRenderer; if (toUseGlyphRenderer(text) && PdfGlyphRenderer.supported() && canUseGlyphRendering(text, styledText)) { textRenderer = new PdfGlyphRenderer(jasperReportsContext, awtIgnoreMissingFont, glyphRendererAddActualText && !tagHelper.isTagged); } else if (text.getLeadingOffset() == 0) { textRenderer = new PdfTextRenderer(jasperReportsContext, awtIgnoreMissingFont); } else { textRenderer = new SimplePdfTextRenderer(jasperReportsContext, awtIgnoreMissingFont);//FIXMETAB optimize this } return textRenderer; }
@Override protected void exportFrame(JRPrintFrame frame) throws JRException { for (Object element : frame.getElements()) { if (element instanceof JRPrintLine) { exportLine((JRPrintLine)element); } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { exportRectangle((JRPrintEllipse)element); } else if (element instanceof JRPrintImage) { exportImage((JRPrintImage) element); } else if (element instanceof JRPrintText) { exportText((JRPrintText)element); } else if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame) element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement) element); } } }
@Override protected JRStyledText getStyledText(JRPrintText textElement, boolean setBackcolor) { JRStyledText styledText = styledTextUtil.getProcessedStyledText(textElement, setBackcolor ? allSelector : noBackcolorSelector, getExporterKey()); if (styledText != null) { short[] lineBreakOffsets = textElement.getLineBreakOffsets(); if (lineBreakOffsets != null && lineBreakOffsets.length > 0) { //insert new lines at the line break positions saved at fill time //cloning the text first //FIXME do we need this? styled text instances are no longer shared styledText = styledText.cloneText(); styledText.insert("\n", lineBreakOffsets); } } return styledText; }
@Override public void exportElement( JROdtExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell ) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText != null) { try { JROdtExporter exporter = (JROdtExporter)exporterContext.getExporterRef(); exporter.exportText(exporterContext.getTableBuilder(), labelPrintText, gridCell); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * */ private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util? { JRPrintText text = new JRBasePrintText(null); text.setStyle(style); Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale()); fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text); styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor()); if (text.getModeValue() == ModeEnum.OPAQUE) { styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor()); } return styledTextAttributes; }
/** * */ private Map<Attribute,Object> getAttributes(JRStyle style)//FIXMEDOCX put this in util? { Map<Attribute,Object> styledTextAttributes = new HashMap<Attribute,Object>(); if (style != null) { JRPrintText text = new JRBasePrintText(null); text.setStyle(style); //JRFontUtil.getAttributes(styledTextAttributes, text, (Locale)null);//FIXMEDOCX getLocale()); fontUtil.getAttributesWithoutAwtFont(styledTextAttributes, text); styledTextAttributes.put(TextAttribute.FOREGROUND, text.getForecolor()); if (text.getModeValue() == ModeEnum.OPAQUE) { styledTextAttributes.put(TextAttribute.BACKGROUND, text.getBackcolor()); } } return styledTextAttributes; }
/** * */ public void exportProps(JRPrintText text) { JRStyle baseStyle = text.getDefaultStyleProvider().getStyleResolver().getBaseStyle(text); exportPropsHeader(baseStyle == null ? null : baseStyle.getName(), text.getParagraph()); //javadoc says getStyleNameReference is not supposed to work for print elements exportAlignment( getHorizontalTextAlign( text.getOwnHorizontalTextAlign() ) ); exportTabStops( text.getParagraph() ); exportLineSpacing( text.getParagraph() ); // exportRunDirection(text.getRunDirection() == JRPrintText.RUN_DIRECTION_RTL ? "rl" : null); exportPropsFooter(); }
protected void exportElements( List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, Map<String, String> currentRow, Map<String, String> repeatedValues, boolean hasDefinedColumns) throws IOException { for (int i = 0; i < elements.size(); ++i) { Object element = elements.get(i); if (element instanceof JRPrintText) { exportText((JRPrintText) element, configuration, currentRow, repeatedValues, hasDefinedColumns); } else if (element instanceof JRPrintFrame) { exportElements(((JRPrintFrame) element).getElements(), configuration, currentRow, repeatedValues, hasDefinedColumns); } } }
protected void exportElements(List<JRPrintElement> elements) { for (int i = 0; i < elements.size();i++) { Object element = elements.get(i); if (element instanceof JRPrintText) { exportText((JRPrintText) element); } else if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; setFrameElementsOffset(frame, false); try { exportElements(frame.getElements()); } finally { restoreElementOffsets(); } } } }
@Override protected void resolveElement(JRPrintElement element, byte evaluation) throws JRException { evaluateText(evaluation); chopTextElement(0); copy((JRPrintText) element); //FIXME put this somewhere else, e.g. in ElementEvaluationAction filler.updateBookmark(element); }
protected void addContentField(int pageNo, JRPrintText element) throws IOException { String allText; JRStyledText styledText = getStyledText(element); if (styledText == null) { allText = ""; } else { allText = styledText.getText(); } if (allText != null && allText.length() > 0) { Field tf = new Field(CONTENT_FIELD, allText, fieldType); Document doc = new Document(); doc.add(new IntField("pageNo", pageNo, Field.Store.YES)); PrintElementId peid = PrintElementId.forElement(element); doc.add(new StringField("uid", peid.toString(), Field.Store.YES)); displayTokens(allText, peid.toString()); doc.add(tf); writer.addDocument(doc); } }
@Override public void exportElement( JROdsExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout ) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText != null) { try { JROdsExporter exporter = (JROdsExporter)exporterContext.getExporterRef(); exporter.exportText(labelPrintText, gridCell, colIndex, rowIndex); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void exportElement( JRDocxExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell ) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText != null) { try { JRDocxExporter exporter = (JRDocxExporter)exporterContext.getExporterRef(); exporter.exportText(exporterContext.getTableHelper(), labelPrintText, gridCell); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void exportElement( JRXlsExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout ) { JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT); if (labelPrintText != null) { try { JRXlsExporter exporter = (JRXlsExporter)exporterContext.getExporterRef(); exporter.exportText(labelPrintText, gridCell, colIndex, rowIndex); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { PdfWriter writer = exporterContext.getPdfWriter(); JasperPrint jasperPrint = exporterContext.getExportedReport(); JRPrintText printText = (JRPrintText)element.getParameterValue(TextInputElement.PARAMETER_PRINT_TEXT_ELEMENT); if (printText == null) //FIXMEINPUT deal with xml serialization { return; } Rectangle rectangle = new Rectangle( element.getX() + exporterContext.getOffsetX(), jasperPrint.getPageHeight() - element.getY() - exporterContext.getOffsetY(), element.getX() + exporterContext.getOffsetX() + element.getWidth(), jasperPrint.getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight() ); TextField text = new TextField(writer, rectangle, getFieldName(element)); Color backColor = printText.getBackcolor(); if(backColor != null){ text.setBackgroundColor(backColor); } Color forecolor = printText.getForecolor(); if(forecolor != null){ text.setTextColor(forecolor); } text.setText(printText.getFullText()); text.setDefaultText("default:" + printText.getFullText()); // text.setBackgroundColor(element.getBackcolor()); // text.setTextColor(element.getForecolor()); // text.setText(getText(element)); // text.setDefaultText(getDefaultText(element)); //FIXME: dynamic settings below: // text.setAlignment(Element.ALIGN_LEFT); // text.setBorderColor(Color.BLACK); // text.setBorderWidth(TextField.BORDER_WIDTH_THIN); // text.setBorderStyle(PdfBorderDictionary.STYLE_INSET); // text.setChoiceExports(null); // text.setChoices(null); // text.setChoiceSelection(0); // text.setExtensionFont(null); // text.setExtraMargin(0, 0); // try{ // text.setFont(BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1250, true)); // }catch(Exception e){ // throw new JRRuntimeException(e); // } text.setFontSize(printText.getFontsize()); if (Boolean.TRUE.equals(element.getParameterValue(TextInputElement.PARAMETER_MULTI_LINE))) { text.setOptions(TextField.MULTILINE); } // text.setRotation(90); text.setVisibility(TextField.VISIBLE); try{ PdfFormField field = text.getTextField(); writer.addAnnotation(field); }catch(Exception e){ throw new JRRuntimeException(e); } }
public void exportElement( JROdtExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell ) { JROdtExporter exporter = (JROdtExporter)exporterContext.getExporterRef(); JRExporterGridCell newGridCell = getGridCellReplacement(exporterContext, element, gridCell); exporter.exportText(exporterContext.getTableBuilder(), (JRPrintText)newGridCell.getElement(), newGridCell); }
public void exportElement( JRDocxExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell ) { JRDocxExporter exporter = (JRDocxExporter)exporterContext.getExporterRef(); JRExporterGridCell newGridCell = getGridCellReplacement(exporterContext, element, gridCell); exporter.exportText(exporterContext.getTableHelper(), (JRPrintText)newGridCell.getElement(), newGridCell); }
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) { JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporterRef(); JRPrintText text = getTextElementReplacement(exporterContext, element); try { exporter.exportText(text); } catch (Exception e) { throw new RuntimeException(e); } }
public JRExporterGridCell getGridCellReplacement( JRExporterContext exporterContext, JRGenericPrintElement element, JRExporterGridCell gridCell ) { JRPrintText text = getTextElementReplacement(exporterContext, element); JRExporterGridCell newGridCell = new ElementReplacementGridCell((ElementGridCell) gridCell, text); newGridCell.setBox(text.getLineBox()); return newGridCell; }
public void exportElement( JRPptxExporterContext exporterContext, JRGenericPrintElement element ) { JRPptxExporter exporter = (JRPptxExporter)exporterContext.getExporterRef(); JRPrintText text = getTextElementReplacement(exporterContext, element); exporter.exportText(text); }
@Override public void body(String namespace, String name, String text) throws Exception { if (text != null) { StringTokenizer tokenizer = new StringTokenizer(text, JRXmlConstants.LINE_BREAK_OFFSET_SEPARATOR); int tokenCount = tokenizer.countTokens(); short[] offsets; if (tokenCount == 0) { //use the zero length array singleton offsets = JRPrintText.ZERO_LINE_BREAK_OFFSETS; } else { offsets = new short[tokenCount]; for (int i = 0; i < offsets.length; i++) { String token = tokenizer.nextToken(); offsets[i] = Short.parseShort(token); } } JRPrintText printText = (JRPrintText) getDigester().peek(); printText.setLineBreakOffsets(offsets); } }
/** * */ public String getTruncatedText(JRPrintText printText) { String truncatedText = null; String originalText = printText.getOriginalText(); if (originalText != null) { if (printText.getTextTruncateIndex() == null) { truncatedText = originalText; } else { if (!JRCommonText.MARKUP_NONE.equals(printText.getMarkup())) { truncatedText = JRStyledTextParser.getInstance().write( printText.getFullStyledText(allSelector), 0, printText.getTextTruncateIndex().intValue()); } else { truncatedText = originalText.substring(0, printText.getTextTruncateIndex().intValue()); } } String textTruncateSuffix = printText.getTextTruncateSuffix(); if (textTruncateSuffix != null) { truncatedText += textTruncateSuffix; } } return truncatedText; }
/** * */ public JRStyledText getStyledText(JRPrintText printText, JRStyledTextAttributeSelector attributeSelector) { String truncatedText = getTruncatedText(printText); if (truncatedText == null) { return null; } Locale locale = JRStyledTextAttributeSelector.getTextLocale(printText); JRStyledText styledText = getStyledText(printText, truncatedText, attributeSelector, locale); return styledText; }
protected JRStyledText getStyledText(JRPrintText printText, String text, JRStyledTextAttributeSelector attributeSelector, Locale locale) { return JRStyledTextParser.getInstance().getStyledText( attributeSelector.getStyledTextAttributes(printText), text, !JRCommonText.MARKUP_NONE.equals(printText.getMarkup()), locale ); }
public JRStyledText getProcessedStyledText(JRPrintText printText, JRStyledTextAttributeSelector attributeSelector, String exporterKey) { String truncatedText = getTruncatedText(printText); if (truncatedText == null) { return null; } Locale locale = JRStyledTextAttributeSelector.getTextLocale(printText); JRStyledText styledText = getStyledText(printText, truncatedText, attributeSelector, locale); JRStyledText processedStyledText = resolveFonts(styledText, locale, exporterKey); return processedStyledText; }
@Override public void visit(JRPrintText textElement, T arg) { for (PrintElementVisitor<T> visitor : visitors) { visitor.visit(textElement, arg); } }
/** * */ protected Phrase getPhrase(JRStyledText styledText, JRPrintText textElement) { String text = styledText.getText(); AttributedString as = styledText.getAttributedString(); return pdfExporter.getPhrase(as, text, textElement); }
/** * */ protected void exportTextContents(JRPrintText text) { boolean startedHyperlink = startHyperlink(text, true); exportStyledText(text, startedHyperlink, false); if (startedHyperlink) { endHyperlink(true); } }
/** * */ protected void exportStyledText(JRPrintText text, boolean startedHyperlink, boolean isIgnoreTextFormatting) { JRStyledText styledText = documentBuilder.getStyledText(text); if (styledText != null && styledText.length() > 0) { exportStyledText(styledText, documentBuilder.getTextLocale(text), startedHyperlink, isIgnoreTextFormatting); } }