Skip to content

Commit 431b241

Browse files
EvgenyB1001ars18wrw
authored andcommitted
Update PdfReaderController after extracting helper classes from CompareTool
DEVSIX-4267
1 parent 23fd851 commit 431b241

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main/java/com/itextpdf/rups/controller/PdfReaderController.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ This file is part of the iText (R) project.
4444

4545
import com.itextpdf.kernel.pdf.*;
4646
import com.itextpdf.kernel.utils.CompareTool;
47+
import com.itextpdf.kernel.utils.objectpathitems.ArrayPathItem;
48+
import com.itextpdf.kernel.utils.objectpathitems.DictPathItem;
49+
import com.itextpdf.kernel.utils.objectpathitems.IndirectPathItem;
50+
import com.itextpdf.kernel.utils.objectpathitems.LocalPathItem;
51+
import com.itextpdf.kernel.utils.objectpathitems.ObjectPath;
4752
import com.itextpdf.rups.event.*;
4853
import com.itextpdf.rups.io.listeners.PdfTreeNavigationListener;
4954
import com.itextpdf.rups.model.ObjectLoader;
@@ -382,25 +387,25 @@ protected void highlightChanges(CompareTool.CompareResult compareResult) {
382387
if (compareResult == null) {
383388
return;
384389
}
385-
for (CompareTool.ObjectPath path : compareResult.getDifferences().keySet()) {
390+
for (ObjectPath path : compareResult.getDifferences().keySet()) {
386391
PdfObjectTreeNode currentNode;
387-
Stack<CompareTool.ObjectPath.IndirectPathItem> indirectPath = (Stack<CompareTool.ObjectPath.IndirectPathItem>) path.getIndirectPath().clone();
392+
Stack<IndirectPathItem> indirectPath = (Stack<IndirectPathItem>) path.getIndirectPath();
388393
while (!indirectPath.empty()) {
389-
CompareTool.ObjectPath.IndirectPathItem indirectPathItem = indirectPath.pop();
394+
IndirectPathItem indirectPathItem = indirectPath.pop();
390395
currentNode = nodes.getNode(indirectPathItem.getOutObject().getObjNumber());
391396
if (currentNode != null) {
392397
nodes.expandNode(currentNode);
393398
}
394399
}
395-
Stack<CompareTool.ObjectPath.LocalPathItem> localPath = (Stack<CompareTool.ObjectPath.LocalPathItem>) path.getLocalPath().clone();
400+
Stack<LocalPathItem> localPath = (Stack<LocalPathItem>) path.getLocalPath();
396401
currentNode = nodes.getNode(path.getBaseOutObject().getObjNumber());
397402
while (!localPath.empty() && currentNode != null) {
398403
nodes.expandNode(currentNode);
399-
CompareTool.ObjectPath.LocalPathItem item = localPath.pop();
400-
if (item instanceof CompareTool.ObjectPath.DictPathItem) {
401-
currentNode = nodes.getChildNode(currentNode, ((CompareTool.ObjectPath.DictPathItem) item).getKey());
402-
} else if (item instanceof CompareTool.ObjectPath.ArrayPathItem) {
403-
int index = ((CompareTool.ObjectPath.ArrayPathItem) item).getIndex();
404+
LocalPathItem item = localPath.pop();
405+
if (item instanceof DictPathItem) {
406+
currentNode = nodes.getChildNode(currentNode, ((DictPathItem) item).getKey());
407+
} else if (item instanceof ArrayPathItem) {
408+
int index = ((ArrayPathItem) item).getIndex();
404409
currentNode = (PdfObjectTreeNode) currentNode.getChildAt(index);
405410
}
406411
}

0 commit comments

Comments
 (0)