summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-21 17:16:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-22 19:25:39 +0100
commite651dcd9820b2472e66f512ad2669e21d23ef465 (patch)
tree70221237a12373e1e821007d8998f439e632e49a
parentd62c93a831080ef332e416dc78f5600c2c5b9850 (diff)
Some more unit conversion unification
Change-Id: I0410a73e4376ea0e4698f311cb3deb02c37fb931 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111341 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx3
-rw-r--r--sc/source/ui/view/drawutil.cxx9
-rw-r--r--sc/source/ui/view/gridwin.cxx3
-rw-r--r--sc/source/ui/view/gridwin4.cxx42
-rw-r--r--sc/source/ui/view/output3.cxx15
-rw-r--r--sc/source/ui/view/preview.cxx95
-rw-r--r--sc/source/ui/view/prevloc.cxx30
-rw-r--r--sc/source/ui/view/prevwsh.cxx5
-rw-r--r--sc/source/ui/view/tabview.cxx9
-rw-r--r--sc/source/ui/view/viewdata.cxx19
-rw-r--r--sc/source/ui/view/viewfun5.cxx4
-rw-r--r--sc/source/ui/view/viewfunc.cxx4
12 files changed, 137 insertions, 101 deletions
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
index 72bd0ad7f0e4..34e22845fa3f 100644
--- a/sc/source/ui/miscdlgs/autofmt.cxx
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -30,6 +30,7 @@
#include <editeng/shdditem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svl/zforlist.hxx>
#include <svtools/scriptedtext.hxx>
#include <svx/framelink.hxx>
@@ -445,7 +446,7 @@ void ScAutoFmtPreview::CalcCellArray( bool bFitWidthP )
static void lclSetStyleFromBorder( svx::frame::Style& rStyle, const ::editeng::SvxBorderLine* pBorder )
{
- rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
+ rStyle.Set(pBorder, o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::pt), 5);
}
void ScAutoFmtPreview::CalcLineMap()
diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx
index 3a6f14561372..cfc60ff23505 100644
--- a/sc/source/ui/view/drawutil.cxx
+++ b/sc/source/ui/view/drawutil.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/unit_conversion.hxx>
#include <vcl/outdev.hxx>
#include <drawutil.hxx>
@@ -65,8 +68,7 @@ void ScDrawUtil::CalcScale( const ScDocument& rDoc, SCTAB nTab,
if ( aPixelLog.X() && nTwipsX )
rScaleX = Fraction( static_cast<double>(aPixelLog.X()) *
static_cast<double>(rZoomX.GetNumerator()) /
- static_cast<double>(nTwipsX) /
- HMM_PER_TWIPS /
+ o3tl::convert<double>(nTwipsX, o3tl::Length::twip, o3tl::Length::mm100) /
static_cast<double>(rZoomX.GetDenominator()) );
else
rScaleX = Fraction( 1, 1 );
@@ -74,8 +76,7 @@ void ScDrawUtil::CalcScale( const ScDocument& rDoc, SCTAB nTab,
if ( aPixelLog.Y() && nTwipsY )
rScaleY = Fraction( static_cast<double>(aPixelLog.Y()) *
static_cast<double>(rZoomY.GetNumerator()) /
- static_cast<double>(nTwipsY) /
- HMM_PER_TWIPS /
+ o3tl::convert<double>(nTwipsY, o3tl::Length::twip, o3tl::Length::mm100) /
static_cast<double>(rZoomY.GetDenominator()) );
else
rScaleY = Fraction( 1, 1 );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1e5c0f6df86e..0fe1c7d357b5 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -30,6 +30,7 @@
#include <editeng/justifyitem.hxx>
#include <editeng/misspellrange.hxx>
#include <editeng/editobj.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/docfile.hxx>
@@ -947,7 +948,7 @@ void ScGridWindow::ShowFilterMenu(const tools::Rectangle& rCellRect, bool bLayou
// minimum width in pixel
if (comphelper::LibreOfficeKit::isActive())
{
- const tools::Long nMinLOKWinWidth = static_cast<tools::Long>(1.3 * STD_COL_WIDTH / TWIPS_PER_PIXEL);
+ const tools::Long nMinLOKWinWidth = o3tl::convert(STD_COL_WIDTH * 13 / 10, o3tl::Length::twip, o3tl::Length::px);
if (nSizeX < nMinLOKWinWidth)
nSizeX = nMinLOKWinWidth;
}
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index c95bc00f701a..0dd3c0b30b59 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -29,6 +29,7 @@
#include <sfx2/printer.hxx>
#include <vcl/cursor.hxx>
#include <vcl/settings.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
@@ -874,8 +875,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
// Tiled offset nScrX, nScrY
MapMode aMap( MapUnit::MapPixel );
Point aOrigin = aOriginalMode.GetOrigin();
- aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
- aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
+ aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px) + nScrX);
+ aOrigin.setY(o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px) + nScrY);
aMap.SetOrigin(aOrigin);
pContentDev->SetMapMode(aMap);
}
@@ -922,7 +923,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
if (bIsTiledRendering)
{
Point aOrigin = aOriginalMode.GetOrigin();
- Size aPixelOffset(aOrigin.getX() / TWIPS_PER_PIXEL, aOrigin.getY() / TWIPS_PER_PIXEL);
+ Size aPixelOffset(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px),
+ o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px));
pContentDev->SetPixelOffset(aPixelOffset);
comphelper::LibreOfficeKit::setLocalRendering();
}
@@ -985,8 +987,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
if (bIsTiledRendering)
{
Point aOrigin = aOriginalMode.GetOrigin();
- aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + aOutputData.nScrX);
- aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + aOutputData.nScrY);
+ aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px)
+ + aOutputData.nScrX);
+ aOrigin.setY(o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)
+ + aOutputData.nScrY);
const double twipFactor = 15 * 1.76388889; // 26.45833335
aOrigin = Point(aOrigin.getX() * twipFactor,
aOrigin.getY() * twipFactor);
@@ -1052,8 +1056,12 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
// Need to draw the background in absolute coords.
Point aOrigin = aOriginalMode.GetOrigin();
- aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScreenX);
- aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScreenY);
+ aOrigin.setX(
+ o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px)
+ + nScreenX);
+ aOrigin.setY(
+ o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)
+ + nScreenY);
aBackground += aOrigin;
rDevice.SetMapMode(aDrawMode);
@@ -1136,8 +1144,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
{
// Need to draw the background in absolute coords.
Point aOrigin = aOriginalMode.GetOrigin();
- aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
- aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
+ aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px)
+ + nScrX);
+ aOrigin.setY(o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)
+ + nScrY);
aBackground += aOrigin;
rDevice.SetMapMode(aDrawMode);
}
@@ -1147,8 +1157,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
if (bIsTiledRendering)
{
Point aOrigin = aOriginalMode.GetOrigin();
- aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
- aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
+ aOrigin.setX(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px)
+ + nScrX);
+ aOrigin.setY(o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)
+ + nScrY);
static const double twipFactor = 15 * 1.76388889; // 26.45833335
// keep into account the zoom factor
aOrigin = Point((aOrigin.getX() * twipFactor) / static_cast<double>(aDrawMode.GetScaleX()),
@@ -1364,8 +1376,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
// Similarly to Writer, we should set the mapmode once on the rDevice, and
// not care about any zoom settings.
- Fraction aFracX(tools::Long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
- Fraction aFracY(tools::Long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+ Fraction aFracX(o3tl::convert(nOutputWidth, o3tl::Length::px, o3tl::Length::twip), nTileWidth);
+ Fraction aFracY(o3tl::convert(nOutputHeight, o3tl::Length::px, o3tl::Length::twip), nTileHeight);
const bool bChangeZoom = (aFracX != origZoomX || aFracY != origZoomY);
@@ -1433,8 +1445,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
nTopLeftTileCol = std::max<sal_Int32>(nTopLeftTileCol, 0);
nTopLeftTileRow = std::max<sal_Int32>(nTopLeftTileRow, 0);
- nTopLeftTileColOrigin = nTopLeftTileColOrigin * TWIPS_PER_PIXEL;
- nTopLeftTileRowOrigin = nTopLeftTileRowOrigin * TWIPS_PER_PIXEL;
+ nTopLeftTileColOrigin = o3tl::convert(nTopLeftTileColOrigin, o3tl::Length::px, o3tl::Length::twip);
+ nTopLeftTileRowOrigin = o3tl::convert(nTopLeftTileRowOrigin, o3tl::Length::px, o3tl::Length::twip);
// Checkout -> 'rDoc.ExtendMerge' ... if we miss merged cells.
diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx
index c4e225a64475..47730c9b3cd2 100644
--- a/sc/source/ui/view/output3.cxx
+++ b/sc/source/ui/view/output3.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/unit_conversion.hxx>
#include <svx/svdoutl.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svdview.hxx>
@@ -55,8 +58,8 @@ Point ScOutputData::PrePrintDrawingLayer(tools::Long nLogStX, tools::Long nLogSt
aRect.SetBottom( -aOffset.Y() );
Point aMMOffset( aOffset );
- aMMOffset.setX( static_cast<tools::Long>(aMMOffset.X() * HMM_PER_TWIPS) );
- aMMOffset.setY( static_cast<tools::Long>(aMMOffset.Y() * HMM_PER_TWIPS) );
+ aMMOffset.setX(o3tl::convert(aMMOffset.X(), o3tl::Length::twip, o3tl::Length::mm100));
+ aMMOffset.setY(o3tl::convert(aMMOffset.Y(), o3tl::Length::twip, o3tl::Length::mm100));
if (!bMetaFile)
aMMOffset += Point( nLogStX, nLogStY );
@@ -65,10 +68,10 @@ Point ScOutputData::PrePrintDrawingLayer(tools::Long nLogStX, tools::Long nLogSt
aRect.AdjustRight(mpDoc->GetColWidth( nCol, nTab ) );
aRect.AdjustBottom(mpDoc->GetRowHeight( nY1, nY2, nTab ) );
- aRect.SetLeft( static_cast<tools::Long>(aRect.Left() * HMM_PER_TWIPS) );
- aRect.SetTop( static_cast<tools::Long>(aRect.Top() * HMM_PER_TWIPS) );
- aRect.SetRight( static_cast<tools::Long>(aRect.Right() * HMM_PER_TWIPS) );
- aRect.SetBottom( static_cast<tools::Long>(aRect.Bottom() * HMM_PER_TWIPS) );
+ aRect.SetLeft(o3tl::convert(aRect.Left(), o3tl::Length::twip, o3tl::Length::mm100));
+ aRect.SetTop(o3tl::convert(aRect.Top(), o3tl::Length::twip, o3tl::Length::mm100));
+ aRect.SetRight(o3tl::convert(aRect.Right(), o3tl::Length::twip, o3tl::Length::mm100));
+ aRect.SetBottom(o3tl::convert(aRect.Bottom(), o3tl::Length::twip, o3tl::Length::mm100));
if(pViewShell || pDrawView)
{
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 40180e6d5a6b..e07511ccd907 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -33,6 +33,7 @@
#include <vcl/commandevent.hxx>
#include <vcl/settings.hxx>
#include <o3tl/deleter.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <preview.hxx>
#include <prevwsh.hxx>
@@ -452,15 +453,19 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
if (nPrinted) // if not, draw everything grey
{
aLocalPageSize = pPrintFunc->GetPageSize();
- aLocalPageSize.setWidth( static_cast<tools::Long>(aLocalPageSize.Width() * HMM_PER_TWIPS ) );
- aLocalPageSize.setHeight( static_cast<tools::Long>(aLocalPageSize.Height() * HMM_PER_TWIPS ) );
-
- nLeftMargin = static_cast<tools::Long>( nLeftMargin * HMM_PER_TWIPS );
- nRightMargin = static_cast<tools::Long>( nRightMargin * HMM_PER_TWIPS );
- nTopMargin = static_cast<tools::Long>( nTopMargin * HMM_PER_TWIPS );
- nBottomMargin = static_cast<tools::Long>( nBottomMargin * HMM_PER_TWIPS );
- nHeaderHeight = static_cast<tools::Long>( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin );
- nFooterHeight = static_cast<tools::Long>( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin );
+ aLocalPageSize.setWidth(
+ o3tl::convert(aLocalPageSize.Width(), o3tl::Length::twip, o3tl::Length::mm100));
+ aLocalPageSize.setHeight(
+ o3tl::convert(aLocalPageSize.Height(), o3tl::Length::twip, o3tl::Length::mm100));
+
+ nLeftMargin = o3tl::convert(nLeftMargin, o3tl::Length::twip, o3tl::Length::mm100);
+ nRightMargin = o3tl::convert(nRightMargin, o3tl::Length::twip, o3tl::Length::mm100);
+ nTopMargin = o3tl::convert(nTopMargin, o3tl::Length::twip, o3tl::Length::mm100);
+ nBottomMargin = o3tl::convert(nBottomMargin, o3tl::Length::twip, o3tl::Length::mm100);
+ constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::twip, o3tl::Length::mm10);
+ const auto m = md.first * mnScale, d = md.second * 100;
+ nHeaderHeight = o3tl::convert(nHeaderHeight, m, d) + nTopMargin;
+ nFooterHeight = o3tl::convert(nFooterHeight, m, d) + nBottomMargin;
}
if (!bStateValid)
@@ -1065,17 +1070,17 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
SvxLRSpaceItem aLRItem = rStyleSet.Get( ATTR_LRSPACE );
- if(( bLeftRulerChange || bRightRulerChange ) && ( aButtonUpPt.X() <= ( 0 - aOffset.X() ) || aButtonUpPt.X() > nWidth * HMM_PER_TWIPS - aOffset.X() ) )
+ if(( bLeftRulerChange || bRightRulerChange ) && ( aButtonUpPt.X() <= ( 0 - aOffset.X() ) || aButtonUpPt.X() > o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() ) )
{
bMoveRulerAction = false;
Invalidate(tools::Rectangle(0, 0, 10000, 10000));
}
- else if( bLeftRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS > nWidth - aLRItem.GetRight() - aOffset.X() / HMM_PER_TWIPS ) )
+ else if( bLeftRulerChange && ( o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) > nWidth - aLRItem.GetRight() - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip) ) )
{
bMoveRulerAction = false;
Invalidate(tools::Rectangle(0, 0, 10000, 10000));
}
- else if( bRightRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS < aLRItem.GetLeft() - aOffset.X() / HMM_PER_TWIPS ) )
+ else if( bRightRulerChange && ( o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) < aLRItem.GetLeft() - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip) ) )
{
bMoveRulerAction = false;
Invalidate(tools::Rectangle(0, 0, 10000, 10000));
@@ -1090,13 +1095,13 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
ScDocShellModificator aModificator( *pDocShell );
if( bLeftRulerChange && bLeftRulerMove )
{
- aLRItem.SetLeft( static_cast<tools::Long>( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS ));
+ aLRItem.SetLeft(o3tl::convert( aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) + o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip));
rStyleSet.Put( aLRItem );
pDocShell->SetModified();
}
else if( bRightRulerChange && bRightRulerMove )
{
- aLRItem.SetRight( static_cast<tools::Long>( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS ));
+ aLRItem.SetRight(nWidth - o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip));
rStyleSet.Put( aLRItem );
pDocShell->SetModified();
}
@@ -1132,7 +1137,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
SetPointer( PointerStyle::Arrow );
bool bMoveRulerAction = true;
- if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > nHeight * HMM_PER_TWIPS -aOffset.Y() ) )
+ if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) -aOffset.Y() ) )
{
bMoveRulerAction = false;
Invalidate(tools::Rectangle(0, 0, 10000, 10000));
@@ -1162,13 +1167,13 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
if( bTopRulerMove && bTopRulerChange )
{
- aULItem.SetUpperValue( static_cast<sal_uInt16>( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) );
+ aULItem.SetUpperValue(o3tl::convert(aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) + o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip));
rStyleSet.Put( aULItem );
pDocShell->SetModified();
}
else if( bBottomRulerMove && bBottomRulerChange )
{
- aULItem.SetLowerValue( static_cast<sal_uInt16>( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) );
+ aULItem.SetLowerValue(nHeight - o3tl::convert(aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) - o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip));
rStyleSet.Put( aULItem );
pDocShell->SetModified();
}
@@ -1179,7 +1184,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
{
const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
Size aHeaderSize = rHeaderSet.Get(ATTR_PAGE_SIZE).GetSize();
- aHeaderSize.setHeight( static_cast<tools::Long>( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper()) );
+ aHeaderSize.setHeight(o3tl::convert( aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) + o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip) - aULItem.GetUpper());
aHeaderSize.setHeight( aHeaderSize.Height() * 100 / mnScale );
SvxSetItem aNewHeader( rStyleSet.Get(ATTR_PAGE_HEADERSET) );
aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) );
@@ -1194,7 +1199,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
{
const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
Size aFooterSize = rFooterSet.Get(ATTR_PAGE_SIZE).GetSize();
- aFooterSize.setHeight( static_cast<tools::Long>( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() ) );
+ aFooterSize.setHeight(nHeight - o3tl::convert(aButtonUpPt.Y(), o3tl::Length::mm100, o3tl::Length::twip) - o3tl::convert(aOffset.Y(), o3tl::Length::mm100, o3tl::Length::twip) - aULItem.GetLower());
aFooterSize.setHeight( aFooterSize.Height() * 100 / mnScale );
SvxSetItem aNewFooter( rStyleSet.Get(ATTR_PAGE_FOOTERSET) );
aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) );
@@ -1252,15 +1257,17 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
tools::Long nNewColWidth = 0;
std::vector<sc::ColRowSpan> aCols(1, sc::ColRowSpan(nColNumberButtonDown,nColNumberButtonDown));
+ constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::mm100, o3tl::Length::twip);
+ const auto m = md.first * 100, d = md.second * mnScale;
if( !bLayoutRTL )
{
- nNewColWidth = static_cast<tools::Long>( PixelToLogic( Point( rMEvt.GetPosPixel().X() - mvRight[ nColNumberButtonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
+ nNewColWidth = o3tl::convert(PixelToLogic( Point( rMEvt.GetPosPixel().X() - mvRight[ nColNumberButtonDown ], 0), aMMMode ).X(), m, d);
nNewColWidth += pDocShell->GetDocument().GetColWidth( nColNumberButtonDown, nTab );
}
else
{
- nNewColWidth = static_cast<tools::Long>( PixelToLogic( Point( mvRight[ nColNumberButtonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
+ nNewColWidth = o3tl::convert(PixelToLogic( Point( mvRight[ nColNumberButtonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X(), m, d);
nNewColWidth += pDocShell->GetDocument().GetColWidth( nColNumberButtonDown, nTab );
}
@@ -1308,30 +1315,32 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
else
pPrintFunc.reset(new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, nullptr, &aOptions ));
- nLeftMargin = static_cast<tools::Long>( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() );
- nRightMargin = static_cast<tools::Long>( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS );
- nRightMargin = static_cast<tools::Long>( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() );
- nTopMargin = static_cast<tools::Long>( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() );
- nBottomMargin = static_cast<tools::Long>( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS );
- nBottomMargin = static_cast<tools::Long>( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() );
+ nLeftMargin = o3tl::convert(pPrintFunc->GetLeftMargin(), o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X();
+ nRightMargin = o3tl::convert(pPrintFunc->GetRightMargin(), o3tl::Length::twip, o3tl::Length::mm100);
+ nRightMargin = o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - nRightMargin - aOffset.X();
+ nTopMargin = o3tl::convert(pPrintFunc->GetTopMargin(), o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y();
+ nBottomMargin = o3tl::convert(pPrintFunc->GetBottomMargin(), o3tl::Length::twip, o3tl::Length::mm100);
+ nBottomMargin = o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - nBottomMargin - aOffset.Y();
if( mnScale > 0 )
{
- nHeaderHeight = static_cast<tools::Long>( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 );
- nFooterHeight = static_cast<tools::Long>( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 );
+ constexpr auto md = o3tl::getConversionMulDiv(o3tl::Length::twip, o3tl::Length::mm100);
+ const auto m = md.first * mnScale, d = md.second * 100;
+ nHeaderHeight = nTopMargin + o3tl::convert(pPrintFunc->GetHeader().nHeight, m, d);
+ nFooterHeight = nBottomMargin - o3tl::convert(pPrintFunc->GetFooter().nHeight, m, d);
}
else
{
- nHeaderHeight = static_cast<tools::Long>( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS );
- nFooterHeight = static_cast<tools::Long>( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS );
+ nHeaderHeight = nTopMargin + o3tl::convert(pPrintFunc->GetHeader().nHeight, o3tl::Length::twip, o3tl::Length::mm100);
+ nFooterHeight = nBottomMargin - o3tl::convert(pPrintFunc->GetFooter().nHeight, o3tl::Length::twip, o3tl::Length::mm100);
}
}
Point aPixPt( rMEvt.GetPosPixel() );
Point aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode );
- Point aLeftBottom = LogicToPixel( Point( nLeftMargin ,static_cast<tools::Long>(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
+ Point aLeftBottom = LogicToPixel( Point( nLeftMargin, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y()), aMMMode );
Point aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode );
Point aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode );
- Point aTopRight = LogicToPixel( Point( static_cast<tools::Long>(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode );
+ Point aTopRight = LogicToPixel( Point( o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X(), nTopMargin ), aMMMode );
Point aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode );
Point aHeaderLeft = LogicToPixel( Point( -aOffset.X(), nHeaderHeight ), aMMMode );
Point aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
@@ -1341,7 +1350,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
{
Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
- Point aColumnBottom = LogicToPixel( Point( 0, static_cast<tools::Long>( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
+ Point aColumnBottom = LogicToPixel( Point( 0, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y()), aMMMode );
tools::Long nRight = i < static_cast<SCCOL>(mvRight.size()) ? mvRight[i] : 0;
if( aPixPt.X() < ( nRight + 2 ) && ( aPixPt.X() > ( nRight - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() )
&& ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
@@ -1405,7 +1414,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::HSplit );
if( bColRulerMove )
{
- if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
DragMove( aMouseMovePoint.X(), PointerStyle::HSplit );
}
}
@@ -1416,7 +1425,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::HSizeBar );
if( bLeftRulerMove )
{
- if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar );
}
}
@@ -1425,7 +1434,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::HSizeBar );
if( bRightRulerMove )
{
- if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X() )
DragMove( aMouseMovePoint.X(), PointerStyle::HSizeBar );
}
}
@@ -1444,7 +1453,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::VSizeBar );
if( bTopRulerMove )
{
- if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
}
}
@@ -1453,7 +1462,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::VSizeBar );
if( bBottomRulerMove )
{
- if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
}
}
@@ -1462,7 +1471,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::VSizeBar );
if( bHeaderRulerMove )
{
- if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
}
}
@@ -1471,7 +1480,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
SetPointer( PointerStyle::VSizeBar );
if( bFooterRulerMove )
{
- if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y() )
DragMove( aMouseMovePoint.Y(), PointerStyle::VSizeBar );
}
}
@@ -1552,12 +1561,12 @@ void ScPreview::DrawInvert( tools::Long nDragPos, PointerStyle nFlags )
tools::Long nWidth = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Width();
if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
{
- tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,static_cast<tools::Long>( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y()));
+ tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1, o3tl::convert(nHeight, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.Y());
Invert( aRect, InvertFlags::N50 );
}
else if( nFlags == PointerStyle::VSizeBar )
{
- tools::Rectangle aRect( -aOffset.X(), nDragPos,static_cast<tools::Long>( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 );
+ tools::Rectangle aRect( -aOffset.X(), nDragPos, o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X(), nDragPos + 1 );
Invert( aRect, InvertFlags::N50 );
}
}
diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx
index 281cc468ab1d..9060893cad9a 100644
--- a/sc/source/ui/view/prevloc.cxx
+++ b/sc/source/ui/view/prevloc.cxx
@@ -20,6 +20,7 @@
#include <prevloc.hxx>
#include <document.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <osl/diagnose.h>
#include <vcl/outdev.hxx>
@@ -278,8 +279,6 @@ static ScPreviewLocationEntry* lcl_GetEntryByAddress(
tools::Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
{
- const double nScaleX = HMM_PER_TWIPS;
- const double nScaleY = HMM_PER_TWIPS;
SCTAB nTab = rRange.aStart.Tab();
tools::Long nPosX = 0;
@@ -288,14 +287,16 @@ tools::Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPo
{
sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
if (nDocW)
- nPosX += static_cast<tools::Long>(nDocW * nScaleX);
+ nPosX += o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
}
- tools::Long nSizeX = static_cast<tools::Long>( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
+ const tools::Long nSizeX
+ = o3tl::convert(pDoc->GetColWidth(nEndCol, nTab), o3tl::Length::twip, o3tl::Length::mm100);
SCROW nEndRow = rCellPos.Row();
- tools::Long nPosY = static_cast<tools::Long>(pDoc->GetScaledRowHeight( rRange.aStart.Row(),
- nEndRow, nTab, nScaleY));
- tools::Long nSizeY = static_cast<tools::Long>( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
+ tools::Long nPosY = o3tl::convert(pDoc->GetRowHeight(rRange.aStart.Row(), nEndRow, nTab),
+ o3tl::Length::twip, o3tl::Length::mm100);
+ tools::Long nSizeY
+ = o3tl::convert(pDoc->GetRowHeight(nEndRow, nTab), o3tl::Length::twip, o3tl::Length::mm100);
Size aOffsetLogic( nPosX, nPosY );
Size aSizeLogic( nSizeX, nSizeY );
@@ -443,9 +444,6 @@ tools::Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const tools::Re
void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
{
- const double nScaleX = HMM_PER_TWIPS;
- const double nScaleY = HMM_PER_TWIPS;
-
// from left to right:
bool bHasHeaderCol = false;
bool bHasRepCols = false;
@@ -553,7 +551,8 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel,
if (!pDoc->ColHidden(nCol, nTab))
{
sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
- tools::Long nNextX = nPosX + static_cast<tools::Long>(nDocW * nScaleX);
+ tools::Long nNextX
+ = nPosX + o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
@@ -572,7 +571,8 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel,
if (!pDoc->ColHidden(nCol, nTab))
{
sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
- tools::Long nNextX = nPosX + static_cast<tools::Long>(nDocW * nScaleX);
+ tools::Long nNextX
+ = nPosX + o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
@@ -618,7 +618,8 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel,
continue;
sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
- tools::Long nNextY = nPosY + static_cast<tools::Long>(nDocH * nScaleY);
+ tools::Long nNextY
+ = nPosY + o3tl::convert(nDocH, o3tl::Length::twip, o3tl::Length::mm100);
tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
@@ -639,7 +640,8 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel,
continue;
sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
- tools::Long nNextY = nPosY + static_cast<tools::Long>(nDocH * nScaleY);
+ tools::Long nNextY
+ = nPosY + o3tl::convert(nDocH, o3tl::Length::twip, o3tl::Length::mm100);
tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index a542737da227..62de4f07ebd7 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -40,6 +40,7 @@
#include <sfx2/printer.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/viewfac.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <drwlayer.hxx>
#include <prevwsh.hxx>
@@ -264,8 +265,8 @@ bool ScPreviewShell::GetPageSize( Size& aPageSize )
const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet();
aPageSize = pParamSet->Get(ATTR_PAGE_SIZE).GetSize();
- aPageSize.setWidth( static_cast<tools::Long>(aPageSize.Width() * HMM_PER_TWIPS ) );
- aPageSize.setHeight( static_cast<tools::Long>(aPageSize.Height() * HMM_PER_TWIPS ) );
+ aPageSize.setWidth(o3tl::convert(aPageSize.Width(), o3tl::Length::twip, o3tl::Length::mm100));
+ aPageSize.setHeight(o3tl::convert(aPageSize.Height(), o3tl::Length::twip, o3tl::Length::mm100));
return true;
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 1769bf007e6e..7e7368548f9a 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -26,6 +26,7 @@
#include <sal/log.hxx>
#include <tools/svborder.hxx>
#include <tools/json_writer.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <pagedata.hxx>
#include <tabview.hxx>
@@ -1673,11 +1674,11 @@ Point ScTabView::GetInsertPos() const
tools::Long nPosX = 0;
for (SCCOL i=0; i<nCol; i++)
nPosX += rDoc.GetColWidth(i,nTab);
- nPosX = static_cast<tools::Long>(nPosX * HMM_PER_TWIPS);
+ nPosX = o3tl::convert(nPosX, o3tl::Length::twip, o3tl::Length::mm100);
if ( rDoc.IsNegativePage( nTab ) )
nPosX = -nPosX;
tools::Long nPosY = static_cast<tools::Long>(rDoc.GetRowHeight( 0, nRow-1, nTab));
- nPosY = static_cast<tools::Long>(nPosY * HMM_PER_TWIPS);
+ nPosY = o3tl::convert(nPosY, o3tl::Length::twip, o3tl::Length::mm100);
return Point(nPosX,nPosY);
}
@@ -1711,8 +1712,8 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange
bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
- tools::Long nDocX = static_cast<tools::Long>( static_cast<double>(rDoc.GetColOffset( rDoc.MaxCol() + 1, nTab )) * HMM_PER_TWIPS ) * nLayoutSign;
- tools::Long nDocY = static_cast<tools::Long>( static_cast<double>(rDoc.GetRowOffset( rDoc.MaxRow() + 1, nTab )) * HMM_PER_TWIPS );
+ tools::Long nDocX = o3tl::convert(rDoc.GetColOffset(rDoc.MaxCol() + 1, nTab), o3tl::Length::twip, o3tl::Length::mm100) * nLayoutSign;
+ tools::Long nDocY = o3tl::convert(rDoc.GetRowOffset( rDoc.MaxRow() + 1, nTab ), o3tl::Length::twip, o3tl::Length::mm100);
if ( aVisible.Left() * nLayoutSign > nDocX * nLayoutSign )
aVisible.SetLeft( nDocX );
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index a18b8f15e52b..d6e287f657ab 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -20,6 +20,7 @@
#include <scitems.hxx>
#include <editeng/eeitem.hxx>
#include <o3tl/safeint.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <editeng/adjustitem.hxx>
@@ -811,8 +812,8 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pVi
assert(bool(pDoc) != bool(pDocSh)); // either one or the other, not both
maMarkData.SelectOneTable(0); // Sync with nTabNo
- aScrSize = Size( tools::Long( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
- static_cast<tools::Long>( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
+ aScrSize = Size( o3tl::convert(STD_COL_WIDTH * OLE_STD_CELLS_X, o3tl::Length::twip, o3tl::Length::px),
+ o3tl::convert(ScGlobal::nStdRowHeight * OLE_STD_CELLS_Y, o3tl::Length::twip, o3tl::Length::px));
maTabData.emplace_back( new ScViewDataTable(nullptr) );
pThisTab = maTabData[nTabNo].get();
@@ -1553,7 +1554,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
{
aPixRect.AdjustRight(1 );
if (bLOKPrintTwips)
- aPTwipsRect.AdjustRight(TWIPS_PER_PIXEL);
+ aPTwipsRect.AdjustRight(o3tl::convert(1, o3tl::Length::px, o3tl::Length::twip));
}
if (bLOKPrintTwips)
@@ -2844,7 +2845,7 @@ void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
pThisTab->nPosX[eWhich] = nNewPosX;
pThisTab->nTPosX[eWhich] = nTPosX;
- pThisTab->nMPosX[eWhich] = static_cast<tools::Long>(nTPosX * HMM_PER_TWIPS);
+ pThisTab->nMPosX[eWhich] = o3tl::convert(nTPosX, o3tl::Length::twip, o3tl::Length::mm100);
pThisTab->nPixPosX[eWhich] = nPixPosX;
}
else
@@ -2887,7 +2888,7 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
pThisTab->nPosY[eWhich] = nNewPosY;
pThisTab->nTPosY[eWhich] = nTPosY;
- pThisTab->nMPosY[eWhich] = static_cast<tools::Long>(nTPosY * HMM_PER_TWIPS);
+ pThisTab->nMPosY[eWhich] = o3tl::convert(nTPosY, o3tl::Length::twip, o3tl::Length::mm100);
pThisTab->nPixPosY[eWhich] = nPixPosY;
}
else
@@ -2974,7 +2975,7 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart )
bool bEnd;
nSize = 0;
- nTwips = static_cast<tools::Long>(rVisAreaStart.X() / HMM_PER_TWIPS);
+ nTwips = o3tl::convert(rVisAreaStart.X(), o3tl::Length::mm100, o3tl::Length::twip);
if (mrDoc.IsLayoutRTL(nTabNo))
nTwips = -nTwips;
SCCOL nX1 = 0;
@@ -2992,7 +2993,7 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart )
}
nSize = 0;
- nTwips = static_cast<tools::Long>(rVisAreaStart.Y() / HMM_PER_TWIPS);
+ nTwips = o3tl::convert(rVisAreaStart.Y(), o3tl::Length::mm100, o3tl::Length::twip);
SCROW nY1 = 0;
bEnd = false;
while (!bEnd)
@@ -3022,8 +3023,8 @@ void ScViewData::SetScreen( const tools::Rectangle& rVisArea )
// here without GetOutputFactor(), since it's for the output into a Metafile
aScrSize = rVisArea.GetSize();
- aScrSize.setWidth( static_cast<tools::Long>( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS ) );
- aScrSize.setHeight( static_cast<tools::Long>( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS ) );
+ aScrSize.setWidth(std::round(o3tl::convert( aScrSize.Width(), o3tl::Length::mm100, o3tl::Length::twip) * ScGlobal::nScreenPPTX));
+ aScrSize.setHeight(std::round(o3tl::convert( aScrSize.Height(), o3tl::Length::mm100, o3tl::Length::twip) * ScGlobal::nScreenPPTY));
}
ScDocFunc& ScViewData::GetDocFunc() const
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 010febb22012..daa2e9c17db3 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -42,6 +42,7 @@
#include <vcl/graph.hxx>
#include <vcl/TypeSerializer.hxx>
#include <osl/thread.h>
+#include <o3tl/unit_conversion.hxx>
#include <comphelper/automationinvokedzone.hxx>
#include <comphelper/lok.hxx>
@@ -99,7 +100,8 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
if (rDoc.IsNegativePage(nTab))
nXT = -nXT;
sal_uLong nYT = rDoc.GetRowHeight( 0, nPosY-1, nTab);
- aPos = Point( static_cast<tools::Long>(nXT * HMM_PER_TWIPS), static_cast<tools::Long>(nYT * HMM_PER_TWIPS) );
+ aPos = Point(o3tl::convert(nXT, o3tl::Length::twip, o3tl::Length::mm100),
+ o3tl::convert(nYT, o3tl::Length::twip, o3tl::Length::mm100));
}
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 36abc6a0a665..192d90e0b342 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -27,6 +27,7 @@
#include <editeng/editobj.hxx>
#include <editeng/langitem.hxx>
#include <editeng/justifyitem.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <sfx2/bindings.hxx>
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
@@ -2403,7 +2404,8 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
nMargin = sal::static_int_cast<sal_uInt16>(
nMargin + pPattern->GetItem(ATTR_INDENT).GetValue() );
- nWidth = static_cast<sal_uInt16>(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS)
+ nWidth = std::round(o3tl::convert(nEdit * pDocSh->GetOutputFactor(),
+ o3tl::Length::mm100, o3tl::Length::twip))
+ nMargin + STD_EXTRA_WIDTH;
}
}