OpenOffice.org
XMerge API

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

java.lang.Object
  |
  +--org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer
All Implemented Interfaces:
DocumentSerializer, OfficeConstants
Direct Known Subclasses:
SxcDocumentSerializerImpl

public abstract class SxcDocumentSerializer
extends java.lang.Object
implements OfficeConstants, DocumentSerializer

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

The serialize method traverses the DOM Document from the given Document object. It uses a DocEncoder object for the actual conversion of contents to the device spreadsheet format.


Field Summary
protected  SpreadsheetEncoder encoder
          A SpreadsheetEncoder object for encoding to appropriate format.
protected  SxcDocument sxcDoc
          SxcDocument object that this converter processes.
 
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
SxcDocumentSerializer(Document document)
          Constructor.
 
Method Summary
protected  void addCell(java.lang.String cellValue)
          This method will take the input cell value and add it to the spreadsheet Document we are currently encoding.
protected  int calculateContentWidth(java.lang.String content)
          This method calculates the width of the input String.
protected  int getDecimalPlaces(org.w3c.dom.Node node)
          This method takes a table:table-cell Node and traverses down to the text:p tag.
protected abstract  java.lang.String parseFormula(java.lang.String formula)
          This abstract method takes a StarOffice formula and parses into the spreadsheet formula format.
protected  void processColumnWidth(int column)
          This method maintains an array of integers that contains the desired widths (in number of chars) for each column.
abstract  ConvertData serialize()
          Method to convert a DOM Document into "Device" Document objects.
protected  void traverseBody(org.w3c.dom.Node node)
          This method traverses office:body Element.
protected  void traverseCell(org.w3c.dom.Node node)
          This method traverses a table:table-cell element Node.
protected  void traverseParagraph(org.w3c.dom.Node node)
          This method traverses the text:p element Node.
protected  void traverseTable(org.w3c.dom.Node node)
          This method traverses the table:table element Node.
protected  void traverseTableColumn(org.w3c.dom.Node node)
          This method traverses the table:table-column Node.
protected  void traverseTableRow(org.w3c.dom.Node node)
          This method traverses the table:table-row element Node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encoder

protected SpreadsheetEncoder encoder
A SpreadsheetEncoder object for encoding to appropriate format.

sxcDoc

protected SxcDocument sxcDoc
SxcDocument object that this converter processes.
Constructor Detail

SxcDocumentSerializer

public SxcDocumentSerializer(Document document)
Constructor.
Parameters:
document - Input SxcDocument Document.
Method Detail

addCell

protected void addCell(java.lang.String cellValue)
                throws java.io.IOException
This method will take the input cell value and add it to the spreadsheet Document we are currently encoding. This method correctly handles cells that are repeated in either the row, cell, or both directions.
Parameters:
cellValue - The contents of the cell we want to add to the spreadsheet Document.
Throws:
java.io.IOException - If any I/O error occurs.

calculateContentWidth

protected int calculateContentWidth(java.lang.String content)
This method calculates the width of the input String. This value is used in the calculation of column widths.
Parameters:
content - The contents from which to calculate the width.

getDecimalPlaces

protected int getDecimalPlaces(org.w3c.dom.Node node)
This method takes a table:table-cell Node and traverses down to the text:p tag. The value is extracted from the text:p tag and the number of decimal places is calculated.
Parameters:
node - A table:table-cell Node.
Returns:
The number of decimal places in the display string of the data in the input Node.

parseFormula

protected abstract java.lang.String parseFormula(java.lang.String formula)
This abstract method takes a StarOffice formula and parses into the spreadsheet formula format.
Parameters:
formula - The formula to be parsed
Returns:
The parsed formula.

processColumnWidth

protected void processColumnWidth(int column)
This method maintains an array of integers that contains the desired widths (in number of chars) for each column.
Parameters:
column - The current column number.

serialize

public abstract ConvertData serialize()
                               throws ConvertException,
                                      java.io.IOException

Method to convert a DOM Document into "Device" Document objects.

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:
serialize in interface DocumentSerializer
Returns:
ConvertData containing "Device" Document objects.
Throws:
ConvertException - If any conversion error occurs.
java.io.IOException - If any I/O error occurs.

traverseBody

protected void traverseBody(org.w3c.dom.Node node)
                     throws java.io.IOException
This method traverses office:body Element.
Parameters:
node - office:body Node.
Throws:
java.io.IOException - If any I/O error occurs.

traverseCell

protected void traverseCell(org.w3c.dom.Node node)
                     throws java.io.IOException
This method traverses a table:table-cell element Node.
Parameters:
node - a table:table-cell Node.
Throws:
java.io.IOException - if any I/O error occurs.

traverseParagraph

protected void traverseParagraph(org.w3c.dom.Node node)
                          throws java.io.IOException
This method traverses the text:p element Node.
Parameters:
node - A text:p Node.
Throws:
java.io.IOException - If any I/O error occurs.

traverseTable

protected void traverseTable(org.w3c.dom.Node node)
                      throws java.io.IOException
This method traverses the table:table element Node.
Parameters:
node - A table:table Node.
Throws:
java.io.IOException - If any I/O error occurs.

traverseTableColumn

protected void traverseTableColumn(org.w3c.dom.Node node)
                            throws java.io.IOException
This method traverses the table:table-column Node. Not yet implemented.
Parameters:
node - A table:table-column Node.
Throws:
java.io.IOException - If any I/O error occurs.

traverseTableRow

protected void traverseTableRow(org.w3c.dom.Node node)
                         throws java.io.IOException
This method traverses the table:table-row element Node.
Parameters:
node - A table:table-row Node.
Throws:
java.io.IOException - If any I/O error occurs.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org