restore serialization in text_properties and text/formattin/layout
This commit is contained in:
parent
ee58762bd9
commit
a9062fe112
2 changed files with 21 additions and 61 deletions
|
@ -35,25 +35,25 @@
|
|||
// boost
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
namespace formatting {
|
||||
namespace mapnik { namespace formatting {
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
|
||||
void layout_node::to_xml(ptree &xml) const
|
||||
{
|
||||
ptree &new_node = xml.push_back(ptree::value_type("Layout", ptree()))->second;
|
||||
ptree & new_node = xml.push_back(ptree::value_type("Layout", ptree()))->second;
|
||||
|
||||
if (dx) serialize_property("dx", *dx, new_node);
|
||||
if (dy) serialize_property("dy", *dy, new_node);
|
||||
if (text_ratio) serialize_property("text-ratio", *text_ratio, new_node);
|
||||
if (wrap_width) serialize_property("wrap-width", *wrap_width, new_node);
|
||||
if (wrap_before) serialize_property("wrap-before", *wrap_before, new_node);
|
||||
if (rotate_displacement) serialize_property("rotate-displacement", *rotate_displacement, new_node);
|
||||
if (orientation) serialize_property("orientation", *orientation, new_node);
|
||||
|
||||
//if (dx) set_attr(new_node, "dx", *dx);
|
||||
//if (dy) set_attr(new_node, "dy", *dy);
|
||||
if (halign) set_attr(new_node, "horizontal-alignment", *halign);
|
||||
if (valign) set_attr(new_node, "vertical-alignment", *valign);
|
||||
if (jalign) set_attr(new_node, "justify-alignment", *jalign);
|
||||
//if (text_ratio) set_attr(new_node, "text-ratio", *text_ratio);
|
||||
//if (wrap_width) set_attr(new_node, "wrap-width", *wrap_width);
|
||||
//if (wrap_before) set_attr(new_node, "wrap-before", *wrap_before);
|
||||
//if (rotate_displacement) set_attr(new_node, "rotate-displacement", *rotate_displacement);
|
||||
//if (orientation) set_attr(new_node, "orientation", to_expression_string(**orientation));
|
||||
|
||||
if (child_) child_->to_xml(new_node);
|
||||
}
|
||||
|
@ -73,16 +73,9 @@ node_ptr layout_node::from_xml(xml_node const& xml)
|
|||
if (xml.has_attribute("rotate-displacement")) set_property_from_xml<boolean>(n->rotate_displacement, "rotate-displacement", xml);
|
||||
if (xml.has_attribute("orientation")) set_property_from_xml<double>(n->orientation, "orientation", xml);
|
||||
|
||||
//n->dx = xml.get_opt_attr<double>("dx");
|
||||
//n->dy = xml.get_opt_attr<double>("dy");
|
||||
n->halign = xml.get_opt_attr<horizontal_alignment_e>("horizontal-alignment");
|
||||
n->valign = xml.get_opt_attr<vertical_alignment_e>("vertical-alignment");
|
||||
n->jalign = xml.get_opt_attr<justify_alignment_e>("justify-alignment");
|
||||
//n->text_ratio = xml.get_opt_attr<double>("text-ratio");
|
||||
//n->wrap_width = xml.get_opt_attr<double>("wrap-width");
|
||||
//n->wrap_before = xml.get_opt_attr<boolean>("wrap-before");
|
||||
//n->rotate_displacement = xml.get_opt_attr<boolean>("rotate-displacement");
|
||||
//n->orientation = xml.get_opt_attr<expression_ptr>("orientation");
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -217,50 +217,17 @@ void text_layout_properties::to_xml(boost::property_tree::ptree & node,
|
|||
bool explicit_defaults,
|
||||
text_layout_properties const& dfl) const
|
||||
{
|
||||
//if (displacement.x != dfl.displacement.x || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "dx", displacement.x);
|
||||
//}
|
||||
//if (displacement.y != dfl.displacement.y || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "dy", displacement.y);
|
||||
//}
|
||||
if (valign != dfl.valign || explicit_defaults)
|
||||
{
|
||||
set_attr(node, "vertical-alignment", valign);
|
||||
}
|
||||
if (halign != dfl.halign || explicit_defaults)
|
||||
{
|
||||
set_attr(node, "horizontal-alignment", halign);
|
||||
}
|
||||
if (jalign != dfl.jalign || explicit_defaults)
|
||||
{
|
||||
set_attr(node, "justify-alignment", jalign);
|
||||
}
|
||||
//if (text_ratio != dfl.text_ratio || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "text-ratio", text_ratio);
|
||||
//}
|
||||
//if (wrap_width != dfl.wrap_width || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "wrap-width", wrap_width);
|
||||
//}
|
||||
//if (wrap_before != dfl.wrap_before || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "wrap-before", wrap_before);
|
||||
//}
|
||||
//if (rotate_displacement != dfl.rotate_displacement || explicit_defaults)
|
||||
//{
|
||||
// set_attr(node, "rotate-displacement", rotate_displacement);
|
||||
//}
|
||||
/// TODO
|
||||
//if (orientation)
|
||||
//{
|
||||
// std::string const& orientationstr = to_expression_string(*orientation);
|
||||
// if (!dfl.orientation || orientationstr != to_expression_string(*(dfl.orientation)) || explicit_defaults) {
|
||||
// set_attr(node, "orientation", orientationstr);
|
||||
// }
|
||||
//}
|
||||
if (!(dx == dfl.dx) || explicit_defaults) serialize_property("dx", dx, node);
|
||||
if (!(dy == dfl.dy) || explicit_defaults) serialize_property("dy", dy, node);
|
||||
if (valign != dfl.valign || explicit_defaults) set_attr(node, "vertical-alignment", valign);
|
||||
if (halign != dfl.halign || explicit_defaults) set_attr(node, "horizontal-alignment", halign);
|
||||
if (jalign != dfl.jalign || explicit_defaults) set_attr(node, "justify-alignment", jalign);
|
||||
if (!(text_ratio == dfl.text_ratio) || explicit_defaults) serialize_property("text-ratio", text_ratio, node);
|
||||
if (!(wrap_width == dfl.wrap_width) || explicit_defaults) serialize_property("wrap-width", wrap_width, node);
|
||||
if (!(wrap_before == dfl.wrap_before) || explicit_defaults) serialize_property("wrap-before", wrap_before, node);
|
||||
if (!(rotate_displacement == dfl.rotate_displacement) || explicit_defaults)
|
||||
serialize_property("rotate-displacement", rotate_displacement, node);
|
||||
if (!(orientation == dfl.orientation) || explicit_defaults) serialize_property("orientation", orientation, node);
|
||||
}
|
||||
|
||||
void text_layout_properties::add_expressions(expression_set& output) const
|
||||
|
|
Loading…
Add table
Reference in a new issue