@Override public JRPrintElement convert(ReportConverter reportConverter, JRComponentElement element) { if (element.getComponent() == null) { return null; } try { HtmlPrintElement htmlPrintElement = HtmlPrintElementUtils.getHtmlPrintElement(); return htmlPrintElement.createImageFromComponentElement(element); } catch (Exception e) { return null; } }
/** * */ public String getFrameStyle(JRPrintElement element) throws IOException //FIXMEODT is this used? { FrameStyle frameStyle = new FrameStyle(styleWriter, element); String frameStyleId = frameStyle.getId(); String frameStyleName = frameStyles.get(frameStyleId); if (frameStyleName == null) { frameStyleName = "F" + frameStylesCounter++; frameStyles.put(frameStyleId, frameStyleName); frameStyle.write(frameStyleName); } return frameStyleName; }
@Override protected JRPrintElement fill() { return null; // JRPrintLine printLine = null; // // printLine = new JRBasePrintLine(filler.getJasperPrint().getDefaultStyleProvider()); // printLine.setX(0); // printLine.setY(this.getRelativeY()); // printLine.setWidth(getWidth()); // printLine.setHeight(1); // printLine.setPen(JRGraphicElement.PEN_DOTTED); // printLine.setForecolor(getForecolor()); // // return printLine; }
@Override public boolean isToExport(JRPrintElement element) { if (element instanceof JRGenericPrintElement) { JRGenericPrintElement genericElement = (JRGenericPrintElement) element; GenericElementHandler handler = handlerEnvironment.getElementHandler( genericElement.getGenericType(), JROdtExporter.ODT_EXPORTER_KEY); if (handler == null || !handler.toExport(genericElement)) { return false; } } return (filter == null || filter.isToExport(element)); }
/** * */ public static void addContent(JRPrintPage printPage, int pageIndex, ElementRangeContents elementsToMove, int xdelta, int ydelta, DelayedFillActions delayedActions) { if (elementsToMove != null && !elementsToMove.getElements().isEmpty()) { List<JRPrintElement> elements = elementsToMove.getElements(); for (int i = elements.size() - 1; i >= 0; i--)// elementsToMove were added in reverse order { JRPrintElement printElement = elements.get(i); printElement.setX(printElement.getX() + xdelta); printElement.setY(printElement.getY() + ydelta); printPage.addElement(printElement); } if (delayedActions != null && elementsToMove.hasEvaluations()) { delayedActions.addElementEvaluations(printPage, pageIndex, elementsToMove); } } }
protected void exportElements(Collection<JRPrintElement> elements) throws IOException { if (elements != null && elements.size() > 0) { for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (filter == null || filter.isToExport(element)) { if (element instanceof JRPrintFrame) { exportFrame((JRPrintFrame)element); } else if (element instanceof JRGenericPrintElement) { exportGenericElement((JRGenericPrintElement) element); } } } } }
@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); }
@Override public JRPrintElement convert(ReportConverter reportConverter, JRElement element) { JRBasePrintFrame printFrame = new JRBasePrintFrame(reportConverter.getDefaultStyleProvider()); JRCrosstab crosstab = (JRCrosstab)element; printFrame.copyBox(crosstab.getLineBox()); copyElement(reportConverter, crosstab, printFrame); List<JRPrintElement> children = getCrosstabChildren(reportConverter, crosstab); if (children != null && children.size() > 0) { // ConvertVisitor convertVisitor = new ConvertVisitor(reportConverter, printFrame); for(int i = 0; i < children.size(); i++) { // ((JRChild)children.get(i)).visit(convertVisitor); printFrame.addElement(children.get(i)); } } return printFrame; }
private void fillContinuingHeaders(int lastRowHeight) throws JRException { int nextToLastHeaderY = rowYs.get(rowIdx - 1).intValue(); List<JRPrintElement> lastPrintRow = getLastPrintRow(); for (int j = 0; j < preparedRow.size(); ++j) { JRFillCellContents contents = preparedRow.get(j); int headerY = rowYs.get(rowIdx - contents.getVerticalSpan()).intValue(); contents.stretchTo(nextToLastHeaderY - headerY + lastRowHeight); lastPrintRow.add(contents.fill()); contents.releaseWorkingClone(); } }
@Override public String getProperty(String propName) { JRPrintElement element = getElement(); if (element.hasProperties() && element.getPropertiesMap().containsProperty(propName)) { return element.getPropertiesMap().getProperty(propName); } PrintElementIndex ancestorIndex = parentIndex; while (ancestorIndex != null) { JRPrintElement ancestor = container.getElement( ancestorIndex.getParentIndex(), ancestorIndex.getIndex()); if (ancestor.hasProperties() && ancestor.getPropertiesMap().containsProperty(propName)) { return ancestor.getPropertiesMap().getProperty(propName); } ancestorIndex = ancestorIndex.getParentIndex(); } return null; }
protected JRLineBox copyParentBox(Cell cell, JRPrintElement element, JRLineBox baseBox, boolean keepLeft, boolean keepRight, boolean keepTop, boolean keepBottom) { FrameCell parentCell = cell.getParent(); if (parentCell == null) { return baseBox; } // TODO lucianc check this in the table instead? JRPrintFrame parentFrame = (JRPrintFrame) getCellElement(parentCell); keepLeft &= element.getX() == 0 && parentFrame.getLineBox().getLeftPadding() == 0; keepRight &= (element.getX() + element.getWidth() + parentFrame.getLineBox().getLeftPadding()) == parentFrame.getWidth(); keepTop &= element.getY() == 0 && parentFrame.getLineBox().getTopPadding() == 0; keepBottom &= (element.getY() + element.getHeight() + parentFrame.getLineBox().getTopPadding()) == parentFrame.getHeight(); JRLineBox resultBox = baseBox; if (keepLeft || keepRight || keepTop || keepBottom) { resultBox = copyFrameBox(parentCell, parentFrame, baseBox, keepLeft, keepRight, keepTop, keepBottom); } return resultBox; }
protected void createLayeredCell(Table table, FrameCell parentCell, int xOffset, int yOffset, JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, DimensionRange<Column> layeredColRange, DimensionRange<Row> layeredRowRange) { if (log.isDebugEnabled()) { log.debug("creating layered cell at " + layeredColRange + ", " + layeredRowRange); } LayeredCell layeredCell = new LayeredCell(parentCell); Table firstLayer = new Table(this); layeredCell.addLayer(firstLayer); moveCellsToLayerTable(parentCell, firstLayer, layeredColRange, layeredRowRange); setElementCells(layeredColRange, layeredRowRange, layeredCell); collapseSpanColumns(table, layeredColRange); collapseSpanRows(table, layeredRowRange); createOverlappedLayer(xOffset, yOffset, layeredCell, element, parentIndex, elementIndex, layeredColRange, layeredRowRange); }
/** * */ public void exportHeader(JRPrintElement element, JRExporterGridCell gridCell) { write(" <w:tc>\n"); exportPropsHeader(); if (gridCell.getColSpan() > 1) { write(" <w:gridSpan w:val=\"" + gridCell.getColSpan() +"\" />\n"); } if (gridCell.getRowSpan() > 1) { write(" <w:vMerge w:val=\"restart\" />\n"); } exportProps(element, gridCell); exportPropsFooter(); }
private List<List<JRPrintElement>> fillColumnHeaders(JRFillCellContents[][] columnHeaderRows) throws JRException { List<List<JRPrintElement>> headerRows = new ArrayList<List<JRPrintElement>>(columnGroups.length); for (int i = 0; i < columnHeaderRows.length; ++i) { List<JRPrintElement> headerRow = new ArrayList<JRPrintElement>(lastColumnIndex - startColumnIndex); headerRows.add(headerRow); for (int j = 0; j < columnHeaderRows[i].length; j++) { JRFillCellContents contents = columnHeaderRows[i][j]; if (contents != null) { headerRow.add(contents.fill()); contents.releaseWorkingClone(); } } } return headerRows; }
@Override public void visit(JRPrintFrame frame, T arg) { visitElement(frame, arg); if (deep) { List<JRPrintElement> elements = frame.getElements(); if (elements != null) { for (JRPrintElement element : elements) { element.accept(this, arg); } } } }
@Override protected JRPrintElement fill() { JRTemplatePrintImage printImage = new JRTemplatePrintImage(getJRTemplateImage(), printElementOriginator); printImage.setUUID(getUUID()); printImage.setX(getX()); printImage.setY(getRelativeY()); printImage.setWidth(getWidth()); printImage.setHeight(getStretchHeight()); printImage.setBookmarkLevel(getBookmarkLevel()); printImage.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBED_IMAGE, Boolean.TRUE.toString()); printImage.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBEDDED_SVG_USE_FONTS, Boolean.TRUE.toString()); EvaluationTimeEnum evaluationTime = getEvaluationTimeValue(); if (evaluationTime == EvaluationTimeEnum.NOW) { copy(printImage); } else { filler.addBoundElement(this, printImage, evaluationTime, getEvaluationGroup(), band); } return printImage; }
public JRGridLayout getLayout() { JRPrintElement element = getElement(); if (!(element instanceof JRPrintFrame)) { // should not happen throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_NOT_FRAME_ELEMENT, new Object[]{getElementAddress()}); } JRPrintFrame frame = (JRPrintFrame) element; PrintElementIndex frameIndex = new PrintElementIndex(getParentIndex(), getElementIndex()); return new JRGridLayout( container, frame.getElements(), frame.getWidth(), frame.getHeight(), 0, //offsetX 0, //offsetY frameIndex ); }
protected void mirrorPrintElements(List<JRPrintElement> printElements, int width) { for (Iterator<JRPrintElement> it = printElements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); int mirrorX = width - element.getX() - element.getWidth(); element.setX(mirrorX); } }
protected void createThStartTag(JRPrintElement element) { PdfStructureElement tableHeaderTag = new PdfStructureElement(tagStack.peek(), PdfName.TH); //pdfContentByte.beginMarkedContentSequence(tableHeaderTag); tableHeaderTag.put(PdfName.K, new PdfArray()); tagStack.push(tableHeaderTag); isTagEmpty = true; createSpanTags(element, tableHeaderTag); }
/** * */ protected boolean isEmbeddedSvgUseFonts(JRPrintElement element) { if ( element.hasProperties() && element.getPropertiesMap().containsProperty(HtmlReportConfiguration.PROPERTY_EMBEDDED_SVG_USE_FONTS) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return getPropertiesUtil().getBooleanProperty(element, HtmlReportConfiguration.PROPERTY_EMBEDDED_SVG_USE_FONTS, getCurrentItemConfiguration().isEmbeddedSvgUseFonts()); } return getCurrentItemConfiguration().isEmbeddedSvgUseFonts(); }
protected void createListItemStartTag(JRPrintElement element) { PdfStructureElement listItemTag = new PdfStructureElement(tagStack.peek(), PdfName.LI); //pdfContentByte.beginMarkedContentSequence(tableHeaderTag); listItemTag.put(PdfName.K, new PdfArray()); tagStack.push(listItemTag); isTagEmpty = true; }
@Override public int compare(JRPrintElement elem1, JRPrintElement elem2) { if (elem1.getY() == elem2.getY()) { return elem1.getX() - elem2.getX(); } else { return elem1.getY() - elem2.getY(); } }
protected void readElementEvaluations(JRVirtualizable<VirtualElementsData> object, int sourceId, JREvaluationTime evaluationTime, LinkedMap<Object, EvaluationBoundAction> actionsMap) { // get the delayed evaluations from the devirtualized data and add it back // to the filler delayed evaluation maps. VirtualElementsData elementsData = object.getVirtualData(); Map<JRPrintElement, Integer> elementEvaluations = elementsData.getElementEvaluations(sourceId, evaluationTime); if (elementEvaluations != null) { for (Map.Entry<JRPrintElement, Integer> entry : elementEvaluations.entrySet()) { JRPrintElement element = entry.getKey(); int fillElementId = entry.getValue(); JRFillElement fillElement = fillElements.get(fillElementId); if (log.isDebugEnabled()) { log.debug(id + " got evaluation " + evaluationTime + ", source id " + sourceId + ", on " + element + ", from object " + object + ", using " + fillElement); } if (fillElement == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_ELEMENT_NOT_FOUND, new Object[]{fillElementId} ); } // add first so that it will be executed immediately actionsMap.addFirst(element, new ElementEvaluationAction(fillElement, element)); } } }
@Override public TableCell visit(FrameCell frameCell, TablePosition position) { JRPrintElement element = getCellElement(frameCell); Color backcolor = getElementBackcolor(frameCell); boolean[] borders = getFrameCellBorders(position.getTable(), frameCell, position.getColumn(), position.getColumn(), position.getRow(), position.getRow()); JRLineBox box = copyFrameBox(frameCell, (JRPrintFrame) element, null, borders[0], borders[1], borders[2], borders[3]); return new TableCell(Tabulator.this, position, frameCell, element, 1, 1, backcolor, box); }
/** * */ public Boolean getShowGridlines(JRPrintElement element) { if ( element.hasProperties() && element.getPropertiesMap().containsProperty(PROPERTY_SHOW_GRIDLINES) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return getPropertiesUtil().getBooleanProperty(element, PROPERTY_SHOW_GRIDLINES, true); } return null; }
public EdgeEnum getFreezeRowEdge(JRPrintElement element) { if (element.hasProperties() && element.getPropertiesMap().containsProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return EdgeEnum.getByName(getPropertiesUtil().getProperty(element, JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE)); } return null; }
protected CrosstabFiller() { setRowHeadersXOffsets(); printRows = new ArrayList<List<JRPrintElement>>(); rowCountVar = variablesMap.get(JRCrosstab.VARIABLE_ROW_COUNT); colCountVar = variablesMap.get(JRCrosstab.VARIABLE_COLUMN_COUNT); }
@Override public void setXProperties(CutsInfo xCuts, JRPrintElement element, int row1, int col1, int row2, int col2) { Map<String,Object> xCutsProperties = xCuts.getPropertiesMap(); Cut cut = xCuts.getCut(col1); Boolean columnAutoFit = getColumnAutoFit(element); if (columnAutoFit != null) { if(!cut.hasProperty(JRXlsAbstractExporter.PROPERTY_AUTO_FIT_COLUMN)) { cut.setProperty(JRXlsAbstractExporter.PROPERTY_AUTO_FIT_COLUMN, columnAutoFit); } else { cut.setProperty(JRXlsAbstractExporter.PROPERTY_AUTO_FIT_COLUMN, (Boolean)cut.getProperty(JRXlsAbstractExporter.PROPERTY_AUTO_FIT_COLUMN) && columnAutoFit); } } Integer columnCustomWidth = getCustomColumnWidth(element); Integer cutColumnCustomWidth = (Integer)cut.getProperty(JRXlsAbstractExporter.PROPERTY_COLUMN_WIDTH); if (columnCustomWidth != null && (cutColumnCustomWidth == null || cutColumnCustomWidth < columnCustomWidth)) { cut.setProperty(JRXlsAbstractExporter.PROPERTY_COLUMN_WIDTH, columnCustomWidth); } setXProperties(xCutsProperties, element); }
public Float getColumnWidthRatio(JRPrintElement element) { if (element.hasProperties() && element.getPropertiesMap().containsProperty(PROPERTY_COLUMN_WIDTH_RATIO) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return getPropertiesUtil().getFloatProperty(element, PROPERTY_COLUMN_WIDTH_RATIO, 0f); } return null; }
public void collectElementEvaluations(JRPrintPage page, List<JRPrintElement> elements, final ElementEvaluationsCollector collector) { fillContext.lockVirtualizationContext(); try { doCollectElementEvaluations(page, elements, collector, true); } finally { fillContext.unlockVirtualizationContext(); } }
@Override protected void exportPage(JRPrintPage page) throws IOException { List<JRPrintElement> elements = page.getElements(); Map<String, String> currentRow = new HashMap<String, String>(); Map<String, String> repeatedValues = new HashMap<String, String>(); CsvMetadataReportConfiguration configuration = getCurrentItemConfiguration(); boolean hasDefinedColumns = columnNames != null; // if columns where passed in as property exportElements(elements, configuration, currentRow, repeatedValues, hasDefinedColumns); // write last row if (columnNames != null && columnNames.size() > 0) { // write header if it was not yet written if (isFirstRow && configuration.isWriteHeader()) { writeReportHeader(); } writeCurrentRow(currentRow, repeatedValues); } JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ public static void moveContent(ElementRange elementRange, int topY) { int distanceToNewTopY = topY - elementRange.getTopY(); for (int i = elementRange.getFirstElementIndex(); i <= elementRange.getLastElementIndex(); i++) { JRPrintElement printElement = elementRange.getPage().getElements().get(i); printElement.setY(printElement.getY() + distanceToNewTopY); } }
@Override public JRPrintElement remove(int index) { lockContext(); try { ensureDataAndTouch(); JRPrintElement element = elements.remove(index); --size; // decrement the deep count deepElementCount -= DeepPrintElementCounter.count(element); if (elements.isEmpty()) { // if the list is empty now, deregister with the virtualizer. // this helps with subreports by immediately releasing the external storage. deregister(); } return element; } finally { unlockContext(); } }
/** * Creates a print frame element. * * @param templateFrame the template frame that the element will use * @param originator */ public JRTemplatePrintFrame(JRTemplateFrame templateFrame, PrintElementOriginator originator) { super(templateFrame, originator); elements = new ArrayList<JRPrintElement>(); }
protected void createCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts) { for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) { JRPrintElement element = it.next(); if (nature.isToExport(element)) { if (createXCuts) { xCuts.addCutOffset(element.getX() + elementOffsetX); xCuts.addCutOffset(element.getX() + element.getWidth() + elementOffsetX); } yCuts.addCutOffset(element.getY() + elementOffsetY); yCuts.addCutOffset(element.getY() + element.getHeight() + elementOffsetY); JRPrintFrame frame = element instanceof JRPrintFrame ? (JRPrintFrame)element : null; if (frame != null && nature.isDeep(frame)) { createCuts( frame.getElements(), element.getX() + elementOffsetX + frame.getLineBox().getLeftPadding().intValue(), element.getY() + elementOffsetY + frame.getLineBox().getTopPadding().intValue(), createXCuts ); } } } }
@Override protected JRPrintElement fill() throws JRException { JRTemplateGenericPrintElement printElement; if (isEvaluateAuto()) { JRRecordedValuesGenericPrintElement recordedValuesElement = new JRRecordedValuesGenericPrintElement(getTemplate(), printElementOriginator, parameters.length); copyBasicAttributes(recordedValuesElement); initDelayedEvaluationPrint(recordedValuesElement); printElement = recordedValuesElement; } else { printElement = new JRTemplateGenericPrintElement(getTemplate(), printElementOriginator, parameters.length); copyBasicAttributes(printElement); if (isEvaluateNow()) { copy(printElement); } else { filler.addBoundElement(this, printElement, getEvaluationTimeValue(), getEvaluationGroupName(), band); } } return printElement; }
public Integer getPageScale(JRPrintElement element) { if ( element.hasProperties() && element.getPropertiesMap().containsProperty(PROPERTY_PAGE_SCALE) ) { // we make this test to avoid reaching the global default value of the property directly // and thus skipping the report level one, if present return getPropertiesUtil().getIntegerProperty(element, PROPERTY_PAGE_SCALE, 0); } return null; }
protected void addBoundElement(JRFillElement element, JRPrintElement printElement, JREvaluationTime evaluationTime, FillPageKey pageKey) { if (log.isDebugEnabled()) { log.debug("Adding evaluation of " + printElement + " by " + element + " for evaluation " + evaluationTime); } delayedActions.addDelayedAction(element, printElement, evaluationTime, pageKey); }
/** * */ private void startElement(JRPrintElement element) throws IOException { contentWriter.write("{\\shp\\shpbxpage\\shpbypage\\shpwr5\\shpfhdr0\\shpfblwtxt0\\shpz"); contentWriter.write(String.valueOf(zorder++)); contentWriter.write("\\shpleft"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getX() + getOffsetX()))); contentWriter.write("\\shpright"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getX() + getOffsetX() + element.getWidth()))); contentWriter.write("\\shptop"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getY() + getOffsetY()))); contentWriter.write("\\shpbottom"); contentWriter.write(String.valueOf(LengthUtil.twip(element.getY() + getOffsetY() + element.getHeight()))); Color bgcolor = element.getBackcolor(); if (element.getModeValue() == ModeEnum.OPAQUE) { contentWriter.write("{\\sp{\\sn fFilled}{\\sv 1}}"); contentWriter.write("{\\sp{\\sn fillColor}{\\sv "); contentWriter.write(String.valueOf(getColorRGB(bgcolor))); contentWriter.write("}}"); } else { contentWriter.write("{\\sp{\\sn fFilled}{\\sv 0}}"); } contentWriter.write("{\\shpinst"); }
public void exportElement(JRPrintElement element) throws IOException, JRException { if (filter == null || filter.isToExport(element)) { if (element instanceof JRPrintLine) { exportLine((JRPrintLine)element); } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { exportEllipse((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); } } }