// // AbiMathView_FileInsert // ------------------- // This is the function that we actually call to insert the MathML. // bool AbiMathView_FileInsert(AV_View* /*v*/, EV_EditMethodCallData* /*d*/) { // Get the current view that the user is in. XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView()); PD_Document * pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc()); char* pNewFile = NULL; bool bOK = s_AskForMathMLPathname(pFrame,&pNewFile); if (!bOK || !pNewFile) { UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %s \n",bOK,pNewFile)); return false; } UT_UTF8String sNewFile = pNewFile; // we own storage for pNewFile and must free it. FREEP(pNewFile); UT_DEBUGMSG(("fileInsertMathML: loading [%s]\n",sNewFile.utf8_str())); IE_Imp_MathML * pImpMathML = new IE_Imp_MathML(pDoc, pMathManager->EntityTable()); UT_Error errorCode = pImpMathML->importFile(sNewFile.utf8_str()); if (errorCode != UT_OK) { s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode); DELETEP(pImpMathML); return false; } /* Create the data item */ UT_uint32 uid = pDoc->getUID(UT_UniqueId::Image); UT_UTF8String sUID; UT_UTF8String_sprintf(sUID,"%d",uid); pDoc->createDataItem(sUID.utf8_str(), false, pImpMathML->getByteBuf(), "application/mathml+xml", NULL); /* Insert the MathML Object */ PT_DocPosition pos = pView->getPoint(); pView->cmdInsertMathML(sUID.utf8_str(),pos); DELETEP(pImpMathML); return true; }
// // AbiGOComponent_FileInsert // ------------------- // This is the function that we actually call to insert a component using // data from a file. // bool AbiGOComponent_FileInsert(G_GNUC_UNUSED AV_View* v, G_GNUC_UNUSED EV_EditMethodCallData *d) { // Get the current view that the user is in. XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); PD_Document * pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc()); char* pNewFile = NULL; IEGraphicFileType iegft = IEGFT_Unknown; bool bOK = s_AskForGOComponentPathname(pFrame,&pNewFile,&iegft); if (!bOK || !pNewFile) { UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %s \n",bOK,pNewFile)); return false; } UT_UTF8String sNewFile = pNewFile; // we own storage for pNewFile and must free it. FREEP(pNewFile); UT_DEBUGMSG(("fileInsertObject: loading [%s]\n",sNewFile.utf8_str())); char *mime_type = go_get_mime_type(sNewFile.utf8_str()); IE_Imp_Component * pImpComponent = new IE_Imp_Component(pDoc, mime_type); g_free(mime_type); UT_Error errorCode = pImpComponent->importFile(sNewFile.utf8_str()); DELETEP(pImpComponent); if(errorCode != UT_OK) { s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode); return false; } return true; }
void AP_UnixApp::errorMsgBadFile(XAP_Frame * pFrame, const char * file, UT_Error error) { s_CouldNotLoadFileMessage (pFrame, file, error); }