PrintPreview: Fixed RICOH MP C3501 color print job issues.
BUG=92358 TEST=Please refer to bug description. Review URL: http://codereview.chromium.org/7826040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99615 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome
browser
printing
resources
print_preview
ui
renderer
printing
@ -29,6 +29,7 @@ using printing::PrintSettings;
|
||||
namespace {
|
||||
|
||||
// CUPS ColorModel attribute and values.
|
||||
const char kCMYK[] = "CMYK";
|
||||
const char kCUPSColorModel[] = "cups-ColorModel";
|
||||
const char kColor[] = "Color";
|
||||
const char kGrayscale[] = "Grayscale";
|
||||
@ -157,7 +158,7 @@ void PrintDialogGtk::UseDefaultSettings() {
|
||||
bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings,
|
||||
const printing::PageRanges& ranges) {
|
||||
bool collate;
|
||||
bool color;
|
||||
int color;
|
||||
bool landscape;
|
||||
bool print_to_pdf;
|
||||
int copies;
|
||||
@ -166,7 +167,7 @@ bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings,
|
||||
|
||||
if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) ||
|
||||
!settings.GetBoolean(printing::kSettingCollate, &collate) ||
|
||||
!settings.GetBoolean(printing::kSettingColor, &color) ||
|
||||
!settings.GetInteger(printing::kSettingColor, &color) ||
|
||||
!settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) ||
|
||||
!settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) ||
|
||||
!settings.GetInteger(printing::kSettingCopies, &copies) ||
|
||||
@ -184,8 +185,21 @@ bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings,
|
||||
}
|
||||
gtk_print_settings_set_n_copies(gtk_settings_, copies);
|
||||
gtk_print_settings_set_collate(gtk_settings_, collate);
|
||||
gtk_print_settings_set(gtk_settings_, kCUPSColorModel,
|
||||
color ? kColor : kGrayscale);
|
||||
|
||||
const char* color_mode;
|
||||
switch (color) {
|
||||
case printing::COLOR:
|
||||
color_mode = kColor;
|
||||
break;
|
||||
case printing::CMYK:
|
||||
color_mode = kCMYK;
|
||||
break;
|
||||
default:
|
||||
color_mode = kGrayscale;
|
||||
break;
|
||||
}
|
||||
gtk_print_settings_set(gtk_settings_, kCUPSColorModel, color_mode);
|
||||
|
||||
const char* cups_duplex_mode;
|
||||
switch (duplex_mode) {
|
||||
case printing::LONG_EDGE:
|
||||
|
@ -14,6 +14,10 @@ cr.define('print_preview', function() {
|
||||
this.colorOption_ = $('color-option');
|
||||
this.colorRadioButton_ = $('color');
|
||||
this.bwRadioButton_ = $('bw');
|
||||
this.GRAY = 1;
|
||||
this.COLOR = 2;
|
||||
this.CMYK = 3; // cmyk - Cyan, magenta, yellow, black
|
||||
this.printerColorModelForColor_ = this.COLOR;
|
||||
}
|
||||
|
||||
cr.addSingletonGetter(ColorSettings);
|
||||
@ -36,11 +40,13 @@ cr.define('print_preview', function() {
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether |this.colorRadioButton_| is checked.
|
||||
* @return {boolean} true if |this.colorRadioButton_| is checked.
|
||||
* Returns the color mode for print preview.
|
||||
* @return {Number} Returns the printer color space
|
||||
*/
|
||||
isColor: function() {
|
||||
return this.colorRadioButton_.checked;
|
||||
get colorMode() {
|
||||
if (this.bwRadioButton_.checked)
|
||||
return this.GRAY;
|
||||
return this.printerColorModelForColor_;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -71,6 +77,8 @@ cr.define('print_preview', function() {
|
||||
this.colorOption_.setAttribute('aria-hidden', disableColorOption);
|
||||
|
||||
var setColorAsDefault = e.printerCapabilities.setColorAsDefault;
|
||||
this.printerColorModelForColor_ =
|
||||
e.printerCapabilities.printerColorModelForColor;
|
||||
this.colorRadioButton_.checked = setColorAsDefault;
|
||||
this.bwRadioButton_.checked = !setColorAsDefault;
|
||||
setColor(this.colorRadioButton_.checked);
|
||||
|
@ -237,6 +237,7 @@ function updateControlsWithSelectedPrinterCapabilities() {
|
||||
'disableColorOption': true,
|
||||
'setColorAsDefault': true,
|
||||
'setDuplexAsDefault': false,
|
||||
'printerColorModelForColor': colorSettings.COLOR,
|
||||
'disableCopiesOption': true});
|
||||
} else {
|
||||
// This message will call back to 'updateWithPrinterCapabilities'
|
||||
@ -344,7 +345,7 @@ function getSettings() {
|
||||
'copies': copiesSettings.numberOfCopies,
|
||||
'collate': copiesSettings.isCollated(),
|
||||
'landscape': layoutSettings.isLandscape(),
|
||||
'color': colorSettings.isColor(),
|
||||
'color': colorSettings.colorMode,
|
||||
'printToPDF': printToPDF,
|
||||
'isFirstRequest' : false,
|
||||
'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(),
|
||||
@ -1024,7 +1025,7 @@ function createPDFPlugin(srcDataIndex) {
|
||||
pdfViewer.goToPage('0');
|
||||
pdfViewer.resetPrintPreviewUrl(srcURL);
|
||||
pdfViewer.reload();
|
||||
pdfViewer.grayscale(!colorSettings.isColor());
|
||||
pdfViewer.grayscale(colorSettings.colorMode == colorSettings.GRAY);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,13 @@ namespace {
|
||||
const char kDisableColorOption[] = "disableColorOption";
|
||||
const char kSetColorAsDefault[] = "setColorAsDefault";
|
||||
const char kSetDuplexAsDefault[] = "setDuplexAsDefault";
|
||||
const char kPrinterColorModelForColor[] = "printerColorModelForColor";
|
||||
|
||||
#if defined(USE_CUPS)
|
||||
const char kColorDevice[] = "ColorDevice";
|
||||
const char kColorModel[] = "ColorModel";
|
||||
const char kColorModelForColor[] = "Color";
|
||||
const char kCMYK[] = "CMYK";
|
||||
const char kDuplex[] = "Duplex";
|
||||
const char kDuplexNone[] = "None";
|
||||
#elif defined(OS_WIN)
|
||||
@ -163,9 +167,11 @@ void ReportPrintSettingsStats(const DictionaryValue& settings) {
|
||||
if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
|
||||
ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);
|
||||
|
||||
bool is_color;
|
||||
if (settings.GetBoolean(printing::kSettingColor, &is_color))
|
||||
ReportPrintSettingHistogram(is_color ? COLOR : BLACK_AND_WHITE);
|
||||
int color_mode;
|
||||
if (settings.GetInteger(printing::kSettingColor, &color_mode)) {
|
||||
ReportPrintSettingHistogram(color_mode == printing::GRAY ? BLACK_AND_WHITE :
|
||||
COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
|
||||
@ -274,6 +280,7 @@ class PrintSystemTaskProxy
|
||||
printing::PrinterCapsAndDefaults printer_info;
|
||||
bool supports_color = true;
|
||||
bool set_duplex_as_default = false;
|
||||
int printer_color_space = printing::GRAY;
|
||||
if (!print_backend_->GetPrinterCapsAndDefaults(printer_name,
|
||||
&printer_info)) {
|
||||
return;
|
||||
@ -309,6 +316,17 @@ class PrintSystemTaskProxy
|
||||
if (ch != NULL && strcmp(ch->choice, kDuplexNone) != 0)
|
||||
set_duplex_as_default = true;
|
||||
|
||||
if (supports_color) {
|
||||
// Identify the color space (COLOR/CMYK) for this printer.
|
||||
ppd_option_t* color_model = ppdFindOption(ppd, kColorModel);
|
||||
if (color_model != NULL) {
|
||||
if (ppdFindChoice(color_model, kColorModelForColor))
|
||||
printer_color_space = printing::COLOR;
|
||||
else if (ppdFindChoice(color_model, kCMYK))
|
||||
printer_color_space = printing::CMYK;
|
||||
}
|
||||
}
|
||||
|
||||
ppdClose(ppd);
|
||||
}
|
||||
file_util::Delete(ppd_file_path, false);
|
||||
@ -319,6 +337,9 @@ class PrintSystemTaskProxy
|
||||
// http://msdn.microsoft.com/en-us/windows/hardware/gg463431.
|
||||
supports_color = (printer_info.printer_capabilities.find(kPskColor) !=
|
||||
std::string::npos);
|
||||
if (supports_color)
|
||||
printer_color_space = printing::COLOR;
|
||||
|
||||
set_duplex_as_default =
|
||||
(printer_info.printer_defaults.find(kPskDuplexFeature) !=
|
||||
std::string::npos) &&
|
||||
@ -337,6 +358,7 @@ class PrintSystemTaskProxy
|
||||
PrintPreviewHandler::last_used_color_setting_);
|
||||
}
|
||||
settings_info.SetBoolean(kSetDuplexAsDefault, set_duplex_as_default);
|
||||
settings_info.SetInteger(kPrinterColorModelForColor, printer_color_space);
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
NewRunnableMethod(this,
|
||||
@ -568,7 +590,10 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
|
||||
return;
|
||||
|
||||
// Storing last used color setting.
|
||||
settings->GetBoolean(printing::kSettingColor, &last_used_color_setting_);
|
||||
int color_mode;
|
||||
if (!settings->GetInteger(printing::kSettingColor, &color_mode))
|
||||
color_mode = printing::GRAY;
|
||||
last_used_color_setting_ = (color_mode != printing::GRAY);
|
||||
|
||||
bool print_to_pdf = false;
|
||||
settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
|
||||
|
@ -241,7 +241,7 @@ void MockRenderThread::OnUpdatePrintSettings(
|
||||
std::string dummy_string;
|
||||
if (!job_settings.GetBoolean(printing::kSettingLandscape, NULL) ||
|
||||
!job_settings.GetBoolean(printing::kSettingCollate, NULL) ||
|
||||
!job_settings.GetBoolean(printing::kSettingColor, NULL) ||
|
||||
!job_settings.GetInteger(printing::kSettingColor, NULL) ||
|
||||
!job_settings.GetBoolean(printing::kSettingPrintToPDF, NULL) ||
|
||||
!job_settings.GetBoolean(printing::kIsFirstRequest, NULL) ||
|
||||
!job_settings.GetString(printing::kSettingDeviceName, &dummy_string) ||
|
||||
|
@ -40,7 +40,7 @@ const char kPrintPreviewHTML[] =
|
||||
void CreatePrintSettingsDictionary(DictionaryValue* dict) {
|
||||
dict->SetBoolean(printing::kSettingLandscape, false);
|
||||
dict->SetBoolean(printing::kSettingCollate, false);
|
||||
dict->SetBoolean(printing::kSettingColor, false);
|
||||
dict->SetInteger(printing::kSettingColor, printing::GRAY);
|
||||
dict->SetBoolean(printing::kSettingPrintToPDF, true);
|
||||
dict->SetInteger(printing::kSettingDuplexMode, printing::SIMPLEX);
|
||||
dict->SetInteger(printing::kSettingCopies, 1);
|
||||
|
@ -67,6 +67,13 @@ enum VerticalHeaderFooterPosition {
|
||||
BOTTOM
|
||||
};
|
||||
|
||||
// Print job color mode values.
|
||||
enum ColorMode {
|
||||
GRAY = 1,
|
||||
COLOR,
|
||||
CMYK,
|
||||
};
|
||||
|
||||
} // namespace printing
|
||||
|
||||
#endif // PRINTING_PRINT_JOB_CONSTANTS_H_
|
||||
|
@ -75,7 +75,7 @@ class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
|
||||
|
||||
// Sets output color mode in PMPrintSettings.
|
||||
// Returns true if color mode is set.
|
||||
bool SetOutputIsColor(bool color);
|
||||
bool SetOutputColor(int color_mode);
|
||||
|
||||
// The native print info object.
|
||||
scoped_nsobject<NSPrintInfo> print_info_;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
static const CFStringRef kColorModel = CFSTR("ColorModel");
|
||||
static const CFStringRef kGrayColor = CFSTR("Gray");
|
||||
static const CFStringRef kCMYK = CFSTR("CMYK");
|
||||
|
||||
namespace printing {
|
||||
|
||||
@ -107,7 +108,7 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
|
||||
print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]);
|
||||
|
||||
bool collate;
|
||||
bool color;
|
||||
int color;
|
||||
bool landscape;
|
||||
bool print_to_pdf;
|
||||
int copies;
|
||||
@ -116,7 +117,7 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
|
||||
|
||||
if (!job_settings.GetBoolean(kSettingLandscape, &landscape) ||
|
||||
!job_settings.GetBoolean(kSettingCollate, &collate) ||
|
||||
!job_settings.GetBoolean(kSettingColor, &color) ||
|
||||
!job_settings.GetInteger(kSettingColor, &color) ||
|
||||
!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) ||
|
||||
!job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) ||
|
||||
!job_settings.GetInteger(kSettingCopies, &copies) ||
|
||||
@ -141,7 +142,7 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
|
||||
return OnError();
|
||||
}
|
||||
|
||||
if (!SetOutputIsColor(color))
|
||||
if (!SetOutputColor(color))
|
||||
return OnError();
|
||||
}
|
||||
|
||||
@ -245,10 +246,14 @@ bool PrintingContextMac::SetDuplexModeInPrintSettings(DuplexMode mode) {
|
||||
return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr;
|
||||
}
|
||||
|
||||
bool PrintingContextMac::SetOutputIsColor(bool color) {
|
||||
bool PrintingContextMac::SetOutputColor(int color_mode) {
|
||||
PMPrintSettings pmPrintSettings =
|
||||
static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
|
||||
CFStringRef output_color = color ? NULL : kGrayColor;
|
||||
CFStringRef output_color = NULL;
|
||||
if (color_mode == printing::GRAY)
|
||||
output_color = kGrayColor;
|
||||
else if (color_mode == printing::CMYK)
|
||||
output_color = kCMYK;
|
||||
|
||||
return PMPrintSettingsSetValue(pmPrintSettings,
|
||||
kColorModel,
|
||||
|
@ -308,7 +308,7 @@ PrintingContext::Result PrintingContextWin::UpdatePrinterSettings(
|
||||
DCHECK(!in_print_job_);
|
||||
|
||||
bool collate;
|
||||
bool color;
|
||||
int color;
|
||||
bool landscape;
|
||||
bool print_to_pdf;
|
||||
int copies;
|
||||
@ -317,7 +317,7 @@ PrintingContext::Result PrintingContextWin::UpdatePrinterSettings(
|
||||
|
||||
if (!job_settings.GetBoolean(kSettingLandscape, &landscape) ||
|
||||
!job_settings.GetBoolean(kSettingCollate, &collate) ||
|
||||
!job_settings.GetBoolean(kSettingColor, &color) ||
|
||||
!job_settings.GetInteger(kSettingColor, &color) ||
|
||||
!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) ||
|
||||
!job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) ||
|
||||
!job_settings.GetInteger(kSettingCopies, &copies) ||
|
||||
@ -365,7 +365,11 @@ PrintingContext::Result PrintingContextWin::UpdatePrinterSettings(
|
||||
return OnError();
|
||||
}
|
||||
|
||||
dev_mode->dmColor = color ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME;
|
||||
if (color == printing::GRAY)
|
||||
dev_mode->dmColor = DMCOLOR_MONOCHROME;
|
||||
else
|
||||
dev_mode->dmColor = DMCOLOR_COLOR;
|
||||
|
||||
dev_mode->dmCopies = std::max(copies, 1);
|
||||
if (dev_mode->dmCopies > 1) // do not change collate unless multiple copies
|
||||
dev_mode->dmCollate = collate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE;
|
||||
|
Reference in New Issue
Block a user