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

View File

@ -45,10 +45,8 @@ public:
/// ///
friend bool operator==(Bullet const &, Bullet const &); friend bool operator==(Bullet const &, Bullet const &);
protected: protected:
#ifdef ENABLE_ASSERTIONS
/// ///
void testInvariant() const; void testInvariant() const;
#endif
private: private:
/** /**
This enum makes adding additional panels or changing panel sizes 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> 2003-09-06 Angus Leeming <leeming@lyx.org>
* ParagraphParameters.h: forward declare ParameterStruct rather than * ParagraphParameters.h: forward declare ParameterStruct rather than

View File

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

View File

@ -12,10 +12,11 @@
#ifndef PARAMETERSTRUCT_H #ifndef PARAMETERSTRUCT_H
#define PARAMETERSTRUCT_H #define PARAMETERSTRUCT_H
#include "vspace.h"
#include "Spacing.h"
#include "layout.h" #include "layout.h"
#include "lyxlength.h" #include "lyxlength.h"
#include "Spacing.h"
#include "vspace.h"
#include "support/types.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" #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 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 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 xforms code anyway) however new ports and external scripts
might drive the wrong values in. might drive the wrong values in.
*/ */
void testInvariant() const 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
}
/// ///
PrinterParams(Target const & t = PRINTER, PrinterParams(Target t = PRINTER,
string const & pname = lyxrc.printer, string const & pname = lyxrc.printer,
string const & fname = string(), string const & fname = string(),
bool const all = true, bool all = true,
unsigned int const & from = 1, unsigned int from = 1,
unsigned int const & to = 0, unsigned int to = 0,
bool const odd = true, bool odd = true,
bool const even = true, bool even = true,
unsigned int const & copies = 1, unsigned int copies = 1,
bool const sorted = false, bool sorted = false,
bool const reverse = false) bool 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();
}
/// ///
PrinterParams(PrinterParams const & pp) 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();
}
}; };
#endif #endif

View File

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

View File

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