2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team
10 * This file Copyright 1999-2001
12 *======================================================
15 #ifndef PRINTERPARAMS_H
16 #define PRINTERPARAMS_H
20 #ifdef ENABLE_ASSERTIONS
21 #include "support/LAssert.h"
22 extern bool containsOnly(string const &, char const *);
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 {
48 /// We allow printing of even pages in a range and so on.
58 WhichPages which_pages;
59 /** Print a page range. Both from_page and to_page used to be strings
60 because they're actually easier to work with that way. I've
61 switched to_page to be an int. However, from_page will remain a
62 string because I want the from_page field to be able to be used as
63 a page range "1,3-5" and so on.
64 I've modified the invariant test to match. ARRae 20000518
75 // The settings below should allow us to print any read-only doc in
76 // whatever size/orientation we want it -- overriding the documents
78 // Override the documents orientation
80 // Print n pages per physical sheet
82 // Override document settings for duplex.
85 /** Test that all the fields contain valid entries. It's unlikely
86 that the internal code will get this wrong (at least for the
87 xforms code anyway) however new ports and external scripts
88 might drive the wrong values in.
90 void testInvariant() const
92 #ifdef ENABLE_ASSERTIONS
93 if (!from_page.empty()) {
94 // Assert(from_page == number or empty)
95 lyx::Assert(containsOnly(from_page,
99 // Assert(to_page == empty
100 // or number iff from_page set)
101 lyx::Assert(!from_page.empty());
105 // Assert(!printer_name.empty());
108 lyx::Assert(!file_name.empty());
114 switch (which_pages) {
127 PrinterParams(Target const & t = PRINTER,
128 string const & pname = lyxrc.printer,
129 string const & fname = string(),
130 WhichPages const wp = ALL,
131 string const & from = string(),
133 bool const reversed = false,
134 bool const unsorted = false,
135 int const & num_copies = 1)
142 reverse_order(reversed),
143 unsorted_copies(unsorted),
144 count_copies(num_copies)
149 PrinterParams(PrinterParams const & pp)
151 printer_name(pp.printer_name),
152 file_name(pp.file_name),
153 which_pages(pp.which_pages),
154 from_page(pp.from_page),
156 reverse_order(pp.reverse_order),
157 unsorted_copies(pp.unsorted_copies),
158 count_copies(pp.count_copies)