Blame SOURCES/0256-sc-lok-emit-RowColumnHeader-info-in-twips.patch

135360
From 2cd289ebee6e572804338d87e26d935443c4817b Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Mon, 2 Nov 2015 10:56:43 +0100
135360
Subject: [PATCH 256/398] sc lok: emit RowColumnHeader info in twips
135360
135360
As that's the unit we use everywhere else in the LOK API. Also, make the
135360
ScGlobal::nScreenPPTX/Y calculation more precise, otherwise rounding
135360
errors occur during the pixel -> twip conversion.
135360
135360
Example with the old precision: col height is 103 px, nScreenPPTY is
135360
0.067, twips is 1537.3134328358208, convering it back is 102.487562189
135360
px.
135360
135360
Example with the new precision: col height is 103 px, nScreenPPTY is
135360
0.0667, twips is 1544.2278860569716, convering it back is 102.948525737
135360
px.
135360
135360
Change-Id: I19f5285508ef0c751614d07969b3a7a037e7d1ec
135360
(cherry picked from commit 708d1c5ab242b545ced598879233fc662d7e6cc0)
135360
---
135360
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 6 ++++--
135360
 sc/source/core/data/global.cxx                      | 6 +++---
135360
 sc/source/ui/view/tabview.cxx                       | 7 +++++--
135360
 3 files changed, 12 insertions(+), 7 deletions(-)
135360
135360
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
index 822a6cb3c4bd..4e9b9b80ea03 100644
135360
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
@@ -250,7 +250,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
135360
         rWindow.m_pRowBar->m_aHeaders.clear();
135360
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
135360
         {
135360
-            Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text"));
135360
+            int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
135360
+            Header aHeader(nSize, rValue.second.get<std::string>("text"));
135360
             rWindow.m_pRowBar->m_aHeaders.push_back(aHeader);
135360
         }
135360
         gtk_widget_show(rWindow.m_pRowBar->m_pDrawingArea);
135360
@@ -259,7 +260,8 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
135360
         rWindow.m_pColumnBar->m_aHeaders.clear();
135360
         for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
135360
         {
135360
-            Header aHeader(std::atoi(rValue.second.get<std::string>("size").c_str()), rValue.second.get<std::string>("text"));
135360
+            int nSize = std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), std::atof(rValue.second.get<std::string>("size").c_str())));
135360
+            Header aHeader(nSize, rValue.second.get<std::string>("text"));
135360
             rWindow.m_pColumnBar->m_aHeaders.push_back(aHeader);
135360
         }
135360
         gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
135360
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
135360
index 12b7cbbe6b56..8303770a7850 100644
135360
--- a/sc/source/core/data/global.cxx
135360
+++ b/sc/source/core/data/global.cxx
135360
@@ -544,9 +544,9 @@ void ScGlobal::UpdatePPT( OutputDevice* pDev )
135360
 
135360
         if ( !pDev )
135360
             pDev = Application::GetDefaultDevice();
135360
-        Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
135360
-        nScreenPPTX = aPix1000.X() / 1000.0;
135360
-        nScreenPPTY = aPix1000.Y() / 1000.0;
135360
+        Point aPix1000 = pDev->LogicToPixel( Point(10000,10000), MAP_TWIP );
135360
+        nScreenPPTX = aPix1000.X() / 10000.0;
135360
+        nScreenPPTY = aPix1000.Y() / 10000.0;
135360
         nPPTZoom = nCurrentZoom;
135360
     }
135360
 }
135360
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
135360
index a3718f62cd7e..f2f6179eaaf9 100644
135360
--- a/sc/source/ui/view/tabview.cxx
135360
+++ b/sc/source/ui/view/tabview.cxx
135360
@@ -2313,12 +2313,15 @@ OUString ScTabView::getRowColumnHeaders()
135360
     SCROW nEndRow = 0;
135360
     pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
135360
 
135360
+    double nPPTX = aViewData.GetPPTX();
135360
+    double nPPTY = aViewData.GetPPTY();
135360
+
135360
     boost::property_tree::ptree aRows;
135360
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
135360
     {
135360
         boost::property_tree::ptree aRow;
135360
         sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
135360
-        aRow.put("size", OString::number(nSize).getStr());
135360
+        aRow.put("size", OString::number(nSize / nPPTY).getStr());
135360
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
135360
         aRow.put("text", aText.toUtf8().getStr());
135360
         aRows.push_back(std::make_pair("", aRow));
135360
@@ -2329,7 +2332,7 @@ OUString ScTabView::getRowColumnHeaders()
135360
     {
135360
         boost::property_tree::ptree aCol;
135360
         sal_uInt16 nSize = pColBar[SC_SPLIT_LEFT]->GetEntrySize(nCol);
135360
-        aCol.put("size", OString::number(nSize).getStr());
135360
+        aCol.put("size", OString::number(nSize / nPPTX).getStr());
135360
         OUString aText = pColBar[SC_SPLIT_LEFT]->GetEntryText(nCol);
135360
         aCol.put("text", aText.toUtf8().getStr());
135360
         aCols.push_back(std::make_pair("", aCol));
135360
-- 
135360
2.12.0
135360