Example #1
0
 void fix_table_children(element el_ptr, style_display disp, string disp_str)
 {
     //          IList<element> tmp;
     //          var first_iter = el_ptr._children.begin();
     //          var cur_iter = el_ptr._children.begin();
     //          auto flush_elements = [&]()
     //  {
     //              element::ptr annon_tag = std::make_shared<html_tag>(shared_from_this());
     //              style st;
     //              st.add_property(_t("display"), disp_str, 0, false);
     //              annon_tag.add_style(st);
     //              annon_tag.parent(el_ptr);
     //              annon_tag.parse_styles();
     //              std::for_each(tmp.begin(), tmp.end(),
     //                  [&annon_tag](element::ptr & el)
     //          {
     //                  annon_tag.appendChild(el);
     //              }
     //);
     //              first_iter = el_ptr.m_children.insert(first_iter, annon_tag);
     //              cur_iter = first_iter + 1;
     //              while (cur_iter != el_ptr.m_children.end() && (*cur_iter).parent() != el_ptr)
     //              {
     //                  cur_iter = el_ptr.m_children.erase(cur_iter);
     //              }
     //              first_iter = cur_iter;
     //              tmp.clear();
     //          };
     //          while (cur_iter != el_ptr.m_children.end())
     //          {
     //              if ((*cur_iter).get_display() != disp)
     //              {
     //                  if (!(*cur_iter).is_white_space() || ((*cur_iter).is_white_space() && !tmp.empty()))
     //                  {
     //                      if (tmp.empty())
     //                      {
     //                          first_iter = cur_iter;
     //                      }
     //                      tmp.push_back((*cur_iter));
     //                  }
     //                  cur_iter++;
     //              }
     //              else if (!tmp.empty())
     //              {
     //                  flush_elements();
     //              }
     //              else
     //              {
     //                  cur_iter++;
     //              }
     //          }
     //          if (!tmp.empty())
     //          {
     //              flush_elements();
     //          }
 }
Example #2
0
 void fix_table_parent(element el_ptr, style_display disp, string disp_str)
 {
     //          element::ptr parent = el_ptr.parent();
     //          if (parent.get_display() != disp)
     //          {
     //              IList<element>::iterator this_element = std::find_if(parent.m_children.begin(), parent.m_children.end(),
     //                  [&](element::ptr & el)
     //          {
     //                  if (el == el_ptr)
     //                  {
     //                      return true;
     //                  }
     //                  return false;
     //              }
     //);
     //              if (this_element != parent.m_children.end())
     //              {
     //                  style_display el_disp = el_ptr.get_display();
     //                  IList<element>::iterator first = this_element;
     //                  IList<element>::iterator last = this_element;
     //                  IList<element>::iterator cur = this_element;
     //                  // find first element with same display
     //                  while (true)
     //                  {
     //                      if (cur == parent.m_children.begin()) break;
     //                      cur--;
     //                      if ((*cur).is_white_space() || (*cur).get_display() == el_disp)
     //                      {
     //                          first = cur;
     //                      }
     //                      else
     //                      {
     //                          break;
     //                      }
     //                  }
     //                  // find last element with same display
     //                  cur = this_element;
     //                  while (true)
     //                  {
     //                      cur++;
     //                      if (cur == parent.m_children.end()) break;
     //                      if ((*cur).is_white_space() || (*cur).get_display() == el_disp)
     //                      {
     //                          last = cur;
     //                      }
     //                      else
     //                      {
     //                          break;
     //                      }
     //                  }
     //                  // extract elements with the same display and wrap them with anonymous object
     //                  element::ptr annon_tag = std::make_shared<html_tag>(shared_from_this());
     //                  style st;
     //                  st.add_property(_t("display"), disp_str, 0, false);
     //                  annon_tag.add_style(st);
     //                  annon_tag.parent(parent);
     //                  annon_tag.parse_styles();
     //                  std::for_each(first, last + 1,
     //                      [&annon_tag](element::ptr & el)
     //              {
     //                      annon_tag.appendChild(el);
     //                  }
     //	);
     //                  first = parent.m_children.erase(first, last + 1);
     //                  parent.m_children.insert(first, annon_tag);
     //              }
     //          }
 }