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
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINTED_PAGE_H_
6 #define PRINTING_PRINTED_PAGE_H_
8 #include "base/ref_counted.h"
9 #include "base/scoped_ptr.h"
12 #include "printing/native_metafile.h"
16 // Contains the data to reproduce a printed page, either on screen or on
17 // paper. Once created, this object is immutable. It has no reference to the
18 // PrintedDocument containing this page.
19 // Note: May be accessed from many threads at the same time. This is an non
20 // issue since this object is immutable. The reason is that a page may be
21 // printed and be displayed at the same time.
22 class PrintedPage
: public base::RefCountedThreadSafe
<PrintedPage
> {
24 PrintedPage(int page_number
,
25 NativeMetafile
* native_metafile
,
26 const gfx::Size
& page_size
,
27 const gfx::Rect
& page_content_rect
,
28 bool has_visible_overlays
);
31 int page_number() const { return page_number_
; }
32 const NativeMetafile
* native_metafile() const;
33 const gfx::Size
& page_size() const { return page_size_
; }
34 const gfx::Rect
& page_content_rect() const { return page_content_rect_
; }
35 bool has_visible_overlays() const { return has_visible_overlays_
; }
37 // Get page content rect adjusted based on
38 // http://dev.w3.org/csswg/css3-page/#positioning-page-box
39 void GetCenteredPageContentRect(const gfx::Size
& paper_size
,
40 gfx::Rect
* content_rect
) const;
43 friend class base::RefCountedThreadSafe
<PrintedPage
>;
47 // Page number inside the printed document.
48 const int page_number_
;
51 const scoped_ptr
<NativeMetafile
> native_metafile_
;
53 // The physical page size. To support multiple page formats inside on print
55 const gfx::Size page_size_
;
57 // The printable area of the page.
58 const gfx::Rect page_content_rect_
;
60 // True if the overlays should be visible in this page.
61 bool has_visible_overlays_
;
63 DISALLOW_COPY_AND_ASSIGN(PrintedPage
);
66 } // namespace printing
68 #endif // PRINTING_PRINTED_PAGE_H_