Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: chrome/browser/printing/pdf_to_emf_converter.cc

Issue 2714073002: Eliminate PS printing edge cases (Closed)
Patch Set: Fix compile errors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/pdf_to_emf_converter.h" 5 #include "chrome/browser/printing/pdf_to_emf_converter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // release |file_| before returning. 357 // release |file_| before returning.
358 Emf emf; 358 Emf emf;
359 if (!LoadEmf(&emf)) { 359 if (!LoadEmf(&emf)) {
360 Close(); 360 Close();
361 return false; 361 return false;
362 } 362 }
363 363
364 { 364 {
365 // Ensure enumerator destruction before calling Close() below. 365 // Ensure enumerator destruction before calling Close() below.
366 Emf::Enumerator emf_enum(emf, nullptr, nullptr); 366 Emf::Enumerator emf_enum(emf, nullptr, nullptr);
367
368 // Check if postscript passthrough is supported. Use normal passthrough if
369 // it is not.
370 DWORD escape = POSTSCRIPT_PASSTHROUGH;
371 const char* ptr = reinterpret_cast<const char*>(&escape);
372 bool postscript_passthrough =
Lei Zhang 2017/02/25 03:03:35 int passthrough = ExtEscape(hdc, QUERYESCSUPPORT,
373 ExtEscape(hdc, QUERYESCSUPPORT, sizeof(escape), ptr, 0, nullptr) > 0;
374
367 for (const Emf::Record& record : emf_enum) { 375 for (const Emf::Record& record : emf_enum) {
368 auto* emf_record = record.record(); 376 auto* emf_record = record.record();
369 if (emf_record->iType != EMR_GDICOMMENT) 377 if (emf_record->iType != EMR_GDICOMMENT)
370 continue; 378 continue;
371 379
372 const EMRGDICOMMENT* comment = 380 const EMRGDICOMMENT* comment =
373 reinterpret_cast<const EMRGDICOMMENT*>(emf_record); 381 reinterpret_cast<const EMRGDICOMMENT*>(emf_record);
374 const char* data = reinterpret_cast<const char*>(comment->Data); 382 const char* data = reinterpret_cast<const char*>(comment->Data);
375 const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data); 383 const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data);
376 int ret = 384 int ret = 0;
377 ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr); 385 if (postscript_passthrough) {
386 ret =
387 ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
388 } else {
389 ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
390 }
378 DCHECK_EQ(*ptr, ret); 391 DCHECK_EQ(*ptr, ret);
379 } 392 }
380 } 393 }
381 Close(); 394 Close();
382 return true; 395 return true;
383 } 396 }
384 397
385 PdfConverterUtilityProcessHostClient::PdfConverterUtilityProcessHostClient( 398 PdfConverterUtilityProcessHostClient::PdfConverterUtilityProcessHostClient(
386 base::WeakPtr<PdfConverterImpl> converter, 399 base::WeakPtr<PdfConverterImpl> converter,
387 const PdfRenderSettings& settings) 400 const PdfRenderSettings& settings)
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 std::unique_ptr<PdfConverterImpl> converter = 653 std::unique_ptr<PdfConverterImpl> converter =
641 base::MakeUnique<PdfConverterImpl>(); 654 base::MakeUnique<PdfConverterImpl>();
642 converter->Start( 655 converter->Start(
643 new PdfConverterUtilityProcessHostClient(converter->GetWeakPtr(), 656 new PdfConverterUtilityProcessHostClient(converter->GetWeakPtr(),
644 conversion_settings), 657 conversion_settings),
645 data, start_callback); 658 data, start_callback);
646 return std::move(converter); 659 return std::move(converter);
647 } 660 }
648 661
649 } // namespace printing 662 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_job_worker.cc » ('j') | printing/print_settings_initializer_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698