lib Library API Documentation

KoUnit Class Reference

KOffice stores everything in pt (using "double") internally. More...

#include <koUnit.h>

List of all members.

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)


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 Function Documentation

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

Prepare ptValue to be displayed in pt.

Definition at line 76 of file koUnit.h.

Referenced by KoLineWidthAction::setCurrentWidth(), and toUserValue().

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

Prepare ptValue to be displayed in mm.

Definition at line 82 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in cm.

Definition at line 88 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in dm.

Definition at line 93 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in inch.

Definition at line 98 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in pica.

Definition at line 104 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in didot.

Definition at line 110 of file koUnit.h.

Referenced by toUserValue().

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

Prepare ptValue to be displayed in cicero.

Definition at line 116 of file koUnit.h.

Referenced by 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 66 of file koUnit.cc.

References toCC(), toCM(), toDD(), toDM(), toInch(), toMM(), toPI(), and toPoint().

Referenced by KoUnitDoubleSpinBox::setLineStep(), KoUnitDoubleSpinBox::setMaxValue(), KoUnitDoubleSpinBox::setMinValue(), and toUserStringValue().

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 89 of file koUnit.cc.

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 113 of file koUnit.cc.

References toUserValue().

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 118 of file koUnit.cc.

Referenced by fromUserValue(), parseValue(), KoUnitDoubleComboBox::value(), KoUnitDoubleLineEdit::value(), and KoUnitDoubleSpinBox::value().

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:
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 141 of file koUnit.cc.

References fromUserValue().

KoUnit::Unit KoUnit::unit const QString _unitName,
bool *  ok = 0
[static]
 

Convert a unit name into a Unit enum.

Parameters:
ok if set, it will be true if the unit was known, false if unknown

Definition at line 180 of file koUnit.cc.

Referenced by parseValue(), and KoRuler::setUnit().

QString KoUnit::unitName Unit  _unit  )  [static]
 

Get the name of a unit.

Definition at line 198 of file koUnit.cc.

Referenced by KoUnitDoubleBase::getVisibleText(), saveOasis(), and KoUnitDoubleBase::toDouble().

QString KoUnit::unitDescription Unit  _unit  )  [static]
 

Get the full (translated) description of a unit.

Definition at line 41 of file koUnit.cc.

double KoUnit::parseValue QString  value,
double  defaultVal = 0.0
[static]
 

parse common KOffice and OO values, like "10cm", "5mm" to pt

Definition at line 146 of file koUnit.cc.

References fromUserValue(), and unit().

Referenced by KoStyleStack::fontSize(), KoPageLayout::loadOasis(), KoParagLayout::loadOasisParagLayout(), and KoTextFormat::parseShadowFromCss().

void KoUnit::saveOasis KoXmlWriter settingsWriter,
Unit  _unit
[static]
 

Save a unit in OASIS format.

Definition at line 210 of file koUnit.cc.

References KoXmlWriter::addConfigItem(), and unitName().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:41:41 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003