Package org.jfree.xmlns.writer

Examples of org.jfree.xmlns.writer.XmlWriter


    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

    protected void startContent(final AttributeMap attrs) throws IOException, DataSourceException, ReportProcessingException
    {
        inFilterElements = false;
        closeTags = 0;
        tableCount = 0;
        final XmlWriter xmlWriter = getXmlWriter();
        xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, getStartContent(), null, XmlWriterSupport.OPEN);
        ++closeTags;
    }
View Full Code Here

        ++closeTags;
    }

    protected void endContent(final AttributeMap attrs) throws IOException, DataSourceException, ReportProcessingException
    {
        final XmlWriter xmlWriter = getXmlWriter();
        //xmlWriter.writeCloseTag();
        while (closeTags > 0)
        {
            xmlWriter.writeCloseTag();
            --closeTags;
        }
    }
View Full Code Here

            }
            if (inFilterElements && tableCount > 1)
            {
                return;
            }
            final XmlWriter xmlWriter = getXmlWriter();
            xmlWriter.writeCloseTag();
            --closeTags;
        }
    }
View Full Code Here

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

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

        // derive section style ..

        // This is a rather cheap solution to the problem. In a sane world, we would have to feed the
        // footer multiple times. Right now, we simply rely on the balacing, which should make sure that
        // the column's content are evenly distributed.
        final XmlWriter writer = getXmlWriter();
        final AttributeList attrs = new AttributeList();
        attrs.setAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME, generateSectionStyle(numberOfColumns));
        attrs.setAttribute(OfficeNamespaces.TEXT_NS, NAME, sectionNames.generateName("Section"));
        writer.writeTag(OfficeNamespaces.TEXT_NS, "section", attrs, XmlWriterSupport.OPEN);
        for (int i = 0; i < numberOfColumns; i++)
        {
            writer.writeStream(contents.getXmlAsReader());
        }

        writer.writeCloseTag();
        return finishBuffering();
    }
View Full Code Here

    }

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

        // now start the buffering. We have to insert the variables declaration
        // later ..
        startBuffering(getStylesCollection(), true);
View Full Code Here

                // Log.debug("Variables-Section in own paragraph " + variables);

                StyleUtilities.copyStyle(OfficeToken.PARAGRAPH,
                        TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, getStylesCollection(),
                        getGlobalStylesCollection(), getPredefinedStylesCollection());
                final XmlWriter xmlWriter = getXmlWriter();
                xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, OfficeToken.P, OfficeToken.STYLE_NAME,
                        TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, XmlWriterSupport.OPEN);
                xmlWriter.writeText(variables);
                xmlWriter.writeCloseTag();
                variables = null;
            }

            if (isTableNS && ObjectUtilities.equal(OfficeToken.TABLE_CELL, elementType))
            {
                cellEmpty = true;
            }

            final boolean keepTogetherOnParagraph = true;

            if (keepTogetherOnParagraph)
            {
                if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs))
                {
                    final int keepTogetherState = getCurrentContext().getKeepTogether();
                    cellEmpty = false;
                    if (!firstCellSeen && (sectionKeepTogether || keepTogetherState == PageContext.KEEP_TOGETHER_GROUP))
                    {
                        OfficeStyle style = null;
                        final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME);
                        if (styleName == null)
                        {
                            final boolean keep = (keepTogetherState == PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && isParentKeepTogether();
                            final ArrayList propertyNameSpaces = new ArrayList();
                            final ArrayList propertyNames = new ArrayList();
                            final ArrayList propertyValues = new ArrayList();

                            propertyNameSpaces.add(OfficeNamespaces.FO_NS);
                            propertyNameSpaces.add(OfficeNamespaces.FO_NS);
                            propertyNames.add(KEEP_TOGETHER);
                            propertyValues.add(ALWAYS);
                            if (keep)
                            {
                                propertyNames.add(KEEP_WITH_NEXT);
                                propertyValues.add(ALWAYS);
                            }
                            else
                            {
                                propertyNames.add(KEEP_WITH_NEXT);
                                propertyValues.add(null);
                            }
                            style = StyleUtilities.queryStyleByProperties(getStylesCollection(), OfficeToken.PARAGRAPH, PARAGRAPH_PROPERTIES, propertyNameSpaces, propertyNames, propertyValues);
                        }
                        if (style == null)
                        {
                            style = deriveStyle(OfficeToken.PARAGRAPH, styleName);
                            // Lets set the 'keep-together' flag..

                            Element paragraphProps = style.getParagraphProperties();
                            if (paragraphProps == null)
                            {
                                paragraphProps = new Section();
                                paragraphProps.setNamespace(OfficeNamespaces.STYLE_NS);
                                paragraphProps.setType(PARAGRAPH_PROPERTIES);
                                style.addNode(paragraphProps);
                            }
                            paragraphProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_TOGETHER, ALWAYS);

                            // We prevent pagebreaks within the two adjacent rows (this one and the next one) if
                            // either a group-wide keep-together is defined or if we haven't reached the end of the
                            // current section yet.
                            if ((keepTogetherState == PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && isParentKeepTogether())
                            {
                                paragraphProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_WITH_NEXT, ALWAYS);
                            }
                        }

                        attrs.setAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME, style.getStyleName());
                    }
                }
            }

            if (ObjectUtilities.equal(OfficeNamespaces.DRAWING_NS, namespace) && ObjectUtilities.equal(OfficeToken.FRAME, elementType))
            {
                final String styleName = (String) attrs.getAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME);
                final OfficeStyle predefAutoStyle = getPredefinedStylesCollection().getAutomaticStyles().getStyle(OfficeToken.GRAPHIC, styleName);
                if (predefAutoStyle != null)
                {
                    // special ole handling
                    Element graphicProperties = predefAutoStyle.getGraphicProperties();
                    graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, VERTICAL_POS, "from-top");
                    graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, HORIZONTAL_POS, "from-left");
                    graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "vertical-rel", "paragraph-content");
                    graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "horizontal-rel", "paragraph");
                    graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "flow-with-text", "false");
                    graphicProperties.setAttribute(OfficeNamespaces.DRAWING_NS, "ole-draw-aspect", "1");

                // attrs.setAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME, predefAutoStyle.getStyleName());
                }
            }

            // process the styles as usual
            performStyleProcessing(attrs);
            final XmlWriter xmlWriter = getXmlWriter();
            final AttributeList attrList = buildAttributeList(attrs);
            xmlWriter.writeTag(namespace, elementType, attrList, XmlWriterSupport.OPEN);

            if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs))
            {
                cellEmpty = false;
                if (tableLayoutConfig != TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null)
                {
                    //Log.debug("Variables-Section in existing cell " + variables);
                    xmlWriter.writeText(variables);
                    variables = null;
                }
            }
        }
    }
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.