From 6dccc6b54e4bb13f765d494bcdcdd782fa11fe38 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 21 Feb 2021 12:03:49 +0300 Subject: Some more unit conversion unification Change-Id: Id000613426eb5a0159f44419446cad1f3d7f1845 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111282 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sc/source/ui/app/transobj.cxx | 9 +++++---- sc/source/ui/docshell/docsh2.cxx | 7 +++++-- sc/source/ui/docshell/docsh3.cxx | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index b83a085d5c08..ad6e01df42e1 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -769,8 +770,8 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize) for (nCol=0; nCol( nPosX * HMM_PER_TWIPS ); - nPosY = static_cast( nPosY * HMM_PER_TWIPS ); + nPosX = o3tl::convert(nPosX, o3tl::Length::twip, o3tl::Length::mm100); + nPosY = o3tl::convert(nPosY, o3tl::Length::twip, o3tl::Length::mm100); aPaperSize.setWidth( aPaperSize.Width() * 2 ); // limit OLE object to double of page size aPaperSize.setHeight( aPaperSize.Height() * 2 ); @@ -791,8 +792,8 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize) break; nSizeY += nAdd; } - nSizeX = static_cast( nSizeX * HMM_PER_TWIPS ); - nSizeY = static_cast( nSizeY * HMM_PER_TWIPS ); + nSizeX = o3tl::convert(nSizeX, o3tl::Length::twip, o3tl::Length::mm100); + nSizeY = o3tl::convert(nSizeY, o3tl::Length::twip, o3tl::Length::mm100); // pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) ); diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 0c8da05362b0..e02b815d2181 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -46,8 +47,10 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) // Additional tables are created by the first View, if bIsEmpty is still sal_True if( bRet ) { - Size aSize( tools::Long( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ), - static_cast( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) ); + Size aSize( + o3tl::convert(STD_COL_WIDTH * OLE_STD_CELLS_X, o3tl::Length::twip, o3tl::Length::mm100), + o3tl::convert(ScGlobal::nStdRowHeight * OLE_STD_CELLS_Y, o3tl::Length::twip, + o3tl::Length::mm100)); // Also adjust start here SetVisAreaOrSize( tools::Rectangle( Point(), aSize ) ); } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index a31d73e5802c..37e1bc773859 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -367,7 +368,6 @@ void ScDocShell::CalcOutputFactor() OUString aTestString( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789"); tools::Long nPrinterWidth = 0; - tools::Long nWindowWidth = 0; const ScPatternAttr* pPattern = &m_aDocument.GetPool()->GetDefaultItem(ATTR_PATTERN); vcl::Font aDefFont; @@ -386,11 +386,11 @@ void ScDocShell::CalcOutputFactor() pVirtWindow->SetMapMode(MapMode(MapUnit::MapPixel)); pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow); // font color doesn't matter here pVirtWindow->SetFont(aDefFont); - nWindowWidth = pVirtWindow->GetTextWidth(aTestString); - nWindowWidth = static_cast( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS ); + double nWindowWidth = pVirtWindow->GetTextWidth(aTestString) / ScGlobal::nScreenPPTX; + nWindowWidth = o3tl::convert(nWindowWidth, o3tl::Length::twip, o3tl::Length::mm100); if (nPrinterWidth && nWindowWidth) - m_nPrtToScreenFactor = nPrinterWidth / static_cast(nWindowWidth); + m_nPrtToScreenFactor = nPrinterWidth / nWindowWidth; else { OSL_FAIL("GetTextSize returns 0 ??"); -- cgit