X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b5d5223d164a3b7fbacc5e69808cadd25163b1b..e5dbcb50a4fc20fa472be523d8c5606587a1ae5e:/src/msw/printdlg.cpp diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index 3b01b5b5b1..aa08d44436 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -44,9 +44,7 @@ #include -#include "wx/msw/private.h" - -#include +#include "wx/msw/wrapcdlg.h" #ifndef __WIN32__ #include @@ -200,6 +198,8 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this // code wouldn't set m_paperSize correctly. + + bool foundPaperSize = false; if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER)) { if (wxThePrintPaperDatabase) @@ -209,13 +209,7 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) { data.SetPaperId( paper->GetId() ); data.SetPaperSize( wxSize(paper->GetWidth() / 10,paper->GetHeight() / 10) ); - } - else - { - // Shouldn't really get here - wxFAIL_MSG(wxT("Couldn't find paper size in paper database.")); - data.SetPaperId( wxPAPER_NONE ); - data.SetPaperSize( wxSize() ); + foundPaperSize = true; } } else @@ -223,10 +217,14 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) // Shouldn't really get here wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative.")); data.SetPaperId( wxPAPER_NONE ); - data.SetPaperSize( wxSize() ); + data.SetPaperSize( wxSize(0,0) ); + + GlobalUnlock(hDevMode); + return false; } } - else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) + + if (!foundPaperSize && (devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) { // DEVMODE is in tenths of a milimeter data.SetPaperId( wxPAPER_NONE ); @@ -237,7 +235,10 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) // Shouldn't really get here wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE.")); data.SetPaperId( wxPAPER_NONE ); - data.SetPaperSize( wxSize() ); + data.SetPaperSize( wxSize(0,0) ); + + GlobalUnlock(hDevMode); + return false; } //// Duplex @@ -279,6 +280,11 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) else data.SetQuality( wxPRINT_QUALITY_HIGH ); + if (devMode->dmDriverExtra > 0) + data.SetPrivData( (char *)devMode+devMode->dmSize, devMode->dmDriverExtra ); + else + data.SetPrivData( NULL, 0 ); + GlobalUnlock(hDevMode); } @@ -297,7 +303,7 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset; // Not sure if we should check for this mismatch -// wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); +// wxASSERT_MSG( (m_printerName.empty() || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); if (!printerName.empty()) data.SetPrinterName( printerName ); @@ -425,6 +431,15 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) devMode->dmPaperSize = (short)paper->GetPlatformId(); devMode->dmFields |= DM_PAPERSIZE; } + else + { + // Fall back on specifying the paper size explicitly + devMode->dmPaperWidth = (short)(data.GetPaperSize().x * 10); + devMode->dmPaperLength = (short)(data.GetPaperSize().y * 10); + devMode->dmPaperSize = DMPAPER_USER; + devMode->dmFields |= DM_PAPERWIDTH; + devMode->dmFields |= DM_PAPERLENGTH; + } } } @@ -470,6 +485,12 @@ bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) devMode->dmPrintQuality = quality; devMode->dmFields |= DM_PRINTQUALITY; + if (data.GetPrivDataLen() > 0) + { + memcpy( (char *)devMode+devMode->dmSize, data.GetPrivData(), data.GetPrivDataLen() ); + devMode->dmDriverExtra = (WXWORD)data.GetPrivDataLen(); + } + if (data.GetBin() != wxPRINTBIN_DEFAULT) { switch (data.GetBin())