Beispiel #1
0
 public void writeColumn(StyleEntry[] colStyles) {
   int i = 0;
   while (i < colStyles.length) {
     StyleEntry colStyle = colStyles[i];
     writer.openTag("table:table-column");
     if (colStyle != null) {
       writer.attribute("table:style-name", colStyle.getName());
       int count = 1;
       // group columns with same style together
       while (i < colStyles.length - 1
           && colStyles[i + 1] != null
           && colStyle.getName().equals(colStyles[i + 1].getName())) {
         count++;
         i++;
       }
       if (count > 1) {
         writer.attribute("table:number-columns-repeated", count);
       }
     } else {
       int count = 1;
       // if the next one is null as well, group
       while (i < colStyles.length - 1 && colStyles[i + 1] == null) {
         count++;
         i++;
       }
       if (count > 1) {
         writer.attribute("table:number-columns-repeated", count);
       }
     }
     writer.closeTag("table:table-column");
     i++;
   }
 }
Beispiel #2
0
  public void writeSpanCell(SpanInfo info) {
    writer.openTag("table:covered-table-cell");
    StyleEntry style = info.getStyle();
    if (style != null) {
      writer.attribute("table:style-name", style.getName());
    }

    writeGridSpan(info);

    insertHiddenParagraph();
    writer.closeTag("table:covered-table-cell");
  }
Beispiel #3
0
 public void writeParagraph(String txt, StyleEntry style) {
   writer.openTag("text:p");
   if (style != null) {
     writer.attribute("text:style-name", style.getName());
   }
   writeString(txt);
   writer.closeTag("text:p");
 }
Beispiel #4
0
  /**
   * @param txt
   * @param style
   * @param info
   * @param fieldType
   * @param isField
   */
  protected void writeSpan(
      String txt, StyleEntry style, HyperlinkInfo info, int fieldType, boolean isField) {
    writer.openTag("text:span");
    if (style != null && style.getType() == StyleConstant.TYPE_TEXT) {
      writer.attribute("text:style-name", style.getName());
    }
    // inline style for hyperlinks
    else if (info != null && info.getStyle() != null) {
      writer.attribute("text:style-name", info.getStyle().getName());
    }

    if (isField) {
      writeAutoText(fieldType);
    } else {
      writeString(txt);
    }
    writer.closeTag("text:span");
  }
Beispiel #5
0
  public void startTableCell(StyleEntry style, SpanInfo spanInfo) {
    writer.openTag("table:table-cell");
    if (style != null) {
      writer.attribute("table:style-name", style.getName());
    }

    if (spanInfo != null) {
      writeGridSpan(spanInfo);
    }
  }
Beispiel #6
0
  public void startTable(String name, StyleEntry style) {
    writer.openTag("table:table");

    if (name != null) {
      writer.attribute("table:name", name);
    }

    if (style != null) {
      writer.attribute("table:style-name", style.getName());
    }
  }
Beispiel #7
0
  /**
   * @param data
   * @param height
   * @param width
   * @param style
   * @param altText
   * @param imageId
   */
  protected void drawImage(
      String imageUrl,
      byte[] imageData,
      Double positionX,
      Double positionY,
      double height,
      double width,
      StyleEntry style,
      String altText,
      String layer,
      int imageId) {
    writer.openTag("draw:frame");
    if (style != null) {
      writer.attribute("draw:style-name", style.getName());
    }

    if (layer != null) {
      writer.attribute("draw:layer", layer);
    }

    writer.attribute("draw:name", "Image" + imageId);
    writer.attribute("text:anchor-type", "paragraph");
    writer.attribute("svg:width", width + "in");
    writer.attribute("svg:height", height + "in");

    if (positionX != null) {
      writer.attribute("svg:x", positionX.doubleValue() + "in");
    }
    if (positionY != null) {
      writer.attribute("svg:y", positionY.doubleValue() + "in");
    }

    writer.attribute("draw:z-index", "0");

    writer.openTag("draw:image");
    if (imageData != null) {
      drawImageData(imageData);
    } else {
      drawImageData(imageUrl);
    }
    writer.closeTag("draw:image");

    writer.openTag("svg:title");
    writer.text(altText);
    writer.closeTag("svg:title");

    writer.closeTag("draw:frame");
  }
Beispiel #8
0
 /**
  * @param style style of the row
  * @param height height of current row, if heigh equals 1 then ignore height
  * @param type header or normal
  */
 public void startTableRow(StyleEntry rowStyle) {
   writer.openTag("table:table-row");
   if (rowStyle != null) {
     writer.attribute("table:style-name", rowStyle.getName());
   }
 }