apply the ostream changes to mathed, some other small related things

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@588 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-03-07 01:14:37 +00:00
parent e19f533b0e
commit abb623f787
38 changed files with 671 additions and 142 deletions

View File

@ -1,3 +1,16 @@
2000-03-06 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/mathed/math_inset.h (Write(ostream & os): add a space at the
end. This fixes a bug.
* src/mathed (all files concerned with file writing): apply the
USE_OSTREAM_ONLY changes to mathed too.
* src/support/DebugStream.h: make the constructor explicit.
* src/lyxfont.C (latexWriteStartChanges): small bug related to
count and ostream squashed.
2000-03-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/support/Makefile.am (libsupport_la_SOURCES): add lyxmanip.h.

View File

@ -141,7 +141,8 @@ private:
/*----------------Inline Bullet Member Functions------------------*/
inline Bullet::Bullet(string const & t)
inline
Bullet::Bullet(string const & t)
: font(MIN), character(MIN), size(MIN), user_text(1), text(t)
{
#ifdef ENABLE_ASSERTIONS
@ -150,7 +151,8 @@ inline Bullet::Bullet(string const & t)
}
inline void Bullet::setCharacter(int c)
inline
void Bullet::setCharacter(int c)
{
if (c < MIN || c >= CHARMAX) {
character = MIN;
@ -164,7 +166,8 @@ inline void Bullet::setCharacter(int c)
}
inline void Bullet::setFont(int f)
inline
void Bullet::setFont(int f)
{
if (f < MIN || f >= FONTMAX) {
font = MIN;
@ -178,7 +181,8 @@ inline void Bullet::setFont(int f)
}
inline void Bullet::setSize(int s)
inline
void Bullet::setSize(int s)
{
if (s < MIN || s >= SIZEMAX) {
size = MIN;
@ -192,7 +196,8 @@ inline void Bullet::setSize(int s)
}
inline void Bullet::setText(string const & t)
inline
void Bullet::setText(string const & t)
{
font = character = size = MIN;
user_text = 1;
@ -203,31 +208,36 @@ inline void Bullet::setText(string const & t)
}
inline int Bullet::getCharacter() const
inline
int Bullet::getCharacter() const
{
return character;
}
inline int Bullet::getFont() const
inline
int Bullet::getFont() const
{
return font;
}
inline int Bullet::getSize() const
inline
int Bullet::getSize() const
{
return size;
}
inline string Bullet::getText() const
inline
string Bullet::getText() const
{
return text;
}
inline Bullet & Bullet::operator=(Bullet const & b)
inline
Bullet & Bullet::operator=(Bullet const & b)
{
#ifdef ENABLE_ASSERTIONS
b.testInvariant();
@ -244,7 +254,8 @@ inline Bullet & Bullet::operator=(Bullet const & b)
}
inline char const * Bullet::c_str() const
inline
char const * Bullet::c_str() const
{
return this->getText().c_str();
}

View File

@ -20,7 +20,8 @@ extern FD_form_paper * fd_form_paper;
extern BufferView * current_view;
inline void DeactivatePaperButtons ()
inline
void DeactivatePaperButtons ()
{
fl_deactivate_object (fd_form_paper->button_ok);
fl_deactivate_object (fd_form_paper->button_apply);
@ -29,7 +30,8 @@ inline void DeactivatePaperButtons ()
}
inline void ActivatePaperButtons ()
inline
void ActivatePaperButtons ()
{
fl_activate_object (fd_form_paper->button_ok);
fl_activate_object (fd_form_paper->button_apply);
@ -38,7 +40,8 @@ inline void ActivatePaperButtons ()
}
inline void DisablePaperLayout()
inline
void DisablePaperLayout()
{
DeactivatePaperButtons();
fl_deactivate_object (fd_form_paper->choice_paperpackage);
@ -60,7 +63,8 @@ inline void DisablePaperLayout()
}
inline void EnablePaperLayout()
inline
void EnablePaperLayout()
{
ActivatePaperButtons();
fl_activate_object (fd_form_paper->choice_paperpackage);
@ -82,7 +86,8 @@ inline void EnablePaperLayout()
}
static void checkMarginValues()
static
void checkMarginValues()
{
int allEmpty;

View File

@ -18,7 +18,8 @@ extern FD_form_paragraph_extra * fd_form_paragraph_extra;
extern BufferView * current_view;
static bool CheckInputWidth();
inline void DeactivateParagraphExtraButtons ()
inline
void DeactivateParagraphExtraButtons ()
{
fl_deactivate_object(fd_form_paragraph_extra->button_ok);
fl_deactivate_object(fd_form_paragraph_extra->button_apply);
@ -26,7 +27,8 @@ inline void DeactivateParagraphExtraButtons ()
fl_set_object_lcol(fd_form_paragraph_extra->button_apply, FL_INACTIVE);
}
inline void ActivateParagraphExtraButtons ()
inline
void ActivateParagraphExtraButtons ()
{
fl_activate_object(fd_form_paragraph_extra->button_ok);
fl_activate_object(fd_form_paragraph_extra->button_apply);
@ -34,7 +36,8 @@ inline void ActivateParagraphExtraButtons ()
fl_set_object_lcol(fd_form_paragraph_extra->button_apply, FL_BLACK);
}
inline void DisableParagraphExtra ()
inline
void DisableParagraphExtra ()
{
DeactivateParagraphExtraButtons();
fl_deactivate_object(fd_form_paragraph_extra->input_pextra_width);
@ -52,7 +55,8 @@ inline void DisableParagraphExtra ()
fl_deactivate_object(fd_form_paragraph_extra->radio_pextra_startmp);
}
inline void EnableParagraphExtra ()
inline
void EnableParagraphExtra ()
{
ActivateParagraphExtraButtons();
fl_activate_object(fd_form_paragraph_extra->input_pextra_width);
@ -278,7 +282,8 @@ void CheckPExtraOptCB(FL_OBJECT * ob, long)
}
static bool CheckInputWidth()
static
bool CheckInputWidth()
{
string s1 = fl_get_input(fd_form_paragraph_extra->input_pextra_width);
string s2 = fl_get_input(fd_form_paragraph_extra->input_pextra_widthp);

View File

@ -203,6 +203,13 @@ WorkArea::~WorkArea()
}
bool WorkArea::belowMouse() const
{
lyxerr << "Below mouse: " << work_area->belowmouse << endl;
return work_area->belowmouse;
}
void WorkArea::resize(int xpos, int ypos, int width, int height)
{
fl_freeze_all_forms();

View File

@ -60,7 +60,7 @@ public:
///
bool active() const { return work_area->active; }
///
bool belowMouse() const { return work_area->belowmouse; }
bool belowMouse() const;
///
bool visible() const { return work_area->form->visible; }
///

View File

@ -68,7 +68,8 @@ FL_OBJECT *fl_add_bmtable(int type, FL_Coord x, FL_Coord y,
}
static void draw_bitmaptable(FL_OBJECT *ob)
static
void draw_bitmaptable(FL_OBJECT *ob)
{
int i, j, lx;
FL_Coord mx, my;

View File

@ -77,7 +77,8 @@ struct Debug {
///
inline void operator|= (Debug::type & d1, Debug::type d2)
inline
void operator|= (Debug::type & d1, Debug::type d2)
{
d1 = static_cast<Debug::type>(d1 | d2);
}

View File

@ -1942,7 +1942,8 @@ void InsetFig::CallbackFig(long arg)
}
inline void DisableFigurePanel(FD_Figure * const form)
inline
void DisableFigurePanel(FD_Figure * const form)
{
fl_deactivate_object(form->EpsFile);
fl_deactivate_object(form->Browse);
@ -1978,7 +1979,8 @@ inline void DisableFigurePanel(FD_Figure * const form)
}
inline void EnableFigurePanel(FD_Figure * const form)
inline
void EnableFigurePanel(FD_Figure * const form)
{
fl_activate_object(form->EpsFile);
fl_activate_object(form->Browse);

View File

@ -85,7 +85,8 @@ enum LyXAlignment {
};
inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
inline
void operator|=(LyXAlignment & la1, LyXAlignment la2) {
la1 = static_cast<LyXAlignment>(la1 | la2);
}
@ -485,14 +486,16 @@ private:
///
inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
inline
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
{
p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
}
///
inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
inline
ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
{
switch (p) {
case LyXTextClass::OneSide:

View File

@ -1441,7 +1441,8 @@ void MenuLayoutCharacter()
}
inline void DeactivateParagraphButtons ()
inline
void DeactivateParagraphButtons ()
{
fl_deactivate_object (fd_form_paragraph->button_ok);
fl_deactivate_object (fd_form_paragraph->button_apply);
@ -1450,7 +1451,8 @@ inline void DeactivateParagraphButtons ()
}
inline void ActivateParagraphButtons ()
inline
void ActivateParagraphButtons ()
{
fl_activate_object (fd_form_paragraph->button_ok);
fl_activate_object (fd_form_paragraph->button_apply);
@ -1459,7 +1461,8 @@ inline void ActivateParagraphButtons ()
}
inline void DisableParagraphLayout ()
inline
void DisableParagraphLayout ()
{
DeactivateParagraphButtons();
fl_deactivate_object (fd_form_paragraph->input_labelwidth);
@ -1482,7 +1485,8 @@ inline void DisableParagraphLayout ()
}
inline void EnableParagraphLayout ()
inline
void EnableParagraphLayout ()
{
ActivateParagraphButtons();
fl_activate_object (fd_form_paragraph->input_labelwidth);

View File

@ -4,8 +4,8 @@
*
* LyX, The Document Processor
*
* Copyright (C) 1995 1996 Matthias Ettrich
* and the LyX Team.
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */

View File

@ -693,8 +693,8 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
if (f.family() != INHERIT_FAMILY) {
os << '\\'
<< LaTeXFamilyNames[f.family()]
<< '{'
<< LaTeXFamilyNames[f.family()].length() + 2;
<< '{';
count += LaTeXFamilyNames[f.family()].length() + 2;
env = true; //We have opened a new environment
}
if (f.series() != INHERIT_SERIES) {

View File

@ -441,37 +441,43 @@ private:
ostream & operator<<(ostream &, LyXFont::FONT_MISC_STATE);
inline LyXFont::LyXFont()
inline
LyXFont::LyXFont()
{
bits = sane;
}
inline LyXFont::LyXFont(LyXFont const & x)
inline
LyXFont::LyXFont(LyXFont const & x)
{
bits = x.bits;
}
inline LyXFont::LyXFont(LyXFont::FONT_INIT1)
inline
LyXFont::LyXFont(LyXFont::FONT_INIT1)
{
bits = inherit;
}
inline LyXFont::LyXFont(LyXFont::FONT_INIT2)
inline
LyXFont::LyXFont(LyXFont::FONT_INIT2)
{
bits = ignore;
}
inline LyXFont::LyXFont(LyXFont::FONT_INIT3)
inline
LyXFont::LyXFont(LyXFont::FONT_INIT3)
{
bits = sane;
}
inline LyXFont & LyXFont::operator=(LyXFont const & x)
inline
LyXFont & LyXFont::operator=(LyXFont const & x)
{
bits = x.bits;
return *this;

View File

@ -140,7 +140,8 @@ enum LyXRCTags {
};
static keyword_item lyxrcTags[] = {
static
keyword_item lyxrcTags[] = {
{ "\\accept_compound", RC_ACCEPT_COMPOUND },
{ "\\alternate_language", RC_ALT_LANG },
{ "\\ascii_linelen", RC_ASCII_LINELEN },

View File

@ -307,17 +307,17 @@ int InsetFormula::Latex(ostream & os, signed char fragile) const
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
// This problem will disapear at 0.13.
string output;
#ifdef USE_OSTREAM_ONLY
if (fragile < 0)
par->Write(output);
par->Write(os);
else
mathed_write(par, output, &ret, fragile, label.c_str());
mathed_write(par, os, &ret, fragile, label.c_str());
#else
string output;
InsetFormula::Latex(output, fragile);
#endif
os << output;
#endif
return ret;
}

View File

@ -33,13 +33,15 @@
static LyxArrayBase * selarray = 0;
inline bool IsAlpha(char c)
inline
bool IsAlpha(char c)
{
return ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z');
}
// This was very smaller, I'll change it later
inline bool IsMacro(short tok, int id)
inline
bool IsMacro(short tok, int id)
{
return (tok != LM_TK_STACK && tok != LM_TK_FRAC && tok != LM_TK_SQRT
&& tok != LM_TK_WIDE
@ -51,7 +53,8 @@ inline bool IsMacro(short tok, int id)
// Yes, mathed isn't using string yet.
inline char * strnew(char const * s)
inline
char * strnew(char const * s)
{
char * s1 = new char[strlen(s)+1];
strcpy(s1, s);

View File

@ -33,6 +33,7 @@
class Painter;
#define USE_OSTREAM_ONLY 1
///
enum math_align {
@ -233,8 +234,10 @@ class MathedInset {
/// Write LaTeX and Lyx code
virtual void Write(ostream &) = 0;
#ifndef USE_OSTREAM_ONLY
/// Write LaTeX and Lyx code
virtual void Write(string & file) = 0;
#endif
/// Reproduces itself
virtual MathedInset * Clone() = 0;
@ -333,8 +336,11 @@ class MathParInset: public MathedInset {
/// Write LaTeX code
virtual void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
/// Write LaTeX code
virtual void Write(string & file);
#endif
///
virtual void Metrics();
///
@ -490,8 +496,12 @@ class MathMatrixInset: public MathParInset {
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -541,9 +551,12 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * data,
void mathed_write(MathParInset *, ostream &, int *, char fragile,
char const * label = 0);
#ifndef USE_OSTREAM_ONLY
///
void mathed_write(MathParInset *, string &, int *, char fragile,
char const * label = 0);
#endif
///
void mathed_parser_file(istream &, int);
///
@ -553,67 +566,77 @@ int MathedLookupBOP(short);
/************************ Inline functions ********************************/
///
inline bool MathIsInset(short x)
inline
bool MathIsInset(short x)
{
return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
}
///
inline bool MathIsFont(short x)
inline
bool MathIsFont(short x)
{
return LM_TC_CONST <= x && x <= LM_TC_BSYM;
}
///
inline bool MathIsAlphaFont(short x)
inline
bool MathIsAlphaFont(short x)
{
return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
}
///
inline bool MathIsActive(short x)
inline
bool MathIsActive(short x)
{
return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
}
///
inline bool MathIsUp(short x)
inline
bool MathIsUp(short x)
{
return x == LM_TC_UP;
}
///
inline bool MathIsDown(short x)
inline
bool MathIsDown(short x)
{
return x == LM_TC_DOWN;
}
///
inline bool MathIsScript(short x)
inline
bool MathIsScript(short x)
{
return x == LM_TC_DOWN || x == LM_TC_UP;
}
///
inline bool MathIsBOPS(short x)
inline
bool MathIsBOPS(short x)
{
return MathedLookupBOP(x) > LMB_NONE;
}
///
inline bool MathIsBinary(short x)
inline
bool MathIsBinary(short x)
{
return x == LM_TC_BOP || x == LM_TC_BOPS;
}
///
inline bool MathIsSymbol(short x) {
inline
bool MathIsSymbol(short x) {
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
}
inline
inline
MathedInset::MathedInset(char const * nm, short ot, short st):
name(nm), objtype(ot), size(st)
{

View File

@ -225,14 +225,15 @@ static struct math_deco_struct {
};
inline int odd(int x) { return ((x) & 1); }
inline
int odd(int x) { return ((x) & 1); }
typedef float matriz_data[2][2];
const matriz_data MATIDEN= { {1, 0}, {0, 1}};
extern int mathed_char_width(short type, int style, byte c);
extern int mathed_char_height(short, int, byte, int&, int&);
extern int mathed_char_height(short, int, byte, int &, int &);
#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
@ -241,11 +242,11 @@ class Matriz {
Matriz() { mateq(m, MATIDEN); }
void rota(int);
void escala(float, float);
void transf(float, float, float&, float&);
void transf(float, float, float &, float &);
protected:
matriz_data m;
void matmat(matriz_data& a);
void matmat(matriz_data & a);
};
@ -271,20 +272,20 @@ void Matriz::escala(float x, float y)
}
void Matriz::matmat(matriz_data& a)
void Matriz::matmat(matriz_data & a)
{
matriz_data c;
for (int i = 0;i < 2; ++i) {
c[0][i] = a[0][0]*m[0][i] + a[0][1]*m[1][i];
c[1][i] = a[1][0]*m[0][i] + a[1][1]*m[1][i];
c[0][i] = a[0][0] * m[0][i] + a[0][1] * m[1][i];
c[1][i] = a[1][0] * m[0][i] + a[1][1] * m[1][i];
}
mateq(m, c);
}
void Matriz::transf(float xp, float yp, float &x, float &y)
void Matriz::transf(float xp, float yp, float & x, float & y)
{
x = m[0][0]*xp + m[0][1]*yp;
y = m[1][0]*xp + m[1][1]*yp;
x = m[0][0] * xp + m[0][1] * yp;
y = m[1][0] * xp + m[1][1] * yp;
}
@ -293,7 +294,7 @@ int search_deco(int code)
{
int i = 0;
while (math_deco_table[i].code && math_deco_table[i].code!= code) ++i;
while (math_deco_table[i].code && math_deco_table[i].code != code) ++i;
if (!math_deco_table[i].code) i = -1;
return i;
}
@ -311,7 +312,8 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
int r = math_deco_table[j].angle;
float * d = math_deco_table[j].data;
if (h > 70 && (math_deco_table[j].code == int('(') || math_deco_table[j].code == int(')')))
if (h > 70 && (math_deco_table[j].code == int('(')
|| math_deco_table[j].code == int(')')))
d = parenthHigh;
mt.rota(r);

View File

@ -16,7 +16,8 @@
#define MAX_HASH_VALUE 490
/* maximum key range = 483, duplicates = 40 */
static unsigned int
static
unsigned int
math_hash (register char const *str, register int len)
{
static unsigned short asso_values[] =
@ -38,7 +39,8 @@ math_hash (register char const *str, register int len)
return len + asso_values[str[len - 1]] + asso_values[str[0]];
}
static latexkeys wordlist[] =
static
latexkeys wordlist[] =
{
{"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0},
{"setminus", LM_TK_SYM, LM_setminus},

View File

@ -47,8 +47,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -78,8 +80,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -110,8 +114,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
protected:
@ -131,8 +137,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
inline void Metrics();
///
@ -156,8 +164,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -185,8 +195,10 @@ public:
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -210,8 +222,10 @@ public:
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
@ -258,8 +272,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
protected:
@ -281,8 +297,10 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -317,10 +335,11 @@ bool MathFuncInset::GetLimits() const
inline
void MathFuncInset::Write(ostream & os)
{
os << "\\" << name;
os << "\\" << name << ' ';
}
#ifndef USE_OSTREAM_ONLY
inline
void MathFuncInset::Write(string & file)
{
@ -328,6 +347,7 @@ void MathFuncInset::Write(string & file)
file += name;
file += ' ';
}
#endif
inline

View File

@ -36,7 +36,8 @@ extern int mathed_char_height(short, int, byte, int&, int&);
// the builtin memcpy() is broken in egcs and gcc 2.95.x on alpha
// stations. We provide a hand-made version instead.
inline void my_memcpy( void * ps_in, const void * pt_in, size_t n )
inline
void my_memcpy( void * ps_in, const void * pt_in, size_t n )
{
char * ps = static_cast<char *>(ps_in);
char const * pt = static_cast<char const *>(pt_in);

View File

@ -191,9 +191,11 @@ class MathedXIter: public MathedIter {
///
void Adjust();
///
inline void GetPos(int&, int&);
inline
void GetPos(int&, int&);
///
inline void GetIncPos(int&, int&);
inline
void GetIncPos(int&, int&);
///
byte* GetString(int&);
///

View File

@ -158,12 +158,55 @@ void MathMacro::SetFocus(int x, int y)
void MathMacro::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (tmplate->flags & MMF_Exp) {
lyxerr[Debug::MATHED] << "Expand " << tmplate->flags
<< ' ' << MMF_Exp << endl;
tmplate->update(this);
tmplate->Write(os);
} else {
if (tmplate->flags & MMF_Env) {
os << "\\begin{"
<< name
<< "} ";
} else {
os << '\\' << name;
}
// if (options) {
// file += '[';
// file += options;
// file += ']';
// }
if (!(tmplate->flags & MMF_Env) && nargs > 0)
os << '{';
for (int i = 0; i < nargs; ++i) {
array = args[i].array;
MathParInset::Write(os);
if (i < nargs - 1)
os << "}{";
}
if (tmplate->flags & MMF_Env) {
os << "\\end{"
<< name
<< '}';
} else {
if (nargs > 0)
os << '}';
else
os << ' ';
}
}
#else
string output;
MathMacro::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMacro::Write(string &file)
{
if (tmplate->flags & MMF_Exp) {
@ -207,7 +250,7 @@ void MathMacro::Write(string &file)
}
}
}
#endif
/*--------------- Macro argument -----------------------------------*/
@ -247,12 +290,21 @@ void MathMacroArgument::Metrics()
void MathMacroArgument::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (expnd_mode) {
MathParInset::Write(os);
} else {
os << '#' << number << ' ';
}
#else
string output;
MathMacroArgument::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMacroArgument::Write(string & file)
{
if (expnd_mode) {
@ -263,6 +315,7 @@ void MathMacroArgument::Write(string & file)
file += ' ';
}
}
#endif
/* --------------------- MathMacroTemplate ---------------------------*/
@ -386,6 +439,7 @@ void MathMacroTemplate::WriteDef(ostream & os)
}
#ifndef USE_OSTREAM_ONLY
void MathMacroTemplate::WriteDef(string & file)
{
file += "\n\\newcommand{\\";
@ -406,6 +460,7 @@ void MathMacroTemplate::WriteDef(string & file)
Write(file);
file += "}\n";
}
#endif
void MathMacroTemplate::setArgument(LyxArrayBase * a, int i)
@ -439,7 +494,7 @@ void MathMacroTemplate::SetMacroFocus(int &idx, int x, int y)
/* -------------------------- MathMacroTable -----------------------*/
MathMacroTable::MathMacroTable(int n): max_macros(n)
MathMacroTable::MathMacroTable(int n) : max_macros(n)
{
macro_table = new MathMacroTemplateP[max_macros];
num_macros = 0;

View File

@ -35,7 +35,7 @@ class MathMacroTemplate;
/// This class contains the data for a macro
class MathMacro : public MathParInset
{
public:
public:
/// A macro can only be builded from an existing template
MathMacro(MathMacroTemplate *);
/// or from another macro.
@ -50,8 +50,10 @@ class MathMacro : public MathParInset
MathedInset * Clone();
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string &);
#endif
///
bool setArgumentIdx(int);
///
@ -75,7 +77,7 @@ class MathMacro : public MathParInset
///
bool Permit(short);
private:
private:
///
MathMacroTemplate * tmplate;
///
@ -102,9 +104,8 @@ class MathMacro : public MathParInset
/// An argument
class MathMacroArgument: public MathParInset
{
public:
class MathMacroArgument: public MathParInset {
public:
///
MathMacroArgument() { expnd_mode = false; number = 1; SetType(LM_OT_MACRO_ARG); }
///
@ -119,8 +120,10 @@ class MathMacroArgument: public MathParInset
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string &);
#endif
///
void setNumber(int n) { number = n; }
/// Is expanded or not
@ -128,7 +131,7 @@ class MathMacroArgument: public MathParInset
/// Is expanded or not
bool getExpand() { return expnd_mode; }
private:
private:
///
bool expnd_mode;
///
@ -137,9 +140,8 @@ class MathMacroArgument: public MathParInset
/// This class contains the macro definition
class MathMacroTemplate: public MathParInset
{
public:
class MathMacroTemplate: public MathParInset {
public:
/// A template constructor needs all the data
MathMacroTemplate(char const *, int na = 0, int f = 0);
///
@ -150,8 +152,10 @@ class MathMacroTemplate: public MathParInset
void Metrics();
///
void WriteDef(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void WriteDef(string &);
void WriteDef(string &);
#endif
/// useful for special insets
void setTCode(MathedTextCodes t) { tcode = t; }
///
@ -172,7 +176,7 @@ class MathMacroTemplate: public MathParInset
/// Replace the appropriate arguments with a specific macro's data
void update(MathMacro * m = 0);
private:
private:
///
short flags;
///
@ -192,9 +196,8 @@ typedef MathMacro * MathMacroP;
typedef MathMacroTemplate * MathMacroTemplateP;
///
class MathMacroTable
{
public:
class MathMacroTable {
public:
///
MathMacroTable(int);
///
@ -212,7 +215,7 @@ class MathMacroTable
///
static bool built;
private:
private:
///
const int max_macros;
///
@ -264,10 +267,10 @@ void MathMacro::SetData(LyxArrayBase * a)
inline
MathMacro * MathMacroTable::getMacro(char const * name) const
{
MathMacroTemplate * mt = getTemplate(name);
return (mt) ? new MathMacro(mt): 0;
}
{
MathMacroTemplate * mt = getTemplate(name);
return (mt) ? new MathMacro(mt): 0;
}
#endif

View File

@ -98,14 +98,16 @@ char * strnew(char const * s)
}
static void mathPrintError(char const * msg)
static
void mathPrintError(char const * msg)
{
lyxerr << "Line ~" << yylineno << ": Math parse error: "
<< msg << endl;
}
static void LexInitCodes()
static
void LexInitCodes()
{
for (int i = 0; i <= 255; ++i) {
if (isalpha(i)) lexcode[i] = LexAlpha;
@ -134,7 +136,8 @@ static void LexInitCodes()
}
static char LexGetArg(char lf, bool accept_spaces= false)
static
char LexGetArg(char lf, bool accept_spaces= false)
{
char rg;
char * p = &yytext[0];
@ -170,7 +173,8 @@ static char LexGetArg(char lf, bool accept_spaces= false)
}
static int yylex(void)
static
int yylex(void)
{
static int init_done = 0;
unsigned char c;

View File

@ -135,14 +135,23 @@ void MathRootInset::SetFocus(int x, int)
void MathRootInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '[';
uroot->Write(os);
os << "]{";
MathParInset::Write(os);
os << '}';
#else
string output;
MathRootInset::Write(output);
os << output;
#endif
}
void MathRootInset::Write(string &outf)
#ifndef USE_OSTREAM_ONLY
void MathRootInset::Write(string & outf)
{
outf += '\\';
outf += name;
@ -152,3 +161,4 @@ void MathRootInset::Write(string &outf)
MathParInset::Write(outf);
outf += '}';
}
#endif

View File

@ -40,8 +40,12 @@ class MathRootInset: public MathSqrtInset {
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///

View File

@ -43,15 +43,22 @@ char const * math_font_name[] = {
void
MathSpaceInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
if (space >= 0 && space < 6) {
os << '\\' << latex_mathspace[space] << ' ';
}
#else
if (space >= 0 && space < 6) {
string output;
MathSpaceInset::Write(output);
os << output;
}
#endif
}
#ifndef USE_OSTREAM_ONLY
void
MathSpaceInset::Write(string & outf)
{
@ -61,34 +68,48 @@ MathSpaceInset::Write(string & outf)
outf += ' ';
}
}
#endif
void
MathDotsInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << ' ';
#else
string output;
MathDotsInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void
MathDotsInset::Write(string & outf)
{
outf += '\\';
outf += name;
outf += ' ';
}
}
#endif
void MathSqrtInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '{';
MathParInset::Write(os);
os << '}';
#else
string output;
MathSqrtInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathSqrtInset::Write(string & outf)
{
outf += '\\';
@ -97,18 +118,46 @@ void MathSqrtInset::Write(string & outf)
MathParInset::Write(outf);
outf += '}';
}
#endif
void MathDelimInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
os << "\\left";
if (l) {
os << '\\' << l->name << ' ';
} else {
if (left == '{' || left == '}') {
os << '\\' << char(left) << ' ';
} else {
os << char(left) << ' ';
}
}
MathParInset::Write(os);
os << "\\right";
if (r) {
os << '\\' << r->name << ' ';
} else {
if (right == '{' || right == '}') {
os << '\\' << char(right) << ' ';
} else {
os << char(right) << ' ';
}
}
#else
string output;
MathDelimInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathDelimInset::Write(string & outf)
{
{
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
outf += "\\left";
@ -143,16 +192,25 @@ void MathDelimInset::Write(string & outf)
}
}
}
#endif
void MathDecorationInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
os << '\\' << l->name << '{';
MathParInset::Write(os);
os << '}';
#else
string output;
MathDecorationInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathDecorationInset::Write(string & outf)
{
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
@ -162,16 +220,50 @@ void MathDecorationInset::Write(string & outf)
MathParInset::Write(outf);
outf += '}';
}
#endif
void MathAccentInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
os << '\\' << l->name;
if (code!= LM_not)
os << '{';
else
os << ' ';
if (inset) {
inset->Write(os);
} else {
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM) {
os << '\\'
<< math_font_name[fn-LM_TC_RM]
<< '{';
}
if (MathIsSymbol(fn)) {
latexkeys * l = lm_get_key_by_id(c, LM_TK_SYM);
if (l) {
os << '\\' << l->name << ' ';
}
} else
os << char(c);
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
os << '}';
}
if (code!= LM_not)
os << '}';
#else
string output;
MathAccentInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathAccentInset::Write(string & outf)
{
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
@ -207,16 +299,34 @@ void MathAccentInset::Write(string & outf)
if (code!= LM_not)
outf += '}';
}
#endif
void MathBigopInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
bool limp = GetLimits();
os << '\\' << name;
if (limp && !(sym != LM_int && sym != LM_oint
&& (GetStyle() == LM_ST_DISPLAY)))
os << "\\limits ";
else
if (!limp && (sym != LM_int && sym != LM_oint
&& (GetStyle() == LM_ST_DISPLAY)))
os << "\\nolimits ";
else
os << ' ';
#else
string output;
MathBigopInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathBigopInset::Write(string & outf)
{
bool limp = GetLimits();
@ -232,16 +342,26 @@ void MathBigopInset::Write(string & outf)
else
outf += ' ';
}
#endif
void MathFracInset::Write(ostream & os)
{
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '{';
MathParInset::Write(os);
os << "}{";
den->Write(os);
os << '}';
#else
string output;
MathFracInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathFracInset::Write(string & outf)
{
outf += '\\';
@ -252,17 +372,136 @@ void MathFracInset::Write(string & outf)
den->Write(outf);
outf += '}';
}
#endif
void MathParInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (!array) return;
int brace = 0;
latexkeys * l;
MathedIter data(array);
// hack
MathedRowSt const * crow = getRowSt();
data.Reset();
if (!Permit(LMPF_FIXED_SIZE)) {
l = lm_get_key_by_id(size, LM_TK_STY);
if (l) {
os << '\\' << l->name << ' ';
}
}
while (data.OK()) {
byte cx = data.GetChar();
if (cx >= ' ') {
int ls;
byte * s = data.GetString(ls);
if (data.FCode() >= LM_TC_RM && data.FCode() <= LM_TC_TEXTRM) {
os << '\\' << math_font_name[data.FCode()-LM_TC_RM] << '{';
}
while (ls > 0) {
if (MathIsSymbol(data.FCode())) {
l = lm_get_key_by_id(*s, (data.FCode() == LM_TC_BSYM) ?
LM_TK_BIGSYM : LM_TK_SYM);
if (l) {
os << '\\' << l->name << ' ';
} else {
lyxerr << "Illegal symbol code[" << *s
<< " " << ls << " " << data.FCode() << "]";
}
} else {
// Is there a standard logical XOR?
if ((data.FCode() == LM_TC_TEX && *s != '{' && *s != '}') ||
(data.FCode() == LM_TC_SPECIAL))
os << '\\';
else {
if (*s == '{') ++brace;
if (*s == '}') --brace;
}
if (*s == '}' && data.FCode() == LM_TC_TEX && brace < 0)
lyxerr <<"Math warning: Unexpected closing brace."
<< endl;
else
os << char(*s);
}
++s; --ls;
}
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
os << '}';
} else
if (MathIsInset(cx)) {
MathedInset * p = data.GetInset();
if (cx == LM_TC_UP)
os << "^{";
if (cx == LM_TC_DOWN)
os << "_{";
p->Write(os);
if (cx == LM_TC_UP || cx == LM_TC_DOWN)
os << '}';
data.Next();
} else
switch(cx) {
case LM_TC_TAB:
{
os << " & ";
data.Next();
break;
}
case LM_TC_CR:
{
if (crow) {
if (!crow->isNumbered()) {
os << "\\nonumber ";
}
if (crow->getLabel()) {
os << "\\label{"
<< crow->getLabel()
<< "} ";
}
crow = crow->getNext();
}
os << "\\\\\n";
++number_of_newlines;
data.Next();
break;
}
default:
lyxerr << "WMath Error: unrecognized code[" << cx << "]";
return;
}
}
if (crow) {
if (!crow->isNumbered()) {
os << "\\nonumber ";
}
if (crow->getLabel()) {
os << "\\label{"
<< crow->getLabel()
<< "} ";
}
}
#if 1
while (brace > 0) {
os << '}';
--brace;
}
#else
// Something like this should work too:
os << string(brace, '}'); // not one-off error I hope.
#endif
#else
if (!array) return;
string output;
MathParInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathParInset::Write(string & outf)
{
if (!array) return;
@ -380,16 +619,42 @@ void MathParInset::Write(string & outf)
--brace;
}
}
#endif
void MathMatrixInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (GetType() == LM_OT_MATRIX){
os << "\\begin{"
<< name
<< '}';
if (v_align == 't' || v_align == 'b') {
os << '['
<< char(v_align)
<< ']';
}
os << '{'
<< h_align
<< "}\n";
++number_of_newlines;
}
MathParInset::Write(os);
if (GetType() == LM_OT_MATRIX){
os << "\n\\end{"
<< name
<< '}';
++number_of_newlines;
}
#else
string output;
MathMatrixInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMatrixInset::Write(string & outf)
{
if (GetType() == LM_OT_MATRIX){
@ -414,22 +679,83 @@ void MathMatrixInset::Write(string & outf)
++number_of_newlines;
}
}
#endif
void mathed_write(MathParInset * p, ostream & os, int * newlines,
char fragile, char const * label)
{
#ifdef USE_OSTREAM_ONLY
number_of_newlines = 0;
short mathed_env = p->GetType();
if (mathed_env == LM_EN_INTEXT) {
if (fragile) os << "\\protect";
os << "\\( "; // changed from " \\( " (Albrecht Dress)
}
else {
// Thinko!
// Is this '\n' really needed, what can go wrong
//if it is not there?
#warning Thinko!
#if 0
if (!suffixIs(outf, '\n')) {
// in batchmode we need to make sure
// a space before an equation doesn't
// make the LaTeX output different
// compared to "Exported LaTeX" ARRae
// Modified to work in a cleaner and hopefully more general way
// (JMarc)
outf += "\n";
++number_of_newlines;
}
#endif
if (mathed_env == LM_EN_DISPLAY){
os << "\\[\n";
} else {
os << "\\begin{"
<< latex_mathenv[mathed_env]
<< "}\n";
}
++number_of_newlines;
}
if (label && label[0] > ' ' && mathed_env == LM_EN_EQUATION){
os << "\\label{"
<< label
<< "}\n";
++number_of_newlines;
}
p->Write(os);
if (mathed_env == LM_EN_INTEXT){
if (fragile) os << "\\protect";
os << " \\)";
}
else if (mathed_env == LM_EN_DISPLAY) {
os << "\\]\n";
++number_of_newlines;
}
else {
os << "\n\\end{"
<< latex_mathenv[mathed_env]
<< "}\n";
number_of_newlines += 2;
}
*newlines = number_of_newlines;
#else
string output;
mathed_write(p, output, newlines, fragile, label);
os << output;
#endif
}
extern int tex_code_break_column;
#ifndef USE_OSTREAM_ONLY
void mathed_write(MathParInset * p, string & outf, int * newlines,
char fragile, char const * label)
{
{
number_of_newlines = 0;
short mathed_env = p->GetType();
@ -484,3 +810,4 @@ void mathed_write(MathParInset * p, string & outf, int * newlines,
}
*newlines = number_of_newlines;
}
#endif

View File

@ -127,7 +127,8 @@ Menus::Menus(LyXView * view, int air)
}
inline BufferView * Menus::currentView()
inline
BufferView * Menus::currentView()
{
return _view->view();
}

View File

@ -87,7 +87,8 @@ static unsigned char const errno_tab[] =
EACCES, EACCES, EACCES, ENOENT, ENOMEM /* 330..334 */
};
inline int TranslateOS2Error(unsigned long rc)
inline
int TranslateOS2Error(unsigned long rc)
{
if (rc >= sizeof (errno_tab))
return EINVAL;

View File

@ -63,7 +63,7 @@ enum {
static bool RunSpellChecker(BufferView * bv);
static FILE *in, *out; /* streams to communicate with ispell */
static FILE * in, * out; /* streams to communicate with ispell */
pid_t isp_pid = -1; // pid for the `ispell' process. Also used (RO) in
// lyx_cb.C
@ -468,8 +468,8 @@ isp_result *ispell_check_word(char *word)
}
static
inline void ispell_terminate()
static inline
void ispell_terminate()
{
// Note: If you decide to optimize this out when it is not
// needed please note that when Aspell is used this command
@ -483,15 +483,15 @@ inline void ispell_terminate()
}
static
inline void ispell_terse_mode()
static inline
void ispell_terse_mode()
{
fputs("!\n", out); // Set terse mode (silently accept correct words)
}
static
inline void ispell_insert_word(char const *word)
static inline
void ispell_insert_word(char const *word)
{
fputc('*', out); // Insert word in personal dictionary
fputs(word, out);
@ -499,16 +499,16 @@ inline void ispell_insert_word(char const *word)
}
static
inline void ispell_accept_word(char const *word)
static inline
void ispell_accept_word(char const *word)
{
fputc('@', out); // Accept in this session
fputs(word, out);
fputc('\n', out);
}
static
inline void ispell_store_replacement(char const *mis, string const & cor) {
static inline
void ispell_store_replacement(char const *mis, string const & cor) {
if(actual_spell_checker == ASC_ASPELL) {
fputs("$$ra ", out);
fputs(mis, out);

View File

@ -85,7 +85,7 @@ struct Debug {
class DebugStream : public ostream {
public:
/// Constructor, sets the debug level to t.
DebugStream(Debug::type t = Debug::NONE);
explicit DebugStream(Debug::type t = Debug::NONE);
/// Constructor, sets the log file to f, and the debug level to t.
DebugStream(char const * f, Debug::type t = Debug::NONE);

View File

@ -8,7 +8,9 @@
#ifdef ENABLE_ASSERTIONS
template<class A> inline void Assert(A assertion)
template<class A>
inline
void Assert(A assertion)
{
if (!assertion) {
lyx::abort();
@ -17,7 +19,9 @@ template<class A> inline void Assert(A assertion)
#else
template<class A> inline void Assert(A /*assertion*/) {}
template<class A>
inline
void Assert(A /*assertion*/) {}
#endif /* ENABLE_ASSERTIONS */

View File

@ -989,7 +989,8 @@ bool LyXReadLink(string const & File, string & Link)
typedef pair<int, string> cmdret;
static cmdret do_popen(string const & cmd)
static
cmdret do_popen(string const & cmd)
{
// One question is if we should use popen or
// create our own popen based on fork, exec, pipe

View File

@ -28,14 +28,16 @@ int compare_no_case(string const & s, string const & s2);
int compare_no_case(string const & s, string const & s2, unsigned int len);
///
inline int compare(char const * a, char const * b)
inline
int compare(char const * a, char const * b)
{
return strcmp(a, b);
}
///
inline int compare(char const * a, char const * b, unsigned int len)
inline
int compare(char const * a, char const * b, unsigned int len)
{
return strncmp(a, b, len);
}
@ -55,7 +57,8 @@ string uppercase(string const &);
/// convert T to string
template<typename T>
inline string tostr(T const & t)
inline
string tostr(T const & t)
{
#ifdef HAVE_SSTREAM
ostringstream ostr;

View File

@ -1348,7 +1348,8 @@ void LyXText::SetParagraphExtraOpt(int type,
}
static char const * alphaCounter(int n) {
static
char const * alphaCounter(int n) {
static char result[2];
result[1] = 0;
if (n == 0)

View File

@ -55,17 +55,20 @@ static LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
//static int number_index, unit_index;
int number_index, unit_index;
static inline void lyx_advance (string & data, unsigned int n)
static inline
void lyx_advance (string & data, unsigned int n)
{
data.erase(0, n);
}
static inline bool isEndOfData (string const & data)
static inline
bool isEndOfData (string const & data)
{
return frontStrip (data).empty();
}
static char nextToken (string & data)
static
char nextToken (string & data)
{
data = frontStrip(data);
if (data.empty())