From: Vincent Vanwaelscappel Date: Wed, 19 Apr 2023 13:18:51 +0000 (+0200) Subject: wait #5871 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=767c1dd3a4fbf5743dc8e93e17f2d2cad15f4e1d;p=fluidbook_tools.git wait #5871 @0.5 --- diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index 366b2cb..1a70147 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -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(); + } } diff --git a/src/Compiler/CompilerInterface.php b/src/Compiler/CompilerInterface.php index 96e3f0b..7739e43 100644 --- a/src/Compiler/CompilerInterface.php +++ b/src/Compiler/CompilerInterface.php @@ -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; diff --git a/src/Compiler/DummyCompiler.php b/src/Compiler/DummyCompiler.php index 393ffee..39bbe01 100644 --- a/src/Compiler/DummyCompiler.php +++ b/src/Compiler/DummyCompiler.php @@ -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. + } } diff --git a/src/Links/Link.php b/src/Links/Link.php index 3ca77e1..b315f85 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -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(); diff --git a/src/SVG/SVGTools.php b/src/SVG/SVGTools.php index 1fcb6be..204928f 100644 --- a/src/SVG/SVGTools.php +++ b/src/SVG/SVGTools.php @@ -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;