X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FPrinterParams.h;h=71253ce75e542596a527b7e17106db604a7e86ab;hb=34046e3c4df63b34bd75d5bca09ee3809815b7fc;hp=6f738a09143e5bfffbdb3b8a8bf01f9752c8ff5d;hpb=6bba977f42b0cde753ac2ffd26f3f9c6b32ba0b6;p=lyx.git diff --git a/src/PrinterParams.h b/src/PrinterParams.h index 6f738a0914..71253ce75e 100644 --- a/src/PrinterParams.h +++ b/src/PrinterParams.h @@ -1,13 +1,13 @@ // -*- C++ -*- /* This file is part of * ====================================================== - * + * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team + * Copyright 1995-2001 The LyX Team * - * This file Copyright 1999-2000 + * This file Copyright 1999-2001 * Allan Rae *====================================================== */ @@ -15,14 +15,14 @@ #ifndef PRINTERPARAMS_H #define PRINTERPARAMS_H -#ifndef LYXRC_H -#error You must include lyxrc.h before PrinterParams.h -#endif +#include "lyxrc.h" #ifdef ENABLE_ASSERTIONS #include "support/LAssert.h" +extern bool containsOnly(string const &, char const *); #endif + /** This struct contains (or should contain) all the parameters required for printing a buffer. Some work still needs to be done on this struct and @@ -33,15 +33,27 @@ */ struct PrinterParams { /// - enum Target{PRINTER, FILE}; + enum Target { + /// + PRINTER, + /// + FILE + }; /// Target target; /// string printer_name; /// string file_name; - ///We allow printing of even pages in a range and so on. - enum WhichPages{ALL, ODD, EVEN}; + /// We allow printing of even pages in a range and so on. + enum WhichPages{ + /// + ALL, + /// + ODD, + /// + EVEN + }; /// WhichPages which_pages; /** Print a page range. Both from_page and to_page used to be strings @@ -59,19 +71,58 @@ struct PrinterParams { /// bool unsorted_copies; /// - int count_copies; + int count_copies; // The settings below should allow us to print any read-only doc in // whatever size/orientation we want it -- overriding the documents // settings. - /// Override the documents orientation - //bool orientation; - /// Print n pages per physical sheet - //unsigned int nup; - /// Override document settings for duplex. - //bool duplex; + // Override the documents orientation + // bool orientation; + // Print n pages per physical sheet + // unsigned int nup; + // Override document settings for duplex. + // bool duplex; + + /** Test that all the fields contain valid entries. It's unlikely + that the internal code will get this wrong (at least for the + xforms code anyway) however new ports and external scripts + might drive the wrong values in. + */ + void testInvariant() const + { +#ifdef ENABLE_ASSERTIONS + if (!from_page.empty()) { + // Assert(from_page == number or empty) + lyx::Assert(containsOnly(from_page, + "1234567890")); + } + if (to_page) { + // Assert(to_page == empty + // or number iff from_page set) + lyx::Assert(!from_page.empty()); + } + switch (target) { + case PRINTER: +// Assert(!printer_name.empty()); + break; + case FILE: + lyx::Assert(!file_name.empty()); + break; + default: + lyx::Assert(false); + break; + } + switch (which_pages) { + case ALL: + case ODD: + case EVEN: + break; + default: + lyx::Assert(false); + break; + } +#endif + } - //@name Constructors and Deconstructors - //@{ /// PrinterParams(Target const & t = PRINTER, string const & pname = lyxrc.printer, @@ -108,61 +159,6 @@ struct PrinterParams { { testInvariant(); } - /// - ~PrinterParams() {} - //@} - - -// do we need these? -// friend bool operator==(PrinterParams const &, PrinterParams const &); -// friend bool operator<(PrinterParams const &, PrinterParams const &); - - //@name Invariant Test Method - //@{ - /** Test that all the fields contain valid entries. It's unlikely - that the internal code will get this wrong (at least for the - xforms code anyway) however new ports and external scripts - might drive the wrong values in. - */ - void testInvariant() const - { -#ifdef ENABLE_ASSERTIONS - extern bool containsOnly(string const &, char const *); - if (!from_page.empty()) { - // Assert(from_page == number or empty) - Assert(containsOnly(from_page, "1234567890")); - } - if (to_page) { - // Assert(to_page == empty - // or number iff from_page set) - Assert(!from_page.empty()); - } - switch (target) { - case PRINTER: -// Assert(!printer_name.empty()); - break; - case FILE: - Assert(!file_name.empty()); - break; - default: - Assert(false); - break; - } - switch (which_pages) { - case ALL: - case ODD: - case EVEN: - break; - default: - Assert(false); - break; - } -#endif - } - //@} }; #endif - - -