lib

KoUnit Class Reference

#include <KoUnit.h>

List of all members.


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

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
 

Length units supported by KOffice.

Definition at line 63 of file KoUnit.h.


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]
 

Save a unit in OASIS format.

Definition at line 212 of file KoUnit.cpp.

static double KoUnit::toCC double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in cicero.

Definition at line 117 of file KoUnit.h.

static double KoUnit::toCM double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in cm.

Definition at line 89 of file KoUnit.h.

static double KoUnit::toDD double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in didot.

Definition at line 111 of file KoUnit.h.

static double KoUnit::toDM double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in dm.

Definition at line 94 of file KoUnit.h.

static double KoUnit::toInch double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in inch.

Definition at line 99 of file KoUnit.h.

static double KoUnit::toMM double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in mm.

Definition at line 83 of file KoUnit.h.

static double KoUnit::toPI double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in pica.

Definition at line 105 of file KoUnit.h.

static double KoUnit::toPoint double  ptValue  )  [inline, static]
 

Prepare ptValue to be displayed in pt.

Definition at line 77 of file KoUnit.h.

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 to unit 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 to unit 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]
 

Get the full (translated) description of a unit.

Definition at line 43 of file KoUnit.cpp.

QString KoUnit::unitName Unit  _unit  )  [static]
 

Get the name of a unit.

Definition at line 200 of file KoUnit.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys