2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team
10 * This file Copyright 1999-2000
12 *======================================================
15 #ifndef PRINTERPARAMS_H
16 #define PRINTERPARAMS_H
19 #error You must include lyxrc.h before PrinterParams.h
22 #ifdef ENABLE_ASSERTIONS
23 #include "support/LAssert.h"
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
34 struct PrinterParams {
36 enum Target{PRINTER, FILE};
43 ///We allow printing of even pages in a range and so on.
44 enum WhichPages{ALL, ODD, EVEN};
46 WhichPages which_pages;
47 /** Print a page range. Both from_page and to_page used to be strings
48 because they're actually easier to work with that way. I've
49 switched to_page to be an int. However, from_page will remain a
50 string because I want the from_page field to be able to be used as
51 a page range "1,3-5" and so on.
52 I've modified the invariant test to match. ARRae 20000518
63 // The settings below should allow us to print any read-only doc in
64 // whatever size/orientation we want it -- overriding the documents
66 /// Override the documents orientation
68 /// Print n pages per physical sheet
70 /// Override document settings for duplex.
73 //@name Constructors and Deconstructors
76 PrinterParams(Target const & t = PRINTER,
77 string const & pname = lyxrc.printer,
78 string const & fname = string(),
79 WhichPages const wp = ALL,
80 string const & from = string(),
82 bool const reversed = false,
83 bool const unsorted = false,
84 int const & num_copies = 1)
91 reverse_order(reversed),
92 unsorted_copies(unsorted),
93 count_copies(num_copies)
98 PrinterParams(PrinterParams const & pp)
100 printer_name(pp.printer_name),
101 file_name(pp.file_name),
102 which_pages(pp.which_pages),
103 from_page(pp.from_page),
105 reverse_order(pp.reverse_order),
106 unsorted_copies(pp.unsorted_copies),
107 count_copies(pp.count_copies)
117 // friend bool operator==(PrinterParams const &, PrinterParams const &);
118 // friend bool operator<(PrinterParams const &, PrinterParams const &);
120 //@name Invariant Test Method
122 /** Test that all the fields contain valid entries. It's unlikely
123 that the internal code will get this wrong (at least for the
124 xforms code anyway) however new ports and external scripts
125 might drive the wrong values in.
127 void testInvariant() const
129 #ifdef ENABLE_ASSERTIONS
130 extern bool containsOnly(string const &, char const *);
131 if (!from_page.empty()) {
132 // Assert(from_page == number or empty)
133 Assert(containsOnly(from_page, "1234567890"));
136 // Assert(to_page == empty
137 // or number iff from_page set)
138 Assert(!from_page.empty());
142 // Assert(!printer_name.empty());
145 Assert(!file_name.empty());
151 switch (which_pages) {