Changeset 561 for trunk/src/gui/painting/qprinterinfo_win.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/painting/qprinterinfo_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 #include <qstringlist.h> 45 45 46 #include < windows.h>46 #include <qt_windows.h> 47 47 48 48 QT_BEGIN_NAMESPACE … … 70 70 static QPrinterInfoPrivate nullQPrinterInfoPrivate; 71 71 72 class QPrinterInfoPrivateDeleter 73 { 74 public: 75 static inline void cleanup(QPrinterInfoPrivate *d) 76 { 77 if (d != &nullQPrinterInfoPrivate) 78 delete d; 79 } 80 }; 81 72 82 ///////////////////////////////////////////////////////////////////////////// 73 83 ///////////////////////////////////////////////////////////////////////////// … … 80 90 DWORD returned = 0; 81 91 82 QT_WA({ 83 if (!EnumPrintersW(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 84 4, 0, 0, &needed, &returned)) 85 { 86 buffer = new BYTE[needed]; 87 if (!EnumPrintersW(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS , NULL, 88 4, buffer, needed, &needed, &returned)) 89 { 90 delete [] buffer; 91 return printers; 92 } 93 PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer); 94 QPrinterInfo defPrn = defaultPrinter(); 95 for (uint i = 0; i < returned; ++i) { 96 printers.append(QPrinterInfo(QString::fromUtf16(reinterpret_cast<const ushort*>(infoList[i].pPrinterName)))); 97 if (printers.at(i).printerName() == defPrn.printerName()) 98 printers[i].d_ptr->m_default = true; 99 } 100 delete [] buffer; 101 } 102 }, { 103 // In Windows 98 networked printers are served through the local connection 104 if (!EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 5, 0, 0, &needed, &returned)) { 105 buffer = new BYTE[needed]; 106 if (!EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 5, buffer, needed, &needed, &returned)) { 107 delete [] buffer; 108 return printers; 109 } 110 111 PPRINTER_INFO_5 infoList = reinterpret_cast<PPRINTER_INFO_5>(buffer); 112 QPrinterInfo defPrn = defaultPrinter(); 113 for (uint i = 0; i < returned; ++i) { 114 printers.append(QPrinterInfo(QString::fromLocal8Bit(reinterpret_cast<const char*>(infoList[i].pPrinterName)))); 115 if (printers.at(i).printerName() == defPrn.printerName()) 116 printers[i].d_ptr->m_default = true; 117 } 118 delete [] buffer; 119 } 120 }); 92 if ( !EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) 93 { 94 buffer = new BYTE[needed]; 95 if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS , NULL, 96 4, buffer, needed, &needed, &returned)) 97 { 98 delete [] buffer; 99 return printers; 100 } 101 PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer); 102 QPrinterInfo defPrn = defaultPrinter(); 103 for (uint i = 0; i < returned; ++i) { 104 printers.append(QPrinterInfo(QString::fromWCharArray(infoList[i].pPrinterName))); 105 if (printers.at(i).printerName() == defPrn.printerName()) 106 printers[i].d_ptr->m_default = true; 107 } 108 delete [] buffer; 109 } 121 110 122 111 return printers; … … 126 115 { 127 116 QString noPrinters(QLatin1String("qt_no_printers")); 128 QString output; 129 QT_WA({ 130 ushort buffer[256]; 131 GetProfileStringW(L"windows", L"device", 132 reinterpret_cast<const wchar_t *>(noPrinters.utf16()), 133 reinterpret_cast<wchar_t *>(buffer), 256); 134 output = QString::fromUtf16(buffer); 135 }, { 136 char buffer[256]; 137 GetProfileStringA("windows", "device", noPrinters.toLatin1(), buffer, 256); 138 output = QString::fromLocal8Bit(buffer); 139 }); 117 wchar_t buffer[256]; 118 GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256); 119 QString output = QString::fromWCharArray(buffer); 140 120 141 121 // Filter out the name of the printer, which should be everything … … 156 136 157 137 QPrinterInfo::QPrinterInfo() 158 { 159 d_ptr = &nullQPrinterInfoPrivate; 138 : d_ptr(&nullQPrinterInfoPrivate) 139 { 160 140 } 161 141 162 142 QPrinterInfo::QPrinterInfo(const QString& name) 163 { 164 d_ptr = new QPrinterInfoPrivate(name); 143 : d_ptr(new QPrinterInfoPrivate(name)) 144 { 165 145 d_ptr->q_ptr = this; 166 146 } 167 147 168 148 QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) 169 { 170 d_ptr = &nullQPrinterInfoPrivate; 149 : d_ptr(&nullQPrinterInfoPrivate) 150 { 171 151 *this = src; 172 152 } 173 153 174 154 QPrinterInfo::QPrinterInfo(const QPrinter& prn) 175 { 176 d_ptr = &nullQPrinterInfoPrivate; 155 : d_ptr(&nullQPrinterInfoPrivate) 156 { 177 157 QList<QPrinterInfo> list = availablePrinters(); 178 158 for (int c = 0; c < list.size(); ++c) { … … 188 168 QPrinterInfo::~QPrinterInfo() 189 169 { 190 if (d_ptr != &nullQPrinterInfoPrivate)191 delete d_ptr;192 170 } 193 171 … … 195 173 { 196 174 Q_ASSERT(d_ptr); 197 if (d_ptr != &nullQPrinterInfoPrivate) 198 delete d_ptr; 199 d_ptr = new QPrinterInfoPrivate(*src.d_ptr); 175 d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); 200 176 d_ptr->q_ptr = this; 201 177 return *this; … … 223 199 { 224 200 const Q_D(QPrinterInfo); 225 DWORD size;226 WORD* papers;227 201 QList<QPrinter::PaperSize> paperList; 228 202 229 QT_WA({ 230 size = DeviceCapabilitiesW(reinterpret_cast<const WCHAR*>(d->m_name.utf16()), 231 NULL, DC_PAPERS, NULL, NULL); 232 if ((int)size == -1) 233 return paperList; 234 papers = new WORD[size]; 235 size = DeviceCapabilitiesW(reinterpret_cast<const WCHAR*>(d->m_name.utf16()), 236 NULL, DC_PAPERS, reinterpret_cast<WCHAR*>(papers), NULL); 237 }, { 238 size = DeviceCapabilitiesA(d->m_name.toLatin1().data(), NULL, DC_PAPERS, NULL, NULL); 239 if ((int)size == -1) 240 return paperList; 241 papers = new WORD[size]; 242 size = DeviceCapabilitiesA(d->m_name.toLatin1().data(), NULL, DC_PAPERS, 243 reinterpret_cast<char*>(papers), NULL); 244 }); 203 DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()), 204 NULL, DC_PAPERS, NULL, NULL); 205 if ((int)size == -1) 206 return paperList; 207 208 wchar_t *papers = new wchar_t[size]; 209 size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()), 210 NULL, DC_PAPERS, papers, NULL); 245 211 246 212 for (int c = 0; c < (int)size; ++c) {
Note:
See TracChangeset
for help on using the changeset viewer.