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)
115 // friend bool operator==(PrinterParams const &, PrinterParams const &);
116 // friend bool operator<(PrinterParams const &, PrinterParams const &);
118 //@name Invariant Test Method
120 /** Test that all the fields contain valid entries. It's unlikely
121 that the internal code will get this wrong (at least for the
122 xforms code anyway) however new ports and external scripts
123 might drive the wrong values in.
125 void testInvariant() const
127 #ifdef ENABLE_ASSERTIONS
128 extern bool containsOnly(string const &, char const *);
129 if (!from_page.empty()) {
130 // Assert(from_page == number or empty)
131 Assert(containsOnly(from_page, "1234567890"));
134 // Assert(to_page == empty
135 // or number iff from_page set)
136 Assert(!from_page.empty());
140 // Assert(!printer_name.empty());
143 Assert(!file_name.empty());
149 switch (which_pages) {