summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-21 11:10:22 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-21 10:02:46 +0100
commitcdc67f6da362cea008a780abe412403eae64d04c (patch)
tree63e69c85ebeaf4340b800b58d97ec5338137a19a /sc/source/core
parenteb807e785b6acda1529b2f58ada2c1e84b38f7f5 (diff)
Some more unit conversion unification
Change-Id: I1a906d918bb4255a75c62c68a57244f59d51d2b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111269 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/column2.cxx17
-rw-r--r--sc/source/core/data/documen9.cxx5
-rw-r--r--sc/source/core/data/global.cxx5
-rw-r--r--sc/source/core/data/stlsheet.cxx7
-rw-r--r--sc/source/core/data/table1.cxx5
-rw-r--r--sc/source/core/data/table2.cxx13
-rw-r--r--sc/source/core/tool/detfunc.cxx5
7 files changed, 35 insertions, 22 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index d194ab134dd1..e6430758cc6f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -44,6 +44,7 @@
#include <editeng/eeitem.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svx/algitem.hxx>
#include <editeng/editobj.hxx>
#include <editeng/editstat.hxx>
@@ -420,7 +421,7 @@ tools::Long ScColumn::GetNeededSize(
// to ensure the exact same paper width (and same line breaks) as in
// ScEditUtil::GetEditArea, used for output.
- fWidthFactor = HMM_PER_TWIPS;
+ fWidthFactor = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::mm100);
}
// use original width for hidden columns:
@@ -438,8 +439,9 @@ tools::Long ScColumn::GetNeededSize(
// space for AutoFilter button: 20 * nZoom/100
constexpr tools::Long nFilterButtonWidthPix = 20; // Autofilter pixel width at 100% zoom.
if ( pFlag->HasAutoFilter() && !bTextWysiwyg )
- nDocWidth -= bInPrintTwips ?
- (nFilterButtonWidthPix * TWIPS_PER_PIXEL) : tools::Long(rZoomX * nFilterButtonWidthPix);
+ nDocWidth -= bInPrintTwips ? o3tl::convert(nFilterButtonWidthPix, o3tl::Length::px,
+ o3tl::Length::twip)
+ : tools::Long(rZoomX * nFilterButtonWidthPix);
aPaper.setWidth( nDocWidth );
@@ -572,7 +574,9 @@ tools::Long ScColumn::GetNeededSize(
{
// add 1pt extra (default margin value) for line breaks with SetVertical
constexpr tools::Long nDefaultMarginInPoints = 1;
- nValue += conditionalScaleFunc(nDefaultMarginInPoints * TWIPS_PER_POINT, nPPT);
+ nValue += conditionalScaleFunc(
+ o3tl::convert(nDefaultMarginInPoints, o3tl::Length::pt, o3tl::Length::twip),
+ nPPT);
}
}
}
@@ -594,8 +598,9 @@ tools::Long ScColumn::GetNeededSize(
constexpr tools::Long nFilterButtonWidthPix = 20; // Autofilter pixel width at 100% zoom.
ScMF nFlags = pPattern->GetItem(ATTR_MERGE_FLAG).GetValue();
if (nFlags & ScMF::Auto)
- nValue += bInPrintTwips ?
- (nFilterButtonWidthPix * TWIPS_PER_PIXEL) : tools::Long(rZoomX * nFilterButtonWidthPix);
+ nValue += bInPrintTwips ? o3tl::convert(nFilterButtonWidthPix, o3tl::Length::px,
+ o3tl::Length::twip)
+ : tools::Long(rZoomX * nFilterButtonWidthPix);
}
return nValue;
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index f44159d6c436..ff5eb488f858 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -23,6 +23,7 @@
#include <editeng/autokernitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/langitem.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <osl/thread.h>
#include <svl/asiancfg.hxx>
#include <svx/svditer.hxx>
@@ -456,8 +457,8 @@ bool ScDocument::IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
for (i=nStartCol; i<=nEndCol; i++)
nRight += GetColWidth(i,nTab);
- aMMRect.SetLeft( static_cast<tools::Long>(nLeft * HMM_PER_TWIPS) );
- aMMRect.SetRight( static_cast<tools::Long>(nRight * HMM_PER_TWIPS) );
+ aMMRect.SetLeft(o3tl::convert(nLeft, o3tl::Length::twip, o3tl::Length::mm100));
+ aMMRect.SetRight(o3tl::convert(nRight, o3tl::Length::twip, o3tl::Length::mm100));
}
else
aMMRect = GetMMRect( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 458e81da5188..e47303bf7cab 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -23,6 +23,7 @@
#include <editeng/editobj.hxx>
#include <svl/srchitem.hxx>
#include <editeng/langitem.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/objsh.hxx>
@@ -461,8 +462,8 @@ void ScGlobal::InitPPT()
if (comphelper::LibreOfficeKit::isActive())
{
// LOK: the below limited precision is not enough for RowColumnHeader.
- nScreenPPTX = double(pDev->GetDPIX()) / double(TWIPS_PER_INCH);
- nScreenPPTY = double(pDev->GetDPIY()) / double(TWIPS_PER_INCH);
+ nScreenPPTX = o3tl::convert<double>(pDev->GetDPIX(), o3tl::Length::twip, o3tl::Length::in);
+ nScreenPPTY = o3tl::convert<double>(pDev->GetDPIY(), o3tl::Length::twip, o3tl::Length::in);
}
else
{
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index 13acfa8e9e56..20f4399dd98b 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -34,14 +34,15 @@
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
#include <svl/hint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <attrib.hxx>
#include <globstr.hrc>
#include <scresid.hxx>
#include <sc.hrc>
-#define TWO_CM 1134
-#define HFDIST_CM 142
+constexpr auto TWO_CM = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip); // 1134
+constexpr auto HFDIST_CM = o3tl::convert(250, o3tl::Length::mm100, o3tl::Length::twip); // 142
ScStyleSheet::ScStyleSheet( const OUString& rName,
const ScStyleSheetPool& rPoolP,
@@ -163,7 +164,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
SfxItemSet& rHFSet = aHFSetItem.GetItemSet();
SvxSizeItem aHFSizeItem( // 0,5 cm + distance
ATTR_PAGE_SIZE,
- Size( 0, tools::Long( 500 / HMM_PER_TWIPS ) + HFDIST_CM ) );
+ Size( 0, o3tl::convert(500, o3tl::Length::mm100, o3tl::Length::twip) + HFDIST_CM ) );
SvxULSpaceItem aHFDistItem ( HFDIST_CM,// nUp
HFDIST_CM,// nLow
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index af09507b5c20..459f804984ed 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -20,6 +20,7 @@
#include <scitems.hxx>
#include <editeng/justifyitem.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <unotools/textsearch.hxx>
#include <unotools/charclass.hxx>
@@ -302,8 +303,8 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
if ( pDrawLayer->ScAddPage( nTab ) ) // sal_False (not inserted) during Undo
{
pDrawLayer->ScRenamePage( nTab, aName );
- sal_uLong const nx = sal_uLong(double(rDocument.MaxCol()+1) * STD_COL_WIDTH * HMM_PER_TWIPS );
- sal_uLong ny = static_cast<sal_uLong>(double(rDocument.MaxRow()+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS );
+ sal_uLong const nx = o3tl::convert((rDocument.MaxCol()+1) * STD_COL_WIDTH, o3tl::Length::twip, o3tl::Length::mm100);
+ sal_uLong ny = o3tl::convert((rDocument.MaxRow()+1) * ScGlobal::nStdRowHeight, o3tl::Length::twip, o3tl::Length::mm10);
pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false );
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d25e7ce7c7f4..833b4edd13f7 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -58,6 +58,7 @@
#include <editeng/boxitem.hxx>
#include <editeng/editobj.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svl/poolcach.hxx>
#include <unotools/charclass.hxx>
#include <math.h>
@@ -3916,13 +3917,15 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos
ScDrawLayer* pDrawLayer = rDocument.GetDrawLayer();
if( pDrawLayer )
{
- double fValX = GetColOffset( rDocument.MaxCol() + 1 ) * HMM_PER_TWIPS;
- double fValY = GetRowOffset( rDocument.MaxRow() + 1 ) * HMM_PER_TWIPS;
- const tools::Long nMax = ::std::numeric_limits<tools::Long>::max();
+ const sal_Int64 nMax = ::std::numeric_limits<tools::Long>::max();
// #i113884# Avoid int32 overflow with possible negative results than can cause bad effects.
// If the draw page size is smaller than all rows, only the bottom of the sheet is affected.
- tools::Long x = ( fValX > static_cast<double>(nMax) ) ? nMax : static_cast<tools::Long>(fValX);
- tools::Long y = ( fValY > static_cast<double>(nMax) ) ? nMax : static_cast<tools::Long>(fValY);
+ tools::Long x = std::min(o3tl::convert(GetColOffset(rDocument.MaxCol() + 1),
+ o3tl::Length::twip, o3tl::Length::mm100),
+ nMax);
+ tools::Long y = std::min(o3tl::convert(GetRowOffset(rDocument.MaxRow() + 1),
+ o3tl::Length::twip, o3tl::Length::mm100),
+ nMax);
if ( IsLayoutRTL() ) // IsNegativePage
x = -x;
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index f2d8f8254d20..2b525e8c0891 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -21,6 +21,7 @@
#include <svtools/colorcfg.hxx>
#include <editeng/eeitem.hxx>
#include <formula/errorcodes.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svx/sdshitm.hxx>
#include <svx/sdsxyitm.hxx>
#include <svx/sdtditm.hxx>
@@ -328,8 +329,8 @@ Point ScDetectiveFunc::GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) c
aPos.AdjustX(rDoc.GetColWidth( i, nTab ) );
aPos.AdjustY(rDoc.GetRowHeight( 0, nRow - 1, nTab ) );
- aPos.setX( static_cast< tools::Long >( aPos.X() * HMM_PER_TWIPS ) );
- aPos.setY( static_cast< tools::Long >( aPos.Y() * HMM_PER_TWIPS ) );
+ aPos.setX(o3tl::convert(aPos.X(), o3tl::Length::twip, o3tl::Length::mm100));
+ aPos.setY(o3tl::convert(aPos.Y(), o3tl::Length::twip, o3tl::Length::mm100));
if ( rDoc.IsNegativePage( nTab ) )
aPos.setX( aPos.X() * -1 );