]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 Mar 2010 18:52:42 +0000 (18:52 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 Mar 2010 18:52:42 +0000 (18:52 +0000)
inc/ws/Controlleur/class.ws.conversion.session.php
inc/ws/Metier/class.ws.document.php

index 269ded484c93c7bfcb7df466e371e95f1262c537..a62c8d7c36501d287d94e0810b9adde5030aca15 100644 (file)
@@ -38,12 +38,7 @@ class wsConversionSession {
 \r
                $dao = new wsDAODocument($core->con);\r
                $this->documents = $dao->selectInList($this->documentsId);\r
-               $this->totalPages = 0;\r
-\r
-               foreach($this->documents as $doc) {\r
-                       $this->totalPages += $doc->getPagesNumber();\r
-               }\r
-               $this->totalDoc = count($this->documents);\r
+               $this->updateCountPages();\r
                $inited = true;\r
        }\r
 \r
@@ -60,6 +55,9 @@ class wsConversionSession {
                        $this->currentDoc = $doc;\r
                        $this->serialize();\r
                        $this->currentDoc->globalOperations();\r
+                       $this->currentDoc = $dao->updateFromObject($this->currentDoc);\r
+                       $this->updateCountPages();\r
+\r
                        for($i = 1;$i <= $doc->generalInfos['pages'];$i++) {\r
                                $this->currentDocPage = $i;\r
                                $this->totalDocPage = $doc->generalInfos['pages'];\r
@@ -77,6 +75,15 @@ class wsConversionSession {
                $this->setProgress(100);\r
        }\r
 \r
+       public function updateCountPages()\r
+       {\r
+               $this->totalPages = 0;\r
+               foreach($this->documents as $doc) {\r
+                       $this->totalPages += $doc->generalInfos['pages'];\r
+               }\r
+               $this->totalDoc = count($this->documents);\r
+       }\r
+\r
        public function getProgress()\r
        {\r
                return array("progress" => $this->progress,\r
index 9b5a26daabf602eecaba60e59873ea44b2b144ff..34b2e62309202e0a6429d2419928384b8b99571d 100644 (file)
@@ -46,6 +46,11 @@ class wsDocument extends cubeMetier {
        const BARBARE_GS = 5;\r
 \r
        protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
+       // Number section styles\r
+       protected static\r
+       $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
+               'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
+               'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
 \r
        public function init()\r
        {\r
@@ -68,14 +73,21 @@ class wsDocument extends cubeMetier {
                $this->uncropDocument();\r
        }\r
 \r
-       public function getInfos()\r
+       public function getInfos($in = null, $force = false)\r
        {\r
-               $pdfinfo = $this->getBasicInfos();\r
-               $pdftk = $this->getAdvancedInfos();\r
+               if(is_null($in)){\r
+                       $in=$this->in;\r
+               }\r
 \r
-               $this->parseInfos($pdfinfo . $pdftk);\r
+               $fwstk = new cubeCommandLine('fwstk');\r
+               $fwstk->setPath(CONVERTER_PATH);\r
+               $fwstk->setArg('--input ' . $in);\r
+               $fwstk->setArg('--infos');\r
+               $fwstk->execute();\r
+               $this->addToLog($fwstk);\r
+               $this->parseInfos($fwstk->output);\r
 \r
-               file_put_contents($this->infos, $pdfinfo . $pdftk);\r
+               file_put_contents($this->infos, $fwstk->output);\r
                $this->findCutDisposition();\r
        }\r
 \r
@@ -153,37 +165,6 @@ class wsDocument extends cubeMetier {
                }\r
        }\r
 \r
-       public function getBasicInfos()\r
-       {\r
-               if (is_null($this->_basicInfos)) {\r
-                       $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
-                       $pdfinfo->setPath(CONVERTER_PATH);\r
-                       $pdfinfo->setArg('-box');\r
-                       $pdfinfo->setArg('f', 1);\r
-                       $pdfinfo->setArg('l', 10000);\r
-                       $pdfinfo->setArg(null, $this->in);\r
-                       $pdfinfo->execute();\r
-                       $this->addToLog($pdfinfo);\r
-\r
-                       $this->_basicInfos = $pdfinfo->output;\r
-               }\r
-               return $this->_basicInfos;\r
-       }\r
-\r
-       public function getAdvancedInfos()\r
-       {\r
-               if (is_null($this->_advancedInfos)) {\r
-                       $pdftk = new cubeCommandLine('pdftk', null, true);\r
-                       $pdftk->setPath(CONVERTER_PATH);\r
-                       $pdftk->setArg(null, $this->in);\r
-                       $pdftk->setArg(null, 'dump_data');\r
-                       $pdftk->execute();\r
-                       $this->addToLog($pdftk);\r
-                       $this->_advancedInfos = $pdftk->output;\r
-               }\r
-               return $this->_advancedInfos;\r
-       }\r
-\r
        public function parseInfos($data)\r
        {\r
                // This function get general infos (pages sizes, boxes, number sections and\r
@@ -191,11 +172,7 @@ class wsDocument extends cubeMetier {
                // Init arrays\r
                $this->generalInfos = array();\r
                $this->bookmarks = array();\r
-               $this->numberSections = array();\r
-               // Number section styles\r
-               $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
-                       'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
-                       'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
+               $this->numberSections = '';\r
 \r
                $res['size'] = array(0, 0);\r
                $lines = explode("\n", $data);\r
@@ -219,15 +196,8 @@ class wsDocument extends cubeMetier {
                        } elseif ($k == 'BookmarkPageNumber') {\r
                                $this->bookmarks[$bookmark_id]['page'] = $v;\r
                                $bookmark_id++;\r
-                       } elseif ($k == 'PageLabelNewIndex') {\r
-                               $section = array('startAt' => $v, 'style' => 'decimal', 'firstNumber' => 1, 'prefix' => '');\r
-                       } else if ($k == 'PageLabelStart') {\r
-                               $section['firstNumber'] = $v;\r
-                       } elseif ($k == 'PageLabelPrefix') {\r
-                               $section['prefix'] = $v;\r
-                       } else if ($k == 'PageLabelNumStyle') {\r
-                               $section['style'] = $numberStyles[$v];\r
-                               $this->numberSections[] = $section;\r
+                       } elseif ($k == 'NumberSections') {\r
+                               $this->numberSection = $v;\r
                        }\r
                }\r
 \r
@@ -236,14 +206,15 @@ class wsDocument extends cubeMetier {
 \r
        public function getPagesNumber()\r
        {\r
-               $this->parseInfos($this->getBasicInfos());\r
+               $this->getInfos();\r
                return $this->generalInfos['pages'];\r
        }\r
 \r
        public function globalOperations()\r
        {\r
                $this->getInfos();\r
-               $this->Crop();\r
+               $this->CropAndCut();\r
+               $this->getInfos($this->cropped, true);\r
                $this->getLinks();\r
                $this->getTexts();\r
        }\r
@@ -263,7 +234,13 @@ class wsDocument extends cubeMetier {
 \r
        public function cutDocument($mode)\r
        {\r
-\r
+               $fwstk = new cubeCommandLine('fwstk');\r
+               $fwstk->setPath(CONVERTER_PATH);\r
+               $fwstk->setArg('--input ' . $this->in);\r
+               $fwstk->setArg('--cut ' . $mode);\r
+               $fwstk->setArg('--output ' . $this->cropped);\r
+               $fwstk->execute();\r
+               $this->addToLog($fwstk);\r
        }\r
 \r
        public function trimDocument()\r
@@ -430,7 +407,7 @@ class wsDocument extends cubeMetier {
        protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)\r
        {\r
                if (is_null($in)) {\r
-                       $in = $this->crop;\r
+                       $in = $this->cropped;\r
                }\r
                $antialiasing = $antialiasing?'yes':'no';\r
                $resolution = round($resolution);\r
@@ -473,6 +450,11 @@ class wsDocument extends cubeMetier {
                }\r
        }\r
 \r
+       protected function isCropped()\r
+       {\r
+               return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut;\r
+       }\r
+\r
        public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0)\r
        {\r
                if ($maxObjects <= 1) {\r
@@ -480,7 +462,7 @@ class wsDocument extends cubeMetier {
                }\r
                // Pour les fichiers croppés, on utilise la méthode flatten qui ne prends\r
                // pas en compte les objets hors de la box\r
-               if ($this->crop) {\r
+               if ($this->isCropped()) {\r
                        $method = max($method, self::FLATTEN);\r
                }\r
 \r
@@ -694,7 +676,7 @@ disablelinks                Disable links.
        {\r
                $fwstk = new cubeCommandLine('fwstk');\r
                $fwstk->setPath(CONVERTER_PATH);\r
-               $fwstk->setArg('--input ' . $this->in);\r
+               $fwstk->setArg('--input ' . $this->cropped);\r
                $fwstk->setArg('--extractLinks ' . $this->out . 'p%d.csv');\r
                $fwstk->execute();\r
                $this->addToLog($fwstk);\r