[Libreoffice-commits] online.git: Branch 'private/hcvcastro/bind-mount' - 15 commits - loleaflet/Makefile loleaflet/reference.html loleaflet/spec loleaflet/src loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp

Henry Castro hcastro at collabora.com
Fri Dec 4 16:28:28 PST 2015


 loleaflet/Makefile                        |   10 +
 loleaflet/reference.html                  |   52 +++++++++
 loleaflet/spec/tilebench.html             |   11 -
 loleaflet/spec/tilebench/TileBenchSpec.js |   15 ++
 loleaflet/src/layer/tile/GridLayer.js     |   30 +++++
 loleaflet/src/map/Map.js                  |    5 
 loolwsd/LOOLSession.cpp                   |    2 
 loolwsd/LOOLWSD.cpp                       |  166 +++++++++++++++---------------
 8 files changed, 196 insertions(+), 95 deletions(-)

New commits:
commit 666e4a080f02a4eaab7355af2968c2a1a31d7618
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Dec 4 18:06:52 2015 -0400

    loolwsd: update drop capabilities

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index debb680..5f0e89d 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -982,6 +982,8 @@ void LOOLWSD::componentMain()
 
 #ifdef __linux
         dropCapability(CAP_SYS_CHROOT);
+        dropCapability(CAP_MKNOD);
+        dropCapability(CAP_FOWNER);
 #else
         dropCapability();
 #endif
@@ -1261,6 +1263,8 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
 
 #ifdef __linux
     dropCapability(CAP_SYS_CHROOT);
+    dropCapability(CAP_MKNOD);
+    dropCapability(CAP_FOWNER);
 #else
     dropCapability();
 #endif
commit f5292a367e7fca543ec0c6aa9769edc5a8fd6df8
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Dec 4 17:09:28 2015 -0400

    loolwsd: rework, remove a jail root child

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 32c1d3e..0c8d672 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -336,7 +336,7 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
         std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
         _availableChildSessions.insert(shared_from_this());
         std::cout << Util::logPrefix() << "Inserted " << this << " id=" << childId << " into _availableChildSessions, size=" << _availableChildSessions.size() << std::endl;
-        LOOLWSD::_childId = _childId = childId;
+        _childId = childId;
         _pidChild = pidChild;
         lock.unlock();
         _availableChildSessionCV.notify_one();
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 9512a86..debb680 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -923,12 +923,6 @@ void LOOLWSD::componentMain()
     {
         _namedMutexLOOL.lock();
 
-        // Initialization
-        std::unique_lock<std::mutex> rngLock(_rngMutex);
-        _rng.seed(Process::id());
-        _childId = (((Poco::UInt64)_rng.next()) << 32) | _rng.next() | 1;
-        rngLock.unlock();
-
         Path jailPath = Path::forDirectory(LOOLWSD::childRoot + Path::separator() + std::to_string(_childId));
         File(jailPath).createDirectory();
 
@@ -1083,6 +1077,10 @@ int LOOLWSD::createComponent()
 {
     int pid;
 
+    std::unique_lock<std::mutex> rngLock(_rngMutex);
+    _childId = (((Poco::UInt64)_rng.next()) << 32) | _rng.next() | 1;
+    rngLock.unlock();
+
     if ((pid = fork()) == -1)
     {
         std::cout << "Fork failed." << std::endl;
@@ -1094,7 +1092,7 @@ int LOOLWSD::createComponent()
         componentMain();
     }
 
-    MasterProcessSession::_childProcesses[pid] = pid;
+    MasterProcessSession::_childProcesses[pid] = _childId;
 
     return Application::EXIT_OK;
 }
@@ -1117,6 +1115,7 @@ void LOOLWSD::desktopMain()
     setSignals(false);
 #endif
 
+    _rng.seed(Process::id());
     startupComponent(_numPreSpawnedChildren);
 
     while (MasterProcessSession::_childProcesses.size() > 0)
@@ -1130,11 +1129,13 @@ void LOOLWSD::desktopMain()
                 if ((WIFEXITED(status) || WIFSIGNALED(status) || WTERMSIG(status) ) )
                 {
                     std::cout << Util::logPrefix() << "One of our known child processes died :" << std::to_string(pid)  << std::endl;
-                    MasterProcessSession::_childProcesses.erase(pid);
-
-                    File aWorkSpace(LOOLSession::jailDocumentURL + Path::separator() + std::to_string(pid));
+                    // remove chroot child
+                    File aWorkSpace(LOOLWSD::childRoot + Path::separator() +
+                                    std::to_string(MasterProcessSession::_childProcesses[pid]));
                     if (aWorkSpace.exists())
                         aWorkSpace.remove(true);
+
+                    MasterProcessSession::_childProcesses.erase(pid);
                 }
 
                 if ( WCOREDUMP(status) )
commit 7ea89ef99bac74de7d8f47b694d553a81318999c
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Dec 4 15:19:31 2015 -0400

    loolwsd: restore jail root child creation

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 4bfb097..9512a86 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -916,13 +916,89 @@ void LOOLWSD::componentMain()
     if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("libreofficekit"), 0, 0, 0) != 0)
         std::cout << Util::logPrefix() << "Cannot set thread name :" << strerror(errno) << std::endl;
 
-    setSignals(true);
+    setSignals(false);
 #endif
 
     try
     {
         _namedMutexLOOL.lock();
 
+        // Initialization
+        std::unique_lock<std::mutex> rngLock(_rngMutex);
+        _rng.seed(Process::id());
+        _childId = (((Poco::UInt64)_rng.next()) << 32) | _rng.next() | 1;
+        rngLock.unlock();
+
+        Path jailPath = Path::forDirectory(LOOLWSD::childRoot + Path::separator() + std::to_string(_childId));
+        File(jailPath).createDirectory();
+
+        Path jailLOInstallation(jailPath, LOOLWSD::loSubPath);
+        jailLOInstallation.makeDirectory();
+        File(jailLOInstallation).createDirectory();
+
+        // Copy (link) LO installation and other necessary files into it from the template
+
+        linkOrCopy(LOOLWSD::sysTemplate, jailPath);
+        linkOrCopy(LOOLWSD::loTemplate, jailLOInstallation);
+
+        // We need this because sometimes the hostname is not resolved
+        std::vector<std::string> networkFiles = {"/etc/host.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/resolv.conf"};
+        for (std::vector<std::string>::iterator it = networkFiles.begin(); it != networkFiles.end(); ++it)
+        {
+            File networkFile(*it);
+            if (networkFile.exists())
+            {
+                networkFile.copyTo(Path(jailPath, "/etc").toString());
+            }
+        }
+#ifdef __linux
+        // Create the urandom and random devices
+        File(Path(jailPath, "/dev")).createDirectory();
+        if (mknod((jailPath.toString() + "/dev/random").c_str(),
+                    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+                    makedev(1, 8)) != 0)
+        {
+            Application::instance().logger().error(Util::logPrefix() +
+                    "mknod(" + jailPath.toString() + "/dev/random) failed: " +
+                    strerror(errno));
+
+        }
+        if (mknod((jailPath.toString() + "/dev/urandom").c_str(),
+                    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+                    makedev(1, 9)) != 0)
+        {
+            Application::instance().logger().error(Util::logPrefix() +
+                    "mknod(" + jailPath.toString() + "/dev/urandom) failed: " +
+                    strerror(errno));
+        }
+#endif
+
+        Application::instance().logger().information("componentMain -> chroot(\"" + jailPath.toString() + "\")");
+        if (chroot(jailPath.toString().c_str()) == -1)
+        {
+            logger().error("chroot(\"" + jailPath.toString() + "\") failed: " + strerror(errno));
+            exit(Application::EXIT_UNAVAILABLE);
+        }
+
+        if (chdir("/") == -1)
+        {
+            logger().error(std::string("chdir(\"/\") in jail failed: ") + strerror(errno));
+            exit(Application::EXIT_UNAVAILABLE);
+        }
+
+#ifdef __linux
+        dropCapability(CAP_SYS_CHROOT);
+#else
+        dropCapability();
+#endif
+
+        if (std::getenv("SLEEPFORDEBUGGER"))
+        {
+            std::cout << "Sleeping " << std::getenv("SLEEPFORDEBUGGER") << " seconds, " <<
+                "attach process " << Process::id() << " in debugger now." << std::endl;
+            Thread::sleep(std::stoul(std::getenv("SLEEPFORDEBUGGER")) * 1000);
+        }
+
 #ifdef __APPLE__
         LibreOfficeKit *loKit(lok_init_2(("/" + loSubPath + "/Frameworks").c_str(), "file:///user"));
 #else
@@ -1041,81 +1117,6 @@ void LOOLWSD::desktopMain()
     setSignals(false);
 #endif
 
-    // Initialization
-    std::unique_lock<std::mutex> rngLock(_rngMutex);
-    _childId = (((Poco::UInt64)_rng.next()) << 32) | _rng.next() | 1;
-    rngLock.unlock();
-
-    Path jailPath = Path::forDirectory(LOOLWSD::childRoot + Path::separator() + std::to_string(_childId));
-    File(jailPath).createDirectory();
-
-    Path jailLOInstallation(jailPath, LOOLWSD::loSubPath);
-    jailLOInstallation.makeDirectory();
-    File(jailLOInstallation).createDirectory();
-
-    // Copy (link) LO installation and other necessary files into it from the template
-
-    linkOrCopy(LOOLWSD::sysTemplate, jailPath);
-    linkOrCopy(LOOLWSD::loTemplate, jailLOInstallation);
-
-    // We need this because sometimes the hostname is not resolved
-    std::vector<std::string> networkFiles = {"/etc/host.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/resolv.conf"};
-    for (std::vector<std::string>::iterator it = networkFiles.begin(); it != networkFiles.end(); ++it)
-    {
-        File networkFile(*it);
-        if (networkFile.exists())
-        {
-            networkFile.copyTo(Path(jailPath, "/etc").toString());
-        }
-    }
-#ifdef __linux
-    // Create the urandom and random devices
-    File(Path(jailPath, "/dev")).createDirectory();
-    if (mknod((jailPath.toString() + "/dev/random").c_str(),
-                S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
-                makedev(1, 8)) != 0)
-    {
-        Application::instance().logger().error(Util::logPrefix() +
-                "mknod(" + jailPath.toString() + "/dev/random) failed: " +
-                strerror(errno));
-
-    }
-    if (mknod((jailPath.toString() + "/dev/urandom").c_str(),
-                S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
-                makedev(1, 9)) != 0)
-    {
-        Application::instance().logger().error(Util::logPrefix() +
-                "mknod(" + jailPath.toString() + "/dev/urandom) failed: " +
-                strerror(errno));
-    }
-#endif
-
-    Application::instance().logger().information("desktopMain -> chroot(\"" + jailPath.toString() + "\")");
-    if (chroot(jailPath.toString().c_str()) == -1)
-    {
-        logger().error("chroot(\"" + jailPath.toString() + "\") failed: " + strerror(errno));
-        exit(Application::EXIT_UNAVAILABLE);
-    }
-
-    if (chdir("/") == -1)
-    {
-        logger().error(std::string("chdir(\"/\") in jail failed: ") + strerror(errno));
-        exit(Application::EXIT_UNAVAILABLE);
-    }
-
-#ifdef __linux
-    dropCapability(CAP_SYS_CHROOT);
-#else
-    dropCapability();
-#endif
-
-    if (std::getenv("SLEEPFORDEBUGGER"))
-    {
-        std::cout << "Sleeping " << std::getenv("SLEEPFORDEBUGGER") << " seconds, " <<
-            "attach process " << Process::id() << " in debugger now." << std::endl;
-        Thread::sleep(std::stoul(std::getenv("SLEEPFORDEBUGGER")) * 1000);
-    }
-
     startupComponent(_numPreSpawnedChildren);
 
     while (MasterProcessSession::_childProcesses.size() > 0)
commit 7c4d91d3adb4d48c2661530a11e7af3c644cf5b4
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 12:57:52 2015 +0200

    loleaflet: jquery is needed by vex in tilebench

diff --git a/loleaflet/spec/tilebench.html b/loleaflet/spec/tilebench.html
index 8f4cdb1..6a0dbaf 100644
--- a/loleaflet/spec/tilebench.html
+++ b/loleaflet/spec/tilebench.html
@@ -11,6 +11,7 @@
 <body>
 	<div id="mocha"></div>
 	<script src="expect.js"></script>
+	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
 	<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
 	<script type="text/javascript" src="../node_modules/happen/happen.js"></script>
 	<script type="text/javascript" src="sinon.js"></script>
commit e36d6a06849a57105585bd0fc880a84989f2550b
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 12:57:11 2015 +0200

    loleaflet: run npm install before packaging

diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 4261f93..2f8a940 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -9,6 +9,7 @@ VERSION=1.4.19
 DRAW_VERSION=0.2.4
 
 all:
+	npm install
 	jake build
 	cd plugins/draw-$(DRAW_VERSION) && jake build
 
commit 73be5c3f50a8fbc1ddae68bcba2c91e228a432d2
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 12:14:22 2015 +0200

    loleaflet: also pack the test files and some nodejs modules

diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 7423327..4261f93 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -18,7 +18,11 @@ dist: all
 	mkdir loleaflet-$(VERSION)
 	cp README loleaflet-$(VERSION)
 	cp reference.html loleaflet-$(VERSION)
-	tar cf - dist plugins/draw-$(DRAW_VERSION)/dist debug/document src/scrollbar docs | (cd loleaflet-$(VERSION) && tar xf -)
+	tar cf - dist plugins/draw-$(DRAW_VERSION)/dist debug/document src/scrollbar docs spec \
+		node_modules/mocha/mocha.css \
+		node_modules/mocha/mocha.js \
+		node_modules/happen/happen.js \
+		| (cd loleaflet-$(VERSION) && tar xf -)
 	tar cfz loleaflet-$(VERSION).tar.gz loleaflet-$(VERSION)
 	rm -rf loleaflet-$(VERSION)
 
commit e1cca3dd7ed509a8dceb1efdaee050856ccc0102
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 10:50:09 2015 +0200

    loleaflet: bump version after tarball

diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index f48e8b6..7423327 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -3,7 +3,7 @@
 # ("micro") part: Between releases odd, even for releases (no other
 # changes inbetween).
 
-VERSION=1.4.18
+VERSION=1.4.19
 
 # Version number of the bundled 'draw' thing
 DRAW_VERSION=0.2.4
commit f662a89f4ea6748df38bf416c845d2e9d4588875
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 10:45:32 2015 +0200

    loleaflet: bump version before tarball

diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 6eab4b4..f48e8b6 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -3,7 +3,7 @@
 # ("micro") part: Between releases odd, even for releases (no other
 # changes inbetween).
 
-VERSION=1.4.17
+VERSION=1.4.18
 
 # Version number of the bundled 'draw' thing
 DRAW_VERSION=0.2.4
commit 031156546edd075d5f0198b0ed7f372c5e91f041
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Dec 4 10:40:56 2015 +0200

    loleaflet: document map.sendUnoCommand

diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 9c80699..e70a02c 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1642,6 +1642,13 @@ var map = L.map('map', {
 		<td><code>undefined</code></td>
         <td>Renders the given font in the smallest rectangle it can fit in.</td>
 	</tr>
+	<tr>
+		<td><code><b>sendUnoCommand</b>(
+			<nobr><<a href="#loleaflet-uno-commands">String</a>> <i>unoCommand</i>,</nobr>
+			<nobr><<a href="#loleaflet-uno-commands">Object</a>> <i>param</i>)</nobr>
+		<td><code>undefined</code></td>
+        <td>Sends a <a href="#loleaflet-uno-commands">uno command</a> with the given paramter to LOKit.</td>
+	</tr>
 </table>
 
 <h2 id="loleaflet-page">Page oriented</h2>
@@ -2469,6 +2476,14 @@ var map = L.map('map', {
 <h2 id="loleaflet-uno-commands">Object values</h2>
 
 <p>A list of common uno commands with their additional parameters.</p>
+<pre><code class="javascript">map.sendUnoCommand('.uno:Bold')<code></pre>
+<pre><code class="javascript">map.sendUnoCommand('.uno:Color',
+{
+  "Color": {
+    "type": "long",
+    "value": 16750848
+  }
+})<code></pre>
 
 <table data-id='values' id='uno-commands-table'>
 	<tr>
@@ -8007,7 +8022,18 @@ var unoCommands = [
             value: 16750848
         }
     },
-    description: 'Apply a highlighting color (the value can be obtained by converting the base 16 color to base 10).'
+    description: 'Apply a highlighting color for a text document (the value can be obtained by converting the base 16 color to base 10).'
+},
+
+{
+    uno: '.uno:BackgroundColor',
+    parameter: {
+        'BackgroundColor': {
+            type: 'long',
+            value: 16750848
+        }
+    },
+    description: 'Apply a highlighting color for a spreadsheet document (the value can be obtained by converting the base 16 color to base 10).'
 },
 
 {
@@ -8023,6 +8049,17 @@ var unoCommands = [
 },
 
 {
+    uno: '.uno:CharBackColor',
+    parameter: {
+        'CharBackColor': {
+            type: 'long',
+            value: 16750848
+        }
+    },
+    description: 'Apply a font color for a presentation document (the value can be obtained by converting the base 16 color to base 10).'
+},
+
+{
     uno: '.uno:CharFontName',
     parameter: {
         'CharFontName.FamilyName': {
@@ -8034,6 +8071,17 @@ var unoCommands = [
 },
 
 {
+    uno: '.uno:Color',
+    parameter: {
+        'Color': {
+            type: 'long',
+            value: 16750848
+        }
+    },
+    description: 'Apply a font color for a non-text document, like a spreadsheet, presentation, etc (the value can be obtained by converting the base 16 color to base 10).'
+},
+
+{
     uno: '.uno:DecrementIndent',
     parameter: null,
     description: 'Decrement paragraph indentation.'
@@ -8076,7 +8124,7 @@ var unoCommands = [
             value: 16750848
         }
     },
-    description: 'Apply a font color (the value can be obtained by converting the base 16 color to base 10).'
+    description: 'Apply a font color for a text document (the value can be obtained by converting the base 16 color to base 10).'
 },
 
 {
commit ebcf779d785d40c6aa670451d9d02ffdd2396430
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Dec 3 22:55:14 2015 +0200

    loleaflet: include reference.html in the tarball

diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index 3d0554a..6eab4b4 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -17,7 +17,8 @@ dist: all
 	rm -rf loleaflet-$(VERSION)
 	mkdir loleaflet-$(VERSION)
 	cp README loleaflet-$(VERSION)
-	tar cf - dist plugins/draw-$(DRAW_VERSION)/dist debug/document src/scrollbar | (cd loleaflet-$(VERSION) && tar xf -)
+	cp reference.html loleaflet-$(VERSION)
+	tar cf - dist plugins/draw-$(DRAW_VERSION)/dist debug/document src/scrollbar docs | (cd loleaflet-$(VERSION) && tar xf -)
 	tar cfz loleaflet-$(VERSION).tar.gz loleaflet-$(VERSION)
 	rm -rf loleaflet-$(VERSION)
 
commit 493d560203580cb7499b0c88682d3dd9c959b247
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Dec 3 22:47:10 2015 +0200

    loleaflet: the current tilebench replay only works for text docs

diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js b/loleaflet/spec/tilebench/TileBenchSpec.js
index 841b5d9..9724d57 100644
--- a/loleaflet/spec/tilebench/TileBenchSpec.js
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -146,6 +146,7 @@ describe('TileBench', function () {
 		done();
 	};
 
+	// since we don't click anywhere, this replay will only work for text documents
 	var keyInput = [
 		[135, 'key type=input char=84 key=0'],
 		[237, 'key type=up char=0 key=16'],
commit 4a1ec210ed4abfcb1f1b84e3fd8d8378826ae79c
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Dec 3 22:44:16 2015 +0200

    loleaflet: allow adding the file_path and host for tilebench

diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js b/loleaflet/spec/tilebench/TileBenchSpec.js
index 120665e..841b5d9 100644
--- a/loleaflet/spec/tilebench/TileBenchSpec.js
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -11,15 +11,24 @@ describe('TileBench', function () {
 		li.style.class = 'test pass';
 		li.innerHTML = '<h2>' + msg + '</h2>';
 		cont.appendChild(li);
-	}
+	};
+
+	var getParameterByName = function (name) {
+		name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+		var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+			results = regex.exec(location.search);
+		return results === null ? "" : results[1].replace(/\+/g, " ");
+	};
 
 	before(function () {
 		var htmlPath = window.location.pathname;
 		var dir = htmlPath.substring(0, htmlPath.lastIndexOf('/'));
 		var fileURL = 'file://' + dir + '/data/eval.odt';
+		fileURL = getParameterByName('file_path') || fileURL;
+		var server = getParameterByName('host') || 'ws://localhost:9980';
 		// initialize the map and load the document
 		map = L.map('map', {
-			server: 'ws://localhost:9980',
+			server: server,
 			doc: fileURL,
 			edit: false,
 			readOnly: false
commit 552514c35dc7c6ed0d99a9083b3762eb38155873
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Dec 3 22:37:22 2015 +0200

    loleaflet: hide the document container after running tilebench

diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js b/loleaflet/spec/tilebench/TileBenchSpec.js
index 6abd54e..120665e 100644
--- a/loleaflet/spec/tilebench/TileBenchSpec.js
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -43,6 +43,7 @@ describe('TileBench', function () {
 
 	after(function () {
 		map.remove();
+        document.getElementById('document-container').style.visibility = 'hidden';
 	});
 
 	describe('Benchmarking', function () {
commit c57cd5b46830cb83908a0ef4aad701cfcfdbb336
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Thu Dec 3 22:21:59 2015 +0200

    loleaflet: remove the scrollbar from tilebench.html

diff --git a/loleaflet/spec/tilebench.html b/loleaflet/spec/tilebench.html
index 4cf5f50..8f4cdb1 100644
--- a/loleaflet/spec/tilebench.html
+++ b/loleaflet/spec/tilebench.html
@@ -5,7 +5,6 @@
 	<title>LOOL Spec Runner</title>
 	<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
 	<link rel="stylesheet" type="text/css" href="../dist/leaflet.css">
-	<link rel="stylesheet" type="text/css" href="../src/scrollbar/jquery.mCustomScrollbar.css">
 	<link rel="stylesheet" type="text/css" href="../dist/dialog/vex.css" />
 	<link rel="stylesheet" type="text/css" href="../dist/dialog/vex-theme-plain.css" />
 </head>
@@ -15,16 +14,11 @@
 	<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
 	<script type="text/javascript" src="../node_modules/happen/happen.js"></script>
 	<script type="text/javascript" src="sinon.js"></script>
-	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
-	<script>window.jQuery || document.write('<script src="../src/scrollbar/jquery-1.11.0.min.js"><\/script>')</script>
-	<script src="../src/scrollbar/jquery.mCustomScrollbar.js"></script>
 	<script src="../dist/dialog/vex.combined.min.js"></script>
 	<script>vex.defaultOptions.className = 'vex-theme-plain';</script>
 
 	<!-- source files -->
-	<script type="text/javascript" src="../build/deps.js"></script>
-
-	<script type="text/javascript" src="../debug/leaflet-include.js"></script>
+	<script type="text/javascript" src="../dist/leaflet-src.js"></script>
 
 	<script>
 		mocha.setup({
@@ -38,7 +32,7 @@
 
 	<div id="toolbar" style="hidden">
 	</div>
-	<div id="document-container" style="top:300px">
+	<div id="document-container" style="top:210px">
 		<div id="map"></div>
 	</div>
 
commit cfda6755373b1060f433407978b6307ec73066a7
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Wed Dec 2 14:16:35 2015 +0200

    loleaflet: glue the spreadsheet to the row/column headers
    
    Previously when the spreadsheet was zoomed out and it was smaller than
    the viewing area, the document would've been centered

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index df981f5..e023189 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -389,6 +389,36 @@ L.GridLayer = L.Layer.extend({
 		this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y});
 	},
 
+	_checkSpreadSheetBounds: function (newZoom) {
+		// for spreadsheets, when the document is smaller than the viewing area
+		// we want it to be glued to the row/column headers instead of being centered
+		// In the future we probably want to remove this and set the bonds only on the
+		// left/upper side of the spreadsheet so that we can have an 'infinite' number of
+		// cells downwards and to the right, like we have on desktop
+		var viewSize = this._map.getSize();
+		var scale = this._map.getZoomScale(newZoom);
+		var width = this._docWidthTwips / this._tileWidthTwips * this._tileSize * scale;
+		var height = this._docHeightTwips / this._tileHeightTwips * this._tileSize * scale;
+		if (width < viewSize.x || height < viewSize.y) {
+			// if after zoomimg the document becomes smaller than the viewing area
+			width = Math.max(width, viewSize.x);
+			height = Math.max(height, viewSize.y);
+			if (!this._map.options._origMaxBounds) {
+				this._map.options._origMaxBounds = this._map.options.maxBounds;
+			}
+			scale = this._map.options.crs.scale(1);
+			this._map.setMaxBounds(new L.LatLngBounds(
+					this._map.unproject(new L.Point(0, 0)),
+					this._map.unproject(new L.Point(width * scale, height * scale))));
+		}
+		else if (this._map.options._origMaxBounds) {
+			// if after zoomimg the document becomes larger than the viewing area
+			// we need to restore the inital bounds
+			this._map.setMaxBounds(this._map.options._origMaxBounds);
+			this._map.options._origMaxBounds = null;
+		}
+	},
+
 	_updateScrollOffset: function () {
 		var centerPixel = this._map.project(this._map.getCenter());
 		var newScrollPos = centerPixel.subtract(this._map.getSize().divideBy(2));
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 28c2209..7dd0ce5 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -74,6 +74,11 @@ L.Map = L.Evented.extend({
 			this._zoom = this._limitZoom(zoom);
 			return this;
 		}
+		if (this._docLayer && this._docLayer._docType === 'spreadsheet') {
+			// for spreadsheets, when the document is smaller than the viewing area
+			// we want it to be glued to the row/column headers instead of being centered
+			this._docLayer._checkSpreadSheetBounds(zoom);
+		}
 		return this.setView(this.getCenter(), zoom, {zoom: options});
 	},
 


More information about the Libreoffice-commits mailing list