]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix printing multiple copies in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 26 May 2013 13:14:38 +0000 (13:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 26 May 2013 13:14:38 +0000 (13:14 +0000)
If wxPrinterDC was created by the native "Print" dialog for a printer that
supports printing multiple copies, we must not manually print multiple copies
ourselves as this results in too many copies being printed. However we still
need to loop explicitly for wxPrinterDC objects created manually or for the
printers without support for multiple copies (supposing they still exist).

Closes #10323.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74055 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/msw/printwin.cpp

index 03eeb53fd3d9ef7812667292d1e0253317fd2ec7..f64bc4e691d2a9ea55ea955e5711c925e0b03328 100644 (file)
@@ -697,6 +697,7 @@ wxMSW:
 - Return more native shell icons from wxArtProvider (Markus Juergens).
 - Fix filter checks in wxDir::FindFirst/Next() (Catalin Raceanu).
 - Add support for wxICON_AUTH_NEEDED to wxMessageDialog (Chris Spencer).
+- Fix printing too many copies of the document in some cases (John Roberts).
 
 wxOSX/Cocoa:
 
index 0c8a2ed6521397984245a0c38f0d57a7317d5c5f..62abb589f6bd8fcd2e9304870279d82444c8ecb9 100644 (file)
@@ -196,7 +196,14 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
         maxPageNum = m_printDialogData.GetToPage();
     }
 
-    const int maxCopyCount = m_printDialogData.GetNoCopies();
+    // The dc we get from the PrintDialog will do multiple copies without help
+    // if the device supports it. Loop only if we have created a dc from our
+    // own m_printDialogData or the device does not support multiple copies.
+    // m_printDialogData.GetPrintData().GetNoCopies() is set from device
+    // devMode in printdlg.cpp/wxWindowsPrintDialog::ConvertFromNative()
+    const int maxCopyCount = !prompt ||
+                             !m_printDialogData.GetPrintData().GetNoCopies()
+                             ? m_printDialogData.GetNoCopies() : 1;
     for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ )
     {
         if ( !printout->OnBeginDocument(minPageNum, maxPageNum) )