android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java |   
 5 -
 desktop/qa/desktop_lib/test_desktop_lib.cxx                                |   
 2 
 libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx                   |   
 7 +-
 sc/source/ui/view/tabview.cxx                                              |   
27 ++++------
 4 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit d5786f64fcba4b41e908714312046052bf70a3c9
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Sat Nov 9 18:18:15 2019 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Wed Nov 13 11:15:59 2019 +0100

    lok: calc: switch row / column / grouping data to pixels.
    
    This simplifies lots of logic in the clients, making it trivial to get
    good row/column header alignment at any zoom. Ultimately TWIPS here are
    highly misleading print-twips, and in this state are ~impossible to map
    to pixels accurately unless all data is present back to the origin
    (which is not the current approach).
    
    Change-Id: I6ca30e77865b62e886e23860f7c23350e544c9fc
    Reviewed-on: https://gerrit.libreoffice.org/82555
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git 
a/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java 
b/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java
index 8bce80afd851..32c1cbb82cd4 100644
--- a/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java
+++ b/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java
@@ -29,7 +29,6 @@ import org.mozilla.gecko.gfx.LayerView;
 import java.util.ArrayList;
 
 import static org.libreoffice.SearchController.addProperty;
-import static org.libreoffice.UnitConverter.twipToPixel;
 
 public class CalcHeadersController {
     private static final String LOGTAG = 
CalcHeadersController.class.getSimpleName();
@@ -236,12 +235,12 @@ public class CalcHeadersController {
             JSONArray rowResult = collectiveResult.getJSONArray("rows");
             for (int i = 0; i < rowResult.length(); i++) {
                 
headerInfo.rowLabels.add(rowResult.getJSONObject(i).getString("text"));
-                
headerInfo.rowDimens.add(twipToPixel(rowResult.getJSONObject(i).getLong("size"),
 LOKitShell.getDpi(mContext)));
+                
headerInfo.rowDimens.add(rowResult.getJSONObject(i).getLong("size"));
             }
             JSONArray columnResult = collectiveResult.getJSONArray("columns");
             for (int i = 0; i < columnResult.length(); i++) {
                 
headerInfo.columnLabels.add(columnResult.getJSONObject(i).getString("text"));
-                
headerInfo.columnDimens.add(twipToPixel(columnResult.getJSONObject(i).getLong("size"),
 LOKitShell.getDpi(mContext)));
+                
headerInfo.columnDimens.add(columnResult.getJSONObject(i).getLong("size"));
             }
             return headerInfo;
         } catch (JSONException e) {
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 1810df911b06..f9ef935c4c62 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -712,6 +712,7 @@ void DesktopLOKTest::testRowColumnHeaders()
     for (boost::property_tree::ptree::value_type& rValue : 
aTree.get_child("rows"))
     {
         sal_Int32 nSize = 
OString(rValue.second.get<std::string>("size").c_str()).toInt32();
+        nSize *= 15; /* TWIPS_PER_PIXEL */
         OString aText(rValue.second.get<std::string>("text").c_str());
 
         if (bFirstHeader)
@@ -740,6 +741,7 @@ void DesktopLOKTest::testRowColumnHeaders()
     for (boost::property_tree::ptree::value_type& rValue : 
aTree.get_child("columns"))
     {
         sal_Int32 nSize = 
OString(rValue.second.get<std::string>("size").c_str()).toInt32();
+        nSize *= 15; /* TWIPS_PER_PIXEL */
         OString aText(rValue.second.get<std::string>("text").c_str());
         if (bFirstHeader)
         {
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx 
b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
index 1987bdc909cf..619b2a87b13f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
@@ -103,7 +103,7 @@ static gboolean gtv_calc_header_bar_draw_impl(GtkWidget* 
pWidget, cairo_t* pCair
         if (priv->m_eType == CalcHeaderType::ROW)
         {
             aRectangle.x = 0;
-            aRectangle.y = nPrevious - 1;
+            aRectangle.y = nPrevious;
             aRectangle.width = ROW_HEADER_WIDTH - 1;
             aRectangle.height = rHeader.m_nSize - nPrevious;
             // Left line.
@@ -118,7 +118,7 @@ static gboolean gtv_calc_header_bar_draw_impl(GtkWidget* 
pWidget, cairo_t* pCair
         }
         else if (priv->m_eType == CalcHeaderType::COLUMN)
         {
-            aRectangle.x = nPrevious - 1;
+            aRectangle.x = nPrevious;
             aRectangle.y = 0;
             aRectangle.width = rHeader.m_nSize - nPrevious;
             aRectangle.height = COLUMN_HEADER_HEIGHT - 1;
@@ -168,7 +168,6 @@ gtv_calc_header_bar_class_init(GtvCalcHeaderBarClass* klass)
 
 void gtv_calc_header_bar_configure(GtvCalcHeaderBar* bar, const 
boost::property_tree::ptree* values)
 {
-    GtvApplicationWindow* window = 
GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(bar)));
     GtvCalcHeaderBarPrivate& priv = getPrivate(bar);
     priv->m_aHeaders.clear();
 
@@ -179,7 +178,7 @@ void gtv_calc_header_bar_configure(GtvCalcHeaderBar* bar, 
const boost::property_
         {
             for (boost::property_tree::ptree::value_type& rValue : val)
             {
-                int nSize = 
std::round(lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(window->lokdocview), 
std::atof(rValue.second.get<std::string>("size").c_str())));
+                int nSize = 
std::round(std::atof(rValue.second.get<std::string>("size").c_str()));
                 if (nSize >= bar->m_nPositionPixel)
                 {
                     const int nScrolledSize = nSize - bar->m_nPositionPixel;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 4904514a7f77..fd09ee211ce8 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2386,7 +2386,7 @@ void lcl_getGroupIndexes(const ScOutlineArray& rArray, 
SCCOLROW nStart, SCCOLROW
 }
 
 void lcl_createGroupsData(
-        SCCOLROW nHeaderIndex, SCCOLROW nEnd, long nSizePx, long nTotalTwips,
+        SCCOLROW nHeaderIndex, SCCOLROW nEnd, long nSizePx, long nTotalPx,
         const ScOutlineArray& rArray, std::vector<size_t>& rGroupIndexes,
         std::vector<long>& rGroupStartPositions, OUString& rGroupsBuffer)
 {
@@ -2406,13 +2406,13 @@ void lcl_createGroupsData(
             }
             else if (nHeaderIndex == pEntry->GetStart())
             {
-                rGroupStartPositions[nLevel] = nTotalTwips - nSizePx * 
TWIPS_PER_PIXEL;
+                rGroupStartPositions[nLevel] = nTotalPx - nSizePx;
             }
             else if (nHeaderIndex > pEntry->GetStart() && (nHeaderIndex < nEnd 
&& nHeaderIndex < pEntry->GetEnd()))
             {
                 // for handling group started before the current view range
                 if (rGroupStartPositions[nLevel] < 0)
-                    rGroupStartPositions[nLevel] *= -TWIPS_PER_PIXEL;
+                    rGroupStartPositions[nLevel] *= -1;
                 break;
             }
             if (nHeaderIndex == pEntry->GetEnd() || (nHeaderIndex == nEnd && 
rGroupStartPositions[nLevel] != -1))
@@ -2431,7 +2431,7 @@ void lcl_createGroupsData(
                 aGroupData += "{ \"level\": \"" + OUString::number(nLevel + 1) 
+ "\", ";
                 aGroupData += "\"index\": \"" + OUString::number(nIndex) + 
"\", ";
                 aGroupData += "\"startPos\": \"" + 
OUString::number(rGroupStartPositions[nLevel]) + "\", ";
-                aGroupData += "\"endPos\": \"" + OUString::number(nTotalTwips) 
+ "\", ";
+                aGroupData += "\"endPos\": \"" + OUString::number(nTotalPx) + 
"\", ";
                 aGroupData += "\"hidden\": \"" + OUString::number(bGroupHidden 
? 1 : 0) + "\" }";
 
                 rGroupsBuffer += aGroupData;
@@ -2592,7 +2592,7 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
     {
         OUString aText = OUString::number(nStartRow + 1);
         aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-        aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / 
aViewData.GetPPTX())).append("\", ");
+        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalPixels)).append("\", ");
         aBuffer.append("\"groupLevels\": 
\"").append(OUString::number(nRowGroupDepth)).append("\" }");
     }
 
@@ -2605,11 +2605,10 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
         // nSize will be 0 for hidden rows.
         const long nSizePx = lcl_GetRowHeightPx(aViewData, nRow, nTab);
         nTotalPixels += nSizePx;
-        const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
 
         if (bRangeHeaderSupport && nRowGroupDepth > 0)
         {
-            lcl_createGroupsData(nRow, nEndRow, nSizePx, nTotalTwips,
+            lcl_createGroupsData(nRow, nEndRow, nSizePx, nTotalPixels,
                                  *pRowArray, aRowGroupIndexes, 
aRowGroupStartPositions,
                                  aRowGroupsBuffer);
         }
@@ -2621,7 +2620,7 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
         aBuffer.append(", ");
         aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalTwips)).append("\" }");
+        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalPixels)).append("\" }");
     }
 
     aRowGroupsBuffer += "]";
@@ -2737,7 +2736,7 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
     {
         OUString aText = OUString::number(nStartCol + 1);
         aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-        aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / 
aViewData.GetPPTY())).append("\", ");
+        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalPixels)).append("\", ");
         aBuffer.append("\"groupLevels\": 
\"").append(OUString::number(nColGroupDepth)).append("\" }");
     }
 
@@ -2750,13 +2749,11 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
         // nSize will be 0 for hidden columns.
         const long nSizePx = lcl_GetColWidthPx(aViewData, nCol, nTab);
         nTotalPixels += nSizePx;
-        const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
 
         if (bRangeHeaderSupport && nColGroupDepth > 0)
-        {
-            lcl_createGroupsData(nCol, nEndCol, nSizePx, nTotalTwips,
-                    *pColArray, aColGroupIndexes, aColGroupStartPositions, 
aColGroupsBuffer);
-        }
+            lcl_createGroupsData(nCol, nEndCol, nSizePx, nTotalPixels,
+                                 *pColArray, aColGroupIndexes,
+                                 aColGroupStartPositions, aColGroupsBuffer);
 
         if (bRangeHeaderSupport && nCol < nEndCol && nSizePx == nPrevSizePx)
             continue;
@@ -2767,7 +2764,7 @@ OUString ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle)
 
         aBuffer.append(", ");
         aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
-        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalTwips)).append("\" }");
+        aBuffer.append("\"size\": 
\"").append(OUString::number(nTotalPixels)).append("\" }");
     }
 
     aColGroupsBuffer += "]";
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to