From 1cd916fc0a5c4a38af730b11ece9657e90163d44 Mon Sep 17 00:00:00 2001 From: Fulvio Senore Date: Tue, 12 May 2015 17:14:40 +0200 Subject: [PATCH] Don't show the last page number when printing if it wasn't defined. Show just the current page in the printing progress messages if the last page has its default "infinitely big" value. Closes #16987. --- src/common/prntbase.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index 92eca0d259..2ca6b4726d 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -72,6 +72,11 @@ #endif #endif // __WXMSW__ +// The value traditionally used as the default max page number and meaning +// "infinitely many". It should probably be documented and exposed, but for now +// at least use it here instead of hardcoding the number. +static const int DEFAULT_MAX_PAGES = 32000; + //---------------------------------------------------------------------------- // wxPrintFactory //---------------------------------------------------------------------------- @@ -553,11 +558,22 @@ void wxPrintAbortDialog::SetProgress(int currentPage, int totalPages, int currentCopy, int totalCopies) { wxString text; - text.Printf(_("Printing page %d of %d"), currentPage, totalPages); + if ( totalPages == DEFAULT_MAX_PAGES ) + { + // This means that the user has not supplied a total number of pages so it + // is better not to show this value. + text.Printf(_("Printing page %d"), currentPage); + } + else + { + // We have a valid total number of pages so we show it. + text.Printf(_("Printing page %d of %d"), currentPage, totalPages); + } if ( totalCopies > 1 ) text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies); m_progress->SetLabel(text); } + void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { wxCHECK_RET( wxPrinterBase::sm_abortWindow != NULL, "OnCancel called twice" ); @@ -617,7 +633,7 @@ bool wxPrintout::HasPage(int page) void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage) { *minPage = 1; - *maxPage = 32000; + *maxPage = DEFAULT_MAX_PAGES; *fromPage = 1; *toPage = 1; }