| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/printing/win_printing_context.h" | 5 #include "chrome/browser/printing/win_printing_context.h" |
| 6 | 6 |
| 7 #include <winspool.h> | 7 #include <winspool.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 dialog_box_(NULL), | 145 dialog_box_(NULL), |
| 146 dialog_box_dismissed_(false), | 146 dialog_box_dismissed_(false), |
| 147 abort_printing_(false), | 147 abort_printing_(false), |
| 148 in_print_job_(false) { | 148 in_print_job_(false) { |
| 149 } | 149 } |
| 150 | 150 |
| 151 PrintingContext::~PrintingContext() { | 151 PrintingContext::~PrintingContext() { |
| 152 ResetSettings(); | 152 ResetSettings(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 PrintingContext::Result PrintingContext::AskUserForSettings(HWND window, | 155 PrintingContext::Result PrintingContext::AskUserForSettings( |
| 156 int max_pages) { | 156 HWND window, |
| 157 int max_pages, |
| 158 bool has_selection) { |
| 157 DCHECK(window); | 159 DCHECK(window); |
| 158 DCHECK(!in_print_job_); | 160 DCHECK(!in_print_job_); |
| 159 dialog_box_dismissed_ = false; | 161 dialog_box_dismissed_ = false; |
| 160 // Show the OS-dependent dialog box. | 162 // Show the OS-dependent dialog box. |
| 161 // If the user press | 163 // If the user press |
| 162 // - OK, the settings are reset and reinitialized with the new settings. OK is | 164 // - OK, the settings are reset and reinitialized with the new settings. OK is |
| 163 // returned. | 165 // returned. |
| 164 // - Apply then Cancel, the settings are reset and reinitialized with the new | 166 // - Apply then Cancel, the settings are reset and reinitialized with the new |
| 165 // settings. CANCEL is returned. | 167 // settings. CANCEL is returned. |
| 166 // - Cancel, the settings are not changed, the previous setting, if it was | 168 // - Cancel, the settings are not changed, the previous setting, if it was |
| 167 // initialized before, are kept. CANCEL is returned. | 169 // initialized before, are kept. CANCEL is returned. |
| 168 // On failure, the settings are reset and FAILED is returned. | 170 // On failure, the settings are reset and FAILED is returned. |
| 169 PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) }; | 171 PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) }; |
| 170 dialog_options.hwndOwner = window; | 172 dialog_options.hwndOwner = window; |
| 171 // Disables the Current Page and Selection radio buttons since WebKit can't | 173 // Disable options we don't support currently. |
| 172 // print a part of the webpage and we don't know which page is the current | |
| 173 // one. | |
| 174 // TODO(maruel): Reuse the previously loaded settings! | 174 // TODO(maruel): Reuse the previously loaded settings! |
| 175 dialog_options.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | | 175 dialog_options.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | |
| 176 PD_NOSELECTION | PD_NOCURRENTPAGE | PD_HIDEPRINTTOFILE; | 176 PD_NOCURRENTPAGE | PD_HIDEPRINTTOFILE; |
| 177 if (!has_selection) |
| 178 dialog_options.Flags |= PD_NOSELECTION; |
| 179 |
| 177 PRINTPAGERANGE ranges[32]; | 180 PRINTPAGERANGE ranges[32]; |
| 178 dialog_options.nStartPage = START_PAGE_GENERAL; | 181 dialog_options.nStartPage = START_PAGE_GENERAL; |
| 179 if (max_pages) { | 182 if (max_pages) { |
| 180 // Default initialize to print all the pages. | 183 // Default initialize to print all the pages. |
| 181 memset(ranges, 0, sizeof(ranges)); | 184 memset(ranges, 0, sizeof(ranges)); |
| 182 ranges[0].nFromPage = 1; | 185 ranges[0].nFromPage = 1; |
| 183 ranges[0].nToPage = max_pages; | 186 ranges[0].nToPage = max_pages; |
| 184 dialog_options.nPageRanges = 1; | 187 dialog_options.nPageRanges = 1; |
| 185 dialog_options.nMaxPageRanges = arraysize(ranges); | 188 dialog_options.nMaxPageRanges = arraysize(ranges); |
| 186 dialog_options.nMaxPage = max_pages; | 189 dialog_options.nMaxPage = max_pages; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 249 |
| 247 #ifndef NDEBUG | 250 #ifndef NDEBUG |
| 248 page_number_ = -1; | 251 page_number_ = -1; |
| 249 #endif | 252 #endif |
| 250 } | 253 } |
| 251 | 254 |
| 252 PrintingContext::Result PrintingContext::NewDocument( | 255 PrintingContext::Result PrintingContext::NewDocument( |
| 253 const std::wstring& document_name) { | 256 const std::wstring& document_name) { |
| 254 DCHECK(!in_print_job_); | 257 DCHECK(!in_print_job_); |
| 255 if (!hdc_) | 258 if (!hdc_) |
| 256 return OnErrror(); | 259 return OnError(); |
| 257 | 260 |
| 258 // Set the flag used by the AbortPrintJob dialog procedure. | 261 // Set the flag used by the AbortPrintJob dialog procedure. |
| 259 abort_printing_ = false; | 262 abort_printing_ = false; |
| 260 | 263 |
| 261 in_print_job_ = true; | 264 in_print_job_ = true; |
| 262 | 265 |
| 263 // Register the application's AbortProc function with GDI. | 266 // Register the application's AbortProc function with GDI. |
| 264 if (SP_ERROR == SetAbortProc(hdc_, &AbortProc)) | 267 if (SP_ERROR == SetAbortProc(hdc_, &AbortProc)) |
| 265 return OnErrror(); | 268 return OnError(); |
| 266 | 269 |
| 267 DOCINFO di = { sizeof(DOCINFO) }; | 270 DOCINFO di = { sizeof(DOCINFO) }; |
| 268 di.lpszDocName = document_name.c_str(); | 271 di.lpszDocName = document_name.c_str(); |
| 269 | 272 |
| 270 // Is there a debug dump directory specified? If so, force to print to a file. | 273 // Is there a debug dump directory specified? If so, force to print to a file. |
| 271 std::wstring debug_dump_path; | 274 std::wstring debug_dump_path; |
| 272 if (!g_browser_process || !g_browser_process->print_job_manager()) { | 275 if (!g_browser_process || !g_browser_process->print_job_manager()) { |
| 273 // Happens only inside a unit test. | 276 // Happens only inside a unit test. |
| 274 debug_dump_path = L"."; | 277 debug_dump_path = L"."; |
| 275 } else { | 278 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 290 file_util::ReplaceIllegalCharacters(&filename, '_'); | 293 file_util::ReplaceIllegalCharacters(&filename, '_'); |
| 291 file_util::AppendToPath(&debug_dump_path, filename); | 294 file_util::AppendToPath(&debug_dump_path, filename); |
| 292 di.lpszOutput = debug_dump_path.c_str(); | 295 di.lpszOutput = debug_dump_path.c_str(); |
| 293 } | 296 } |
| 294 | 297 |
| 295 DCHECK_EQ(MessageLoop::current()->NestableTasksAllowed(), false); | 298 DCHECK_EQ(MessageLoop::current()->NestableTasksAllowed(), false); |
| 296 // Begin a print job by calling the StartDoc function. | 299 // Begin a print job by calling the StartDoc function. |
| 297 // NOTE: StartDoc() starts a message loop. That causes a lot of problems with | 300 // NOTE: StartDoc() starts a message loop. That causes a lot of problems with |
| 298 // IPC. Make sure recursive task processing is disabled. | 301 // IPC. Make sure recursive task processing is disabled. |
| 299 if (StartDoc(hdc_, &di) <= 0) | 302 if (StartDoc(hdc_, &di) <= 0) |
| 300 return OnErrror(); | 303 return OnError(); |
| 301 | 304 |
| 302 #ifndef NDEBUG | 305 #ifndef NDEBUG |
| 303 page_number_ = 0; | 306 page_number_ = 0; |
| 304 #endif | 307 #endif |
| 305 return OK; | 308 return OK; |
| 306 } | 309 } |
| 307 | 310 |
| 308 PrintingContext::Result PrintingContext::NewPage() { | 311 PrintingContext::Result PrintingContext::NewPage() { |
| 309 if (abort_printing_) | 312 if (abort_printing_) |
| 310 return CANCEL; | 313 return CANCEL; |
| 311 DCHECK(in_print_job_); | 314 DCHECK(in_print_job_); |
| 312 | 315 |
| 313 // Inform the driver that the application is about to begin sending data. | 316 // Inform the driver that the application is about to begin sending data. |
| 314 if (StartPage(hdc_) <= 0) | 317 if (StartPage(hdc_) <= 0) |
| 315 return OnErrror(); | 318 return OnError(); |
| 316 | 319 |
| 317 #ifndef NDEBUG | 320 #ifndef NDEBUG |
| 318 ++page_number_; | 321 ++page_number_; |
| 319 #endif | 322 #endif |
| 320 | 323 |
| 321 return OK; | 324 return OK; |
| 322 } | 325 } |
| 323 | 326 |
| 324 PrintingContext::Result PrintingContext::PageDone() { | 327 PrintingContext::Result PrintingContext::PageDone() { |
| 325 if (abort_printing_) | 328 if (abort_printing_) |
| 326 return CANCEL; | 329 return CANCEL; |
| 327 DCHECK(in_print_job_); | 330 DCHECK(in_print_job_); |
| 328 | 331 |
| 329 if (EndPage(hdc_) <= 0) | 332 if (EndPage(hdc_) <= 0) |
| 330 return OnErrror(); | 333 return OnError(); |
| 331 return OK; | 334 return OK; |
| 332 } | 335 } |
| 333 | 336 |
| 334 PrintingContext::Result PrintingContext::DocumentDone() { | 337 PrintingContext::Result PrintingContext::DocumentDone() { |
| 335 if (abort_printing_) | 338 if (abort_printing_) |
| 336 return CANCEL; | 339 return CANCEL; |
| 337 DCHECK(in_print_job_); | 340 DCHECK(in_print_job_); |
| 338 | 341 |
| 339 // Inform the driver that document has ended. | 342 // Inform the driver that document has ended. |
| 340 if (EndDoc(hdc_) <= 0) | 343 if (EndDoc(hdc_) <= 0) |
| 341 return OnErrror(); | 344 return OnError(); |
| 342 | 345 |
| 343 ResetSettings(); | 346 ResetSettings(); |
| 344 return OK; | 347 return OK; |
| 345 } | 348 } |
| 346 | 349 |
| 347 void PrintingContext::Cancel() { | 350 void PrintingContext::Cancel() { |
| 348 abort_printing_ = true; | 351 abort_printing_ = true; |
| 349 in_print_job_ = false; | 352 in_print_job_ = false; |
| 350 if (hdc_) | 353 if (hdc_) |
| 351 CancelDC(hdc_); | 354 CancelDC(hdc_); |
| 352 DismissDialog(); | 355 DismissDialog(); |
| 353 } | 356 } |
| 354 | 357 |
| 355 void PrintingContext::DismissDialog() { | 358 void PrintingContext::DismissDialog() { |
| 356 if (dialog_box_) { | 359 if (dialog_box_) { |
| 357 DestroyWindow(dialog_box_); | 360 DestroyWindow(dialog_box_); |
| 358 dialog_box_dismissed_ = true; | 361 dialog_box_dismissed_ = true; |
| 359 } | 362 } |
| 360 } | 363 } |
| 361 | 364 |
| 362 PrintingContext::Result PrintingContext::OnErrror() { | 365 PrintingContext::Result PrintingContext::OnError() { |
| 363 // This will close hdc_ and clear settings_. | 366 // This will close hdc_ and clear settings_. |
| 364 ResetSettings(); | 367 ResetSettings(); |
| 365 return abort_printing_ ? CANCEL : FAILED; | 368 return abort_printing_ ? CANCEL : FAILED; |
| 366 } | 369 } |
| 367 | 370 |
| 368 // static | 371 // static |
| 369 BOOL PrintingContext::AbortProc(HDC hdc, int nCode) { | 372 BOOL PrintingContext::AbortProc(HDC hdc, int nCode) { |
| 370 if (nCode) { | 373 if (nCode) { |
| 371 // TODO(maruel): Need a way to find the right instance to set. Should | 374 // TODO(maruel): Need a way to find the right instance to set. Should |
| 372 // leverage PrintJobManager here? | 375 // leverage PrintJobManager here? |
| 373 // abort_printing_ = true; | 376 // abort_printing_ = true; |
| 374 } | 377 } |
| 375 return true; | 378 return true; |
| 376 } | 379 } |
| 377 | 380 |
| 378 bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode, | 381 bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode, |
| 379 const std::wstring& new_device_name, | 382 const std::wstring& new_device_name, |
| 380 const PRINTPAGERANGE* ranges, | 383 const PRINTPAGERANGE* ranges, |
| 381 int number_ranges) { | 384 int number_ranges, |
| 385 bool selection_only) { |
| 382 skia::PlatformDeviceWin::InitializeDC(hdc_); | 386 skia::PlatformDeviceWin::InitializeDC(hdc_); |
| 383 DCHECK(GetDeviceCaps(hdc_, CLIPCAPS)); | 387 DCHECK(GetDeviceCaps(hdc_, CLIPCAPS)); |
| 384 DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_STRETCHDIB); | 388 DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_STRETCHDIB); |
| 385 DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_BITMAP64); | 389 DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_BITMAP64); |
| 386 // Some printers don't advertise these. | 390 // Some printers don't advertise these. |
| 387 // DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_SCALING); | 391 // DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_SCALING); |
| 388 // DCHECK(GetDeviceCaps(hdc_, SHADEBLENDCAPS) & SB_CONST_ALPHA); | 392 // DCHECK(GetDeviceCaps(hdc_, SHADEBLENDCAPS) & SB_CONST_ALPHA); |
| 389 // DCHECK(GetDeviceCaps(hdc_, SHADEBLENDCAPS) & SB_PIXEL_ALPHA); | 393 // DCHECK(GetDeviceCaps(hdc_, SHADEBLENDCAPS) & SB_PIXEL_ALPHA); |
| 390 | 394 |
| 391 // StretchDIBits() support is needed for printing. | 395 // StretchDIBits() support is needed for printing. |
| 392 if (!(GetDeviceCaps(hdc_, RASTERCAPS) & RC_STRETCHDIB) || | 396 if (!(GetDeviceCaps(hdc_, RASTERCAPS) & RC_STRETCHDIB) || |
| 393 !(GetDeviceCaps(hdc_, RASTERCAPS) & RC_BITMAP64)) { | 397 !(GetDeviceCaps(hdc_, RASTERCAPS) & RC_BITMAP64)) { |
| 394 NOTREACHED(); | 398 NOTREACHED(); |
| 395 ResetSettings(); | 399 ResetSettings(); |
| 396 return false; | 400 return false; |
| 397 } | 401 } |
| 398 | 402 |
| 399 DCHECK(!in_print_job_); | 403 DCHECK(!in_print_job_); |
| 400 DCHECK(hdc_); | 404 DCHECK(hdc_); |
| 401 // Convert the PRINTPAGERANGE array to a PrintSettings::PageRanges vector. | 405 // Convert the PRINTPAGERANGE array to a PrintSettings::PageRanges vector. |
| 402 PageRanges ranges_vector; | 406 PageRanges ranges_vector; |
| 403 ranges_vector.reserve(number_ranges); | 407 ranges_vector.reserve(number_ranges); |
| 404 for (int i = 0; i < number_ranges; ++i) { | 408 for (int i = 0; i < number_ranges; ++i) { |
| 405 PageRange range; | 409 PageRange range; |
| 406 // Transfert from 1-based to 0-based. | 410 // Transfert from 1-based to 0-based. |
| 407 range.from = ranges[i].nFromPage - 1; | 411 range.from = ranges[i].nFromPage - 1; |
| 408 range.to = ranges[i].nToPage - 1; | 412 range.to = ranges[i].nToPage - 1; |
| 409 ranges_vector.push_back(range); | 413 ranges_vector.push_back(range); |
| 410 } | 414 } |
| 411 settings_.Init(hdc_, dev_mode, ranges_vector, new_device_name); | 415 settings_.Init(hdc_, |
| 416 dev_mode, |
| 417 ranges_vector, |
| 418 new_device_name, |
| 419 selection_only); |
| 412 return true; | 420 return true; |
| 413 } | 421 } |
| 414 | 422 |
| 415 bool PrintingContext::GetPrinterSettings(HANDLE printer, | 423 bool PrintingContext::GetPrinterSettings(HANDLE printer, |
| 416 const std::wstring& device_name) { | 424 const std::wstring& device_name) { |
| 417 DCHECK(!in_print_job_); | 425 DCHECK(!in_print_job_); |
| 418 scoped_array<uint8> buffer; | 426 scoped_array<uint8> buffer; |
| 419 | 427 |
| 420 // A PRINTER_INFO_9 structure specifying the per-user default printer | 428 // A PRINTER_INFO_9 structure specifying the per-user default printer |
| 421 // settings. | 429 // settings. |
| 422 GetPrinterHelper(printer, 9, &buffer); | 430 GetPrinterHelper(printer, 9, &buffer); |
| 423 if (buffer.get()) { | 431 if (buffer.get()) { |
| 424 PRINTER_INFO_9* info_9 = reinterpret_cast<PRINTER_INFO_9*>(buffer.get()); | 432 PRINTER_INFO_9* info_9 = reinterpret_cast<PRINTER_INFO_9*>(buffer.get()); |
| 425 if (info_9->pDevMode != NULL) { | 433 if (info_9->pDevMode != NULL) { |
| 426 if (!AllocateContext(device_name, info_9->pDevMode)) { | 434 if (!AllocateContext(device_name, info_9->pDevMode)) { |
| 427 ResetSettings(); | 435 ResetSettings(); |
| 428 return false; | 436 return false; |
| 429 } | 437 } |
| 430 return InitializeSettings(*info_9->pDevMode, device_name, NULL, 0); | 438 return InitializeSettings(*info_9->pDevMode, device_name, NULL, 0, false); |
| 431 } | 439 } |
| 432 buffer.reset(); | 440 buffer.reset(); |
| 433 } | 441 } |
| 434 | 442 |
| 435 // A PRINTER_INFO_8 structure specifying the global default printer settings. | 443 // A PRINTER_INFO_8 structure specifying the global default printer settings. |
| 436 GetPrinterHelper(printer, 8, &buffer); | 444 GetPrinterHelper(printer, 8, &buffer); |
| 437 if (buffer.get()) { | 445 if (buffer.get()) { |
| 438 PRINTER_INFO_8* info_8 = reinterpret_cast<PRINTER_INFO_8*>(buffer.get()); | 446 PRINTER_INFO_8* info_8 = reinterpret_cast<PRINTER_INFO_8*>(buffer.get()); |
| 439 if (info_8->pDevMode != NULL) { | 447 if (info_8->pDevMode != NULL) { |
| 440 if (!AllocateContext(device_name, info_8->pDevMode)) { | 448 if (!AllocateContext(device_name, info_8->pDevMode)) { |
| 441 ResetSettings(); | 449 ResetSettings(); |
| 442 return false; | 450 return false; |
| 443 } | 451 } |
| 444 return InitializeSettings(*info_8->pDevMode, device_name, NULL, 0); | 452 return InitializeSettings(*info_8->pDevMode, device_name, NULL, 0, false); |
| 445 } | 453 } |
| 446 buffer.reset(); | 454 buffer.reset(); |
| 447 } | 455 } |
| 448 | 456 |
| 449 // A PRINTER_INFO_2 structure specifying the driver's default printer | 457 // A PRINTER_INFO_2 structure specifying the driver's default printer |
| 450 // settings. | 458 // settings. |
| 451 GetPrinterHelper(printer, 2, &buffer); | 459 GetPrinterHelper(printer, 2, &buffer); |
| 452 if (buffer.get()) { | 460 if (buffer.get()) { |
| 453 PRINTER_INFO_2* info_2 = reinterpret_cast<PRINTER_INFO_2*>(buffer.get()); | 461 PRINTER_INFO_2* info_2 = reinterpret_cast<PRINTER_INFO_2*>(buffer.get()); |
| 454 if (info_2->pDevMode != NULL) { | 462 if (info_2->pDevMode != NULL) { |
| 455 if (!AllocateContext(device_name, info_2->pDevMode)) { | 463 if (!AllocateContext(device_name, info_2->pDevMode)) { |
| 456 ResetSettings(); | 464 ResetSettings(); |
| 457 return false; | 465 return false; |
| 458 } | 466 } |
| 459 return InitializeSettings(*info_2->pDevMode, device_name, NULL, 0); | 467 return InitializeSettings(*info_2->pDevMode, device_name, NULL, 0, false); |
| 460 } | 468 } |
| 461 buffer.reset(); | 469 buffer.reset(); |
| 462 } | 470 } |
| 463 // Failed to retrieve the printer settings. | 471 // Failed to retrieve the printer settings. |
| 464 ResetSettings(); | 472 ResetSettings(); |
| 465 return false; | 473 return false; |
| 466 } | 474 } |
| 467 | 475 |
| 468 bool PrintingContext::AllocateContext(const std::wstring& printer_name, | 476 bool PrintingContext::AllocateContext(const std::wstring& printer_name, |
| 469 const DEVMODE* dev_mode) { | 477 const DEVMODE* dev_mode) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 496 reinterpret_cast<const wchar_t*>( | 504 reinterpret_cast<const wchar_t*>( |
| 497 reinterpret_cast<const wchar_t*>(dev_names) + | 505 reinterpret_cast<const wchar_t*>(dev_names) + |
| 498 dev_names->wDeviceOffset); | 506 dev_names->wDeviceOffset); |
| 499 GlobalUnlock(dialog_options.hDevNames); | 507 GlobalUnlock(dialog_options.hDevNames); |
| 500 } | 508 } |
| 501 } | 509 } |
| 502 | 510 |
| 503 bool success = false; | 511 bool success = false; |
| 504 if (dev_mode && !device_name.empty()) { | 512 if (dev_mode && !device_name.empty()) { |
| 505 hdc_ = dialog_options.hDC; | 513 hdc_ = dialog_options.hDC; |
| 514 PRINTPAGERANGE* page_ranges = NULL; |
| 515 DWORD num_page_ranges = 0; |
| 516 bool print_selection_only = false; |
| 506 if (dialog_options.Flags & PD_PAGENUMS) { | 517 if (dialog_options.Flags & PD_PAGENUMS) { |
| 507 success = InitializeSettings(*dev_mode, | 518 page_ranges = dialog_options.lpPageRanges; |
| 508 device_name, | 519 num_page_ranges = dialog_options.nPageRanges; |
| 509 dialog_options.lpPageRanges, | |
| 510 dialog_options.nPageRanges); | |
| 511 } else { | |
| 512 success = InitializeSettings(*dev_mode, device_name, NULL, 0); | |
| 513 } | 520 } |
| 521 if (dialog_options.Flags & PD_SELECTION) { |
| 522 print_selection_only = true; |
| 523 } |
| 524 success = InitializeSettings(*dev_mode, |
| 525 device_name, |
| 526 dialog_options.lpPageRanges, |
| 527 dialog_options.nPageRanges, |
| 528 print_selection_only); |
| 514 } | 529 } |
| 515 | 530 |
| 516 if (!success && dialog_options.hDC) { | 531 if (!success && dialog_options.hDC) { |
| 517 DeleteDC(dialog_options.hDC); | 532 DeleteDC(dialog_options.hDC); |
| 518 hdc_ = NULL; | 533 hdc_ = NULL; |
| 519 } | 534 } |
| 520 | 535 |
| 521 if (dev_mode) { | 536 if (dev_mode) { |
| 522 GlobalUnlock(dialog_options.hDevMode); | 537 GlobalUnlock(dialog_options.hDevMode); |
| 523 } | 538 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 reinterpret_cast<const wchar_t*>( | 582 reinterpret_cast<const wchar_t*>( |
| 568 reinterpret_cast<const wchar_t*>(dev_names) + | 583 reinterpret_cast<const wchar_t*>(dev_names) + |
| 569 dev_names->wDeviceOffset); | 584 dev_names->wDeviceOffset); |
| 570 GlobalUnlock(dialog_options.hDevNames); | 585 GlobalUnlock(dialog_options.hDevNames); |
| 571 } | 586 } |
| 572 } | 587 } |
| 573 | 588 |
| 574 bool success = false; | 589 bool success = false; |
| 575 if (dev_mode && !device_name.empty()) { | 590 if (dev_mode && !device_name.empty()) { |
| 576 hdc_ = dialog_options.hDC; | 591 hdc_ = dialog_options.hDC; |
| 577 success = InitializeSettings(*dev_mode, device_name, NULL, 0); | 592 success = InitializeSettings(*dev_mode, device_name, NULL, 0, false); |
| 578 } | 593 } |
| 579 | 594 |
| 580 if (!success && dialog_options.hDC) { | 595 if (!success && dialog_options.hDC) { |
| 581 DeleteDC(dialog_options.hDC); | 596 DeleteDC(dialog_options.hDC); |
| 582 hdc_ = NULL; | 597 hdc_ = NULL; |
| 583 } | 598 } |
| 584 | 599 |
| 585 if (dev_mode) { | 600 if (dev_mode) { |
| 586 GlobalUnlock(dialog_options.hDevMode); | 601 GlobalUnlock(dialog_options.hDevMode); |
| 587 } | 602 } |
| 588 | 603 |
| 589 if (dialog_options.hDevMode != NULL) | 604 if (dialog_options.hDevMode != NULL) |
| 590 GlobalFree(dialog_options.hDevMode); | 605 GlobalFree(dialog_options.hDevMode); |
| 591 if (dialog_options.hDevNames != NULL) | 606 if (dialog_options.hDevNames != NULL) |
| 592 GlobalFree(dialog_options.hDevNames); | 607 GlobalFree(dialog_options.hDevNames); |
| 593 | 608 |
| 594 return hdc_ ? OK : FAILED; | 609 return hdc_ ? OK : FAILED; |
| 595 } | 610 } |
| 596 | 611 |
| 597 } // namespace printing | 612 } // namespace printing |
| OLD | NEW |