Changeset 561 for trunk/src/gui/painting/qprintengine_mac.mm
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (16 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/qprintengine_mac.mm
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 ** … … 62 62 { 63 63 Q_D(QMacPrintEngine); 64 65 Q_ASSERT(dev && dev->devType() == QInternal::Printer); 66 if (!static_cast<QPrinter *>(dev)->isValid()) 67 return false; 64 68 65 69 if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize … … 89 93 OSStatus status = noErr; 90 94 #ifndef QT_MAC_USE_COCOA 91 # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) 92 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { 93 status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format) 94 : PMSessionBeginCGDocument(d->session, d->settings, d->format); 95 } else 96 # endif 97 { 98 status = d->shouldSuppressStatus() ? PMSessionBeginDocumentNoDialog(d->session, d->settings, d->format) 99 : PMSessionBeginDocument(d->session, d->settings, d->format); 100 } 95 status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format) 96 : PMSessionBeginCGDocument(d->session, d->settings, d->format); 101 97 #else 102 98 status = PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format); … … 122 118 static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0; 123 119 d->paintEngine->end(); 124 if (d->state != QPrinter::Idle) { 125 #ifndef QT_MAC_USE_COCOA 126 if (d->shouldSuppressStatus()) { 127 PMSessionEndPageNoDialog(d->session); 128 PMSessionEndDocumentNoDialog(d->session); 129 } else { 130 PMSessionEndPage(d->session); 131 PMSessionEndDocument(d->session); 132 } 133 PMRelease(d->session); 134 #else 135 PMSessionEndPageNoDialog(d->session); 136 PMSessionEndDocumentNoDialog(d->session); 137 [d->printInfo release]; 138 #endif 139 d->printInfo = 0; 140 d->session = 0; 141 } 120 if (d->state != QPrinter::Idle) 121 d->releaseSession(); 142 122 d->state = QPrinter::Idle; 143 123 return true; … … 481 461 482 462 #ifndef QT_MAC_USE_COCOA 483 # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)484 if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_4)485 # endif486 {487 if(paintEngine->type() == QPaintEngine::CoreGraphics) {488 CFStringRef strings[1] = { kPMGraphicsContextCoreGraphics };489 QCFType<CFArrayRef> contextArray = CFArrayCreate(kCFAllocatorDefault,490 reinterpret_cast<const void **>(strings),491 1, &kCFTypeArrayCallBacks);492 OSStatus err = PMSessionSetDocumentFormatGeneration(session, kPMDocumentFormatPDF,493 contextArray, 0);494 if(err != noErr) {495 qWarning("QMacPrintEngine::initialize: Cannot set format generation to PDF: %ld", err);496 state = QPrinter::Error;497 }498 }499 }500 463 if (!settingsOK || !formatOK) { 501 464 qWarning("QMacPrintEngine::initialize: Unable to initialize QPainter"); … … 508 471 q->setProperty(propC.key(), propC.value()); 509 472 } 473 } 474 475 void QMacPrintEnginePrivate::releaseSession() 476 { 477 #ifndef QT_MAC_USE_COCOA 478 if (shouldSuppressStatus()) { 479 PMSessionEndPageNoDialog(session); 480 PMSessionEndDocumentNoDialog(session); 481 } else { 482 PMSessionEndPage(session); 483 PMSessionEndDocument(session); 484 } 485 PMRelease(session); 486 #else 487 PMSessionEndPageNoDialog(session); 488 PMSessionEndDocumentNoDialog(session); 489 [printInfo release]; 490 #endif 491 printInfo = 0; 492 session = 0; 510 493 } 511 494 … … 544 527 CGContextRef cgContext; 545 528 OSStatus err = noErr; 546 #ifndef QT_MAC_USE_COCOA547 # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)548 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {549 err = PMSessionGetCGGraphicsContext(session, &cgContext);550 } else551 # endif552 {553 err = PMSessionGetGraphicsContext(session, kPMGraphicsContextCoreGraphics,554 reinterpret_cast<void **>(&cgContext));555 }556 #else557 529 err = PMSessionGetCGGraphicsContext(session, &cgContext); 558 #endif559 530 if(err != noErr) { 560 531 qWarning("QMacPrintEngine::newPage: Cannot retrieve CoreGraphics context: %ld", long(err)); … … 738 709 break; 739 710 case PPK_PrinterName: { 711 bool printerNameSet = false; 740 712 OSStatus status = noErr; 741 713 QCFType<CFArrayRef> printerList; … … 748 720 if (name == value.toString()) { 749 721 status = PMSessionSetCurrentPMPrinter(d->session, printer); 722 printerNameSet = true; 750 723 break; 751 724 } … … 754 727 if (status != noErr) 755 728 qWarning("QMacPrintEngine::setPrinterName: Error setting printer: %ld", long(status)); 729 if (!printerNameSet) { 730 qWarning("QMacPrintEngine::setPrinterName: Failed to set printer named '%s'.", qPrintable(value.toString())); 731 d->releaseSession(); 732 d->state = QPrinter::Idle; 733 } 756 734 break; } 757 735 case PPK_SuppressSystemPrintStatus: … … 877 855 break; } 878 856 case PPK_PrinterName: { 879 CFIndex currIndex; 880 PMPrinter unused; 881 QCFType<CFArrayRef> printerList; 882 OSStatus status = PMSessionCreatePrinterList(d->session, &printerList, &currIndex, &unused); 857 PMPrinter printer; 858 OSStatus status = PMSessionGetCurrentPrinter(d->session, &printer); 883 859 if (status != noErr) 884 qWarning("QMacPrintEngine::printerName: Problem getting list of printers: %ld", long(status)); 885 if (currIndex != -1 && printerList && currIndex < CFArrayGetCount(printerList)) { 886 const CFStringRef name = static_cast<CFStringRef>(CFArrayGetValueAtIndex(printerList, currIndex)); 887 if (name) 888 ret = QCFString::toQString(name); 889 } 860 qWarning("QMacPrintEngine::printerName: Failed getting current PMPrinter: %ld", long(status)); 861 if (printer) 862 ret = QCFString::toQString(PMPrinterGetName(printer)); 890 863 break; } 891 864 case PPK_Resolution: {
Note:
See TracChangeset
for help on using the changeset viewer.