UT_Error OXML_Element_Math::addToPT(PD_Document * pDocument)
{
    UT_uint32 id;
    id = pDocument->getUID(UT_UniqueId::Math);
    std::string mID = UT_std_string_sprintf("MathLatex%d", id);
    std::string lID = UT_std_string_sprintf("LatexMath%d", id);

    UT_ByteBuf mathBuf;
    UT_ByteBuf latexBuf;
    mathBuf.ins(0,reinterpret_cast<const UT_Byte *>(m_MathML.c_str()),static_cast<UT_uint32>(m_MathML.length()));

    UT_UTF8String sMathml; // TO DO : use std::string after enabling it in ie_math_convert
    UT_UTF8String sLatex,sitex;
    sMathml.assign(m_MathML.c_str());
    
    pDocument->createDataItem(mID.c_str(),false,&mathBuf, "", NULL);   
  
    if(convertMathMLtoLaTeX(sMathml, sLatex) && convertLaTeXtoEqn(sLatex,sitex))
    {    
        // Conversion of MathML to LaTeX and the Equation Form suceeds
        latexBuf.ins(0,reinterpret_cast<const UT_Byte *>(sitex.utf8_str()),static_cast<UT_uint32>(sitex.size()));
        pDocument->createDataItem(lID.c_str(), false, &latexBuf, "", NULL);
    }
   
    const gchar *atts[5] = { NULL, NULL, NULL, NULL, NULL };
    atts[0] = PT_IMAGE_DATAID;
    atts[1] = static_cast<const gchar *>(mID.c_str());
    atts[2] = static_cast<const gchar *>("latexid");
    atts[3] = static_cast<const gchar *>(lID.c_str());
    if(!pDocument->appendObject(PTO_Math, atts))
        return UT_ERROR;

    return UT_OK;
}
Exemplo n.º 2
0
static void _png_write(png_structp png_ptr, png_bytep data, png_size_t length)
{
	UT_ByteBuf* pBB = (UT_ByteBuf*) png_get_io_ptr(png_ptr);

	pBB->ins(pBB->getLength(), data, length);
}