]> _ Git - fluidbook_tools.git/commitdiff
wait #5871 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Apr 2023 13:18:51 +0000 (15:18 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Apr 2023 13:18:51 +0000 (15:18 +0200)
src/Compiler/Compiler.php
src/Compiler/CompilerInterface.php
src/Compiler/DummyCompiler.php
src/Links/Link.php
src/SVG/SVGTools.php

index 366b2cb78eee46d09caf1307e2f91341ee04ca07..1a70147413d41d6191a7bc33b1a2243edf03e04f 100644 (file)
@@ -20,8 +20,7 @@ use Illuminate\Queue\Jobs\SyncJob;
 use Illuminate\Queue\SerializesModels;
 use JsonException;
 
-class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
-{
+class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface {
     use FluidbookCompiler;
 
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
@@ -58,8 +57,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     protected $resolutions = [150, 300];
 
 
-    public function addSource($document, $start = 1, $pages = null)
-    {
+    public function addSource($document, $start = 1, $pages = null) {
         $source = new Source(new Document($document), $start, $pages);
         $this->sources[] = $source;
         foreach ($source->getRange() as $sourcePage) {
@@ -73,8 +71,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
      *
      * @return void
      */
-    public function handle()
-    {
+    public function handle() {
         $sync = ($this->job instanceof SyncJob);
         if ($sync) {
             PHP::neverStop(false);
@@ -89,8 +86,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         stop_measure('Process Fluidbook');
     }
 
-    public function processPages($sync = false)
-    {
+    public function processPages($sync = false) {
         start_measure('Process Pages');
         foreach ($this->sources as $source) {
             $source->getDocument()->processPages($this->getProcessFiles(), $source->getRange(), $sync);
@@ -98,8 +94,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         stop_measure('Process Pages');
     }
 
-    public function getTexts()
-    {
+    public function getTexts() {
         start_measure('Process texts');
         foreach ($this->sources as $source) {
             $source->getDocument()->processTexts();
@@ -111,8 +106,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     /**
      * @return ProcessFile[]
      */
-    public function getProcessFiles()
-    {
+    public function getProcessFiles() {
         $res = [
             'thumb' => new ProcessFile('jpg', 'thumb'),
             'text' => new ProcessFile('svg', 150, false, true),
@@ -129,8 +123,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
      * @return ProcessFile
      * @throws Exception
      */
-    public function getProcessFile($name, $page = null)
-    {
+    public function getProcessFile($name, $page = null) {
         $files = $this->getProcessFiles();
         if (isset($files[$name])) {
             $res = $files[$name];
@@ -148,8 +141,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
      * @return SourcePage
      * @throws Exception
      */
-    public function getSourceOfPage($page)
-    {
+    public function getSourceOfPage($page) {
         if (isset($this->pages[$page - 1])) {
             return $this->pages[$page - 1];
         }
@@ -159,8 +151,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     /**
      * @throws JsonException
      */
-    protected function compileFluidbook()
-    {
+    protected function compileFluidbook() {
         start_measure('Compile fluidbook');
 
         if ($this->wdir === '') {
@@ -179,15 +170,13 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         stop_measure('Compile fluidbook');
     }
 
-    public function prepareStub()
-    {
+    public function prepareStub() {
         if ($this->stub !== '') {
             $this->vdir->copyDirectory($this->stub, '/');
         }
     }
 
-    public function compileContents()
-    {
+    public function compileContents() {
         for ($i = 1; $i <= $this->getPageCount(); $i++) {
 
             foreach ($this->resolutions as $resolution) {
@@ -198,13 +187,11 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         }
     }
 
-    public function getPagePDFSource($page)
-    {
+    public function getPagePDFSource($page) {
         return $this->getProcessFile('back300', $page)->getSplittedPDFPage();
     }
 
-    public function getPageCount()
-    {
+    public function getPageCount() {
         $res = 0;
         foreach ($this->sources as $source) {
             $res += $source->getPages();
@@ -216,8 +203,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     /**
      * @throws \JsonException
      */
-    public function compileSearch()
-    {
+    public function compileSearch() {
         $index = new SearchIndex();
 
         foreach ($this->pages as $i => $page) {
@@ -231,8 +217,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     /**
      * @throws JsonException
      */
-    public function compileConfig()
-    {
+    public function compileConfig() {
         $settings = mb_substr(file_get_contents($this->stub . '/data/datas.js'), 13, -2);
         $this->config = json_decode($settings, false, 512, JSON_THROW_ON_ERROR);
         $this->config->maxResolution = 300;
@@ -246,8 +231,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         $this->vdir->file_put_contents('data/datas.js', $c);
     }
 
-    protected function compileDimensions()
-    {
+    protected function compileDimensions() {
         $firstPageDoc = $this->getSourceOfPage(1)->getSource()->getDocument();
 
         $width = round($firstPageDoc->getWidth(), 8);
@@ -280,8 +264,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         }
     }
 
-    protected function compilePageNumbers()
-    {
+    protected function compilePageNumbers() {
 
         $this->config->numerotation = [];
         foreach ($this->sources as $source) {
@@ -289,8 +272,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         }
     }
 
-    protected function compileChapters()
-    {
+    protected function compileChapters() {
         $this->config->chaptersPagesNumber = 'physical';
         $this->config->chapters = [];
         foreach ($this->sources as $source) {
@@ -298,68 +280,56 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
         }
     }
 
-    public function getBookSurface()
-    {
+    public function getBookSurface() {
         return $this->getWidth() * $this->getHeight();
     }
 
-    public function getWidth()
-    {
+    public function getWidth() {
         return $this->getSourceOfPage(1)->getSource()->getDocument()->getWidth();
     }
 
-    public function getHeight()
-    {
+    public function getHeight() {
         return $this->getSourceOfPage(1)->getSource()->getDocument()->getHeight();
     }
 
-    public function addVideoJs()
-    {
+    public function addVideoJs() {
         $this->addLess('videojs/videojs');
     }
 
-    public function addSlideshowLibrary($inline = true)
-    {
+    public function addSlideshowLibrary($inline = true) {
         $l = ($inline ? $this->config->inlineSlideshowLibrary : $this->config->popupSlideshowLibrary);
         $this->addLess('slideshow/' . $l);
     }
 
 
-    public function addTriggersLink($page, $link, $delay = 0)
-    {
+    public function addTriggersLink($page, $link, $delay = 0) {
         // TODO: Implement addTriggersLink() method.
     }
 
-    public function addAudiodescription($link)
-    {
+    public function addAudiodescription($link) {
         // TODO: Implement addAudiodescription() method.
     }
 
-    public function addBookmarkGroup($link)
-    {
+    public function addBookmarkGroup($link) {
         // TODO: Implement addBookmarkGroup() method.
     }
 
-    public function getConfigZIP($d)
-    {
+    public function getConfigZIP($d) {
         // TODO: Implement getConfigZIP() method.
     }
 
-    public function addContentLock($page, $unlockConditions = '')
-    {
+    public function addContentLock($page, $unlockConditions = '') {
         // TODO: Implement addContentLock() method.
     }
 
 
-    public function source_path($path = ''): string
-    {
+    public function source_path($path = ''): string {
         // TODO: Implement source_path() method.
         return '';
     }
 
 
-    public function virtualToPhysical($virtual): string|int
-    {
+    public function virtualToPhysical($virtual): string|int {
         // TODO: Implement virtualToPhysical() method.
         return "";
     }
@@ -392,4 +362,12 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface
     public function pushSetting($key, $value) {
         // TODO: Implement pushSetting() method.
     }
+
+    public function getWidthForLinks() {
+        return $this->getWidth() / $this->getLinkScale();
+    }
+
+    public function getHeightForLinks() {
+        return $this->getHeight() / $this->getLinkScale();
+    }
 }
index 96e3f0b84142ee4e1daca84f7453ebc2d6ba0ceb..7739e43b093cf06ba3651cd7e21f8b9d12a749cb 100644 (file)
@@ -38,8 +38,12 @@ interface CompilerInterface {
 
     public function getWidth();
 
+    public function getWidthForLinks();
+
     public function getHeight();
 
+    public function getHeightForLinks();
+
     public function virtualToPhysical($virtual);
 
     public function getPagePDFSource($page): string;
index 393ffeeb60e7bfbb5a3bc94bae5865c119347c3a..39bbe0169f48542e5e92f7714e278f81ed938fd2 100644 (file)
@@ -115,4 +115,12 @@ class DummyCompiler implements CompilerInterface {
     public function addSEOArticle($page, $title, $intro, $image, $id = null, $url = null, $content = '') {
         // TODO: Implement addSEOArticle() method.
     }
+
+    public function getWidthForLinks() {
+        // TODO: Implement getWidthForLinks() method.
+    }
+
+    public function getHeightForLinks() {
+        // TODO: Implement getHeightForLinks() method.
+    }
 }
index 3ca77e14e44c3b7f25a5b440a8a01df270f68ec0..b315f8550934408ccfffe933d241d818f9d43174 100644 (file)
@@ -429,16 +429,16 @@ class Link {
 
     public function overlapDoublePage() {
         // $this->page is normally an integer but it can also be a string (eg. background / aftersearch)
-        if (!is_int($this->page))
+        if (!is_int($this->page)) {
             return false;
-
-        return ($this->page % 2 == 0 && $this->left + $this->width > $this->compiler->getWidth());
+        }
+        return ($this->page % 2 == 0 && ($this->left + $this->width) > $this->compiler->getWidthForLinks());
     }
 
     public function getRightClone() {
         $res = clone $this;
         $res->page++;
-        $res->left -= $this->compiler->getWidth();
+        $res->left -= $this->compiler->getWidthForLinks();
         $res->rightClone = true;
         $res->id .= '_c';
         $res->init();
index 1fcb6be2fb86f04d977e166cc99d68110b8ab6bc..204928f30d2312372e64ea397c584de98a90f2b3 100644 (file)
@@ -3,12 +3,8 @@
 namespace Fluidbook\Tools\SVG;
 
 use Cubist\Util\CommandLine;
-use Cubist\Util\CommandLine\Inkscape;
 use Cubist\Util\Files\Files;
-use Cubist\Util\Str;
 use Fluidbook\Tools\FluidbookTools;
-use Illuminate\Validation\Rules\In;
-use ZipStream\File;
 
 class SVGTools {
     protected static $_r;