Blame SOURCES/0258-sc-lok-fix-rounding-errors-with-non-100-zoom.patch

f325b2
From 9d9749fb86461eefdb2bab01de003409b236dde0 Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Mon, 2 Nov 2015 15:18:09 +0100
f325b2
Subject: [PATCH 258/398] sc lok: fix rounding errors with non-100% zoom
f325b2
f325b2
There were two problems here:
f325b2
f325b2
1) ScTabView::getRowColumnHeaders() did not expose twip values directly,
f325b2
but used ScRow/ColBar::GetEntrySize(), which does a twip -> pixel
f325b2
conversion, and then converted it back to twip. Avoid this unnecessary
f325b2
roundtrip.
f325b2
f325b2
2) ScViewData::ToPixel() trunaces the resulting float to an integer, so
f325b2
if the result is e.g. 67.7 pixels, then Calc handled that as 67, but
f325b2
gtktiledviewer rounded that up to 68, resulting in non-matching headers
f325b2
for the rendered tiles.
f325b2
f325b2
Change-Id: Ie6ed1ea923a423d1526eeb235b7b87106fd2f20b
f325b2
(cherry picked from commit 861b28b88909ec39fc83fccc0ab23d288128aa0e)
f325b2
---
f325b2
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |  4 ++--
f325b2
 sc/source/ui/view/tabview.cxx                       | 11 ++++-------
f325b2
 2 files changed, 6 insertions(+), 9 deletions(-)
f325b2
f325b2
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
index c6821065d147..7e6379124678 100644
f325b2
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
@@ -256,7 +256,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
f325b2
         rWindow.m_pRowBar->m_aHeaders.clear();
f325b2
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
f325b2
         {
f325b2
-            int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
f325b2
+            int nSize = lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str()));
f325b2
             Header aHeader(nSize, rValue.second.get<std::string>("text"));
f325b2
             rWindow.m_pRowBar->m_aHeaders.push_back(aHeader);
f325b2
         }
f325b2
@@ -266,7 +266,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
f325b2
         rWindow.m_pColumnBar->m_aHeaders.clear();
f325b2
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
f325b2
         {
f325b2
-            int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
f325b2
+            int nSize = lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str()));
f325b2
             Header aHeader(nSize, rValue.second.get<std::string>("text"));
f325b2
             rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader);
f325b2
         }
f325b2
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
f325b2
index f2f6179eaaf9..2d886bca6003 100644
f325b2
--- a/sc/source/ui/view/tabview.cxx
f325b2
+++ b/sc/source/ui/view/tabview.cxx
f325b2
@@ -2313,15 +2313,12 @@ OUString ScTabView::getRowColumnHeaders()
f325b2
     SCROW nEndRow = 0;
f325b2
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
f325b2
 
f325b2
-    double nPPTX = aViewData.GetPPTX();
f325b2
-    double nPPTY = aViewData.GetPPTY();
f325b2
-
f325b2
     boost::property_tree::ptree aRows;
f325b2
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
f325b2
     {
f325b2
         boost::property_tree::ptree aRow;
f325b2
-        sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
f325b2
-        aRow.put("size", OString::number(nSize / nPPTY).getStr());
f325b2
+        sal_uInt16 nSize = pDoc->GetOriginalHeight(nRow, aViewData.GetTabNo());
f325b2
+        aRow.put("size", OString::number(nSize).getStr());
f325b2
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
f325b2
         aRow.put("text", aText.toUtf8().getStr());
f325b2
         aRows.push_back(std::make_pair("", aRow));
f325b2
@@ -2331,8 +2328,8 @@ OUString ScTabView::getRowColumnHeaders()
f325b2
     for (SCCOL nCol = 0; nCol <= nEndCol; ++nCol)
f325b2
     {
f325b2
         boost::property_tree::ptree aCol;
f325b2
-        sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
f325b2
-        aCol.put("size", OString::number(nSize / nPPTX).getStr());
f325b2
+        sal_uInt16 nSize = pDoc->GetColWidth(nCol, aViewData.GetTabNo());
f325b2
+        aCol.put("size", OString::number(nSize).getStr());
f325b2
         OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
f325b2
         aCol.put("text", aText.toUtf8().getStr());
f325b2
         aCols.push_back(std::make_pair("", aCol));
f325b2
-- 
f325b2
2.12.0
f325b2