diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-30 11:55:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-30 16:01:20 +0200 |
commit | 23cf9370edf41c591ebb5acad372b5ce2395f68e (patch) | |
tree | 423c32cfaa29cce485ba0d9e1b181484a4d91a94 /svtools | |
parent | 5fb3b6b925db2989ce61bb954d7156f2a3b84b4c (diff) |
weld SdSnapLineDlg
Change-Id: I3a8117719525fa204f29cc10a944376116050d61
Reviewed-on: https://gerrit.libreoffice.org/53658
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/unitconv.cxx | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx index f99b2806076c..64d1acb75330 100644 --- a/svtools/source/misc/unitconv.cxx +++ b/svtools/source/misc/unitconv.cxx @@ -132,7 +132,6 @@ void SetFieldUnit( MetricField& rField, FieldUnit eUnit, bool bAll ) } } - void SetFieldUnit( MetricBox& rBox, FieldUnit eUnit ) { sal_Int64 nMin = rBox.Denormalize( rBox.GetMin( FUNIT_TWIP ) ); @@ -162,6 +161,12 @@ void SetFieldUnit( MetricBox& rBox, FieldUnit eUnit ) rBox.SetMax( rBox.Normalize( nMax ), FUNIT_TWIP ); } +void SetMetricValue(weld::MetricSpinButton& rField, int nCoreValue, MapUnit eUnit) +{ + auto nVal = OutputDevice::LogicToLogic(nCoreValue, eUnit, MapUnit::Map100thMM); + nVal = rField.normalize(nVal); + rField.set_value(nVal, FUNIT_100TH_MM); +} void SetMetricValue( MetricField& rField, long nCoreValue, MapUnit eUnit ) { @@ -171,6 +176,29 @@ void SetMetricValue( MetricField& rField, long nCoreValue, MapUnit eUnit ) } +int GetCoreValue(const weld::MetricSpinButton& rField, MapUnit eUnit) +{ + int nVal = rField.get_value(FUNIT_100TH_MM); + // avoid rounding issues + const int nSizeMask = 0xff000000; + bool bRoundBefore = true; + if( nVal >= 0 ) + { + if( (nVal & nSizeMask) == 0 ) + bRoundBefore = false; + } + else + { + if( ((-nVal) & nSizeMask ) == 0 ) + bRoundBefore = false; + } + if( bRoundBefore ) + nVal = rField.denormalize( nVal ); + auto nUnitVal = OutputDevice::LogicToLogic(nVal, MapUnit::Map100thMM, eUnit); + if (!bRoundBefore) + nUnitVal = rField.denormalize(nUnitVal); + return nUnitVal; +} long GetCoreValue( const MetricField& rField, MapUnit eUnit ) { @@ -196,7 +224,6 @@ long GetCoreValue( const MetricField& rField, MapUnit eUnit ) return static_cast<long>(nUnitVal); } - long CalcToUnit( float nIn, MapUnit eUnit ) { // nIn is in Points |