OpenOffice.org
XMerge API

org.openoffice.xmerge.converter.xml.sxc
Class SxcDocumentDeserializer

java.lang.Object
  |
  +--org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer
All Implemented Interfaces:
DocumentDeserializer, OfficeConstants
Direct Known Subclasses:
SxcDocumentDeserializerImpl

public abstract class SxcDocumentDeserializer
extends java.lang.Object
implements OfficeConstants, DocumentDeserializer

General spreadsheet implementation of DocumentDeserializer for the SxcPluginFactory. Used with SXC Document objects.

The deserialize method uses a DocDecoder to read the device spreadsheet format into a String object, then it calls buildDocument to create a SxcDocument object from it.


Fields inherited from interface org.openoffice.xmerge.converter.xml.OfficeConstants
ATTRIBUTE_FO_FONT_FAMILY, ATTRIBUTE_OFFICE_CLASS, ATTRIBUTE_SPACE_COUNT, ATTRIBUTE_STYLE_FONT_PITCH, ATTRIBUTE_STYLE_NAME, ATTRIBUTE_TABLE_BOOLEAN_VALUE, ATTRIBUTE_TABLE_CURRENCY, ATTRIBUTE_TABLE_DATE_VALUE, ATTRIBUTE_TABLE_FORMULA, ATTRIBUTE_TABLE_NAME, ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED, ATTRIBUTE_TABLE_NUM_ROWS_REPEATED, ATTRIBUTE_TABLE_STRING_VALUE, ATTRIBUTE_TABLE_STYLE_NAME, ATTRIBUTE_TABLE_TIME_VALUE, ATTRIBUTE_TABLE_VALUE, ATTRIBUTE_TABLE_VALUE_TYPE, ATTRIBUTE_TEXT_STYLE_NAME, CELLTYPE_BOOLEAN, CELLTYPE_CURRENCY, CELLTYPE_DATE, CELLTYPE_FLOAT, CELLTYPE_PERCENT, CELLTYPE_STRING, CELLTYPE_TIME, SXC_FILE_EXTENSION, SXC_TYPE, SXW_FILE_EXTENSION, SXW_TYPE, TAG_BOOKMARK, TAG_BOOKMARK_START, TAG_HEADING, TAG_HYPERLINK, TAG_LINE_BREAK, TAG_LIST_HEADER, TAG_LIST_ITEM, TAG_OFFICE_AUTOMATIC_STYLES, TAG_OFFICE_BODY, TAG_OFFICE_DOCUMENT, TAG_OFFICE_DOCUMENT_CONTENT, TAG_OFFICE_DOCUMENT_STYLES, TAG_OFFICE_FONT_DECLS, TAG_OFFICE_MASTER_STYLES, TAG_OFFICE_STYLES, TAG_ORDERED_LIST, TAG_PARAGRAPH, TAG_SPACE, TAG_SPAN, TAG_STYLE_FONT_DECL, TAG_TAB_STOP, TAG_TABLE, TAG_TABLE_CELL, TAG_TABLE_COLUMN, TAG_TABLE_ROW, TAG_TABLE_SCENARIO, TAG_UNORDERED_LIST
 
Constructor Summary
SxcDocumentDeserializer(ConvertData cd)
          Constructor.
 
Method Summary
protected  void addEmptyCells(int numColsSkipped, org.w3c.dom.Node row)
          This method will add empty cells to the Document.
protected  void addEmptyRows(int numEmptyRows, org.w3c.dom.Node root, int numEmptyCells)
          This method will add empty rows to the Document.
abstract  SpreadsheetDecoder createDecoder(java.lang.String workbook, java.lang.String[] worksheetNames, java.lang.String password)
          This abstract method will be implemented by concrete subclasses and will return an application-specific Decoder.
protected  void decode()
          Outer level method used to decode a WorkBook into a Document.
 Document deserialize()
          Method to convert a set of "Device" Document objects into a SxcDocument object and returns it as a Document.
protected abstract  java.lang.String getWorkbookName(ConvertData cd)
          This method will return the name of the WorkBook from the ConvertData.
protected abstract  java.lang.String[] getWorksheetNames(ConvertData cd)
          This method will return the name of the WorkSheet from the ConvertData.
protected  java.lang.String parseFormula(java.lang.String formula)
          This method takes a formula and parses it into StarOffice XML formula format.
protected  void processCellData(org.w3c.dom.Element cellElement, java.lang.String type, java.lang.String contents)
          This method process the data in a cell and sets the appropriate attributes on the cell Element.
protected  void processCells(org.w3c.dom.Node root)
          This method process the cells in a Document and generates a portion of the Document.
protected  void processTable(org.w3c.dom.Node root)
          This method process a WorkSheet and generates a portion of the Document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SxcDocumentDeserializer

public SxcDocumentDeserializer(ConvertData cd)
Constructor.
Parameters:
cd - ConvertData consisting of a device content object.
Method Detail

addEmptyCells

protected void addEmptyCells(int numColsSkipped,
                             org.w3c.dom.Node row)
This method will add empty cells to the Document. It is called when the conversion process encounters a row that contains some cells without data.
Parameters:
numColsSkipped - The number of empty cells that we need to add to the current row.
row - The Node of the Document we are building that we will append our empty cell Node objects. This Node should be a TAG_TABLE_ROW tag.

addEmptyRows

protected void addEmptyRows(int numEmptyRows,
                            org.w3c.dom.Node root,
                            int numEmptyCells)
This method will add empty rows to the Document. It is called when the conversion process encounters a row (or rows) that do not contain any data in its cells.
Parameters:
numEmptyRows - The number of empty rows that we need to add to the Document.
root - The Node of the Document we are building that we will append our empty row Node objects. This Node should be a TAG_TABLE tag.
numEmptyCells - The number of empty cells in the empty row.

createDecoder

public abstract SpreadsheetDecoder createDecoder(java.lang.String workbook,
                                                 java.lang.String[] worksheetNames,
                                                 java.lang.String password)
                                          throws java.io.IOException
This abstract method will be implemented by concrete subclasses and will return an application-specific Decoder.
Parameters:
workbook - The WorkBook to read.
password - The WorkBook password.
Returns:
The appropriate SpreadSheetDecoder.
Throws:
java.io.IOException - If any I/O error occurs.

decode

protected void decode()
               throws java.io.IOException
Outer level method used to decode a WorkBook into a Document.
Throws:
java.io.IOException - If any I/O error occurs.

deserialize

public Document deserialize()
                     throws ConvertException,
                            java.io.IOException

Method to convert a set of "Device" Document objects into a SxcDocument object and returns it as a Document.

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.

Specified by:
deserialize in interface DocumentDeserializer
Returns:
document An SxcDocument consisting of the data converted from the input stream.
Throws:
ConvertException - If any conversion error occurs.
java.io.IOException - If any I/O error occurs.

getWorkbookName

protected abstract java.lang.String getWorkbookName(ConvertData cd)
                                             throws java.io.IOException

This method will return the name of the WorkBook from the ConvertData. Allows for situations where the WorkBook name differs from the Device Content name.

Implemented in the Deserializer as the Decoder's constructor requires a name.

Parameters:
cd - The ConvertData containing the Device content.
Returns:
The WorkBook name.

getWorksheetNames

protected abstract java.lang.String[] getWorksheetNames(ConvertData cd)
                                                 throws java.io.IOException
This method will return the name of the WorkSheet from the ConvertData.
Parameters:
cd - The ConvertData containing the Device content.
Returns:
The WorkSheet names.

parseFormula

protected java.lang.String parseFormula(java.lang.String formula)

This method takes a formula and parses it into StarOffice XML formula format.

Many spreadsheets use ',' as a separator. StarOffice XML format uses ';' as a separator instead.

Many spreadsheets use '!' as a separator when refencing a cell in a different sheet.

Example: =sheet1!A1

StarOffice XML format uses '.' as a separator instead.

Example: =sheet1.A1
Parameters:
formula - A formula string.
Returns:
A StarOffice XML format formula string.

processCellData

protected void processCellData(org.w3c.dom.Element cellElement,
                               java.lang.String type,
                               java.lang.String contents)
This method process the data in a cell and sets the appropriate attributes on the cell Element.
Parameters:
cellElement - A TAG_TABLE_CELL Element that we will be adding attributes to based on the type of data in the cell.
type - The type of data contained in the cell.
contents - The contents of the data contained in the cell.

processCells

protected void processCells(org.w3c.dom.Node root)
                     throws java.io.IOException

This method process the cells in a Document and generates a portion of the Document.

This method assumes that records are sorted by row and then column.

Parameters:
root - The Node of the Document we are building that we will append our cell Node objects. This Node should be a TAG_TABLE tag.
Throws:
java.io.IOException - If any I/O error occurs.

processTable

protected void processTable(org.w3c.dom.Node root)
                     throws java.io.IOException
This method process a WorkSheet and generates a portion of the Document. A spreadsheet is represented as a table Node in StarOffice XML format.
Parameters:
root - The root Node of the Document we are building. This Node should be a TAG_OFFICE_BODY tag.
Throws:
java.io.IOException - If any I/O error occurs.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org