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
19 #error You must include lyxrc.h before PrinterParams.h
22 #ifdef ENABLE_ASSERTIONS
23 #include "support/LAssert.h"
24 extern bool containsOnly(string const &, char const *);
29 This struct contains (or should contain) all the parameters required for
30 printing a buffer. Some work still needs to be done on this struct and
31 printing handling in general to make it nice and full-featured.
32 The main things I'd like to add now is the ability to print a read-only
33 document with different orientation, papersize or single/duplex state
34 than the document's settings. ARRae 20000423
36 struct PrinterParams {
50 /// We allow printing of even pages in a range and so on.
60 WhichPages which_pages;
61 /** Print a page range. Both from_page and to_page used to be strings
62 because they're actually easier to work with that way. I've
63 switched to_page to be an int. However, from_page will remain a
64 string because I want the from_page field to be able to be used as
65 a page range "1,3-5" and so on.
66 I've modified the invariant test to match. ARRae 20000518
77 // The settings below should allow us to print any read-only doc in
78 // whatever size/orientation we want it -- overriding the documents
80 // Override the documents orientation
82 // Print n pages per physical sheet
84 // Override document settings for duplex.
87 /** Test that all the fields contain valid entries. It's unlikely
88 that the internal code will get this wrong (at least for the
89 xforms code anyway) however new ports and external scripts
90 might drive the wrong values in.
92 void testInvariant() const
94 #ifdef ENABLE_ASSERTIONS
95 if (!from_page.empty()) {
96 // Assert(from_page == number or empty)
97 lyx::Assert(containsOnly(from_page,
101 // Assert(to_page == empty
102 // or number iff from_page set)
103 lyx::Assert(!from_page.empty());
107 // Assert(!printer_name.empty());
110 lyx::Assert(!file_name.empty());
116 switch (which_pages) {
129 PrinterParams(Target const & t = PRINTER,
130 string const & pname = lyxrc.printer,
131 string const & fname = string(),
132 WhichPages const wp = ALL,
133 string const & from = string(),
135 bool const reversed = false,
136 bool const unsorted = false,
137 int const & num_copies = 1)
144 reverse_order(reversed),
145 unsorted_copies(unsorted),
146 count_copies(num_copies)
151 PrinterParams(PrinterParams const & pp)
153 printer_name(pp.printer_name),
154 file_name(pp.file_name),
155 which_pages(pp.which_pages),
156 from_page(pp.from_page),
158 reverse_order(pp.reverse_order),
159 unsorted_copies(pp.unsorted_copies),
160 count_copies(pp.count_copies)