Ejemplo n.º 1
0
  void process_pde_text(PdeTextP text, ptree& node) {
    PdfTextState ts;

    switch (text->GetType())
    {
    case kPdeText:
    {
      node.put("type", "text_paragraph");
      std::wstring s;
      s.resize(text->GetText(nullptr, 0));
      text->GetText((wchar_t*)s.c_str(), s.size());
      node.put("text", w2utf8(s.c_str()));
      text->GetTextState(&ts);
      auto num_lines = text->GetNumTextLines();
      for (auto i = 0; i < num_lines; i++) {
        ptree line_node;
        PdeTextLineP text_line = text->GetTextLine(i);
        process_pde_element((PdeElementP)text_line, line_node);
        node.add_child("element", line_node);
      }
    }
    break;
    case kPdeTextLine:
    {
      PdeTextLineP text_line = (PdeTextLine*)text;
      node.put("type", "text_line");
      std::wstring s;
      s.resize(text_line->GetText(nullptr, 0));
      text_line->GetText((wchar_t*)s.c_str(), s.size());
      node.put("text", w2utf8(s.c_str()));
      text_line->GetTextState(&ts);
      auto num_word = text_line->GetNumWords();
      for (auto i = 0; i < num_word; i++) {
        ptree word_node;
        PdeWordP text_word = text_line->GetWord(i);
        process_pde_element((PdeElementP)text_word, word_node);
        node.add_child("element", word_node);
      }
    }
    break;
    case kPdeWord:
    {
      PdeWordP word = (PdeWord*)text;
      node.put("type", "text_word");
      std::wstring s;
      s.resize(word->GetText(nullptr, 0));
      word->GetText((wchar_t*)s.c_str(), s.size());
      node.put("text", w2utf8(s.c_str()));
      word->GetTextState(&ts);
    }
    break;
    }
    process_pdf_text_state(ts, node);
  }
Ejemplo n.º 2
0
 //methods
 void process_pdf_rgb(PdfRGB& color, ptree& node) {
   ptree stroke_node;
   stroke_node.put("red", color.r);
   stroke_node.put("green", color.g);
   stroke_node.put("blue", color.b);
   node.add_child("fill_color", stroke_node);
 }
Ejemplo n.º 3
0
template<typename T> static void
unparseElements(ptree& tree, const std::string& key, const T& elements)
{
    if (elements.size()) {
        ptree list;
        for (const auto& elem : elements)
           list.push_back({"", unparse(elem)});
        tree.add_child(key, list);
    }
}
Ejemplo n.º 4
0
void CompShapePolygon::writeToPropertyTree(ptree& propTree) const
{
    for ( size_t i = 0; i < getVertexCount(); ++i )
    {
        ptree vertexPropTree;
        vertexPropTree.add("x", m_vertices[i].x);
        vertexPropTree.add("y", m_vertices[i].y);
        propTree.add_child("polygon.vertex", vertexPropTree);
    }
}
Ejemplo n.º 5
0
 void process_page(PdfPageP page, ptree& node) {
   if (!page) return;
   node.put("number", page->GetNumber());
   node.put("rotate", page->GetRotate());
   PdfPageMapParams params;
   PdePageMapP page_map = page->AcquirePageMap(&params, nullptr, nullptr);
   if (page_map == nullptr)
     return;
   int num_elements = page_map->GetNumElements();
   for (auto i = 0; i < num_elements; i++) {
     ptree elem_tree;
     PdeElementP element = page_map->GetElement(i);
     process_pde_element(element, elem_tree);
     node.add_child("element", elem_tree);
   }
   page->ReleasePageMap();
 }
Ejemplo n.º 6
0
void CompPhysics::writeToPropertyTree(ptree& propTree) const
{
    // damping element

    if (getLinearDamping() != 0.0f || getAngularDamping() != 0.0f)
    {
        propTree.add("damping.linear", getLinearDamping());
        propTree.add("damping.angular", getAngularDamping());
    }

    if (m_localGravitationPoint != Vector2D(0.0f, 0.0f))
    {
        propTree.add("gravitationPoint.x", m_localGravitationPoint.x);
        propTree.add("gravitationPoint.y", m_localGravitationPoint.y);
    }

    if (isFixedRotation())
    {
        propTree.add("isFixedRotation", true);
    }

    if (isBullet())
    {
        propTree.add("isBullet", true);
    }

    for (ShapeInfoVec::const_iterator it = getShapeInfos().begin(); it != getShapeInfos().end(); ++it)
    {
        ptree shapePropTree;
        shapePropTree.add("comp_id", (*it)->compId);

        if ((*it)->density != 0)
            shapePropTree.add("density", (*it)->density);
        if ((*it)->friction != 0)
            shapePropTree.add("friction", (*it)->friction);
        if ((*it)->restitution != 0)
            shapePropTree.add("restitution", (*it)->restitution);

        if ((*it)->isSensor)
            shapePropTree.add("isSensor", true);
        propTree.add_child("shape", shapePropTree);
    }
}
Ejemplo n.º 7
0
  void process_pde_element(PdeElementP element, ptree& node) {
    if (!element) return;
    node.put("id", element->GetId());

    PdfRect bbox;
    element->GetBBox(&bbox);
    node.put("left", bbox.left);
    node.put("bottom", bbox.bottom);
    node.put("right", bbox.right);
    node.put("top", bbox.top);

    switch (element->GetType())
    {
    case kPdeText:
    case kPdeTextLine:
    case kPdeWord:
      process_pde_text((PdeText*)element, node);
      break;
    case kPdeImage:
      process_pde_image((PdeImage*)element, node);
      break;
    case kPdePath:
    case kPdeLine:
    case kPdeRect:
      process_pde_path((PdePath*)element, node);
      break;
    case kPdeTable:
      process_pde_table((PdeTable*)element, node);
      break;
    default:
      break;
    }
    auto num_childs = element->GetNumChildren();
    for (auto i = 0; i < num_childs; i++) {
      ptree elem_node;
      PdeElementP child = element->GetChild(i);
      process_pde_element(child, elem_node);
      node.add_child("element", elem_node);
    }
  }
Ejemplo n.º 8
0
string Account::executeGetRequest(ptree & root)
{
	string ret = MPAO::DEFAULT_JSON_ID;

	//MPA_LOG_TRIVIAL(trace, "" );

	ptree accountsChildren;

	vector<mpapo::Account> accounts = getAccounts();
	for (vector<mpapo::Account>::iterator it = accounts.begin(); it != accounts.end(); it++)
	{
		ptree accountPtree;
		accountPtree.put("id", (*it).id);
		accountPtree.put("version", (*it).version);
		accountPtree.put("name", (*it).name);
		accountPtree.put("balance", StrUtil::float2string((*it).balance));

		accountsChildren.push_back(std::make_pair("", accountPtree));
	}

	root.add_child("accounts", accountsChildren);

	return ret;
}
Ejemplo n.º 9
0
  void process_pdf_annot(PdfAnnotP annot, ptree& node) {
    PdfAnnotSubtype subtype = annot->GetSubtype();
    switch (subtype) {
    case kAnnotText:
      node.put("subtype", "Text"); break;
    case kAnnotLink:
      node.put("subtype", "Link"); break;
    case kAnnotFreeText:
      node.put("subtype", "FreeText"); break;
    case kAnnotLine:
      node.put("subtype", "Line"); break;
    case kAnnotSquare:
      node.put("subtype", "Square"); break;
    case kAnnotCircle:
      node.put("subtype", "Circle"); break;
    case kAnnotPolygon:
      node.put("subtype", "Polygon"); break;
    case kAnnotPolyLine:
      node.put("subtype", "Polyline"); break;
    case kAnnotHighlight:
      node.put("subtype", "Highlight"); break;
    case kAnnotUnderline:
      node.put("subtype", "Underline"); break;
    case kAnnotSquiggly:
      node.put("subtype", "Squiggly"); break;
    case kAnnotStrikeOut:
      node.put("subtype", "StrikeOut"); break;
    case kAnnotStamp:
      node.put("subtype", "Stamp"); break;
    case kAnnotCaret:
      node.put("subtype", "Caret"); break;
    case kAnnotInk:
      node.put("subtype", "Ink"); break;
    case kAnnotPopup:
      node.put("subtype", "Popup"); break;
    case kAnnotFileAttachment:
      node.put("subtype", "FileAttachment"); break;
    case kAnnotSound:
      node.put("subtype", "Sound"); break;
    case kAnnotMovie:
      node.put("subtype", "Movie"); break;
    case kAnnotWidget:
      node.put("subtype", "Widget"); break;
    case kAnnotScreen:
      node.put("subtype", "Screen"); break;
    case kAnnotPrinterMark:
      node.put("subtype", "PrinterMark"); break;
    case kAnnotTrapNet:
      node.put("subtype", "TrapNet"); break;
    case kAnnotWatermark:
      node.put("subtype", "WaterMark"); break;
    case kAnnot3D:
      node.put("subtype", "3D"); break;
    case kAnnotRedact:
      node.put("subtype", "Redact"); break;
    case kAnnotUnknown:
    default:
      node.put("subtype", "Unknown"); break;
    }

    PdfAnnotAppearance ap;
    annot->GetAppearance(&ap);
    ptree appearance;
    ptree fill_node;
    switch (ap.fill_type) {
    case kFillTypeNone: fill_node.put("fill_type", "none"); break;
    case kFillTypeSolid: fill_node.put("fill_type", "solid"); break;
    }
    process_pdf_rgb(ap.fill_color, fill_node);
    appearance.add_child("fill", fill_node);

    ptree border_node;
    switch (ap.border) {
    case kBorderSolid: border_node.put("border", "solid"); break;
    case kBorderDashed: border_node.put("border", "dashed"); break;
    case kBorderBeveled: border_node.put("border", "beveled"); break;
    case kBorderUnderline: border_node.put("border", "underline"); break;
    case kBorderInset: border_node.put("border", "inset"); break;
    }
    border_node.put("width", ap.border_width);
    process_pdf_rgb(ap.border_color, border_node);
    appearance.add_child("fill", border_node);
    appearance.put("opacity", ap.opacity);
    appearance.put("font_size", ap.font_size);

    node.add_child("appearance", appearance);
  }