public FillPartPrintOutput(BaseReportFiller filler) { parts = new TreeMap<Integer, PrintPart>(); pages = new ArrayList<JRPrintPage>(); delayedActions = new DelayedFillActions(filler); delayedActions.createDelayedEvaluationTime(JREvaluationTime.EVALUATION_TIME_MASTER); if (log.isDebugEnabled()) { log.debug(this + " created delayed actions " + delayedActions.getId()); } if (filler.getFillContext().isCollectingBookmarks()) { bookmarkHelper = new BookmarkHelper(true); } styles = new LinkedHashMap<String, JRStyle>(); origins = new LinkedHashSet<JROrigin>(); }
@Override public void addPage(JRPrintPage page, DelayedFillActions delayedActionsSource) { int pageIndex = pages.size(); if (log.isDebugEnabled()) { log.debug("adding part page at index " + pageIndex); } pages.add(page); if (bookmarkHelper != null) { bookmarkHelper.addBookmarks(page, pageIndex); } delayedActions.moveMasterEvaluations(delayedActionsSource, page, pageIndex); }
@Override public void append(FillPartPrintOutput output) { int pageOffset = pages.size(); for (Map.Entry<Integer, PrintPart> partEntry : output.parts.entrySet()) { parts.put(pageOffset + partEntry.getKey(), partEntry.getValue()); } for (ListIterator<JRPrintPage> it = output.pages.listIterator(); it.hasNext();) { JRPrintPage page = it.next(); pages.add(page); delayedActions.moveMasterEvaluations(output.delayedActions, page, pageOffset + it.previousIndex()); } if (bookmarkHelper != null && output.bookmarkHelper != null) { // adding in bulk bookmarkHelper.appendBookmarks(output.bookmarkHelper, pageOffset); } addStyles(output.styles.values()); addOrigins(output.origins); }
/** * Applies generic element transformers of a specific key to a filled report * by replacing generic elements with the transformed elements. * * @param report the report * @param transformerExportKey the key used to resolve element transformers * @see GenericElementTransformer * @see GenericElementHandlerBundle#getHandler(String, String) */ public static void transformGenericElements( JasperReportsContext jasperReportsContext, JasperPrint report, String transformerExportKey ) { TransformerContext transformerContext = new TransformerContext(jasperReportsContext, report); List<JRPrintPage> pages = report.getPages(); for (Iterator<JRPrintPage> pageIt = pages.iterator(); pageIt.hasNext();) { JRPrintPage page = pageIt.next(); transformElements(transformerContext, transformerExportKey, page.getElements()); } }
protected void exportPage(JRPrintPage page) throws IOException { Collection<JRPrintElement> elements = page.getElements(); Boolean exportReportComponentsOnly = getCurrentConfiguration().isReportComponentsExportOnly(); if (exportReportComponentsOnly == null) { exportReportComponentsOnly = false; } if (!exportReportComponentsOnly) { exportElements(elements); exportWebFonts(); exportHyperlinks(); } exportBookmarks(); exportParts(); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, DocumentException, IOException { tagHelper.startPage(); Collection<JRPrintElement> elements = page.getElements(); exportElements(elements); tagHelper.endPage(); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ public static JRPrintImage getImage(List<JasperPrint> jasperPrintList, JRPrintElementIndex imageIndex) { JasperPrint report = jasperPrintList.get(imageIndex.getReportIndex()); JRPrintPage page = report.getPages().get(imageIndex.getPageIndex()); Integer[] elementIndexes = imageIndex.getAddressArray(); Object element = page.getElements().get(elementIndexes[0].intValue()); for (int i = 1; i < elementIndexes.length; ++i) { JRPrintFrame frame = (JRPrintFrame) element; element = frame.getElements().get(elementIndexes[i].intValue()); } return (JRPrintImage) element; }
/** * Exports a report page * @param page Page that will be exported * @throws JRException */ protected void exportPage(JRPrintPage page, boolean lastPage) throws JRException, IOException { exportElements(page.getElements()); if(!lastPage) { contentWriter.write("\\page\n"); } JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * This static method calculates all the X cuts for a list of pages. * * @param jasperPrint * The JasperPrint document. * @param startPageIndex * The first page to consider. * @param endPageIndex * The last page to consider. * @param offsetX * horizontal element position offset */ public static CutsInfo calculateXCuts(ExporterNature nature, JasperPrint jasperPrint, int startPageIndex, int endPageIndex, int offsetX) { CutsInfo xCuts = new CutsInfo(); List<JRPrintPage> pages = jasperPrint.getPages(); for (int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++) { JRPrintPage page = pages.get(pageIndex); addXCuts(nature, page.getElements(), offsetX, xCuts); } // add a cut at the page width if there are not parts and if no element goes beyond the page width if (!jasperPrint.hasParts()) { int width = jasperPrint.getPageWidth(); int lastCut = xCuts.getLastCutOffset(); if (lastCut < width) { xCuts.addCutOffset(width); } } return xCuts; }
/** * This static method calculates all the X cuts for a list of pages. * * @param pages * The list of pages. * @param startPageIndex * The first page to consider. * @param endPageIndex * The last page to consider. * @param width * The page width * @param offsetX * horizontal element position offset * @deprecated Replaced by {@link #calculateXCuts(ExporterNature, JasperPrint, int, int, int)}. */ public static CutsInfo calculateXCuts(ExporterNature nature, List<JRPrintPage> pages, int startPageIndex, int endPageIndex, int width, int offsetX) { CutsInfo xCuts = new CutsInfo(); for (int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++) { JRPrintPage page = pages.get(pageIndex); addXCuts(nature, page.getElements(), offsetX, xCuts); } // add a cut at the page width if no element goes beyond the width int lastCut = xCuts.getLastCutOffset(); if (lastCut < width) { xCuts.addCutOffset(width); } return xCuts; }
/** * */ 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 JRPrintPage newPage() { JRPrintPage page; if (fillContext.isUsingVirtualizer()) { JRVirtualPrintPage virtualPage = new JRVirtualPrintPage(jasperPrint, virtualizationContext); page = virtualPage; } else { page = new JRBasePrintPage(); } return page; }
protected void addPage(JRPrintPage page) { if (!isSubreport()) { if (log.isDebugEnabled()) { log.debug("Fill " + fillerId + ": adding page " + (jasperPrint.getPages().size() + 1)); } // notify that the previous page was generated int pageCount = jasperPrint.getPages().size(); if (pageCount > 0 && fillListener != null) { fillListener.pageGenerated(jasperPrint, pageCount - 1); } addLastPageBookmarks(); jasperPrint.addPage(page); fillContext.setPrintPage(page); } }
protected boolean hasBoundActions(JRPrintPage page) { boolean hasActions = delayedActions.hasDelayedActions(page); if (hasActions) { return true; } if (subfillers != null) { for (JRBaseFiller subfiller : subfillers.values()) { // recursive if (subfiller.hasBoundActions(page)) { return true; } } } return false; }
@Override public void addPage(JRPrintPage page, DelayedFillActions delayedActionsSource) { int pageIndex = jasperPrint.getPages().size(); if (log.isDebugEnabled()) { log.debug("adding part page at index " + pageIndex); } jasperPrint.addPage(page); addLastPageBookmarks(); delayedActions.moveMasterEvaluations(delayedActionsSource, page, pageIndex); if (fillListener != null) { fillListener.pageGenerated(jasperPrint, pageIndex); } }
protected void registerPage(JRPrintPage page) { if (page instanceof JRVirtualPrintPage) { JRVirtualizationContext virtualizationContext = ((JRVirtualPrintPage) page).getVirtualizationContext(); if (!listenedContexts.contains(virtualizationContext)) { //FIXMEBOOK part reports use a single context which will collect all listeners virtualizationContext.addListener(this); listenedContexts.add(virtualizationContext); if (log.isDebugEnabled()) { log.debug(id + " registered virtualization listener on " + virtualizationContext); } } } }
public boolean hasDelayedActions(JRPrintPage page) { FillPageKey pageKey = new FillPageKey(page); for (LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> map : actionsMap.values()) { fillContext.lockVirtualizationContext(); try { synchronized (map) { LinkedMap<Object, EvaluationBoundAction> boundMap = map.get(pageKey); if (boundMap != null && !boundMap.isEmpty()) { return true; } } } finally { fillContext.unlockVirtualizationContext(); } } return false; }
protected boolean hasMasterDelayedActions(JRPrintPage page) { LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> masterActions = actionsMap.get(JREvaluationTime.EVALUATION_TIME_MASTER); FillPageKey pageKey = new FillPageKey(page); fillContext.lockVirtualizationContext(); try { synchronized (masterActions)//FIXME is this necessary? { LinkedMap<Object, EvaluationBoundAction> pageMasterActions = masterActions.get(pageKey); return pageMasterActions != null && !pageMasterActions.isEmpty(); } } finally { fillContext.unlockVirtualizationContext(); } }
protected void refresh() { if (rViewer != null && hasReport()) { try { List<JRPrintPage> pages = rViewer.getReport().getPages(); if (pages.isEmpty()) refresh(null, "Document is Empty", null); else refresh(renderPage(), null, pages.get(rViewer.getPageIndex())); } catch (Throwable e) { e.printStackTrace(); refresh(null, e.getMessage(), null); } } else refresh(null, null, null); setFocus(); }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { Vector lines = layoutGrid(page); int y = 0; for (y = 0; y < lines.size(); y++) { String s = ("" + lines.elementAt(y)); while (s.endsWith(" ")) { s = s.substring(0, s.length() - 1); } writer.write(s); writer.write("\r\n"); // // DIRUBAH } while (y < PAGE_ROWS) { writer.write("\r\n"); // // DIRUBAH y++; } if (ADD_FORM_FEED) { writer.write("\f"); } if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; ReportExportConfiguration configuration = getCurrentItemConfiguration(); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); JRGridLayout layout = new JRGridLayout( nature, page.getElements(), pageFormat.getPageWidth(), pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), null //address ); exportGrid(layout, null); JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
@Override protected int exportPage(JRPrintPage page, CutsInfo xCuts, int startRow, String defaultSheetName) throws JRException { if (oldPageFormat != pageFormat) { styleBuilder.buildPageLayout(++pageFormatIndex, pageFormat); oldPageFormat = pageFormat; } return super.exportPage(page, xCuts, startRow, defaultSheetName); }
protected void exportPage(JRPrintPage page) throws IOException { Collection<JRPrintElement> elements = page.getElements(); exportElements(elements); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
protected void exportPage(JRPrintPage page) throws IOException { Tabulator tabulator = new Tabulator(tableFilter, page.getElements()); tabulator.tabulate(); HtmlReportConfiguration configuration = getCurrentItemConfiguration(); boolean isIgnorePageMargins = configuration.isIgnorePageMargins(); if (!isIgnorePageMargins) { PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); tabulator.addMargins(pageFormat.getPageWidth(), pageFormat.getPageHeight()); } Table table = tabulator.getTable(); boolean isWhitePageBackground = configuration.isWhitePageBackground(); if (isWhitePageBackground) { setBackcolor(Color.white); } CellElementVisitor elementVisitor = new CellElementVisitor(); TableVisitor tableVisitor = new TableVisitor(tabulator, elementVisitor); exportTable(tableVisitor, table, isWhitePageBackground, true); if (isWhitePageBackground) { restoreBackcolor(); } JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(Graphics2D grx, int pageIndex) throws JRException { List<JRPrintPage> pages = jasperPrint.getPages(); JRPrintPage page = pages.get(pageIndex); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); if (whitePageBackground) { grx.setColor(Color.white); grx.fillRect( 0, 0, pageFormat.getPageWidth(), pageFormat.getPageHeight() ); } grx.setColor(Color.black); grx.setStroke(new BasicStroke(1)); /* */ drawVisitor.getFrameDrawer().draw(grx, page.getElements(), getOffsetX(), getOffsetY()); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException { frameIndexStack = new ArrayList<Integer>(); exportElements(page.getElements()); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException { startPage = true; pageAnchor = JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1); ReportExportConfiguration configuration = getCurrentItemConfiguration(); pageGridLayout = new JRGridLayout( nature, page.getElements(), pageFormat.getPageWidth(), pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), null //address ); exportGrid(pageGridLayout, null); JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
@Override protected int exportPage(JRPrintPage page, CutsInfo xCuts, int startRow, String defaultSheetName) throws JRException { if (oldPageFormat != pageFormat) { oldPageFormat = pageFormat; } return super.exportPage(page, xCuts, startRow, defaultSheetName); }
public JRPrintImage getImage(ExporterInput exporterInput, JRPrintElementIndex imageIndex) throws JRException//FIXMECONTEXT move these to an abstract up? { List<ExporterInputItem> items = exporterInput.getItems(); ExporterInputItem item = items.get(imageIndex.getReportIndex()); JasperPrint report = item.getJasperPrint(); JRPrintPage page = report.getPages().get(imageIndex.getPageIndex()); Integer[] elementIndexes = imageIndex.getAddressArray(); Object element = page.getElements().get(elementIndexes[0].intValue()); for (int i = 1; i < elementIndexes.length; ++i) { JRPrintFrame frame = (JRPrintFrame) element; element = frame.getElements().get(elementIndexes[i].intValue()); } if(element instanceof JRGenericPrintElement) { JRGenericPrintElement genericPrintElement = (JRGenericPrintElement)element; return ((GenericElementXlsxHandler)GenericElementHandlerEnviroment.getInstance(jasperReportsContext).getElementHandler( genericPrintElement.getGenericType(), XLSX_EXPORTER_KEY )).getImage(exporterContext, genericPrintElement); } return (JRPrintImage) element; }
@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(); } }
/** * @throws IOException * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { xmlWriter.startElement(JRXmlConstants.ELEMENT_page); exportElements(page.getElements()); xmlWriter.closeElement(); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportReportToWriter() throws JRException, IOException { List<ExporterInputItem> items = exporterInput.getItems(); for(int reportIndex = 0; reportIndex < items.size(); reportIndex++) { ExporterInputItem item = items.get(reportIndex); setCurrentExporterInputItem(item); List<JRPrintPage> pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) { PageRange pageRange = getPageRange(); int startPageIndex = (pageRange == null || pageRange.getStartPageIndex() == null) ? 0 : pageRange.getStartPageIndex(); int endPageIndex = (pageRange == null || pageRange.getEndPageIndex() == null) ? (pages.size() - 1) : pageRange.getEndPageIndex(); for(int i = startPageIndex; i <= endPageIndex; i++) { if (Thread.interrupted()) { throw new ExportInterruptedException(); } JRPrintPage page = pages.get(i); /* */ exportPage(page); } } } writer.flush(); }
/** * Exports a page to the output writer. Only text elements within the page are considered. For each page, the engine * creates a matrix of characters and each rendered text element is placed at the appropriate position in the matrix. * After all texts are parsed, the character matrix is sent to the output writer. */ protected void exportPage(JRPrintPage page) throws IOException { List<JRPrintElement> elements = page.getElements(); pageData = new char[pageHeightInChars][]; for (int i = 0; i < pageHeightInChars; i++) { pageData[i] = new char[pageWidthInChars]; Arrays.fill(pageData[i], ' '); } exportElements(elements); for (int i = 0; i < pageHeightInChars; i++) { int lineLength = pageWidthInChars; if (isTrimLineRight) { int j = pageWidthInChars - 1; while (j >= 0 && pageData[i][j] == ' ') { j--; } lineLength = j + 1; } writer.write(pageData[i], 0, lineLength); writer.write(lineSeparator); } writer.write(pageSeparator); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
public SimpleElementRange( JRPrintPage page, int columnIndex, int topY ) { this.page = page; this.columnIndex = columnIndex; this.firstElementIndex = page.getElements().size(); // this points to the next element added to the page, if any this.lastElementIndex = firstElementIndex - 1; // if endElementIndex does not change, it means there is no content to move this.topY = topY; this.bottomY = topY; }
protected void addLastPageBookmarks() { if (bookmarkHelper != null) { int pageIndex = jasperPrint.getPages() == null ? -1 : (jasperPrint.getPages().size() - 1); if (pageIndex >= 0) { JRPrintPage page = jasperPrint.getPages().get(pageIndex); bookmarkHelper.addBookmarks(page, pageIndex); } } }
protected void subreportPageFilled(JRPrintPage subreportPage) { FillPageKey subreportKey = new FillPageKey(subreportPage); // this method is only called when the parent is a band report JRBaseFiller parentFiller = (JRBaseFiller) parent.getFiller(); //FIXMEBOOK the index is only correct when the parent is the master, see fillListener.pageUpdated int parentPageIndex = parentFiller.getJasperPrint().getPages().size() - 1; FillPageKey parentKey = new FillPageKey(parentFiller.printPage, parentPageIndex); // move all delayed elements from the subreport page to the master page moveBoundActions(subreportKey, parentKey); // move all master evaluations to the parent parent.getFiller().delayedActions.moveMasterEvaluations(delayedActions, parentKey); }
public boolean isPageFinal(int pageIndex) { currentFillPartLock.readLock().lock(); try { JRPrintPage page = getPage(pageIndex); boolean hasMasterActions = delayedActions.hasDelayedActions(page); if (hasMasterActions) { return false; } boolean isFinal; if (pageIndex < currentPartStartIndex) { isFinal = true; } else { isFinal = currentFillingPart.isPageFinal(page); } return isFinal; } finally { currentFillPartLock.readLock().unlock(); } }
protected void addPage(JRPrintPage page, int pageOffset, DelayedFillActions sourceActions, BookmarkIterator sourceBookmarkIterator) { int pageIndex = jasperPrint.getPages().size(); if (log.isDebugEnabled()) { log.debug("adding part page at index " + pageIndex); } jasperPrint.addPage(page); if (sourceBookmarkIterator != null) { int sourcePageIndex = pageIndex - pageOffset; while (sourceBookmarkIterator.hasBookmark() && sourceBookmarkIterator.bookmark().getPageIndex() == sourcePageIndex) { bookmarkHelper.addBookmark(sourceBookmarkIterator.bookmark(), pageOffset); sourceBookmarkIterator.next(); } } delayedActions.moveMasterEvaluations(sourceActions, page, pageIndex); if (fillListener != null) { fillListener.pageGenerated(jasperPrint, pageIndex); } }
public void collectElementEvaluations(JRPrintPage page, List<JRPrintElement> elements, final ElementEvaluationsCollector collector) { fillContext.lockVirtualizationContext(); try { doCollectElementEvaluations(page, elements, collector, true); } finally { fillContext.unlockVirtualizationContext(); } }
protected Directory createLuceneDirectory(JasperPrint jasperPrint) throws IOException, JRException { Long start = System.currentTimeMillis(); Directory dir = new RAMDirectory(); Analyzer analyzer = getConfiguredAnalyzer(); IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_45, analyzer); iwc.setOpenMode(OpenMode.CREATE); writer = new IndexWriter(dir, iwc); List<JRPrintPage> pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) { if (log.isDebugEnabled()) { log.debug("there are " + pages.size() + " pages to be indexed"); } for (int i = 0, ps = pages.size(); i < ps; i++) { if (log.isDebugEnabled()) { log.debug("indexing page: " + i); } indexPage(pages.get(i), i); } } writer.close(); if (log.isDebugEnabled()) { log.debug("index creation took: " + (System.currentTimeMillis() - start) + " ms"); } return dir; }