summaryrefslogtreecommitdiffstats
path: root/printing/pdf_render_settings.h
blob: 5c5542a17aa2c4361b56e0e646ed846f876e9e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PRINTING_PDF_RENDER_SETTINGS_H_
#define PRINTING_PDF_RENDER_SETTINGS_H_

#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_param_traits.h"
#include "printing/printing_export.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/ipc/gfx_param_traits.h"

namespace printing {

// Defining PDF rendering settings.
class PdfRenderSettings {
 public:
  PdfRenderSettings() {}
  PdfRenderSettings(gfx::Rect area, int dpi, bool autorotate)
      : area_(area), dpi_(dpi), autorotate_(autorotate) {}
  ~PdfRenderSettings() {}

  const gfx::Rect& area() const { return area_; }
  int dpi() const { return dpi_; }
  bool autorotate() const { return autorotate_; }

  gfx::Rect area_;
  int dpi_;
  bool autorotate_;
};

}  // namespace printing

namespace IPC {
template <>
struct ParamTraits<printing::PdfRenderSettings> {
  typedef printing::PdfRenderSettings param_type;
  static void Write(base::Pickle* m, const param_type& p) {
    WriteParam(m, p.area_);
    WriteParam(m, p.dpi_);
    WriteParam(m, p.autorotate_);
  }

  static bool Read(const base::Pickle* m,
                   base::PickleIterator* iter,
                   param_type* r) {
    return ReadParam(m, iter, &r->area_) &&
        ReadParam(m, iter, &r->dpi_) &&
        ReadParam(m, iter, &r->autorotate_);
  }

  static void Log(const param_type& p, std::string* l) {
    LogParam(p.area_, l);
    l->append(", ");
    LogParam(p.dpi_, l);
    l->append(", ");
    LogParam(p.autorotate_, l);
  }
};

}  // namespace IPC

#endif  // PRINTING_PDF_RENDER_SETTINGS_H_