Rebased ref, commits from common ancestor: commit 632d7dad8b9e4ea5fc81cba98398bf6ae374c00b Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Jul 21 21:15:39 2014 +0200
Lets not roll our own twip/mm100 conversions. Change-Id: Id1d0c2bed0359c35086d963dcfe9b765b6232b09 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 08b8013..60a6f47 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -27,6 +27,7 @@ #include <editeng/scripttypeitem.hxx> #include <sfx2/bindings.hxx> #include <sfx2/printer.hxx> +#include <tools/mapunit.hxx> #include <vcl/settings.hxx> #include <svx/svdpage.hxx> @@ -424,9 +425,8 @@ Size ScGridWindow::GetDataAreaSize() SdrPage* pPage = pPageView->GetPage(); Rectangle aDrawDataArea = pPage->GetAllObjBoundRect(); // Draw layer works in 100th mm, whereas we're working with TWIPs. - aDrawDataArea.SetPos( aDrawDataArea.TopLeft() * 1440 / 2540 ); - aDrawDataArea.SetSize( Size( aDrawDataArea.GetSize().Width() * 1440 / 2540, - aDrawDataArea.GetSize().Height() * 1440 / 2540 ) ); + aDrawDataArea.SetPos( convertMm100ToTwip(aDrawDataArea.TopLeft() ) ); + aDrawDataArea.SetSize( convertMm100ToTwip( aDrawDataArea.GetSize() ) ); // We specifically keep iterating until we have covered both the // data area AND the drawing layer area. We also make sure that @@ -641,7 +641,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod MapMode aDrawMode = pOutDev->GetMapMode(); Point aOrigin = aDrawMode.GetOrigin(); aDrawMode.SetMapUnit( MAP_100TH_MM ); - aDrawMode.SetOrigin( (aOrigin * 2540l) / 1440l ); + aDrawMode.SetOrigin( convertTwipToMm100( aOrigin ) ); Rectangle aDrawingRectLogic; { commit 047bdf304a48a126f840933df0e54dd9f79afbbb Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Jul 21 21:13:15 2014 +0200 Add Point and Size versions of convertMm100ToTwip/TwipToMm100. There seem to be quite a few cases where the individual components are being converted, this way we can just conver the entire object as one. Change-Id: I0043b6f40520d7497e6edc185187706b255f2354 diff --git a/include/tools/mapunit.hxx b/include/tools/mapunit.hxx index a68b6b4..af3eaa9 100644 --- a/include/tools/mapunit.hxx +++ b/include/tools/mapunit.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_TOOLS_MAPUNIT_HXX #define INCLUDED_TOOLS_MAPUNIT_HXX +#include "gen.hxx" + enum MapUnit { MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM, MAP_1000TH_INCH, MAP_100TH_INCH, MAP_10TH_INCH, MAP_INCH, MAP_POINT, MAP_TWIP, MAP_PIXEL, MAP_SYSFONT, MAP_APPFONT, @@ -33,6 +35,18 @@ inline sal_Int64 convertTwipToMm100(sal_Int64 n) return (n*127-36)/72; } +inline Point convertTwipToMm100(const Point& rPoint) +{ + return Point(convertTwipToMm100(rPoint.getX()), + convertTwipToMm100(rPoint.getY())); +} + +inline Size convertTwipToMm100(const Size& rSize) +{ + return Size(convertTwipToMm100(rSize.getWidth()), + convertTwipToMm100(rSize.getHeight())); +} + inline sal_Int64 convertMm100ToTwip(sal_Int64 n) { if (n >= 0) @@ -41,6 +55,18 @@ inline sal_Int64 convertMm100ToTwip(sal_Int64 n) return (n*72-63)/127; } +inline Point convertMm100ToTwip(const Point& rPoint) +{ + return Point(convertMm100ToTwip(rPoint.getX()), + convertMm100ToTwip(rPoint.getY())); +} + +inline Size convertMm100ToTwip(const Size& rSize) +{ + return Size(convertMm100ToTwip(rSize.getWidth()), + convertMm100ToTwip(rSize.getHeight())); +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits