LibreOffice Module xmerge (master) 1
xslt/DocumentMergerImpl.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.xslt;
20
21import org.w3c.dom.Document;
22
35
40public class DocumentMergerImpl implements DocumentMerger {
41
44
46 cc_ = cc;
47 this.orig = doc;
48 }
49
50 public void merge(org.openoffice.xmerge.Document modifiedDoc) throws MergeException {
51
53 GenericOfficeDocument wdoc2 = (GenericOfficeDocument) modifiedDoc;
54
55 Document doc1 = wdoc1.getContentDOM();
56 Document doc2 = wdoc2.getContentDOM();
57
58 Iterator i1 = new ParaNodeIterator(cc_, doc1.getDocumentElement());
59 Iterator i2 = new ParaNodeIterator(cc_, doc2.getDocumentElement());
60
61 DiffAlgorithm diffAlgo = new IteratorLCSAlgorithm();
62
63 // find out the paragraph level diffs
64 Difference[] diffTable = diffAlgo.computeDiffs(i1, i2);
65
67 Debug.log(Debug.INFO, "Diff Result: ");
68
69 for (int i = 0; i < diffTable.length; i++) {
70 Debug.log(Debug.INFO, diffTable[i].debug());
71 }
72 }
73
74 // merge the paragraphs
76 DocumentMerge docMerge = new DocumentMerge(cc_, charMerge);
77
78 docMerge.applyDifference(i1, i2, diffTable);
79 }
80}
This Exception is thrown by merge algorithms.
Xslt implementation of DocumentMerger for the PluginFactoryImpl.
void merge(org.openoffice.xmerge.Document modifiedDoc)
DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc)
This class is an implementation of OfficeDocument for the generic office format.
This is the Difference basic unit.
Definition: Difference.java:27
String debug()
Display debug information.
This is one of the implementations of DiffAlgorithm interface.
This is an implementation of the Iterator interface.
This is an implementation of the NodeMergeAlgorithm interface.
This is an implementation of the MergeAlgorithm interface.
void applyDifference(Iterator orgSeq, Iterator modSeq, Difference[] differences)
This method is to merge the difference to an Iterator.
This class is used for logging debug messages.
Definition: Debug.java:39
static final int INFO
Informational messages.
Definition: Debug.java:42
static boolean isFlagSet(int f)
Checks if flag is set.
Definition: Debug.java:176
static void log(int flag, String msg)
Log message based on the flag type.
Definition: Debug.java:205
A ConverterCapabilities object is used by DocumentMerger implementations.
A DocumentMerger can merge changes from a modified "Device" Document to the assigned original "Office...
A Document represents any Document to be converted and the resulting Document from any conversion.
Definition: Document.java:36
This is the difference algorithm interface.
Difference[] computeDiffs(Iterator orgSeq, Iterator modSeq)
Returns a Difference array.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
Definition: Iterator.java:27
This is an interface for a MergeAlgorithm to merge two Node objects.
int i
Provides implementations for the Iterator interface and related support classes.
Provides implementations for the MergeAlgorithm interface, the NodeMergeAlgorithm interface,...
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...
Definition: Convert.java:19