예제 #1
0
        public void CreateOwnedObjects_Picture()
        {
            CheckDisposed();

            StTxtPara para = (StTxtPara)m_currentText.ParagraphsOS[0];

            ITsString     tss     = para.Contents.UnderlyingTsString;
            ITsStrFactory factory = TsStrFactoryClass.Create();

            using (DummyFileMaker fileMaker = new DummyFileMaker("junk.jpg", true))
            {
                CmPicture pict = new CmPicture(Cache, fileMaker.Filename,
                                               factory.MakeString("Test picture", Cache.DefaultVernWs),
                                               StringUtils.LocalPictures);
                pict.InsertORCAt(tss, 0, para.Hvo,
                                 (int)StTxtPara.StTxtParaTags.kflidContents, 0);
                tss = para.Contents.UnderlyingTsString;
                int cchOrigStringLength = tss.Length;

                NMock.DynamicMock mockIObjectMetaInfoProvider =
                    new DynamicMock(typeof(IObjectMetaInfoProvider));
                mockIObjectMetaInfoProvider.Strict = true;
                mockIObjectMetaInfoProvider.ExpectAndReturn(1, "PictureFolder", StringUtils.LocalPictures);
                para.CreateOwnedObjects(0, 1,
                                        (IObjectMetaInfoProvider)mockIObjectMetaInfoProvider.MockInstance);
                mockIObjectMetaInfoProvider.Verify();

                tss = para.Contents.UnderlyingTsString;
                Assert.AreEqual(cchOrigStringLength, tss.Length);
                string sObjData = tss.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptObjData);
                Guid   guid     = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));

                byte odt = Convert.ToByte(sObjData[0]);
                Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
                Assert.IsTrue(Cache.GetGuidFromId(pict.Hvo) != guid, "New guid was not inserted");
            }
        }
예제 #2
0
 /// <summary>
 /// This method is broken out so TeEditingHelper can override and adjust annotations.
 /// Probably anything else that does it will need to adjust annotations, too, but nothing
 /// else yet uses this kind of picture in an StText.
 /// </summary>
 protected virtual void InsertPictureOrc(CmPicture pict, ITsString tss, int ich, int hvoObj, int propTag, int ws)
 {
     pict.InsertORCAt(tss, ich, hvoObj, propTag, ws);
 }