Skip to content

Commit

Permalink
Merge pull request #5694 from effective-webwork/fix-order
Browse files Browse the repository at this point in the history
Fix order of logical and physical divisions
  • Loading branch information
solth authored Jul 18, 2023
2 parents 87d95d1 + 5644d54 commit 56587ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ public void addDocStruc(boolean preview) {
dataEditor.getGalleryPanel().setGalleryViewMode(LIST_MODE);
}
try {
dataEditor.getStructurePanel().preserve();
dataEditor.refreshStructurePanel();
dataEditor.getPaginationPanel().show();
} catch (UnknownTreeNodeDataException e) {
Helper.setErrorMessage(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,14 @@ private LogicalDivision preserveLogicalAndPhysicalRecursive(TreeNode treeNode) t
}
}
}
/*
PhysicalDivisions assigned to multiple LogicalDivisions may lead to wrong order value. The order will be
incremented for each occurrence and not just the last one. The LogicalDivisions containing those
PhysicalDivisions must be set to the order value of their first PhysicalDivision.
*/
if (!structure.getViews().isEmpty()) {
structure.setOrder(structure.getViews().getFirst().getPhysicalDivision().getOrder());
}
return structure;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ private static void handlePosition(Workpiece workpiece, LogicalDivision logicalD
List<Integer> siblingOrderValues = Stream.concat(logicalDivision.getChildren().stream()
.map(Division::getOrder), Stream.of(structureOrder)).sorted().collect(Collectors.toList());

// new order must be set at correction location between existing siblings
logicalDivision.getChildren().add(siblingOrderValues.indexOf(structureOrder), newStructure);
// new order must be set at correct location between existing siblings
logicalDivision.getChildren().add(siblingOrderValues.lastIndexOf(structureOrder), newStructure);
}
break;
case FIRST_CHILD_OF_CURRENT_ELEMENT:
Expand Down

0 comments on commit 56587ea

Please sign in to comment.