From 8c622e4ff04765c786cbe9ccc9824f4429aee4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 28 Apr 2007 12:58:49 +0000 Subject: [PATCH] rename/merge LyXLength related stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18067 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 14 +- src/{LyXLength.cpp => Length.cpp} | 217 ++++++++++++++---- src/{LyXLength.h => Length.h} | 94 ++++++-- src/LyXGlueLength.cpp | 140 ----------- src/LyXGlueLength.h | 78 ------- src/Makefile.am | 6 +- src/Paragraph.cpp | 2 +- src/ParagraphParameters.cpp | 6 +- src/ParagraphParameters.h | 10 +- src/TextMetrics.cpp | 2 +- src/VSpace.cpp | 24 +- src/VSpace.h | 10 +- src/frontends/controllers/BCView.h | 2 +- .../controllers/frontend_helpers.cpp | 2 +- src/frontends/qt4/LengthCombo.cpp | 6 +- src/frontends/qt4/LengthCombo.h | 8 +- src/frontends/qt4/QBox.cpp | 14 +- src/frontends/qt4/QDocument.cpp | 6 +- src/frontends/qt4/QExternal.cpp | 24 +- src/frontends/qt4/QGraphics.cpp | 18 +- src/frontends/qt4/QGraphicsDialog.cpp | 4 +- src/frontends/qt4/QTabular.cpp | 16 +- src/frontends/qt4/QVSpace.cpp | 8 +- src/frontends/qt4/QWrap.cpp | 10 +- src/frontends/qt4/Validator.cpp | 12 +- src/frontends/qt4/Validator.h | 23 +- src/frontends/qt4/qt_helpers.cpp | 26 +-- src/frontends/qt4/qt_helpers.h | 18 +- src/graphics/GraphicsParams.cpp | 10 +- src/insets/ExternalTransforms.h | 6 +- src/insets/InsetBox.cpp | 8 +- src/insets/InsetBox.h | 6 +- src/insets/InsetExternal.cpp | 4 +- src/insets/InsetGraphics.cpp | 40 ++-- src/insets/InsetGraphics.h | 2 +- src/insets/InsetGraphicsParams.cpp | 8 +- src/insets/InsetGraphicsParams.h | 6 +- src/insets/InsetTabular.cpp | 34 +-- src/insets/InsetTabular.h | 22 +- src/insets/InsetWrap.cpp | 4 +- src/insets/InsetWrap.h | 4 +- src/lengthcommon.cpp | 4 +- src/lengthcommon.h | 4 +- src/mathed/InsetMathGrid.cpp | 4 +- src/mathed/InsetMathGrid.h | 8 +- src/mathed/InsetMathKern.cpp | 2 +- src/mathed/InsetMathKern.h | 6 +- src/mathed/InsetMathXYMatrix.cpp | 2 +- src/mathed/InsetMathXYMatrix.h | 6 +- src/mathed/MathFactory.cpp | 4 +- src/mathed/MathParser.cpp | 2 +- src/tex2lyx/text.cpp | 24 +- src/text.cpp | 2 +- 53 files changed, 495 insertions(+), 527 deletions(-) rename src/{LyXLength.cpp => Length.cpp} (52%) rename src/{LyXLength.h => Length.h} (55%) delete mode 100644 src/LyXGlueLength.cpp delete mode 100644 src/LyXGlueLength.h diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index f9b037f35d..fd8d964a18 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -961,19 +961,19 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, } } if (!topmargin.empty()) - os << ",tmargin=" << from_ascii(LyXLength(topmargin).asLatexString()); + os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString()); if (!bottommargin.empty()) - os << ",bmargin=" << from_ascii(LyXLength(bottommargin).asLatexString()); + os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString()); if (!leftmargin.empty()) - os << ",lmargin=" << from_ascii(LyXLength(leftmargin).asLatexString()); + os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString()); if (!rightmargin.empty()) - os << ",rmargin=" << from_ascii(LyXLength(rightmargin).asLatexString()); + os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString()); if (!headheight.empty()) - os << ",headheight=" << from_ascii(LyXLength(headheight).asLatexString()); + os << ",headheight=" << from_ascii(Length(headheight).asLatexString()); if (!headsep.empty()) - os << ",headsep=" << from_ascii(LyXLength(headsep).asLatexString()); + os << ",headsep=" << from_ascii(Length(headsep).asLatexString()); if (!footskip.empty()) - os << ",footskip=" << from_ascii(LyXLength(footskip).asLatexString()); + os << ",footskip=" << from_ascii(Length(footskip).asLatexString()); os << "}\n"; texrow.newline(); } diff --git a/src/LyXLength.cpp b/src/Length.cpp similarity index 52% rename from src/LyXLength.cpp rename to src/Length.cpp index ae75fcd7eb..c9d6be2a4e 100644 --- a/src/LyXLength.cpp +++ b/src/Length.cpp @@ -1,5 +1,5 @@ /** - * \file LyXLength.cpp + * \file Length.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -15,7 +15,7 @@ #include -#include "LyXLength.h" +#include "Length.h" #include "lengthcommon.h" #include "LyXRC.h" @@ -26,25 +26,30 @@ namespace lyx { - using std::ostringstream; using std::string; -LyXLength::LyXLength() - : val_(0), unit_(LyXLength::UNIT_NONE) +///////////////////////////////////////////////////////////////////// +// +// Length +// +///////////////////////////////////////////////////////////////////// + +Length::Length() + : val_(0), unit_(Length::UNIT_NONE) {} -LyXLength::LyXLength(double v, LyXLength::UNIT u) +Length::Length(double v, Length::UNIT u) : val_(v), unit_(u) {} -LyXLength::LyXLength(string const & data) - : val_(0), unit_(LyXLength::PT) +Length::Length(string const & data) + : val_(0), unit_(Length::PT) { - LyXLength tmp; + Length tmp; if (!isValidLength(data, &tmp)) return; // should raise an exception @@ -54,7 +59,7 @@ LyXLength::LyXLength(string const & data) } -string const LyXLength::asString() const +string const Length::asString() const { ostringstream os; os << val_ << unit_name[unit_]; // setw? @@ -62,7 +67,7 @@ string const LyXLength::asString() const } -docstring const LyXLength::asDocstring() const +docstring const Length::asDocstring() const { odocstringstream os; os << val_ << unit_name[unit_]; // setw? @@ -70,7 +75,7 @@ docstring const LyXLength::asDocstring() const } -string const LyXLength::asLatexString() const +string const Length::asLatexString() const { ostringstream os; switch (unit_) { @@ -100,43 +105,43 @@ string const LyXLength::asLatexString() const } -double LyXLength::value() const +double Length::value() const { return val_; } -LyXLength::UNIT LyXLength::unit() const +Length::UNIT Length::unit() const { return unit_; } -void LyXLength::value(double v) +void Length::value(double v) { val_ = v; } -void LyXLength::unit(LyXLength::UNIT u) +void Length::unit(Length::UNIT u) { unit_ = u; } -bool LyXLength::zero() const +bool Length::zero() const { return val_ == 0.0; } -bool LyXLength::empty() const +bool Length::empty() const { - return unit_ == LyXLength::UNIT_NONE; + return unit_ == Length::UNIT_NONE; } -int LyXLength::inPixels(int text_width, int em_width_base) const +int Length::inPixels(int text_width, int em_width_base) const { // Zoom factor specified by user in percent double const zoom = lyxrc.zoom / 100.0; // [percent] @@ -159,79 +164,79 @@ int LyXLength::inPixels(int text_width, int em_width_base) const double result = 0.0; switch (unit_) { - case LyXLength::SP: + case Length::SP: // Scaled point: sp = 1/65536 pt result = zoom * dpi * val_ / (72.27 * 65536); // 4736286.7 break; - case LyXLength::PT: + case Length::PT: // Point: 1 pt = 1/72.27 inch result = zoom * dpi * val_ / 72.27; // 72.27 break; - case LyXLength::BP: + case Length::BP: // Big point: 1 bp = 1/72 inch result = zoom * dpi * val_ / 72; // 72 break; - case LyXLength::DD: + case Length::DD: // Didot: 1157dd = 1238 pt? result = zoom * dpi * val_ / (72.27 / (0.376 * 2.845)); // 67.559735 break; - case LyXLength::MM: + case Length::MM: // Millimeter: 1 mm = 1/25.4 inch result = zoom * dpi * val_ / 25.4; // 25.4 break; - case LyXLength::PC: + case Length::PC: // Pica: 1 pc = 12 pt result = zoom * dpi * val_ / (72.27 / 12); // 6.0225 break; - case LyXLength::CC: + case Length::CC: // Cicero: 1 cc = 12 dd result = zoom * dpi * val_ / (72.27 / (12 * 0.376 * 2.845)); // 5.6299779 break; - case LyXLength::CM: + case Length::CM: // Centimeter: 1 cm = 1/2.54 inch result = zoom * dpi * val_ / 2.54; // 2.54 break; - case LyXLength::IN: + case Length::IN: // Inch result = zoom * dpi * val_; break; - case LyXLength::EX: + case Length::EX: // Ex: The height of an "x" // 0.4305 is the ration between 1ex and 1em in cmr10 result = val_ * em_width * 0.4305; break; - case LyXLength::EM: + case Length::EM: // Em: The width of an "m" result = val_ * em_width; break; - case LyXLength::MU: + case Length::MU: // math unit = 1/18em result = val_ * em_width / 18; break; - case LyXLength::PCW: // Always % of workarea - case LyXLength::PTW: - case LyXLength::PLW: + case Length::PCW: // Always % of workarea + case Length::PTW: + case Length::PLW: result = val_ * text_width / 100; break; - case LyXLength::PPW: + case Length::PPW: // paperwidth/textwidth is 1.7 for A4 paper with default margins result = val_ * text_width * 1.7 / 100; break; - case LyXLength::PTH: + case Length::PTH: result = val_ * text_width * 1.787 / 100; break; - case LyXLength::PPH: + case Length::PPH: result = val_ * text_width * 2.2 / 100; break; - case LyXLength::UNIT_NONE: + case Length::UNIT_NONE: result = 0; // this cannot happen break; } @@ -239,21 +244,21 @@ int LyXLength::inPixels(int text_width, int em_width_base) const } -int LyXLength::inBP() const +int Length::inBP() const { - // return any LyXLength value as a one with + // return any Length value as a one with // the PostScript point, called bp (big points) double result = 0.0; switch (unit_) { - case LyXLength::CM: + case Length::CM: // 1bp = 0.2835cm result = val_ * 28.346; break; - case LyXLength::MM: + case Length::MM: // 1bp = 0.02835mm result = val_ * 2.8346; break; - case LyXLength::IN: + case Length::IN: // 1pt = 1/72in result = val_ * 72.0; break; @@ -266,13 +271,133 @@ int LyXLength::inBP() const } -bool operator==(LyXLength const & l1, LyXLength const & l2) +bool operator==(Length const & l1, Length const & l2) { return l1.value() == l2.value() && l1.unit() == l2.unit(); } -bool operator!=(LyXLength const & l1, LyXLength const & l2) +bool operator!=(Length const & l1, Length const & l2) +{ + return !(l1 == l2); +} + + +///////////////////////////////////////////////////////////////////// +// +// GlueLength +// +///////////////////////////////////////////////////////////////////// + + +GlueLength::GlueLength(Length const & len) + : len_(len) +{} + + +GlueLength::GlueLength(Length const & len, Length const & plus, + Length const & minus) + : len_(len), plus_(plus), minus_(minus) +{} + + +GlueLength::GlueLength(string const & data) +{ + isValidGlueLength(data, this); +} + + +string const GlueLength::asString() const +{ + ostringstream buffer; + + buffer << len_.value(); + + if (plus_.zero() && minus_.zero()) { + buffer << unit_name[len_.unit()]; + return buffer.str(); + } + + // just len and plus + if (minus_.zero()) { + if (len_.unit() != plus_.unit()) + buffer << unit_name[len_.unit()]; + buffer << '+' << plus_.value(); + buffer << unit_name[plus_.unit()]; + return buffer.str(); + } + + // just len and minus + if (plus_.zero()) { + if (len_.unit() != minus_.unit()) + buffer << unit_name[len_.unit()]; + buffer << '-' << minus_.value(); + buffer << unit_name[minus_.unit()]; + return buffer.str(); + } + + // ok, len, plus AND minus + + // len+- + if (minus_ == plus_) { + if (len_.unit() != minus_.unit()) + buffer << unit_name[len_.unit()]; + buffer << "+-" << minus_.value(); + buffer << unit_name[minus_.unit()]; + return buffer.str(); + } + + // this is so rare a case, why bother minimising units ? + + buffer << unit_name[len_.unit()]; + buffer << '+' << plus_.value() << unit_name[plus_.unit()]; + buffer << '-' << minus_.value() << unit_name[minus_.unit()]; + + return buffer.str(); +} + + +string const GlueLength::asLatexString() const +{ + ostringstream buffer; + + buffer << len_.value() << unit_name[len_.unit()]; + + if (!plus_.zero()) + buffer << " plus " << plus_.value() << unit_name[plus_.unit()]; + if (!minus_.zero()) + buffer << " minus " << minus_.value() << unit_name[minus_.unit()]; + return buffer.str(); +} + + +Length const & GlueLength::len() const +{ + return len_; +} + + +Length const & GlueLength::plus() const +{ + return plus_; +} + + +Length const & GlueLength::minus() const +{ + return minus_; +} + + +bool operator==(GlueLength const & l1, GlueLength const & l2) +{ + return l1.len() == l2.len() + && l1.plus() == l2.plus() + && l1.minus() == l2.minus(); +} + + +bool operator!=(GlueLength const & l1, GlueLength const & l2) { return !(l1 == l2); } diff --git a/src/LyXLength.h b/src/Length.h similarity index 55% rename from src/LyXLength.h rename to src/Length.h index 3ffc51cba4..6dff8b3c89 100644 --- a/src/LyXLength.h +++ b/src/Length.h @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file LyXLength.h + * \file Length.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -24,11 +24,17 @@ namespace lyx { #undef PC #undef SP +///////////////////////////////////////////////////////////////////// +// +// Length +// +///////////////////////////////////////////////////////////////////// + /** - * LyXLength - Represents latex length measurement + * Length - Represents latex length measurement */ -class LyXLength { +class Length { public: /// length units enum UNIT { @@ -54,14 +60,14 @@ public: }; /// - LyXLength(); + Length(); /// - LyXLength(double v, LyXLength::UNIT u); + Length(double v, Length::UNIT u); /// "data" must be a decimal number, followed by a unit - explicit LyXLength(std::string const & data); + explicit Length(std::string const & data); - void swap(LyXLength & rhs) + void swap(Length & rhs) { std::swap(val_, rhs.val_); std::swap(unit_, rhs.unit_); @@ -70,11 +76,11 @@ public: /// double value() const; /// - LyXLength::UNIT unit() const; + Length::UNIT unit() const; /// void value(double); /// - void unit(LyXLength::UNIT unit); + void unit(Length::UNIT unit); /// bool zero() const; /// @@ -90,19 +96,19 @@ public: /// return the on-screen size of this length of an image int inBP() const; - friend bool isValidLength(std::string const & data, LyXLength * result); + friend bool isValidLength(std::string const & data, Length * result); private: /// double val_; /// - LyXLength::UNIT unit_; + Length::UNIT unit_; }; /// -bool operator==(LyXLength const & l1, LyXLength const & l2); +bool operator==(Length const & l1, Length const & l2); /// -bool operator!=(LyXLength const & l1, LyXLength const & l2); +bool operator!=(Length const & l1, Length const & l2); /** Test whether \p data represents a valid length. * * \returns whether \p data is a valid length @@ -110,14 +116,72 @@ bool operator!=(LyXLength const & l1, LyXLength const & l2); * and LaTeX format is the representation of length variables as units (e.g. * \c text% vs. \c \\textwidth) you can actually use this function as well * for testing LaTeX lengths as long as they only contain real units like pt. - * \param result Pointer to a LyXLength variable. If \p result is not 0 and + * \param result Pointer to a Length variable. If \p result is not 0 and * \p data is valid, the length represented by it is stored into \p result. */ -bool isValidLength(std::string const & data, LyXLength * result = 0); +bool isValidLength(std::string const & data, Length * result = 0); /// return the LyX name of the given unit number char const * stringFromUnit(int unit); +///////////////////////////////////////////////////////////////////// +// +// GlueLength +// +///////////////////////////////////////////////////////////////////// + +class GlueLength { +public: + /// + GlueLength() {} + /// + explicit GlueLength(Length const & len); + /// + GlueLength(Length const & len, + Length const & plus, + Length const & minus); + + /** "data" must be a decimal number, followed by a unit, and + optional "glue" indicated by "+" and "-". You may abbreviate + reasonably. Examples: + 1.2 cm // 4mm +2pt // 2cm -4mm +2mm // 4+0.1-0.2cm + The traditional Latex format is also accepted, like + 4cm plus 10pt minus 10pt */ + explicit GlueLength(std::string const & data); + + /// + Length const & len() const; + /// + Length const & plus() const; + /// + Length const & minus() const; + + + /// conversion + std::string const asString() const; + /// + std::string const asLatexString() const; + + friend bool isValidGlueLength(std::string const & data, + GlueLength* result); + +private: + /// the normal vlaue + Length len_; + /// extra stretch + Length plus_; + /// extra shrink + Length minus_; +}; + +/// +bool operator==(GlueLength const & l1, GlueLength const & l2); +/// +bool operator!=(GlueLength const & l1, GlueLength const & l2); +/** If "data" is valid, the length represented by it is + stored into "result", if that is not 0. */ +bool isValidGlueLength(std::string const & data, GlueLength * result = 0); + } // namespace lyx #endif // LYXLENGTH_H diff --git a/src/LyXGlueLength.cpp b/src/LyXGlueLength.cpp deleted file mode 100644 index 046e5461d0..0000000000 --- a/src/LyXGlueLength.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/** - * \file LyXGlueLength.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * \author Matthias Ettrich - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "LyXGlueLength.h" -#include "lengthcommon.h" - -#include - - -namespace lyx { - -using std::ostringstream; -using std::string; - - -LyXGlueLength::LyXGlueLength(LyXLength const & len) - : len_(len) -{} - - -LyXGlueLength::LyXGlueLength(LyXLength const & len, LyXLength const & plus, - LyXLength const & minus) - : len_(len), plus_(plus), minus_(minus) -{} - - -LyXGlueLength::LyXGlueLength(string const & data) -{ - isValidGlueLength(data, this); -} - - -string const LyXGlueLength::asString() const -{ - ostringstream buffer; - - buffer << len_.value(); - - if (plus_.zero() && minus_.zero()) { - buffer << unit_name[len_.unit()]; - return buffer.str(); - } - - // just len and plus - if (minus_.zero()) { - if (len_.unit() != plus_.unit()) - buffer << unit_name[len_.unit()]; - buffer << '+' << plus_.value(); - buffer << unit_name[plus_.unit()]; - return buffer.str(); - } - - // just len and minus - if (plus_.zero()) { - if (len_.unit() != minus_.unit()) - buffer << unit_name[len_.unit()]; - buffer << '-' << minus_.value(); - buffer << unit_name[minus_.unit()]; - return buffer.str(); - } - - // ok, len, plus AND minus - - // len+- - if (minus_ == plus_) { - if (len_.unit() != minus_.unit()) - buffer << unit_name[len_.unit()]; - buffer << "+-" << minus_.value(); - buffer << unit_name[minus_.unit()]; - return buffer.str(); - } - - // this is so rare a case, why bother minimising units ? - - buffer << unit_name[len_.unit()]; - buffer << '+' << plus_.value() << unit_name[plus_.unit()]; - buffer << '-' << minus_.value() << unit_name[minus_.unit()]; - - return buffer.str(); -} - - -string const LyXGlueLength::asLatexString() const -{ - ostringstream buffer; - - buffer << len_.value() << unit_name[len_.unit()]; - - if (!plus_.zero()) - buffer << " plus " << plus_.value() << unit_name[plus_.unit()]; - if (!minus_.zero()) - buffer << " minus " << minus_.value() << unit_name[minus_.unit()]; - return buffer.str(); -} - - -LyXLength const & LyXGlueLength::len() const -{ - return len_; -} - - -LyXLength const & LyXGlueLength::plus() const -{ - return plus_; -} - - -LyXLength const & LyXGlueLength::minus() const -{ - return minus_; -} - - -bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2) -{ - return l1.len() == l2.len() - && l1.plus() == l2.plus() - && l1.minus() == l2.minus(); -} - - -bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2) -{ - return !(l1 == l2); -} - - -} // namespace lyx diff --git a/src/LyXGlueLength.h b/src/LyXGlueLength.h deleted file mode 100644 index f60f42374f..0000000000 --- a/src/LyXGlueLength.h +++ /dev/null @@ -1,78 +0,0 @@ -// -*- C++ -*- -/** - * \file LyXGlueLength.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * \author Matthias Ettrich - * \author Jean-Marc Lasgouttes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef LYX_GLUE_LENGTH_H -#define LYX_GLUE_LENGTH_H - -#include "LyXLength.h" - - -namespace lyx { - - -class LyXGlueLength { -public: - /// - LyXGlueLength() {} - /// - explicit LyXGlueLength(LyXLength const & len); - /// - LyXGlueLength(LyXLength const & len, - LyXLength const & plus, - LyXLength const & minus); - - /** "data" must be a decimal number, followed by a unit, and - optional "glue" indicated by "+" and "-". You may abbreviate - reasonably. Examples: - 1.2 cm // 4mm +2pt // 2cm -4mm +2mm // 4+0.1-0.2cm - The traditional Latex format is also accepted, like - 4cm plus 10pt minus 10pt */ - explicit LyXGlueLength(std::string const & data); - - /// - LyXLength const & len() const; - /// - LyXLength const & plus() const; - /// - LyXLength const & minus() const; - - - /// conversion - std::string const asString() const; - /// - std::string const asLatexString() const; - - friend bool isValidGlueLength(std::string const & data, - LyXGlueLength* result); - -private: - /// the normal vlaue - LyXLength len_; - /// extra stretch - LyXLength plus_; - /// extra shrink - LyXLength minus_; -}; - -/// -bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2); -/// -bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2); -/** If "data" is valid, the length represented by it is - stored into "result", if that is not 0. */ -bool isValidGlueLength(std::string const & data, LyXGlueLength * result = 0); - - -} // namespace lyx - -#endif // LYXGLUELENGTH_H diff --git a/src/Makefile.am b/src/Makefile.am index ca8e8b7937..abc4820e31 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -158,6 +158,8 @@ lyx_SOURCES = \ LaTeXFeatures.h \ LaTeX.h \ layout.h \ + Length.cpp \ + Length.h \ lengthcommon.cpp \ lengthcommon.h \ Lexer.cpp \ @@ -174,14 +176,10 @@ lyx_SOURCES = \ LyXFont.h \ LyXFunc.cpp \ LyXFunc.h \ - LyXGlueLength.cpp \ - LyXGlueLength.h \ LyX.h \ LyXLayout.cpp \ LyXLayout.h \ lyxlayout_ptr_fwd.h \ - LyXLength.cpp \ - LyXLength.h \ LyXRC.cpp \ LyXRC.h \ LyXServer.cpp \ diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 7cd2b86c22..1e736efd99 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -28,7 +28,7 @@ #include "Language.h" #include "LaTeXFeatures.h" #include "Color.h" -#include "LyXLength.h" +#include "Length.h" #include "LyXFont.h" #include "LyXRC.h" #include "Row.h" diff --git a/src/ParagraphParameters.cpp b/src/ParagraphParameters.cpp index ed3bf281d3..1438664114 100644 --- a/src/ParagraphParameters.cpp +++ b/src/ParagraphParameters.cpp @@ -164,13 +164,13 @@ void ParagraphParameters::labelWidthString(docstring const & lws) } -LyXLength const & ParagraphParameters::leftIndent() const +Length const & ParagraphParameters::leftIndent() const { return leftindent_; } -void ParagraphParameters::leftIndent(LyXLength const & li) +void ParagraphParameters::leftIndent(Length const & li) { leftindent_ = li; } @@ -194,7 +194,7 @@ void ParagraphParameters::read(Lexer & lex) noindent(true); } else if (token == "\\leftindent") { lex.next(); - LyXLength value(lex.getString()); + Length value(lex.getString()); leftIndent(value); } else if (token == "\\start_of_appendix") { startOfAppendix(true); diff --git a/src/ParagraphParameters.h b/src/ParagraphParameters.h index 62e462b66f..cbbc2759a4 100644 --- a/src/ParagraphParameters.h +++ b/src/ParagraphParameters.h @@ -15,7 +15,7 @@ #define PARAGRAPHPARAMETERS_H #include "layout.h" -#include "LyXLength.h" +#include "Length.h" #include "Spacing.h" #include "support/types.h" @@ -28,7 +28,7 @@ namespace lyx { class BufferView; -class LyXLength; +class Length; class Lexer; class Paragraph; class Spacing; @@ -76,9 +76,9 @@ public: /// void labelWidthString(docstring const &); /// - LyXLength const & leftIndent() const; + Length const & leftIndent() const; /// - void leftIndent(LyXLength const &); + void leftIndent(Length const &); /// read the parameters from a lex void read(Lexer & lex); @@ -107,7 +107,7 @@ private: /// docstring labelwidthstring_; /// - LyXLength leftindent_; + Length leftindent_; }; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 6720555da3..1ad906907c 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -29,7 +29,7 @@ #include "FuncRequest.h" #include "FontIterator.h" #include "Color.h" -#include "LyXLength.h" +#include "Length.h" #include "LyXRC.h" #include "LyXText.h" #include "MetricsInfo.h" diff --git a/src/VSpace.cpp b/src/VSpace.cpp index e88833e2f4..d720589eef 100644 --- a/src/VSpace.cpp +++ b/src/VSpace.cpp @@ -38,10 +38,10 @@ namespace { /// 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 }; +Length::UNIT unit[4] = { Length::UNIT_NONE, + Length::UNIT_NONE, + Length::UNIT_NONE, + Length::UNIT_NONE }; /// the current position in the number array int number_index; @@ -154,7 +154,7 @@ char nextToken(string & data) unit[unit_index] = unitFromString(buffer); } - if (unit[unit_index] != LyXLength::UNIT_NONE) { + if (unit[unit_index] != Length::UNIT_NONE) { ++unit_index; return 'u'; } @@ -203,7 +203,7 @@ const char * stringFromUnit(int unit) } -bool isValidGlueLength(string const & data, LyXGlueLength * result) +bool isValidGlueLength(string const & data, GlueLength * result) { // This parser is table-driven. First, it constructs a "pattern" // that describes the sequence of tokens in "data". For example, @@ -211,7 +211,7 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result) // numbers and units are stored into static arrays. Then, "pattern" // is searched in the "table". If it is found, the associated // table entries tell us which number and unit should go where - // in the LyXLength structure. Example: if "data" has the "pattern" + // in the Length structure. Example: if "data" has the "pattern" // "nu+nu-nu", the associated table entries are "2, 3, 2, 3". // That means, "plus_val" is the second number that was seen // in the input, "minus_val" is the third number, and "plus_uni" @@ -280,7 +280,7 @@ bool isValidGlueLength(string const & data, LyXGlueLength * result) } -bool isValidLength(string const & data, LyXLength * result) +bool isValidLength(string const & data, Length * result) { // This is a trimmed down version of isValidGlueLength. // The parser may seem overkill for lengths without @@ -350,12 +350,12 @@ VSpace::VSpace(vspace_kind k) {} -VSpace::VSpace(LyXLength const & l) +VSpace::VSpace(Length const & l) : kind_(LENGTH), len_(l), keep_(false) {} -VSpace::VSpace(LyXGlueLength const & l) +VSpace::VSpace(GlueLength const & l) : kind_(LENGTH), len_(l), keep_(false) {} @@ -392,7 +392,7 @@ VSpace::VSpace(string const & data) // without units in added_space_top/bottom. // Let unit default to centimeters here. kind_ = LENGTH; - len_ = LyXGlueLength(LyXLength(convert(input), LyXLength::CM)); + len_ = GlueLength(Length(convert(input), Length::CM)); } } @@ -403,7 +403,7 @@ VSpace::vspace_kind VSpace::kind() const } -LyXGlueLength const & VSpace::length() const +GlueLength const & VSpace::length() const { return len_; } diff --git a/src/VSpace.h b/src/VSpace.h index 03f91520e2..6715e935b5 100644 --- a/src/VSpace.h +++ b/src/VSpace.h @@ -12,7 +12,7 @@ #ifndef VSPACE_H #define VSPACE_H -#include "LyXGlueLength.h" +#include "Length.h" namespace lyx { @@ -39,9 +39,9 @@ public: explicit VSpace(vspace_kind k); - explicit VSpace(LyXLength const & l); + explicit VSpace(Length const & l); - explicit VSpace(LyXGlueLength const & l); + explicit VSpace(GlueLength const & l); /// Constructor for reading from a .lyx file explicit VSpace(std::string const & data); @@ -49,7 +49,7 @@ public: /// return the type of vertical space vspace_kind kind() const; /// return the length of this space - LyXGlueLength const & length() const; + GlueLength const & length() const; // a flag that switches between \vspace and \vspace* bool keep() const; @@ -73,7 +73,7 @@ private: /// This VSpace kind vspace_kind kind_; /// the specified length - LyXGlueLength len_; + GlueLength len_; /// if true, use \vspace* type bool keep_; }; diff --git a/src/frontends/controllers/BCView.h b/src/frontends/controllers/BCView.h index 5699c6ce81..6b35f7137d 100644 --- a/src/frontends/controllers/BCView.h +++ b/src/frontends/controllers/BCView.h @@ -34,7 +34,7 @@ class ButtonPolicy; * * Many widgets can be grouped together in the derived class if they * make a logical whole. E.g., an input and a choice widget that together - * are used to set a LyXLength can be interrogated together. + * are used to set a Length can be interrogated together. */ class CheckedWidget { public: diff --git a/src/frontends/controllers/frontend_helpers.cpp b/src/frontends/controllers/frontend_helpers.cpp index 3034cddc81..4acc4acf29 100644 --- a/src/frontends/controllers/frontend_helpers.cpp +++ b/src/frontends/controllers/frontend_helpers.cpp @@ -18,7 +18,7 @@ #include "debug.h" #include "gettext.h" #include "Language.h" -#include "LyXLength.h" +#include "Length.h" #include diff --git a/src/frontends/qt4/LengthCombo.cpp b/src/frontends/qt4/LengthCombo.cpp index ba7de38832..648bc7a246 100644 --- a/src/frontends/qt4/LengthCombo.cpp +++ b/src/frontends/qt4/LengthCombo.cpp @@ -27,9 +27,9 @@ LengthCombo::LengthCombo(QWidget * parent) } -lyx::LyXLength::UNIT LengthCombo::currentLengthItem() const +lyx::Length::UNIT LengthCombo::currentLengthItem() const { - return static_cast(currentIndex()); + return static_cast(currentIndex()); } @@ -40,7 +40,7 @@ void LengthCombo::has_activated(int) } -void LengthCombo::setCurrentItem(lyx::LyXLength::UNIT unit) +void LengthCombo::setCurrentItem(lyx::Length::UNIT unit) { QComboBox::setCurrentIndex(int(unit)); } diff --git a/src/frontends/qt4/LengthCombo.h b/src/frontends/qt4/LengthCombo.h index 345d2bdc18..affae3034f 100644 --- a/src/frontends/qt4/LengthCombo.h +++ b/src/frontends/qt4/LengthCombo.h @@ -20,7 +20,7 @@ //namespace lyx { /** - * A combo box for selecting LyXLength::UNIT types. + * A combo box for selecting Length::UNIT types. */ class LengthCombo : public QComboBox { Q_OBJECT @@ -29,11 +29,11 @@ public: LengthCombo(QWidget * parent); /// set the current item from unit - virtual void setCurrentItem(lyx::LyXLength::UNIT unit); + virtual void setCurrentItem(lyx::Length::UNIT unit); /// set the current item from int virtual void setCurrentItem(int item); /// get the current item - lyx::LyXLength::UNIT currentLengthItem() const; + lyx::Length::UNIT currentLengthItem() const; /// enable the widget virtual void setEnabled(bool b); /// use the %-items? @@ -43,7 +43,7 @@ protected Q_SLOTS: virtual void has_activated(int index); Q_SIGNALS: /// the current selection has changed - void selectionChanged(lyx::LyXLength::UNIT unit); + void selectionChanged(lyx::Length::UNIT unit); }; diff --git a/src/frontends/qt4/QBox.cpp b/src/frontends/qt4/QBox.cpp index 2987688fa1..a617cf35c2 100644 --- a/src/frontends/qt4/QBox.cpp +++ b/src/frontends/qt4/QBox.cpp @@ -60,13 +60,13 @@ QBoxDialog::QBoxDialog(QBox * form) connect(widthED, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); - connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); connect(valignCO, SIGNAL(highlighted(const QString &)), this, SLOT(change_adaptor())); connect(heightED, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); - connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::LyXLength::UNIT) ), + connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT) ), this, SLOT(change_adaptor())); connect(restorePB, SIGNAL(clicked()), this, SLOT(restoreClicked())); connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); @@ -127,7 +127,7 @@ void QBoxDialog::restoreClicked() { form_->setInnerType(true, 2); widthED->setText("100"); - widthUnitsLC->setCurrentItem(LyXLength::PCW); + widthUnitsLC->setCurrentItem(Length::PCW); heightED->setText("1"); for (int j = 0; j < heightUnitsLC->count(); j++) { if (heightUnitsLC->itemText(j) == qt_("Total Height")) @@ -217,8 +217,8 @@ void QBox::update_contents() dialog_->halignCO->setEnabled(!ibox); setSpecial(ibox); - LyXLength::UNIT default_unit = - (lyxrc.default_papersize > 3) ? LyXLength::CM : LyXLength::IN; + Length::UNIT default_unit = + (lyxrc.default_papersize > 3) ? Length::CM : Length::IN; lengthToWidgets(dialog_->widthED, dialog_->widthUnitsLC, (controller().params().width).asString(), default_unit); @@ -308,7 +308,7 @@ void QBox::apply() } else width = widgetsToLength(dialog_->widthED, dialog_->widthUnitsLC); - controller().params().width = LyXLength(width); + controller().params().width = Length(width); i = 0; spec = false; @@ -342,7 +342,7 @@ void QBox::apply() } else height = widgetsToLength(dialog_->heightED, dialog_->heightUnitsLC); - controller().params().height = LyXLength(height); + controller().params().height = Length(height); } diff --git a/src/frontends/qt4/QDocument.cpp b/src/frontends/qt4/QDocument.cpp index e66fe80d76..d3cd5e60e8 100644 --- a/src/frontends/qt4/QDocument.cpp +++ b/src/frontends/qt4/QDocument.cpp @@ -963,14 +963,14 @@ void QDocumentDialog::updateParams(BufferParams const & params) { // set the default unit // FIXME: move to controller - LyXLength::UNIT defaultUnit = LyXLength::CM; + Length::UNIT defaultUnit = Length::CM; switch (lyxrc.default_papersize) { case PAPER_DEFAULT: break; case PAPER_USLETTER: case PAPER_USLEGAL: case PAPER_USEXECUTIVE: - defaultUnit = LyXLength::IN; + defaultUnit = Length::IN; break; case PAPER_A3: @@ -979,7 +979,7 @@ void QDocumentDialog::updateParams(BufferParams const & params) case PAPER_B3: case PAPER_B4: case PAPER_B5: - defaultUnit = LyXLength::CM; + defaultUnit = Length::CM; break; case PAPER_CUSTOM: break; diff --git a/src/frontends/qt4/QExternal.cpp b/src/frontends/qt4/QExternal.cpp index 0d9e29aa9a..4b4c068187 100644 --- a/src/frontends/qt4/QExternal.cpp +++ b/src/frontends/qt4/QExternal.cpp @@ -95,7 +95,7 @@ QExternalDialog::QExternalDialog(QExternal * form) this, SLOT(formatChanged(const QString&))); connect(widthUnitCO, SIGNAL(activated(int)), this, SLOT(widthUnitChanged())); - connect(heightUnitCO, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); connect(displayCB, SIGNAL(stateChanged(int)), this, SLOT(change_adaptor())); @@ -155,7 +155,7 @@ bool QExternalDialog::activateAspectratio() const bool const wIsDbl = isStrDbl(wstr); if (wIsDbl && float_equal(convert(wstr), 0.0, 0.05)) return false; - LyXLength l; + Length l; if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero())) return false; @@ -269,14 +269,14 @@ void QExternalDialog::widthUnitChanged() namespace { -LyXLength::UNIT defaultUnit() +Length::UNIT defaultUnit() { - LyXLength::UNIT default_unit = LyXLength::CM; + Length::UNIT default_unit = Length::CM; switch (lyxrc.default_papersize) { case PAPER_USLETTER: case PAPER_USLEGAL: case PAPER_USEXECUTIVE: - default_unit = LyXLength::IN; + default_unit = Length::IN; break; default: break; @@ -394,7 +394,7 @@ void setSize(QLineEdit & widthED, QComboBox & widthUnitCO, } string const h = data.height.zero() ? string() : data.height.asString(); - LyXLength::UNIT default_unit = data.width.zero() ? + Length::UNIT default_unit = data.width.zero() ? defaultUnit() : data.width.unit(); lengthToWidgets(&heightED, &heightUnitCO, h, default_unit); @@ -420,24 +420,24 @@ void getSize(external::ResizeData & data, // Subtract one, because scale is 0. int const unit = widthUnitCO.currentIndex() - 1; - LyXLength w; + Length w; if (isValidLength(width, &w)) data.width = w; else if (isStrDbl(width)) - data.width = LyXLength(convert(width), - static_cast(unit)); + data.width = Length(convert(width), + static_cast(unit)); else - data.width = LyXLength(); + data.width = Length(); data.scale = string(); } else { // scaling instead of a width data.scale = width; - data.width = LyXLength(); + data.width = Length(); } - data.height = LyXLength(widgetsToLength(&heightED, &heightUnitCO)); + data.height = Length(widgetsToLength(&heightED, &heightUnitCO)); data.keepAspectRatio = aspectratioCB.isChecked(); } diff --git a/src/frontends/qt4/QGraphics.cpp b/src/frontends/qt4/QGraphics.cpp index 86771c96b9..1ef6052ebb 100644 --- a/src/frontends/qt4/QGraphics.cpp +++ b/src/frontends/qt4/QGraphics.cpp @@ -139,12 +139,12 @@ void QGraphics::update_contents() InsetGraphicsParams & igp = controller().params(); // set the right default unit - LyXLength::UNIT unitDefault = LyXLength::CM; + Length::UNIT unitDefault = Length::CM; switch (lyxrc.default_papersize) { case PAPER_USLETTER: case PAPER_USLEGAL: case PAPER_USEXECUTIVE: - unitDefault = LyXLength::IN; + unitDefault = Length::IN; break; default: break; @@ -169,7 +169,7 @@ void QGraphics::update_contents() controller().bbChanged = false; } else { // get the values from the inset - LyXLength anyLength; + Length anyLength; string const xl(token(igp.bb, ' ', 0)); string const yl(token(igp.bb, ' ', 1)); string const xr(token(igp.bb, ' ', 2)); @@ -347,19 +347,19 @@ void QGraphics::apply() //the graphics section if (dialog_->scaleCB->isChecked() && !dialog_->Scale->text().isEmpty()) { igp.scale = fromqstr(dialog_->Scale->text()); - igp.width = LyXLength("0pt"); - igp.height = LyXLength("0pt"); + igp.width = Length("0pt"); + igp.height = Length("0pt"); igp.keepAspectRatio = false; } else { igp.scale = string(); igp.width = dialog_->WidthCB->isChecked() ? //Note that this works even if dialog_->Width is "auto", since in //that case we get "0pt". - LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit)): - LyXLength("0pt"); + Length(widgetsToLength(dialog_->Width, dialog_->widthUnit)): + Length("0pt"); igp.height = dialog_->HeightCB->isChecked() ? - LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit)) : - LyXLength("0pt"); + Length(widgetsToLength(dialog_->Height, dialog_->heightUnit)) : + Length("0pt"); igp.keepAspectRatio = dialog_->aspectratio->isEnabled() && dialog_->aspectratio->isChecked() && igp.width.value() > 0 && igp.height.value() > 0; diff --git a/src/frontends/qt4/QGraphicsDialog.cpp b/src/frontends/qt4/QGraphicsDialog.cpp index 1541c72b55..4f499d2b76 100644 --- a/src/frontends/qt4/QGraphicsDialog.cpp +++ b/src/frontends/qt4/QGraphicsDialog.cpp @@ -63,9 +63,9 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form) this, SLOT(change_adaptor())); connect(Height, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); - connect(heightUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); - connect(widthUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); connect(aspectratio, SIGNAL(stateChanged(int)), this, SLOT(change_adaptor())); diff --git a/src/frontends/qt4/QTabular.cpp b/src/frontends/qt4/QTabular.cpp index db9dddf981..cc501c0a22 100644 --- a/src/frontends/qt4/QTabular.cpp +++ b/src/frontends/qt4/QTabular.cpp @@ -56,17 +56,17 @@ QTabularDialog::QTabularDialog(QTabular * form) connect(topspaceED, SIGNAL(returnPressed()), this, SLOT(topspace_changed())); - connect(topspaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(topspace_changed())); connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed())); connect(bottomspaceED, SIGNAL(returnPressed()), this, SLOT(bottomspace_changed())); - connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(bottomspace_changed())); connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed())); connect(interlinespaceED, SIGNAL(returnPressed()), this, SLOT(interlinespace_changed())); - connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(interlinespace_changed())); connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed())); connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool))); @@ -95,7 +95,7 @@ QTabularDialog::QTabularDialog(QTabular * form) connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked())); connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed())); connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed())); - connect(widthUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), this, SLOT(width_changed())); + connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed())); connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked())); connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed())); connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed())); @@ -653,7 +653,7 @@ void QTabular::update_contents() update_borders(); - LyXLength pwidth; + Length pwidth; docstring special; if (multicol) { @@ -669,7 +669,7 @@ void QTabular::update_contents() bool const isReadonly = bc().bp().isReadOnly(); dialog_->specialAlignmentED->setEnabled(!isReadonly); - LyXLength::UNIT default_unit = controller().useMetricUnits() ? LyXLength::CM : LyXLength::IN; + Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN; dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs()); dialog_->booktabsRB->setChecked(tabular.useBookTabs()); @@ -896,8 +896,8 @@ void QTabular::closeGUI() string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit); string width2; - LyXLength llen = tabular.getColumnPWidth(cell); - LyXLength llenMulti = tabular.getMColumnPWidth(cell); + Length llen = tabular.getColumnPWidth(cell); + Length llenMulti = tabular.getMColumnPWidth(cell); if (multicol && !llenMulti.zero()) width2 = llenMulti.asString(); diff --git a/src/frontends/qt4/QVSpace.cpp b/src/frontends/qt4/QVSpace.cpp index 7ca55ad9d8..3d3bd68524 100644 --- a/src/frontends/qt4/QVSpace.cpp +++ b/src/frontends/qt4/QVSpace.cpp @@ -69,7 +69,7 @@ QVSpaceDialog::QVSpaceDialog(QVSpace * form) this, SLOT(enableCustom(int))); connect(keepCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(unitCO, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); valueLE->setValidator(unsignedLengthValidator(valueLE)); @@ -133,8 +133,8 @@ static void setWidgetsFromVSpace(VSpace const & space, spacing->setCurrentIndex(item); keep->setChecked(space.keep()); - LyXLength::UNIT default_unit = - (lyxrc.default_papersize > 3) ? LyXLength::CM : LyXLength::IN; + Length::UNIT default_unit = + (lyxrc.default_papersize > 3) ? Length::CM : Length::IN; bool const custom_vspace = space.kind() == VSpace::LENGTH; if (custom_vspace) { value->setEnabled(true); @@ -173,7 +173,7 @@ static VSpace setVSpaceFromWidgets(int spacing, space = VSpace(VSpace::VFILL); break; case 5: - space = VSpace(LyXGlueLength(widgetsToLength(value, unit))); + space = VSpace(GlueLength(widgetsToLength(value, unit))); break; } diff --git a/src/frontends/qt4/QWrap.cpp b/src/frontends/qt4/QWrap.cpp index 37df9eb054..f2fff95e03 100644 --- a/src/frontends/qt4/QWrap.cpp +++ b/src/frontends/qt4/QWrap.cpp @@ -52,7 +52,7 @@ QWrapDialog::QWrapDialog(QWrap * form) connect(widthED, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); - connect(unitsLC, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), + connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); connect(valignCO, SIGNAL(highlighted(const QString &)), this, SLOT(change_adaptor())); @@ -103,13 +103,13 @@ void QWrap::build_dialog() void QWrap::apply() { double const value = convert(fromqstr(dialog_->widthED->text())); - LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem(); + Length::UNIT unit = dialog_->unitsLC->currentLengthItem(); if (dialog_->widthED->text().isEmpty()) - unit = LyXLength::UNIT_NONE; + unit = Length::UNIT_NONE; InsetWrapParams & params = controller().params(); - params.width = LyXLength(value, unit); + params.width = Length(value, unit); switch (dialog_->valignCO->currentIndex()) { case 0: @@ -144,7 +144,7 @@ void QWrap::update_contents() { InsetWrapParams & params = controller().params(); - LyXLength len(params.width); + Length len(params.width); dialog_->widthED->setText(toqstr(numtostr(len.value()))); dialog_->unitsLC->setCurrentItem(len.unit()); diff --git a/src/frontends/qt4/Validator.cpp b/src/frontends/qt4/Validator.cpp index a8bdf34f1b..b73e06ef2e 100644 --- a/src/frontends/qt4/Validator.cpp +++ b/src/frontends/qt4/Validator.cpp @@ -50,12 +50,12 @@ QValidator::State LengthValidator::validate(QString & qtext, int &) const return QValidator::Acceptable; if (glue_length_) { - LyXGlueLength gl; + GlueLength gl; return (isValidGlueLength(text, &gl)) ? QValidator::Acceptable : QValidator::Intermediate; } - LyXLength l; + Length l; bool const valid_length = isValidLength(text, &l); if (!valid_length) return QValidator::Intermediate; @@ -68,14 +68,14 @@ QValidator::State LengthValidator::validate(QString & qtext, int &) const } -void LengthValidator::setBottom(LyXLength const & b) +void LengthValidator::setBottom(Length const & b) { b_ = b; no_bottom_ = false; } -void LengthValidator::setBottom(LyXGlueLength const & g) +void LengthValidator::setBottom(GlueLength const & g) { g_ = g; no_bottom_ = false; @@ -86,7 +86,7 @@ void LengthValidator::setBottom(LyXGlueLength const & g) LengthValidator * unsignedLengthValidator(QLineEdit * ed) { LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); + v->setBottom(Length()); return v; } @@ -108,7 +108,7 @@ QValidator::State LengthAutoValidator::validate(QString & qtext, int & dummy) co LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit * ed) { LengthAutoValidator * v = new LengthAutoValidator(ed); - v->setBottom(LyXLength()); + v->setBottom(Length()); return v; } diff --git a/src/frontends/qt4/Validator.h b/src/frontends/qt4/Validator.h index f4da36bd9f..682c247c3f 100644 --- a/src/frontends/qt4/Validator.h +++ b/src/frontends/qt4/Validator.h @@ -25,8 +25,7 @@ #ifndef VALIDATOR_H #define VALIDATOR_H -#include "LyXLength.h" -#include "LyXGlueLength.h" +#include "Length.h" #include @@ -37,7 +36,7 @@ class QLineEdit; namespace lyx { /** A class to ascertain whether the data passed to the @c validate() - * member function can be interpretted as a LyXGlueLength. + * member function can be interpretted as a GlueLength. */ class LengthValidator : public QValidator { @@ -46,18 +45,18 @@ public: /// Define a validator for widget @c parent. LengthValidator(QWidget * parent); - /** @returns QValidator::Acceptable if @c data is a LyXGlueLength. + /** @returns QValidator::Acceptable if @c data is a GlueLength. * If not, returns QValidator::Intermediate. */ QValidator::State validate(QString & data, int &) const; /** @name Bottom - * Set and retrieve the minimum allowed LyXLength value. + * Set and retrieve the minimum allowed Length value. */ //@{ - void setBottom(LyXLength const &); - void setBottom(LyXGlueLength const &); - LyXLength bottom() const { return b_; } + void setBottom(Length const &); + void setBottom(GlueLength const &); + Length bottom() const { return b_; } //@} private: @@ -66,8 +65,8 @@ private: LengthValidator& operator=( const LengthValidator & ); #endif - LyXLength b_; - LyXGlueLength g_; + Length b_; + GlueLength g_; bool no_bottom_; bool glue_length_; }; @@ -81,7 +80,7 @@ LengthValidator * unsignedLengthValidator(QLineEdit *); //hard-coding it as "auto". But see qt_helpers.h for reasons this //is not so trivial and an idea about how to do it. (RGH) /** A class to ascertain whether the data passed to the @c validate() - * member function can be interpretted as a LyXGlueLength or is "auto". + * member function can be interpretted as a GlueLength or is "auto". */ class LengthAutoValidator : public LengthValidator { @@ -90,7 +89,7 @@ class LengthAutoValidator : public LengthValidator /// Define a validator for widget @c parent. LengthAutoValidator(QWidget * parent); - /** @returns QValidator::Acceptable if @c data is a LyXGlueLength + /** @returns QValidator::Acceptable if @c data is a GlueLength * or is "auto". If not, returns QValidator::Intermediate. */ QValidator::State validate(QString & data, int &) const; diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp index 24392f5bb9..5cf3cfb3a0 100644 --- a/src/frontends/qt4/qt_helpers.cpp +++ b/src/frontends/qt4/qt_helpers.cpp @@ -71,38 +71,38 @@ string widgetsToLength(QLineEdit const * input, LengthCombo const * combo) if (isValidGlueLength(fromqstr(length))) return fromqstr(length); - LyXLength::UNIT const unit = combo->currentLengthItem(); + Length::UNIT const unit = combo->currentLengthItem(); - return LyXLength(length.toDouble(), unit).asString(); + return Length(length.toDouble(), unit).asString(); } -LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo) +Length widgetsToLength(QLineEdit const * input, QComboBox const * combo) { QString const length = input->text(); if (length.isEmpty()) - return LyXLength(); + return Length(); // don't return unit-from-choice if the input(field) contains a unit if (isValidGlueLength(fromqstr(length))) - return LyXLength(fromqstr(length)); + return Length(fromqstr(length)); - LyXLength::UNIT const unit = unitFromString(fromqstr(combo->currentText())); + Length::UNIT const unit = unitFromString(fromqstr(combo->currentText())); - return LyXLength(length.toDouble(), unit); + return Length(length.toDouble(), unit); } void lengthToWidgets(QLineEdit * input, LengthCombo * combo, - LyXLength const & len, LyXLength::UNIT defaultUnit) + Length const & len, Length::UNIT defaultUnit) { - combo->setCurrentItem(LyXLength(len).unit()); - input->setText(toqstr(convert(LyXLength(len).value()))); + combo->setCurrentItem(Length(len).unit()); + input->setText(toqstr(convert(Length(len).value()))); } void lengthToWidgets(QLineEdit * input, LengthCombo * combo, - string const & len, LyXLength::UNIT defaultUnit) + string const & len, Length::UNIT defaultUnit) { if (len.empty()) { // no length (UNIT_NONE) @@ -113,13 +113,13 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo, combo->setCurrentItem(defaultUnit); input->setText(toqstr(len)); } else { - lengthToWidgets(input, combo, LyXLength(len), defaultUnit); + lengthToWidgets(input, combo, Length(len), defaultUnit); } } void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo, - LyXLength const & len, LyXLength::UNIT defaultUnit) + Length const & len, Length::UNIT defaultUnit) { if (len.value() == 0) lengthToWidgets(input, combo, "auto", defaultUnit); diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index 8f0e811105..29ecf5c353 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -13,7 +13,7 @@ #ifndef QTHELPERS_H #define QTHELPERS_H -#include "LyXLength.h" +#include "Length.h" #include "support/docstring.h" #include "support/qstring_helpers.h" @@ -32,21 +32,21 @@ std::string makeFontName(std::string const & family, std::string const & foundry std::pair parseFontName(std::string const & name); -/// method to get a LyXLength from widgets (LengthCombo) +/// method to get a Length from widgets (LengthCombo) std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo); -/// method to get a LyXLength from widgets (QComboBox) -LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo); +/// method to get a Length from widgets (QComboBox) +Length widgetsToLength(QLineEdit const * input, QComboBox const * combo); //FIXME It would be nice if defaultUnit were a default argument -/// method to set widgets from a LyXLength +/// method to set widgets from a Length void lengthToWidgets(QLineEdit * input, LengthCombo * combo, - LyXLength const & len, LyXLength::UNIT default_unit); + Length const & len, Length::UNIT default_unit); /// method to set widgets from a string void lengthToWidgets(QLineEdit * input, LengthCombo * combo, - std::string const & len, LyXLength::UNIT default_unit); -/// method to set widgets from a LyXLength with optional "auto" if zero + std::string const & len, Length::UNIT default_unit); +/// method to set widgets from a Length with optional "auto" if zero void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo, - LyXLength const & len, LyXLength::UNIT defaultUnit); + Length const & len, Length::UNIT defaultUnit); //FIXME setAutoTextCB should really take an argument, as indicated, that //determines what text is to be written for "auto". But making diff --git a/src/graphics/GraphicsParams.cpp b/src/graphics/GraphicsParams.cpp index ce23f0b5c5..0677d95b2a 100644 --- a/src/graphics/GraphicsParams.cpp +++ b/src/graphics/GraphicsParams.cpp @@ -12,7 +12,7 @@ #include "GraphicsParams.h" -#include "LyXLength.h" +#include "Length.h" #include @@ -71,10 +71,10 @@ BoundingBox::BoundingBox(string const & bb) // inBP returns the length in Postscript points. // Note further that there are 72 Postscript pixels per inch. - unsigned int const xl_tmp = abs(LyXLength(a).inBP()); - unsigned int const yb_tmp = abs(LyXLength(b).inBP()); - unsigned int const xr_tmp = abs(LyXLength(c).inBP()); - unsigned int const yt_tmp = abs(LyXLength(d).inBP()); + unsigned int const xl_tmp = abs(Length(a).inBP()); + unsigned int const yb_tmp = abs(Length(b).inBP()); + unsigned int const xr_tmp = abs(Length(c).inBP()); + unsigned int const yt_tmp = abs(Length(d).inBP()); if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp) return; diff --git a/src/insets/ExternalTransforms.h b/src/insets/ExternalTransforms.h index 3d6b9338a2..a43b45b312 100644 --- a/src/insets/ExternalTransforms.h +++ b/src/insets/ExternalTransforms.h @@ -12,7 +12,7 @@ #ifndef EXTERNALTRANSFORMS_H #define EXTERNALTRANSFORMS_H -#include "LyXLength.h" +#include "Length.h" #include "graphics/GraphicsParams.h" @@ -63,8 +63,8 @@ public: bool usingScale() const; std::string scale; - LyXLength width; - LyXLength height; + Length width; + Length height; bool keepAspectRatio; }; diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index cec9123660..581bd57e11 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -508,12 +508,12 @@ InsetBoxParams::InsetBoxParams(string const & label) : type(label), use_parbox(false), inner_box(true), - width(LyXLength("100col%")), + width(Length("100col%")), special("none"), pos('t'), hor_pos('c'), inner_pos('t'), - height(LyXLength("1in")), + height(Length("1in")), height_special("totalheight") // default is 1\\totalheight {} @@ -614,7 +614,7 @@ void InsetBoxParams::read(Lexer & lex) return; if (token == "width") { lex.next(); - width = LyXLength(lex.getString()); + width = Length(lex.getString()); } else { lyxerr << "InsetBox::Read: Missing 'width'-tag!" << endl; lex.pushToken(token); @@ -638,7 +638,7 @@ void InsetBoxParams::read(Lexer & lex) return; if (token == "height") { lex.next(); - height = LyXLength(lex.getString()); + height = Length(lex.getString()); } else { lyxerr << "InsetBox::Read: Missing 'height'-tag!" << endl; lex.pushToken(token); diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index d905fa049d..3f3b43b73f 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -14,7 +14,7 @@ #define INSETBOX_H #include "InsetCollapsable.h" -#include "LyXLength.h" +#include "Length.h" #include "MailInset.h" @@ -36,7 +36,7 @@ public: /// columnwidth? bool inner_box; /// - LyXLength width; + Length width; /// "special" widths, see usrguide.dvi §3.5 std::string special; /// @@ -46,7 +46,7 @@ public: /// char inner_pos; /// - LyXLength height; + Length height; /// std::string height_special; }; diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 1d924c8261..06733efdd9 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -337,7 +337,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) case EX_HEIGHT: lex.next(); - resizedata.height = LyXLength(lex.getString()); + resizedata.height = Length(lex.getString()); break; case EX_KEEPASPECTRATIO: @@ -361,7 +361,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) case EX_WIDTH: lex.next(); - resizedata.width = LyXLength(lex.getString()); + resizedata.width = Length(lex.getString()); break; case EX_END: diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 6b06f733e8..d921b12a76 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -64,7 +64,7 @@ TODO #include "FuncStatus.h" #include "gettext.h" #include "LaTeXFeatures.h" -#include "LyXLength.h" +#include "Length.h" #include "Lexer.h" #include "MetricsInfo.h" #include "Mover.h" @@ -350,53 +350,53 @@ string const InsetGraphics::createLatexOptions() const } -docstring const InsetGraphics::toDocbookLength(LyXLength const & len) const +docstring const InsetGraphics::toDocbookLength(Length const & len) const { odocstringstream result; switch (len.unit()) { - case LyXLength::SP: // Scaled point (65536sp = 1pt) TeX's smallest unit. + case Length::SP: // Scaled point (65536sp = 1pt) TeX's smallest unit. result << len.value() * 65536.0 * 72 / 72.27 << "pt"; break; - case LyXLength::PT: // Point = 1/72.27in = 0.351mm + case Length::PT: // Point = 1/72.27in = 0.351mm result << len.value() * 72 / 72.27 << "pt"; break; - case LyXLength::BP: // Big point (72bp = 1in), also PostScript point + case Length::BP: // Big point (72bp = 1in), also PostScript point result << len.value() << "pt"; break; - case LyXLength::DD: // Didot point = 1/72 of a French inch, = 0.376mm + case Length::DD: // Didot point = 1/72 of a French inch, = 0.376mm result << len.value() * 0.376 << "mm"; break; - case LyXLength::MM: // Millimeter = 2.845pt + case Length::MM: // Millimeter = 2.845pt result << len.value() << "mm"; break; - case LyXLength::PC: // Pica = 12pt = 4.218mm + case Length::PC: // Pica = 12pt = 4.218mm result << len.value() << "pc"; break; - case LyXLength::CC: // Cicero = 12dd = 4.531mm + case Length::CC: // Cicero = 12dd = 4.531mm result << len.value() * 4.531 << "mm"; break; - case LyXLength::CM: // Centimeter = 10mm = 2.371pc + case Length::CM: // Centimeter = 10mm = 2.371pc result << len.value() << "cm"; break; - case LyXLength::IN: // Inch = 25.4mm = 72.27pt = 6.022pc + case Length::IN: // Inch = 25.4mm = 72.27pt = 6.022pc result << len.value() << "in"; break; - case LyXLength::EX: // Height of a small "x" for the current font. + case Length::EX: // Height of a small "x" for the current font. // Obviously we have to compromise here. Any better ratio than 1.5 ? result << len.value() / 1.5 << "em"; break; - case LyXLength::EM: // Width of capital "M" in current font. + case Length::EM: // Width of capital "M" in current font. result << len.value() << "em"; break; - case LyXLength::MU: // Math unit (18mu = 1em) for positioning in math mode + case Length::MU: // Math unit (18mu = 1em) for positioning in math mode result << len.value() * 18 << "em"; break; - case LyXLength::PTW: // Percent of TextWidth - case LyXLength::PCW: // Percent of ColumnWidth - case LyXLength::PPW: // Percent of PageWidth - case LyXLength::PLW: // Percent of LineWidth - case LyXLength::PTH: // Percent of TextHeight - case LyXLength::PPH: // Percent of Paper + case Length::PTW: // Percent of TextWidth + case Length::PCW: // Percent of ColumnWidth + case Length::PPW: // Percent of PageWidth + case Length::PLW: // Percent of LineWidth + case Length::PTH: // Percent of TextHeight + case Length::PPH: // Percent of Paper // Sigh, this will go wrong. result << len.value() << "%"; break; diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 0a90f90d1c..6671c67904 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -96,7 +96,7 @@ private: /// Create the options for the latex command. std::string const createLatexOptions() const; /// Create length values for docbook export. - docstring const toDocbookLength(LyXLength const & len) const; + docstring const toDocbookLength(Length const & len) const; /// Create the atributes for docbook export. docstring const createDocBookAttributes() const; /// Convert the file if needed, and return the location of the file. diff --git a/src/insets/InsetGraphicsParams.cpp b/src/insets/InsetGraphicsParams.cpp index e26edc34e1..858ce5e8f0 100644 --- a/src/insets/InsetGraphicsParams.cpp +++ b/src/insets/InsetGraphicsParams.cpp @@ -69,8 +69,8 @@ void InsetGraphicsParams::init() lyxscale = 100; // lyx scaling in percentage display = graphics::DefaultDisplay; // display mode; see preferences scale = string("100"); // output scaling in percentage - width = LyXLength(); - height = LyXLength(); + width = Length(); + height = Length(); keepAspectRatio = false; // for LaTeX output draft = false; // draft mode noUnzip = false; // unzip files @@ -209,11 +209,11 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const & scale = lex.getString(); } else if (token == "width") { lex.next(); - width = LyXLength(lex.getString()); + width = Length(lex.getString()); scale = string(); } else if (token == "height") { lex.next(); - height = LyXLength(lex.getString()); + height = Length(lex.getString()); scale = string(); } else if (token == "keepAspectRatio") { keepAspectRatio = true; diff --git a/src/insets/InsetGraphicsParams.h b/src/insets/InsetGraphicsParams.h index 05c65da5c6..5294a42ba3 100644 --- a/src/insets/InsetGraphicsParams.h +++ b/src/insets/InsetGraphicsParams.h @@ -15,7 +15,7 @@ #include "graphics/GraphicsTypes.h" -#include "LyXLength.h" +#include "Length.h" #include "support/FileName.h" namespace lyx { @@ -38,9 +38,9 @@ public: /// Scaling for output (LaTeX) std::string scale; /// sizes for output (LaTeX) - LyXLength width; + Length width; /// - LyXLength height; + Length height; /// Keep the ratio between height and width when resizing. bool keepAspectRatio; /// draft mode diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 85900d7e08..adb374719b 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -235,7 +235,7 @@ string const write_attribute(string const & name, Tabular::idx_type const & i) template <> -string const write_attribute(string const & name, LyXLength const & value) +string const write_attribute(string const & name, Length const & value) { // we write only the value if we really have one same reson as above. return value.zero() ? string() : write_attribute(name, value.asString()); @@ -426,19 +426,19 @@ bool getTokenValue(string const & str, char const * token, bool & flag) } -bool getTokenValue(string const & str, char const * token, LyXLength & len) +bool getTokenValue(string const & str, char const * token, Length & len) { // set the lenght to be zero() as default as this it should be if not // in the file format. - len = LyXLength(); + len = Length(); string tmp; return getTokenValue(str, token, tmp) && isValidLength(tmp, &len); } -bool getTokenValue(string const & str, char const * token, LyXLength & len, bool & flag) +bool getTokenValue(string const & str, char const * token, Length & len, bool & flag) { - len = LyXLength(); + len = Length(); flag = false; string tmp; if (!getTokenValue(str, token, tmp)) @@ -1105,7 +1105,7 @@ void toggleFixedWidth(Cursor & cur, InsetText * inset, bool fixedWidth) void Tabular::setColumnPWidth(Cursor & cur, idx_type cell, - LyXLength const & width) + Length const & width) { col_type const j = column_of_cell(cell); @@ -1126,7 +1126,7 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell, bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell, - LyXLength const & width) + Length const & width) { if (!isMultiColumn(cell)) return false; @@ -1216,7 +1216,7 @@ Tabular::getVAlignment(idx_type cell, bool onlycolumn) const } -LyXLength const Tabular::getPWidth(idx_type cell) const +Length const Tabular::getPWidth(idx_type cell) const { if (isMultiColumn(cell)) return cellinfo_of_cell(cell).p_width; @@ -1224,17 +1224,17 @@ LyXLength const Tabular::getPWidth(idx_type cell) const } -LyXLength const Tabular::getColumnPWidth(idx_type cell) const +Length const Tabular::getColumnPWidth(idx_type cell) const { return column_info[column_of_cell(cell)].p_width; } -LyXLength const Tabular::getMColumnPWidth(idx_type cell) const +Length const Tabular::getMColumnPWidth(idx_type cell) const { if (isMultiColumn(cell)) return cellinfo_of_cell(cell).p_width; - return LyXLength(); + return Length(); } @@ -2952,7 +2952,7 @@ bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const continue; Dimension dim; MetricsInfo m = mi; - LyXLength p_width; + Length p_width; if (tabular.cell_info[i][j].multicolumn == Tabular::CELL_BEGIN_OF_MULTICOLUMN) p_width = tabular.cellinfo_of_cell(cell).p_width; @@ -4143,7 +4143,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, switch (feature) { case Tabular::SET_PWIDTH: { - LyXLength const len(value); + Length const len(value); tabular.setColumnPWidth(cur, cur.idx(), len); if (len.zero() && tabular.getAlignment(cur.idx(), true) == LYX_ALIGN_BLOCK) @@ -4152,7 +4152,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, } case Tabular::SET_MPWIDTH: - tabular.setMColumnPWidth(cur, cur.idx(), LyXLength(value)); + tabular.setMColumnPWidth(cur, cur.idx(), Length(value)); break; case Tabular::SET_SPECIAL_COLUMN: @@ -4408,7 +4408,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, break; case Tabular::SET_TOP_SPACE: { - LyXLength len; + Length len; if (value == "default") for (row_type i = sel_row_start; i <= sel_row_end; ++i) tabular.row_info[i].top_space_default = true; @@ -4426,7 +4426,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, } case Tabular::SET_BOTTOM_SPACE: { - LyXLength len; + Length len; if (value == "default") for (row_type i = sel_row_start; i <= sel_row_end; ++i) tabular.row_info[i].bottom_space_default = true; @@ -4444,7 +4444,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, } case Tabular::SET_INTERLINE_SPACE: { - LyXLength len; + Length len; if (value == "default") for (row_type i = sel_row_start; i <= sel_row_end; ++i) tabular.row_info[i].interline_space_default = true; diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 9c9d5cb444..8a75f45bbb 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -38,7 +38,7 @@ #include "Inset.h" #include "MailInset.h" -#include "LyXLength.h" +#include "Length.h" #include "InsetText.h" @@ -294,9 +294,9 @@ public: void setVAlignment(idx_type cell, VAlignment align, bool onlycolumn = false); /// - void setColumnPWidth(Cursor &, idx_type, LyXLength const &); + void setColumnPWidth(Cursor &, idx_type, Length const &); /// - bool setMColumnPWidth(Cursor &, idx_type, LyXLength const &); + bool setMColumnPWidth(Cursor &, idx_type, Length const &); /// void setAlignSpecial(idx_type cell, docstring const & special, Feature what); @@ -307,11 +307,11 @@ public: VAlignment getVAlignment(idx_type cell, bool onlycolumn = false) const; /// - LyXLength const getPWidth(idx_type cell) const; + Length const getPWidth(idx_type cell) const; /// - LyXLength const getColumnPWidth(idx_type cell) const; + Length const getColumnPWidth(idx_type cell) const; /// - LyXLength const getMColumnPWidth(idx_type cell) const; + Length const getMColumnPWidth(idx_type cell) const; /// docstring const getAlignSpecial(idx_type cell, int what) const; /// @@ -489,7 +489,7 @@ public: /// docstring align_special; /// - LyXLength p_width; // this is only set for multicolumn!!! + Length p_width; // this is only set for multicolumn!!! /// boost::shared_ptr inset; }; @@ -513,15 +513,15 @@ public: /// bool bottom_line; /// Extra space between the top line and this row - LyXLength top_space; + Length top_space; /// Ignore top_space if true and use the default top space bool top_space_default; /// Extra space between this row and the bottom line - LyXLength bottom_space; + Length bottom_space; /// Ignore bottom_space if true and use the default bottom space bool bottom_space_default; /// Extra space between the bottom line and the next top line - LyXLength interline_space; + Length interline_space; /// Ignore interline_space if true and use the default interline space bool interline_space_default; /// This are for longtabulars only @@ -555,7 +555,7 @@ public: /// int width_of_column; /// - LyXLength p_width; + Length p_width; /// docstring align_special; }; diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 263c290e11..7290a4bbc4 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -53,7 +53,7 @@ InsetWrap::InsetWrap(BufferParams const & bp, string const & type) font.setColor(Color::collapsable); setLabelFont(font); params_.type = type; - params_.width = LyXLength(50, LyXLength::PCW); + params_.width = Length(50, Length::PCW); setInsetName(from_utf8(type)); } @@ -136,7 +136,7 @@ void InsetWrapParams::read(Lexer & lex) lex >> token; if (token == "width") { lex.next(); - width = LyXLength(lex.getString()); + width = Length(lex.getString()); } else { lyxerr << "InsetWrap::Read:: Missing 'width'-tag!" << endl; diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index a2f8d0932d..b2f027dd03 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -13,7 +13,7 @@ #define INSETWRAP_H #include "InsetCollapsable.h" -#include "LyXLength.h" +#include "Length.h" #include "MailInset.h" @@ -32,7 +32,7 @@ public: /// std::string placement; /// - LyXLength width; + Length width; }; diff --git a/src/lengthcommon.cpp b/src/lengthcommon.cpp index 4b6a45a6ae..191eca85ba 100644 --- a/src/lengthcommon.cpp +++ b/src/lengthcommon.cpp @@ -39,12 +39,12 @@ char const * const unit_name_gui[] = { N_("Text Width %"), N_("Column Width %"), N_("Page Width %"), N_("Line Width %"), N_("Text Height %"), N_("Page Height %"), "" }; -LyXLength::UNIT unitFromString(string const & data) +Length::UNIT unitFromString(string const & data) { int i = 0; while (i < num_units && data != unit_name[i]) ++i; - return static_cast(i); + return static_cast(i); } diff --git a/src/lengthcommon.h b/src/lengthcommon.h index 9a2acaa40b..4d4acc9bb3 100644 --- a/src/lengthcommon.h +++ b/src/lengthcommon.h @@ -15,7 +15,7 @@ #ifndef LENGTH_COMMON_H #define LENGTH_COMMON_H -#include "LyXLength.h" +#include "Length.h" namespace lyx { @@ -33,7 +33,7 @@ extern char const * const unit_name[]; extern char const * const unit_name_gui[]; /// return the unit given a string representation such as "cm" -LyXLength::UNIT unitFromString(std::string const & data); +Length::UNIT unitFromString(std::string const & data); diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 2d23ab4a20..c0f13b7983 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -311,13 +311,13 @@ InsetMathGrid::row_type InsetMathGrid::row(idx_type idx) const } -void InsetMathGrid::vcrskip(LyXLength const & crskip, row_type row) +void InsetMathGrid::vcrskip(Length const & crskip, row_type row) { rowinfo_[row].crskip_ = crskip; } -LyXLength InsetMathGrid::vcrskip(row_type row) const +Length InsetMathGrid::vcrskip(row_type row) const { return rowinfo_[row].crskip_; } diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h index 96ec55a2dd..ba221fdc48 100644 --- a/src/mathed/InsetMathGrid.h +++ b/src/mathed/InsetMathGrid.h @@ -13,7 +13,7 @@ #define MATH_GRID_H #include "InsetMathNest.h" -#include "LyXLength.h" +#include "Length.h" namespace lyx { @@ -59,7 +59,7 @@ public: /// how many hlines above this row? unsigned int lines_; /// parameter to the line break - LyXLength crskip_; + Length crskip_; /// extra distance between lines int skip_; /// Is a page break allowed after this row? @@ -123,9 +123,9 @@ public: /// char valign() const; /// - void vcrskip(LyXLength const &, row_type row); + void vcrskip(Length const &, row_type row); /// - LyXLength vcrskip(row_type row) const; + Length vcrskip(row_type row) const; /// void resize(short int type, col_type cols); /// diff --git a/src/mathed/InsetMathKern.cpp b/src/mathed/InsetMathKern.cpp index f4e2afda2d..d9fb774993 100644 --- a/src/mathed/InsetMathKern.cpp +++ b/src/mathed/InsetMathKern.cpp @@ -30,7 +30,7 @@ InsetMathKern::InsetMathKern() } -InsetMathKern::InsetMathKern(LyXLength const & w) +InsetMathKern::InsetMathKern(Length const & w) : wid_(w) { dim_.asc = 0; diff --git a/src/mathed/InsetMathKern.h b/src/mathed/InsetMathKern.h index 0f0d99e798..cb75de0134 100644 --- a/src/mathed/InsetMathKern.h +++ b/src/mathed/InsetMathKern.h @@ -13,7 +13,7 @@ #define MATH_CHEATINSET_H #include "InsetMath.h" -#include "LyXLength.h" +#include "Length.h" namespace lyx { @@ -27,7 +27,7 @@ public: /// InsetMathKern(); /// - explicit InsetMathKern(LyXLength const & wid); + explicit InsetMathKern(Length const & wid); /// explicit InsetMathKern(docstring const & wid); /// @@ -41,7 +41,7 @@ public: private: virtual std::auto_ptr doClone() const; /// width in em - LyXLength wid_; + Length wid_; }; diff --git a/src/mathed/InsetMathXYMatrix.cpp b/src/mathed/InsetMathXYMatrix.cpp index f8de6c7072..e5250f897b 100644 --- a/src/mathed/InsetMathXYMatrix.cpp +++ b/src/mathed/InsetMathXYMatrix.cpp @@ -20,7 +20,7 @@ namespace lyx { -InsetMathXYMatrix::InsetMathXYMatrix(LyXLength const & s, char c) +InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c) : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c) {} diff --git a/src/mathed/InsetMathXYMatrix.h b/src/mathed/InsetMathXYMatrix.h index 797b9f19bb..5c7f1b2a3a 100644 --- a/src/mathed/InsetMathXYMatrix.h +++ b/src/mathed/InsetMathXYMatrix.h @@ -12,7 +12,7 @@ #ifndef MATH_XYMATRIX_H #define MATH_XYMATRIX_H -#include "LyXLength.h" +#include "Length.h" #include "InsetMathGrid.h" @@ -22,7 +22,7 @@ namespace lyx { class InsetMathXYMatrix : public InsetMathGrid { public: /// - InsetMathXYMatrix(LyXLength const & = LyXLength(), char c = '\0'); + InsetMathXYMatrix(Length const & = Length(), char c = '\0'); /// bool metrics(MetricsInfo &, Dimension &) const; /// @@ -48,7 +48,7 @@ private: /// virtual std::auto_ptr doClone() const; /// extra spacing, may be empty - LyXLength spacing_; + Length spacing_; /// char spacing_code_; }; diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index ad7b86d31c..1ae36429c7 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -318,7 +318,7 @@ MathAtom createInsetMath(docstring const & s) return MathAtom(new InsetMathKern); if (s.substr(0, 8) == "xymatrix") { char spacing_code = '\0'; - LyXLength spacing; + Length spacing; size_t const len = s.length(); size_t i = 8; if (i < len && s[i] == '@') { @@ -338,7 +338,7 @@ MathAtom createInsetMath(docstring const & s) } if (i < len && s[i] == '=') { ++i; - spacing = LyXLength(to_ascii(s.substr(i))); + spacing = Length(to_ascii(s.substr(i))); } } return MathAtom(new InsetMathXYMatrix(spacing, spacing_code)); diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 2a63b824b3..04c69536e7 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -134,7 +134,7 @@ bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type & cellrow, return false; } } - grid.vcrskip(LyXLength(to_utf8(vskip)), cellrow - 1); + grid.vcrskip(Length(to_utf8(vskip)), cellrow - 1); grid.rowinfo(cellrow - 1).allow_pagebreak_ = allow_pagebreak; return true; } diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 136903a283..d26b972c98 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -2305,18 +2305,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } if (!known_vspace) { switch (unitFromString(unit)) { - case LyXLength::SP: - case LyXLength::PT: - case LyXLength::BP: - case LyXLength::DD: - case LyXLength::MM: - case LyXLength::PC: - case LyXLength::CC: - case LyXLength::CM: - case LyXLength::IN: - case LyXLength::EX: - case LyXLength::EM: - case LyXLength::MU: + case Length::SP: + case Length::PT: + case Length::BP: + case Length::DD: + case Length::MM: + case Length::PC: + case Length::CC: + case Length::CM: + case Length::IN: + case Length::EX: + case Length::EM: + case Length::MU: known_unit = true; break; default: diff --git a/src/text.cpp b/src/text.cpp index 9a5471054d..34add3a582 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -38,7 +38,7 @@ #include "gettext.h" #include "Language.h" #include "Color.h" -#include "LyXLength.h" +#include "Length.h" #include "Lexer.h" #include "LyXRC.h" #include "Row.h"