19package org.openoffice.xmerge.merger.diff;
21import org.w3c.dom.Node;
22import org.w3c.dom.Element;
24import java.util.ArrayList;
79 ArrayList<Difference> diffVector =
new ArrayList<Difference>();
87 Element orgRow, modRow;
88 boolean different =
false;
89 boolean orgSplited =
false;
90 boolean modSplited =
false;
92 while (orgSeqObject !=
null) {
96 if (modSeqObject ==
null) {
100 diffVector.add(diff);
101 orgSeqObject = orgSeq.
next();
104 if (!orgSeq.
equivalent(orgSeqObject, modSeqObject)) {
106 orgRow = (Element)orgSeqObject;
107 modRow = (Element)modSeqObject;
111 String orgRowRepeated = orgRow.getAttribute(
113 String modRowRepeated = modRow.getAttribute(
120 if (orgRowRepeated.length() > 0) {
121 orgRowNum =
Integer.parseInt(orgRowRepeated);
123 if (modRowRepeated.length() > 0) {
124 modRowNum =
Integer.parseInt(modRowRepeated);
128 if (orgRowNum == modRowNum) {
129 orgSeqObject = orgSeq.
next();
130 modSeqObject = modSeq.
next();
134 }
else if (orgRowNum > modRowNum) {
137 orgRowNum - modRowNum);
143 modSeqObject = modSeq.
next();
150 modRowNum - orgRowNum);
157 orgSeqObject = orgSeq.
next();
163 diffVector.add(diff);
168 orgSeqObject = orgSeq.
next();
169 modSeqObject = modSeq.
next();
178 for (; modSeqObject !=
null; modSeqObject = modSeq.
next(), j++) {
180 diffVector.add(diff);
194 diffVector.toArray(diffArray);
205 Element splitRow = (Element)(orgRow.cloneNode(
true));
208 splitRow.setAttribute(
210 String.valueOf(splitNum));
211 }
else if (splitNum == 1) {
212 splitRow.removeAttribute(
219 }
else if (orgNum == 1) {
220 orgRow.removeAttribute(
224 Node parentNode = orgRow.getParentNode();
225 parentNode.insertBefore(splitRow, orgRow);
This is the Difference basic unit.
static final int CHANGE
Change operation.
static final int DELETE
Delete operation.
static final int ADD
Add operation.
A very simple and direct difference algorithm for row Node objects in a spreadsheet.
Difference[] computeDiffs(Iterator orgSeq, Iterator modSeq)
Compute the differences of the given two sequences.
Element splitRepeatedRow(Element orgRow, int splitNum, int orgNum)
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED
Attribute tag for table:number-rows-repeated of element table:table-row.
This is the difference algorithm interface.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
void refresh()
A method to force the Iterator to traverse the tree again to refresh the content.
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.
Document and PluginFactory implementations for XML based formats.
The DiffAlgorithm and MergeAlgorithm are used to provide the merge capabilities of this project.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...