[Libreoffice-commits] core.git: android/source desktop/qa libreofficekit/qa sc/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 13 10:17:42 UTC 2019


 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 66bbf08f08dafe38c02edbca11ca01e7906d4b81
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Nov 9 18:18:15 2019 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Nov 13 11:16:56 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/82572
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at 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 e6207b2cf98a..2c2d03b967ea 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -709,6 +709,7 @@ void DesktopLOKTest::testRowColumnHeaders()
     for (const 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)
@@ -737,6 +738,7 @@ void DesktopLOKTest::testRowColumnHeaders()
     for (const 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 9346057b7d01..ee75100464f3 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
@@ -114,7 +114,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.
@@ -129,7 +129,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;
@@ -179,7 +179,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();
 
@@ -190,7 +189,7 @@ void gtv_calc_header_bar_configure(GtvCalcHeaderBar* bar, const boost::property_
         {
             for (const 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 ff0dc196d82f..ec52581dad23 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))
@@ -2430,7 +2430,7 @@ void lcl_createGroupsData(
                 OUString aGroupData = "{ \"level\": \"" + OUString::number(nLevel + 1) + "\", "
                     "\"index\": \"" + OUString::number(nIndex) + "\", "
                     "\"startPos\": \"" + OUString::number(rGroupStartPositions[nLevel]) + "\", "
-                    "\"endPos\": \"" + OUString::number(nTotalTwips) + "\", "
+                    "\"endPos\": \"" + OUString::number(nTotalPx) + "\", "
                     "\"hidden\": \"" + OUString::number(bGroupHidden ? 1 : 0) + "\" }";
 
                 rGroupsBuffer += aGroupData;
@@ -2591,7 +2591,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("\" }");
     }
 
@@ -2603,11 +2603,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);
         }
@@ -2619,7 +2618,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 += "]";
@@ -2735,7 +2734,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("\" }");
     }
 
@@ -2747,13 +2746,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;
@@ -2764,7 +2761,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 += "]";


More information about the Libreoffice-commits mailing list