23#include <KoXmlWriter.h>
32TQStringList KoUnit::listOfUnitName()
35 for ( uint i = 0 ; i <= KoUnit::U_LASTUNIT ; ++i )
48 return i18n(
"Millimeters (mm)");
50 return i18n(
"Centimeters (cm)");
52 return i18n(
"Decimeters (dm)");
54 return i18n(
"Inches (in)");
56 return i18n(
"Pica (pi)");
58 return i18n(
"Didot (dd)");
60 return i18n(
"Cicero (cc)");
62 return i18n(
"Points (pt)" );
64 return i18n(
"Error!");
72 return toMM( ptValue );
74 return toCM( ptValue );
76 return toDM( ptValue );
80 return toPI( ptValue );
82 return toDD( ptValue );
84 return toCC( ptValue );
96 return POINT_TO_MM( ptValue );
98 return POINT_TO_CM( ptValue );
100 return POINT_TO_DM( ptValue );
102 return POINT_TO_INCH( ptValue );
104 return POINT_TO_PI( ptValue );
106 return POINT_TO_DD( ptValue );
108 return POINT_TO_CC( ptValue );
117 return TDEGlobal::locale()->formatNumber(
toUserValue( ptValue,
unit ) );
124 return MM_TO_POINT( value );
126 return CM_TO_POINT( value );
128 return DM_TO_POINT( value );
130 return INCH_TO_POINT( value );
132 return PI_TO_POINT( value );
134 return DD_TO_POINT( value );
136 return CC_TO_POINT( value );
150 value.simplifyWhiteSpace();
153 if( value.isEmpty() )
156 int index = value.find( TQRegExp(
"[a-z]+$" ) );
158 return value.toDouble();
160 TQString
unit = value.mid( index );
161 value.truncate ( index );
162 double val = value.toDouble();
174 else if(
unit ==
"km" )
176 kdWarning() <<
"KoUnit::parseValue: Unit " <<
unit <<
" is not supported, please report." << endl;
186 if ( _unitName == TQString::fromLatin1(
"mm" ) )
return U_MM;
187 if ( _unitName == TQString::fromLatin1(
"cm" ) )
return U_CM;
188 if ( _unitName == TQString::fromLatin1(
"dm" ) )
return U_DM;
189 if ( _unitName == TQString::fromLatin1(
"in" )
190 || _unitName == TQString::fromLatin1(
"inch") )
return U_INCH;
191 if ( _unitName == TQString::fromLatin1(
"pi" ) )
return U_PI;
192 if ( _unitName == TQString::fromLatin1(
"dd" ) )
return U_DD;
193 if ( _unitName == TQString::fromLatin1(
"cc" ) )
return U_CC;
194 if ( _unitName == TQString::fromLatin1(
"pt" ) )
return U_PT;
202 if ( _unit == U_MM )
return TQString::fromLatin1(
"mm" );
203 if ( _unit == U_CM )
return TQString::fromLatin1(
"cm" );
204 if ( _unit == U_DM )
return TQString::fromLatin1(
"dm" );
205 if ( _unit == U_INCH )
return TQString::fromLatin1(
"in" );
206 if ( _unit == U_PI )
return TQString::fromLatin1(
"pi" );
207 if ( _unit == U_DD )
return TQString::fromLatin1(
"dd" );
208 if ( _unit == U_CC )
return TQString::fromLatin1(
"cc" );
209 return TQString::fromLatin1(
"pt" );
static double toInch(double ptValue)
Prepare ptValue to be displayed in inch.
static double toUserValue(double ptValue, Unit unit)
This method is the one to use to display a value in a dialog.
static double toDM(double ptValue)
Prepare ptValue to be displayed in dm.
static double toCM(double ptValue)
Prepare ptValue to be displayed in cm.
static double toMM(double ptValue)
Prepare ptValue to be displayed in mm.
static double fromUserValue(double value, Unit unit)
This method is the one to use to read a value from a dialog.
static double toPI(double ptValue)
Prepare ptValue to be displayed in pica.
static TQString unitDescription(Unit _unit)
Get the full (translated) description of a unit.
static double toCC(double ptValue)
Prepare ptValue to be displayed in cicero.
static TQString toUserStringValue(double ptValue, Unit unit)
This method is the one to use to display a value in a dialog.
static double toDD(double ptValue)
Prepare ptValue to be displayed in didot.
static double ptToUnit(const double ptValue, const Unit unit)
Convert the value ptValue to a given unit unit Unlike KoUnit::ptToUnit the return value remains unrou...
static double parseValue(TQString value, double defaultVal=0.0)
parse common KOffice and OO values, like "10cm", "5mm" to pt
Unit
Length units supported by KOffice.
static void saveOasis(KoXmlWriter *settingsWriter, Unit _unit)
Save a unit in OASIS format.
static double toPoint(double ptValue)
Prepare ptValue to be displayed in pt.
static Unit unit(const TQString &_unitName, bool *ok=0)
Convert a unit name into a Unit enum.
static TQString unitName(Unit _unit)
Get the name of a unit.
A class for writing out XML (to any TQIODevice), with a special attention on performance.
void addConfigItem(const TQString &configName, const TQString &value)
Special helper for writing config item into settings.xml.