diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-11-10 12:23:02 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-11-10 15:43:19 +0100 |
commit | f37b87ea5c87a683a39758a2875539f6bf59cf93 (patch) | |
tree | b9f2313b2eca445a46c14eedea24f017e8b8f5dd | |
parent | afbbfb3b55beb937555a972d9edbb47ede91001a (diff) |
This converts to/from mm100s, not twips
Change-Id: Ie13e38c78b5e9a65b0dc572628f4fcc93b2c2a17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105530
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 4 | ||||
-rw-r--r-- | include/tools/UnitConversion.hxx | 8 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 8 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptbase.cxx | 2 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-stylesheet.cxx | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 42e171ce3fb0..6adf8aa6c5fe 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -6307,7 +6307,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS case 3 : eTabAdjust = SvxTabAdjust::Decimal; break; default : eTabAdjust = SvxTabAdjust::Left; } - aTabItem.Insert(SvxTabStop(convertMasterUnitToTwip(nTab), eTabAdjust)); + aTabItem.Insert(SvxTabStop(convertMasterUnitToMm100(nTab), eTabAdjust)); } nLatestManTab = nTab; } @@ -6320,7 +6320,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS nTab = nDefaultTab * ( 1 + nTab ); for ( i = 0; ( i < 20 ) && ( nTab < 0x1b00 ); i++ ) { - aTabItem.Insert( SvxTabStop( convertMasterUnitToTwip(nTab))); + aTabItem.Insert( SvxTabStop( convertMasterUnitToMm100(nTab))); nTab += nDefaultTab; } } diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx index d568b78a2dd6..e78ef315b432 100644 --- a/include/tools/UnitConversion.hxx +++ b/include/tools/UnitConversion.hxx @@ -33,10 +33,10 @@ constexpr double convertPointToTwip(double fNumber) { return fNumber * 20.0; } constexpr double convertPointToMm100(double fNumber) { return fNumber * (2540.0 / 72.0); } -// Convert PPT's "master unit" (1/576 inch) to twips -constexpr sal_Int64 convertMasterUnitToTwip(sal_Int64 n) { return n * 2540.0 / 576.0; } +// Convert PPT's "master unit" (1/576 inch) to mm/100 +constexpr sal_Int64 convertMasterUnitToMm100(sal_Int64 n) { return n * (2540.0 / 576.0); } -// Convert twips to PPT's "master unit" -constexpr sal_Int64 convertTwipToMasterUnit(sal_Int64 n) { return n / (2540.0 / 576.0); } +// Convert mm/100 to PPT's "master unit" +constexpr sal_Int64 convertMm100ToMasterUnit(sal_Int64 n) { return n / (2540.0 / 576.0); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 3ecac3614608..92ee21a6f5c6 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -665,7 +665,7 @@ void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj ) if ( !pPara->mbFixedLineSpacing && rPortion.mnCharHeight > static_cast<sal_uInt16>( static_cast<double>(-nLineSpacing) * 0.001 * 72.0 / 2.54 ) ) // 1/100mm to point nLineSpacing = nNormalSpacing; else - nLineSpacing = static_cast<sal_Int16>( convertTwipToMasterUnit(nLineSpacing) ); + nLineSpacing = static_cast<sal_Int16>( convertMm100ToMasterUnit(nLineSpacing) ); } if ( ( pPara->meLineSpacing == css::beans::PropertyState_DIRECT_VALUE ) || ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_LineFeed, nLineSpacing ) ) ) @@ -1210,7 +1210,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u const sal_uInt32 nDefaultTabSize = MapSize( awt::Size( nDefaultTabSizeSrc, 1 ) ).Width; sal_uInt32 nDefaultTabs = std::abs( maRect.GetWidth() ) / nDefaultTabSize; if ( nTabs ) - nDefaultTabs -= static_cast<sal_Int32>( convertTwipToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize ); + nDefaultTabs -= static_cast<sal_Int32>( convertMm100ToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize ); if ( static_cast<sal_Int32>(nDefaultTabs) < 0 ) nDefaultTabs = 0; @@ -1239,7 +1239,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u pRuleOut->WriteUInt16( nTabCount ); for ( const css::style::TabStop& rTabStop : rTabStops ) { - sal_uInt16 nPosition = static_cast<sal_uInt16>( convertTwipToMasterUnit(rTabStop.Position) ); + sal_uInt16 nPosition = static_cast<sal_uInt16>( convertMm100ToMasterUnit(rTabStop.Position) ); sal_uInt16 nType; switch ( rTabStop.Alignment ) { @@ -1256,7 +1256,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u sal_uInt32 nWidth = 1; if ( nTabs ) - nWidth += static_cast<sal_Int32>( convertTwipToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize ); + nWidth += static_cast<sal_Int32>( convertMm100ToMasterUnit(rTabStops[ nTabs - 1 ].Position) / nDefaultTabSize ); nWidth *= nDefaultTabSize; for ( i = 0; i < nDefaultTabs; i++, nWidth += nDefaultTabSize ) pRuleOut->WriteUInt32( nWidth ); diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index 38015a654e09..27870ec4bb43 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -491,7 +491,7 @@ bool PPTWriterBase::GetStyleSheets() aXPropSet( mXModel, UNO_QUERY ); sal_uInt16 nDefaultTab = ( aXPropSet.is() && ImplGetPropertyValue( aXPropSet, "TabStop" ) ) - ? static_cast<sal_uInt16>( convertTwipToMasterUnit(*o3tl::doAccess<sal_Int32>(mAny)) ) + ? static_cast<sal_uInt16>( convertMm100ToMasterUnit(*o3tl::doAccess<sal_Int32>(mAny)) ) : 1250; maStyleSheetList.emplace_back( new PPTExStyleSheet( nDefaultTab, dynamic_cast<PPTExBulletProvider*>(this) ) ); diff --git a/sd/source/filter/eppt/pptx-stylesheet.cxx b/sd/source/filter/eppt/pptx-stylesheet.cxx index 6a015ebfa143..6acf110c50b2 100644 --- a/sd/source/filter/eppt/pptx-stylesheet.cxx +++ b/sd/source/filter/eppt/pptx-stylesheet.cxx @@ -258,7 +258,7 @@ void PPTExParaSheet::SetStyleSheet( const css::uno::Reference< css::beans::XProp nLineSpacing = 100; } else - nLineSpacing = static_cast<sal_Int16>( convertTwipToMasterUnit(nLineSpacing) ); + nLineSpacing = static_cast<sal_Int16>(convertMm100ToMasterUnit(nLineSpacing)); } rLev.mnLineFeed = nLineSpacing; } |