Пример #1
0
  /**
   * Handles the loading of defined styles from the style.xml file as well as automatic styles from
   * the content.xml file.
   *
   * <p>Any change to a defined style, such as a short bold section, falls into the latter category.
   */
  protected void loadStyles(SxcDocument sxcDoc) {

    styleCat = new StyleCatalog(25);
    NodeList nl = null;
    String families[] =
        new String[] {
          SxcConstants.COLUMN_STYLE_FAMILY,
          SxcConstants.ROW_STYLE_FAMILY,
          SxcConstants.TABLE_CELL_STYLE_FAMILY
        };
    Class<?> classes[] = new Class[] {ColumnStyle.class, RowStyle.class, CellStyle.class};
    /*
     * Process the content XML for any other style info.
     */
    org.w3c.dom.Document contentDom = sxcDoc.getContentDOM();
    nl = contentDom.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
    if (nl.getLength() != 0) {
      styleCat.add(nl.item(0), families, classes, null, false);
    }

    org.w3c.dom.Document stylesDom = sxcDoc.getStyleDOM();
    nl = stylesDom.getElementsByTagName(TAG_OFFICE_STYLES);
    if (nl.getLength() != 0) {
      styleCat.add(nl.item(0), families, classes, null, false);
    }
  }
Пример #2
0
  /**
   * Method to convert a set of &quot;Device&quot; <code>Document</code> objects into a <code>
   * SxcDocument</code> object and returns it as a <code>Document</code>.
   *
   * <p>This method is not thread safe for performance reasons. This method should not be called
   * from within two threads. It would be best to call this method only once per object instance.
   *
   * @return document An <code>SxcDocument</code> consisting of the data converted from the input
   *     stream.
   * @throws ConvertException If any conversion error occurs.
   * @throws IOException If any I/O error occurs.
   */
  public Document deserialize() throws ConvertException, IOException {

    // Get the name of the WorkBook from the ConvertData.
    String[] worksheetNames = getWorksheetNames(cd);
    String workbookName = getWorkbookName(cd);

    // Create a document
    SxcDocument sxcDoc = new SxcDocument(workbookName);
    sxcDoc.initContentDOM();
    sxcDoc.initSettingsDOM();

    // Default to an initial 5 entries in the catalog.
    styleCat = new StyleCatalog(5);

    doc = sxcDoc.getContentDOM();
    settings = sxcDoc.getSettingsDOM();
    initFontTable();
    // Little fact for the curious reader: workbookName should
    // be the name of the StarCalc file minus the file extension suffix.

    // Create a Decoder to decode the DeviceContent to a spreadsheet document
    // TODO - we aren't using a password in StarCalc, so we can
    // use any value for password here.  If StarCalc XML supports
    // passwords in the future, we should try to get the correct
    // password value here.

    decoder = createDecoder(workbookName, worksheetNames, "password");

    Debug.log(Debug.TRACE, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    Debug.log(Debug.TRACE, "<DEBUGLOG>");

    decoder.addDeviceContent(cd);
    decode();

    Debug.log(Debug.TRACE, "</DEBUGLOG>");

    return sxcDoc;
  }