19package org.openoffice.xmerge.merger.merge;
21import org.w3c.dom.Node;
22import org.w3c.dom.Element;
23import org.w3c.dom.NodeList;
24import org.w3c.dom.NamedNodeMap;
53 public void merge(Node orgRow, Node modRow) {
64 boolean needMerge =
true;
65 Element orgCell, modCell;
70 while (orgSeqObject !=
null) {
74 if (modSeqObject ==
null) {
77 orgSeqObject = orgSeq.
next();
82 if (!orgSeq.
equivalent(orgSeqObject, modSeqObject)) {
84 orgCell = (Element)orgSeqObject;
85 modCell = (Element)modSeqObject;
89 String orgColRepeated = orgCell.getAttribute(
91 String modColRepeated = modCell.getAttribute(
97 if (orgColRepeated.length() > 0) {
98 orgColNum =
Integer.parseInt(orgColRepeated);
100 if (modColRepeated.length() > 0) {
101 modColNum =
Integer.parseInt(modColRepeated);
105 if (orgColNum == modColNum) {
106 orgSeqObject = orgSeq.
next();
107 modSeqObject = modSeq.
next();
111 }
else if (orgColNum > modColNum) {
114 orgColNum - modColNum);
116 if (orgSeq.
equivalent(orgSplitCell, modCell)) {
119 orgCell = orgSplitCell;
120 modSeqObject = modSeq.
next();
127 modColNum - orgColNum);
129 if (modSeq.
equivalent(orgCell, modSplitCell)) {
132 modCell = modSplitCell;
133 orgSeqObject = orgSeq.
next();
142 orgSeqObject = orgSeq.
next();
143 modSeqObject = modSeq.
next();
150 orgCell = (Element)orgSeq.
start();
153 for (; modSeqObject !=
null; modSeqObject = modSeq.
next()) {
155 Node parent = orgCell.getParentNode();
156 parent.appendChild(clonedNode);
167 Element splitCell = (Element)(orgCell.cloneNode(
true));
170 splitCell.setAttribute(
172 String.valueOf(splitNum));
173 }
else if (splitNum == 1) {
174 splitCell.removeAttribute(
178 orgCell.setAttribute(
181 }
else if (orgNum == 1) {
182 orgCell.removeAttribute(
186 Node parentNode = orgCell.getParentNode();
187 parentNode.insertBefore(splitCell, orgCell);
200 NamedNodeMap attrNodes = modCell.getAttributes();
202 if (attrNodes !=
null) {
209 Node firstParaNode = paraNodes.item(0);
212 if (firstParaNode !=
null) {
217 Node firstChild = orgCell.getFirstChild();
218 if (firstChild !=
null) {
219 orgCell.insertBefore(clonedNode, firstChild);
221 orgCell.appendChild(clonedNode);
228 int len = attrNodes.getLength();
230 for (
int i = 0;
i < len;
i++) {
231 Node attr = attrNodes.item(
i);
235 attr.getNodeName())) {
236 orgCell.setAttribute(attr.getNodeName(),
237 attr.getNodeValue());
This is an implementations of the Iterator interface.
This is an implementation of the NodeMergeAlgorithm interface.
Element splitColRepeatedCell(Element orgCell, int splitNum, int orgNum)
final ConverterCapabilities cc_
The capabilities of this converter.
void mergeCellSequences(Iterator orgSeq, Iterator modSeq)
void merge(Node orgRow, Node modRow)
This method is used to merge two given Node objects.
PositionBaseRowMerge(ConverterCapabilities cc)
Constructor.
void mergeCells(Element orgCell, Element modCell)
Utility methods to handle sheet XML tree.
static void emptyCell(ConverterCapabilities cc, Node node)
Empty the content of a cell value.
Class containing static utility methods for handling XML trees.
static Node deepClone(Node oldNode, Node newNode)
Perform a deep clone of certain Node which will base on the document Node of the old Node.
A ConverterCapabilities object is used by DocumentMerger implementations.
boolean canConvertAttribute(String tag, String attribute)
Test to see if the device document format supports the tag attribute in question.
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String TAG_TABLE_CELL
Element tag for table:table-cell.
String ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED
Attribute tag for table:number-columns-repeated of element table:table-cell.
String TAG_PARAGRAPH
Element tag for text:p.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
boolean equivalent(Object obj1, Object obj2)
A method to allow the difference algorithm to test whether the obj1 and obj2 in the Iterator are cons...
Object start()
Move to the beginning of the sequence.
Object next()
Move to next element in the sequence.
This is an interface for a MergeAlgorithm to merge two Node objects.
Document and PluginFactory implementations for XML based formats.
Provides implementations for the Iterator interface and related support classes.
The DiffAlgorithm and MergeAlgorithm are used to provide the merge capabilities of this project.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...