2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2000-06-12 11:27:15 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2000-06-12 11:27:15 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
2001-05-30 13:53:44 +00:00
|
|
|
* This file Copyright 1999-2001
|
2000-06-12 11:27:15 +00:00
|
|
|
* Allan Rae
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PRINTERPARAMS_H
|
|
|
|
#define PRINTERPARAMS_H
|
|
|
|
|
2002-03-22 15:13:36 +00:00
|
|
|
#include "lyxrc.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_ASSERTIONS
|
2002-07-28 18:13:51 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "support/LAssert.h"
|
|
|
|
#endif
|
|
|
|
|
2000-09-26 13:54:57 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/**
|
|
|
|
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
|
|
|
|
printing handling in general to make it nice and full-featured.
|
|
|
|
The main things I'd like to add now is the ability to print a read-only
|
|
|
|
document with different orientation, papersize or single/duplex state
|
|
|
|
than the document's settings. ARRae 20000423
|
|
|
|
*/
|
|
|
|
struct PrinterParams {
|
|
|
|
///
|
2000-09-26 13:54:57 +00:00
|
|
|
enum Target {
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
|
|
|
PRINTER,
|
|
|
|
///
|
|
|
|
FILE
|
|
|
|
};
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
Target target;
|
|
|
|
///
|
|
|
|
string printer_name;
|
|
|
|
///
|
|
|
|
string file_name;
|
2000-08-07 20:58:24 +00:00
|
|
|
/// We allow printing of even pages in a range and so on.
|
|
|
|
enum WhichPages{
|
|
|
|
///
|
|
|
|
ALL,
|
|
|
|
///
|
|
|
|
ODD,
|
|
|
|
///
|
|
|
|
EVEN
|
|
|
|
};
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
WhichPages which_pages;
|
|
|
|
/** Print a page range. Both from_page and to_page used to be strings
|
|
|
|
because they're actually easier to work with that way. I've
|
|
|
|
switched to_page to be an int. However, from_page will remain a
|
|
|
|
string because I want the from_page field to be able to be used as
|
|
|
|
a page range "1,3-5" and so on.
|
|
|
|
I've modified the invariant test to match. ARRae 20000518
|
|
|
|
*/
|
|
|
|
string from_page;
|
|
|
|
///
|
|
|
|
int to_page;
|
|
|
|
///
|
|
|
|
bool reverse_order;
|
|
|
|
///
|
|
|
|
bool unsorted_copies;
|
|
|
|
///
|
2002-03-21 17:27:08 +00:00
|
|
|
int count_copies;
|
2000-06-12 11:27:15 +00:00
|
|
|
// The settings below should allow us to print any read-only doc in
|
|
|
|
// whatever size/orientation we want it -- overriding the documents
|
|
|
|
// settings.
|
2002-03-21 17:27:08 +00:00
|
|
|
// Override the documents orientation
|
2000-08-07 20:58:24 +00:00
|
|
|
// bool orientation;
|
|
|
|
// Print n pages per physical sheet
|
|
|
|
// unsigned int nup;
|
|
|
|
// Override document settings for duplex.
|
|
|
|
// bool duplex;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
/** 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)
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(containsOnly(from_page,
|
|
|
|
"1234567890"));
|
2000-10-02 00:10:25 +00:00
|
|
|
}
|
|
|
|
if (to_page) {
|
|
|
|
// Assert(to_page == empty
|
|
|
|
// or number iff from_page set)
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(!from_page.empty());
|
2000-10-02 00:10:25 +00:00
|
|
|
}
|
|
|
|
switch (target) {
|
|
|
|
case PRINTER:
|
2002-03-21 17:27:08 +00:00
|
|
|
// Assert(!printer_name.empty());
|
2000-10-02 00:10:25 +00:00
|
|
|
break;
|
|
|
|
case FILE:
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(!file_name.empty());
|
2000-10-02 00:10:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(false);
|
2000-10-02 00:10:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (which_pages) {
|
|
|
|
case ALL:
|
|
|
|
case ODD:
|
|
|
|
case EVEN:
|
|
|
|
break;
|
|
|
|
default:
|
2001-04-24 15:25:26 +00:00
|
|
|
lyx::Assert(false);
|
2000-10-02 00:10:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
PrinterParams(Target const & t = PRINTER,
|
|
|
|
string const & pname = lyxrc.printer,
|
|
|
|
string const & fname = string(),
|
|
|
|
WhichPages const wp = ALL,
|
|
|
|
string const & from = string(),
|
|
|
|
int const & to = 0,
|
|
|
|
bool const reversed = false,
|
|
|
|
bool const unsorted = false,
|
|
|
|
int const & num_copies = 1)
|
|
|
|
: target(t),
|
|
|
|
printer_name(pname),
|
|
|
|
file_name(fname),
|
|
|
|
which_pages(wp),
|
|
|
|
from_page(from),
|
|
|
|
to_page(to),
|
|
|
|
reverse_order(reversed),
|
|
|
|
unsorted_copies(unsorted),
|
|
|
|
count_copies(num_copies)
|
|
|
|
{
|
|
|
|
testInvariant();
|
|
|
|
}
|
|
|
|
///
|
|
|
|
PrinterParams(PrinterParams const & pp)
|
|
|
|
: target(pp.target),
|
|
|
|
printer_name(pp.printer_name),
|
|
|
|
file_name(pp.file_name),
|
|
|
|
which_pages(pp.which_pages),
|
|
|
|
from_page(pp.from_page),
|
|
|
|
to_page(pp.to_page),
|
|
|
|
reverse_order(pp.reverse_order),
|
|
|
|
unsorted_copies(pp.unsorted_copies),
|
|
|
|
count_copies(pp.count_copies)
|
|
|
|
{
|
|
|
|
testInvariant();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|