[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 | |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 8 | #include "base/memory/ref_counted.h" |
9 | #include "base/memory/scoped_ptr.h" | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 10 | #include "printing/metafile.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 11 | #include "ui/gfx/rect.h" |
12 | #include "ui/gfx/size.h" | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
14 | namespace printing { | ||||
15 | |||||
16 | // Contains the data to reproduce a printed page, either on screen or on | ||||
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 17 | // paper. Once created, this object is immutable. It has no reference to the |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 18 | // PrintedDocument containing this page. |
19 | // 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] | 20 | // issue since this object is immutable. The reason is that a page may be |
21 | // printed and be displayed at the same time. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 22 | class PRINTING_EXPORT PrintedPage |
23 | : public base::RefCountedThreadSafe<PrintedPage> { | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | public: |
25 | PrintedPage(int page_number, | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 26 | Metafile* metafile, |
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 27 | const gfx::Size& page_size, |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 28 | const gfx::Rect& page_content_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | |
30 | // Getters | ||||
31 | int page_number() const { return page_number_; } | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 32 | const Metafile* metafile() const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | const gfx::Size& page_size() const { return page_size_; } |
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 34 | const gfx::Rect& page_content_rect() const { return page_content_rect_; } |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 35 | #if defined(OS_WIN) |
36 | void set_shrink_factor(double shrink_factor) { | ||||
37 | shrink_factor_ = shrink_factor; | ||||
38 | } | ||||
[email protected] | 732b813 | 2012-01-10 23:17:32 | [diff] [blame] | 39 | double shrink_factor() const { return shrink_factor_; } |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 40 | #endif // OS_WIN |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | |
[email protected] | a12552b0 | 2010-07-05 06:45:21 | [diff] [blame] | 42 | // Get page content rect adjusted based on |
43 | // http://dev.w3.org/csswg/css3-page/#positioning-page-box | ||||
44 | void GetCenteredPageContentRect(const gfx::Size& paper_size, | ||||
45 | gfx::Rect* content_rect) const; | ||||
46 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | private: |
[email protected] | 877d55d | 2009-11-05 21:53:08 | [diff] [blame] | 48 | friend class base::RefCountedThreadSafe<PrintedPage>; |
49 | |||||
50 | ~PrintedPage(); | ||||
51 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 52 | // Page number inside the printed document. |
53 | const int page_number_; | ||||
54 | |||||
55 | // Actual paint data. | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 56 | const scoped_ptr<Metafile> metafile_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 57 | |
[email protected] | 9de1347a | 2014-06-12 09:49:08 | [diff] [blame] | 58 | #if defined(OS_WIN) |
59 | // Shrink done in comparison to desired_dpi. | ||||
60 | double shrink_factor_; | ||||
61 | #endif // OS_WIN | ||||
62 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 63 | // The physical page size. To support multiple page formats inside on print |
64 | // job. | ||||
65 | const gfx::Size page_size_; | ||||
66 | |||||
[email protected] | 40c7cfe | 2010-07-01 07:04:05 | [diff] [blame] | 67 | // The printable area of the page. |
68 | const gfx::Rect page_content_rect_; | ||||
69 | |||||
[email protected] | 5930cb6 | 2009-12-08 02:04:22 | [diff] [blame] | 70 | DISALLOW_COPY_AND_ASSIGN(PrintedPage); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 71 | }; |
72 | |||||
73 | } // namespace printing | ||||
74 | |||||
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 75 | #endif // PRINTING_PRINTED_PAGE_H_ |