file: Unfold scanned booklets into sequential pages - #87
Open
sjg20 wants to merge 1 commit into
Open
Conversation
When a saddle-stitched booklet is taken apart and scanned, each scanned page holds two booklet pages side by side and the sheets come out in reading order only on the outermost sheet. Recovering normal sequential pages by hand is tedious, so add an 'Unfold booklet' operation that does it automatically. Each scanned page is split down the middle into a left and a right half and the halves are reordered into reading order in a new stack. The imposition is the standard saddle stitch: the outer sheet carries the last and first pages, the next sheet the second and second-to-last, and so on, alternating which half is the lower page number as the scan moves from the outer to the inner sheets. The full halves are kept, so no page is trimmed or dropped. The reading order is worked out by bookletOrder(), a pure helper that is covered by a unit test, and the page-writing logic in copyTo() is factored into addImageAsPage() so the new path can reuse it. The operation creates a new max stack and supports undo, mirroring the existing duplicate operation. Co-developed-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfold scanned booklets into sequential pages
When a saddle-stitched booklet is taken apart (e.g. by pulling the
staples) and fed through a scanner, each scanned page holds two booklet
pages side by side, and the sheets only come out in reading order on the
outermost sheet. This adds an Unfold booklet operation that recovers
normal sequential pages automatically.
What it does
right half (no trimming — the full halves are kept, no page dropped).
imposition. For an 8-page booklet (4 scanned pages) the scans hold
[8|1] [2|7] [6|3] [4|5]and unfold to1 2 3 4 5 6 7 8.duplicate operation.
Structure
File::bookletOrder()— pure helper computing the reading order;covered by a unit test (
testBookletOrder).File::addImageAsPage()— the page-writing logic factored out ofcopyTo()so the new path reuses it (no behaviour change tocopyTo).File::unfoldBooklet()→Desktopmodel::opUnfoldBooklets()/unfoldBooklet()→UCUnfoldBookletundo → desktop action/slot/menu.Tests
testBookletOrder— verifies the imposition for a 4-sheet booklet andthat every source page contributes exactly one left and one right half.
testUnfoldBooklet— unfolds the test stack, checks the new stack isnamed
testfile_unfold, is a Max, has twice the page count, and thatundo removes it.
Note: the full GUI build could not be exercised locally (the sandbox
lacks the QtStateMachine dev headers used by
desktopwidget.cpp); thecore objects and the test were compiled individually and the full
build/tests rely on CI.