// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-1999 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
/* length units
*/
-static const int num_units = int(LyXLength::UNIT_NONE);
+static const int num_units = LyXLength::UNIT_NONE;
// I am not sure if "mu" should be possible to select (Lgb)
static char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
LyXLength::UNIT unitFromString (string const & data)
{
- int i=0;
+ int i = 0;
while ((i<num_units) && (data != unit_name[i])) ++i;
return (LyXLength::UNIT)i;
}
//static int number_index, unit_index;
int number_index, unit_index;
-static inline void advance (string & data, unsigned int n)
+static inline void lyx_advance (string & data, unsigned int n)
{
data.erase(0, n);
}
if (data.empty())
return '\0';
else if (data[0] == '+') {
- advance (data, 1);
+ lyx_advance (data, 1);
return '+';
}
else if (prefixIs(data, "plus")) {
- advance (data, 4);
+ lyx_advance (data, 4);
return '+';
}
else if (data[0] == '-') {
- advance (data, 1);
+ lyx_advance (data, 1);
return '-';
}
else if (prefixIs(data, "minus")) {
- advance (data, 5);
+ lyx_advance (data, 5);
return '-';
}
else {
string::size_type i;
// I really mean assignment ("=") below, not equality!
- if ((i = data.find_first_not_of("0123456789.")) != string::npos) {
+ if ((i = data.find_last_of("0123456789.")) != string::npos) {
if (number_index > 3) return 'E'; // Error
- string buffer = data.substr(0, i);
+ string buffer = data.substr(0, i + 1);
if (sscanf (buffer.c_str(),
"%f", &number[number_index]) == 1) {
- advance (data, i);
+ lyx_advance (data, i + 1);
++number_index;
return 'n';
} else
return 'E'; // Error
- } else if (( i = data
- .find_first_of("abcdefghijklmnopqrstuvwxyz")) != string::npos) {
+ } else if ((i = data.find_last_of("abcdefghijklmnopqrstuvwxyz"))
+ != string::npos) {
if (unit_index > 3) return 'E'; // Error
- string buffer = data.substr(0, i);
+ string buffer = data.substr(0, i + 1);
unit[unit_index] = unitFromString (buffer);
if (unit[unit_index] != LyXLength::UNIT_NONE) {
- advance (data, i);
+ lyx_advance (data, i + 1);
++unit_index;
return 'u';
} else
short val_sign = 1; // positive as default
switch(buffer[0]) {
case '-':
- advance(buffer, 1);
+ lyx_advance(buffer, 1);
val_sign = -1;
break;
case '+':
- advance(buffer, 1);
+ lyx_advance(buffer, 1);
// fall through
default:
// no action
short val_sign = 1; // positive as default
switch(buffer[0]) {
case '-':
- advance(buffer, 1);
+ lyx_advance(buffer, 1);
val_sign = -1;
break;
case '+':
- advance(buffer, 1);
+ lyx_advance(buffer, 1);
// fall through
default:
// no action
if (!isValidGlueLength (data, &tmp))
return; // should raise an exception
else {
- val=tmp.val;
- uni=tmp.uni;
- plus_val =tmp.plus_val;
- plus_uni =tmp.plus_uni;
- minus_val=tmp.minus_val;
- minus_uni=tmp.minus_uni;
+ val = tmp.val;
+ uni = tmp.uni;
+ plus_val = tmp.plus_val;
+ plus_uni = tmp.plus_uni;
+ minus_val = tmp.minus_val;
+ minus_uni = tmp.minus_uni;
}
}
}
-bool VSpace::operator== (VSpace const & other) const
+bool VSpace::operator==(VSpace const & other) const
{
if (this->kin == other.kin)
if (this->kin == LENGTH)
switch (kin) {
case NONE: return string();
case DEFSKIP:
- return current_view->currentBuffer()->params.getDefSkip().asLatexCommand();
+ return current_view->buffer()->params.getDefSkip().asLatexCommand();
case SMALLSKIP: return kp ? "\\vspace*{\\smallskipamount}"
: "\\smallskip{}";
case MEDSKIP: return kp ? "\\vspace*{\\medskipamount}"
int VSpace::inPixels() const
{
// Height of a normal line in pixels (zoom factor considered)
- int height = current_view->currentBuffer()->text->DefaultHeight(); // [pixels]
+#ifdef MOVE_TEXT
+ int height = current_view->text->DefaultHeight(); // [pixels]
+#else
+ int height = current_view->buffer()->text->DefaultHeight(); // [pixels]
+#endif
// Zoom factor specified by user in percent
float const zoom = lyxrc->zoom / 100.0; // [percent]
case NONE: return 0;
case DEFSKIP:
- return current_view->currentBuffer()->params.getDefSkip().inPixels();
+ return current_view->buffer()->params.getDefSkip().inPixels();
// This is how the skips are normally defined by
// LateX. But there should be some way to change