19package org.openoffice.xmerge.converter.xml.sxc;
21import java.io.IOException;
22import java.util.Iterator;
32import org.w3c.dom.Element;
33import org.w3c.dom.Node;
34import org.w3c.dom.NodeList;
59 private org.w3c.dom.Document
doc =
null;
143 sxcDoc.initContentDOM();
144 sxcDoc.initSettingsDOM();
149 doc = sxcDoc.getContentDOM();
180 String fontTable[]=
new String[] {
"Tahoma",
"Tahoma",
"swiss",
"variable",
181 "Courier New",
"'Courier New'",
186 Node root = list.item(0);
188 for(
int i=0;
i<fontTable.length;) {
198 root.appendChild(tableElement);
208 protected void decode() throws IOException {
215 System.err.println(
"Error decoding invalid Input stream");
222 Node node = list.item(0);
224 for (
int i = 0;
i < numSheets;
i++) {
229 int len = list.getLength();
240 if(nameDefinitionTable.hasNext()) {
246 Node settingsNode = settingsList.item(0);
268 configItemMapIndexed.appendChild(configItemMapEntry);
269 configItemSetEntry.appendChild(configItemMapIndexed);
270 root.appendChild(configItemSetEntry);
289 while(eNameDefinitions.hasNext()) {
295 root.appendChild(namedExpressionsElement);
330 root.appendChild(tableElement);
374 styleName = existingStyle.
getName();
385 root.appendChild(colElement);
405 Element rowElement =
null;
408 Element cellElement =
null;
421 Node autoStylesNode =
null;
434 if (
col <= lastColumn && rowElement !=
null) {
435 int numSkippedCells = lastColumn -
col + 1;
445 int deltaRows = newRow - row;
476 styleName = existingStyle.
getName();
485 root.appendChild(rowElement);
493 if (rowElement ==
null) {
505 int numColsSkipped = newCol -
col;
532 autoStylesNode =
doc.getElementsByTagName(
535 if (autoStylesNode ==
null) {
537 doc.insertBefore(autoStylesNode, bodyNode);
553 styleName = existingStyle.
getName();
563 rowElement.appendChild(cellElement);
567 cellElement.appendChild(textElement);
568 textElement.appendChild(
doc.createTextNode(cellContents));
578 if (
col <= lastColumn && rowElement !=
null) {
579 int numSkippedCells = lastColumn -
col + 1;
584 if(autoStylesNode!=
null) {
587 int nlLen = nl.getLength();
588 for (
int i = 0;
i < nlLen;
i++) {
589 autoStylesNode.appendChild(nl.item(0));
613 protected void addEmptyRows(
int numEmptyRows, Node root,
int numEmptyCells) {
624 Integer.toString(numEmptyRows));
627 root.appendChild(rowElement);
633 for (
int i = 0;
i < numEmptyRows;
i++) {
663 if (numColsSkipped > 1) {
667 Integer.toString(numColsSkipped));
671 row.appendChild(cellElement);
674 for (
int i = 0;
i < numColsSkipped;
i++) {
696 if (contents.startsWith(
"=")) {
723 contents.toLowerCase());
ConvertData is used as a container for passing Document objects in and out of the Convert class.
This Exception is thrown by convert algorithms.
A StyleCatalog holds a collection of Style objects.
Style[] getMatching(Style s)
Given a Style s return all Style objects that match.
Element writeNode(org.w3c.dom.Document parentDoc, String name)
Create a Node named name in Document parentDoc, and write the entire StyleCatalog to it.
void add(Node node, String families[], Class<?> classes[], Class<?> defaultClass, boolean alwaysCreateDefault)
Parse the Document starting from node and working downward, and add all styles found,...
An object of class Style represents a style in an OpenOffice document.
String getName()
Returns the name of this Style.
void setName(String newName)
Sets the name of this Style.
This is a class representing the different attributes for a worksheet contained in settings....
void writeNode(org.w3c.dom.Document settings, Node root)
Writes out a settings.xml entry for this BookSettings object.
Represents a text Style in an OpenOffice document.
This is a class to define a table-column structure.
boolean isRow()
Does this ColumnRowInfo represent a row?
int getRepeated()
Get the repeat count for this item.
int getSize()
Get the height (for rows) or width (for columns).
boolean isColumn()
Does this ColumnRowInfo represent a column?
Represents a text Style in an OpenOffice document.
This is a class to define a Name Definition structure.
void writeNode(org.w3c.dom.Document doc, Node root)
Writes out a content.xml entry for this NameDefinition object.
Represents a text Style in an OpenOffice document.
This class is a abstract class for encoding a "Device" Document format into an alternative spreadshee...
abstract String getCellContents()
Return the contents of the active cell.
abstract Iterator< ColumnRowInfo > getColumnRowInfos()
Returns an Enumeration to a Vector of ColumnRowInfo.
abstract int getNumberOfColumns()
Returns the number of populated columns in the current WorkSheet.
abstract String getSheetName()
Returns the name of the current WorkSheet.
abstract BookSettings getSettings()
Returns the BookSettings.
abstract int getRowNumber()
Returns the number of the active row.
abstract Format getCellFormat()
Return a Format object describing the active cells formatting.
abstract void addDeviceContent(ConvertData cd)
Add the contents of a ConvertData to the workbook.
abstract String getCellDataType()
Return the data type of the active cell.
abstract String getCellValue()
Return the value of the active cell.
abstract boolean goToNextCell()
Move on the next populated cell in the current WorkSheet.
abstract int getColNumber()
Returns the number of the active column.
abstract void setWorksheet(int sheetIndex)
Sets the active WorkSheet.
abstract int getNumberOfSheets()
Returns the total number of sheets in the WorkBook.
abstract Iterator< NameDefinition > getNameDefinitions()
Returns an Enumeration to a Vector of NameDefinition.
General spreadsheet implementation of DocumentDeserializer for the SxcPluginFactory.
void processCellData(Element cellElement, String type, String contents)
This method process the data in a cell and sets the appropriate attributes on the cell Element.
void processNameDefinition(Node root, Iterator< NameDefinition > eNameDefinitions)
This method process a Name Definition Table and generates a portion of the Document.
final ConvertData cd
A ConvertData object assigned to this object.
void processCells(Node root)
This method process the cells in a Document and generates a portion of the Document.
StyleCatalog styleCat
A StyleCatalog for the workbook.
void addEmptyCells(int numColsSkipped, Node row)
This method will add empty cells to the Document.
SxcDocumentDeserializer(ConvertData cd)
Constructor.
org.w3c.dom.Document settings
A w3c Document.
abstract String[] getWorksheetNames(ConvertData cd)
This method will return the name of the WorkSheet from the ConvertData.
void processColumns(Node root)
This method process the cells in a Document and generates a portion of the Document.
void initFontTable()
This initializes a font table so we can include some basic font support for spreadsheets.
void processTable(Node root)
This method process a WorkSheet and generates a portion of the Document.
org.w3c.dom.Document doc
A w3c Document.
SpreadsheetDecoder decoder
A SpreadsheetDecoder object for decoding from device formats.
void decode()
Outer level method used to decode a WorkBook into a Document.
abstract String getWorkbookName(ConvertData cd)
This method will return the name of the WorkBook from the ConvertData.
abstract SpreadsheetDecoder createDecoder(String workbook, String[] worksheetNames, String password)
This abstract method will be implemented by concrete subclasses and will return an application-specif...
Document deserialize()
Method to convert a set of "Device" Document objects into a SxcDocument object and returns it as a Do...
void processSettings(Node root)
This method process the settings portion of the Document.
void addEmptyRows(int numEmptyRows, Node root, int numEmptyCells)
This method will add empty rows to the Document.
This class is an implementation of OfficeDocument for the SXC format.
This class is used for logging debug messages.
static final int TRACE
Trace messages.
static void log(int flag, String msg)
Log message based on the flag type.
A DocumentDeserializer represents a converter that converts "Device" Document objects into the "Offic...
A Document represents any Document to be converted and the resulting Document from any conversion.
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String TAG_TABLE_CELL
Element tag for table:table-cell.
String ATTRIBUTE_FO_FONT_FAMILY_GENERIC
Attribute tag for fo:font-family of element fo:font-family.
String ATTRIBUTE_CONFIG_NAME
Attribute tag for config:name of element config:config-item.
String ATTRIBUTE_TABLE_VALUE
Attribute tag for table:value of element table:table-cell.
String ATTRIBUTE_TABLE_VALUE_TYPE
Attribute tag for table:value-type of element table:table-cell.
String ATTRIBUTE_TABLE_STYLE_NAME
Attribute tag for table:style-name of table elements.
String ATTRIBUTE_STYLE_NAME
Attribute tag for style:name of element style:name.
String ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED
Attribute tag for table:number-columns-repeated of element table:table-cell.
String TAG_TABLE_COLUMN
Element tag for table:table-column.
String ATTRIBUTE_FO_FONT_FAMILY
Attribute tag for fo:font-family of element fo:font-family.
String TAG_TABLE
Element tag for table:table.
String CELLTYPE_CURRENCY
The cell contains data of type currency.
String TAG_OFFICE_BODY
Element tag for office:body.
String TAG_CONFIG_ITEM_MAP_ENTRY
Element tag for config:config-item-map-entry.
String TAG_PARAGRAPH
Element tag for text:p.
String CELLTYPE_BOOLEAN
The cell contains data of type boolean.
String ATTRIBUTE_TABLE_BOOLEAN_VALUE
Attribute tag for table:time-boolean-value of element table:table-cell.
String TAG_OFFICE_AUTOMATIC_STYLES
Element tag for office:automatic-styles.
String CELLTYPE_DATE
The cell contains data of type date.
String TAG_TABLE_ROW
Element tag for table:table-row.
String CELLTYPE_TIME
The cell contains data of type time.
String CELLTYPE_STRING
The cell contains data of type string.
String TAG_STYLE_FONT_DECL
Element tag for style:font-decl.
String ATTRIBUTE_TABLE_FORMULA
Attribute tag for table:formula of element table:table-cell.
String ATTRIBUTE_TABLE_DATE_VALUE
Attribute tag for table:date-value of element table:table-cell.
String TAG_CONFIG_ITEM_MAP_INDEXED
Element tag for config:config-item-map-indexed.
String ATTRIBUTE_TABLE_CURRENCY
Attribute tag for table:currency of element table:table-cell.
String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED
Attribute tag for table:number-rows-repeated of element table:table-row.
String ATTRIBUTE_STYLE_FONT_PITCH
Attribute tag for style:font-pitch of element style:font-pitch.
String TAG_CONFIG_ITEM_SET
Element tag for config:config-item-set.
String ATTRIBUTE_TABLE_TIME_VALUE
Attribute tag for table:time-value of element table:table-cell.
String TAG_NAMED_EXPRESSIONS
Element tag for table:named-expression.
String CELLTYPE_PERCENT
The cell contains data of type percent.
String TAG_OFFICE_SETTINGS
Element tag for office:settings.
String TAG_OFFICE_FONT_DECLS
Element tag for office:font-decls.
String ATTRIBUTE_TABLE_NAME
Attribute tag for table:name of element table:table.
Interface defining constants for Sxc attributes.
String COLUMN_STYLE_FAMILY
Family name for column styles.
String TABLE_CELL_STYLE_FAMILY
Family name for table-cell styles.
String DEFAULT_STYLE
Name of the default style.
String ROW_STYLE_FAMILY
Family name for row styles.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
RttiCompleteObjectLocator col
Document and PluginFactory implementations for XML based formats.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...