Index: src/af/gr/xp/gr_EmbedManager.cpp =================================================================== RCS file: /cvsroot/abi/src/af/gr/xp/gr_EmbedManager.cpp,v retrieving revision 1.10 diff -u -5 -r1.10 gr_EmbedManager.cpp --- src/af/gr/xp/gr_EmbedManager.cpp 23 Aug 2005 06:58:26 -0000 1.10 +++ src/af/gr/xp/gr_EmbedManager.cpp 31 Dec 2005 15:36:31 -0000 @@ -458,5 +458,9 @@ */ bool GR_EmbedManager::isResizeable(UT_sint32 uid) { return true; } + +void GR_EmbedManager::setRun (UT_sint32 uid, fp_Run * run) +{ +} Index: src/af/gr/xp/gr_EmbedManager.h =================================================================== RCS file: /cvsroot/abi/src/af/gr/xp/gr_EmbedManager.h,v retrieving revision 1.8 diff -u -5 -r1.8 gr_EmbedManager.h --- src/af/gr/xp/gr_EmbedManager.h 24 Nov 2005 17:58:33 -0000 1.8 +++ src/af/gr/xp/gr_EmbedManager.h 31 Dec 2005 15:36:31 -0000 @@ -46,10 +46,11 @@ GR_Image * m_pPreview; UT_UTF8String m_sDataID; UT_uint32 m_iZoom; }; +class fp_Run; class ABI_EXPORT GR_EmbedManager { public: GR_EmbedManager(GR_Graphics * pG); virtual ~GR_EmbedManager(); @@ -73,10 +74,12 @@ virtual bool modify(UT_sint32 uid); virtual bool changeAPI(UT_sint32 uid, UT_uint32 api); virtual bool convert(UT_uint32 iConvType, UT_ByteBuf & pFrom, UT_ByteBuf & pTo); virtual bool isEdittable(UT_sint32 uid); virtual bool isResizeable(UT_sint32 uid); + virtual void setRun (UT_sint32 uid, fp_Run * run); + private: GR_Graphics * m_pG; UT_GenericVector m_vecSnapshots; }; Index: src/text/fmt/xp/fp_EmbedRun.cpp =================================================================== RCS file: /cvsroot/abi/src/text/fmt/xp/fp_EmbedRun.cpp,v retrieving revision 1.15 diff -u -5 -r1.15 fp_EmbedRun.cpp --- src/text/fmt/xp/fp_EmbedRun.cpp 1 Oct 2005 09:32:52 -0000 1.15 +++ src/text/fmt/xp/fp_EmbedRun.cpp 31 Dec 2005 15:36:32 -0000 @@ -107,10 +107,11 @@ { PD_Document * pDoc = getBlock()->getDocument(); m_iEmbedUID = getEmbedManager()->makeEmbedView(pDoc,m_iIndexAP,m_pszDataID); UT_DEBUGMSG((" EmbedRun %x UID is %d \n",this,m_iEmbedUID)); getEmbedManager()->initializeEmbedView(m_iEmbedUID); + getEmbedManager()->setRun (m_iEmbedUID, this); getEmbedManager()->loadEmbedData(m_iEmbedUID); } getEmbedManager()->setDefaultFontSize(m_iEmbedUID,atoi(pszSize)); if(getEmbedManager()->isDefault()) { Index: src/text/fmt/xp/fv_View.h =================================================================== RCS file: /cvsroot/abi/src/text/fmt/xp/fv_View.h,v retrieving revision 1.380 diff -u -5 -r1.380 fv_View.h --- src/text/fmt/xp/fv_View.h 3 Nov 2005 21:07:33 -0000 1.380 +++ src/text/fmt/xp/fv_View.h 31 Dec 2005 15:36:32 -0000 @@ -197,12 +197,14 @@ UT_Error cmdInsertHyperlink(const char* szName); fp_Run * getHyperLinkRun(PT_DocPosition pos); UT_Error cmdDeleteHyperlink(); bool cmdInsertMathML(const char * szFileName, PT_DocPosition pos); - bool cmdInsertEmbed(UT_ByteBuf * pBuf,PT_DocPosition pos,const char * szMime,const char * szProps); - bool cmdUpdateEmbed(UT_ByteBuf * pBuf, const char * szMime, const char * szProps); + bool cmdInsertEmbed(UT_ByteBuf * pBuf,PT_DocPosition pos,const char * szMime,const char * szProps); + bool cmdUpdateEmbed(UT_ByteBuf * pBuf, const char * szMime, const char * szProps); + bool cmdUpdateEmbed(fp_Run * pRun, UT_ByteBuf * pBuf, const char * szMime, const char * szProps); + bool cmdDeleteEmbed(fp_Run * pRun); bool cmdInsertLatexMath(UT_UTF8String & sLatex, UT_UTF8String & sMath); UT_Error cmdInsertTOC(void); Index: src/text/fmt/xp/fv_View_cmd.cpp =================================================================== RCS file: /cvsroot/abi/src/text/fmt/xp/fv_View_cmd.cpp,v retrieving revision 1.247 diff -u -5 -r1.247 fv_View_cmd.cpp --- src/text/fmt/xp/fv_View_cmd.cpp 15 Sep 2005 14:28:59 -0000 1.247 +++ src/text/fmt/xp/fv_View_cmd.cpp 31 Dec 2005 15:36:34 -0000 @@ -5379,10 +5379,117 @@ cmdSelect(pos1,pos1+1); return true; } /*! + * This method updates the Embedded object in pRun with a new + * object defined with the supplied bytebuffer, as well as strings to represent + * the MIME/Type and Object type. + * + * eg for a GNOME-Office chart we'll have MIME-TYPE "application/chart+xml" + * and sProps="embed-type: GOChart"; + */ +bool FV_View::cmdUpdateEmbed(fp_Run * pRun, UT_ByteBuf * pBuf, const char * szMime, const char * szProps) +{ + if(pRun == NULL || pRun->getType() != FPRUN_EMBED) + { + return false; + } + PT_DocPosition pos; + bool flag; + pRun->mapXYToPosition(0, 0, pos, flag, flag, flag); + cmdSelect (pos, pos+1); + const XML_Char * atts[7]={"dataid",NULL,"props",NULL,NULL,NULL,NULL}; + bool bRepeat = true; + UT_UTF8String sUID; + UT_uint32 uid = 0; + while(bRepeat) + { + uid = m_pDoc->getUID(UT_UniqueId::Image); + UT_UTF8String_sprintf(sUID,"%d",uid); + // + // Make sure data item is unique! + // + bRepeat = m_pDoc->getDataItemDataByName(sUID.utf8_str(),NULL,NULL,NULL); + } + atts[1] = sUID.utf8_str(); + const char * mimetypeGOChart = UT_strdup(szMime); + bool bres = m_pDoc->createDataItem(sUID.utf8_str(),false,pBuf,static_cast(const_cast(mimetypeGOChart)), NULL); + UT_return_val_if_fail(bres,false) + const XML_Char *cur_style = NULL; + getStyle(&cur_style); + if((cur_style != NULL) && (*cur_style) && (strcmp(cur_style,"None") != 0)) + { + atts[4] = PT_STYLE_ATTRIBUTE_NAME; + atts[5] = cur_style; + } + const XML_Char ** props = NULL; + + // Signal PieceTable Change + _saveAndNotifyPieceTableChange(); + m_pDoc->beginUserAtomicGlob(); + getCharFormat(&props,false,pos); + UT_UTF8String sFullProps; + UT_UTF8String sProp,sVal; + UT_UTF8String sProps; + sProps = szProps; + UT_sint32 i = 0; + if(props) + { + for(i=0;props[i] != NULL;i+=2) + { + sProp = props[i]; + // Filter out size properties + if (sProp == "width" || sProp == "height" || sProp == "descent" + || sProp == "ascent") + continue; + sVal = props[i+1]; + UT_DEBUGMSG(("Update Embed Prop %s val %s \n",props[i],props[i+1])); + UT_UTF8String_setProperty(sFullProps,sProp,sVal); + } + } + UT_DEBUGMSG(("Supplied props %s \n",sProps.utf8_str())); + UT_UTF8String_addPropertyString(sFullProps,sProps); + atts[3]=sFullProps.utf8_str(); + UT_DEBUGMSG(("Property String at Update Object is %s \n",atts[3])); + _deleteSelection(); + m_pDoc->insertObject(pos,PTO_Embed,atts,NULL); + m_pDoc->endUserAtomicGlob(); + + _generalUpdate(); + _restorePieceTableState(); + _updateInsertionPoint(); + cmdSelect(pos,pos+1); + return true; +} + +/*! + * This method deletes the Embedded object in pRun. + */ +bool FV_View::cmdDeleteEmbed(fp_Run * pRun) +{ + if(pRun == NULL || pRun->getType() != FPRUN_EMBED) + { + return false; + } + PT_DocPosition pos; + bool flag; + pRun->mapXYToPosition(0, 0, pos, flag, flag, flag); + cmdSelect (pos, pos+1); + _saveAndNotifyPieceTableChange(); + m_pDoc->beginUserAtomicGlob(); + _deleteSelection(); + m_pDoc->endUserAtomicGlob(); + + _generalUpdate(); + _restorePieceTableState(); + _updateInsertionPoint(); + cmdSelect(pos,pos); + return true; +} + +/*! * This method inserts an image at the strux of type iStruxType at the * point given by ipos. * This is useful for speficifying images as backgrounds to pages and cells. */ UT_Error FV_View::cmdInsertGraphicAtStrux(FG_Graphic* pFG, PT_DocPosition iPos, PTStruxType iStruxType)