Index: printing/backend/cups_helper.cc |
diff --git a/printing/backend/cups_helper.cc b/printing/backend/cups_helper.cc |
index 981a539ae4461123a6f979a166746dce757760ef..37cd0d870d64dca52b4cff22bde686c83faf1c89 100644 |
--- a/printing/backend/cups_helper.cc |
+++ b/printing/backend/cups_helper.cc |
@@ -33,6 +33,9 @@ const char kHighGray[] = "High.Gray"; |
const char kDuplex[] = "Duplex"; |
const char kDuplexNone[] = "None"; |
+const char kPageSize[] = "PageSize"; |
+ |
+const double kMicronsInPoint = 352.777778; |
Vitaly Buka (NO REVIEWS)
2014/06/12 19:32:51
kHundrethsMMPerInch / kPointsPerInch * 10
Aleksey Shlyapnikov
2014/06/12 21:21:12
Done.
|
#if !defined(OS_MACOSX) |
void ParseLpOptions(const base::FilePath& filepath, |
@@ -397,6 +400,34 @@ bool ParsePpdCapabilities( |
caps.color_model = cm_color; |
caps.bw_model = cm_black; |
+ if (ppd->num_sizes > 0 && ppd->sizes) { |
+ VLOG(1) << "Paper list size - " << ppd->num_sizes; |
+ ppd_option_t* paper_option = ppdFindOption(ppd, kPageSize); |
+ for (int i = 0; i < ppd->num_sizes; ++i) { |
+ gfx::Size paper_size_microns( |
+ static_cast<int>(ppd->sizes[i].width * kMicronsInPoint + 0.5), |
Vitaly Buka (NO REVIEWS)
2014/06/12 19:32:51
std::lrint ?
Aleksey Shlyapnikov
2014/06/12 21:21:12
I'd prefer predictable rounding behavior.
|
+ static_cast<int>(ppd->sizes[i].length * kMicronsInPoint + 0.5)); |
+ if (paper_size_microns.width() > 0 && paper_size_microns.height() > 0) { |
Vitaly Buka (NO REVIEWS)
2014/06/12 19:32:51
should we report continuous paper?
Aleksey Shlyapnikov
2014/06/12 21:21:12
And what print preview is supposed to do about it?
|
+ PrinterSemanticCapsAndDefaults::Paper paper; |
+ paper.size_um = paper_size_microns; |
+ paper.vendor_id = ppd->sizes[i].name; |
+ if (paper_option) { |
+ ppd_choice_t* paper_choice = |
+ ppdFindChoice(paper_option, ppd->sizes[i].name); |
+ // Human readable paper name should be UTF-8 encoded, but some PPDs |
+ // do not follow this standard. |
+ if (paper_choice && base::IsStringUTF8(paper_choice->text)) { |
+ paper.display_name = paper_choice->text; |
+ } |
+ } |
+ caps.papers.push_back(paper); |
+ if (i == 0 || ppd->sizes[i].marked) { |
+ caps.default_paper = paper; |
+ } |
+ } |
+ } |
+ } |
+ |
ppdClose(ppd); |
base::DeleteFile(ppd_file_path, false); |