* sandbox/arthur/xml_to_html/xml_to_html.hh,
* sandbox/arthur/xml_to_html/xml_to_html.cc,
* sandbox/arthur/xml_to_html/xml_to_html.pro: Remove.
* sandbox/arthur/xml_to_html/README,
* sandbox/arthur/xml_to_html/main.cc,
* sandbox/arthur/xml_to_html/domitem.cc,
* sandbox/arthur/xml_to_html/domitem.hh,
* sandbox/arthur/xml_to_html/dommodel.cc,
* sandbox/arthur/xml_to_html/dommodel.hh: Move to...
* sandbox/arthur/xml_transform/README,
* sandbox/arthur/xml_transform/main.cc,
* sandbox/arthur/xml_transform/domitem.cc,
* sandbox/arthur/xml_transform/domitem.hh,
* sandbox/arthur/xml_transform/dommodel.cc,
* sandbox/arthur/xml_transform/dommodel.hh: ...this.
* sandbox/arthur/xml_to_html/patterns/css.css,
* sandbox/arthur/xml_to_html/patterns/xsl.xsl: Move to...
* sandbox/arthur/xml_transform/templates/html/css.css,
* sandbox/arthur/xml_transform/templates/html/xsl.xsl: ...this.
* sandbox/arthur/xml_transform/image_crop.cc,
* sandbox/arthur/xml_transform/loader.cc: New.
* sandbox/arthur/xml_transform/templates/html/html_generator.sh,
* sandbox/arthur/xml_transform/templates/pdf/line.xsl,
* sandbox/arthur/xml_transform/templates/pdf/main.xsl,
* sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl,
* sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh,
* sandbox/arthur/xml_transform/templates/pdf/regions.xsl,
* sandbox/arthur/xml_transform/xml_transform.pro: New.
---
scribo/ChangeLog | 39 +++
scribo/sandbox/arthur/xml_to_html/README | 25 --
scribo/sandbox/arthur/xml_to_html/main.cc | 58 ----
scribo/sandbox/arthur/xml_to_html/patterns/css.css | 28 --
scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl | 229 ---------------
scribo/sandbox/arthur/xml_to_html/xml_to_html.cc | 292 --------------------
scribo/sandbox/arthur/xml_to_html/xml_to_html.hh | 49 ----
scribo/sandbox/arthur/xml_to_html/xml_to_html.pro | 16 -
scribo/sandbox/arthur/xml_transform/README | 19 ++
.../{xml_to_html => xml_transform}/domitem.cc | 0
.../{xml_to_html => xml_transform}/domitem.hh | 0
.../{xml_to_html => xml_transform}/dommodel.cc | 0
.../{xml_to_html => xml_transform}/dommodel.hh | 0
scribo/sandbox/arthur/xml_transform/image_crop.cc | 184 ++++++++++++
scribo/sandbox/arthur/xml_transform/image_crop.hh | 46 +++
scribo/sandbox/arthur/xml_transform/loader.cc | 162 +++++++++++
scribo/sandbox/arthur/xml_transform/loader.hh | 49 ++++
scribo/sandbox/arthur/xml_transform/main.cc | 30 ++
.../arthur/xml_transform/templates/html/css.css | 31 ++
.../xml_transform/templates/html/html_generator.sh | 3 +
.../arthur/xml_transform/templates/html/xsl.xsl | 224 +++++++++++++++
.../arthur/xml_transform/templates/pdf/line.xsl | 129 +++++++++
.../arthur/xml_transform/templates/pdf/main.xsl | 62 ++++
.../xml_transform/templates/pdf/main_crop.xsl | 42 +++
.../xml_transform/templates/pdf/pdf_generator.sh | 3 +
.../arthur/xml_transform/templates/pdf/regions.xsl | 59 ++++
.../sandbox/arthur/xml_transform/xml_transform.cc | 93 +++++++
.../sandbox/arthur/xml_transform/xml_transform.hh | 48 ++++
.../sandbox/arthur/xml_transform/xml_transform.pro | 20 ++
29 files changed, 1243 insertions(+), 697 deletions(-)
delete mode 100644 scribo/sandbox/arthur/xml_to_html/README
delete mode 100644 scribo/sandbox/arthur/xml_to_html/main.cc
delete mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/css.css
delete mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
create mode 100644 scribo/sandbox/arthur/xml_transform/README
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/domitem.cc (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/domitem.hh (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/dommodel.cc (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/dommodel.hh (100%)
create mode 100644 scribo/sandbox/arthur/xml_transform/image_crop.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/image_crop.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/loader.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/loader.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/main.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/css.css
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.pro
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 5d742bd..df16c98 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,42 @@
+2010-07-08 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ XML transform program.
+
+ * sandbox/arthur/xml_to_html/xml_to_html.hh,
+ * sandbox/arthur/xml_to_html/xml_to_html.cc,
+ * sandbox/arthur/xml_to_html/xml_to_html.pro: Remove.
+
+ * sandbox/arthur/xml_to_html/README,
+ * sandbox/arthur/xml_to_html/main.cc,
+ * sandbox/arthur/xml_to_html/domitem.cc,
+ * sandbox/arthur/xml_to_html/domitem.hh,
+ * sandbox/arthur/xml_to_html/dommodel.cc,
+ * sandbox/arthur/xml_to_html/dommodel.hh: Move to...
+
+ * sandbox/arthur/xml_transform/README,
+ * sandbox/arthur/xml_transform/main.cc,
+ * sandbox/arthur/xml_transform/domitem.cc,
+ * sandbox/arthur/xml_transform/domitem.hh,
+ * sandbox/arthur/xml_transform/dommodel.cc,
+ * sandbox/arthur/xml_transform/dommodel.hh: ...this.
+
+ * sandbox/arthur/xml_to_html/patterns/css.css,
+ * sandbox/arthur/xml_to_html/patterns/xsl.xsl: Move to...
+
+ * sandbox/arthur/xml_transform/templates/html/css.css,
+ * sandbox/arthur/xml_transform/templates/html/xsl.xsl: ...this.
+
+ * sandbox/arthur/xml_transform/image_crop.cc,
+ * sandbox/arthur/xml_transform/loader.cc: New.
+
+ * sandbox/arthur/xml_transform/templates/html/html_generator.sh,
+ * sandbox/arthur/xml_transform/templates/pdf/line.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/main.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh,
+ * sandbox/arthur/xml_transform/templates/pdf/regions.xsl,
+ * sandbox/arthur/xml_transform/xml_transform.pro: New.
+
2010-07-05 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
Small fix in Qt interface.
diff --git a/scribo/sandbox/arthur/xml_to_html/README
b/scribo/sandbox/arthur/xml_to_html/README
deleted file mode 100644
index f16f472..0000000
--- a/scribo/sandbox/arthur/xml_to_html/README
+++ /dev/null
@@ -1,25 +0,0 @@
-xml_to_html
-
-Produce HTML view from ICDAR (or LRDE extended) XML.
-
-*Compilation:
-
- Just change the paths to olena and milena in xml_to_html.pro
-
-*Usage:
-
- -m, --merge: Merge an XML with an other XML
- args: <xml_file_1> <xml_file_2> [xml_output]
-
-Useful to merge LRDE XML extended mode files with ICDAR XML files to combine both images
and recognized text.
-
-
- -c, --create-html: Crop images (if exist) from the ppm file using the XML file and
produce an html output.
- args: <xml_file> [ppm_file] [output dir]
-
-If no PPM file is given, the program will only produce an HTML output without images.
-If a PPM file is given, the program will crop image_region, separator_region,
graphic_regions, chart_region and table_region to output_dir/img/id.png
-
-*Result:
-
-To view the result run your internet browser on output_dir/output.xml (Does not work with
Chrome on local, use a LAMPP server to fix this ;-) ).
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/main.cc
b/scribo/sandbox/arthur/xml_to_html/main.cc
deleted file mode 100644
index 9ec705a..0000000
--- a/scribo/sandbox/arthur/xml_to_html/main.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <iostream>
-#include "xml_to_html.hh"
-
-int main(int argc, char **argv)
-{
-
- std::string man;
- man = "xml_to_html: ...usage\n -m, --merge: Merge an XML with an other XML\n
\targs: <xml_file_1> <xml_file_2> [xml_output]\n\n -c, --create-html: Crop
images (if exist) from the ppm file using the XML file and produce an html output.\n
\targs: <xml_file> [ppm_file] [output dir]\n";
-
- if (argc > 2)
- {
- new QApplication::QApplication(argc, argv, false);
- ImageCrop crop;
-
- std::string merge = "--merge";
- std::string m = "-m";
- std::string scrop = "--create-html";
- std::string c = "-c";
-
- if (argc == 3 && (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0))
- {
- bool b = false;
- b = crop.load_xml(argv[2], QString::Null());
-
- if (b)
- crop.find_image_regions();
- }
- else if (argc > 3)
- {
- if (merge.compare(argv[1]) == 0 || m.compare(argv[1]) == 0)
- {
- if (argc > 4)
- crop.merge(argv[2], argv[3], argv[4]);
- else
- crop.merge(argv[2], argv[3]);
- }
- else if (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0)
- {
- bool b = false;
- if (argc > 4)
- b = crop.load_xml(argv[2], argv[3], argv[4]);
- else
- b = crop.load_xml(argv[2], argv[3]);
-
- if (b)
- crop.find_image_regions();
- }
- else
- std::cout << man;
- }
- else
- std::cout << man;
- }
- else
- std::cout << man;
-
- return 0;
-}
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/css.css
b/scribo/sandbox/arthur/xml_to_html/patterns/css.css
deleted file mode 100644
index 7171754..0000000
--- a/scribo/sandbox/arthur/xml_to_html/patterns/css.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.line
-{
- position:absolute;
- background-color:white;
- z-index:7;
- display:inline;
- white-space:pre;
- letter-spacing:-2px;
- padding:0px;
- margin:0px;
- filter:alpha(opacity=100);
- font-family:"Times New Roman", Times, serif;
-}
-.para
-{
- position:absolute;
- z-index:6;
-}
-.region
-{
- position:absolute;
- z-index:5;
-}
-.image
-{
- position:absolute;
- border:0;
-}
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
b/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
deleted file mode 100644
index aa5a078..0000000
--- a/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
+++ /dev/null
@@ -1,229 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:template match="/"> <!-- "/" means the whole document
(root) -->
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
- <title>Fooooooo !</title>
- <link rel="stylesheet" type="text/css" href="css.css"
/>
- </head>
- <body>
-
- <div class="image" style="top:0px;left:0px;">
- <img src="../../ppm/mp00076.png" />
- </div>
-
- <!-- BEGIN IMAGE REGION -->
- <xsl:for-each select="pcGts/page/graphic_region|
- pcGts/page/image_region|
- pcGts/page/chart_region|
- pcGts/page/table_region|
- pcGts/page/separator_region|
- pcGts/page/text_region|
- pcGts/page/text_region/paragraph|
- pcGts/page/text_region/paragraph/line">
-
- <!-- y1 -->
- <xsl:variable name="y1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="ascending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x2 -->
- <xsl:variable name="x2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="descending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- y2 -->
- <xsl:variable name="y2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="descending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x1 -->
- <xsl:variable name="x1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="ascending"
data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- TEXT LINE-->
- <xsl:if test="name() = 'line'">
-
- <xsl:variable name="x_height">
- <xsl:value-of select="../../@x_height" />
- </xsl:variable>
-
- <xsl:variable name="a_height">
- <xsl:value-of select="../../@a_height" />
- </xsl:variable>
-
- <xsl:variable name="colour">
- <xsl:choose>
- <xsl:when test="../../@txt_colour != ''">
- <xsl:value-of select="../../@txt_colour" />
- </xsl:when>
- <xsl:otherwise>
- Black
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d_height_tmp">
- <xsl:value-of select="../../@d_height" />
- </xsl:variable>
-
- <xsl:variable name="d_height">
- <xsl:choose>
- <xsl:when test="$d_height_tmp < 0">
- <xsl:value-of select="-$d_height_tmp" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height_tmp" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="a">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) < $d_height">
- <xsl:value-of select="$x_height + $d_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$a_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) > $d_height">
- <xsl:value-of select="-($a_height - $x_height)" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d_f">
- <xsl:choose>
- <xsl:when test="$d < 0">
- <xsl:value-of select="-$d" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="line"
onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
- onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
- <xsl:attribute name="style">
- opacity:1;
- height:auto;
- font-size:<xsl:value-of select="$a+$d_f" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1 " />px;
- top:<xsl:value-of select="$y1 " />px;
- color:<xsl:value-of select="$colour" />;
- </xsl:attribute>
- <xsl:value-of select="@text"/>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT LINE -->
-
- <!-- TEXT REGION -->
- <xsl:if test="name() = 'text_region'">
- <div class="region">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT REGION -->
-
- <!-- PARAGRAPH -->
- <xsl:if test="name() = 'paragraph'">
- <div class="para">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF PARAGRAPH -->
-
- <!-- NON-TEXT REGIONS -->
- <xsl:if test="name() = 'image_region' or name() =
'separator_region' or name() = 'graphic_region' or name() =
'chart_region' or name() = 'table_region'">
-
- <!-- id -->
- <xsl:variable name="id">
- <xsl:value-of select="@id" />
- </xsl:variable>
-
- <!-- depth -->
- <xsl:variable name="depth">
- <xsl:choose>
- <xsl:when test="name() = 'separator_region'">
- 1
- </xsl:when>
- <xsl:otherwise>
- 4
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="image">
- <xsl:attribute name="style">
- top:<xsl:value-of select="$y1" />px;
- left:<xsl:value-of select="$x1" />px;
- width:<xsl:value-of select="$x2 - $x1"/>px;
- height:<xsl:value-of select="$y2 - $y1"/>px;
- z-index:<xsl:value-of select="$depth"/>;
- </xsl:attribute>
- <img>
- <xsl:attribute name="alt">
- <xsl:value-of select="name()" />
- </xsl:attribute>
- <xsl:attribute name="width">
- <xsl:value-of select="$x2 - $x1" />
- </xsl:attribute>
- <xsl:attribute name="height">
- <xsl:value-of select="$y2 - $y1" />
- </xsl:attribute>
- <xsl:attribute name="src">
- img/<xsl:value-of select="$id"/>.png</xsl:attribute>
- </img>
- </div>
-
- </xsl:if>
- <!-- END NON-TEXT REGIONS -->
- </xsl:for-each>
- </body>
- </html>
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
b/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
deleted file mode 100644
index 8267466..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
+++ /dev/null
@@ -1,292 +0,0 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-# include "xml_to_html.hh"
-# include "dommodel.hh"
-# include <limits.h>
-
-#include <scribo/preprocessing/crop.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/core/alias/box2d.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/io/magick/save.hh>
-#include <mln/io/ppm/all.hh>
-
-ImageCrop::ImageCrop():
- regions_(false)
-{
-}
-
-ImageCrop::~ImageCrop()
-{
-}
-
-void ImageCrop::merge(QString in, QString other, QString output)
-{
- if (in.endsWith(".xml") && other.endsWith(".xml")
&& output.endsWith(".xml"))
- {
- QFile f_in(in);
- QFile f_other(other);
- QFile f_output(output);
-
- qDebug() << "Merging to " << output <<
"...";
-
- f_in.open(QIODevice::ReadOnly);
- f_other.open(QIODevice::ReadOnly);
- f_output.open(QIODevice::ReadWrite);
-
- QTextStream stream_in(&f_in);
- QTextStream stream_other(&f_other);
- QTextStream output_stream(&f_output);
-
- QString line = stream_in.readLine();
- output_stream << line;
- line = stream_in.readLine();
-
- while (!line.contains("</page>"))
- {
- output_stream << "\n" << line;
- line = stream_in.readLine();
- }
-
- line = stream_other.readLine();
-
- while (!line.contains("<page"))
- line = stream_other.readLine();
-
- line = stream_other.readLine();
-
- while (!line.contains("</pcGts>"))
- {
- output_stream << "\n" << line;
- line = stream_other.readLine();
- }
-
- output_stream << "\n" << line;
-
- f_in.close();
- f_other.close();
- f_output.close();
- }
- else
- std::cout << "merge : error, only xml files are needed." <<
std::endl;
-}
-
-bool ImageCrop::load_xml(QString xml_file, QString image_file, QString path)
-{
- if (xml_file.endsWith(".xml") &&
(image_file.endsWith(".ppm") || image_file == QString::Null()) )
- {
- image_file_ = image_file;
- regions_ = (image_file != QString::Null());
-
- path_ = path;
- if (!path_.endsWith("/"))
- path_.append("/");
-
- QDir dir(path_);
-
- if (!dir.mkpath("img"))
- {
- path_ = "output/";
- dir.mkpath(path_);
- dir.setPath(path_);
- dir.mkpath("img");
- }
-
- if (QFile::exists(xml_file))
- {
- QFile file(xml_file);
- QFile output(path_ + "output.xml");
- QFile xsl("patterns/xsl.xsl");
- QFile css("patterns/css.css");
- xsl.copy(path_ + "xsl.xsl");
- css.copy(path_ + "css.css");
-
- if (QFile::exists(path_ + "output.xml"))
- output.remove();
-
- output.open(QIODevice::ReadWrite);
- file.open(QIODevice::ReadOnly);
-
- QTextStream stream_in(&file);
- QTextStream stream_out(&output);
- stream_in.setCodec("UTF-8");
- stream_out.setCodec("UTF-8");
-
- QString line = stream_in.readLine();
- stream_out << line;
- stream_out << "\n<?xml-stylesheet type=\"text/xsl\"
href=\"xsl.xsl\" ?>";
-
- // /!\ attributes of ICDAR PcGts removed.
- line = stream_in.readLine();
- stream_out << "\n<pcGts>";
-
- line = stream_in.readLine();
-
- while (!line.contains("</pcGts>"))
- {
- stream_out << "\n" << line;
- line = stream_in.readLine();
- }
-
- stream_out << "\n" << line;
-
- output.close();
- file.close();
-
- qDebug() << "Output saved to " + path_;
-
- if (file.open(QIODevice::ReadOnly))
- {
- QDomDocument document;
- if (document.setContent(&file))
- {
- layout_ = new DomModel(document, this);
- }
- else
- qDebug() << "Error while loading the XML file, please choose
another.";
-
- file.close();
- }
- }
- return true;
- }
- else
- {
- std::cout << "Wrong files format !" << std::endl;
- return false;
- }
-}
-
-void ImageCrop::find_image_regions()
-{
- if (layout_ && regions_)
- {
- QModelIndex pgGts = layout_->index(1, 0);
- QModelIndex page = layout_->index(1, 0, pgGts);
- QModelIndex region;
- QModelIndex attributes;
- QModelIndex coords;
- QModelIndex point;
- bool regions_found = false;
- for (int i = 0; true; ++i)
- {
- region = layout_->index(i, 0, page);
- attributes = layout_->index(i, 1, page);
- QString name = layout_->data(region, Qt::DisplayRole).toString();
- coords = layout_->index(0, 0, region);
-
- bool is_image_region = name == QString("image_region")
- || name == QString("graphic_region")
- || name == QString("separator_region")
- || name == QString("chart_region")
- || name == QString("table_region") ;
-
- if (!region.isValid() || !coords.isValid())
- break;
-
- if (is_image_region)
- {
-
- regions_found = true;
- QMap<QString, QVariant> data =
- layout_->data(attributes, Qt::UserRole).toMap();
-
- QString id;
- QMap<QString, QVariant>::iterator it = data.find("id");
-
- if (it == data.end() || it.key() != "id")
- qDebug() << "No image region.";
-
- while (it != data.end() && it.key() == "id")
- {
- qDebug() << name;
- id = it.value().toString();
- qDebug() << it.key() + " = " + it.value().toString();
- ++it;
- }
-
- int x_max = 0;
- int y_max = 0;
- int x_min = INT_MAX;
- int y_min = INT_MAX;
-
- // QVector<QMap<QString, QVariant> > vect;
- for (int j = 0; true; ++j)
- {
- // Navigate to the coordinate list
- point = layout_->index(j, 1, coords);
- if (!point.isValid())
- break;
-
- QMap<QString, QVariant> data =
- layout_->data(point, Qt::UserRole).toMap();
- int x = data["x"].toInt();
- int y = data["y"].toInt();
-
- // vect << data;
-
- if (x < x_min)
- x_min = x;
- if (x > x_max)
- x_max = x;
-
- if (y < y_min)
- y_min = y;
- if (y > y_max)
- y_max = y;
-
- }
-
- using namespace mln;
-
- box2d box = make::box2d(y_min, x_min, y_max, x_max);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, image_file_.toStdString());
- ima = scribo::preprocessing::crop(ima, box);
-
- // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
- // data::fill(mask, true);
-
- /*for (int a = 1; a < vect.size(); ++a)
- {
- int x = vect[a]["x"].toInt();
- int y = vect[a]["y"].toInt();
-
- data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
- }*/
-
-
- // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
- io::magick::save(ima, path_.toStdString() + "img/" + id.toStdString() +
".png");
-
- }
- }
-
- if (!regions_found)
- qDebug() << "No regions found.";
- }
-}
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
b/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
deleted file mode 100644
index 27a271e..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef IMAGE_CROP_HH
-# define IMAGE_CROP_HH
-
-# include <QtGui>
-
-class DomModel;
-
-class ImageCrop : public QObject
-{
- Q_OBJECT
- public:
- ImageCrop();
- ~ImageCrop();
- void merge(QString in, QString other, QString output = "output.xml");
- bool load_xml(QString xml_file, QString image_file = "", QString path =
"output");
- void find_image_regions();
- private:
- DomModel* layout_;
- QString image_file_;
- QString path_;
- bool regions_;
-};
-
-#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
b/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
deleted file mode 100644
index b43b527..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-######################################################################
-# Automatically generated by qmake (2.01a) lun. juil. 5 16:53:31 2010
-######################################################################
-
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
-QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/olena/milena
-I/amd/beyrouth/home/lrde/stage/crepin/olena/
-QT += xml
-LIBS += `Magick++-config --libs`
-
-
-# Input
-HEADERS += domitem.hh dommodel.hh xml_to_html.hh
-SOURCES += domitem.cc dommodel.cc main.cc xml_to_html.cc
diff --git a/scribo/sandbox/arthur/xml_transform/README
b/scribo/sandbox/arthur/xml_transform/README
new file mode 100644
index 0000000..e0bfbc8
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/README
@@ -0,0 +1,19 @@
+xml_transform <option> <xml_file> <ppm_file> <output_dir>
+
+Transforms an ICDAR XML file to different kind of output.
+
+OPTIONS:
+
+ --html: Produce a HTML output
+
+Once process is finished, open output.xml with your internet browser. If this one
supports XSLT, there is no problem to display the result but if it does not support it
(like Konqueror or Chrome in local), you should run `sh html_generator.sh` (xsltproc
package required) to generate a HTML file readable by all browsers.
+
+ --pdf: Produce a PDF output, regions will be cropped as follows in the XML file.
+ --pdf-no-crop: Produce a PDF output without cropping regions, the entire picture
will be displayed.
+
+PDF is not directly created once the process is finished, to produce it, go to the
output_dir and run `sh pdf_generator.sh` (fop >= 0.95 required).
+
+
+BUILD:
+
+Chnage the environment variable QMAKE_CXXFLAGS to indicate the correct paths to milena
and olena then, just type qmake and make.
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/domitem.cc
b/scribo/sandbox/arthur/xml_transform/domitem.cc
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/domitem.cc
rename to scribo/sandbox/arthur/xml_transform/domitem.cc
diff --git a/scribo/sandbox/arthur/xml_to_html/domitem.hh
b/scribo/sandbox/arthur/xml_transform/domitem.hh
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/domitem.hh
rename to scribo/sandbox/arthur/xml_transform/domitem.hh
diff --git a/scribo/sandbox/arthur/xml_to_html/dommodel.cc
b/scribo/sandbox/arthur/xml_transform/dommodel.cc
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/dommodel.cc
rename to scribo/sandbox/arthur/xml_transform/dommodel.cc
diff --git a/scribo/sandbox/arthur/xml_to_html/dommodel.hh
b/scribo/sandbox/arthur/xml_transform/dommodel.hh
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/dommodel.hh
rename to scribo/sandbox/arthur/xml_transform/dommodel.hh
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.cc
b/scribo/sandbox/arthur/xml_transform/image_crop.cc
new file mode 100644
index 0000000..aa17c31
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.cc
@@ -0,0 +1,184 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "image_crop.hh"
+# include "loader.hh"
+# include "dommodel.hh"
+
+# include <limits.h>
+
+#include <scribo/preprocessing/crop.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/save.hh>
+#include <mln/io/ppm/all.hh>
+
+ImageCrop::ImageCrop()
+{
+}
+
+ImageCrop::~ImageCrop()
+{
+}
+
+void ImageCrop::save_image(QString image, QString output)
+{
+ using namespace mln;
+
+ image2d<value::rgb8> ima;
+ io::ppm::load(ima, image.toStdString());
+
+ io::magick::save(ima, output.toStdString() + "img/image.png");
+}
+
+void ImageCrop::crop_regions(QString xml_file, QString image_file, QString output)
+{
+ Loader loader;
+
+ QFile f(image_file);
+
+ if (!f.exists())
+ {
+ qDebug() << "Image doesn't exist !";
+ abort();
+ }
+ DomModel* layout = loader.xml_to_dom(xml_file);
+ if (layout)
+ {
+ QModelIndex pcGts = layout->index(1, 0);
+ QModelIndex page = layout->index(1, 0, pcGts);
+ QModelIndex region;
+ QModelIndex attributes;
+ QModelIndex coords;
+ QModelIndex point;
+ bool regions_found = false;
+
+ for (int i = 0; true; ++i)
+ {
+ region = layout->index(i, 0, page);
+ attributes = layout->index(i, 1, page);
+
+ QString name = layout->data(region, Qt::DisplayRole).toString();
+ coords = layout->index(0, 0, region);
+
+ bool is_region =
+ name == QString("image_region")
+ || name == QString("graphic_region")
+ || name == QString("separator_region")
+ || name == QString("chart_region")
+ || name == QString("table_region") ;
+
+ if (!region.isValid() || !coords.isValid())
+ break;
+
+ if (is_region)
+ {
+ regions_found = true;
+ QMap<QString, QVariant> data =
+ layout->data(attributes, Qt::UserRole).toMap();
+
+ QString id;
+ QMap<QString, QVariant>::iterator it = data.find("id");
+
+ if (it == data.end() || it.key() != "id")
+ qDebug() << "WTF_Error : No image region.";
+
+ while (it != data.end() && it.key() == "id")
+ {
+ qDebug() << name;
+ id = it.value().toString();
+ qDebug() << it.key() + " = " + it.value().toString();
+ ++it;
+ }
+
+ int x_max = 0;
+ int y_max = 0;
+ int x_min = INT_MAX;
+ int y_min = INT_MAX;
+
+ // QVector<QMap<QString, QVariant> > vect;
+ for (int j = 0; true; ++j)
+ {
+ // Navigate to the coordinate list
+ point = layout->index(j, 1, coords);
+ if (!point.isValid())
+ break;
+
+ QMap<QString, QVariant> data =
+ layout->data(point, Qt::UserRole).toMap();
+ int x = data["x"].toInt();
+ int y = data["y"].toInt();
+
+ // vect << data;
+
+ if (x < x_min)
+ x_min = x;
+ if (x > x_max)
+ x_max = x;
+
+ if (y < y_min)
+ y_min = y;
+ if (y > y_max)
+ y_max = y;
+
+ }
+
+ using namespace mln;
+
+ box2d box = make::box2d(y_min, x_min, y_max, x_max);
+
+ image2d<value::rgb8> ima;
+ io::ppm::load(ima, image_file.toStdString());
+ ima = scribo::preprocessing::crop(ima, box);
+
+ // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
+ // data::fill(mask, true);
+
+ /*for (int a = 1; a < vect.size(); ++a)
+ {
+ int x = vect[a]["x"].toInt();
+ int y = vect[a]["y"].toInt();
+
+ data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
+ }*/
+
+ // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
+ io::magick::save(ima, output.toStdString() + "img/" + id.toStdString() +
".png");
+
+ }
+ }
+
+ if (!regions_found)
+ qDebug() << "No regions found.";
+
+ }
+ else
+ {
+ qDebug() << "Error with XML file.";
+ }
+
+
+}
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.hh
b/scribo/sandbox/arthur/xml_transform/image_crop.hh
new file mode 100644
index 0000000..e4b0a38
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.hh
@@ -0,0 +1,46 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef IMAGE_CROP_HH
+# define IMAGE_CROP_HH
+
+# include <QtGui>
+
+class DomModel;
+
+class ImageCrop : public QObject
+{
+ Q_OBJECT
+ public:
+
+ ImageCrop();
+ ~ImageCrop();
+
+ void save_image(QString image, QString output);
+ void crop_regions(QString xml_file, QString image_file, QString output);
+
+};
+
+#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/loader.cc
b/scribo/sandbox/arthur/xml_transform/loader.cc
new file mode 100644
index 0000000..5623928
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/loader.cc
@@ -0,0 +1,162 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "loader.hh"
+# include "dommodel.hh"
+# include "xml_transform.hh"
+
+Loader::Loader()
+{
+}
+
+Loader::~Loader()
+{
+}
+
+DomModel* Loader::xml_to_dom(QString output)
+{
+ QString file_path = output;
+
+ QFile file(file_path);
+
+ if (file.open(QIODevice::ReadOnly))
+ {
+ QDomDocument document;
+ if (document.setContent(&file))
+ {
+ return new DomModel(document);
+ }
+ }
+
+ return 0;
+}
+
+bool Loader::set_output(QString& output)
+{
+ QDir dir(output);
+
+ if (!output.endsWith("/"))
+ output.append("/");
+
+ if (!dir.exists())
+ {
+ return dir.mkpath(".");
+ }
+ else
+ {
+ QStringList list = dir.entryList(QDir::Writable | QDir::AllDirs);
+ return list.size() != 0;
+ }
+}
+
+
+void Loader::add_html_templates(QString output)
+{
+
+ QFile gen("templates/html/html_generator.sh");
+ gen.copy(output + "html_generator.sh");
+
+ QFile css("templates/html/css.css");
+ css.copy(output + "css.css");
+
+ QFile xsl("templates/html/xsl.xsl");
+ xsl.copy(output + "xsl.xsl");
+
+}
+
+void Loader::add_pdf_templates(bool crop, QString output)
+{
+
+ QFile regions("templates/pdf/regions.xsl");
+ regions.copy(output + "regions.xsl");
+
+ QFile gen("templates/pdf/pdf_generator.sh");
+ gen.copy(output + "pdf_generator.sh");
+
+ QFile line("templates/pdf/line.xsl");
+ line.copy(output + "line.xsl");
+ if (crop)
+ {
+ QFile xsl("templates/pdf/main_crop.xsl");
+ xsl.copy(output + "main.xsl");
+ }
+ else
+ {
+ QFile xsl("templates/pdf/main.xsl");
+ xsl.copy(output + "main.xsl");
+ }
+}
+
+bool Loader::load_xml(QString xml_file, bool html, QString output)
+{
+ QFile file(xml_file);
+
+ if (file.exists())
+ {
+ file.open(QIODevice::ReadOnly);
+ set_output(output);
+
+ QFile out_file(output + "output.xml");
+ out_file.open(QIODevice::ReadWrite);
+
+ QTextStream stream_in(&file);
+ QTextStream stream_out(&out_file);
+
+ QString line = stream_in.readLine();
+
+ while(!line.contains("<?xml"))
+ line = stream_in.readLine();
+
+ stream_out << line;
+
+ if (html)
+ stream_out << "\n<?xml-stylesheet type=\"text/xsl\"
href=\"xsl.xsl\" ?>";
+
+ // /!\ attributes of ICDAR PcGts removed.
+ while(!line.contains("<pcGts"))
+ line = stream_in.readLine();
+
+ line = stream_in.readLine();
+ stream_out << "\n<pcGts>";
+
+ while (!line.contains("</pcGts>"))
+ {
+ stream_out << "\n" << line;
+ line = stream_in.readLine();
+ }
+
+ stream_out << "\n" << line;
+
+ file.close();
+ out_file.close();
+
+ return true;
+ }
+ else
+ {
+ qDebug() << xml_file + " doesn't exist";
+ return false;
+ }
+}
diff --git a/scribo/sandbox/arthur/xml_transform/loader.hh
b/scribo/sandbox/arthur/xml_transform/loader.hh
new file mode 100644
index 0000000..7d24254
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/loader.hh
@@ -0,0 +1,49 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef LOADER_HH
+# define LOADER_HH
+
+//# include <QtGui>
+# include "xml_transform.hh"
+
+class DomModel;
+
+class Loader
+{
+ public:
+
+ Loader();
+ ~Loader();
+
+ // void merge(QString in, QString other, QString output = "output.xml");
+ bool load_xml(QString xml_file, bool html, QString output);
+ DomModel* xml_to_dom(QString output);
+ bool set_output(QString& output);
+ void add_pdf_templates(bool crop, QString output);
+ void add_html_templates(QString output);
+};
+
+#endif /* !LOADER_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/main.cc
b/scribo/sandbox/arthur/xml_transform/main.cc
new file mode 100644
index 0000000..9e18cff
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/main.cc
@@ -0,0 +1,30 @@
+#include <iostream>
+#include "xml_transform.hh"
+
+int main(int argc, char **argv)
+{
+
+ std::string man = "xml_transform <option> <xml_file> <ppm_file>
<output_dir>\nOPTIONS:\n\t--html: Produce a HTML output\n\t--pdf: Produce a PDF
output, regions will be croped as follows in the XML file.\n\t--pdf-no-crop: Produce a PDF
output without croping regions, the entire picture will be displayed.";
+
+ if (argc > 4)
+ {
+ std::string html = "--html";
+ std::string pdf = "--pdf";
+ std::string pdf_no_crop = "--pdf-no-crop";
+
+ XmlTransform xmlt(argv[4], argv[2]);
+
+ if (html.compare(argv[1]) == 0)
+ xmlt.createHTML(argv[3]);
+ else if (pdf.compare(argv[1]) == 0)
+ xmlt.createPDF(argv[3], true);
+ else if (pdf_no_crop.compare(argv[1]) == 0)
+ xmlt.createPDF(argv[3], false);
+ else
+ std::cout << man << std::endl;
+ }
+ else
+ std::cout << man << std::endl;
+
+ return 0;
+}
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/css.css
b/scribo/sandbox/arthur/xml_transform/templates/html/css.css
new file mode 100644
index 0000000..0443390
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/css.css
@@ -0,0 +1,31 @@
+.line
+{
+ position:absolute;
+ background-color:white;
+ z-index:7;
+ display:inline;
+ white-space:pre;
+
+ /* FIXME */
+ letter-spacing:-2px;
+
+ padding:0px;
+ margin:0px;
+ filter:alpha(opacity=100);
+ font-family:"Times New Roman", Times, serif;
+}
+.para
+{
+ position:absolute;
+ z-index:6;
+}
+.region
+{
+ position:absolute;
+ z-index:5;
+}
+.image
+{
+ position:absolute;
+ border:0;
+}
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
b/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
new file mode 100644
index 0000000..bb24305
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+xsltproc xsl.xsl output.xml > output.html
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
new file mode 100644
index 0000000..3d6a1c5
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
@@ -0,0 +1,224 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/"> <!-- "/" means the whole document
(root) -->
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
+ <title>SCRIBO</title>
+ <link rel="stylesheet" type="text/css" href="css.css"
/>
+ </head>
+ <body>
+
+ <xsl:for-each select="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region|
+ pcGts/page/text_region|
+ pcGts/page/text_region/paragraph|
+ pcGts/page/text_region/paragraph/line">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <!-- TEXT LINE-->
+ <xsl:if test="name() = 'line'">
+
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="../../@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="../../@d_height < 0">
+ <xsl:value-of select="-../../@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="../../@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="line"
onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
+ onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
+ <xsl:attribute name="style">
+ opacity:1;
+ height:auto;
+ font-size:<xsl:value-of select="$a+$d" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT LINE -->
+
+ <!-- TEXT REGION -->
+ <xsl:if test="name() = 'text_region'">
+ <div class="region">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT REGION -->
+
+ <!-- PARAGRAPH -->
+ <xsl:if test="name() = 'paragraph'">
+ <div class="para">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF PARAGRAPH -->
+
+ <!-- NON-TEXT REGIONS -->
+ <xsl:if test="name() = 'image_region' or name() =
'separator_region' or name() = 'graphic_region' or name() =
'chart_region' or name() = 'table_region'">
+
+ <!-- id -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- depth -->
+ <xsl:variable name="depth">
+ <xsl:choose>
+ <xsl:when test="name() = 'separator_region'">
+ 1
+ </xsl:when>
+ <xsl:otherwise>
+ 4
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="image">
+ <xsl:attribute name="style">
+ top:<xsl:value-of select="$y1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ width:<xsl:value-of select="$x2 - $x1"/>px;
+ height:<xsl:value-of select="$y2 - $y1"/>px;
+ z-index:<xsl:value-of select="$depth"/>;
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="alt">
+ <xsl:value-of select="name()" />
+ </xsl:attribute>
+ <xsl:attribute name="width">
+ <xsl:value-of select="$x2 - $x1" />
+ </xsl:attribute>
+ <xsl:attribute name="height">
+ <xsl:value-of select="$y2 - $y1" />
+ </xsl:attribute>
+ <xsl:attribute name="src">
+ img/<xsl:value-of select="$id"/>.png</xsl:attribute>
+ </img>
+ </div>
+
+ </xsl:if>
+ <!-- END NON-TEXT REGIONS -->
+ </xsl:for-each>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
b/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
new file mode 100644
index 0000000..b143502
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
@@ -0,0 +1,129 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: line.xsl
+ DESCRIPTION: match all pcGts/page/text_region/paragraph/line in order to display
the "text" attributes
+ -->
+
+ <xsl:template match="pcGts/page/text_region/paragraph/line">
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="../../@d_height < 0">
+ <xsl:value-of select="-../../@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="../../@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- Text lines coordinates -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <!-- END OF lines coordinates -->
+
+ <!-- WTF !?, Necessary to do a lower-case ! -->
+ <xsl:variable name="smallcase"
select="'abcdefghijklmnopqrstuvwxyz'" />
+ <xsl:variable name="uppercase"
select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
+
+ <!-- Text Colour -->
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="translate(../../@txt_colour, $smallcase,
$uppercase)" />
+ </xsl:when>
+ <xsl:otherwise>
+ black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+
+ <fo:block-container position="absolute">
+
+ <xsl:attribute name="left">
+ <xsl:value-of select="$x1" />px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ <xsl:value-of select="$y1" />px
+ </xsl:attribute>
+
+ <xsl:attribute name="color">
+ <xsl:value-of select="$colour" />
+ </xsl:attribute>
+
+ <!-- if necessary, put letter-spacing="-Npt" ~ -3 <= N <= -1
+ in fo:block-->
+
+ <fo:block font-family="Times">
+
+ <xsl:attribute name="font-size">
+ <xsl:value-of select="$a + $d" />px
+ </xsl:attribute>
+
+ <xsl:value-of select="@text"/>
+ </fo:block>
+
+ </fo:block-container>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
b/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
new file mode 100644
index 0000000..065831e
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: main.xsl
+ DESCRIPTION: produce pdf output -->
+
+ <xsl:import href="line.xsl"/>
+
+ <xsl:template match="/">
+ <fo:root>
+
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page" margin-left="0cm"
margin-right="0cm" margin-bottom="0cm" margin-top="0cm">
+
+ <!-- Output will be sized with image size -->
+ <xsl:attribute name="page-width">
+ <xsl:value-of select="pcGts/page/@image_width" />px
+ </xsl:attribute>
+ <xsl:attribute name="page-height">
+ <xsl:value-of select="pcGts/page/@image_height" />px
+ </xsl:attribute>
+
+ <fo:region-body
+ margin-top="0mm" margin-bottom="0mm"
+ margin-left="0mm" margin-right="0mm"/>
+ <fo:region-after extent="0mm"/>
+
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="page">
+
+ <fo:flow flow-name="xsl-region-body">
+
+ <xsl:apply-imports />
+
+ <fo:block-container position="absolute" z-index="-3">
+
+ <xsl:attribute name="left">
+ 0px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ 0px
+ </xsl:attribute>
+
+ <fo:block>
+ <fo:external-graphic>
+ <xsl:attribute name="src">
+ url('img/image.png')
+ </xsl:attribute>
+ </fo:external-graphic>
+ </fo:block>
+
+ </fo:block-container>
+
+ </fo:flow>
+
+ </fo:page-sequence>
+ </fo:root>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
b/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
new file mode 100644
index 0000000..0dbb673
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: main.xsl
+ DESCRIPTION: produce pdf output -->
+
+ <xsl:import href="regions.xsl"/>
+ <xsl:import href="line.xsl"/>
+
+ <xsl:template match="/">
+ <fo:root>
+
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page" margin-left="0cm"
margin-right="0cm" margin-bottom="0cm" margin-top="0cm">
+
+ <!-- Output will be sized with image size -->
+ <xsl:attribute name="page-width">
+ <xsl:value-of select="pcGts/page/@image_width" />px
+ </xsl:attribute>
+ <xsl:attribute name="page-height">
+ <xsl:value-of select="pcGts/page/@image_height" />px
+ </xsl:attribute>
+
+ <fo:region-body
+ margin-top="0mm" margin-bottom="0mm"
+ margin-left="0mm" margin-right="0mm"/>
+ <fo:region-after extent="0mm"/>
+
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="page">
+
+ <fo:flow flow-name="xsl-region-body">
+ <xsl:apply-imports />
+ </fo:flow>
+
+ </fo:page-sequence>
+ </fo:root>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
b/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
new file mode 100644
index 0000000..c6339a5
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+fop -xsl main.xsl -xml output.xml -pdf output.pdf
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
new file mode 100644
index 0000000..65a8c79
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: regions.xsl
+ DESCRIPTION: Match all regions that are not text to display them -->
+
+ <xsl:template match="pcGts/page/image_region|
+ pcGts/page/graphic_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region">
+
+ <!-- ID of the region, used to display id.png -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- Regions coordinates -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending"
data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <!-- END OF regions coordinates -->
+
+ <fo:block-container position="absolute">
+
+ <xsl:attribute name="left">
+ <xsl:value-of select="$x1" />px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ <xsl:value-of select="$y1" />px
+ </xsl:attribute>
+
+ <fo:block>
+ <fo:external-graphic>
+ <xsl:attribute name="src">
+ url('img/<xsl:value-of select="$id" />.png')
+ </xsl:attribute>
+ </fo:external-graphic>
+ </fo:block>
+
+ </fo:block-container>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.cc
b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
new file mode 100644
index 0000000..dd35aff
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "image_crop.hh"
+# include "loader.hh"
+# include "xml_transform.hh"
+
+XmlTransform::XmlTransform(QString output, QString xml_file) :
+ output_dir_(output),
+ xml_file_(xml_file)
+{
+ Loader loader;
+ if (!loader.set_output(output_dir_))
+ abort();
+}
+
+XmlTransform::~XmlTransform()
+{
+}
+
+void XmlTransform::createPDF (QString img, bool crop)
+{
+ Loader loader;
+
+ QString output = output_dir_;
+ output.append("img");
+
+ if (loader.set_output(output))
+ {
+ if (loader.load_xml(xml_file_, false, output_dir_))
+ {
+
+ ImageCrop Crop;
+
+ if (crop)
+ Crop.crop_regions(xml_file_, img, output_dir_);
+ else
+ Crop.save_image(img, output_dir_);
+
+ loader.add_pdf_templates(crop, output_dir_);
+ }
+ else
+ abort();
+ }
+ else
+ abort();
+}
+
+void XmlTransform::createHTML(QString img)
+{
+ Loader loader;
+
+ QString output = output_dir_;
+ output.append("img");
+
+ if (loader.set_output(output))
+ {
+ if (loader.load_xml(xml_file_, true, output_dir_))
+ {
+ ImageCrop Crop;
+
+ Crop.crop_regions(xml_file_, img, output_dir_);
+ loader.add_html_templates(output_dir_);
+ }
+ else
+ abort();
+ }
+ else
+ abort();
+}
+
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.hh
b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
new file mode 100644
index 0000000..808c108
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
@@ -0,0 +1,48 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef XML_TRANFORM_HH
+# define XML_TRANFORM_HH
+
+# include <QtGui>
+
+class XmlTransform : public QObject
+{
+ Q_OBJECT
+ public:
+
+ XmlTransform(QString output, QString xml_file);
+ ~XmlTransform();
+
+ void createHTML(QString img);
+ void createPDF(QString img, bool crop);
+
+protected:
+ QString output_dir_;
+ QString xml_file_;
+};
+
+#endif // !XML_TRANFORM_HH
+
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.pro
b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
new file mode 100644
index 0000000..161a7f4
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
@@ -0,0 +1,20 @@
+######################################################################
+# Automatically generated by qmake (2.01a) jeu. juil. 8 16:33:27 2010
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/milena
-I/amd/beyrouth/home/lrde/stage/crepin/git/olena/
+QT += xml
+LIBS += `Magick++-config --libs`
+
+# Input
+HEADERS += domitem.hh dommodel.hh image_crop.hh loader.hh xml_transform.hh
+SOURCES += domitem.cc \
+ dommodel.cc \
+ image_crop.cc \
+ loader.cc \
+ main.cc \
+ xml_transform.cc
--
1.5.6.5