Package org.pentaho.reporting.engine.classic.core.modules.output.table.base

Examples of org.pentaho.reporting.engine.classic.core.modules.output.table.base.SheetLayout


                    final boolean incremental)
      throws ContentProcessingException
  {
    try
    {
      final SheetLayout sheetLayout = contentProducer.getSheetLayout();

      if (documentContentItem == null)
      {
        this.cellBackgroundProducer = new CellBackgroundProducer
            (metaData.isFeatureSupported(AbstractTableOutputProcessor.TREAT_ELLIPSE_AS_RECTANGLE),
                metaData.isFeatureSupported(OutputProcessorFeature.UNALIGNED_PAGEBANDS));

        this.configuration = metaData.getConfiguration();
        this.allowRawLinkTargets = "true".equals
            (configuration.getConfigProperty(HtmlTableModule.ALLOW_RAW_LINK_TARGETS));
        this.copyExternalImages = "true".equals
            (configuration.getConfigProperty(HtmlTableModule.COPY_EXTERNAL_IMAGES));

        documentContentItem = contentLocation.createItem
            (contentNameGenerator.generateName(null, "text/html"));

        final OutputStream out = documentContentItem.getOutputStream();
        final String encoding = configuration.getConfigProperty
            (HtmlTableModule.ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
        writer = new BufferedWriter(new OutputStreamWriter(out, encoding));

        final DefaultTagDescription td = new DefaultTagDescription();
        td.configure(getConfiguration(), "org.pentaho.reporting.engine.classic.core.modules.output.table.html.");

        if (isCreateBodyFragment() == false)
        {
          if (isInlineStylesRequested())
          {
            this.styleManager = new InlineStyleManager();
            this.xmlWriter = new XmlWriter(writer, td);
            this.xmlWriter.addImpliedNamespace(HtmlPrinter.XHTML_NAMESPACE, "");
            this.xmlWriter.setHtmlCompatiblityMode(true);
            writeCompleteHeader(xmlWriter, writer, contentProducer, logicalPage, null, null);
          }
          else
          {
            if (isExternalStyleSheetRequested())
            {
              this.styleFile = dataLocation.createItem(dataNameGenerator.generateName("style", "text/css"));
              this.styleFileUrl = urlRewriter.rewrite(documentContentItem, styleFile);
            }

            this.styleManager = new GlobalStyleManager();
            if (isForceBufferedWriting() == false && styleFile != null)
            {
              this.xmlWriter = new XmlWriter(writer, td);
              this.xmlWriter.addImpliedNamespace(HtmlPrinter.XHTML_NAMESPACE, "");
              this.xmlWriter.setHtmlCompatiblityMode(true);
              writeCompleteHeader(xmlWriter, writer, contentProducer, logicalPage, styleFileUrl, null);
            }
            else
            {
              this.bufferWriter = new MemoryStringWriter(1024 * 512);
              this.xmlWriter = new XmlWriter(bufferWriter, td);
              this.xmlWriter.setAdditionalIndent(1);
              this.xmlWriter.addImpliedNamespace(HtmlPrinter.XHTML_NAMESPACE, "");
              this.xmlWriter.setHtmlCompatiblityMode(true);
            }
          }

          this.xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "body", XmlWriterSupport.OPEN);
        }
        else
        {
          this.styleManager = new InlineStyleManager();
          this.xmlWriter = new XmlWriter(writer, td);
          this.xmlWriter.addImpliedNamespace(HtmlPrinter.XHTML_NAMESPACE, "");
          this.xmlWriter.setHtmlCompatiblityMode(true);
        }

        final ReportAttributeMap map = logicalPage.getAttributes();
        final Object rawContent = map.getAttribute(AttributeNames.Html.NAMESPACE,
            AttributeNames.Html.EXTRA_RAW_CONTENT);
        if (rawContent != null)
        {
          xmlWriter.writeText(String.valueOf(rawContent));
        }

        // table name
        final String sheetName = contentProducer.getSheetName();
        if (sheetName != null)
        {
          xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "h1", createSheetNameAttributes(), XmlWriterSupport.OPEN);
          xmlWriter.writeTextNormalized(sheetName, true);
          xmlWriter.writeCloseTag();
        }

        // table
        xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "table", createTableAttributes(sheetLayout, logicalPage),
            XmlWriterSupport.OPEN);
        writeColumnDeclaration(sheetLayout);
      }

      final int colCount = sheetLayout.getColumnCount();
      final boolean emptyCellsUseCSS = isEmptyCellsUseCSS();

      final int startRow = contentProducer.getFinishedRows();
      final int finishRow = contentProducer.getFilledRows();

      if (textExtractor == null)
      {
        textExtractor = new HtmlTextExtractor(metaData, xmlWriter, styleManager, this);
      }

      for (int row = startRow; row < finishRow; row++)
      {
        xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "tr",
            createRowAttributes(logicalPage, sheetLayout, row, contentProducer), XmlWriterSupport.OPEN);
        for (int col = 0; col < colCount; col++)
        {
          final RenderBox content = contentProducer.getContent(row, col);
          final int sectionType = contentProducer.getSectionType(row, col);
          if (content == null)
          {
            final CellBackground background = cellBackgroundProducer.getBackgroundAt
                (logicalPage, sheetLayout, col, row, true, sectionType);
            if (background == null)
            {
              if (emptyCellsUseCSS)
              {
                xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "td", XmlWriterSupport.CLOSE);
              }
              else
              {
                final AttributeList attrs = new AttributeList();
                attrs.setAttribute(HtmlPrinter.XHTML_NAMESPACE, "style", "font-size: 1pt");
                xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "td", attrs, XmlWriterSupport.OPEN);
                xmlWriter.writeText("&nbsp;");
                xmlWriter.writeCloseTag();
              }
              continue;
            }

            // Background cannot be null at this point ..
            final String[] anchor = background.getAnchors();
            if (anchor.length == 0 && emptyCellsUseCSS)
            {
              final AttributeList cellAttributes = createCellAttributes(1, 1, null, background, null, null);
              xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "td", cellAttributes, XmlWriterSupport.CLOSE);
            }
            else
            {
              final AttributeList cellAttributes =
                  createCellAttributes(1, 1, null, background, HtmlPrinter.EMPTY_CELL_ATTRNAMES,
                      HtmlPrinter.EMPTY_CELL_ATTRVALS);
              xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "td", cellAttributes, XmlWriterSupport.OPEN);
              for (int i = 0; i < anchor.length; i++)
              {
                xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, "a", "name", anchor[i], XmlWriterSupport.CLOSE);
              }
              xmlWriter.writeText("&nbsp;");
              xmlWriter.writeCloseTag();

            }
            continue;
          }

          if (content.isCommited() == false)
          {
            throw new InvalidReportStateException(
                "Uncommited content encountered: " + row + ", " + col + ' ' + content);
          }

          final long contentOffset = contentProducer.getContentOffset(row, col);

          final long colPos = sheetLayout.getXPosition(col);
          final long rowPos = sheetLayout.getYPosition(row);
          if (content.getX() != colPos || (content.getY() + contentOffset) != rowPos)
          {
            // A spanned cell ..
            if (content.isFinished())
            {
              continue;
            }
          }

          final int colSpan = sheetLayout.getColSpan(col, content.getX() + content.getWidth());
          final int rowSpan = sheetLayout.getRowSpan(row, content.getY() + content.getHeight() + contentOffset);

          final CellBackground realBackground = cellBackgroundProducer.getBackgroundAt
              (logicalPage, sheetLayout, col, row, colSpan, rowSpan, true, sectionType);


View Full Code Here


  protected void processPaginationContent(final LogicalPageKey logicalPageKey, final LogicalPageBox logicalPage)
      throws ContentProcessingException
  {
    final TableLayoutProducer tableLayoutProducer = new TableLayoutProducer(metaData);
    tableLayoutProducer.update(logicalPage, false);
    final SheetLayout layout = tableLayoutProducer.getLayout();
    final TableContentProducer tcp = new TableContentProducer(layout, metaData);
    tcp.compute(logicalPage, false);
    try
    {
      // then add it to the layout-producer ..
View Full Code Here

      // Start a new page.
      final PhysicalPageBox page = logicalPage.getPageGrid().getPage(0, 0);
      configureSheet(page);

      // Set column widths ..
      final SheetLayout sheetLayout = contentProducer.getSheetLayout();
      final int columnCount = contentProducer.getColumnCount();
      for (short col = 0; col < columnCount; col++)
      {
        final double cellWidth = StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(col, col + 1));
        final double poiCellWidth = (cellWidth * scaleFactor);
        sheet.setColumnWidth(col, (short) poiCellWidth);
      }
    }

    // and finally the content ..
    final SheetLayout sheetLayout = contentProducer.getSheetLayout();
    final int colCount = sheetLayout.getColumnCount();
    final int startRow = contentProducer.getFinishedRows();
    final int finishRow = contentProducer.getFilledRows();

    for (int row = startRow; row < finishRow; row++)
    {
      final Row hssfRow = getRowAt(row);
      final double lastRowHeight = StrictGeomUtility.toExternalValue(sheetLayout.getRowHeight(row));
      hssfRow.setHeightInPoints((float) (lastRowHeight));

      for (short col = 0; col < colCount; col++)
      {
        final RenderBox content = contentProducer.getContent(row, col);
        if (content == null)
        {
          final int sectionType = contentProducer.getSectionType(row, col);
          final CellBackground background =
              cellBackgroundProducer.getBackgroundAt(logicalPage, sheetLayout, col, row, 1, 1, false, sectionType);
          if (background == null)
          {
            if (row == 0 && col == 0)
            {
              // create a single cell, so that we dont run into nullpointer inside POI..
              getCellAt(col, row);
            }
            // An empty cell .. ignore
            continue;
          }

          // A empty cell with a defined background ..
          final Cell cell = getCellAt(col, row);
          final CellStyle style = cellStyleProducer.createCellStyle(null, background);
          if (style != null)
          {
            cell.setCellStyle(style);
          }
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final long contentOffset = contentProducer.getContentOffset(row, col);
        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY() + contentOffset,
                content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
View Full Code Here

                                  final OutputProcessorMetaData metaData,
                                  final TableContentProducer contentProducer) throws IOException
  {

    // Start a new page.
    final SheetLayout sheetLayout = contentProducer.getSheetLayout();
    final int columnCount = contentProducer.getColumnCount();
    final int rowCount = contentProducer.getRowCount();

    if (cellBackgroundProducer == null)
    {
      this.cellBackgroundProducer = new CellBackgroundProducer
          (metaData.isFeatureSupported(AbstractTableOutputProcessor.TREAT_ELLIPSE_AS_RECTANGLE),
              metaData.isFeatureSupported(OutputProcessorFeature.UNALIGNED_PAGEBANDS));
    }

    final AttributeList pageAttributes = new AttributeList();
    pageAttributes.setAttribute(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "col-count", pointConverter.format(
        columnCount));
    pageAttributes.setAttribute(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "row-count", pointConverter.format(
        rowCount));
    xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "table", pageAttributes, XmlWriter.OPEN);
    xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "cols", XmlWriter.OPEN);
    for (int i = 0; i < columnCount; i++)
    {
      final double cellWidth = StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(i, i + 1));
      xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "column", "width", pointConverter.format(cellWidth),
          XmlWriter.CLOSE);
    }
    xmlWriter.writeCloseTag();

    final int startRow = contentProducer.getFinishedRows();
    final int finishRow = contentProducer.getFilledRows();

    for (int row = startRow; row < finishRow; row++)
    {
      xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "row", XmlWriter.OPEN);

      for (short col = 0; col < columnCount; col++)
      {
        final RenderBox content = contentProducer.getContent(row, col);

        if (content == null)
        {
          final int sectionType = contentProducer.getSectionType(row, col);
          final CellBackground background = cellBackgroundProducer.getBackgroundAt
              (logicalPageBox, sheetLayout, col, row, true, sectionType);
          if (background == null)
          {
            xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "empty-cell", XmlWriter.CLOSE);
            continue;
          }

          // A empty cell with a defined background ..
          xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "empty-cell", createCellAttributes(background),
              XmlWriter.OPEN);

          writeAttributes(background.getAttributes(), background.getElementType());
          xmlWriter.writeCloseTag();
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY(), content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
          xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "spanned-cell", XmlWriter.CLOSE);
View Full Code Here

        writer = new PrintWriter(new OutputStreamWriter(out, encoding));
      }


      final SheetLayout sheetLayout = contentProducer.getSheetLayout();
      final int columnCount = contentProducer.getColumnCount();
      final int lastColumn = columnCount - 1;

      final int startRow = contentProducer.getFinishedRows();
      final int finishRow = contentProducer.getFilledRows();

      for (int row = startRow; row < finishRow; row++)
      {
        for (short col = 0; col < columnCount; col++)
        {
          final RenderBox content = contentProducer.getContent(row, col);
          if (content == null)
          {
            writer.print(quoter.getSeparator());
            continue;
          }

          if (content.isCommited() == false)
          {
            throw new InvalidReportStateException("Uncommited content encountered");
          }

          final long contentOffset = contentProducer.getContentOffset(row, col);
          final long colPos = sheetLayout.getXPosition(col);
          final long rowPos = sheetLayout.getYPosition(row);
          if (content.getX() != colPos || (content.getY() + contentOffset) != rowPos)
          {
            // A spanned cell ..
            writer.print(quoter.getSeparator());
            continue;
View Full Code Here

    }

    // Start a new page.
    try
    {
      final SheetLayout sheetLayout = contentProducer.getSheetLayout();
      final int columnCount = contentProducer.getColumnCount();
      if (table == null)
      {
        final int rowCount = contentProducer.getRowCount();
        table = new Table(columnCount, rowCount);
        table.setAutoFillEmptyCells(false);
        table.setWidth(100); // span the full page..
        // and finally the content ..

        final float[] cellWidths = new float[columnCount];
        for (int i = 0; i < columnCount; i++)
        {
          cellWidths[i] = (float) StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(i, i + 1));
        }
        table.setWidths(cellWidths);
      }

      final int startRow = contentProducer.getFinishedRows();
      final int finishRow = contentProducer.getFilledRows();
      //logger.debug ("Processing: " + startRow + " " + finishRow + " " + incremental);

      for (int row = startRow; row < finishRow; row++)
      {
        for (short col = 0; col < columnCount; col++)
        {
          final RenderBox content = contentProducer.getContent(row, col);
          final int sectionType = contentProducer.getSectionType(row, col);

          if (content == null)
          {
            final CellBackground background = cellBackgroundProducer.getBackgroundAt
                (logicalPage, sheetLayout, col, row, false, sectionType);
            if (background == null)
            {
              // An empty cell .. ignore
              final RtfCell cell = new RtfCell();
              cell.setBorderWidth(0);
              table.addCell(cell, row, col);
              continue;
            }

            // A empty cell with a defined background ..
            final RtfCell cell = new RtfCell();
            cell.setBorderWidth(0);
            updateCellStyle(cell, background);
            table.addCell(cell, row, col);
            continue;
          }

          if (content.isCommited() == false)
          {
            throw new InvalidReportStateException("Uncommited content encountered");
          }

          final long contentOffset = contentProducer.getContentOffset(row, col);
          final long colPos = sheetLayout.getXPosition(col);
          final long rowPos = sheetLayout.getYPosition(row);
          if (content.getX() != colPos || (content.getY() + contentOffset) != rowPos)
          {
            // A spanned cell ..
            continue;
          }

          final int colSpan = sheetLayout.getColSpan(col, content.getX() + content.getWidth());
          final int rowSpan = sheetLayout.getRowSpan(row, content.getY() + content.getHeight() + contentOffset);

          final CellBackground realBackground = cellBackgroundProducer.getBackgroundAt
              (logicalPage, sheetLayout, col, row, colSpan, rowSpan, false, sectionType);

          final Cell cell = new Cell();
View Full Code Here

                                     final LogicalPageBox logicalPage,
                                     final TableContentProducer contentProducer)
  {
   // if (true) return;

    final SheetLayout sheetLayout = contentProducer.getSheetLayout();
    // Lets print the sheet layout
    logger.debug("<table>");
    final int colCount = sheetLayout.getColumnCount();
    for (int col = 0; col < colCount; col++)
    {
      logger.debug("<col pos=" + sheetLayout.getXPosition(col) + " width=" + sheetLayout.getCellWidth(col) + " />");
    }

    final int rowCount = sheetLayout.getRowCount();
    for (int row = 0; row < rowCount; row++)
    {
      logger.debug ("<row pos=" +sheetLayout.getYPosition(row) + " height=" + sheetLayout.getRowHeight(row) + ">");
      for (int col = 0; col < colCount; col++)
      {
        logger.debug("  <cell>");

        final RenderBox content = contentProducer.getContent(row, col);
View Full Code Here

  public void processTableContent(final LogicalPageBox logicalPage,
                                  final TableContentProducer contentProducer) throws IOException
  {

    // Start a new page.
    final SheetLayout sheetLayout = contentProducer.getSheetLayout();
    final int columnCount = contentProducer.getColumnCount();
    final int rowCount = contentProducer.getRowCount();

    final AttributeList pageAttributes = new AttributeList();
    pageAttributes.setAttribute(LAYOUT_OUTPUT_NAMESPACE, "col-count", pointConverter.format(columnCount));
    pageAttributes.setAttribute(LAYOUT_OUTPUT_NAMESPACE, "row-count", pointConverter.format(rowCount));
    xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "table", pageAttributes, XmlWriter.OPEN);
    xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "cols", XmlWriter.OPEN);
    for (int i = 0; i < columnCount; i++)
    {
      final double cellWidth = StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(i, i + 1));
      xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "column", "width", pointConverter.format(cellWidth), XmlWriter.CLOSE);
    }
    xmlWriter.writeCloseTag();

    final int startRow = contentProducer.getFinishedRows();
    final int finishRow = contentProducer.getFilledRows();

    for (int row = startRow; row < finishRow; row++)
    {
      xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "row", XmlWriter.OPEN);

      for (short col = 0; col < columnCount; col++)
      {
        final RenderBox content = contentProducer.getContent(row, col);
        final int sectionType = contentProducer.getSectionType(row, col);

        if (content == null)
        {
          final CellBackground background = cellBackgroundProducer.getBackgroundAt
              (logicalPage, sheetLayout, col, row, true, sectionType);
          if (background == null)
          {
            xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "empty-cell", XmlWriter.CLOSE);
            continue;
          }

          // A empty cell with a defined background ..
          xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "empty-cell", createCellAttributes(background), XmlWriter.CLOSE);
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY(), content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
          xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "spanned-cell", XmlWriter.CLOSE);
View Full Code Here

        conflicts.clear();
        conflicts = tableContentProducer.computeConflicts(pageBox, conflicts);

        // watermark needs extra pass, or it will produce bogus warnings.
        tableLayoutProducer.computeDesigntimeConflicts(pageBox.getWatermarkArea());
        final SheetLayout watermarkLayout = tableLayoutProducer.getLayout();
        tableContentProducer.reset(watermarkLayout);
        conflicts = tableContentProducer.computeWatermarkConflics(pageBox, conflicts);

        transferGlobalLayoutProcessor.performTransfer(pageBox, conflicts, masterReport);
      }
View Full Code Here

                                  final TableContentProducer contentProducer,
                                  final boolean incremental) throws IOException
  {

    // Start a new page.
    final SheetLayout sheetLayout = contentProducer.getSheetLayout();
    final int columnCount = contentProducer.getColumnCount();
    final int rowCount = contentProducer.getRowCount();
    final int startRow = contentProducer.getFinishedRows();
    final int finishRow = contentProducer.getFilledRows();
    if (incremental && startRow == finishRow)
    {
      return;
    }

    if (cellBackgroundProducer == null)
    {
      this.cellBackgroundProducer = new CellBackgroundProducer
          (metaData.isFeatureSupported(AbstractTableOutputProcessor.TREAT_ELLIPSE_AS_RECTANGLE),
              metaData.isFeatureSupported(OutputProcessorFeature.UNALIGNED_PAGEBANDS));
    }

    if (tableOpen == false)
    {
      tableOpen = true;
      final AttributeList pageAttributes = new AttributeList();
      pageAttributes.setAttribute
          (XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "col-count", pointIntConverter.format(columnCount));
      pageAttributes.setAttribute
          (XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "row-count", pointIntConverter.format(rowCount));
      pageAttributes.setAttribute
          (XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "sheet-name", contentProducer.getSheetName());
      xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "table", pageAttributes, XmlWriter.OPEN);
      xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "cols", XmlWriter.OPEN);
      for (int i = 0; i < columnCount; i++)
      {
        final double cellWidth = StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(i, i + 1));
        xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "column", "width", pointShortConverter.format(cellWidth),
            XmlWriter.CLOSE);
      }
      xmlWriter.writeCloseTag();
    }

    for (int row = startRow; row < finishRow; row++)
    {
      final AttributeList rowAttributes = new AttributeList();
      final double rowHeight = StrictGeomUtility.toExternalValue(sheetLayout.getRowHeight(row));
      rowAttributes.setAttribute
          (XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "height",
              pointShortConverter.format(rowHeight));
      xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "row", rowAttributes, XmlWriter.OPEN);

      for (short col = 0; col < columnCount; col++)
      {
        final RenderBox content = contentProducer.getContent(row, col);

        if (content == null)
        {
          final CellMarker.SectionType sectionType = contentProducer.getSectionType(row, col);
          final RenderBox backgroundBox = contentProducer.getBackground(row, col);
          final CellBackground background;
          if (backgroundBox != null)
          {
            background = cellBackgroundProducer.getBackgroundForBox
                (logicalPageBox, sheetLayout, col, row, 1, 1, true, sectionType, backgroundBox);
          }
          else
          {
            background = cellBackgroundProducer.getBackgroundAt(logicalPageBox, sheetLayout, col, row, true, sectionType);
          }
          if (background == null)
          {
            xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "empty-cell", XmlWriter.CLOSE);
            continue;
          }

          // A empty cell with a defined background ..
          xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "empty-cell", createCellAttributes(background),
              XmlWriter.OPEN);

          writeAttributes(background.getAttributes(), background.getElementType());
          xmlWriter.writeCloseTag();
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final long contentOffset = contentProducer.getContentOffset(row, col);
        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
          xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "spanned-cell", XmlWriter.CLOSE);
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.modules.output.table.base.SheetLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.