cleanups from John and Juergen, bib files parsing fix from Herbert

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3586 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-02-26 10:50:48 +00:00
parent 635fea0855
commit 1120aa806c
37 changed files with 327 additions and 235 deletions

View File

@ -1,3 +1,7 @@
2002-02-26 John Levon <moz@compsoc.man.ac.uk>
* acconfig.h: nt/os2 defines moved
2002-02-04 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* README: change reference to bugtracker

View File

@ -96,15 +96,11 @@ int mkstemp(char*);
#endif
#ifdef __EMX__
#include "os2_defines.h"
#endif
#ifdef VMS
#include "vms_defines.h"
#include "support/os2_defines.h"
#endif
#if defined(__CYGWIN__) || defined( __CYGWIN32__)
#include "nt_defines.h"
#include "support/nt_defines.h"
#endif
/* Some support for the boost library. */

View File

@ -1,3 +1,7 @@
2002-02-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* ui/default.ui: change Layout>LaTeX Preamble to Layout>Preamble.
2002-02-13 José Matos <jamatos@fep.up.pt>
* examples/linuxdoc_manpage.lyx: added

View File

@ -284,7 +284,7 @@ Menuset
# Item "TeX Style|X" "tex-mode"
Separator
Item "Change Environment Depth|v" "depth-increment"
Item "LaTeX Preamble...|L" "layout-preamble"
Item "Preamble...|r" "layout-preamble"
Item "Start Appendix here|A" "appendix"
End

View File

@ -9,7 +9,6 @@ src/converter.C
src/CutAndPaste.C
src/debug.C
src/exporter.C
src/ext_l10n.h
src/figure_form.C
src/figureForm.C
src/FontLoader.C

View File

@ -1,3 +1,36 @@
2002-02-26 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
* lyxserver.C:
* os2_defines.h:
* os2_errortable.h:
* nt_defines.h: move .h into support/
* vms_defines.h: remove
* WorkArea.C: add space in debug output
* text2.C:
* paragraph.C:
* buffer.C: add WITH_WARNINGS
* vc-backend.h:
* vc-backend.C:
* bufferlist.C: s/retrive/retrieve/, add docs
* vspace.h:
* vspace.C:
* kbmap.h:
* lyxlength.h:
* lyxgluelength.h:
* length_common.h:
* chset.h:
* chset.C: add docs
* lyxgui.C: add ID to X error handler
* lyxtestclass.c: fix typo
2002-02-26 Juergen Vigna <jug@sad.it>
* tabular_funcs.C (write_attribute): changed so that some default

View File

@ -187,9 +187,6 @@ lyx_SOURCES = \
main.C \
minibuffer.C \
minibuffer.h \
nt_defines.h \
os2_defines.h \
os2_errortable.h \
paragraph.C \
paragraph.h \
paragraph_pimpl.C \

View File

@ -299,7 +299,9 @@ std::stack<ErtComp> ert_stack;
ErtComp ert_comp;
#endif
#ifdef WITH_WARNINGS
#warning And _why_ is this here? (Lgb)
#endif
int unknown_layouts;
int unknown_tokens;

View File

@ -542,7 +542,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
// How can we know _how_ to do the checkout?
// With the current VC support it has to be,
// a RCS file since CVS do not have special ,v files.
RCS::retrive(s);
RCS::retrieve(s);
return loadLyXFile(filename, tolastfiles);
}
}

View File

@ -23,9 +23,10 @@ bool CharacterSet::loadFile(string const & fname)
{
map_.clear();
name_.erase();
if (fname.empty() || fname == "ascii")
return true; // ascii 7-bit
// ascii 7-bit
if (fname.empty() || fname == "ascii")
return true;
// open definition file
lyxerr[Debug::KBMAP]

View File

@ -1,4 +1,10 @@
// -*- C++ -*-
/**
* \file chset.h
* Copyright 2002 the LyX Team
* Read the file COPYING
*/
#ifndef CHSET_H
#define CHSET_H
@ -11,21 +17,33 @@
#include "LString.h"
///
/// a class for mapping char strings such as "\^{A}" to the integer value
class CharacterSet {
public:
///
bool loadFile(string const &);
///
/**
* initialise this charset from the given .cdef file
* param charset the charset to look for
*
* Finds a .cdef file corresponding to the named charset
* and parses it. This function is only intended to be
* called once.
*/
bool loadFile(string const & charset);
/// return the name of the current charset
string const & getName() const;
///
/**
* Return the encoded charset value of the given string.
*
* The bool value is false if an encoding could not be found
* in this charset, and true otherwise.
*/
std::pair<bool, int> const encodeString(string const &) const;
private:
///
/// charset name
string name_;
///
typedef std::map<string, unsigned char> Cdef;
///
/// mapping from string representation to encoded value
Cdef map_;
};
#endif

View File

@ -1,3 +1,7 @@
2002-02-21 Herbert Voss <voss@lyx.org>
* biblio.C: fix bug with commentlines in a bibentry
2002-02-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am: simpler obj. file compile

View File

@ -320,18 +320,29 @@ searchKeys(InfoMap const & theMap,
string const parseBibTeX(string data, string const & findkey)
{
string keyvalue;
for (string::iterator it = data.begin(); it < data.end(); ++it) {
if ((*it) == '\n' || (*it) == '\t')
(*it)= ' ';
// at first we delete all characters right of '%' and
// replace tabs through a space and remove leading spaces
string data_;
int Entries = 0;
string dummy = token(data,'\n', Entries);
while (!dummy.empty()) {
dummy = subst(dummy, '\t', ' '); // no tabs
dummy = frontStrip(dummy); // no leading spaces
if (dummy.find('%') != string::npos) {
if (dummy.find('%') > 0)
data_ += dummy.substr(0,data.find('%'));
}
else
data_ += dummy;
dummy = token(data, '\n', ++Entries);
}
data = frontStrip(data);
data = data_;
// now get only the important line of the bibtex entry.
// all entries are devided by ',' except the last one.
data += ','; // now we have same behaviour for all entries
// because the last one is "blah ... }"
int Entries = 0;
string dummy = token(data, ',', Entries);
Entries = 0;
dummy = token(data, ',', Entries);
while (!contains(lowercase(dummy), findkey) && !dummy.empty())
dummy = token(data, ',', ++Entries);
if (dummy.empty())

View File

@ -1,3 +1,8 @@
2002-02-24 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* forms/form_graphics.fd: Enlarge Restore button.
* FormGraphics.C: Set filter to bounding box input fields.
2002-02-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am: simpler obj. file compiling

View File

@ -143,6 +143,10 @@ void FormGraphics::build()
fl_set_input_return (bbox_->input_bb_x1, FL_RETURN_CHANGED);
fl_set_input_return (bbox_->input_bb_y1, FL_RETURN_CHANGED);
fl_set_input_filter(bbox_->input_bb_x0, fl_unsigned_float_filter);
fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter);
fl_set_input_filter(bbox_->input_bb_x1, fl_unsigned_float_filter);
string const bb_units = "pt|cm|in";
fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str());
bc().addReadOnly(bbox_->button_getBB);

View File

@ -22,9 +22,9 @@ FD_form_graphics * FormGraphics::build_graphics()
FL_OBJECT *obj;
FD_form_graphics *fdui = new FD_form_graphics;
fdui->form = fl_bgn_form(FL_NO_BOX, 510, 360);
fdui->form = fl_bgn_form(FL_NO_BOX, 510, 345);
fdui->form->u_vdata = this;
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 510, 360, "");
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 510, 345, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fdui->tabFolder = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 5, 5, 500, 270, _("Tabbed folder"));
fl_set_object_boxtype(obj, FL_FRAME_BOX);
@ -32,7 +32,7 @@ FD_form_graphics * FormGraphics::build_graphics()
fl_set_object_resize(obj, FL_RESIZE_ALL);
{
char const * const dummy = N_("Restore|#R");
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 5, 310, 80, 30, idex(_(dummy)));
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 5, 310, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);

View File

@ -10,13 +10,13 @@ SnapGrid: 5
=============== FORM ===============
Name: form_graphics
Width: 510
Height: 360
Height: 345
Number of Objects: 7
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 510 360
box: 0 0 510 345
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -52,7 +52,7 @@ argument:
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 5 310 80 30
box: 5 310 100 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER

View File

@ -1,10 +1,12 @@
// -*- C++ -*-
/* ======================================================================= *\
File : kbmap.h, kbmap.h,v 1.3 1996/12/10 04:35:57 larsbj Exp
Author : chb, 30.Oct.1995
Docu : see kbmap.C
Purpose: class definitions for XKeyEvent keymap handling
\* ==================================================================== */
/**
* \file kbmap.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author Lars Gullik Bjønnes <larsbj@lyx.org>
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef KBMAP_H
#define KBMAP_H
@ -93,4 +95,4 @@ private:
Table table;
};
#endif
#endif // KBMAP_H

View File

@ -1,16 +1,22 @@
// -*- C++ -*-
#ifndef LENGHT_COMMON_H
#define LENGHT_COMMON_H
#ifndef LENGTH_COMMON_H
#define LENGTH_COMMON_H
#include "LString.h"
#include "lyxlength.h"
/// the number of units possible
extern int const num_units;
// I am not sure if "mu" should be possible to select (Lgb)
/**
* array of unit names
*
* FIXME: I am not sure if "mu" should be possible to select (Lgb)
*/
extern char const *unit_name[];
/// return the unit given a string representation such as "cm"
LyXLength::UNIT unitFromString(string const & data);
#endif
#endif // LENGTH_COMMON_H

View File

@ -88,7 +88,7 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
// Get the reason for the crash.
char etxt[513];
XGetErrorText(display, xeev->error_code, etxt, 512);
lyxerr << etxt << endl;
lyxerr << etxt << " id: " << xeev->resourceid << endl;
// By doing an abort we get a nice backtrace. (hopefully)
lyx::abort();
return 0; // Solaris CC wants us to return something

View File

@ -1,13 +1,12 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
/**
* \file lyxgluelength.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* \author Matthias Ettrich
*/
#ifndef LYX_GLUE_LENGTH_H
#define LYX_GLUE_LENGTH_H
@ -78,4 +77,4 @@ bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2);
///
bool isValidGlueLength(string const & data, LyXGlueLength * result);
#endif
#endif // LYXGLUELENGTH_H

View File

@ -1,13 +1,12 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
/**
* \file lyxlength.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* \author Matthias Ettrich
*/
#ifndef LYX_LENGTH_H
#define LYX_LENGTH_H
@ -18,47 +17,30 @@
#include "LString.h"
//
/// LyXLength Class
//
/**
* LyXLength - Represents latex length measurement
*/
class LyXLength {
public:
/// length units
enum UNIT {
/// Scaled point (65536sp = 1pt) TeX's smallest unit.
SP,
/// Point = 1/72.27in = 0.351mm
PT,
/// Big point (72bp = 1in), also PostScript point
BP,
/// Didot point = 1/72 of a French inch, = 0.376mm
DD,
/// Millimeter = 2.845pt
MM,
/// Pica = 12pt = 4.218mm
PC,
/// Cicero = 12dd = 4.531mm
CC,
/// Centimeter = 10mm = 2.371pc
CM,
/// Inch = 25.4mm = 72.27pt = 6.022pc
IN,
/// Height of a small "x" for the current font.
EX,
/// Width of capital "M" in current font.
EM,
/// Math unit (18mu = 1em) for positioning in math mode
MU,
/// Percent of columnwidth both "%" or "%c"
PW,
///
PE,
/// Percent of pagewidth
PP,
/// Percent of linewidth
PL,
/// no unit
UNIT_NONE
SP, ///< Scaled point (65536sp = 1pt) TeX's smallest unit.
PT, ///< Point = 1/72.27in = 0.351mm
BP, ///< Big point (72bp = 1in), also PostScript point
DD, ///< Didot point = 1/72 of a French inch, = 0.376mm
MM, ///< Millimeter = 2.845pt
PC, ///< Pica = 12pt = 4.218mm
CC, ///< Cicero = 12dd = 4.531mm
CM, ///< Centimeter = 10mm = 2.371pc
IN, ///< Inch = 25.4mm = 72.27pt = 6.022pc
EX, ///< Height of a small "x" for the current font.
EM, ///< Width of capital "M" in current font.
MU, ///< Math unit (18mu = 1em) for positioning in math mode
PW, ///< Percent of columnwidth both "%" or "%c"
PE, ///< FIXME
PP, ///< Percent of pagewidth
PL, ///< Percent of linewidth
UNIT_NONE ///< no unit
};
///
@ -79,11 +61,11 @@ public:
void unit(LyXLength::UNIT unit);
///
bool zero() const;
/// conversion
/// return string representation
string const asString() const;
///
/// return string representation for LaTeX
string const asLatexString() const;
///
/// return the on-screen size of this length
int inPixels(int default_width, int default_height) const;
/** If "data" is valid, the length represented by it is
@ -103,7 +85,7 @@ bool operator==(LyXLength const & l1, LyXLength const & l2);
bool operator!=(LyXLength const & l1, LyXLength const & l2);
///
bool isValidLength(string const & data, LyXLength * result);
///
/// return the name of the given unit number
char const * stringFromUnit(int unit);
#endif
#endif // LYXLENGTH_H

View File

@ -62,7 +62,7 @@
#define INCL_DOSNMPIPES
#define INCL_DOSERRORS
#include <os2.h>
#include "os2_errortable.h"
#include "support/os2_errortable.h"
#endif
using std::endl;

View File

@ -57,7 +57,7 @@ bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
{
lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
if (!lay.Read(lexrc, *this)) {
// Reslove fonts
// Resolve fonts
lay.resfont = lay.font;
#ifndef INHERIT_LANGUAGE
lay.resfont.realize(defaultfont());

View File

@ -1615,13 +1615,13 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
// Fully instantiated font
LyXFont font = getFont(bparams, i);
LyXFont const last_font = running_font;
LyXFont const & last_font = running_font;
// Spaces at end of font change are simulated to be
// outside font change, i.e. we write "\textXX{text} "
// rather than "\textXX{text }". (Asger)
if (open_font && c == ' ' && i <= size() - 2) {
LyXFont const next_font = getFont(bparams, i + 1);
LyXFont const & next_font = getFont(bparams, i + 1);
if (next_font != running_font
&& next_font != font) {
font = next_font;
@ -1943,7 +1943,9 @@ Paragraph::getParLanguage(BufferParams const & bparams) const
return getFirstFontSettings().language();
#else
Language const * lang = getFirstFontSettings().language();
#ifdef WITH_WARNINGS
#warning We should make this somewhat better, any ideas? (Jug)
#endif
if (lang == inherit_language || lang == ignore_language)
lang = bparams.language;
return lang;

View File

@ -1,3 +1,10 @@
2002-02-26 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
* os2_defines.h:
* os2_errortable.h:
* nt_defines.h: moved from src/
2002-02-18 Herbert Voss <voss@perce.de>
* filetools.C: (getExtFromContents) return the fileextension

View File

@ -54,6 +54,9 @@ libsupport_la_SOURCES = \
lyxmanip.h \
$(LYXSTRING) lyxsum.C \
mkdir.C \
nt_defines.h \
os2_defines.h \
os2_errortable.h \
path.C \
path.h \
putenv.C \

View File

@ -2207,10 +2207,12 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
if (it != inset_owner) {
lyxerr << "InsetText is " << it << endl;
lyxerr << "inset_owner is " << inset_owner << endl;
#ifdef WITH_WARNINGS
#warning I believe this code is wrong. (Lgb)
#warning Jürgen, have a look at this. (Lgb)
#warning Hmmm, I guess you are right but we
#warning should verify when this is needed
#endif
// Jürgen, would you like to have a look?
// I guess we need to move the outer cursor
// and open and lock the inset (bla bla bla)

View File

@ -42,5 +42,3 @@ Undo::~Undo()
delete tmppar;
}
}

View File

@ -70,9 +70,9 @@ string const RCS::find_file(string const & file)
}
void RCS::retrive(string const & file)
void RCS::retrieve(string const & file)
{
lyxerr[Debug::LYXVC] << "LyXVC::RCS: retrive.\n\t" << file << endl;
lyxerr[Debug::LYXVC] << "LyXVC::RCS: retrieve.\n\t" << file << endl;
VCS::doVCCommand("co -q -r \""
+ file + "\"",
string());

View File

@ -1,4 +1,12 @@
// -*- C++ -*-
/**
* \file vc-backend.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author Lars Gullik Bjønnes
*/
#ifndef VC_BACKEND_H
#define VC_BACKEND_H
@ -11,61 +19,71 @@
class Buffer;
///
/// A simple version control system interface
class VCS {
public:
///
/// the status of the managed file
enum VCStatus {
///
UNLOCKED,
///
LOCKED
};
///
virtual ~VCS() {}
///
virtual void scanMaster() = 0;
///
/// register a file for version control
virtual void registrer(string const & msg) = 0;
///
/// check in the current revision
virtual void checkIn(string const & msg) = 0;
///
/// check out for editing
virtual void checkOut() = 0;
///
/// revert current edits
virtual void revert() = 0;
///
/// FIXME
virtual void undoLast() = 0;
///
/**
* getLog - read the revision log into the given file
* @param fname file name to read into
*/
virtual void getLog(string const &) = 0;
///
/// return the current version description
virtual string const versionString() const = 0;
///
/// return the current version
string const & version() const {
return version_;
}
///
/// return the user who has locked the file
string const & locker() const { return locker_; }
///
/// set the owning buffer
void owner(Buffer * b) { owner_ = b; }
///
/// return the owning buffer
Buffer * owner() const { return owner_; }
///
/// return the lock status of this file
VCStatus status() const { return vcstatus; }
protected:
///
static int doVCCommand(string const &, string const &);
/// parse information from the version file
virtual void scanMaster() = 0;
/**
* doVCCommand - call out to the version control utility
* @param cmd the command to execute
* @param path the path from which to execute
* @return exit status
*/
static int doVCCommand(string const & cmd, string const & path);
/** The master VC file. For RCS this is *,v or RCS/ *,v. master should
have full path.
*/
/**
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
* have full path.
*/
string master_;
/// The status of the VC controlled file.
VCStatus vcstatus;
/** The version of the VC file. I am not sure if this can be a
string of if it must be a
float/int. */
/**
* The version of the VC file. I am not sure if this can be a
* string or if it must be a float/int.
*/
string version_;
/// The user currently keeping the lock on the VC file.
@ -78,31 +96,33 @@ protected:
///
class RCS : public VCS {
public:
///
explicit
RCS(string const & m);
///
/// return the revision file for the given file, if found
static string const find_file(string const & file);
///
static void retrive(string const & file);
///
virtual void scanMaster();
///
static void retrieve(string const & file);
virtual void registrer(string const & msg);
///
virtual void checkIn(string const & msg);
///
virtual void checkOut();
///
virtual void revert();
///
virtual void undoLast();
///
virtual void getLog(string const &);
///
virtual string const versionString() const {
return "RCS: " + version_;
}
protected:
virtual void scanMaster();
};
@ -112,27 +132,30 @@ public:
///
explicit
CVS(string const & m, string const & f);
///
/// return the revision file for the given file, if found
static string const find_file(string const & file);
///
virtual void scanMaster();
///
virtual void registrer(string const & msg);
///
virtual void checkIn(string const & msg);
///
virtual void checkOut();
///
virtual void revert();
///
virtual void undoLast();
///
virtual void getLog(string const &);
///
virtual string const versionString() const {
return "CVS: " + version_;
}
protected:
virtual void scanMaster();
private:
string file_;
};
#endif
#endif // VCBACKEND_H

View File

@ -1,18 +0,0 @@
/* -*- C++ -*- */
/* This file is part of
* ======================================================
*
* LyX, the High Level Word Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ======================================================
A few prototypes and definitions needed for VMS / OpenVMS */
#ifndef VMS_DEFINES_H
#define VMS_DEFINES_H
/* Currently empty. */
#endif /* _VMS_DEFINES_H */

View File

@ -1,12 +1,10 @@
/* This file is part of
* ======================================================
/**
* \file vspace.C
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* \author Matthias Ettrich
*/
#include <config.h>
@ -21,6 +19,7 @@
#include "lyxrc.h"
#include "lyxtext.h"
#include "BufferView.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
@ -29,29 +28,45 @@
namespace {
double number[4] = { 0, 0, 0, 0 };
LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE };
/// used to return numeric values in parsing vspace
double number[4] = { 0, 0, 0, 0 };
/// used to return unit types in parsing vspace
LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE };
/// the current position in the number array
int number_index;
/// the current position in the unit array
int unit_index;
/// skip n characters of input
inline
void lyx_advance(string & data, string::size_type n)
{
data.erase(0, n);
}
/// return true when the input is at the end
inline
bool isEndOfData(string const & data)
{
return frontStrip(data).empty();
}
/**
* nextToken - return the next token in the input
* @param data input string
* @return a char representing the type of token returned
*
* The possible return values are :
* + stretch indicator for glue length
* - shrink indicator for glue length
* n a numeric value (stored in number array)
* u a unit type (stored in unit array)
* E parse error
*/
char nextToken(string & data)
{
data = frontStrip(data);
@ -125,6 +140,7 @@ char nextToken(string & data)
}
/// latex representation of a vspace
struct LaTeXLength {
char const * pattern;
int plus_val_index;
@ -134,6 +150,7 @@ struct LaTeXLength {
};
/// the possible formats for a vspace string
LaTeXLength table[] = {
{ "nu", 0, 0, 0, 0 },
{ "nu+nu", 2, 0, 2, 0 },
@ -242,10 +259,10 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result)
bool isValidLength(string const & data, LyXLength * result)
{
/// This is a trimmed down version of isValidGlueLength.
/// The parser may seem overkill for lengths without
/// glue, but since we already have it, using it is
/// easier than writing something from scratch.
// This is a trimmed down version of isValidGlueLength.
// The parser may seem overkill for lengths without
// glue, but since we already have it, using it is
// easier than writing something from scratch.
if (data.empty())
return true;
@ -425,7 +442,8 @@ string const VSpace::asLatexCommand(BufferParams const & params) const
case LENGTH: return keep_ ? "\\vspace*{" + len_.asLatexString() + '}'
: "\\vspace{" + len_.asLatexString() + '}';
}
return string(); // should never be reached
lyx::Assert(0);
}
@ -464,14 +482,12 @@ int VSpace::inPixels(BufferView * bv) const
retval = 3 * default_height;
break;
case LENGTH:
{
case LENGTH: {
int const default_width = bv->workWidth();
retval = len_.len().inPixels(default_width, default_height);
break;
}
}
return retval;
}

View File

@ -1,13 +1,11 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
/**
* \file vspace.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* \author Matthias Ettrich
*/
#ifndef VSPACE_H
#define VSPACE_H
@ -24,63 +22,57 @@ class BufferParams;
class BufferView;
///
/// A class representing latex vertical spacing
class VSpace {
public:
/// The different kinds of spaces.
enum vspace_kind {
///
NONE,
///
NONE, ///< no added vertical space
DEFSKIP,
///
SMALLSKIP,
///
MEDSKIP,
///
BIGSKIP,
///
VFILL,
///
LENGTH
LENGTH ///< user-defined length
};
/// Constructor
VSpace();
/// Constructor
explicit VSpace(vspace_kind k);
/// Constructor
explicit VSpace(LyXLength const & l);
/// Constructor
explicit VSpace(LyXGlueLength const & l);
/// Constructor for reading from a .lyx file
explicit VSpace(string const & data);
/// access functions
/// return the type of vertical space
vspace_kind kind() const;
///
/// return the length of this space
LyXGlueLength length() const;
// a flag that switches between \vspace and \vspace*
bool keep() const;
///
/// if set true, use \vspace* when type is not DEFSKIP
void setKeep(bool val);
///
bool operator==(VSpace const &) const;
// conversion
/// how it goes into the LyX file
string const asLyXCommand() const;
///
/// the latex representation
string const asLatexCommand(BufferParams const & params) const;
///
/// the size of the space on-screen
int inPixels(BufferView * bv) const;
private:
/// This VSpace kind
vspace_kind kind_;
///
/// the specified length
LyXGlueLength len_;
///
/// if true, use \vspace* type
bool keep_;
};