LibreOffice Module xmerge (master) 1
SxcDocumentSerializer.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 */
18
19package org.openoffice.xmerge.converter.xml.sxc;
20
21import java.io.IOException;
22import java.util.ArrayList;
23import java.util.Iterator;
24
32import org.w3c.dom.Element;
33import org.w3c.dom.NamedNodeMap;
34import org.w3c.dom.Node;
35import org.w3c.dom.NodeList;
36
48public abstract class SxcDocumentSerializer implements OfficeConstants,
50
52 private Format fmt = null;
53
55 private int rowID = 1;
56
58 private int colID = 1;
59
61 private int rowsRepeated = 1;
62
64 private int colsRepeated = 1;
65
67 private StyleCatalog styleCat = null;
68
73 private ArrayList<ColumnRowInfo> ColumnRowList;
74
78 protected SpreadsheetEncoder encoder = null;
79
86 fmt = new Format();
87 }
88
103 public abstract ConvertData serialize() throws ConvertException,
104 IOException;
105
113 public void traverseSettings(Node node) throws IOException {
114 if (node.hasChildNodes()) {
115
116 NodeList nodeList = node.getChildNodes();
117 int len = nodeList.getLength();
118 for (int i = 0; i < len; i++) {
119 Node child = nodeList.item(i);
120
121 if (child.getNodeType() == Node.ELEMENT_NODE) {
122 String nodeName = child.getNodeName();
123
124 if (nodeName.equals(TAG_CONFIG_ITEM_SET)) {
125
126 traverseSettings(child);
127
128 } else if (nodeName.equals(TAG_CONFIG_ITEM_MAP_INDEXED)) {
129
130 traverseSettings(child);
131
132 } else if (nodeName.equals(TAG_CONFIG_ITEM_MAP_ENTRY)) {
133
134 BookSettings bs = new BookSettings(child);
136
137 } else {
138
139 Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(child) + " />");
140 }
141 }
142 }
143 }
144 }
145
153 protected void loadStyles(SxcDocument sxcDoc) {
154
155 styleCat = new StyleCatalog(25);
156 NodeList nl = null;
157 String families[] = new String[] { SxcConstants.COLUMN_STYLE_FAMILY,
160 Class<?> classes[] = new Class[] { ColumnStyle.class,
161 RowStyle.class,
162 CellStyle.class};
163 /*
164 * Process the content XML for any other style info.
165 */
166 org.w3c.dom.Document contentDom = sxcDoc.getContentDOM();
167 nl = contentDom.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
168 if (nl.getLength() != 0) {
169 styleCat.add(nl.item(0), families, classes, null, false);
170 }
171
172 org.w3c.dom.Document stylesDom = sxcDoc.getStyleDOM();
173 nl = stylesDom.getElementsByTagName(TAG_OFFICE_STYLES);
174 if (nl.getLength() != 0) {
175 styleCat.add(nl.item(0), families, classes, null, false);
176 }
177 }
178
186 protected void traverseBody(Node node) throws IOException {
187
188 Debug.log(Debug.TRACE, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
189 Debug.log(Debug.TRACE, "<DEBUGLOG>");
190
191 if (node.hasChildNodes()) {
192
193 NodeList nodeList = node.getChildNodes();
194 int len = nodeList.getLength();
195
196 for (int i = 0; i < len; i++) {
197 Node searchNode = nodeList.item(i);
198 if (searchNode.getNodeType() == Node.ELEMENT_NODE) {
199
200 String nodeName = searchNode.getNodeName();
201
202 if (nodeName.equals(TAG_NAMED_EXPRESSIONS)) {
203
204 traverseNamedExpressions(searchNode);
205
206 } else {
207
208 Debug.log(Debug.TRACE, "Skipping " + XmlUtil.getNodeInfo(searchNode) + " />");
209 }
210 }
211 }
212
213 for (int i = 0; i < len; i++) {
214 Node child = nodeList.item(i);
215
216 if (child.getNodeType() == Node.ELEMENT_NODE) {
217 String nodeName = child.getNodeName();
218
219 if (nodeName.equals(TAG_TABLE)) {
220
221 traverseTable(child);
222
223 } else {
224
225 Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(child) + " />");
226 }
227 }
228 }
229 }
230
231 Debug.log(Debug.TRACE, "</DEBUGLOG>");
232 }
233
241 protected void traverseNamedExpressions(Node node) throws IOException {
242
243 Debug.log(Debug.TRACE, "<NAMED:EXPRESSIONS>");
244
245 if (node.hasChildNodes()) {
246
247 NodeList nodeList = node.getChildNodes();
248 int len = nodeList.getLength();
249
250 for (int i = 0; i < len; i++) {
251 Node child = nodeList.item(i);
252
253 if (child.getNodeType() == Node.ELEMENT_NODE) {
254 NameDefinition nd = new NameDefinition(child);
256 }
257 }
258 }
259
260 Debug.log(Debug.TRACE, "</NAMED:EXPRESSIONS>");
261 }
262
270 protected void traverseTable(Node node) throws IOException {
271
272 Debug.log(Debug.TRACE, "<TABLE>");
273
274 ColumnRowList = new ArrayList<ColumnRowInfo>();
275
276 // Get table attributes
277 // ToDo - extract style from attribute
278
279 NamedNodeMap att = node.getAttributes();
280
282 att.getNamedItem(ATTRIBUTE_TABLE_NAME).getNodeValue();
283
284 rowID = 1;
285
287
288 if (node.hasChildNodes()) {
289
290 NodeList nodeList = node.getChildNodes();
291 int len = nodeList.getLength();
292
293 for (int i = 0; i < len; i++) {
294 Node child = nodeList.item(i);
295
296 if (child.getNodeType() == Node.ELEMENT_NODE) {
297 String nodeName = child.getNodeName();
298
299 if (nodeName.equals(TAG_TABLE_ROW)) {
300 // TODO - handle all the possible rows
301 // spelled out in the entities
302
303 traverseTableRow(child);
304
305 } else if (nodeName.equals(TAG_TABLE_COLUMN)) {
306
307 traverseTableColumn(child);
308
309 } else if (nodeName.equals(TAG_TABLE_SCENARIO)) {
310
311 // TODO
312
313 } else {
314
315 Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(child) + " />");
316 }
317 }
318 }
319 }
320
321 // Add column width info to the current sheet
323
324 Debug.log(Debug.TRACE, "</TABLE>");
325 }
326
334 protected void traverseTableRow(Node node) throws IOException {
335
336 // Get the attributes of the row
337 NamedNodeMap cellAtt = node.getAttributes();
338
339 if (cellAtt != null) {
340
341 Node rowStyle =
342 cellAtt.getNamedItem(ATTRIBUTE_TABLE_STYLE_NAME);
343
344 Node tableNumRowRepeatingNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_NUM_ROWS_REPEATED);
345 int repeatedRows = 1;
346
347 if(tableNumRowRepeatingNode!=null) {
348 String repeatStr = tableNumRowRepeatingNode.getNodeValue();
349 Debug.log(Debug.TRACE, "traverseTableRow() repeated-rows : " + repeatStr);
350 repeatedRows = Integer.parseInt(repeatStr);
351 }
352
353 String styleName = "";
354
355 if ( rowStyle != null) {
356 styleName = rowStyle.getNodeValue();
357 }
358 if(styleName.equalsIgnoreCase("Default") || styleName.length()==0) {
359
360 Debug.log(Debug.TRACE, "No defined Row Style Attribute was found");
361
362 } else {
363
364 RowStyle rStyle = ( RowStyle)styleCat.lookup(styleName,
366 RowStyle.class);
367
368 int rowHeight = rStyle != null ? rStyle.getRowHeight() : 0;
369
370 Debug.log(Debug.TRACE, "traverseTableRow() Row Height : " + rowHeight);
371 ColumnRowInfo ri = new ColumnRowInfo( rowHeight,
372 repeatedRows,
374 rowHeight!=0);
375 ColumnRowList.add(ri);
376 }
377
378 // Get the attribute representing the number of rows repeated
379 Node rowsRepeatedNode =
380 cellAtt.getNamedItem(ATTRIBUTE_TABLE_NUM_ROWS_REPEATED);
381
382 // There is a number of rows repeated attribute:
383 if (rowsRepeatedNode != null) {
384 // Get the number of times the row is repeated
385 String rowsRepeatedString = rowsRepeatedNode.getNodeValue();
386 rowsRepeated = Integer.parseInt(rowsRepeatedString);
387 } else {
388 // The row is not repeated
389 rowsRepeated = 1;
390 }
391 }
392
393 Debug.log(Debug.TRACE, "<TR>");
394
395 if (node.hasChildNodes()) {
396
397 NodeList nodeList = node.getChildNodes();
398 int len = nodeList.getLength();
399
400 for (int i = 0; i < len; i++) {
401 Node child = nodeList.item(i);
402
403 if (child.getNodeType() == Node.ELEMENT_NODE) {
404 String nodeName = child.getNodeName();
405
406 if (nodeName.equals(TAG_TABLE_CELL)) {
407
408 traverseCell(child);
409
410 } else {
411
412 Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(child) + " />");
413 }
414 }
415 }
416 }
417
418 // Increase the row counter by the number of rows which are repeated
420
421 // Re-initialize number of rows repeated before processing the next
422 // row data.
423 rowsRepeated = 1;
424
425 // When starting a new row, set the column counter back to the
426 // first column.
427 colID = 1;
428
429 // Re-initialize number of columns repeated before processing
430 // the next row data.
431 colsRepeated = 1;
432
433 Debug.log(Debug.TRACE, "</TR>");
434 }
435
445 protected void traverseTableColumn(Node node) throws IOException {
446
447 Debug.log(Debug.TRACE, "traverseColumn() : ");
448 NamedNodeMap cellAtt = node.getAttributes();
449 Node tableStyleNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_STYLE_NAME);
450 Node tableNumColRepeatingNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED);
451 Node tableDefaultCellStyle = cellAtt.getNamedItem(ATTRIBUTE_DEFAULT_CELL_STYLE);
452
453 int repeatedColumns = 1;
454 int columnWidth = 0;
456
457 if(tableNumColRepeatingNode!=null) {
458 Debug.log(Debug.TRACE, "traverseColumn() repeated-cols : " + tableNumColRepeatingNode.getNodeValue());
459 repeatedColumns = Integer.parseInt(tableNumColRepeatingNode.getNodeValue());
460 col.setRepeated(repeatedColumns);
461 }
462
463 String cellStyleName = "";
464
465 if(tableDefaultCellStyle!=null) {
466 cellStyleName = tableDefaultCellStyle.getNodeValue();
467
468 Debug.log(Debug.TRACE, "traverseColumn() default-cell-style : " + cellStyleName);
469 }
470
471 CellStyle cellStyle = null;
472
473 if(cellStyleName.equalsIgnoreCase("Default") || cellStyleName.length()==0) {
474
475 Debug.log(Debug.TRACE, "No default cell Style Attribute was found");
476
477 } else {
478
479 cellStyle = (CellStyle)styleCat.lookup(cellStyleName,
481 CellStyle.class);
482 }
483
484 if (cellStyle != null) {
485 Format defaultFmt = new Format(cellStyle.getFormat());
486 col.setFormat(defaultFmt);
487 }
488
489 String styleName = "";
490
491 if(tableStyleNode!=null) {
492 styleName = tableStyleNode.getNodeValue();
493 }
494
495 if(styleName.equalsIgnoreCase("Default") || styleName.length()==0) {
496
497 Debug.log(Debug.TRACE, "No defined Style Attribute was found");
498
499 } else {
500
501 ColumnStyle cStyle = (ColumnStyle)styleCat.lookup(styleName,
503 ColumnStyle.class);
504
505 columnWidth = cStyle != null ? cStyle.getColWidth() : 0;
506 col.setSize(columnWidth);
507 Debug.log(Debug.TRACE, "traverseColumn() Column Width : " + columnWidth);
508
509 }
510 ColumnRowList.add(col);
511 }
512
520 protected void traverseCell(Node node) throws IOException {
521
522 NamedNodeMap cellAtt = node.getAttributes();
523
525
526 // Get the type of data in the cell
527 Node tableValueTypeNode =
528 cellAtt.getNamedItem(ATTRIBUTE_TABLE_VALUE_TYPE);
529
530 // Get the number of columns this cell is repeated
531 Node colsRepeatedNode =
532 cellAtt.getNamedItem(ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED);
533
534 // Get the style type
535 Node tableStyleNode =
536 cellAtt.getNamedItem(ATTRIBUTE_TABLE_STYLE_NAME);
537
538 String styleName = "";
539
540 if(tableStyleNode!=null) {
541 styleName = tableStyleNode.getNodeValue();
542 }
543
544 CellStyle cStyle = null;
545
546 if(styleName.equalsIgnoreCase("Default")) {
547
548 Debug.log(Debug.TRACE, "No defined Style Attribute was found");
549
550 } else if(styleName.length()!=0) {
551
552 cStyle = (CellStyle)styleCat.lookup(styleName,
554 CellStyle.class);
555 }
556
557 if (cStyle != null) {
558 Format definedFormat = cStyle.getFormat();
559 fmt = new Format(definedFormat);
560 }
561
562 // There is a number of cols repeated attribute
563 if (colsRepeatedNode != null) {
564 // Get the number of times the cell is repeated
565 String colsRepeatedString = colsRepeatedNode.getNodeValue();
566 colsRepeated = Integer.parseInt(colsRepeatedString);
567 } else {
568 // The cell is not repeated
569 colsRepeated = 1;
570 }
571
572
573 // if there is no style we need to check to see if there is a default
574 // cell style defined in the table-column's
575
576 if (fmt.isDefault() && styleName.length()==0) {
577 int index = 1;
578 for(Iterator<ColumnRowInfo> e = ColumnRowList.iterator();e.hasNext();) {
579 ColumnRowInfo cri = e.next();
580 if(cri.isColumn()) {
581 if(colID>=index && colID<(index+cri.getRepeated())) {
582 fmt = new Format(cri.getFormat());
583 }
584 index += cri.getRepeated();
585 }
586 }
587 }
588
589 if (tableValueTypeNode != null) {
590
591 String cellType =
592 tableValueTypeNode.getNodeValue();
593
594 if (cellType.equalsIgnoreCase(CELLTYPE_STRING)) {
595
596 // has text:p tag
598 Node tableStringValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_STRING_VALUE);
599 Debug.log(Debug.TRACE,"Cell Type String : " + tableStringValueNode);
600 if(tableStringValueNode != null) {
601 fmt.setValue(tableStringValueNode.getNodeValue());
602 }
603
604 } else if (cellType.equalsIgnoreCase(CELLTYPE_FLOAT)) {
605
606 // has table:value attribute
607 // has text:p tag
608
609 // Determine the number of decimal places StarCalc
610 // is displaying for this floating point output.
613 Node tableValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_VALUE);
614 fmt.setValue(tableValueNode.getNodeValue());
615
616
617 } else if (cellType.equalsIgnoreCase(CELLTYPE_TIME)) {
618
619 // has table:time-value attribute
620 // has text:p tag - which is the value we convert
621
623 Node tableTimeNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_TIME_VALUE);
624 fmt.setValue(tableTimeNode.getNodeValue());
625
626 } else if (cellType.equalsIgnoreCase(CELLTYPE_DATE)) {
627
628 // has table:date-value attribute
629 // has text:p tag - which is the value we convert
630
632 Node tableDateNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_DATE_VALUE);
633 fmt.setValue(tableDateNode.getNodeValue());
634
635 } else if (cellType.equalsIgnoreCase(CELLTYPE_CURRENCY)) {
636
637 // has table:currency
638 // has table:value attribute
639 // has text:p tag
640
643 Node tableValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_VALUE);
644 fmt.setValue(tableValueNode.getNodeValue());
645
646 } else if (cellType.equalsIgnoreCase(CELLTYPE_BOOLEAN)) {
647
648 // has table:boolean-value attribute
649 // has text:p tag - which is the value we convert
650
652 Node tableBooleanNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_BOOLEAN_VALUE);
653 fmt.setValue(tableBooleanNode.getNodeValue());
654
655 } else if (cellType.equalsIgnoreCase(CELLTYPE_PERCENT)) {
656
657 // has table:value attribute
658 // has text:p tag
659
662 Node tableValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_VALUE);
663 fmt.setValue(tableValueNode.getNodeValue());
664
665 } else {
666
667 Debug.log(Debug.TRACE,"No defined value type" + cellType);
668 // Should never get here
669
670 }
671 }
672
673 Node tableFormulaNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_FORMULA);
674
675 if(tableFormulaNode != null)
676 {
677 if(tableValueTypeNode == null) { // If there is no value-type Node we must assume string-value
679 Node tableStringValueNode = cellAtt.getNamedItem(ATTRIBUTE_TABLE_STRING_VALUE);
680 fmt.setValue(tableStringValueNode.getNodeValue());
681 }
682 String cellFormula = tableFormulaNode.getNodeValue();
683 addCell(cellFormula);
684 } else {
685
686 // Text node, Date node, or Time node
687
689 "TextNode, DateNode, TimeNode or BooleanNode\n");
690 // This handles the case where we have style information but no content
691 if (node.hasChildNodes()) {
692 NodeList childList = node.getChildNodes();
693 int len = childList.getLength();
694
695 for (int i = 0; i < len; i++) {
696 Node child = childList.item(i);
697 if (child.getNodeType() == Node.ELEMENT_NODE) {
698 String childName = child.getNodeName();
699 if (childName.equals(TAG_PARAGRAPH)) {
700 traverseParagraph(child);
701 }
702 }
703 }
704 } else if(!fmt.isDefault()) {
705 addCell("");
706 }
707 }
708
709 // Increase the column counter by the number of times the
710 // last cell was repeated.
712
713 // Re-initialize the number of columns repeated before processing
714 // the next cell data.
715 colsRepeated = 1;
716
717 }
718
726 protected void traverseParagraph(Node node) throws IOException {
727
728 NamedNodeMap cellAtt = node.getAttributes();
729
730 int debug_i=0;
731 Node debug_attrib = null;
732 if (cellAtt == null || cellAtt.item(0) == null) {
733 Debug.log(Debug.INFO, "No Paragraph Attributes\n");
734 } else {
735 while ((debug_attrib = cellAtt.item(debug_i++)) != null) {
736 Debug.log(Debug.INFO, "Paragraph Attribute " + debug_i +
737 ": " + debug_attrib.getNodeName() + " : " +
738 debug_attrib.getNodeValue() + "\n");
739 }
740 }
741
742 if (node.hasChildNodes()) {
743
744 NodeList nodeList = node.getChildNodes();
745
746 int len = nodeList.getLength();
747
748 StringBuffer buffer = new StringBuffer();
749
750 for (int i = 0; i < len; i++) {
751
752 Node child = nodeList.item(i);
753
754 // TODO: need to handle space/tabs/newline nodes later
755 short nodeType = child.getNodeType();
756
757 switch (nodeType) {
758
759 case Node.TEXT_NODE:
760 buffer.append(child.getNodeValue());
761 break;
762
763 case Node.ENTITY_REFERENCE_NODE:
764
765 NodeList nodeList2 = child.getChildNodes();
766 int len2 = nodeList2.getLength();
767
768 for (int j = 0; j < len2; j++) {
769 Node child2 = nodeList2.item(j);
770
771 if (child2.getNodeType() == Node.TEXT_NODE) {
772 buffer.append(child2.getNodeValue());
773 }
774 }
775
776 break;
777 }
778 }
779
780 String s = buffer.toString();
781 addCell(s);
782
783 }
784 }
785
798 protected void addCell(String cellValue) throws IOException {
799
800 int col = colID;
801 int row = rowID;
802
803 for (int i = 0; i < rowsRepeated; i++) {
804
805 // Log the columns when there are rowsRepeated.
806 if (i > 0) {
807 Debug.log(Debug.TRACE, "</TR>");
808 Debug.log(Debug.TRACE, "<TR>");
809 }
810
811 col = colID;
812
813 for (int j = 0; j < colsRepeated; j++) {
814
815 Debug.log(Debug.TRACE, "<TD>");
816
817 // Add the cell data to the encoded spreadsheet document
818 encoder.addCell(row, col, fmt, cellValue);
819
820 Debug.log(Debug.TRACE, cellValue);
821 Debug.log(Debug.TRACE, "</TD>");
822
823 col++;
824 }
825
826 row++;
827
828 }
829
830 }
831
844 protected int getDecimalPlaces(Node node) {
845
846 int decimals = 0;
847 Element element = null;
848
849 // cast org.w3c.dom.Node to org.w3c.dom.Element
850 if (node instanceof Element) {
851 element = (Element) node;
852 } else {
853 return decimals;
854 }
855
856 // Traverse to the text:p element, there should only be one.
857 NodeList list = element.getElementsByTagName(TAG_PARAGRAPH);
858
859 if (list.getLength() != 1) {
860 return decimals;
861 }
862
863 Node paragraph = list.item(0);
864 if (paragraph.hasChildNodes()) {
865
866 NodeList nodeList = paragraph.getChildNodes();
867 int len = nodeList.getLength();
868 for (int j = 0; j < len; j++) {
869
870 Node child = nodeList.item(j);
871 if (child.getNodeType() == Node.TEXT_NODE) {
872
873 String s = child.getNodeValue();
874 int k = s.lastIndexOf('.');
875 if (k > 0) {
876 s = s.substring(k+1);
877 decimals = s.length();
878 }
879 }
880 }
881 }
882
883 return decimals;
884 }
885}
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 lookup(String name, String family, String parent, Class<?> styleClass)
Return the first Style matching the specified names.
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,...
This is a class representing the different attributes for a worksheet contained in settings....
Represents a text Style in an OpenOffice document.
Definition: CellStyle.java:35
Format getFormat()
Returns the Format object for this particular style.
Definition: CellStyle.java:109
This is a class to define a table-column structure.
int getRepeated()
Get the repeat count for this item.
boolean isColumn()
Does this ColumnRowInfo represent a column?
Represents a text Style in an OpenOffice document.
int getColWidth()
Returns the width of this column.
This class specifies the format for a given spreadsheet cell.
Definition: Format.java:26
void setValue(String newValue)
In the case of formula the contents are set as the formula string and the value of the formula is a f...
Definition: Format.java:210
boolean isDefault()
Tests if the current Format object has default attribute values.
Definition: Format.java:375
void setCategory(String newCategory)
Set the formatting category of this object, ie number, date, currency.
Definition: Format.java:180
void clearFormatting()
Reset this Format description.
Definition: Format.java:125
void setDecimalPlaces(int precision)
Set the precision of the number to be displayed.
Definition: Format.java:237
This is a class to define a Name Definition structure.
Represents a text Style in an OpenOffice document.
Definition: RowStyle.java:34
int getRowHeight()
Returns the height of this row.
Definition: RowStyle.java:107
This class is an abstract class for encoding an SXC into an alternative spreadsheet format.
abstract void setColumnRows(ArrayList< ColumnRowInfo > columnRows)
Set the width of the columns in the WorkBook.
abstract void addCell(int row, int column, Format fmt, String cellContents)
Add a cell to the current WorkSheet.
abstract void setNameDefinition(NameDefinition nd)
Set the name definition of this spreadsheet.
abstract void createWorksheet(String sheetName)
Create a new WorkSheet within the WorkBook.
abstract void addSettings(BookSettings s)
Adds settings to the WorkBook.
General spreadsheet implementation of DocumentSerializer for the SxcPluginFactory.
void traverseTableColumn(Node node)
This method traverses the table:table-column Node.
void addCell(String cellValue)
This method will take the input cell value and add it to the spreadsheet Document we are currently en...
void traverseSettings(Node node)
This method traverses office:settings Element.
void traverseBody(Node node)
This method traverses office:body Element.
void traverseNamedExpressions(Node node)
This method traverses the table:table element Node.
SpreadsheetEncoder encoder
A SpreadsheetEncoder object for encoding to appropriate format.
void loadStyles(SxcDocument sxcDoc)
Handles the loading of defined styles from the style.xml file as well as automatic styles from the co...
void traverseCell(Node node)
This method traverses a table:table-cell element Node.
int colsRepeated
The number of times the current column is repeated.
void traverseTable(Node node)
This method traverses the table:table element Node.
int rowsRepeated
The number of times the current row is repeated.
void traverseTableRow(Node node)
This method traverses the table:table-row element Node.
int getDecimalPlaces(Node node)
This method takes a table:table-cell Node and traverses down to the text:p tag.
abstract ConvertData serialize()
Method to convert a DOM Document into "Device" Document objects.
void traverseParagraph(Node node)
This method traverses the text:p element Node.
StyleCatalog styleCat
The number of times the current column is repeated.
ArrayList< ColumnRowInfo > ColumnRowList
An array of column widths of the current worksheet.
This class is an implementation of OfficeDocument for the SXC format.
This class is used for logging debug messages.
Definition: Debug.java:39
static final int INFO
Informational messages.
Definition: Debug.java:42
static final int TRACE
Trace messages.
Definition: Debug.java:46
static void log(int flag, String msg)
Log message based on the flag type.
Definition: Debug.java:205
Class containing static utility methods for handling XML trees.
Definition: XmlUtil.java:30
static String getNodeInfo(Node node)
Returns the name and type of an XML DOM Node.
Definition: XmlUtil.java:120
A DocumentSerializer represents a converter that converts a "Office" Document to a "Device" Document ...
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String ATTRIBUTE_DEFAULT_CELL_STYLE
Attribute tag for table:default-cell-style-name of element table:table-column.
String TAG_TABLE_CELL
Element tag for table:table-cell.
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_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 CELLTYPE_CURRENCY
The cell contains data of type currency.
String TAG_CONFIG_ITEM_MAP_ENTRY
Element tag for config:config-item-map-entry.
String CELLTYPE_BOOLEAN
The cell contains data of type boolean.
String TAG_TABLE_SCENARIO
Element tag for table:scenario.
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_OFFICE_STYLES
Element tag for office:styles.
String ATTRIBUTE_TABLE_STRING_VALUE
Attribute tag for table:string-value of element table:table-cell.
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 CELLTYPE_FLOAT
The cell contains data of type float.
String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED
Attribute tag for table:number-rows-repeated of element table:table-row.
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 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 ROW_STYLE_FAMILY
Family name for row styles.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
Definition: Iterator.java:27
RttiCompleteObjectLocator col
@ paragraph
int i
index
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...
Definition: Convert.java:19
const char * tableName