summaryrefslogtreecommitdiff
path: root/src/lib/SW602Printer.h
blob: 64778b2f91479999a17c05ae5d1a570b0efc6ad3 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * This file is part of the libsw602 project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/* This header contains code specific to a mac file needed to read
 * TPrint structure (ie. the structure which keeps the printer parameters)
 * see http://developer.apple.com/documentation/Mac/QuickDraw/QuickDraw-411.html
 *   or http://www.mactech.com/articles/mactech/Vol.01/01.09/AllAboutPrinting/index.html
 */

#ifndef INCLUDED_SW602_PRINTER_H
#define INCLUDED_SW602_PRINTER_H

#include <ostream>

#include <librevenge/librevenge.h>

#include "SW602Types.h"

namespace libsw602
{

/** \struct PrinterInfoData
    \brief internal structure used to keep TPrint content */
struct PrinterInfoData;

//! the Apple© rectangle : Rect
struct PrinterRect
{
  //! returns the size
  SW602Vec2i size() const
  {
    return m_pos[1]-m_pos[0];
  }
  //! returns the position ( 0: leftTop, 1:rightBottom )
  SW602Vec2i pos(int i) const
  {
    return m_pos[i];
  }

  //! operator <<
  friend std::ostream &operator<< (std::ostream &o, PrinterRect const &r)
  {
    o << "[" << r.m_pos[0] << " " << r.m_pos[1] << "]";
    return o;
  }

  //! read value in a file, knowing the resolution
  bool read(librevenge::RVNGInputStream &input, SW602Vec2i const &res);

protected:
  //! the LT and RB positions
  SW602Vec2i m_pos[2];
};

//! the Apple© printer information : TPrint
struct PrinterInfo
{
  //! constructor
  PrinterInfo();
  //! destructor
  ~PrinterInfo();

  //! returns the page rectangle
  PrinterRect page() const;
  //! returns the paper rectangle
  PrinterRect paper() const;

  friend std::ostream &operator<< (std::ostream &o, PrinterInfo const &r);

  //! reads the struture in a file
  bool read(librevenge::RVNGInputStream &input);

protected:
  //! internal data
  boost::shared_ptr<PrinterInfoData> m_data;
private:
  PrinterInfo(PrinterInfo const &orig);
  PrinterInfo &operator=(PrinterInfo const &orig);
};

}

#endif

/* vim:set shiftwidth=2 softtabstop=2 expandtab: */