General tidy. Not very exciting.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7699 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-09-06 23:01:26 +00:00
parent d727b8e95e
commit 4fb18536e9
9 changed files with 106 additions and 83 deletions

View File

@ -47,9 +47,7 @@ Bullet::Bullet(int f, int c, int s)
size = MIN;
}
generateText();
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -57,9 +55,7 @@ Bullet::Bullet(int f, int c, int s)
Bullet::Bullet(string const & t)
: font(MIN), character(MIN), size(MIN), user_text(1), text(t)
{
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -71,9 +67,7 @@ void Bullet::setCharacter(int c)
character = c;
}
user_text = 0;
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -85,9 +79,7 @@ void Bullet::setFont(int f)
font = f;
}
user_text = 0;
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -99,9 +91,7 @@ void Bullet::setSize(int s)
size = s;
}
user_text = 0;
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -110,9 +100,7 @@ void Bullet::setText(string const & t)
font = character = size = MIN;
user_text = 1;
text = t;
#ifdef ENABLE_ASSERTIONS
testInvariant();
#endif
}
@ -136,17 +124,13 @@ int Bullet::getSize() const
Bullet & Bullet::operator=(Bullet const & b)
{
#ifdef ENABLE_ASSERTIONS
b.testInvariant();
#endif
font = b.font;
character = b.character;
size = b.size;
user_text = b.user_text;
text = b.text;
#ifdef ENABLE_ASSERTIONS
this->testInvariant();
#endif
return *this;
}
@ -367,8 +351,9 @@ string const Bullet::bulletEntry(int f, int c)
return BulletPanels[f][c];
}
void Bullet::testInvariant() const
{
#ifdef ENABLE_ASSERTIONS
void Bullet::testInvariant() const {
Assert(font >= MIN);
Assert(font < FONTMAX);
Assert(character >= MIN);
@ -389,5 +374,5 @@ void Bullet::testInvariant() const {
// // user_text == 0
// Assert(text.empty()); // not usually true
// }
}
#endif
}

View File

@ -45,10 +45,8 @@ public:
///
friend bool operator==(Bullet const &, Bullet const &);
protected:
#ifdef ENABLE_ASSERTIONS
///
void testInvariant() const;
#endif
private:
/**
This enum makes adding additional panels or changing panel sizes

View File

@ -1,3 +1,11 @@
2003-09-06 Angus Leeming <leeming@lyx.org>
* Bullet.[Ch]: factorize all those #ifdef ENABLE_ASSERTIONS to just one,
inside testInvariant.
* PrinterParams.C: new file.
* PrinterParams.[Ch]: move the function bodies out of line.
2003-09-06 Angus Leeming <leeming@lyx.org>
* ParagraphParameters.h: forward declare ParameterStruct rather than

View File

@ -96,6 +96,7 @@ lyx_SOURCES = \
ParagraphParameters.C \
ParagraphParameters.h \
ParameterStruct.h \
PrinterParams.C \
PrinterParams.h \
RowList.h \
ShareContainer.h \

View File

@ -12,10 +12,11 @@
#ifndef PARAMETERSTRUCT_H
#define PARAMETERSTRUCT_H
#include "vspace.h"
#include "Spacing.h"
#include "layout.h"
#include "lyxlength.h"
#include "Spacing.h"
#include "vspace.h"
#include "support/types.h"

78
src/PrinterParams.C Normal file
View File

@ -0,0 +1,78 @@
/**
* \file PrinterParams.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Allan Rae
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "PrinterParams.h"
#include "support/lstrings.h"
#include "support/LAssert.h"
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)
{
testInvariant();
}
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:
//lyx::support::Assert(!printer_name.empty());
break;
case FILE:
lyx::support::Assert(!file_name.empty());
break;
default:
lyx::support::Assert(false);
break;
}
#endif
}

View File

@ -14,12 +14,6 @@
#include "lyxrc.h"
#ifdef ENABLE_ASSERTIONS
#include "support/lstrings.h"
#include "support/LAssert.h"
#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
@ -79,65 +73,21 @@ struct PrinterParams {
xforms code anyway) however new ports and external scripts
might drive the wrong values in.
*/
void testInvariant() const
{
#ifdef ENABLE_ASSERTIONS
switch (target) {
case PRINTER:
//lyx::support::Assert(!printer_name.empty());
break;
case FILE:
lyx::support::Assert(!file_name.empty());
break;
default:
lyx::support::Assert(false);
break;
}
#endif
}
void testInvariant() const;
///
PrinterParams(Target const & t = PRINTER,
PrinterParams(Target t = PRINTER,
string const & pname = lyxrc.printer,
string const & fname = string(),
bool const all = true,
unsigned int const & from = 1,
unsigned int const & to = 0,
bool const odd = true,
bool const even = true,
unsigned int const & copies = 1,
bool const sorted = false,
bool const reverse = false)
: 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)
{
testInvariant();
}
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)
: 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();
}
PrinterParams(PrinterParams const & pp);
};
#endif

View File

@ -25,6 +25,7 @@
#include "support/tostr.h"
#include "support/filetools.h"
#include "support/LAssert.h"
#include "support/path.h"
#include "support/systemcall.h"

View File

@ -22,6 +22,7 @@
#include "PrinterParams.h"
#include "support/lstrings.h"
#include "support/tostr.h"
#include "lyx_forms.h"