#include "PrinterParams.h"
-#include "support/lstrings.h"
+#include "LyXRC.h"
#include "support/assert.h"
+#include "support/lstrings.h"
-using namespace std;
-
namespace lyx {
-
-PrinterParams::PrinterParams(Target t,
- string const & pname,
- string const & fname,
- bool all,
- unsigned int from,
- unsigned int to,
- bool odd,
- bool even,
- unsigned int copies,
- bool sorted,
- bool reverse)
- : target(t),
- printer_name(pname),
- file_name(fname),
- all_pages(all),
- from_page(from),
- to_page(to),
- odd_pages(odd),
- even_pages(even),
- count_copies(copies),
- sorted_copies(sorted),
- reverse_order(reverse)
+PrinterParams::PrinterParams()
{
- testInvariant();
-}
+ target = PRINTER;
+ printer_name = lyxrc.printer;
+ file_name = std::string();
+ all_pages = true;
+ from_page = 1;
+ to_page = 0;
+ odd_pages = true;
+ even_pages = true;
+ count_copies = 1;
+ sorted_copies = false;
+ reverse_order = false;
-
-PrinterParams::PrinterParams(PrinterParams const & pp)
- : target(pp.target),
- printer_name(pp.printer_name),
- file_name(pp.file_name),
- all_pages(pp.all_pages),
- from_page(pp.from_page),
- to_page(pp.to_page),
- odd_pages(pp.odd_pages),
- even_pages(pp.even_pages),
- count_copies(pp.count_copies),
- sorted_copies(pp.sorted_copies),
- reverse_order(pp.reverse_order)
-{
testInvariant();
}
void PrinterParams::testInvariant() const
{
-#ifdef ENABLE_ASSERTIONS
switch (target) {
case PRINTER:
- //LASSERT(!printer_name.empty(), /**/);
+ LASSERT(!printer_name.empty(), /**/);
break;
case FILE:
LASSERT(!file_name.empty(), /**/);
LASSERT(false, /**/);
break;
}
-#endif
}
#ifndef PRINTERPARAMS_H
#define PRINTERPARAMS_H
-#include "LyXRC.h"
+#include <string>
namespace lyx {
document with different orientation, papersize or single/duplex state
than the document's settings. ARRae 20000423
*/
-class PrinterParams {
+class PrinterParams
+{
public:
+ ///
+ PrinterParams();
+
///
enum Target {
///
///
FILE
};
+
+ /** Test that all the fields contain valid entries. It's unlikely
+ that the internal code will get this wrong however new ports
+ and external scripts might drive the wrong values in.
+ */
+ void testInvariant() const;
+
+public:
///
Target target;
///
// 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 however new ports
- and external scripts might drive the wrong values in.
- */
- void testInvariant() const;
- ///
- PrinterParams(Target t = PRINTER,
- std::string const & pname = lyxrc.printer,
- std::string const & fname = std::string(),
- bool all = true,
- unsigned int from = 1,
- unsigned int to = 0,
- bool odd = true,
- bool even = true,
- unsigned int copies = 1,
- bool sorted = false,
- bool reverse = false);
- ///
- PrinterParams(PrinterParams const & pp);
};
#include "Buffer.h"
#include "BufferParams.h"
#include "FuncRequest.h"
-#include "support/gettext.h"
+#include "LyXRC.h"
#include "support/convert.h"
#include "support/FileFilterList.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/os.h"
#include <QLineEdit>
void GuiPrint::applyView()
{
- PrinterParams::Target t = PrinterParams::PRINTER;
- if (fileRB->isChecked())
- t = PrinterParams::FILE;
-
- params_ = PrinterParams(t,
- fromqstr(printerED->text()),
- os::internal_path(fromqstr(fileED->text())),
- allRB->isChecked(),
- fromED->text().toUInt(),
- toED->text().toUInt(),
- oddCB->isChecked(),
- evenCB->isChecked(),
- copiesSB->text().toUInt(),
- collateCB->isChecked(),
- reverseCB->isChecked()
- );
+ params_.target = fileRB->isChecked()
+ ? PrinterParams::FILE : PrinterParams::PRINTER;
+ params_.printer_name = fromqstr(printerED->text());
+ params_.file_name = os::internal_path(fromqstr(fileED->text()));
+ params_.all_pages = allRB->isChecked();
+ params_.from_page = fromED->text().toUInt();
+ params_.to_page = toED->text().toUInt();
+ params_.odd_pages = oddCB->isChecked();
+ params_.even_pages = evenCB->isChecked();
+ params_.count_copies = copiesSB->text().toUInt();
+ params_.sorted_copies = collateCB->isChecked();
+ params_.reverse_order = reverseCB->isChecked();
}
/// get global printer parameters
string const name = support::changeExtension(buffer().absFileName(),
lyxrc.print_file_extension);
- params_ = PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name);
+ params_ = PrinterParams();
+ params_.file_name = name;
setButtonsValid(true); // so that the user can press Ok
return true;