summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-10-23 17:20:38 +0200
committerJan Holesovsky <kendy@collabora.com>2018-11-07 12:51:03 +0100
commit053d9247ce0818580658a7b6f5854f8b21754f7c (patch)
tree74e8357d14920b7babe85b9287dff8e52e5bbefd /sc
parentddd2790f3402abaa64ccc501b63826dd29b29b68 (diff)
sc lok: Implement hi-dpi and zoom for spreadsheets.
A bit different approach than trying to paint different zoom levels at the samet time, because it is terribly hard to achieve with Calc - things misalign, because Calc tries to fit the lines into the pixels etc. Instead, always paint the spreadsheet at 100%, but use cairo to scale the actual painting. Change-Id: I228a9dd41bf29862bdd188825d12e61e1c86cccc
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/docuno.cxx10
-rw-r--r--sc/source/ui/view/gridwin4.cxx32
2 files changed, 28 insertions, 14 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b42179663858..021f316c6236 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -978,12 +978,12 @@ bool ScModelObj::isMimeTypeSupported()
return EditEngine::HasValidData(aDataHelper.GetTransferable());
}
-void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int nTileTwipWidth_, int nTileTwipHeight_)
+void ScModelObj::setClientZoom(int /*nTilePixelWidth_*/, int /*nTilePixelHeight_*/, int /*nTileTwipWidth_*/, int /*nTileTwipHeight_*/)
{
- mnTilePixelWidth = nTilePixelWidth_;
- mnTilePixelHeight = nTilePixelHeight_;
- mnTileTwipWidth = nTileTwipWidth_;
- mnTileTwipHeight = nTileTwipHeight_;
+ mnTilePixelWidth = 256;
+ mnTilePixelHeight = 256;
+ mnTileTwipWidth = mnTilePixelWidth * TWIPS_PER_PIXEL;
+ mnTileTwipHeight = mnTilePixelHeight * TWIPS_PER_PIXEL;
}
OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle)
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 56f19eaf2895..23a01512310d 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -32,6 +32,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
+#include <comphelper/scopeguard.hxx>
#include <sfx2/lokhelper.hxx>
#include <svx/svdview.hxx>
@@ -1108,17 +1109,30 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
// coords only, and avoid all the SetMapMode()'s.
// Similarly to Writer, we should set the mapmode once on the rDevice, and
// not care about any zoom settings.
-
- Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
- Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
-
- // page break zoom, and aLogicMode in ScViewData
+ //
+ // But until that happens, we actually draw everything at 100%, and only
+ // set cairo's scale factor accordingly, so that everything is painted
+ // bigger or smaller. This is different to what Calc's internal scaling
+ // would do - because that one is trying to fit the lines between cells to
+ // integer multiples of pixels.
+ //
+ // See also desktop/source/lib/init.cxx for details, where we have to set
+ // the stuff accorndingly for the VirtualDevice creation.
+
+ // page break zoom, and aLogicMode in ScViewData - hardcode that to what
+ // we mean as 100% (256px tiles meaning 3840 twips)
+ Fraction aFracX(long(256 * TWIPS_PER_PIXEL), 3840);
+ Fraction aFracY(long(256 * TWIPS_PER_PIXEL), 3840);
pViewData->SetZoom(aFracX, aFracY, true);
- const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / nTileWidth;
- const double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / nTileHeight;
- const double fTileBottomPixel = static_cast<double>(nTilePosY + nTileHeight) * nOutputHeight / nTileHeight;
- const double fTileRightPixel = static_cast<double>(nTilePosX + nTileWidth) * nOutputWidth / nTileWidth;
+ // Cairo scales for us, we have to compensate for that, otherwise we are
+ // painting too far away
+ const double fDPIScale = comphelper::LibreOfficeKit::getDPIScale();
+
+ const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / (nTileWidth * fDPIScale);
+ const double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / (nTileHeight * fDPIScale);
+ const double fTileBottomPixel = static_cast<double>(nTilePosY + nTileHeight) * nOutputHeight / (nTileHeight * fDPIScale);
+ const double fTileRightPixel = static_cast<double>(nTilePosX + nTileWidth) * nOutputWidth / (nTileWidth * fDPIScale);
SCTAB nTab = pViewData->GetTabNo();
ScDocument* pDoc = pViewData->GetDocument();