[Libreoffice-commits] online.git: loleaflet/src

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


 loleaflet/src/control/Control.ColumnHeader.js |    4 ++--
 loleaflet/src/control/Control.Header.js       |   24 ++++++++++--------------
 loleaflet/src/control/Control.RowHeader.js    |    4 ++--
 3 files changed, 14 insertions(+), 18 deletions(-)

New commits:
commit d5d157275dd69647d149a10703765174ef40a09a
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Nov 9 18:17:29 2019 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Nov 13 10:17:13 2019 +0000

    calc: switch row / column / grouping data to pixels.
    
    This simplifies lots of logic, making it trivial to get good row/column
    header alignment at any zoom. Ultimately TWIPS were highly misleading
    'print-twips', and in that state are ~impossible to map to pixels
    accurately unless all data is present back to the origin
    (which was not provided previously).
    
    This requires the equivalent patch on master.
    
    Change-Id: I110f6f646e2b52bec4584c193c640df6b41100f8

diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index c68656ae0..ff76788a7 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -410,8 +410,8 @@ L.Control.ColumnHeader = L.Control.Header.extend({
 		this._groupLevels = parseInt(columns[0].groupLevels);
 		this._groups = this._groupLevels ? new Array(this._groupLevels) : null;
 
-		var startOffsetTw = parseInt(columns[0].size);
-		this._startOffset = this._twipsToPixels(startOffsetTw);
+		var startOffsetPx = parseInt(columns[0].size);
+		this._startOffset = startOffsetPx;
 
 		// collect group controls data
 		if (colGroups !== undefined && this._groups) {
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index b29a4817c..fe17df4cc 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -631,8 +631,8 @@ L.Control.Header = L.Control.extend({
 			if (!this._groups[level]) {
 				this._groups[level] = {};
 			}
-			var startPos = this._twipsToPixels(parseInt(groupData.startPos));
-			var endPos = this._twipsToPixels(parseInt(groupData.endPos));
+			var startPos = parseInt(groupData.startPos);
+			var endPos = parseInt(groupData.endPos);
 			var isHidden = !!parseInt(groupData.hidden);
 			if (isHidden || startPos === endPos) {
 				startPos -= this._groupHeadSize / 2;
@@ -757,31 +757,27 @@ L.Control.Header.colHeaderHeight = undefined;
  *   the size of the last known gap.
  * - When a new tick position is defined, it resets the size of the last known gap
  *
- * All the outputs are mapped through a scale function. Inputs are meant
- * to be given in twips, outputs are meant to be returned in CSS pixels,
- * which is also the internal storage format.
+ * All inputs received are given in pixels, outputs are meant to be returned
+ * in CSS pixels, which is also the internal storage format.
  *
- * **NB.** to ensure that all row heights are the same size even though
- * their twip height doesn't map to an integer number of pixels we need to
- * convert to pixels early - and work in pixels internally, as the calc
- * core does.
+ * **NB.** twip to pixel mapping is made non-obvious by the need to ensure that
+ * there are no cumulative rounding errors from TWIP heights to pixels. We have to
+ * match the core here, so we just use pixels.
  */
 L.Control.Header.GapTickMap = L.Class.extend({
 
-	initialize: function (ticks, scaleCallback) {
+	initialize: function (ticks) {
 
 		var gapSize;
 		this._ticks = [];
-		this.scaleCallback = scaleCallback || function() {return 0;}
 
 		// Sanitize input
 		var knownTicks = [];
 		for (var i in ticks) {
 			// The field in the input data struct is called "text" but it's the
 			// column/row index, as a string.
-			// Idem for "size": it's the tick position in twips, as a string
-			knownTicks[ parseInt(ticks[i].text) ] =
-				this.scaleCallback(parseInt(ticks[i].size));
+			// Idem for "size": it's the tick position in pixels, as a string
+			knownTicks[ parseInt(ticks[i].text) ] = parseInt(ticks[i].size);
 		}
 
 		// This *assumes* the input is ordered - i.e. tick indexes only grow
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 6d2739ca5..d40622064 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -399,8 +399,8 @@ L.Control.RowHeader = L.Control.Header.extend({
 		this._groupLevels = parseInt(rows[0].groupLevels);
 		this._groups = this._groupLevels ? new Array(this._groupLevels) : null;
 
-		var startOffsetTw = parseInt(rows[0].size);
-		this._startOffset = this._twipsToPixels(startOffsetTw);
+		var startOffsetPx = parseInt(rows[0].size);
+		this._startOffset = startOffsetPx;
 
 		// collect group controls data
 		if (rowGroups !== undefined && this._groups) {


More information about the Libreoffice-commits mailing list