Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: printing/pdf_transform.h

Issue 1421493002: Printing: Move some printing code out of pdf/ and into printing/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef PRINTING_PDF_TRANSFORM_H_
6 #define PRINTING_PDF_TRANSFORM_H_
7
8 #include "printing/printing_export.h"
9
10 namespace gfx {
11 class Rect;
12 }
13
14 namespace printing {
15
16 // A rect struct for use with FPDF bounding box functions.
17 // With PDFs, origin is bottom-left.
18 struct PRINTING_EXPORT ClipBox {
19 float left;
20 float right;
21 float top;
22 float bottom;
23 };
24
25 // Calculate the scale factor between |content_rect| and a page of size
26 // |src_width| x |src_height|.
27 //
28 // |content_rect| specifies the printable area of the destination page, with
29 // origin at left-bottom. Values are in points.
30 // |src_width| specifies the source page width in points.
31 // |src_height| specifies the source page height in points.
32 // |rotated| True if source page is rotated 90 degree or 270 degree.
33 PRINTING_EXPORT double CalculateScaleFactor(const gfx::Rect& content_rect,
34 double src_width,
35 double src_height,
36 bool rotated);
37
38 // Make the default size to be letter size (8.5" X 11"). We are just following
39 // the PDFium way of handling these corner cases. PDFium always consider
40 // US-Letter as the default page size.
41 PRINTING_EXPORT void SetDefaultClipBox(bool rotated, ClipBox* clip_box);
42
43 // Set the media box and/or crop box as needed. If both boxes are there, then
44 // nothing needs to be done. If one box is missing, then fill it with the value
45 // from the other box. If both boxes are missing, then they both get the default
46 // value from SetDefaultClipBox(), based on |rotated|.
47 PRINTING_EXPORT void CalculateMediaBoxAndCropBox(bool rotated,
48 bool has_media_box,
49 bool has_crop_box,
50 printing::ClipBox* media_box,
51 printing::ClipBox* crop_box);
52
53 // Compute source clip box boundaries based on the crop box / media box of
54 // source page and scale factor.
55 // Returns the computed source clip box values.
56 //
57 // |media_box| The PDF's media box.
58 // |crop_box| The PDF's crop box.
59 PRINTING_EXPORT ClipBox CalculateClipBoxBoundary(const ClipBox& media_box,
60 const ClipBox& crop_box);
61
62 // Scale |box| by |scale_factor|.
63 PRINTING_EXPORT void ScaleClipBox(double scale_factor, ClipBox* box);
64
65 // Calculate the clip box translation offset for a page that does need to be
66 // scaled. All parameters are in points.
67 //
68 // |content_rect| specifies the printable area of the destination page, with
69 // origin at left-bottom.
70 // |source_clip_box| specifies the source clip box positions, relative to
71 // origin at left-bottom.
72 // |offset_x| and |offset_y| will contain the final translation offsets for the
73 // source clip box, relative to origin at left-bottom.
74 PRINTING_EXPORT void CalculateScaledClipBoxOffset(
75 const gfx::Rect& content_rect,
76 const ClipBox& source_clip_box,
77 double* offset_x,
78 double* offset_y);
79
80 // Calculate the clip box offset for a page that does not need to be scaled.
81 // All parameters are in points.
82 //
83 // |content_rect| specifies the printable area of the destination page, with
84 // origin at left-bottom.
85 // |rotation| specifies the source page rotation values which are N / 90
86 // degrees.
87 // |page_width| specifies the screen destination page width.
88 // |page_height| specifies the screen destination page height.
89 // |source_clip_box| specifies the source clip box positions, relative to origin
90 // at left-bottom.
91 // |offset_x| and |offset_y| will contain the final translation offsets for the
92 // source clip box, relative to origin at left-bottom.
93 PRINTING_EXPORT void CalculateNonScaledClipBoxOffset(
94 const gfx::Rect& content_rect,
95 int rotation,
96 int page_width,
97 int page_height,
98 const ClipBox& source_clip_box,
99 double* offset_x,
100 double* offset_y);
101
102 } // namespace printing
103
104 #endif // PRINTING_PDF_TRANSFORM_H_
OLDNEW
« no previous file with comments | « printing/BUILD.gn ('k') | printing/pdf_transform.cc » ('j') | printing/pdf_transform.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698