Package org.jfree.report.structure

Examples of org.jfree.report.structure.Element


     * @param attrs the attributes.
     * @throws org.xml.sax.SAXException if there is a parsing error.
     */
    protected void startParsing(final Attributes attrs) throws SAXException
    {
        final Element element = getElement();
        copyElementType(element);
        copyAttributes(attrs, element);
    }
View Full Code Here


      (final OfficeStyle style,
       final OfficeStylesCollection stylesCollection,
       final OfficeStylesCollection predefCollection)
      throws ReportProcessingException
  {
    final Element textProperties = style.getTextProperties();
    if (textProperties == null)
    {
      return;
    }

    try
    {
      final FontFaceDeclsSection currentFonts = stylesCollection.getFontFaceDecls();
      final FontFaceDeclsSection predefFonts = predefCollection.getFontFaceDecls();

      final String fontName = (String)
          textProperties.getAttribute(OfficeNamespaces.STYLE_NS, "font-name");
      if (fontName != null)
      {
        if (currentFonts.containsFont(fontName) == false)
        {
          final FontFaceElement element = predefFonts.getFontFace(fontName);
          if (element != null)
          {
            currentFonts.addFontFace((FontFaceElement) element.clone());
          }
        }
      }

      final String fontNameAsian = (String)
          textProperties.getAttribute(OfficeNamespaces.STYLE_NS,
              "font-name-asian");
      if (fontNameAsian != null)
      {
        if (currentFonts.containsFont(fontNameAsian) == false)
        {
          final FontFaceElement element = predefFonts.getFontFace(
              fontNameAsian);
          if (element != null)
          {
            currentFonts.addFontFace((FontFaceElement) element.clone());
          }
        }
      }

      final String fontNameComplex = (String)
          textProperties.getAttribute(OfficeNamespaces.STYLE_NS,
              "font-name-complex");
      if (fontNameComplex != null)
      {
        if (currentFonts.containsFont(fontNameComplex) == false)
        {
View Full Code Here

    final OfficeStyle style = predefCollection.getStyle(styleFamily, styleName);
    if (style == null)
    {
      return null; // no such style
    }
    final Element section = style.findFirstChild(OfficeNamespaces.STYLE_NS, sectionName);
    if (section != null)
    {
      final Object attribute = section.getAttribute(propertyNamespace, propertyName);
      if (attribute != null)
      {
        return String.valueOf(attribute);
      }
    }
View Full Code Here

        {
          final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TEXT_NS, "style-name");
          final OfficeStyle style = deriveStyle("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");
          final int keepTogetherState = getCurrentContext().getKeepTogether();
          // 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)
          {
            paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "keep-with-next", "always");
          }

          attrs.setAttribute(OfficeNamespaces.TEXT_NS, "style-name", style.getStyleName());
        }
      }
    }
    else
    {
      if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-cell", attrs))
      {
        cellEmpty = false;
        if (firstCellSeen == false && sectionKeepTogether)
        {
          final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
          final OfficeStyle style = deriveStyle("table-cell", 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");
          final int keepTogetherState = getCurrentContext().getKeepTogether();
          // 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)
          {
            paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "keep-with-next", "always");
          }

          attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName());
        }
      }
View Full Code Here

        final OfficeStyle style = deriveStyle("paragraph", TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT);
        style.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName);
        if (breakDefinition.isResetPageNumber())
        {
          final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
          paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");
        }
        if (isColumnBreakPending())
        {
          final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
          paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "break-before", "column");
          setColumnBreakPending(false);
        }
        xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name", style.getStyleName(), XmlWriterSupport.OPEN);
        xmlWriter.writeText(variables);
        xmlWriter.writeCloseTag();
        variables = null;
        masterPageName = null;
        breakDefinition = null;
      }
      else if (isColumnBreakPending())
      {
        setColumnBreakPending(false);

        final OfficeStyle style = deriveStyle("paragraph", TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT);
        final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
        paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");

        xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, "p", "style-name", style.getStyleName(), XmlWriterSupport.OPEN);
        xmlWriter.writeText(variables);
        xmlWriter.writeCloseTag();
        variables = null;
      }
      else
      {
        // Write a paragraph without adding the pagebreak. We can reuse the global style, but we have to make
        // sure that the style is part of the current 'auto-style' collection.
//        Log.debug("Variables-Section " + 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.OPEN);
        xmlWriter.writeText(variables);
        xmlWriter.writeCloseTag();
        variables = null;
      }
    }

    final boolean keepWithNext = isKeepTableWithNext();
    final boolean localKeepTogether = "true".equals
        (attrs.getAttribute(OfficeNamespaces.OOREPORT_NS, "keep-together"));
    final boolean tableMergeActive = isTableMergeActive();
    if (tableMergeActive == false)
    {
      this.sectionKeepTogether = false;
    }
    else
    {
      this.sectionKeepTogether = localKeepTogether;
    }

    // Check, whether we have a reason to derive a style...
    if (masterPageName != null ||
        (tableMergeActive == false && (localKeepTogether || keepWithNext)) || isColumnBreakPending())
    {
      final String styleName = (String)
          attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
      final OfficeStyle style = deriveStyle("table", styleName);

      if (masterPageName != null)
      {
//        Log.debug("Starting a new MasterPage: " + masterPageName);
        // Patch the current styles.
        // This usually only happens on Table-Styles or Paragraph-Styles
        style.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName);
        if (breakDefinition.isResetPageNumber())
        {
          final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
          paragraphProps.setAttribute(OfficeNamespaces.STYLE_NS, "page-number", "1");
        }
      }
      if (isColumnBreakPending())
      {
        final Element paragraphProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "paragraph-properties");
        paragraphProps.setAttribute(OfficeNamespaces.FO_NS, "break-before", "column");
        setColumnBreakPending(false);
      }

      // Inhibit breaks inside the table only if it has been defined and if we do not create one single
      // big detail section. In that case, this flag would be invalid and would cause layout-errors.
      if (tableMergeActive == false)
      {
        if (localKeepTogether)
        {
          final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "table-properties");
          tableProps.setAttribute(OfficeNamespaces.STYLE_NS, "may-break-between-rows", "false");
        }
      }
      else
      {
        if (detailBandProcessingState == DETAIL_SECTION_WAIT)
        {
          detailBandProcessingState = DETAIL_SECTION_FIRST_STARTED;
        }
        else if (detailBandProcessingState == DETAIL_SECTION_FIRST_PRINTED)
        {
          detailBandProcessingState = DETAIL_SECTION_OTHER_STARTED;
        }
      }
      if (keepWithNext)
      {
        final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "table-properties");
        tableProps.setAttribute(OfficeNamespaces.FO_NS, "keep-with-next", "always");
        // A keep-with-next does not work, if the may-break-betweek rows is not set to false ..
        tableProps.setAttribute(OfficeNamespaces.STYLE_NS, "may-break-between-rows", "false");
      }
      attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName());
      // no need to copy the styles, this was done while deriving the
      // style ..
    }
View Full Code Here

      // 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());
      }
    }
View Full Code Here

      {
        // Now this is very bad. It means that there is no style defined with the given name.
        return;
      }

      final Element tableColumnProperties = style.getTableColumnProperties();
      String widthStr = (String) tableColumnProperties.getAttribute("column-width");
      widthStr = widthStr.substring(0, widthStr.indexOf(getUnitsOfMeasure(widthStr)));
      addColumnWidthToRowBoundaryMarker(Float.parseFloat(widthStr));
      ColumnBoundary currentRowBoundary = new ColumnBoundary(getCurrentRowBoundaryMarker());
      final List columnBoundaryList = getColumnBoundaryList();
      final int idx = columnBoundaryList.indexOf(currentRowBoundary);
View Full Code Here

      final OfficeStyle tableStyle = new OfficeStyle();
      tableStyle.setStyleFamily("table");
      tableStyle.setStyleName("Initial_Table");
      tableStyle.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName);
      final Element tableProperties = produceFirstChild(tableStyle, OfficeNamespaces.STYLE_NS, "table-properties");
      tableProperties.setAttribute(OfficeNamespaces.FO_NS, "background-color", "transparent");
      commonStyles.addStyle(tableStyle);
    }
    return "Initial_Table";
  }
View Full Code Here

        for (int i = 0; i < nodeArray.length; i++)
        {
            final Node node = nodeArray[i];
            if (node instanceof Element)
            {
                final Element element = (Element) node;
                if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) &&
                        "table".equals(element.getType()))
                {
                    tables.add(element);
                }
            }
        }
View Full Code Here

            if (!commonStyles.containsStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS))
            {
                final OfficeStyle graphicsDefaultStyle = new OfficeStyle();
                graphicsDefaultStyle.setStyleFamily(OfficeToken.GRAPHIC);
                graphicsDefaultStyle.setStyleName(OfficeToken.GRAPHICS);
                final Element graphicProperties = produceFirstChild(graphicsDefaultStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
                graphicProperties.setAttribute(OfficeNamespaces.TEXT_NS, "anchor-type", OfficeToken.PARAGRAPH);
                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "x", ZERO_CM);
                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "y", ZERO_CM);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "wrap", "dynamic");
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "number-wrapped-paragraphs", "no-limit");
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "wrap-contour", OfficeToken.FALSE);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, VERTICAL_POS, "from-top"); // changed for chart

                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "vertical-rel", OfficeToken.PARAGRAPH);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, HORIZONTAL_POS, "from-left"); // changed for chart

                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "horizontal-rel", OfficeToken.PARAGRAPH);
                commonStyles.addStyle(graphicsDefaultStyle);
            }

            // Make sure that later generated styles do not overwrite existing styles.
            fillStyleNameGenerator(predefinedStylesCollection);
View Full Code Here

TOP

Related Classes of org.jfree.report.structure.Element

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.