lib

#include <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 TQString toUserStringValue (double ptValue, Unit unit)
static double fromUserValue (double value, Unit unit)
static double fromUserValue (const TQString &value, Unit unit, bool *ok=0)
static Unit unit (const TQString &_unitName, bool *ok=0)
static TQString unitName (Unit _unit)
static TQString unitDescription (Unit _unit)
static TQStringList listOfUnitName ()
static double parseValue (TQString value, double defaultVal=0.0)
static void saveOasis (KoXmlWriter *settingsWriter, Unit _unit)

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.

Member Enumeration Documentation

◆ Unit

Length units supported by KOffice.

Definition at line 63 of file KoUnit.h.

Member Function Documentation

◆ fromUserValue() [1/2]

double KoUnit::fromUserValue ( const TQString & value,
Unit unit,
bool * ok = 0 )
static

This method is the one to use to read a value from a dialog.

Parameters
valuevalue entered by the user
unitunit type selected by the user
okif 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.

◆ fromUserValue() [2/2]

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.

◆ listOfUnitName()

TQStringList KoUnit::listOfUnitName ( )
static

Definition at line 32 of file KoUnit.cpp.

◆ parseValue()

double KoUnit::parseValue ( TQString 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.

◆ ptToUnit()

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.

◆ saveOasis()

void KoUnit::saveOasis ( KoXmlWriter * settingsWriter,
Unit _unit )
static

Save a unit in OASIS format.

Definition at line 212 of file KoUnit.cpp.

◆ toCC()

double KoUnit::toCC ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in cicero.

Definition at line 117 of file KoUnit.h.

◆ toCM()

double KoUnit::toCM ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in cm.

Definition at line 89 of file KoUnit.h.

◆ toDD()

double KoUnit::toDD ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in didot.

Definition at line 111 of file KoUnit.h.

◆ toDM()

double KoUnit::toDM ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in dm.

Definition at line 94 of file KoUnit.h.

◆ toInch()

double KoUnit::toInch ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in inch.

Definition at line 99 of file KoUnit.h.

◆ toMM()

double KoUnit::toMM ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in mm.

Definition at line 83 of file KoUnit.h.

◆ toPI()

double KoUnit::toPI ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in pica.

Definition at line 105 of file KoUnit.h.

◆ toPoint()

double KoUnit::toPoint ( double ptValue)
inlinestatic

Prepare ptValue to be displayed in pt.

Definition at line 77 of file KoUnit.h.

◆ toUserStringValue()

TQString 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.

◆ toUserValue()

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.

◆ unit()

KoUnit::Unit KoUnit::unit ( const TQString & _unitName,
bool * ok = 0 )
static

Convert a unit name into a Unit enum.

Parameters
_unitNamename to convert
okif set, it will be true if the unit was known, false if unknown

Definition at line 182 of file KoUnit.cpp.

◆ unitDescription()

TQString KoUnit::unitDescription ( Unit _unit)
static

Get the full (translated) description of a unit.

Definition at line 43 of file KoUnit.cpp.

◆ unitName()

TQString 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: