]> git.lyx.org Git - lyx.git/blobdiff - src/Length.cpp
Revert unintended commit.
[lyx.git] / src / Length.cpp
index c9d6be2a4e32843e35f17714792c8f303fc304f6..e248d7c4f4e2e918065e4f8801ebae1b6cbd0361 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Matthias Ettrich
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author Jean-Marc Lasgouttes
  * \author Angus Leeming
  * \author John Levon
 #include <config.h>
 
 #include "Length.h"
-#include "lengthcommon.h"
 #include "LyXRC.h"
 
 #include "support/docstream.h"
+
 #include <sstream>
 #include <iomanip>
 
+using namespace std;
 
 namespace lyx {
 
-using std::ostringstream;
-using std::string;
-
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -59,6 +57,13 @@ Length::Length(string const & data)
 }
 
 
+void Length::swap(Length & rhs)
+{
+       std::swap(val_, rhs.val_);
+       std::swap(unit_, rhs.unit_);
+}
+
+
 string const Length::asString() const
 {
        ostringstream os;
@@ -153,7 +158,7 @@ int Length::inPixels(int text_width, int em_width_base) const
                ? em_width_base
                : 10*(dpi/72.27)*zoom;
        // A different estimate for em_width is
-       // theFontMetrics(LyXFont(LyXFont::ALL_SANE)).width('M')
+       // theFontMetrics(FontInfo(sane_font)).width('M')
        // but this estimate might not be more accurate as the screen font
        // is different then the latex font.
 
@@ -271,6 +276,26 @@ int Length::inBP() const
 }
 
 
+Length::UNIT Length::defaultUnit()
+{
+       // FIXME user a proper pref, since we should get rid of
+       // default_papersize in lyxrc.
+       UNIT u = Length::CM;
+       switch (lyxrc.default_papersize) {
+               case PAPER_USLETTER:
+               case PAPER_USLEGAL:
+               case PAPER_USEXECUTIVE:
+                       u = Length::IN;
+                       break;
+               default:
+                       break;
+       }
+
+       return u;
+}
+
+
+
 bool operator==(Length const & l1, Length const & l2)
 {
        return l1.value() == l2.value() && l1.unit() == l2.unit();