lib
KoUnit Class Reference
#include <KoUnit.h>
Detailed Description
KOffice stores everything in pt (using "double") internally.When displaying a value to the user, the value is converted to the user's unit of choice, and rounded to a reasonable precision to avoid 0.999999
Definition at line 59 of file KoUnit.h.
Public Types | |
U_MM = 0 | |
U_PT = 1 | |
U_INCH = 2 | |
U_CM = 3 | |
U_DM = 4 | |
U_PI = 5 | |
U_DD = 6 | |
U_CC = 7 | |
U_LASTUNIT = U_CC | |
enum | Unit { U_MM = 0, U_PT = 1, U_INCH = 2, U_CM = 3, U_DM = 4, U_PI = 5, U_DD = 6, U_CC = 7, U_LASTUNIT = U_CC } |
Static Public Member Functions | |
static double | toPoint (double ptValue) |
static double | toMM (double ptValue) |
static double | toCM (double ptValue) |
static double | toDM (double ptValue) |
static double | toInch (double ptValue) |
static double | toPI (double ptValue) |
static double | toDD (double ptValue) |
static double | toCC (double ptValue) |
static double | toUserValue (double ptValue, Unit unit) |
static double | ptToUnit (const double ptValue, const Unit unit) |
static QString | toUserStringValue (double ptValue, Unit unit) |
static double | fromUserValue (double value, Unit unit) |
static double | fromUserValue (const QString &value, Unit unit, bool *ok=0) |
static Unit | unit (const QString &_unitName, bool *ok=0) |
static QString | unitName (Unit _unit) |
static QString | unitDescription (Unit _unit) |
static QStringList | listOfUnitName () |
static double | parseValue (QString value, double defaultVal=0.0) |
static void | saveOasis (KoXmlWriter *settingsWriter, Unit _unit) |
Member Enumeration Documentation
enum KoUnit::Unit |
Member Function Documentation
double KoUnit::fromUserValue | ( | const QString & | value, | |
Unit | unit, | |||
bool * | ok = 0 | |||
) | [static] |
This method is the one to use to read a value from a dialog.
- Parameters:
-
value value entered by the user unit unit type selected by the user ok if set, the pointed bool is set to true if the value could be converted to a double, and to false otherwise.
- Returns:
- the value in
unit
, converted to points for internal use
Definition at line 143 of file KoUnit.cpp.
double KoUnit::fromUserValue | ( | double | value, | |
Unit | unit | |||
) | [static] |
This method is the one to use to read a value from a dialog.
- Returns:
- the value in
unit
, converted to points for internal use Old name: ptFromUnit
Definition at line 120 of file KoUnit.cpp.
double KoUnit::parseValue | ( | QString | value, | |
double | defaultVal = 0.0 | |||
) | [static] |
parse common KOffice and OO values, like "10cm", "5mm" to pt
Definition at line 148 of file KoUnit.cpp.
double KoUnit::ptToUnit | ( | const double | ptValue, | |
const Unit | unit | |||
) | [static] |
Convert the value ptValue
to a given unit unit
Unlike KoUnit::ptToUnit the return value remains unrounded, so that it can be used in complex calculation.
- Returns:
- the converted value Old name: ptToUnitUnrounded
Definition at line 91 of file KoUnit.cpp.
void KoUnit::saveOasis | ( | KoXmlWriter * | settingsWriter, | |
Unit | _unit | |||
) | [static] |
static double KoUnit::toCC | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toCM | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toDD | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toDM | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toInch | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toMM | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toPI | ( | double | ptValue | ) | [inline, static] |
static double KoUnit::toPoint | ( | double | ptValue | ) | [inline, static] |
QString KoUnit::toUserStringValue | ( | double | ptValue, | |
Unit | unit | |||
) | [static] |
This method is the one to use to display a value in a dialog.
- Returns:
- the value
ptValue
converted tounit
and rounded, ready to be displayed Old name: userValue
Definition at line 115 of file KoUnit.cpp.
double KoUnit::toUserValue | ( | double | ptValue, | |
Unit | unit | |||
) | [static] |
This method is the one to use to display a value in a dialog.
- Returns:
- the value
ptValue
converted tounit
and rounded, ready to be displayed Old name: ptToUnit
Definition at line 68 of file KoUnit.cpp.
KoUnit::Unit KoUnit::unit | ( | const QString & | _unitName, | |
bool * | ok = 0 | |||
) | [static] |
Convert a unit name into a Unit enum.
- Parameters:
-
_unitName name to convert ok if set, it will be true if the unit was known, false if unknown
Definition at line 182 of file KoUnit.cpp.
QString KoUnit::unitDescription | ( | Unit | _unit | ) | [static] |
QString KoUnit::unitName | ( | Unit | _unit | ) | [static] |
The documentation for this class was generated from the following files: