summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-08-11 17:36:12 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-11-12 09:44:10 +0100
commit00d74a5e0291a40e532b2a0f51fdd5a3e1f487ed (patch)
treec34ba7a271768d14bd6f5535069ac203228fa476 /sc/source/ui
parent9871789e0f9256ac27ea7bc4590ba910d6e4c373 (diff)
Use more o3tl::convert in sc
Change-Id: I624b6c570eff8b6cdc83ffcb2d0dbadf848715b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120330 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/docshell/docsh4.cxx12
-rw-r--r--sc/source/ui/inc/printfun.hxx4
-rw-r--r--sc/source/ui/unoobj/docuno.cxx8
-rw-r--r--sc/source/ui/view/output2.cxx1
-rw-r--r--sc/source/ui/view/printfun.cxx5
-rw-r--r--sc/source/ui/view/viewdata.cxx1
6 files changed, 16 insertions, 15 deletions
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 1c32a670baf1..289c66f756d9 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1692,7 +1692,7 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange )
tools::Long nBlkTwipsX = 0;
if (bHeaders)
- nBlkTwipsX += tools::Long(PRINT_HEADER_WIDTH);
+ nBlkTwipsX += PRINT_HEADER_WIDTH;
SCCOL nStartCol = rRange.aStart.Col();
SCCOL nEndCol = rRange.aEnd.Col();
if ( pRepeatCol && nStartCol >= pRepeatCol->aStart.Col() )
@@ -1710,7 +1710,7 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange )
tools::Long nBlkTwipsY = 0;
if (bHeaders)
- nBlkTwipsY += tools::Long(PRINT_HEADER_HEIGHT);
+ nBlkTwipsY += PRINT_HEADER_HEIGHT;
SCROW nStartRow = rRange.aStart.Row();
SCROW nEndRow = rRange.aEnd.Row();
if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() )
@@ -2259,7 +2259,7 @@ namespace {
tools::Long SnapHorizontal( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal, SCCOL& rStartCol )
{
SCCOL nCol = 0;
- tools::Long nTwips = static_cast<tools::Long>(nVal / HMM_PER_TWIPS);
+ tools::Long nTwips = o3tl::convert(nVal, o3tl::Length::mm100, o3tl::Length::twip);
tools::Long nSnap = 0;
while ( nCol<rDoc.MaxCol() )
{
@@ -2272,7 +2272,7 @@ tools::Long SnapHorizontal( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal
else
break;
}
- nVal = static_cast<tools::Long>( nSnap * HMM_PER_TWIPS );
+ nVal = o3tl::convert(nSnap, o3tl::Length::twip, o3tl::Length::mm100);
rStartCol = nCol;
return nVal;
}
@@ -2281,7 +2281,7 @@ tools::Long SnapHorizontal( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal
tools::Long SnapVertical( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal, SCROW& rStartRow )
{
SCROW nRow = 0;
- tools::Long nTwips = static_cast<tools::Long>(nVal / HMM_PER_TWIPS);
+ tools::Long nTwips = o3tl::convert(nVal, o3tl::Length::mm100, o3tl::Length::twip);
tools::Long nSnap = 0;
bool bFound = false;
@@ -2310,7 +2310,7 @@ tools::Long SnapVertical( const ScDocument& rDoc, SCTAB nTab, tools::Long nVal,
if (!bFound)
nRow = rDoc.MaxRow(); // all hidden down to the bottom
- nVal = static_cast<tools::Long>( nSnap * HMM_PER_TWIPS );
+ nVal = o3tl::convert(nSnap, o3tl::Length::twip, o3tl::Length::mm100);
rStartRow = nRow;
return nVal;
}
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 9ad5c27e547b..b58acd9f4c52 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -42,8 +42,8 @@ class FmFormView;
#define RANGENO_NORANGE USHRT_MAX
-#define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
-#define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
+constexpr sal_Int64 PRINT_HEADER_WIDTH = o3tl::toTwips(1, o3tl::Length::cm);
+constexpr sal_Int64 PRINT_HEADER_HEIGHT = o3tl::toTwips(12.8, o3tl::Length::pt);
// Settings for headers/footers
struct ScPrintHFParam
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 11016aafb202..162eb706c1ae 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -533,8 +533,8 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
return;
ScViewData* pActiveViewData = &pViewShell->GetViewData();
- Fraction aFracX(tools::Long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
- Fraction aFracY(tools::Long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+ Fraction aFracX(o3tl::toTwips(nOutputWidth, o3tl::Length::px), nTileWidth);
+ Fraction aFracY(o3tl::toTwips(nOutputHeight, o3tl::Length::px), nTileHeight);
// Try to find a view that matches the tile-zoom requested by iterating over
// first few shells. This is to avoid switching of zooms in ScGridWindow::PaintTile
@@ -980,8 +980,8 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int
// Doing this in ScTabViewShell init code does not work because callbacks do not work at that point for the first view.
lcl_sendLOKDocumentBackground(pViewData);
- const Fraction newZoomX(nTilePixelWidth_ * TWIPS_PER_PIXEL, nTileTwipWidth_);
- const Fraction newZoomY(nTilePixelHeight_ * TWIPS_PER_PIXEL, nTileTwipHeight_);
+ const Fraction newZoomX(o3tl::toTwips(nTilePixelWidth_, o3tl::Length::px), nTileTwipWidth_);
+ const Fraction newZoomY(o3tl::toTwips(nTilePixelHeight_, o3tl::Length::px), nTileTwipHeight_);
if (pViewData->GetZoomX() == newZoomX && pViewData->GetZoomY() == newZoomY)
return;
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 8da5ec78118a..31b0076bc0bc 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -91,6 +91,7 @@ using namespace com::sun::star;
#define DRAWTEXT_MAX 32767
const sal_uInt16 SC_SHRINKAGAIN_MAX = 7;
+constexpr auto HMM_PER_TWIPS = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::mm100);
class ScDrawStringsVars
{
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index eb7de664694b..ccd015552074 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1564,9 +1564,7 @@ void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
aTwipOffset.AdjustX( -(rDoc.GetColWidth( nCol, nPrintTab )) );
aTwipOffset.AdjustY( -sal_Int32(rDoc.GetRowHeight( 0, nY1-1, nPrintTab )) );
- Point aMMOffset( aTwipOffset );
- aMMOffset.setX( static_cast<tools::Long>(aMMOffset.X() * HMM_PER_TWIPS) );
- aMMOffset.setY( static_cast<tools::Long>(aMMOffset.Y() * HMM_PER_TWIPS) );
+ Point aMMOffset(o3tl::convert(aTwipOffset, o3tl::Length::twip, o3tl::Length::mm100));
aMMOffset += Point( nLogStX, nLogStY );
MapMode aDrawMapMode( MapUnit::Map100thMM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() );
@@ -2597,6 +2595,7 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc.
aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
tools::Long nEffZoom = nZoom * static_cast<tools::Long>(nManualZoom);
+ constexpr auto HMM_PER_TWIPS = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::mm100);
nScaleX = nScaleY = HMM_PER_TWIPS; // output in 1/100 mm
Fraction aZoomFract( nEffZoom,10000 );
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index d4b4092291a1..6ac95430a84e 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1730,6 +1730,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
// (and same line breaks) as for output.
Fraction aFract(1,1);
+ constexpr auto HMM_PER_TWIPS = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::mm100);
tools::Rectangle aUtilRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, Point(0, 0), pWin->GetOutDev(),
HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false );
aPaperSize.setWidth( aUtilRect.GetWidth() );