Package org.jfree.xmlns.writer

Examples of org.jfree.xmlns.writer.XmlWriter


      rootAttributes.addNamespaceDeclaration("office", OfficeNamespaces.OFFICE_NS);
      rootAttributes.addNamespaceDeclaration("config", OfficeNamespaces.CONFIG);
      rootAttributes.addNamespaceDeclaration("ooo", OfficeNamespaces.OO2004_NS);
      rootAttributes.setAttribute(OfficeNamespaces.OFFICE_NS, "version", "1.0");
      final OutputStream outputStream = getOutputRepository().createOutputStream("settings.xml","text/xml");
      final XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), createTagDescription());
      xmlWriter.setAlwaysAddNamespace(true);
      xmlWriter.writeXmlDeclaration("UTF-8");
      xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "document-settings", rootAttributes, XmlWriterSupport.OPEN);
      xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "settings", XmlWriterSupport.OPEN);
      xmlWriter.writeTag(OfficeNamespaces.CONFIG, "config-item-set", "name", "ooo:configuration-settings", XmlWriterSupport.OPEN);

      final AttributeList configAttributes = new AttributeList();
      configAttributes.setAttribute(OfficeNamespaces.CONFIG, "name", "TableRowKeep");
      configAttributes.setAttribute(OfficeNamespaces.CONFIG, "type", "boolean");
      xmlWriter.writeTag(OfficeNamespaces.CONFIG, "config-item", configAttributes, XmlWriterSupport.OPEN);
      xmlWriter.writeText("true");
      xmlWriter.writeCloseTag();

      xmlWriter.writeCloseTag();
      xmlWriter.writeCloseTag();
      xmlWriter.writeCloseTag();
      xmlWriter.close();
    }
    catch (IOException ioe)
    {
      throw new ReportProcessingException("Failed to write settings document");
    }
View Full Code Here


    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.INTERNAL_NS, "image", attrs))
    {
      return;
    }

    final XmlWriter xmlWriter = getXmlWriter();
    if (tableLayoutConfig != TABLE_LAYOUT_VARIABLES_PARAGRAPH &&
        ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-cell", attrs))
    {
      if (variables != null)
      {
        // This cannot happen as long as the report sections only contain tables. But at some point in the
        // future they will be made of paragraphs, and then we are prepared ..
        //Log.debug("Variables-Section " + variables);
        if (sectionKeepTogether == true && expectedTableRowCount > 0)
        {
          StyleUtilities.copyStyle("paragraph",
              TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
              getGlobalStylesCollection(), getPredefinedStylesCollection());
          xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name",
              TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, XmlWriterSupport.OPEN);
          xmlWriter.writeText(variables);
          xmlWriter.writeCloseTag();
          variables = null;
        }
        else
        {
          StyleUtilities.copyStyle("paragraph",
              TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITHOUT_KEEPWNEXT, getStylesCollection(),
              getGlobalStylesCollection(), getPredefinedStylesCollection());
          xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name",
              TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITHOUT_KEEPWNEXT, XmlWriterSupport.OPEN);
          xmlWriter.writeText(variables);
          xmlWriter.writeCloseTag();
          variables = null;
        }
      }
      // Only generate the empty paragraph, if we have to add the keep-together ..
      else if (cellEmpty && expectedTableRowCount > 0 &&
          sectionKeepTogether == true && firstCellSeen == false)
      {
        // we have no variables ..
        StyleUtilities.copyStyle("paragraph",
            TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
            getGlobalStylesCollection(), getPredefinedStylesCollection());
        xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name",
            TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, XmlWriterSupport.CLOSE);
      }
    }

    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-cell", attrs))
    {
      firstCellSeen = true;
    }
    else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "covered-table-cell", attrs))
    {
      firstCellSeen = true;
    }

    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table", attrs))
    {
      if (getCurrentRole() == ROLE_DETAIL)
      {
        if (isTableMergeActive() == false)
        {
          // We do not merge the detail bands, so an ordinary close will do.
          xmlWriter.writeCloseTag();
        }
        else if (detailBandProcessingState == DETAIL_SECTION_FIRST_STARTED)
        {
          final int keepTogetherState = getCurrentContext().getKeepTogether();
          if (keepTogetherState == PageContext.KEEP_TOGETHER_FIRST_DETAIL)
          {
            xmlWriter.writeCloseTag();
            detailBandProcessingState = DETAIL_SECTION_FIRST_PRINTED;
          }
          else
          {
            detailBandProcessingState = DETAIL_SECTION_OTHER_PRINTED;
          }
        }
        else if (detailBandProcessingState == DETAIL_SECTION_OTHER_STARTED)
        {
          detailBandProcessingState = DETAIL_SECTION_OTHER_PRINTED;
        }
      }
      else
      {
        xmlWriter.writeCloseTag();
      }
      if (isSectionPagebreakAfter(attrs))
      {
        setPagebreakDefinition(new PageBreakDefinition(false));
      }
    }
    else
    {
      xmlWriter.writeCloseTag();
    }
  }
View Full Code Here

    if (tableLayoutConfig == TABLE_LAYOUT_SINGLE_DETAIL_TABLE)
    {
      if (detailBandProcessingState == DETAIL_SECTION_OTHER_PRINTED)
      {
        // closes the table ..
        final XmlWriter xmlWriter = getXmlWriter();
        xmlWriter.writeCloseTag();
        detailBandProcessingState = DETAIL_SECTION_WAIT;
      }
    }

  }
View Full Code Here

  protected void endContent(final AttributeMap attrs)
      throws IOException, DataSourceException, ReportProcessingException
  {
    finishSection();
    final BufferState bodyText = finishBuffering();
    final XmlWriter writer = getXmlWriter();

    final Map definedMappings = variablesDeclarations.getDefinedMappings();
    if (definedMappings.isEmpty() == false)
    {
      writer.writeTag(OfficeNamespaces.TEXT_NS, "variable-decls", XmlWriterSupport.OPEN);
      final Iterator mappingsIt = definedMappings.entrySet().iterator();
      while (mappingsIt.hasNext())
      {
        final Map.Entry entry = (Map.Entry) mappingsIt.next();
        final AttributeList entryList = new AttributeList();
        entryList.setAttribute(OfficeNamespaces.TEXT_NS, "name", (String) entry.getKey());
        entryList.setAttribute(OfficeNamespaces.OFFICE_NS, "value-type", (String) entry.getValue());
        writer.writeTag(OfficeNamespaces.TEXT_NS, "variable-decl", entryList, XmlWriterSupport.CLOSE);
      }
      writer.writeCloseTag();
    }

    writer.writeStream(bodyText.getXmlAsReader());
    writer.setLineEmpty(true);
    writer.writeCloseTag();
  }
View Full Code Here

    try
    {
      final OutputStream outputStream = outputRepository.createOutputStream(target, "text/xml");
      final Writer writer = new OutputStreamWriter(outputStream, "UTF-8");

      this.rootXmlWriter = new XmlWriter(writer, tagDescription);
      this.rootXmlWriter.setAlwaysAddNamespace(true);

      final AttributeList rootAttributes = new AttributeList();
      rootAttributes.addNamespaceDeclaration("office", OfficeNamespaces.OFFICE_NS);
      rootAttributes.addNamespaceDeclaration("style", OfficeNamespaces.STYLE_NS);
View Full Code Here

  public void processText(final String text)
      throws DataSourceException, ReportProcessingException
  {
    try
    {
      final XmlWriter xmlWriter = getXmlWriter();
      final LineBreakIterator lb = new LineBreakIterator(text);
      while (lb.hasNext())
      {
        final String line = (String) lb.next();
        final String normalizedText = XmlWriterSupport.normalize(line, false);
        xmlWriter.writeText(normalizedText);
        if (lb.hasNext())
        {
          xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "line-break", XmlWriterSupport.CLOSE);
        }
      }
    }
    catch (IOException e)
    {
View Full Code Here

    {
      // do nothing yet. We should define something for that later ..
      return;
    }

    final XmlWriter xmlWriter = getXmlWriter();
    final String text = String.valueOf(rawvalue);
    try
    {
      final LineBreakIterator lb = new LineBreakIterator(text);
      while (lb.hasNext())
      {
        final String line = (String) lb.next();
        final String normalizedText = XmlWriterSupport.normalize(line, false);
        xmlWriter.writeText(normalizedText);
        if (lb.hasNext())
        {
          xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "line-break", XmlWriterSupport.CLOSE);
        }
      }
    }
    catch (IOException e)
    {
View Full Code Here

  }

  public void startBuffering(final OfficeStylesCollection stylesCollection,
                             final boolean indent) throws ReportProcessingException
  {
    final XmlWriter currentWriter;
    if (xmlWriters.isEmpty())
    {
      currentWriter = rootXmlWriter;
    }
    else
    {
      final BufferState bufferState = (BufferState) xmlWriters.peek();
      currentWriter = bufferState.getXmlWriter();
    }

    try
    {
      final MemoryByteArrayOutputStream out =
          new MemoryByteArrayOutputStream(INITIAL_BUFFER_SIZE, 256 * INITIAL_BUFFER_SIZE);
      final DeflaterOutputStream deflateOut = new DeflaterOutputStream(out);
      final OutputStreamWriter xmlBuffer = new OutputStreamWriter(deflateOut, "UTF-16");
      //    final StringWriter xmlBuffer = new StringWriter
      //        (OfficeDocumentReportTarget.INITIAL_BUFFER_SIZE);
      final XmlWriter contentXmlWriter = new XmlWriter(xmlBuffer, createTagDescription());
      contentXmlWriter.copyNamespaces(currentWriter);
      if (indent)
      {
        contentXmlWriter.setAdditionalIndent(currentWriter.getCurrentIndentLevel());
        contentXmlWriter.setWriteFinalLinebreak(true);
      }
      else
      {
        contentXmlWriter.setWriteFinalLinebreak(false);
      }
      contentXmlWriter.setAlwaysAddNamespace(true);
      xmlWriters.push(new BufferState(contentXmlWriter, out, stylesCollection));
    }
    catch (IOException ioe)
    {
      throw new ReportProcessingException("Unable to create the buffer");
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.