TPrinter::Print asks the printout for a selection with GetDialogInfo. If the printout reports one (a non-zero selFromPage), it is always printed instead of what the user chose in the Print dialog. The page range is chosen by this condition (source/owlcore/printer.cpp):
else if ((prompt && (Data->Flags & PD_SELECTION)) || selFromPage)
{
fromPage = selFromPage;
toPage = selToPage;
}
The selFromPage operand makes the choice in the dialog irrelevant: "All", "Pages" and "Current page" all print the selection. The condition is from the original code (only the parentheses were added in [r2781]).
The intent seems to be that the selection is printed when the user picks "Selection" in the dialog, or by default when printing without the dialog. If so, the condition should be:
else if (prompt ? (Data->Flags & PD_SELECTION) : selFromPage != 0)
Related problem in TRichEditPrintout: TRichEditPrintout::GetDialogInfo reports a selection even when there is none. Without a selection, it returns selFromPage = 1 and selToPage = 2 (if there are at least 2 pages). With a selection, it returns the page where the selection starts and the following page, not the page where it ends. Combined with the above, printing a TRichEdit through TRichEditPrintout prints only pages 1 and 2, whatever is chosen. For a one-page document, it reports pages 1 to 0, which fails the precondition in the print loop (fromPage <= toPage) in a diagnostic build, and prints nothing otherwise. The "!BB Update to support multiple preview pages" comment there suggests the values were meant for the old preview (two pages) rather than for the selection. It should report a selection only if there is one, from the page of the start of the selection to the page of its end.
Found while fixing "Current page" in [r9534]. The RichEditor example is not affected, since its printouts do not report a selection.
Commit: [r2781]
Commit: [r9534]
Commit: [r9541]
Discussion: AI assistance
Wiki: OWLNext_6.40_Series_Revision_History
Wiki: OWLNext_7_Series_Revision_History
Fixed in trunk [r9539]:
Tested with the real Print dialog, recording the pages printed: no selection; a selection with All, Selection, Pages and without the dialog; a selection starting at a page break; a one-page document; and the page count. The old code fails 10 of the checks.
The same code is probably in the branches, which I haven't checked.
Related
Commit: [r9539]
The 7 and 6.44 branches had all three bugs. The fix is ported to branch 7 in [r9540] and to 6.44 in [r9541].
Tested on both branches by printing to the XPS Document Writer, with the user's choice in the Print dialog simulated. The test covers the same cases as in trunk, plus a "Selection" choice left from the last time. The old code fails 11 of the checks on both branches. Built with VS 2026 (x64) only.
Related
Commit: [r9540]