* demo/viewer/viewer.cc,
* demo/viewer/xml_widget.cc: Update tag names.
* scribo/io/xml/internal/extended_page_xml_visitor.hh,
* scribo/io/xml/save.hh: Save component outlines.
---
scribo/ChangeLog | 10 ++++
scribo/demo/viewer/viewer.cc | 10 ++--
scribo/demo/viewer/xml_widget.cc | 2 +-
.../io/xml/internal/extended_page_xml_visitor.hh | 49 +++++++++++++-------
scribo/scribo/io/xml/save.hh | 2 +-
5 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 248e856..05512ce 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,15 @@
2011-06-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix XML output.
+
+ * demo/viewer/viewer.cc,
+ * demo/viewer/xml_widget.cc: Update tag names.
+
+ * scribo/io/xml/internal/extended_page_xml_visitor.hh,
+ * scribo/io/xml/save.hh: Save component outlines.
+
+2011-06-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix compilation issues.
* scribo/core/component_features_data.hh,
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 173cb3b..12270e1 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -368,7 +368,7 @@ Viewer::add_text(QDomNode line)
QDomNode coords = line.firstChild();
- while (!coords.isNull() &&
!coords.toElement().tagName().contains("coords"))
+ while (!coords.isNull() &&
!coords.toElement().tagName().contains("Coords"))
coords = coords.nextSibling();
if (coords.isNull())
@@ -416,7 +416,7 @@ Viewer::add_region(QDomNode father, QString attr_id)
QString name = father.toElement().tagName();
region::RegionId id = static_cast<region::RegionId>(region_ids_[name]);
- while (!coords.isNull() &&
!coords.toElement().tagName().contains("coords"))
+ while (!coords.isNull() &&
!coords.toElement().tagName().contains("Coords"))
coords = coords.nextSibling();
if (coords.isNull())
@@ -471,7 +471,7 @@ Viewer::add_typo_lines(QDomNode father, QString attr_id)
// Looking for bbox coordinates.
{
QDomNode coords = father.firstChild();
- while (!coords.isNull() &&
!coords.toElement().tagName().contains("coords"))
+ while (!coords.isNull() &&
!coords.toElement().tagName().contains("Coords"))
coords = coords.nextSibling();
if (coords.isNull())
@@ -581,7 +581,7 @@ Viewer::load_xml(QString filename)
QDomElement root = doc.documentElement();
QDomNode page = root.firstChild();
- while (!page.isNull() &&
!page.toElement().tagName().contains("page"))
+ while (!page.isNull() &&
!page.toElement().tagName().contains("Page"))
page = page.nextSibling();
if (page.isNull())
@@ -611,7 +611,7 @@ Viewer::load_xml(QString filename)
QDomNode coords = region.firstChild();
- while (!coords.isNull() &&
!coords.toElement().tagName().contains("coords"))
+ while (!coords.isNull() &&
!coords.toElement().tagName().contains("Coords"))
coords = coords.nextSibling();
if (!container.isNull() && !coords.isNull())
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
index 57d171f..642cf9a 100644
--- a/scribo/demo/viewer/xml_widget.cc
+++ b/scribo/demo/viewer/xml_widget.cc
@@ -86,7 +86,7 @@ void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item)
if (!node.isNull())
{
QString append;
- if (node.toElement().tagName().contains("point"))
+ if (node.toElement().tagName().contains("Point"))
{
QString x = node.toElement().attribute("x", "0");
QString y = node.toElement().attribute("y", "0");
diff --git a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
index d109827..da7a582 100644
--- a/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
+++ b/scribo/scribo/io/xml/internal/extended_page_xml_visitor.hh
@@ -52,8 +52,12 @@
# include <scribo/io/xml/internal/print_page_preambule.hh>
# include <scribo/io/xml/internal/compute_text_colour.hh>
+# include <scribo/text/paragraphs_closing.hh>
+
+# include <scribo/util/component_precise_outline.hh>
# include <scribo/util/color_to_hex.hh>
+
namespace scribo
{
@@ -67,31 +71,29 @@ namespace scribo
{
- class extended_page_xml_visitor : public
doc_serializer<extended_page_xml_visitor>
+ template <typename L>
+ class extended_page_xml_visitor
+ : public doc_serializer<extended_page_xml_visitor<L> >
{
public:
// Constructor
extended_page_xml_visitor(std::ofstream& out);
// Visit overloads
- template <typename L>
void visit(const document<L>& doc) const;
- template <typename L>
void visit(const component_set<L>& comp_set) const;
- template <typename L>
void visit(const component_info<L>& info) const;
- template <typename L>
void visit(const paragraph_set<L>& parset) const;
- template <typename L>
void visit(const line_info<L>& line) const;
private: // Attributes
std::ofstream& output;
mutable image2d<scribo::def::lbl_type> elt_edge;
+ mutable L lbl_;
};
@@ -99,8 +101,8 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- inline
- extended_page_xml_visitor::extended_page_xml_visitor(std::ofstream& out)
+ template <typename L>
+ extended_page_xml_visitor<L>::extended_page_xml_visitor(std::ofstream& out)
: output(out)
{
}
@@ -111,7 +113,7 @@ namespace scribo
//
template <typename L>
void
- extended_page_xml_visitor::visit(const document<L>& doc) const
+ extended_page_xml_visitor<L>::visit(const document<L>& doc) const
{
// Preambule
print_PAGE_preambule(output, doc, false);
@@ -150,8 +152,9 @@ namespace scribo
//
template <typename L>
void
- extended_page_xml_visitor::visit(const component_set<L>& comp_set) const
+ extended_page_xml_visitor<L>::visit(const component_set<L>& comp_set)
const
{
+ lbl_ = comp_set.labeled_image();
for_all_comps(c, comp_set)
if (comp_set(c).is_valid())
comp_set(c).accept(*this);
@@ -162,8 +165,14 @@ namespace scribo
//
template <typename L>
void
- extended_page_xml_visitor::visit(const component_info<L>& info) const
+ extended_page_xml_visitor<L>::visit(const component_info<L>& info)
const
{
+ // Getting component outline
+ scribo::def::lbl_type id = (scribo::def::lbl_type)info.id().to_equiv();
+ //const L& lbl = info.holder().labeled_image();
+ p_array<point2d>
+ par = scribo::util::component_precise_outline(lbl_ | info.bbox(), id);
+
switch (info.type())
{
case component::WhitespaceSeparator:
@@ -177,7 +186,7 @@ namespace scribo
<< " y_max=\"" << info.bbox().pmax().row() <<
"\""
<< ">" << std::endl;
- internal::print_box_coords(output, info.bbox(), " ");
+ internal::print_image_coords(output, par, " ");
output << " </whitespace_separator_region>" <<
std::endl;
break;
@@ -195,7 +204,7 @@ namespace scribo
<< " y_max=\"" << info.bbox().pmax().row() <<
"\""
<< ">" << std::endl;
- internal::print_box_coords(output, info.bbox(), " ");
+ internal::print_image_coords(output, par, " ");
output << " </vertical_separator_region>" <<
std::endl;
break;
@@ -213,7 +222,7 @@ namespace scribo
<< " y_max=\"" << info.bbox().pmax().row() <<
"\""
<< ">" << std::endl;
- internal::print_box_coords(output, info.bbox(), " ");
+ internal::print_image_coords(output, par, " ");
output << " </horizontal_separator_region>" <<
std::endl;
break;
@@ -250,13 +259,19 @@ namespace scribo
//
template <typename L>
void
- extended_page_xml_visitor::visit(const paragraph_set<L>& parset) const
+ extended_page_xml_visitor<L>::visit(const paragraph_set<L>& parset)
const
{
const line_set<L>& lines = parset.lines();
+ // Prepare paragraph outlines.
+ L par_clo = text::paragraphs_closing(parset);
+
for_all_paragraphs(p, parset)
if (parset(p).is_valid())
{
+ p_array<mln_site(L)> par = scribo::util::component_precise_outline(par_clo
+ | parset(p).bbox(), p);
+
const mln::util::array<line_id_t>& line_ids = parset(p).line_ids();
// FIXME: compute that information on the whole paragraph
@@ -286,7 +301,7 @@ namespace scribo
output << "\">"
<< std::endl;
- internal::print_box_coords(output, parset(p).bbox(), " ");
+ internal::print_image_coords(output, parset(p).bbox(), " ");
// EXTENSIONS - Not officially supported
for_all_paragraph_lines(lid, line_ids)
@@ -303,7 +318,7 @@ namespace scribo
template <typename L>
void
- extended_page_xml_visitor::visit(const line_info<L>& line) const
+ extended_page_xml_visitor<L>::visit(const line_info<L>& line) const
{
if (line.has_text())
{
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index cc6905b..cc02c03 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -103,7 +103,7 @@ namespace scribo
template <typename L>
void save_page_extended(const document<L>& doc, std::ofstream& output)
{
- scribo::io::xml::internal::extended_page_xml_visitor f(output);
+ scribo::io::xml::internal::extended_page_xml_visitor<L> f(output);
doc.accept(f);
}
--
1.5.6.5