Package org.jfree.xmlns.writer

Examples of org.jfree.xmlns.writer.XmlWriter


        {
            return;
        }

        // do this after we close the tag
        final XmlWriter xmlWriter = getXmlWriter();
        final Object attribute = attrs.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned");
        final int span = TextUtilities.parseInt((String) attribute, 0);
        for (int i = 1; i < span; i++)
        {
            xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.COVERED_TABLE_CELL, null, XmlWriter.CLOSE);
        }
    }
View Full Code Here


    protected void startContent(final AttributeMap attrs) throws IOException, DataSourceException,
            ReportProcessingException
    {
        if (!isElementBoundaryCollectionPass())
        {
            final XmlWriter xmlWriter = getXmlWriter();
            xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, getStartContent(), null, XmlWriterSupport.OPEN);

            final AttributeMap tableAttributes = new AttributeMap();
            tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TABLE_NS);
            tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.TABLE);
            tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, generateInitialTableStyle());
            tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "name", "Report");

            performStyleProcessing(tableAttributes);

            xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE, buildAttributeList(tableAttributes), XmlWriterSupport.OPEN);
            createTableShapes();
            createTableColumns();
        }
    }
View Full Code Here

            ReportProcessingException
    {
        // todo
        if (!isElementBoundaryCollectionPass())
        {
            final XmlWriter xmlWriter = getXmlWriter();
            xmlWriter.writeCloseTag();
            xmlWriter.writeCloseTag();
        }
    }
View Full Code Here

    final OutputStream manifestOutputStream =
        outputRepository.createOutputStream("META-INF/manifest.xml", "text/xml");

    final OutputStreamWriter writer = new OutputStreamWriter(manifestOutputStream, "UTF-8");
    final XmlWriter xmlWriter = new XmlWriter(writer, tagDescription);
    xmlWriter.setAlwaysAddNamespace(true);
    xmlWriter.writeXmlDeclaration("UTF-8");

    final AttributeList rootAttributes = new AttributeList();
    rootAttributes.addNamespaceDeclaration("manifest", MANIFEST_NS);
    xmlWriter.writeTag(MANIFEST_NS, "manifest", rootAttributes, XmlWriterSupport.OPEN);

    final Iterator iterator = entries.entrySet().iterator();
    while (iterator.hasNext())
    {
      final Map.Entry entry = (Map.Entry) iterator.next();
      final AttributeList entryAttrs = new AttributeList();
      entryAttrs.setAttribute(MANIFEST_NS, "media-type", (String) entry.getValue());
      entryAttrs.setAttribute(MANIFEST_NS, "full-path", (String) entry.getKey());
      xmlWriter.writeTag(MANIFEST_NS, "file-entry", entryAttrs, XmlWriterSupport.CLOSE);
    }

    xmlWriter.writeCloseTag();
    xmlWriter.close();
  }
View Full Code Here

  }

  private void processElement(final AttributeMap attrs, final String namespace, final String elementType)
      throws IOException, ReportProcessingException
  {
    final XmlWriter xmlWriter = getXmlWriter();

    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table", attrs))
    {
      // a new table means we must clear our "calculated" table boundary array cache
      boundariesForTableArray = null;

      final String tableStyle = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
      if (tableStyle == null)
      {
        tableBackgroundColor = null;
      }
      else
      {
        final Object raw = StyleUtilities.queryStyle(getPredefinedStylesCollection(), "table", tableStyle,
            "table-properties", OfficeNamespaces.FO_NS, "background-color");
        if (raw == null || "transparent".equals(raw))
        {
          tableBackgroundColor = null;
        }
        else
        {
          tableBackgroundColor = String.valueOf(raw);
        }
      }
      return;
    }

    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-column", attrs)
        || ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-columns", attrs))
    {
      return;
    }

    // covered-table-cell elements may appear in the input from row or column spans. In the event that we hit a
    // column-span we simply ignore these elements because we are going to adjust the span to fit the uniform table.
    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "covered-table-cell", attrs))
    {
      if (columnSpanCounter > 0)
      {
        columnSpanCounter--;
      }

      if (columnSpanCounter == 0)
      {
        // if we weren't expecting a covered-table-cell, let's use it, it's probably from a row-span
        columnCounter++;
        final int span = getColumnSpanForCell(tableCounter, columnCounter, 1);
        // use the calculated span for the column in the uniform table to create any additional covered-table-cell
        // elements
        for (int i = 0; i < span; i++)
        {
          xmlWriter.writeTag(namespace, "covered-table-cell", null, XmlWriter.CLOSE);
        }
      }
      return;
    }

    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-row", attrs))
    {
      // a new row means our column counter gets reset
      columnCounter = 0;
      // Lets make sure the color of the table is ok ..
      if (tableBackgroundColor != null)
      {
        final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
        final OfficeStyle style = deriveStyle("table-row", styleName);
        Element tableRowProperties = style.getTableRowProperties();
        if (tableRowProperties == null)
        {
          tableRowProperties = new Section();
          tableRowProperties.setNamespace(OfficeNamespaces.STYLE_NS);
          tableRowProperties.setType("table-row-properties");
          tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, "background-color", tableBackgroundColor);
          style.addNode(tableRowProperties);
        }
        else
        {
          final Object oldValue = tableRowProperties.getAttribute(OfficeNamespaces.FO_NS, "background-color");
          if (oldValue == null || "transparent".equals(oldValue))
          {
            tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, "background-color", tableBackgroundColor);
          }
        }
        attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName());
      }
    }
    else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-cell", attrs))
    {
      columnCounter++;
      final String numColSpanStr = (String) attrs.getAttribute(namespace, "number-columns-spanned");
      int initialColumnSpan = columnSpanCounter = 1;
      if (numColSpanStr != null)
      {
        initialColumnSpan = Integer.parseInt(numColSpanStr);
        columnSpanCounter = initialColumnSpan;
      }
      final int span = getColumnSpanForCell(tableCounter, columnCounter, initialColumnSpan);
      if (initialColumnSpan > 1)
      {
        // add the initial column span to our column counter index (subtract 1, since it is counted by default)
        columnCounter += initialColumnSpan - 1;
      }

      // if (span < initialColumnSpan)
      // {
      // // ColumnBoundary cbs[] = getBoundariesForTable(tableCounter);
      // // for (int i = 0; i < cbs.length; i++)
      // // {
      // // System.out.print(cbs[i].getBoundary() + " ");
      // // }
      // // System.out.println();
      //
      // Log.error("A cell cannot span less than the declared columns: Declared=" + initialColumnSpan + " Computed="
      // + span);
      // }

      // there's no point to create number-columns-spanned attributes if we only span 1 column
      if (span > 1)
      {
        attrs.setAttribute(namespace, "number-columns-spanned", "" + span);
      }
      // we must also generate "covered-table-cell" elements for each column spanned
      // but we'll do this in the endElement, after we close this "table-cell"
    }

    // All styles have to be processed or you will loose the paragraph-styles and inline text-styles.
    // ..
    performStyleProcessing(attrs);

    final AttributeList attrList = buildAttributeList(attrs);
    xmlWriter.writeTag(namespace, elementType, attrList, XmlWriter.OPEN);
    // System.out.println("elementType = " + elementType);
  }
View Full Code Here

  private void createTableColumns() throws ReportProcessingException
  {
    try
    {
      final XmlWriter xmlWriter = getXmlWriter();
      // at this point we need to generate the table-columns section based on our boundary table
      // <table-columns>
      // <table-column style-name="coX"/>
      // ..
      // </table-columns>
      // the first boundary is '0' which is a placeholder so we will ignore it
      xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "table-columns", null, XmlWriterSupport.OPEN);

      // blow away current column styles
      // start processing at i=1 because we added a boundary for "0" which is virtual
      final ColumnBoundary[] cba = getSortedColumnBoundaryArray();
      for (int i = 1; i < cba.length; i++)
      {
        final ColumnBoundary cb = cba[i];
        float columnWidth = cb.getBoundary();
        if (i > 1)
        {
          columnWidth -= cba[i - 1].getBoundary();
        }
        final OfficeStyle style = deriveStyle("table-column", ("co" + String.valueOf(i) + "_"));
        final Section tableColumnProperties = new Section();
        tableColumnProperties.setType("table-column-properties");
        tableColumnProperties.setNamespace(style.getNamespace());
        tableColumnProperties.setAttribute(style.getNamespace(), "column-width", String.valueOf(columnWidth)
            + getUnitsOfMeasure(null));
        style.addNode(tableColumnProperties);

        final AttributeList myAttrList = new AttributeList();
        myAttrList.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName());
        xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "table-column", myAttrList, XmlWriterSupport.CLOSE);
      }
      xmlWriter.writeCloseTag();
    }
    catch (IOException e)
    {
      throw new ReportProcessingException("Failed", e);
    }
View Full Code Here

      return;
    }

    try
    {
      final XmlWriter xmlWriter = getXmlWriter();
      xmlWriter.writeCloseTag();
      // table-cell elements may have a number-columns-spanned attribute which indicates how many
      // 'covered-table-cell' elements we need to generate
      generateCoveredTableCells(attrs);
    }
    catch (IOException e)
View Full Code Here

    {
      return;
    }

    // do this after we close the tag
    final XmlWriter xmlWriter = getXmlWriter();
    final Object attribute = attrs.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned");
    final int span = TextUtilities.parseInt((String) attribute, 0);
    for (int i = 1; i < span; i++)
    {
      xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "covered-table-cell", null, XmlWriter.CLOSE);
    }
  }
View Full Code Here

    if (isElementBoundaryCollectionPass())
    {
      return;
    }

    final XmlWriter xmlWriter = getXmlWriter();
    xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "spreadsheet", null, XmlWriterSupport.OPEN);

    final AttributeMap tableAttributes = new AttributeMap();
    tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TABLE_NS);
    tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, "table");
    tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", generateInitialTableStyle());
    tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "name", "Report");

    performStyleProcessing(tableAttributes);

    xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "table", buildAttributeList(tableAttributes), XmlWriterSupport.OPEN);
    createTableColumns();
  }
View Full Code Here

      ReportProcessingException
  {
    // todo
    if (isElementBoundaryCollectionPass() == false)
    {
      final XmlWriter xmlWriter = getXmlWriter();
      xmlWriter.writeCloseTag();
      xmlWriter.writeCloseTag();
    }
  }
View Full Code Here

TOP

Related Classes of org.jfree.xmlns.writer.XmlWriter

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.