X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FPrinterParams.h;h=413201733818616b40aea6514544a15ca0d97d33;hb=cb52251ccff29d6cbfa13ab90a96be566e3f41ac;hp=670c32ae2207af39fa39191781a7b5d3bbb25995;hpb=d6665cba427b04ae37f42c846398cad518d2be0f;p=lyx.git diff --git a/src/PrinterParams.h b/src/PrinterParams.h index 670c32ae22..4132017338 100644 --- a/src/PrinterParams.h +++ b/src/PrinterParams.h @@ -5,9 +5,9 @@ * 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 *====================================================== */ @@ -84,6 +84,47 @@ struct PrinterParams { // 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 + } + /// PrinterParams(Target const & t = PRINTER, string const & pname = lyxrc.printer, @@ -120,50 +161,6 @@ struct PrinterParams { { testInvariant(); } - -// do we need these? -// friend bool operator==(PrinterParams const &, PrinterParams const &); -// friend bool operator<(PrinterParams const &, PrinterParams const &); - - /** 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) - 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