public class RevisionHandler extends Object implements Closeable
The `RevisionHandler` class allows you to work with revisions in documents. It provides methods to retrieve the list of revisions, apply changes to revisions, and save the modified document.
Example usage:
try (RevisionHandler revisionHandler = new RevisionHandler(sourceFile)) {
List<RevisionInfo> revisionList = revisionHandler.getRevisions();
for (RevisionInfo revisionInfo : revisionList) {
if (revisionInfo.getType() == RevisionType.DELETION)
// Set an action to be applied to the revision
revisionInfo.setAction(RevisionAction.Accept);
}
// Create an instance of ApplyRevisionOptions
ApplyRevisionOptions revisionChanges = new ApplyRevisionOptions();
revisionChanges.setChanges(revisionList);
// Apply the revisions using the options
revisionHandler.applyRevisionChanges(resultFile, revisionChanges);
}
ApplyRevisionOptions,
RevisionInfo,
RevisionAction| Modifier and Type | Field and Description |
|---|---|
static String |
SOURCE_PATH_IS_NULL |
| Constructor and Description |
|---|
RevisionHandler(com.aspose.words.Document document)
Initializes a new instance of the RevisionHandler class with a document.
|
RevisionHandler(InputStream file,
FileType fileType)
Initializes a new instance of the RevisionHandler class with a file stream containing revisions.
|
RevisionHandler(Path filePath)
Initializes a new instance of the RevisionHandler class with the path to the file containing revisions.
|
RevisionHandler(String filePath)
Initializes a new instance of the RevisionHandler class with the path to the file containing revisions.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyRevisionChanges(ApplyRevisionOptions changes)
Processes changes in revisions and applies them to the original file.
|
void |
applyRevisionChanges(OutputStream outputStream,
ApplyRevisionOptions changes)
Processes changes in revisions and writes the result to the document stream.
|
void |
applyRevisionChanges(Path filePath,
ApplyRevisionOptions changes)
Processes changes in revisions and writes the result to the specified file.
|
void |
applyRevisionChanges(String filePath,
ApplyRevisionOptions changes)
Processes changes in revisions and writes the result to the specified file.
|
void |
close() |
List<RevisionInfo> |
getRevisions()
Gets the list of all revisions.
|
public static final String SOURCE_PATH_IS_NULL
public RevisionHandler(com.aspose.words.Document document)
document - The document.public RevisionHandler(InputStream file, FileType fileType)
file - The source document stream.fileType - The type of the file.public RevisionHandler(Path filePath)
filePath - The path to the file.public RevisionHandler(String filePath)
filePath - The path to the file.public void applyRevisionChanges(ApplyRevisionOptions changes)
changes - The list of changed revisions.public void applyRevisionChanges(OutputStream outputStream, ApplyRevisionOptions changes)
outputStream - The result document stream.changes - The list of changed revisions.public void applyRevisionChanges(Path filePath, ApplyRevisionOptions changes)
filePath - The result file path.changes - The list of changed revisions.public void applyRevisionChanges(String filePath, ApplyRevisionOptions changes)
filePath - The result file path.changes - The list of changed revisions.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic List<RevisionInfo> getRevisions()
Due to the fact that revisions were originally sorted in a group, revisions must be taken from a List.
In the List, a single revision can be split into multiple revisions with the same general text.
Since the List may contain revisions with the same general text, this must be controlled when creating a list of revisions for the user.
This is controlled here using List<RevisionGroup> groups.
Copyright © 2024. All rights reserved.