[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 5 | #ifndef PRINTING_PRINTED_PAGE_H_ |
6 | #define PRINTING_PRINTED_PAGE_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
dcheng | c3df9ba | 2016-04-07 23:09:32 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
avi | 126e93c | 2015-12-21 21:48:16 | [diff] [blame] | 10 | #include "base/macros.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 12 | #include "printing/metafile.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 13 | #include "ui/gfx/geometry/rect.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 14 | #include "ui/gfx/geometry/size.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | |
16 | namespace printing { | ||||
17 | |||||
18 | // Contains the data to reproduce a printed page, either on screen or on | ||||
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 19 | // paper. Once created, this object is immutable. It has no reference to the |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | // PrintedDocument containing this page. |
21 | // Note: May be accessed from many threads at the same time. This is an non | ||||
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 22 | // issue since this object is immutable. The reason is that a page may be |
23 | // printed and be displayed at the same time. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 24 | class PRINTING_EXPORT PrintedPage |
25 | : public base::RefCountedThreadSafe<PrintedPage> { | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 26 | public: |
27 | PrintedPage(int page_number, | ||||
dcheng | c3df9ba | 2016-04-07 23:09:32 | [diff] [blame] | 28 | std::unique_ptr<MetafilePlayer> metafile, |
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 29 | const gfx::Size& page_size, |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 30 | const gfx::Rect& page_content_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | |
32 | // Getters | ||||
33 | int page_number() const { return page_number_; } | ||||
vitalybuka | 5d129058 | 2014-09-12 09:19:59 | [diff] [blame] | 34 | const MetafilePlayer* metafile() const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | const gfx::Size& page_size() const { return page_size_; } |
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 36 | const gfx::Rect& page_content_rect() const { return page_content_rect_; } |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 37 | #if defined(OS_WIN) |
pkasting | 46a6291 | 2014-10-09 21:30:00 | [diff] [blame] | 38 | void set_shrink_factor(float shrink_factor) { |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 39 | shrink_factor_ = shrink_factor; |
40 | } | ||||
pkasting | 46a6291 | 2014-10-09 21:30:00 | [diff] [blame] | 41 | float shrink_factor() const { return shrink_factor_; } |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 42 | #endif // OS_WIN |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 43 | |
[email protected] | a12552b0 | 2010-07-05 06:45:21 | [diff] [blame] | 44 | // Get page content rect adjusted based on |
45 | // http://dev.w3.org/csswg/css3-page/#positioning-page-box | ||||
46 | void GetCenteredPageContentRect(const gfx::Size& paper_size, | ||||
47 | gfx::Rect* content_rect) const; | ||||
48 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 49 | private: |
[email protected] | 877d55d | 2009-11-05 21:53:08 | [diff] [blame] | 50 | friend class base::RefCountedThreadSafe<PrintedPage>; |
51 | |||||
52 | ~PrintedPage(); | ||||
53 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 54 | // Page number inside the printed document. |
55 | const int page_number_; | ||||
56 | |||||
57 | // Actual paint data. | ||||
dcheng | c3df9ba | 2016-04-07 23:09:32 | [diff] [blame] | 58 | const std::unique_ptr<MetafilePlayer> metafile_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 59 | |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 60 | #if defined(OS_WIN) |
61 | // Shrink done in comparison to desired_dpi. | ||||
pkasting | 46a6291 | 2014-10-09 21:30:00 | [diff] [blame] | 62 | float shrink_factor_; |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 63 | #endif // OS_WIN |
64 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 65 | // The physical page size. To support multiple page formats inside on print |
66 | // job. | ||||
67 | const gfx::Size page_size_; | ||||
68 | |||||
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 69 | // The printable area of the page. |
70 | const gfx::Rect page_content_rect_; | ||||
71 | |||||
[email protected] | 5930cb6 | 2009-12-08 02:04:22 | [diff] [blame] | 72 | DISALLOW_COPY_AND_ASSIGN(PrintedPage); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 73 | }; |
74 | |||||
75 | } // namespace printing | ||||
76 | |||||
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 77 | #endif // PRINTING_PRINTED_PAGE_H_ |