]> git.lyx.org Git - lyx.git/blob - src/PrinterParams.h
multicol; small stuff
[lyx.git] / src / PrinterParams.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *          LyX, The Document Processor
6  *
7  *          Copyright 1995 Matthias Ettrich
8  *          Copyright 1995-2001 The LyX Team
9  *
10  *          This file Copyright 1999-2001
11  *          Allan Rae
12  *======================================================
13  */
14
15 #ifndef PRINTERPARAMS_H
16 #define PRINTERPARAMS_H
17
18 #include "lyxrc.h"
19
20 #ifdef ENABLE_ASSERTIONS
21 #include "support/lstrings.h"
22 #include "support/LAssert.h"
23 #endif
24
25
26 /**
27   This struct contains (or should contain) all the parameters required for
28   printing a buffer.  Some work still needs to be done on this struct and
29   printing handling in general to make it nice and full-featured.
30   The main things I'd like to add now is the ability to print a read-only
31   document with different orientation, papersize or single/duplex state
32   than the document's settings. ARRae 20000423
33 */
34 struct PrinterParams {
35         ///
36         enum Target {
37                 ///
38                 PRINTER,
39                 ///
40                 FILE
41         };
42         ///
43         Target target;
44         ///
45         string printer_name;
46         ///
47         string file_name;
48         ///
49         bool all_pages;
50         /** Print a page range. Both from_page and to_page used to be strings
51             because they're actually easier to work with that way.  I've
52             switched to_page to be an int.  However, from_page will remain a
53             string because I want the from_page field to be able to be used as
54             a page range "1,3-5" and so on.
55             I've modified the invariant test to match. ARRae 20000518
56          */
57         unsigned int from_page;
58         ///
59         unsigned int to_page;
60         ///
61         bool odd_pages;
62         ///
63         bool even_pages;
64         ///
65         unsigned int count_copies;
66         ///
67         bool sorted_copies;
68         ///
69         bool reverse_order;
70         // The settings below should allow us to print any read-only doc in
71         // whatever size/orientation we want it -- overriding the documents
72         // settings.
73         // Override the documents orientation
74         // bool orientation;
75         // Print n pages per physical sheet
76         // unsigned int nup;
77         // Override document settings for duplex.
78         // bool duplex;
79
80         /** Test that all the fields contain valid entries.  It's unlikely
81             that the internal code will get this wrong (at least for the
82             xforms code anyway) however new ports and external scripts
83             might drive the wrong values in.
84          */
85         void testInvariant() const
86                 {
87 #ifdef ENABLE_ASSERTIONS
88                         switch (target) {
89                         case PRINTER:
90                                 //Assert(!printer_name.empty());
91                                 break;
92                         case FILE:
93                                 lyx::Assert(!file_name.empty());
94                                 break;
95                         default:
96                                 lyx::Assert(false);
97                                 break;
98                         }
99 #endif
100                 }
101
102         ///
103         PrinterParams(Target const & t = PRINTER,
104                       string const & pname = lyxrc.printer,
105                       string const & fname = string(),
106                       bool const all = true,
107                       unsigned int const & from = 1,
108                       unsigned int const & to = 0,
109                       bool const odd = true,
110                       bool const even = true,
111                       unsigned int const & copies = 1,
112                       bool const sorted = false,
113                       bool const reverse = false)
114                 : target(t),
115                   printer_name(pname),
116                   file_name(fname),
117                   all_pages(all),
118                   from_page(from),
119                   to_page(to),
120                   odd_pages(odd),
121                   even_pages(even),
122                   count_copies(copies),
123                   sorted_copies(sorted),
124                   reverse_order(reverse)
125                 {
126                         testInvariant();
127                 }
128         ///
129         PrinterParams(PrinterParams const & pp)
130                 : target(pp.target),
131                   printer_name(pp.printer_name),
132                   file_name(pp.file_name),
133                   all_pages(pp.all_pages),
134                   from_page(pp.from_page),
135                   to_page(pp.to_page),
136                   odd_pages(pp.odd_pages),
137                   even_pages(pp.even_pages),
138                   count_copies(pp.count_copies),
139                   sorted_copies(pp.sorted_copies),
140                   reverse_order(pp.reverse_order)
141                 {
142                         testInvariant();
143                 }
144 };
145
146 #endif