Package org.jfree.layouting.util

Examples of org.jfree.layouting.util.AttributeMap


    }

    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


    }

    protected AttributeMap computeAttributes(final FlowController fc, final Element element, final ReportTarget target)
            throws DataSourceException
    {
        final AttributeMap attributeMap = new AttributeMap( super.computeAttributes(fc, element, target) );
        final Section s = (Section) element;
        int rowCount = 0;
        final Node[] nodeArray = s.getNodeArray();
        for (int i = 0; i < nodeArray.length; i++)
        {
            final Node node = nodeArray[i];
            if (node instanceof Element)
            {
                final Element child = (Element) node;
                if (OfficeNamespaces.TABLE_NS.equals(child.getNamespace()) &&
                        OfficeToken.TABLE_ROW.equals(child.getType()))
                {
                    rowCount += 1;
                }
            }
        }

        attributeMap.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "table-row-count", IntegerCache.getInteger(rowCount));
        attributeMap.makeReadOnly();
        return attributeMap;
    }
View Full Code Here

  }

  protected AttributeMap computeAttributes(final FlowController fc, final Element element, final ReportTarget target)
      throws DataSourceException
  {
    final AttributeMap map = new AttributeMap( super.computeAttributes(fc, element, target) );
    final String value = String.valueOf(repeatHeader || repeatFooter);
    map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeating-header-or-footer", value);
    map.makeReadOnly();
    return map;
  }
View Full Code Here

    protected AttributeMap computeAttributes(final FlowController fc,
            final Element element,
            final ReportTarget target)
            throws DataSourceException
    {
        final AttributeMap attributeMap = new AttributeMap(super.computeAttributes(fc, element, target));
        final String definedStyle = (String) attributeMap.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
        attributeMap.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, getDisplayStyleName((Section) element, definedStyle));

        try
        {
            final DataFlags value = computeValue();
            if (value != null)
            {
                FormatValueUtility.applyValueForCell(value.getValue(), attributeMap);
            }
        }
        catch (Exception e)
        {
        // ignore ..
        }
        attributeMap.makeReadOnly();
        return attributeMap;
    }
View Full Code Here

     * @throws ReportProcessingException
     */
    public final void startElement(final AttributeMap roAttrs)
            throws DataSourceException, ReportProcessingException
    {
        final AttributeMap attrs = new LazyAttributeMap(roAttrs);
        // todo
        if (DEBUG_ELEMENTS)
        {
            LOGGER.debug("Starting " + getCurrentState() + '/' + states.size() + ' ' +
                    ReportTargetUtil.getNamespaceFromAttribute(attrs) + " -> " +
                    ReportTargetUtil.getElemenTypeFromAttribute(attrs));
        }
        try
        {
            switch (getCurrentState())
            {
                case OfficeDocumentReportTarget.STATE_IN_DOCUMENT:
                {
                    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OFFICE_NS, "body", attrs))
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_BODY));
                        startBody(attrs);
                    }
                    else
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_OTHER));
                        if (!isFilteredNamespace(ReportTargetUtil.getNamespaceFromAttribute(attrs)))
                        {
                            startOther(attrs);
                        }
                    }
                    break;
                }
                case OfficeDocumentReportTarget.STATE_IN_BODY:
                {
                    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OFFICE_NS, "report", attrs))
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_CONTENT));
                        startContent(attrs);
                    }
                    else
                    {
                        throw new IllegalStateException("The 'office:body' element must have exactly one child of type 'report'");
                    }
                    break;
                }
                case OfficeDocumentReportTarget.STATE_IN_CONTENT:
                {
                    // Either a ordinary section or a group ..
                    // A group.
                    if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "report-body", attrs))
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP_BODY));
                        startGroupBody(attrs);
                    }
                    else
                    {
                        // Either a template-section, page-header, page-footer, report-header, report-footer
                        // or variables-section
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
                        if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "template", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_TEMPLATE;
                        }
                        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-header", attrs))
                        {
                            if ("spreadsheet-section".equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "role")))
                            {
                                currentRole = OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER;
                            }
                            else
                            {
                                currentRole = OfficeDocumentReportTarget.ROLE_PAGE_HEADER;
                            }
                        }
                        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-footer", attrs))
                        {
                            if ("spreadsheet-section".equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "role")))
                            {
                                currentRole = OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER;
                            }
                            else
                            {
                                currentRole = OfficeDocumentReportTarget.ROLE_PAGE_FOOTER;
                            }
                        }
                        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "report-header", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_REPORT_HEADER;
                        }
                        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "report-footer", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_REPORT_FOOTER;
                        }
                        else if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "variables-section", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_VARIABLES;
                        }
                        else
                        {
                            throw new IllegalStateException("Expected either 'template', 'report-body', " +
                                    "'report-header', 'report-footer', 'variables-section', 'page-header' or 'page-footer'");
                        }
                        startReportSection(attrs, currentRole);
                    }
                    break;
                }
                case OfficeDocumentReportTarget.STATE_IN_GROUP_BODY:
                {
                    // We now expect either an other group or a detail band.

                    if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group", attrs))
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP));
                        groupContext = new GroupContext(groupContext);
                        startGroup(attrs);
                    }
                    else
                    {
                        // Either a variables-section, or a detail-band
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
                        if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "detail", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_DETAIL;
                        }
                        else if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "variables-section", attrs))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_VARIABLES;
                        }
                        else
                        {
                            throw new IllegalStateException("Expected either 'group', 'detail' or 'variables-section'");
                        }
                        startReportSection(attrs, currentRole);
                    }
                    break;
                }
                case OfficeDocumentReportTarget.STATE_IN_GROUP:
                {
                    // A group can carry a repeating group header/footer or a group-instance section.
                    if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "group-instance", attrs))
                    {
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP_INSTANCE));
                        startGroupInstance(attrs);
                    }
                    else
                    {
                        // repeating group header/footer, but *no* variables section
                        states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
                        if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group-header", attrs) &&
                                OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section")))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_HEADER;
                        }
                        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group-footer", attrs) &&
                                OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section")))
                        {
                            currentRole = OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_FOOTER;
                        }
                        else
                        {
View Full Code Here

    }

    public final void endElement(final AttributeMap roAttrs)
            throws DataSourceException, ReportProcessingException
    {
        final AttributeMap attrs = new LazyAttributeMap(roAttrs);
        // final int oldState = getCurrentState();
        try
        {

            switch (getCurrentState())
View Full Code Here

  protected AttributeMap computeAttributes(final FlowController fc,
                                           final Element element,
                                           final ReportTarget target)
      throws DataSourceException
  {
    final AttributeMap attrs = super.computeAttributes(fc, element, target);
    final LayoutController controller = getParent();
    if (!(controller instanceof OfficeGroupLayoutController))
    {
      return attrs;
    }
    final OfficeGroupLayoutController oglc = (OfficeGroupLayoutController) controller;
    if (oglc.isNormalFlowProcessing())
    {
      return attrs;
    }

    final AttributeMap retval = new AttributeMap(attrs);
    retval.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section", OfficeToken.TRUE);
    retval.makeReadOnly();
    return retval;
  }
View Full Code Here

        final FormattedTextElement element = (FormattedTextElement) getNode();
        final VariablesCollection vc = getVariablesCollection();
        if (vc != null)
        {
            final String name = vc.addVariable(element);
            final AttributeMap variablesGet = new AttributeMap();
            variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
                    Element.TYPE_ATTRIBUTE, "variable-get");
            variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE,
                    Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS);
            variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name);
            //variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "display", "value");

            final String dataStyleName = computeValueStyle();
            if (dataStyleName != null)
            {
                variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName);
            }

            final String valueType = computeValueType();
            variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE, valueType);
            target.startElement(variablesGet);

            target.endElement(variablesGet);
        }
        else
View Full Code Here

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

        if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.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, OfficeToken.STYLE_NAME);
            if (tableStyle == null)
            {
                tableBackgroundColor = null;
            }
            else
            {
                final Object raw = StyleUtilities.queryStyle(getPredefinedStylesCollection(), OfficeToken.TABLE, tableStyle,
                        "table-properties", OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR);
                if (raw == null || "transparent".equals(raw))
                {
                    tableBackgroundColor = null;
                }
                else
                {
                    tableBackgroundColor = String.valueOf(raw);
                }
            }
            return;
        }

        if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMN, attrs) ||
                ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.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, OfficeToken.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, OfficeToken.COVERED_TABLE_CELL, null, XmlWriter.CLOSE);
                }
            }
            return;
        }

        if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.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, OfficeToken.STYLE_NAME);
                final OfficeStyle style = deriveStyle(OfficeToken.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, OfficeToken.BACKGROUND_COLOR, tableBackgroundColor);
                    style.addNode(tableRowProperties);
                }
                else
                {
                    final Object oldValue = tableRowProperties.getAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR);
                    if (oldValue == null || "transparent".equals(oldValue))
                    {
                        tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR, tableBackgroundColor);
                    }
                }
                retval.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, style.getStyleName());
            }
        }
        else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_CELL, attrs))
        {
            columnCounter++;
            final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
            if (styleName != null)
            {
                final OfficeStyle cellStyle = getPredefinedStylesCollection().getStyle(OfficeToken.TABLE_CELL, styleName);
                if (cellStyle != null)
                {
                    final Element props = cellStyle.getTableCellProperties();
                    if (props != null)
                    {
                        final Object raw = props.getAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR);
                        if (raw == null || "transparent".equals(raw))
                        {
                            cellStyle.removeNode(props);
                        }
                    }
                }
            }

            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();
            //
            // LOGGER.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)
            {
                retval.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 OfficeToken.TABLE_CELL
        }
View Full Code Here

                xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.SHAPES, null, XmlWriterSupport.OPEN);


                for (int i = 0; i < shapes.size(); i++)
                {
                    final AttributeMap attrs = (AttributeMap) shapes.get(i);
                    final AttributeList attrList = buildAttributeList(attrs);
                    attrList.removeAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME);
                    xmlWriter.writeTag(OfficeNamespaces.DRAWING_NS, OfficeToken.FRAME, attrList, XmlWriterSupport.OPEN);
                    startChartProcessing((AttributeMap) ole.get(i));
View Full Code Here

TOP

Related Classes of org.jfree.layouting.util.AttributeMap

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.