blob: 5ab1c17633c1c554beb4f79d71229de78e613aa0 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]8ff1d422009-07-07 21:31:395#ifndef PRINTING_PRINTED_PAGE_H_
6#define PRINTING_PRINTED_PAGE_H_
initial.commit09911bf2008-07-26 23:55:297
dchengc3df9ba2016-04-07 23:09:328#include <memory>
9
avi126e93c2015-12-21 21:48:1610#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/ref_counted.h"
[email protected]7d7489902011-04-11 21:54:0612#include "printing/metafile.h"
tfarina3b0452d2014-12-31 15:20:0913#include "ui/gfx/geometry/rect.h"
tfarinaebe974f02015-01-03 04:25:3214#include "ui/gfx/geometry/size.h"
initial.commit09911bf2008-07-26 23:55:2915
16namespace printing {
17
18// Contains the data to reproduce a printed page, either on screen or on
[email protected]4ecd07452009-03-31 14:34:4319// paper. Once created, this object is immutable. It has no reference to the
initial.commit09911bf2008-07-26 23:55:2920// PrintedDocument containing this page.
21// Note: May be accessed from many threads at the same time. This is an non
[email protected]4ecd07452009-03-31 14:34:4322// 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]69f5b1e62011-09-01 06:34:0424class PRINTING_EXPORT PrintedPage
25 : public base::RefCountedThreadSafe<PrintedPage> {
initial.commit09911bf2008-07-26 23:55:2926 public:
27 PrintedPage(int page_number,
dchengc3df9ba2016-04-07 23:09:3228 std::unique_ptr<MetafilePlayer> metafile,
[email protected]40c7cfe2010-07-01 07:04:0529 const gfx::Size& page_size,
[email protected]9de1347a2014-06-12 09:49:0830 const gfx::Rect& page_content_rect);
initial.commit09911bf2008-07-26 23:55:2931
32 // Getters
33 int page_number() const { return page_number_; }
vitalybuka5d1290582014-09-12 09:19:5934 const MetafilePlayer* metafile() const;
initial.commit09911bf2008-07-26 23:55:2935 const gfx::Size& page_size() const { return page_size_; }
[email protected]40c7cfe2010-07-01 07:04:0536 const gfx::Rect& page_content_rect() const { return page_content_rect_; }
[email protected]9de1347a2014-06-12 09:49:0837#if defined(OS_WIN)
pkasting46a62912014-10-09 21:30:0038 void set_shrink_factor(float shrink_factor) {
[email protected]9de1347a2014-06-12 09:49:0839 shrink_factor_ = shrink_factor;
40 }
pkasting46a62912014-10-09 21:30:0041 float shrink_factor() const { return shrink_factor_; }
[email protected]9de1347a2014-06-12 09:49:0842#endif // OS_WIN
initial.commit09911bf2008-07-26 23:55:2943
[email protected]a12552b02010-07-05 06:45:2144 // 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.commit09911bf2008-07-26 23:55:2949 private:
[email protected]877d55d2009-11-05 21:53:0850 friend class base::RefCountedThreadSafe<PrintedPage>;
51
52 ~PrintedPage();
53
initial.commit09911bf2008-07-26 23:55:2954 // Page number inside the printed document.
55 const int page_number_;
56
57 // Actual paint data.
dchengc3df9ba2016-04-07 23:09:3258 const std::unique_ptr<MetafilePlayer> metafile_;
initial.commit09911bf2008-07-26 23:55:2959
[email protected]9de1347a2014-06-12 09:49:0860#if defined(OS_WIN)
61 // Shrink done in comparison to desired_dpi.
pkasting46a62912014-10-09 21:30:0062 float shrink_factor_;
[email protected]9de1347a2014-06-12 09:49:0863#endif // OS_WIN
64
initial.commit09911bf2008-07-26 23:55:2965 // The physical page size. To support multiple page formats inside on print
66 // job.
67 const gfx::Size page_size_;
68
[email protected]40c7cfe2010-07-01 07:04:0569 // The printable area of the page.
70 const gfx::Rect page_content_rect_;
71
[email protected]5930cb62009-12-08 02:04:2272 DISALLOW_COPY_AND_ASSIGN(PrintedPage);
initial.commit09911bf2008-07-26 23:55:2973};
74
75} // namespace printing
76
[email protected]8ff1d422009-07-07 21:31:3977#endif // PRINTING_PRINTED_PAGE_H_