[email protected] | b5cf844c | 2012-06-18 21:49:20 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "printing/printed_document.h" | ||||
6 | |||||
7 | #import <ApplicationServices/ApplicationServices.h> | ||||
8 | #import <CoreFoundation/CoreFoundation.h> | ||||
9 | |||||
10 | #include "base/logging.h" | ||||
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 11 | #include "printing/page_number.h" |
12 | #include "printing/printed_page.h" | ||||
13 | |||||
14 | namespace printing { | ||||
15 | |||||
16 | void PrintedDocument::RenderPrintedPage( | ||||
17 | const PrintedPage& page, gfx::NativeDrawingContext context) const { | ||||
18 | #ifndef NDEBUG | ||||
19 | { | ||||
20 | // Make sure the page is from our list. | ||||
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 21 | base::AutoLock lock(lock_); |
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 22 | DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); |
23 | } | ||||
24 | #endif | ||||
25 | |||||
[email protected] | 3b52c98 | 2010-09-27 20:40:36 | [diff] [blame] | 26 | DCHECK(context); |
27 | |||||
[email protected] | d91db11 | 2011-10-18 20:58:51 | [diff] [blame] | 28 | const PageSetup& page_setup(immutable_.settings_.page_setup_device_units()); |
[email protected] | a12552b0 | 2010-07-05 06:45:21 | [diff] [blame] | 29 | gfx::Rect content_area; |
30 | page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area); | ||||
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 31 | |
[email protected] | d91db11 | 2011-10-18 20:58:51 | [diff] [blame] | 32 | const Metafile* metafile = page.metafile(); |
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 33 | // Each Metafile is a one-page PDF, and pages use 1-based indexing. |
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 34 | const int page_number = 1; |
[email protected] | b5cf844c | 2012-06-18 21:49:20 | [diff] [blame] | 35 | struct Metafile::MacRenderPageParams params; |
36 | params.autorotate = true; | ||||
37 | metafile->RenderPage(page_number, context, content_area.ToCGRect(), params); | ||||
[email protected] | e059878 | 2010-10-07 22:01:52 | [diff] [blame] | 38 | } |
39 | |||||
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 40 | } // namespace printing |