different = true;
if (modSeqObject == null) {
// no more modsequence, all the remaining org sequence objs
// should consider as a delete.
Difference diff = new Difference(Difference.DELETE, i, j);
diffVector.add(diff);
orgSeqObject = orgSeq.next();
} else {
if (!orgSeq.equivalent(orgSeqObject, modSeqObject)) {
orgRow = (Element)orgSeqObject;
modRow = (Element)modSeqObject;
// check whether the original Row with multiple row
// if so, need to split one out for merge
String orgRowRepeated = orgRow.getAttribute(
OfficeConstants.ATTRIBUTE_TABLE_NUM_ROWS_REPEATED);
String modRowRepeated = modRow.getAttribute(
OfficeConstants.ATTRIBUTE_TABLE_NUM_ROWS_REPEATED);
int orgRowNum = 1;
int modRowNum = 1;
if (orgRowRepeated.length() > 0) {
orgRowNum =
Integer.valueOf(orgRowRepeated).intValue();
}
if (modRowRepeated.length() > 0) {
modRowNum =
Integer.valueOf(modRowRepeated).intValue();
}
// try to find out the common number of repeated Rows
if (orgRowNum == modRowNum) {
orgSeqObject = orgSeq.next();
modSeqObject = modSeq.next();
// cut the original row into two halves, first half
// have the repeated attribute = modify row attr
} else if (orgRowNum > modRowNum) {
Element orgSplitRow = splitRepeatedRow(
orgRow, modRowNum,
orgRowNum - modRowNum);
// it may equal after the split!
if (orgSeq.equivalent(orgSplitRow, modRow)) {
different = false;
}
orgSplited = true;
modSeqObject = modSeq.next();
// cut the modified Row into two halves, first half
// have the repeated attribute = original Row attr
} else {
Element modSplitRow = splitRepeatedRow(
modRow, orgRowNum,
modRowNum - orgRowNum);
// check whether rows are equal after the split
if (modSeq.equivalent(orgRow, modSplitRow)) {
different = false;
}
modSplited = true;
orgSeqObject = orgSeq.next();
}
if (different) {
Difference diff = new Difference(Difference.CHANGE,
i, j);
diffVector.add(diff);
}
} else {
// Rows are equivalent, move on to next one.
orgSeqObject = orgSeq.next();
modSeqObject = modSeq.next();
} // end if-else
j++;
} // end if-else
i++;
} // end while loop
// any extra objects in modify sequence should consider as an add
// to the original sequence
for (; modSeqObject != null; modSeqObject = modSeq.next(), j++) {
Difference diff = new Difference(Difference.ADD, i, j);
diffVector.add(diff);
}
// need to refresh the iterator if we split the rows
if (orgSplited) {