protected void exportFrame(
      TableBuilder tableBuilder, JRPrintFrame frame, JRExporterGridCell gridCell)
      throws IOException, JRException {
    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    boolean appendBackcolor =
        frame.getModeValue() == ModeEnum.OPAQUE
            && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB());

    if (appendBackcolor) {
      setBackcolor(frame.getBackcolor());
    }

    try {
      JRGridLayout layout = gridCell.getLayout();
      JRPrintElementIndex frameIndex =
          new JRPrintElementIndex(reportIndex, pageIndex, gridCell.getWrapper().getAddress());
      exportGrid(layout, frameIndex);
    } finally {
      if (appendBackcolor) {
        restoreBackcolor();
      }
    }

    tableBuilder.buildCellFooter();
  }
Ejemplo n.º 2
0
  public CellStyle(Writer styleWriter, JRExporterGridCell gridCell) {
    super(styleWriter);

    JRPrintElement element = gridCell.getElement();

    if (element != null && element.getModeValue() == ModeEnum.OPAQUE) {
      // fill = "solid";
      backcolor = JRColorUtil.getColorHexa(element.getBackcolor());
    } else {
      // fill = "none";
      if (gridCell.getBackcolor() != null) {
        backcolor = JRColorUtil.getColorHexa(gridCell.getBackcolor());
      }
    }

    RotationEnum rotation =
        element instanceof JRPrintText
            ? ((JRPrintText) element).getRotationValue()
            : RotationEnum.NONE;
    VerticalAlignEnum vAlign = VerticalAlignEnum.TOP;
    HorizontalAlignEnum hAlign = HorizontalAlignEnum.LEFT;

    JRAlignment alignment = element instanceof JRAlignment ? (JRAlignment) element : null;
    if (alignment != null) {
      vAlign = alignment.getVerticalAlignmentValue();
      hAlign = alignment.getHorizontalAlignmentValue();
    }

    horizontalAlignment = ParagraphStyle.getHorizontalAlignment(hAlign, vAlign, rotation);
    verticalAlignment = ParagraphStyle.getVerticalAlignment(hAlign, vAlign, rotation);

    setBox(gridCell.getBox());
  }
  public void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell)
      throws IOException {
    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null) {
      textLength = styledText.length();
    }

    tempBodyWriter.write("<text:p text:style-name=\"");
    tempBodyWriter.write(styleCache.getParagraphStyle(text));
    tempBodyWriter.write("\">");
    insertPageAnchor();
    if (text.getAnchorName() != null) {
      exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName()));
    }

    boolean startedHyperlink = startHyperlink(text, true);

    if (textLength > 0) {
      exportStyledText(styledText, getTextLocale(text), startedHyperlink);
    }

    if (startedHyperlink) {
      endHyperlink(true);
    }

    tempBodyWriter.write("</text:p>\n");

    tableBuilder.buildCellFooter();
  }
  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);
  }
  protected void exportRectangle(
      TableBuilder tableBuilder, JRPrintRectangle rectangle, JRExporterGridCell gridCell)
      throws IOException {
    JRLineBox box = new JRBaseLineBox(null);
    JRPen pen = box.getPen();
    pen.setLineColor(rectangle.getLinePen().getLineColor());
    pen.setLineStyle(rectangle.getLinePen().getLineStyleValue());
    pen.setLineWidth(rectangle.getLinePen().getLineWidth());

    gridCell.setBox(box); // CAUTION: only some exporters set the cell box

    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());
    tableBuilder.buildCellFooter();
  }
 protected JRPrintElementIndex getElementIndex(JRExporterGridCell gridCell) {
   JRPrintElementIndex imageIndex =
       new JRPrintElementIndex(reportIndex, pageIndex, gridCell.getWrapper().getAddress());
   return imageIndex;
 }
  protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameIndex)
      throws IOException, JRException {
    CutsInfo xCuts = gridLayout.getXCuts();
    JRExporterGridCell[][] grid = gridLayout.getGrid();

    TableBuilder tableBuilder =
        frameIndex == null
            ? new TableBuilder(reportIndex, pageIndex, tempBodyWriter, tempStyleWriter)
            : new TableBuilder(frameIndex.toString(), tempBodyWriter, tempStyleWriter);

    tableBuilder.buildTableStyle(gridLayout.getWidth());
    tableBuilder.buildTableHeader();

    for (int col = 1; col < xCuts.size(); col++) {
      tableBuilder.buildColumnStyle(col - 1, xCuts.getCutOffset(col) - xCuts.getCutOffset(col - 1));
      tableBuilder.buildColumnHeader(col - 1);
      tableBuilder.buildColumnFooter();
    }

    JRPrintElement element = null;
    for (int row = 0; row < grid.length; row++) {
      int emptyCellColSpan = 0;
      int emptyCellWidth = 0;
      int rowHeight = gridLayout.getRowHeight(row);

      tableBuilder.buildRowStyle(row, rowHeight);
      tableBuilder.buildRowHeader(row);

      for (int col = 0; col < grid[0].length; col++) {
        JRExporterGridCell gridCell = grid[row][col];
        if (gridCell.getType() == JRExporterGridCell.TYPE_OCCUPIED_CELL) {
          if (emptyCellColSpan > 0) {
            // writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight);
            emptyCellColSpan = 0;
            emptyCellWidth = 0;
          }

          // writeOccupiedCells(1);
          exportOccupiedCells(1);
          //					OccupiedGridCell occupiedGridCell = (OccupiedGridCell)gridCell;
          //					ElementGridCell elementGridCell =
          // (ElementGridCell)grid[occupiedGridCell.getRow()][occupiedGridCell.getCol()];
          //					exportOccupiedCells(elementGridCell);
          //					col += elementGridCell.getColSpan() - 1;
        } else if (gridCell.getWrapper() != null) {
          if (emptyCellColSpan > 0) {
            // writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight);
            emptyCellColSpan = 0;
            emptyCellWidth = 0;
          }

          element = gridCell.getWrapper().getElement();

          if (element instanceof JRPrintLine) {
            exportLine(tableBuilder, (JRPrintLine) element, gridCell);
          } else if (element instanceof JRPrintRectangle) {
            exportRectangle(tableBuilder, (JRPrintRectangle) element, gridCell);
          } else if (element instanceof JRPrintEllipse) {
            exportEllipse(tableBuilder, (JRPrintEllipse) element, gridCell);
          } else if (element instanceof JRPrintImage) {
            exportImage(tableBuilder, (JRPrintImage) element, gridCell);
          } else if (element instanceof JRPrintText) {
            exportText(tableBuilder, (JRPrintText) element, gridCell);
          } else if (element instanceof JRPrintFrame) {
            exportFrame(tableBuilder, (JRPrintFrame) element, gridCell);
          } else if (element instanceof JRGenericPrintElement) {
            exportGenericElement(tableBuilder, (JRGenericPrintElement) element, gridCell);
          }

          // //x += gridCell.colSpan - 1;
          // col += gridCell.getColSpan() - 1;
        } else {
          emptyCellColSpan++;
          emptyCellWidth += gridCell.getWidth();
          exportEmptyCell(gridCell, 1);
        }
      }

      //			if (emptyCellColSpan > 0)
      //			{
      //				//writeEmptyCell(null, emptyCellColSpan, emptyCellWidth, rowHeight);
      //			}

      tableBuilder.buildRowFooter();
    }

    tableBuilder.buildTableFooter();
  }