diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-14 00:09:43 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-13 23:38:37 +0100 |
commit | 7b8f630db30ee0066a9f4b6e540368d2fcad7fa8 (patch) | |
tree | e40626d45db8a228defeca6e66aba9055974d0a6 /writerfilter | |
parent | 44f20abf66ce3f9806ad95522d7d9ae698350499 (diff) |
Use o3tl::convert
Change-Id: I78db3001d602ec1a0847785b3c127b9d345f5af7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125173
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 29 |
2 files changed, 16 insertions, 15 deletions
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx index 307da49db4e9..59e2e48d68be 100644 --- a/writerfilter/source/dmapper/ConversionHelper.cxx +++ b/writerfilter/source/dmapper/ConversionHelper.cxx @@ -434,7 +434,7 @@ double convertTwipToMM100Double(sal_Int32 _t) // anything that's bigger than 32767 appears to be simply ignored. if( _t >= 0x8000 ) return 0.0; - return _t * 254.0 / 144.0; + return o3tl::convert<double>(_t, o3tl::Length::twip, o3tl::Length::mm100); } sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t) diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index dc833c363571..8634d66e1ae5 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -63,6 +63,7 @@ #include <tools/diagnose_ex.h> #include "PropertyMapHelper.hxx" #include <o3tl/sorted_vector.hxx> +#include <o3tl/unit_conversion.hxx> using namespace com::sun::star; @@ -411,13 +412,13 @@ SectionPropertyMap::SectionPropertyMap( bool bIsFirstSection ) , m_nPageNumber( -1 ) , m_nPageNumberType( -1 ) , m_nBreakType( -1 ) - , m_nLeftMargin( 2540 ) // page left margin, default 1 inch = 1440 twip -> 2540 1/100 mm - , m_nRightMargin( 2540 ) // page right margin, default 1 inch = 1440 twip -> 2540 1/100 mm + , m_nLeftMargin( o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100) ) + , m_nRightMargin( o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100) ) , m_nGutterMargin(0) - , m_nTopMargin( 2540 ) - , m_nBottomMargin( 2540 ) - , m_nHeaderTop( 1270 ) // 720 twip - , m_nHeaderBottom( 1270 ) // 720 twip + , m_nTopMargin( o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100) ) + , m_nBottomMargin( o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100) ) + , m_nHeaderTop( o3tl::convert(0.5, o3tl::Length::in, o3tl::Length::mm100) ) + , m_nHeaderBottom( o3tl::convert(0.5, o3tl::Length::in, o3tl::Length::mm100) ) , m_nGridType( 0 ) , m_nGridLinePitch( 1 ) , m_nDxtCharSpace( 0 ) @@ -452,14 +453,14 @@ SectionPropertyMap::SectionPropertyMap( bool bIsFirstSection ) Insert( PROP_HEIGHT, uno::makeAny( static_cast<sal_Int32>(aLetter.getHeight()) ) ); // page width, 1/100mm Insert( PROP_WIDTH, uno::makeAny( static_cast<sal_Int32>(aLetter.getWidth()) ) ); - // page left margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_LEFT_MARGIN, uno::makeAny( sal_Int32(2540) ) ); - // page right margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_RIGHT_MARGIN, uno::makeAny( sal_Int32(2540) ) ); - // page top margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_TOP_MARGIN, uno::makeAny( sal_Int32(2540) ) ); - // page bottom margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_BOTTOM_MARGIN, uno::makeAny( sal_Int32(2540) ) ); + // page left margin, 1/100 mm + Insert( PROP_LEFT_MARGIN, uno::makeAny( sal_Int32(o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100)) ) ); + // page right margin, 1/100 mm + Insert( PROP_RIGHT_MARGIN, uno::makeAny( sal_Int32(o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100)) ) ); + // page top margin, 1/100 mm + Insert( PROP_TOP_MARGIN, uno::makeAny( sal_Int32(o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100)) ) ); + // page bottom margin, 1/100 mm + Insert( PROP_BOTTOM_MARGIN, uno::makeAny( sal_Int32(o3tl::convert(1, o3tl::Length::in, o3tl::Length::mm100)) ) ); // page style layout Insert( PROP_PAGE_STYLE_LAYOUT, uno::makeAny( style::PageStyleLayout_ALL ) ); uno::Any aFalse( uno::makeAny( false ) ); |