cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24370 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-04-19 20:39:48 +00:00
parent a125dab7fd
commit c206a3953e
3 changed files with 45 additions and 84 deletions

View File

@ -12,66 +12,37 @@
#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(), /**/);
@ -80,7 +51,6 @@ void PrinterParams::testInvariant() const
LASSERT(false, /**/);
break;
}
#endif
}

View File

@ -12,7 +12,7 @@
#ifndef PRINTERPARAMS_H
#define PRINTERPARAMS_H
#include "LyXRC.h"
#include <string>
namespace lyx {
@ -25,8 +25,12 @@ 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 {
///
@ -34,6 +38,14 @@ public:
///
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;
///
@ -72,25 +84,6 @@ public:
// 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);
};

View File

@ -20,11 +20,12 @@
#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>
@ -157,22 +158,18 @@ void GuiPrint::updateContents()
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();
}
@ -181,7 +178,8 @@ bool GuiPrint::initialiseParams(string const &)
/// 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;