Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
02c32e0f
Kaydet (Commit)
02c32e0f
authored
Eki 10, 2011
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
partially revert
849a713f
üst
e0c72547
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
187 additions
and
0 deletions
+187
-0
converter.cxx
sax/source/tools/converter.cxx
+187
-0
No files found.
sax/source/tools/converter.cxx
Dosyayı görüntüle @
02c32e0f
...
...
@@ -275,6 +275,193 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer,
(
void
)
nMeasure
;
(
void
)
nSourceUnit
;
(
void
)
nTargetUnit
;
#if 0
if( nSourceUnit == MeasureUnit::PERCENT )
{
OSL_ENSURE( nTargetUnit == MeasureUnit::PERCENT,
"MeasureUnit::PERCENT only maps to MeasureUnit::PERCENT!" );
rBuffer.append( nMeasure );
rBuffer.append( sal_Unicode('%' ) );
}
else
{
// the sign is processed seperatly
if( nMeasure < 0 )
{
nMeasure = -nMeasure;
rBuffer.append( sal_Unicode('-') );
}
// The new length is (nVal * nMul)/(nDiv*nFac*10)
long nMul = 1000;
long nDiv = 1;
long nFac = 100;
const sal_Char* psUnit = 0;
switch( nSourceUnit )
{
case MeasureUnit::TWIP:
switch( nTargetUnit )
{
case MeasureUnit::MM_100TH:
case MeasureUnit::MM_10TH:
OSL_ENSURE( MeasureUnit::INCH == nTargetUnit,"output unit not supported for twip values" );
case MeasureUnit::MM:
// 0.01mm = 0.57twip (exactly)
nMul = 25400; // 25.4 * 1000
nDiv = 1440; // 72 * 20;
nFac = 100;
psUnit = gpsMM;
break;
case MeasureUnit::CM:
// 0.001cm = 0.57twip (exactly)
nMul = 25400; // 2.54 * 10000
nDiv = 1440; // 72 * 20;
nFac = 1000;
psUnit = gpsCM;
break;
case MeasureUnit::POINT:
// 0.01pt = 0.2twip (exactly)
nMul = 1000;
nDiv = 20;
nFac = 100;
psUnit = gpsPT;
break;
case MeasureUnit::INCH:
default:
OSL_ENSURE( MeasureUnit::INCH == nTargetUnit,
"output unit not supported for twip values" );
// 0.0001in = 0.144twip (exactly)
nMul = 100000;
nDiv = 1440; // 72 * 20;
nFac = 10000;
psUnit = gpsINCH;
break;
}
break;
case MeasureUnit::POINT:
// 1pt = 1pt (exactly)
OSL_ENSURE( MeasureUnit::POINT == nTargetUnit,
"output unit not supported for pt values" );
nMul = 10;
nDiv = 1;
nFac = 1;
psUnit = gpsPT;
break;
case MeasureUnit::MM_10TH:
case MeasureUnit::MM_100TH:
{
long nFac2 = (MeasureUnit::MM_100TH == nSourceUnit) ? 100 : 10;
switch( nTargetUnit )
{
case MeasureUnit::MM_100TH:
case MeasureUnit::MM_10TH:
OSL_ENSURE( MeasureUnit::INCH == nTargetUnit,
"output unit not supported for 1/100mm values" );
case MeasureUnit::MM:
// 0.01mm = 1 mm/100 (exactly)
nMul = 10;
nDiv = 1;
nFac = nFac2;
psUnit = gpsMM;
break;
case MeasureUnit::CM:
// 0.001mm = 1 mm/100 (exactly)
nMul = 10;
nDiv = 1; // 72 * 20;
nFac = 10*nFac2;
psUnit = gpsCM;
break;
case MeasureUnit::POINT:
// 0.01pt = 0.35 mm/100 (exactly)
nMul = 72000;
nDiv = 2540;
nFac = nFac2;
psUnit = gpsPT;
break;
case MeasureUnit::INCH:
default:
OSL_ENSURE( MeasureUnit::INCH == nTargetUnit,
"output unit not supported for 1/100mm values" );
// 0.0001in = 0.254 mm/100 (exactly)
nMul = 100000;
nDiv = 2540;
nFac = 100*nFac2;
psUnit = gpsINCH;
break;
}
break;
}
}
long nLongVal = 0;
bool bOutLongVal = true;
if( nMeasure > SAL_INT32_MAX / nMul )
{
// A big int is required for calculation
BigInt nBigVal( nMeasure );
BigInt nBigFac( nFac );
nBigVal *= nMul;
nBigVal /= nDiv;
nBigVal += 5;
nBigVal /= 10;
if( nBigVal.IsLong() )
{
// To convert the value into a string a long is sufficient
nLongVal = (long)nBigVal;
}
else
{
BigInt nBigFac2( nFac );
BigInt nBig10( 10 );
rBuffer.append( (sal_Int32)(nBigVal / nBigFac2) );
if( !(nBigVal % nBigFac2).IsZero() )
{
rBuffer.append( sal_Unicode('.') );
while( nFac > 1 && !(nBigVal % nBigFac2).IsZero() )
{
nFac /= 10;
nBigFac2 = nFac;
rBuffer.append( (sal_Int32)((nBigVal / nBigFac2) % nBig10 ) );
}
}
bOutLongVal = false;
}
}
else
{
nLongVal = nMeasure * nMul;
nLongVal /= nDiv;
nLongVal += 5;
nLongVal /= 10;
}
if( bOutLongVal )
{
rBuffer.append( (sal_Int32)(nLongVal / nFac) );
if( nFac > 1 && (nLongVal % nFac) != 0 )
{
rBuffer.append( sal_Unicode('.') );
while( nFac > 1 && (nLongVal % nFac) != 0 )
{
nFac /= 10;
rBuffer.append( (sal_Int32)((nLongVal / nFac) % 10) );
}
}
}
if( psUnit )
rBuffer.appendAscii( psUnit );
}
#endif
}
static
const
OUString
&
getTrueString
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment