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 #include "printing/printed_page.h"
9 PrintedPage::PrintedPage(int page_number
,
10 NativeMetafile
* native_metafile
,
11 const gfx::Size
& page_size
,
12 const gfx::Rect
& page_content_rect
,
13 bool has_visible_overlays
)
14 : page_number_(page_number
),
15 native_metafile_(native_metafile
),
16 page_size_(page_size
),
17 page_content_rect_(page_content_rect
),
18 has_visible_overlays_(has_visible_overlays
) {
21 PrintedPage::~PrintedPage() {
24 const NativeMetafile
* PrintedPage::native_metafile() const {
25 return native_metafile_
.get();
28 void PrintedPage::GetCenteredPageContentRect(
29 const gfx::Size
& paper_size
, gfx::Rect
* content_rect
) const {
30 *content_rect
= page_content_rect();
31 if (paper_size
.width() > page_size().width()) {
32 int diff
= paper_size
.width() - page_size().width();
33 content_rect
->set_x(content_rect
->x() + diff
/ 2);
35 if (paper_size
.height() > page_size().height()) {
36 int diff
= paper_size
.height() - page_size().height();
37 content_rect
->set_y(content_rect
->y() + diff
/ 2);
41 } // namespace printing