\r
RewriteRule ^viewerhu/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/js/(.+)$ fluidbook/compile/_html5/js/$4 [L] \r
RewriteRule ^viewerhu/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+\r
+ RewriteRule ^viewerht/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/js/(.+)$ fluidbook/compile/_html5/js/$4 [L] \r
+ RewriteRule ^viewerht/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
\r
</IfModule>
\ No newline at end of file
compile.on.save=true\r
-user.properties.file=C:\\Users\\Vincent\\.netbeans\\7.0\\build.properties\r
+user.properties.file=C:\\Users\\Cube\\.netbeans\\7.0\\build.properties\r
B#=org.apache.pdfbox.util.operator.pagedrawer.FillNonZeroAndStrokePath\r
b*#=org.apache.pdfbox.util.operator.pagedrawer.CloseFillEvenOddAndStrokePath\r
B*#=org.apache.pdfbox.util.operator.pagedrawer.FillEvenOddAndStrokePath\r
-#BDC org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5\r
+BDC# org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5\r
BI#=org.apache.pdfbox.util.operator.pagedrawer.BeginInlineImage\r
-#BMC org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5\r
+BMC# org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5\r
BT=org.apache.pdfbox.util.operator.BeginText\r
-#BX org.apache.pdfbox.util.operator.NotImplemented\r
+BX# org.apache.pdfbox.util.operator.NotImplemented\r
c#=org.apache.pdfbox.util.operator.pagedrawer.CurveTo\r
cm=org.apache.pdfbox.util.operator.Concatenate\r
CS=org.apache.pdfbox.util.operator.SetStrokingColorSpace\r
<property file="nbproject/project.properties"/>\r
</target>\r
<target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">\r
+ <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>\r
+ <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>\r
+ <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>\r
+ <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>\r
+ <condition property="platform.javac" value="${platform.home}/bin/javac">\r
+ <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>\r
+ </condition>\r
+ <property name="platform.javac" value="${platform.javac.tmp}"/>\r
+ <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>\r
+ <condition property="platform.java" value="${platform.home}/bin/java">\r
+ <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>\r
+ </condition>\r
+ <property name="platform.java" value="${platform.java.tmp}"/>\r
+ <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>\r
+ <condition property="platform.javadoc" value="${platform.home}/bin/javadoc">\r
+ <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>\r
+ </condition>\r
+ <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>\r
+ <condition property="platform.invalid" value="true">\r
+ <or>\r
+ <contains string="${platform.javac}" substring="$${platforms."/>\r
+ <contains string="${platform.java}" substring="$${platforms."/>\r
+ <contains string="${platform.javadoc}" substring="$${platforms."/>\r
+ </or>\r
+ </condition>\r
+ <fail unless="platform.home">Must set platform.home</fail>\r
+ <fail unless="platform.bootcp">Must set platform.bootcp</fail>\r
+ <fail unless="platform.java">Must set platform.java</fail>\r
+ <fail unless="platform.javac">Must set platform.javac</fail>\r
+ <fail if="platform.invalid">\r
+ The J2SE Platform is not correctly set up.\r
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. \r
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.\r
+ For example like this:\r
+ ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file)\r
+ or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) \r
+ </fail>\r
<available file="${manifest.file}" property="manifest.available"/>\r
<condition property="splashscreen.available">\r
<and>\r
<condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">\r
<length length="0" string="${endorsed.classpath}" when="greater"/>\r
</condition>\r
- <condition else="false" property="jdkBug6558476">\r
- <and>\r
- <matches pattern="1\.[56]" string="${java.specification.version}"/>\r
- <not>\r
- <os family="unix"/>\r
- </not>\r
- </and>\r
- </condition>\r
- <property name="javac.fork" value="${jdkBug6558476}"/>\r
<property name="jar.index" value="false"/>\r
<property name="jar.index.metainf" value="${jar.index}"/>\r
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>\r
<property location="${build.dir}/empty" name="empty.dir"/>\r
<mkdir dir="${empty.dir}"/>\r
<mkdir dir="@{apgeneratedsrcdir}"/>\r
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
<src>\r
<dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
<include name="*"/>\r
<sequential>\r
<property location="${build.dir}/empty" name="empty.dir"/>\r
<mkdir dir="${empty.dir}"/>\r
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
<src>\r
<dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
<include name="*"/>\r
<attribute default="**" name="testincludes"/>\r
<sequential>\r
<property name="junit.forkmode" value="perTest"/>\r
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">\r
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
<batchtest todir="${build.test.results.dir}"/>\r
<classpath>\r
<path path="${run.test.classpath}"/>\r
<classpath>\r
<path path="@{classpath}"/>\r
</classpath>\r
+ <bootclasspath>\r
+ <path path="${platform.bootcp}"/>\r
+ </bootclasspath>\r
</nbjpdastart>\r
</sequential>\r
</macrodef>\r
</macrodef>\r
</target>\r
<target name="-init-debug-args">\r
- <property name="version-output" value="java version "${ant.java.version}"/>\r
+ <exec executable="${platform.java}" outputproperty="version-output">\r
+ <arg value="-version"/>\r
+ </exec>\r
<condition property="have-jdk-older-than-1.4">\r
<or>\r
<contains string="${version-output}" substring="java version "1.0"/>\r
<attribute default="${debug.classpath}" name="classpath"/>\r
<element name="customize" optional="true"/>\r
<sequential>\r
- <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+ <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
<jvmarg line="${debug-args-line}"/>\r
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>\r
<attribute default="${run.classpath}" name="classpath"/>\r
<element name="customize" optional="true"/>\r
<sequential>\r
- <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+ <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>\r
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>\r
<path path="${run.classpath}"/>\r
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>\r
</pathconvert>\r
- <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
+ <echo level="info">${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
</target>\r
<target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">\r
<tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>\r
<j2seproject3:copylibs manifest="${tmp.manifest.file}"/>\r
<echo level="info">To run this application from the command line without Ant, try:</echo>\r
<property location="${dist.jar}" name="dist.jar.resolved"/>\r
- <echo level="info">java -jar "${dist.jar.resolved}"</echo>\r
+ <echo level="info">${platform.java} -jar "${dist.jar.resolved}"</echo>\r
</target>\r
<target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">\r
<delete>\r
-->\r
<target depends="init" if="have.sources" name="-javadoc-build">\r
<mkdir dir="${dist.javadoc.dir}"/>\r
- <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
+ <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
<classpath>\r
<path path="${javac.classpath}"/>\r
</classpath>\r
- <fileset dir="${src.src.dir}" excludes="*.java,${excludes}" includes="${includes}">\r
+ <fileset dir="${src.src.dir}" excludes="${excludes}" includes="${includes}">\r
<filename name="**/*.java"/>\r
</fileset>\r
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">\r
<include name="**/*.java"/>\r
- <exclude name="*.java"/>\r
</fileset>\r
</javadoc>\r
<copy todir="${dist.javadoc.dir}">\r
-build.xml.data.CRC32=5afba316\r
+build.xml.data.CRC32=0fe54e23\r
build.xml.script.CRC32=ef618d2d\r
-build.xml.stylesheet.CRC32=28e38971@1.44.1.45\r
+build.xml.stylesheet.CRC32=28e38971@1.43.1.45\r
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.\r
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.\r
-nbproject/build-impl.xml.data.CRC32=5afba316\r
-nbproject/build-impl.xml.script.CRC32=f0904f14\r
-nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45\r
+nbproject/build-impl.xml.data.CRC32=0fe54e23\r
+nbproject/build-impl.xml.script.CRC32=34b388b3\r
+nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45\r
manifest.file=manifest.mf\r
meta.inf.dir=${src.dir}/META-INF\r
mkdist.disabled=false\r
-platform.active=default_platform\r
+platform.active=JDK_1.7\r
run.classpath=\\r
${build.classes.dir}:\\r
${javac.classpath}\r
<configuration>\r
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">\r
<name>fwstk</name>\r
+ <explicit-platform explicit-source-supported="true"/>\r
<source-roots>\r
<root id="src.src.dir"/>\r
</source-roots>\r
(OperatorProcessor) klass.newInstance();
registerOperatorProcessor(operator, processor);
} catch (Exception e) {
- throw new WrappedIOException(
- "OperatorProcessor class " + processorClassName
- + " could not be instantiated", e);
+
}
}
}
} else {\r
$res .= '<td class="bouton"><a class="popupFSBar" rel="toolbar=yes" rev="viewer_' . $book->book_id . '" href="' . SITE_PATH . 'viewer/' . $book->book_id . '_' . $book->hash . '/">' . $btVoir . '</a></td>';\r
}\r
- $res .= '<td class="bouton"><a class="popupFSBar" rel="toolbar=yes" rev="editor_' . $book->book_id . '" href="' . SITE_PATH . 'editor/' . $book->book_id . '">' . $btEdit . '</a></td>';\r
+ $res .= '<td class="bouton"><a class="popupFSBar" rel="toolbar=yes" rev="editor_' . $book->book_id . '" href="' . SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash . '">' . $btEdit . '</a></td>';\r
} else {\r
$res.='<td></td><td></td>';\r
}\r
global $core;\r
\r
$args = cubePage::getArgs($args);\r
- $book_id = $args[0];\r
+ $e = explode('_', $args[0]);\r
+ $book_id = $e[0];\r
+ $hash = isset($e[1]) ? $e[1] : '';\r
+\r
\r
self::checkDocumentVersionOfBook($book_id);\r
\r
if ($book_id == 'new') {\r
$dao = new wsDAOBook($core->con);\r
$book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang);\r
- http::redirect(SITE_PATH . 'editor/' . $book->book_id);\r
+ http::redirect(SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash);\r
}\r
\r
$res = '<html><head><style type="text/css">';\r
$res .= '<title>' . __('Edition de la publication') . ' #' . $args[0] . '</title>';\r
$res .= '</head>';\r
$res .= '<body onload="this.focus();">';\r
- $res .= self::editComposition($args);\r
+ $res .= self::editComposition($book_id, $hash);\r
$res .= '</body>';\r
$res .= '</html>';\r
echo $res;\r
exit;\r
}\r
\r
- public static function editComposition($args) {\r
+ public static function editComposition($book_id,$hash) {\r
+\r
$fv = array(session_name() => session_id(),\r
- 'book_id' => $args[0]);\r
+ 'book_id' => $book_id,\r
+ 'hash' => $hash);\r
\r
$mtime = filemtime(ROOT . '/swf/composer.swf');\r
return cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . $mtime, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, false);\r
self::commonHTML5Viewer($book_id, $hash, 'u');\r
}\r
\r
+ public static function viewerht($args) {\r
+ commonDroits::min(5);\r
+ $args = cubePage::getArgs($args);\r
+\r
+ $e = explode('_', $args[0]);\r
+ if (count($e) == 2 || $e[2] < TIME - 10) {\r
+ $e[2] = TIME;\r
+ http::redirect(SITE_PATH . 'viewerht/' . implode('_', $e) . '/');\r
+ exit;\r
+ }\r
+\r
+ $book_id = $e[0];\r
+ $hash = $e[1];\r
+ self::commonHTML5Viewer($book_id, $hash, 't');\r
+ }\r
+\r
public static function commonHTML5Viewer($book_id, $hash, $version='') {\r
global $core;\r
self::checkDocumentVersionOfBook($book_id);\r
}\r
\r
if (!$dao->isUpToDate($book_id)) {\r
- $dao->compile($book_id);\r
- $dao->touchCompile($book_id);\r
+ if ($version == 'u' || $version == 't') {\r
+ $dao->compileHTML5($book_id);\r
+ } else {\r
+ $dao->compile($book_id);\r
+ $dao->touchCompile($book_id);\r
+ }\r
}\r
+\r
echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html');\r
exit;\r
}\r
return $res;\r
}\r
\r
- protected function compileHTML5($book_id) {\r
+ public function compileHTML5($book_id) {\r
$htmlCompiler = new wsHTML5Compiler($book_id);\r
$htmlCompiler->compile();\r
}\r
// Then make HD background shots\r
$resolutions = array(36 => 90, 72 => 80, 150 => 75);\r
foreach ($resolutions as $r => $q) {\r
- $texts = false;\r
- $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, $texts);\r
+ $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false);\r
+ $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true);\r
}\r
// Then get layout infos from swf\r
file_put_contents($this->out . '/html/s' . $page . '.layout', $this->dumpSWF($page));\r
'js/libs/fluidbook/fluidbook.nav.js',
'js/libs/fluidbook/fluidbook.js',
'js/main.js');
+ protected static $testJsFiles = array(
+ 'js/libs/cube/fb.js',
+ 'js/libs/modernizr.js',
+ 'js/libs/jquery/jquery.js',
+ 'js/libs/jquery/jquery.transform.js',
+ 'js/libs/jquery/jquery.mousewheel.js',
+ 'js/libs/jquery/jquery.hashchange.js',
+ 'js/tester.js'
+ );
protected $layouts = array();
protected $cssSize = array();
protected $cssColor = array();
protected $optimalWidth = 567;
protected $optimalHeight = 709;
protected $additionalConfig = array();
+ protected $fontScale = 1;
function __construct($book_id) {
global $core;
}
}
- $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg');
- $this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2);
-
$daoDoc = new wsDAODocument($core->con);
$firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
$size = $firstDoc->generalInfos['size'];
$this->width = round($size[0], 2);
$this->height = round($size[1], 2);
+
+ $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg');
+ $this->pdf2htmlRatio = round($imagesize[0] / $this->width, 2);
+
$this->cssScale = min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
$this->cssWidth = $this->width * $this->cssScale;
return $p + 1;
}
+ protected function sortPage($layout) {
+ $lines = array();
+ foreach ($layout->l as $line) {
+ $lines[] = $line;
+ }
+ usort($lines, array($this, 'compareLines'));
+
+ return $lines;
+ }
+
protected function compareLines($a, $b) {
if ((float) $a['y'] > (float) $b['y']) {
return 1;
}
public function compile() {
+
+
foreach ($this->layouts as $page => $layout) {
- $this->div[$page] = array();
+ $lines = $this->sortPage($layout);
$document_id = $this->pages[$page]['document_id'];
- $lines = array();
- foreach ($layout->l as $line) {
- $lines[] = $line;
- }
- usort($lines, array($this, 'compareLines'));
-
+ $this->div[$page] = array();
foreach ($lines as $line) {
$this->div[$page][] = $this->addLine($line, $document_id);
}
$scripts[] = '<script type="text/javascript" src="data/datas.js"></script>';
$script = implode("\n\t\t", $scripts);
+ $scripts=array();
+ foreach (self::$testJsFiles as $js) {
+ $scripts[] = '<script type="text/javascript" src="' . $js . '"></script>';
+ }
+ $scripts[] = '<script type="text/javascript" src="data/datas.js"></script>';
+ $script_test = implode("\n\t\t", $scripts);
+
$vars = array('titre', 'credits', 'ga', 'style', 'script');
foreach ($vars as $v) {
$uhtml = str_replace('<!-- $' . $v . ' -->', $$v, $uhtml);
}
+ $thtml=file_get_contents(WS_COMPILE_ASSETS . '/_html5/tester.html');
+
+ $vars = array('titre', 'credits', 'ga', 'style', 'script_test');
+ foreach ($vars as $v) {
+ $thtml = str_replace('<!-- $' . $v . ' -->', $$v, $thtml);
+ }
+
file_put_contents($this->vdir . '/index.html', $html);
file_put_contents($this->vdir . '/indexu.html', $uhtml);
+ file_put_contents($this->vdir . '/indext.html', $thtml);
}
protected function writeLangs() {
foreach ($this->pages as $page => $infos) {
foreach (self::$resolutions as $r) {
copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg');
+ copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/t' . $page . '.jpg');
}
copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
}
protected function writePage($page) {
$res = '';
+ $page = $this->sortPageLines($page);
foreach ($page as $line) {
$res .= $this->writeLine($line);
}
return $res;
}
+ protected function sortPageLines($page) {
+ $cols = array();
+ // On groupe par x pour tenter de regrouper les paragraphes
+ foreach ($page as $line) {
+ if (!count($line['groups'])) {
+ continue;
+ }
+ $x = (string) $line['groups'][0]['x'];
+ if (!isset($cols[$x])) {
+ $cols[$x] = array();
+ }
+ $cols[$x][] = $line;
+ }
+ // On trie les colonnes
+ usort($cols, array('wsHTML5Compiler', 'sortCols'));
+ // Maintenant, on écrase tout ça
+ $res = array();
+ foreach ($cols as $c) {
+ foreach ($c as $line) {
+ $res[] = $line;
+ }
+ }
+ return $res;
+ }
+
+ protected function sortCols($a, $b) {
+ if ($a[0]['y'] > $b[0]['y']) {
+ return 1;
+ } else if ($a[0]['y'] < $b[0]['y']) {
+ return -1;
+ } else if ($a[0]['groups'][0]['x'] > $b[0]['groups'][0]['x']) {
+ return 1;
+ } else if ($a[0]['groups'][0]['x'] < $b[0]['groups'][0]['x']) {
+ return -1;
+ }
+ return 0;
+ }
+
protected function writeLine($line) {
$res = '';
foreach ($line['groups'] as $group) {
+
$res.=$this->writeGroup($group, $line);
}
return $res;
$group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply);
$group['x'] = $this->getCSSX(($group['x']) * $this->multiply);
+ $group['letterspacing'] = $this->getCSSLetterSpacing($group['letterspacing'] * $this->multiply);
+ $group['wordspacing'] = $this->getCSSWordSpacing($group['wordspacing'] * $this->multiply);
$class = array('g');
if (!is_null($group['color'])) {
$class = implode(' ', $class);
$res = '<div class="' . $class . '">';
- foreach ($group['spans'] as $span) {
- $res.=$this->writeSpan($span);
- }
+ $res.=$group['text'];
$res.='</div>';
return $res;
}
}
foreach ($this->cssLetterSpacing as $letterspacing => $index) {
- $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'em}';
+ $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'px}';
}
foreach ($this->cssWordSpacing as $wordspacing => $index) {
- $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'em}';
+ $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'px}';
}
foreach ($this->cssX as $x => $index) {
}
foreach ($this->cssFont as $font => $index) {
- $res[] = "@font-face{font-family:F" . $index . ";src:url('F" . $index . ".woff') format('woff'),url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".svg#" . $font . "') format('svg')}";
+ $res[] = "@font-face{font-family:F" . $index . ";src:url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".woff') format('woff'),url('F" . $index . ".svg#" . $font . "') format('svg')}";
$res[] = '.f' . $index . '{font-family:F' . $index . ',Arial,Helvetica}';
}
}
usort($tab, array('wsHTML5Compiler', 'sortSpans'));
- if ($debug) {
- //fb($tab);
- }
$currentGroup = null;
$lastParent = null;
if (!is_null($currentGroup)) {
cubeXML::append($l, $currentGroup);
}
-
- if ($debug) {
- fb($l);
- }
return $l;
}
if ($alpha == 0) {
return false;
}
-
- $first = true;
- $letterSpacing = 0;
- $letterCount = 0;
- $wordSpacing = 0;
- $wordCount = 0;
-
$res = array();
- $spans = array();
-
- foreach ($group->s as $span) {
- if ($first && trim((string) $span) == '') {
- continue;
- }
- if ($first) {
- $pos = $x = $span['x'];
- $pos+=$span['width'];
- $first = false;
- } else {
- if ((float) $span['x'] < (float) $newSpan['x']) {
- // On change de groupe
- $ls = $ws = 0;
- if ($letterCount > 0) {
- $ls = $letterSpacing / $letterCount;
- }
- if ($wordCount > 0) {
- $ws = $wordSpacing / $wordCount;
- }
+ $groups = $this->separateGroups($group);
- $res[] = array(
- 'color' => $this->getCSSColor($group['color']),
- 'size' => $this->getCSSSize($group['size']),
- 'font' => $this->getCSSFont((string) $group['font'], $document_id),
- 'letterspacing' => $this->getCSSLetterSpacing($ls),
- 'wordspacing' => $this->getCSSLetterSpacing($ws),
- 'y' => 0,
- 'x' => $x,
- 'spans' => $spans);
-
- $spans = array();
- $pos = $x = $span['x'];
- $pos+=$span['width'];
- } else {
-
- $diff = $span['x'] - $pos;
- if ($diff > $group['size'] / 4) {
- $space = round($diff / $group['size'], 4);
- if ($space > 2) {
- // On change de groupe
- $ls = $ws = 0;
- if ($letterCount > 0) {
- $ls = $letterSpacing / $letterCount;
- }
- if ($wordCount > 0) {
- $ws = $wordSpacing / $wordCount;
- }
- $res[] = array(
- 'color' => $this->getCSSColor($group['color']),
- 'size' => $this->getCSSSize($group['size']),
- 'font' => $this->getCSSFont($group['font'], $document_id),
- 'letterspacing' => $this->getCSSLetterSpacing($ls),
- 'wordspacing' => $this->getCSSLetterSpacing($ws),
- 'y' => 0,
- 'x' => $x,
- 'spans' => $spans);
-
- $spans = array();
- $pos = $x = $span['x'];
- $pos+=$span['width'];
- } else {
-
- $newSpan = $this->addSpan('<span style="width:' . $space . 'em;"> </span>', true);
- array_push($spans, $newSpan);
- }
- }
- }
- }
+ foreach ($groups as $g) {
+ $first = true;
+ $letterSpacing = 0;
+ $letters = 0;
+ $wordSpacing = 0;
+ $spaces = 0;
+ $lastWidth = 0;
+ $nextX = 0;
+ $text = '';
- $newSpan = $this->addSpan($span);
- $pos = $span['x'] + $span['width'];
+ foreach ($g['spans'] as $span) {
+ $char = $span['text'];
- array_push($spans, $newSpan);
- $copy = (string) $span;
- $len = mb_strlen($copy);
- str_replace(' ', '-', $copy, $w);
- $l = $len - $w;
+ if ($first && trim($char) == "") {
+ continue;
+ }
+ if ($first) {
+ $x = floatval($span['x']);
+ $first = false;
+ }
- $letterCount+=$l;
- $wordCount+=$w;
+ $text.=$char;
+ }
- $letterSpacing+=$l * (float) $span['letterspacing'];
- $wordSpacing+=$w * (float) $span['wordspacing'];
- }
- if (count($spans)) {
- $ls = $ws = 0;
- if ($letterCount > 0) {
- $ls = $letterSpacing / $letterCount;
- }
- if ($wordCount > 0) {
- $ws = $wordSpacing / $wordCount;
- }
+ $ws = floatval($group['wordspacing']);
+ $ls = floatval($group['letterspacing']);
+ $size = floatval($group['size']);
$res[] = array(
'color' => $this->getCSSColor($group['color']),
'size' => $this->getCSSSize($group['size']),
'font' => $this->getCSSFont($group['font'], $document_id),
- 'letterspacing' => $this->getCSSLetterSpacing($ls),
- 'wordspacing' => $this->getCSSLetterSpacing($ws),
+ 'letterspacing' => $ls * $size,
+ 'wordspacing' => $ws * $size,
'y' => 0,
'x' => $x,
- 'spans' => $spans);
+ 'text' => $text);
}
-
return $res;
}
- protected function addSpan($span, $space=false) {
- $text = (string) $span;
- return array('text' => $text, 'space' => $space, 'x' => $span['x']);
+ protected function separateGroups($group) {
+ $res = array();
+
+ $first = true;
+ $currentGroup = array('spans' => array());
+ $nextX = 0;
+ $x = 0;
+
+ $spaceWidth = $group['space'];
+ $size = floatval($group['size']);
+ $letterSpacing = floatval($group['letterspacing']) * $size;
+ $wordSpacing = floatval($group['wordspacing']) * $size + $letterSpacing;
+
+ $lastIsSpace = true;
+
+ foreach ($group->s as $span) {
+ $char = (string) $span;
+
+ if ($first && trim($char) == "") {
+ continue;
+ }
+ if ($first) {
+ $x = floatval($span['x']);
+ $first = false;
+ }
+ $sox = floatval($span['x']);
+ $sx = $sox - $x;
+ $sw = floatval($span['width']);
+
+ $diff = $sx - $nextX;
+
+ $s = $char;
+
+ if ($lastIsSpace) {
+ if ($diff > $wordSpacing) {
+ $diff-=$wordSpacing;
+ $diff = round($diff * $this->multiply, 2);
+ if ($diff != 0) {
+ $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
+ }
+ }
+ } else {
+ if ($diff < $letterSpacing) {
+ $diff-=$letterSpacing;
+ $diff = round($diff * $this->multiply, 2);
+ if ($diff != 0) {
+ $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
+ }
+ } else if ($diff > $letterSpacing) {
+ $diff-=$letterSpacing;
+ $diff = round($diff * $this->multiply, 2);
+ if ($diff != 0) {
+ $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
+ }
+ }
+ }
+
+ $newSpan = array('text' => $s, 'x' => $sox);
+ $currentGroup['spans'][] = $newSpan;
+
+
+ $nextX = $sx + $sw;
+ $lastIsSpace = substr($char, -1) == " ";
+ }
+ $res[] = $currentGroup;
+ return $res;
}
- protected function getCSSSize($size) {
+ protected function getCSSSize(
+ $size) {
$size = $this->normalizeFloatValue($size);
$size*=$this->multiply;
return $this->getIndex($size, $this->cssSize);
}
- protected function getCSSFont($font, $document_id) {
+ protected function getCSSFont(
+ $font, $document_id) {
$font = (string) $font;
if (!isset($this->fontDocs[$font])) {
$this->fontDocs[$font] = array();
} elseif ($alpha == 1) {
return '#' . substr($color, 2, 6);
}
- return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
+ return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha
+ . ')';
}
}
$core->url->register('viewerp', 'viewerp', '^viewerp/(.*)$', array('wsUrl', 'viewerp'));\r
$core->url->register('viewerh', 'viewerh', '^viewerh/(.*)$', array('wsUrl', 'viewerh'));\r
$core->url->register('viewerhu', 'viewerhu', '^viewerhu/(.*)$', array('wsUrl', 'viewerhu'));\r
+$core->url->register('viewerht', 'viewerht', '^viewerht/(.*)$', array('wsUrl', 'viewerht'));\r
\r
if (DEV) {\r
$tools = ROOT . '/../inc/tools/';\r