Add PrivData() field to wxPrintData since MSW's printer

sometimes seem to save data in an extra field. The
    original author of the patch chose to save it in char*
    so I kept that, although void* would probably be correct.
    The patch is against 2.4.2 and the code has been reshuffled
    since then so that the patch had to be redone entirely.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2005-02-28 01:51:59 +00:00
parent 74124ea961
commit aa96f01c02
4 changed files with 53 additions and 1 deletions

View File

@ -217,6 +217,11 @@ public:
void operator=(const wxPrintData& data);
char* GetPrivData() const { return m_privData; }
int GetPrivDataLen() const { return m_privDataLen; }
void SetPrivData( char *privData, int len );
#if WXWIN_COMPATIBILITY_2_4
// PostScript-specific data
wxString GetPrinterCommand() const;
@ -268,6 +273,9 @@ private:
wxString m_filename;
char* m_privData;
int m_privDataLen;
wxPrintNativeDataBase *m_nativeData;
private:

View File

@ -44,7 +44,7 @@ public:
void SetDevMode(void* data) { m_devMode = data; }
void* GetDevNames() const { return m_devNames; }
void SetDevNames(void* data) { m_devNames = data; }
private:
void* m_devMode;
void* m_devNames;

View File

@ -185,6 +185,9 @@ wxPrintData::wxPrintData()
m_paperId = wxPAPER_A4;
m_paperSize = wxSize(210, 297);
m_privData = NULL;
m_privDataLen = 0;
m_nativeData = wxPrintFactory::GetFactory()->CreatePrintNativeData();
}
@ -195,11 +198,29 @@ wxPrintData::wxPrintData(const wxPrintData& printData)
(*this) = printData;
}
void wxPrintData::SetPrivData( char *privData, int len )
{
if (m_privData)
{
delete [] m_privData;
m_privData = NULL;
}
m_privDataLen = len;
if (m_privDataLen > 0)
{
m_privData = new char[m_privDataLen];
memcpy( m_privData, privData, m_privDataLen );
}
}
wxPrintData::~wxPrintData()
{
m_nativeData->m_ref--;
if (m_nativeData->m_ref == 0)
delete m_nativeData;
if (m_privData)
delete [] m_privData;
#ifdef __WXMAC__
delete m_nativePrintData ;
@ -250,6 +271,18 @@ void wxPrintData::operator=(const wxPrintData& data)
m_nativeData = data.GetNativeData();
m_nativeData->m_ref++;
if (m_privData)
{
delete [] m_privData;
m_privData = NULL;
}
m_privDataLen = data.GetPrivDataLen();
if (m_privDataLen > 0)
{
m_privData = new char[m_privDataLen];
memcpy( m_privData, data.GetPrivData(), m_privDataLen );
}
#ifdef __WXMAC__
m_nativePrintData->CopyFrom( data.m_nativePrintData ) ;
#endif

View File

@ -279,6 +279,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);
}
@ -469,6 +474,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 = data.GetPrivDataLen();
}
if (data.GetBin() != wxPRINTBIN_DEFAULT)
{