/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new object, given a text representation (e.g., from the clipboard). /// </summary> /// <param name="cache">FDO cache representing the DB connection to use</param> /// <param name="sTextRep">Text representation of object</param> /// <param name="selDst">Provided for information in case it's needed to generate /// the new object (E.g., footnotes might need it to generate the proper sequence /// letter)</param> /// <param name="kodt">The object data type to use for embedding the new object</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public override Guid MakeObjFromText(FdoCache cache, string sTextRep, IVwSelection selDst, out int kodt) { if (m_decoratedEditingHelper != null) { return(m_decoratedEditingHelper.MakeObjFromText(cache, sTextRep, selDst, out kodt)); } return(base.MakeObjFromText(cache, sTextRep, selDst, out kodt)); }
public void TestTextRepOfObj_CmPicture() { CheckDisposed(); string internalPathOrig = null; string internalPathNew = null; try { using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true)) { ITsStrFactory factory = TsStrFactoryClass.Create(); EditingHelper editHelper = new EditingHelper(null); CmPicture pict = new CmPicture(m_fdoCache, filemaker.Filename, factory.MakeString("Test picture", m_fdoCache.DefaultVernWs), StringUtils.LocalPictures); Assert.IsNotNull(pict); Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath); Guid guid = Cache.GetGuidFromId(pict.Hvo); string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, guid); int objectDataType; guid = editHelper.MakeObjFromText(m_fdoCache, sTextRepOfObject, null, out objectDataType); CmPicture pictNew = new CmPicture(Cache, Cache.GetIdFromGuid(guid)); Assert.IsTrue(pict != pictNew); internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath; internalPathNew = pictNew.PictureFileRA.AbsoluteInternalPath; Assert.AreEqual(internalPathOrig, internalPathNew); Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk")); Assert.IsTrue(internalPathNew.EndsWith(".jpg")); AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString, pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString); Assert.AreEqual(pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO); } } finally { // TODO: When Undo works right, these should get cleaned up automatically if (internalPathOrig != null) { File.Delete(internalPathOrig); } if (internalPathNew != null) { File.Delete(internalPathNew); } } }
public void TestTextRepOfObj_CmPicture() { CheckDisposed(); string internalPathOrig = null; string internalPathNew = null; try { using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true)) { ITsStrFactory factory = TsStrFactoryClass.Create(); EditingHelper editHelper = new EditingHelper(null); CmPicture pict = new CmPicture(m_fdoCache, filemaker.Filename, factory.MakeString("Test picture", m_fdoCache.DefaultVernWs), StringUtils.LocalPictures); Assert.IsNotNull(pict); Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath); Guid guid = Cache.GetGuidFromId(pict.Hvo); string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, guid); int objectDataType; guid = editHelper.MakeObjFromText(m_fdoCache, sTextRepOfObject, null, out objectDataType); CmPicture pictNew = new CmPicture(Cache, Cache.GetIdFromGuid(guid)); Assert.IsTrue(pict != pictNew); internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath; internalPathNew = pictNew.PictureFileRA.AbsoluteInternalPath; Assert.AreEqual(internalPathOrig, internalPathNew); Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk")); Assert.IsTrue(internalPathNew.EndsWith(".jpg")); AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString, pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString); Assert.AreEqual(pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO); } } finally { // TODO: When Undo works right, these should get cleaned up automatically if (internalPathOrig != null) File.Delete(internalPathOrig); if (internalPathNew != null) File.Delete(internalPathNew); } }